Java Code Examples for net.minecraftforge.fml.common.eventhandler.EventPriority#LOWEST
The following examples show how to use
net.minecraftforge.fml.common.eventhandler.EventPriority#LOWEST .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContainerEventHandler.java From NotEnoughItems with MIT License | 6 votes |
@SubscribeEvent (priority = EventPriority.LOWEST, receiveCanceled = true)//We need to be called before JEI. public void onGuiMouseEventpre(MouseInputEvent.Pre event) { if (Mouse.getEventButton() == -1 || event.getGui() == null || !Mouse.getEventButtonState()) { return; } Point mouse = GuiDraw.getMousePosition(); int eventButton = Mouse.getEventButton(); if (JEIIntegrationManager.searchBoxOwner == EnumItemBrowser.JEI) { GuiTextFieldFilter fieldFilter = JEIIntegrationManager.getTextFieldFilter(); if (fieldFilter != null && fieldFilter.isMouseOver(mouse.x, mouse.y)) { if (eventButton == 0) { if (fieldFilter.isFocused() && (System.currentTimeMillis() - lastSearchBoxClickTime < 500)) {//double click NEIClientConfig.world.nbt.setBoolean("searchinventories", !SearchField.searchInventories()); NEIClientConfig.world.saveNBT(); lastSearchBoxClickTime = 0L; } else { lastSearchBoxClickTime = System.currentTimeMillis(); } } else if (eventButton == 1) { NEIClientConfig.setSearchExpression("", false); LayoutManager.searchField.setText("", false); } } } }
Example 2
Source File: ItemHeartUpgrade.java From Cyberware with MIT License | 6 votes |
@SubscribeEvent(priority = EventPriority.LOWEST) public void handleHurt(LivingHurtEvent event) { EntityLivingBase e = event.getEntityLiving(); if (!event.isCanceled() && CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this, 1, 2))) { float damageAmount = event.getAmount(); DamageSource damageSrc = event.getSource(); damageAmount = applyArmorCalculations(e, damageSrc, damageAmount); damageAmount = applyPotionDamageCalculations(e, damageSrc, damageAmount); damageAmount = Math.max(damageAmount - e.getAbsorptionAmount(), 0.0F); damageMedkit.put(e.getEntityId(), damageAmount); timesMedkit.put(e.getEntityId(), e.ticksExisted); } }
Example 3
Source File: CMMEventHandler.java From Custom-Main-Menu with MIT License | 6 votes |
@SubscribeEvent(priority = EventPriority.LOWEST) public void openGui(GuiOpenEvent event) { if (event.getGui() instanceof GuiMainMenu) { GuiCustom customMainMenu = CustomMainMenu.INSTANCE.config.getGUI("mainmenu"); if (customMainMenu != null) { event.setGui(customMainMenu); } } else if (event.getGui() instanceof GuiCustom) { GuiCustom custom = (GuiCustom) event.getGui(); GuiCustom target = CustomMainMenu.INSTANCE.config.getGUI(custom.guiConfig.name); if (target != custom) { event.setGui(target); } } }
Example 4
Source File: HandlerHammer.java From ExNihiloAdscensio with MIT License | 6 votes |
@SubscribeEvent(priority=EventPriority.LOWEST) public void hammer(BlockEvent.HarvestDropsEvent event) { if (event.getWorld().isRemote || event.getHarvester() == null || event.isSilkTouching()) return; ItemStack held = event.getHarvester().getHeldItemMainhand(); if (!isHammer(held)) return; List<ItemStack> rewards = HammerRegistry.getRewardDrops(event.getWorld().rand, event.getState(), ((IHammer) held.getItem()).getMiningLevel(held), event.getFortuneLevel()); if (rewards != null && rewards.size() > 0) { event.getDrops().clear(); event.setDropChance(1.0F); event.getDrops().addAll(rewards); } }
Example 5
Source File: EventsClient.java From Valkyrien-Skies with Apache License 2.0 | 6 votes |
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true) public void onDrawBlockHighlightEventLast(DrawBlockHighlightEvent event) { BlockPos pos = Minecraft.getMinecraft().objectMouseOver.getBlockPos(); Optional<PhysicsObject> physicsObject = ValkyrienUtils .getPhysicsObject(Minecraft.getMinecraft().world, pos); if (physicsObject.isPresent()) { RayTraceResult objectOver = Minecraft.getMinecraft().objectMouseOver; if (objectOver != null && objectOver.hitVec != null) { BufferBuilder buffer = Tessellator.getInstance().getBuffer(); buffer.xOffset = oldXOff; buffer.yOffset = oldYOff; buffer.zOffset = oldZOff; // wrapper.wrapping.renderer.inverseTransform(event.getPartialTicks()); // objectOver.hitVec = RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.lToWTransform, objectOver.hitVec); } } GL11.glPopMatrix(); }
Example 6
Source File: ForgeMain.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent(priority = EventPriority.LOWEST) public void onPlayerQuit(PlayerEvent.PlayerLoggedOutEvent event) { if (event.player.worldObj.isRemote) { return; } handleQuit((EntityPlayerMP) event.player); }
Example 7
Source File: ForgeMain.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent(priority = EventPriority.LOWEST) public void onPlayerQuit(PlayerEvent.PlayerLoggedOutEvent event) { if (event.player.world.isRemote) { return; } handleQuit((EntityPlayerMP) event.player); }
Example 8
Source File: ProxyClient.java From WearableBackpacks with MIT License | 5 votes |
@SubscribeEvent(priority=EventPriority.LOWEST) public void onRenderPlayerPre(RenderPlayerEvent.Pre event) { EntityPlayer player = event.getEntityPlayer(); if ((BackpackHelper.getBackpack(player) == null) || !player.isWearing(EnumPlayerModelParts.CAPE)) return; // Disable player rendering for players with equipped backpacks // by temporarily setting whether they are wearing it to false. setWearing(player, EnumPlayerModelParts.CAPE, false); _disabledCape = true; }
Example 9
Source File: ContainerEventHandler.java From NotEnoughItems with MIT License | 5 votes |
@SubscribeEvent (priority = EventPriority.LOWEST, receiveCanceled = true)//we need to be called after JEI has registered the key press and updated the search box. public void onKeyTypedPost(KeyboardInputEvent.Post event) { GuiTextFieldFilter fieldFilter = JEIIntegrationManager.getTextFieldFilter(); if (fieldFilter != null && JEIIntegrationManager.searchBoxOwner == EnumItemBrowser.JEI && isNEIInWorld() && fieldFilter.isFocused()) { NEIClientConfig.setSearchExpression(fieldFilter.getText(), false); LayoutManager.searchField.setText(fieldFilter.getText(), false); } }
Example 10
Source File: ModToolLeveling.java From TinkersToolLeveling with MIT License | 5 votes |
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true) public void onLivingHurt(LivingAttackEvent event) { // if it's cancelled it got handled by the battlesign (or something else. but it's a prerequisite.) if(!event.isCanceled()) { return; } if(event.getSource().isUnblockable() || !event.getSource().isProjectile() || event.getSource().getTrueSource() == null) { return; } // hit entity is a player? if(!(event.getEntity() instanceof EntityPlayer)) { return; } EntityPlayer player = (EntityPlayer) event.getEntity(); // needs to be blocking with a battlesign if(!player.isActiveItemStackBlocking() || player.getActiveItemStack().getItem() != TinkerMeleeWeapons.battleSign) { return; } // broken battlesign. if(ToolHelper.isBroken(player.getActiveItemStack())) { return; } // at this point we duplicated all the logic if the battlesign should reflect a projectile.. bleh. int xp = Math.max(1, Math.round(event.getAmount())); addXp(player.getActiveItemStack(), xp, player); }
Example 11
Source File: EventHandler.java From Signals with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent(priority = EventPriority.LOWEST) public void onDimensionChange(EntityTravelToDimensionEvent event){ CapabilityMinecartDestination cap = event.getEntity().getCapability(CapabilityMinecartDestination.INSTANCE, null); if(cap != null) { cap.travelingBetweenDimensions = !event.isCanceled(); } }
Example 12
Source File: BiomeGeneratorImplementation.java From malmo with MIT License | 5 votes |
@SubscribeEvent(priority = EventPriority.LOWEST) public void onBiomeGenInit(WorldTypeEvent.InitBiomeGens event) { // Negative one is flag value for normal world gen if (bparams.getBiome() == -1) return; GenLayer[] replacement = new GenLayer[2]; replacement[0] = new GenLayerConstant(bparams.getBiome()); replacement[1] = replacement[0]; event.setNewBiomeGens(replacement); }
Example 13
Source File: PotionCrash.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true) public void fall(LivingFallEvent e) { EntityLivingBase entitySource = e.getEntityLiving(); PotionEffect crash = entitySource.getActivePotionEffect(this); if (crash == null) return; PotionEffect jump = entitySource.getActivePotionEffect(MobEffects.JUMP_BOOST); float f = (jump == null) ? 0.0f : (jump.getAmplifier() + 1); float damage = MathHelper.clamp((e.getDistance() - 3.0f - f) * e.getDamageMultiplier() * 2, 0, 10f); float range = damage / 10f + Math.max(crash.getAmplifier(), 5); if (damage > 0.0f) { e.setDamageMultiplier(e.getDamageMultiplier() / (crash.getAmplifier() + 2)); List<EntityLivingBase> entities = entitySource.world.getEntitiesWithinAABB(EntityLivingBase.class, entitySource.getEntityBoundingBox().grow(range * 2)); entities.stream().filter(entity -> entity != entitySource && entity.onGround).forEach(entity -> { entity.attackEntityFrom(damageSourceEarthquake(entitySource), range); entity.motionY = range / 10.0; entity.velocityChanged = true; }); if (!entitySource.world.isRemote) for (BlockPos pos : BlockPos.getAllInBoxMutable( new BlockPos(entitySource.getPositionVector()) .add(-range, -2, -range), new BlockPos(entitySource.getPositionVector()) .add(range, 0, range))) { IBlockState state = entitySource.world.getBlockState(pos); if (state.isFullCube()) entitySource.world.playEvent(2001, pos.toImmutable(), Block.getStateId(state)); } } }
Example 14
Source File: ForgeMain.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent(priority = EventPriority.LOWEST) public void onPlayerQuit(PlayerEvent.PlayerLoggedOutEvent event) { if (event.player.worldObj.isRemote) { return; } handleQuit((EntityPlayerMP) event.player); }
Example 15
Source File: ExtraInventory.java From ForgeHax with MIT License | 5 votes |
@SubscribeEvent(priority = EventPriority.LOWEST) public void onGuiOpen(GuiOpenEvent event) { if (guiCloseGuard) { // do not close the gui when this mod executes closeWindow() event.setCanceled(true); } else if (event.getGui() instanceof GuiInventory) { // create a wrapper and replace the gui event.setGui(openedGui = createGuiWrapper((GuiInventory) event.getGui())); // server doesn't need to be informed the gui has been closed guiNeedsClose.set(false); } }
Example 16
Source File: CommonProxy.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent(priority = EventPriority.LOWEST) public static void registerRecipesLowest(RegistryEvent.Register<IRecipe> event) { GTLog.logger.info("Running late material handlers..."); OrePrefix.runMaterialHandlers(); DecompositionRecipeHandler.runRecipeGeneration(); RecyclingRecipes.init(); WoodMachineRecipes.init(); }
Example 17
Source File: MiscHandler.java From Cyberware with MIT License | 4 votes |
@SubscribeEvent(priority = EventPriority.LOWEST) @SideOnly(Side.CLIENT) public void handleCyberwareTooltip(ItemTooltipEvent event) { ItemStack stack = event.getItemStack(); if (CyberwareAPI.isCyberware(stack)) { ICyberware ware = CyberwareAPI.getCyberware(stack); Quality quality = ware.getQuality(stack); GameSettings settings = Minecraft.getMinecraft().gameSettings; if (settings.isKeyDown(settings.keyBindSneak)) { List<String> info = ware.getInfo(stack); if (info != null) { event.getToolTip().addAll(info); } ItemStack[][] reqs = ware.required(stack); if (reqs.length > 0) { String joined = ""; for (int i = 0; i < reqs.length; i++) { String toAdd = ""; for (int j = 0; j < reqs[i].length; j++) { if (j != 0) { toAdd += " " + I18n.format("cyberware.tooltip.joinerOr") + " "; } toAdd += I18n.format(reqs[i][j].getUnlocalizedName() + ".name"); } if (i != 0) { joined += I18n.format("cyberware.tooltip.joiner") + " "; } joined += toAdd; } event.getToolTip().add(ChatFormatting.AQUA + I18n.format("cyberware.tooltip.requires") + " " + joined); } event.getToolTip().add(ChatFormatting.RED + I18n.format("cyberware.slot." + ware.getSlot(stack).getName())); if (quality != null) { event.getToolTip().add(I18n.format(quality.getUnlocalizedName())); } } else { event.getToolTip().add(ChatFormatting.DARK_GRAY + I18n.format("cyberware.tooltip.shiftPrompt", Minecraft.getMinecraft().gameSettings.keyBindSneak.getDisplayName())); } } else if (stack.getItem() instanceof IDeconstructable) { if (event.getToolTip().size() > 1) { event.getToolTip().add(1, ChatFormatting.DARK_GRAY + I18n.format("cyberware.tooltip.canDeconstruct")); } else { event.getToolTip().add(ChatFormatting.DARK_GRAY + I18n.format("cyberware.tooltip.canDeconstruct")); } } }
Example 18
Source File: EventHandler.java From Signals with GNU General Public License v3.0 | 4 votes |
@SubscribeEvent(priority = EventPriority.LOWEST) public void onCapabilityAttachmentTile(AttachCapabilitiesEvent<TileEntity> event){ RailManager.getInstance().onTileEntityCapabilityAttachEvent(event); }
Example 19
Source File: TextureStitchHandler.java From AgriCraft with MIT License | 4 votes |
@SubscribeEvent(priority = EventPriority.LOWEST) @SuppressWarnings("unused") public static void onTextureStitch(TextureStitchEvent e) { CoreHandler.loadTextures(e.getMap()::registerSprite); PluginHandler.loadTextures(e.getMap()::registerSprite); }
Example 20
Source File: CommonProxy.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@SubscribeEvent(priority = EventPriority.LOWEST) public static void registerBlocksLast(RegistryEvent.Register<Block> event) { //last chance for mods to register their potion types is here PotionFluids.initPotionFluids(); }