net.minecraftforge.event.entity.living.LivingEvent Java Examples
The following examples show how to use
net.minecraftforge.event.entity.living.LivingEvent.
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: ModuleEffectLeap.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@SubscribeEvent public void tickEntity(LivingEvent.LivingUpdateEvent event) { ItemStack stack = event.getEntityLiving().getHeldItemMainhand(); if (stack.isEmpty()) return; if (NBTHelper.hasNBTEntry(stack, "jump_timer")) { int x = NBTHelper.getInt(stack, "jump_timer", 0); if (x <= 0 || event.getEntityLiving().collidedVertically) { NBTHelper.removeNBTEntry(stack, "jump_timer"); NBTHelper.removeNBTEntry(stack, "jump_count"); NBTHelper.removeNBTEntry(stack, "max_jumps"); } else NBTHelper.setInt(stack, "jump_timer", x - 1); } }
Example #2
Source File: PlayerEventHandler.java From HexxitGear with GNU General Public License v3.0 | 6 votes |
@ForgeSubscribe public void playerUpdate(LivingEvent.LivingUpdateEvent event) { if (ticks > 16) { if (event.entityLiving != null && event.entityLiving instanceof EntityPlayer) { if (!event.entityLiving.worldObj.isRemote) return; EntityPlayer player = (EntityPlayer) event.entityLiving; String capeUrl = CapeHandler.getCapeUrl(player.username); if (capeUrl != null && !capeUrl.equals(player.cloakUrl)) { player.cloakUrl = capeUrl; FMLClientHandler.instance().getClient().renderEngine.obtainImageData(player.cloakUrl, null); } } ticks = 0; } ticks++; }
Example #3
Source File: EventHandlerEntity.java From Gadomancy with GNU Lesser General Public License v3.0 | 6 votes |
@SubscribeEvent public void on(LivingEvent.LivingUpdateEvent event) { if (event.entityLiving == null || !(event.entityLiving instanceof EntityPlayer)) return; EntityPlayer player = (EntityPlayer) event.entity; if ((event.entity.worldObj.provider.dimensionId == ModConfig.dimOuterId) && ((player.ticksExisted & 7) == 0) && ((player.capabilities.isFlying) || (Hover.getHover(player.getEntityId())))) { if(player.capabilities.isCreativeMode && MiscUtils.isANotApprovedOrMisunderstoodPersonFromMoreDoor(player)) return; player.capabilities.isFlying = false; Hover.setHover(player.getEntityId(), false); if (!((EntityPlayer) event.entityLiving).worldObj.isRemote) { String msg = StatCollector.translateToLocal("tc.break.fly"); if (player.capabilities.isCreativeMode) { msg += " " + StatCollector.translateToLocal("gadomancy.eldritch.noflyCreative"); } player.addChatMessage(new ChatComponentText(EnumChatFormatting.ITALIC + "" + EnumChatFormatting.GRAY + msg)); } } }
Example #4
Source File: PotionTimeSlow.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@SubscribeEvent(priority = EventPriority.HIGHEST) public void onTick(LivingEvent.LivingUpdateEvent event) { EntityLivingBase e = event.getEntityLiving(); if(e.isPotionActive(ModPotions.TIME_SLOW) && timeScale(e) == 0) { boolean shouldFreeze = true; if(e.isDead || e.getHealth() <= 0) { shouldFreeze = false; } if(e instanceof EntityDragon && ((EntityDragon) e).getPhaseManager().getCurrentPhase().getType() == PhaseList.DYING) { shouldFreeze = false; } if(shouldFreeze) { handleImportantEntityTicks(e); event.setCanceled(true); } } }
Example #5
Source File: ModuleEffectTimeSlow.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@SubscribeEvent public static void skipTick(LivingEvent.LivingUpdateEvent event) { if (event.getEntity().getEntityData().hasKey("skip_tick") && event.getEntity().getEntityData().hasKey("skip_tick_interval") && event.getEntity().getEntityData().hasKey("skip_tick_interval_save")) { int tickCountdown = event.getEntity().getEntityData().getInteger("skip_tick"); int tickInterval = event.getEntity().getEntityData().getInteger("skip_tick_interval"); if (tickInterval <= 0) { event.getEntity().getEntityData().setInteger("skip_tick_interval", event.getEntity().getEntityData().getInteger("skip_tick_interval_save")); if (tickCountdown <= 0) { event.getEntity().getEntityData().removeTag("skip_tick"); event.getEntity().getEntityData().removeTag("skip_tick_interval"); event.getEntity().getEntityData().removeTag("skip_tick_interval_save"); } else { event.getEntity().getEntityData().setInteger("skip_tick", --tickCountdown); event.setCanceled(true); } } else { event.getEntity().getEntityData().setInteger("skip_tick_interval", --tickInterval); } } }
Example #6
Source File: SquashableMod.java From CommunityMod with GNU Lesser General Public License v2.1 | 6 votes |
@SubscribeEvent public static void onLivingUpdate(LivingEvent.LivingUpdateEvent event) { EntityLivingBase entity = event.getEntityLiving(); if (entity.world.isRemote) { return; } if (entity.collidedHorizontally && isBeingPushedByPiston(entity)) { Squashable squashable = entity.getCapability(squashableCap(), null); if (squashable == null) { return; } double[] pistonDeltas = getPistonDeltas(entity); double pushedAngle = Math.atan2(pistonDeltas[2], pistonDeltas[0]); EnumFacing.Axis faceAxis = EnumFacing.fromAngle(entity.rotationYaw).getAxis(); EnumFacing.Axis pushAxis = EnumFacing.fromAngle(pushedAngle).getAxis(); EnumFacing.Axis squashAxis = faceAxis == pushAxis ? EnumFacing.Axis.Z : EnumFacing.Axis.X; squashable.squash(squashAxis); NETWORK.sendToAllTracking(new SquashEntityMessage(entity, squashAxis), entity); } }
Example #7
Source File: HorseStats.java From ForgeHax with MIT License | 5 votes |
@SubscribeEvent public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) { if (EntityUtils.isDrivenByPlayer(event.getEntity()) && getRidingEntity() instanceof AbstractHorse) { double newSpeed = speed.getAsDouble(); if (getLocalPlayer().isSprinting()) { newSpeed *= multiplier.getAsDouble(); } applyStats(jumpHeight.getAsDouble(), newSpeed); } }
Example #8
Source File: ItemElectricBootsTraveller.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent public void onPlayerJump(LivingEvent.LivingJumpEvent event) { if (event.entityLiving instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.entityLiving; boolean hasArmor = player.getCurrentArmor(0) != null && player.getCurrentArmor(0).getItem() == this; if (hasArmor) player.motionY += jumpBonus; } }
Example #9
Source File: HandlerEvents.java From burlapcraft with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent public void givePickaxeEvent(LivingEvent.LivingUpdateEvent event) { if (event.entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.entity; if (!player.inventory.hasItem(Items.diamond_pickaxe)) { player.inventory.addItemStackToInventory(new ItemStack(Items.diamond_pickaxe)); } } }
Example #10
Source File: CommonHandler.java From GokiStats with MIT License | 5 votes |
@SubscribeEvent public void playerJump(LivingEvent.LivingJumpEvent event) { if ((event.getEntityLiving() instanceof EntityPlayer)) { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); if (player.isSprinting()) { player.motionY *= 1.0F + Stats.LEAPER_V.getBonus(player); player.motionX *= 1.0F + Stats.LEAPER_H.getBonus(player); player.motionZ *= 1.0F + Stats.LEAPER_H.getBonus(player); } } }
Example #11
Source File: PotionTimeSlow.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
private static void stopEvent(LivingEvent event) { PotionEffect effect = ModPotions.TIME_SLOW.getEffect(event.getEntityLiving()); if (effect == null) return; if (timeScale(event.getEntity()) == 0) { event.setCanceled(true); event.setResult(Event.Result.DENY); } }
Example #12
Source File: PotionLowGrav.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent public void jump(LivingEvent.LivingJumpEvent event) { EntityLivingBase entity = event.getEntityLiving(); if (!entity.isPotionActive(this)) return; PotionEffect effect = entity.getActivePotionEffect(this); if (effect == null) return; entity.motionY = effect.getAmplifier() / 3.0; }
Example #13
Source File: Nyan.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@SubscribeEvent public static void onLivingUpdate(LivingEvent.LivingUpdateEvent event) { final Entity entity = event.getEntity(); final World world = entity.getEntityWorld(); if(world.isRemote) { return; } final MinecraftServer server = world.getMinecraftServer(); final NBTTagCompound data = entity.getEntityData(); if(data.hasUniqueId(NYANED_ENTITY_UUID_KEY)) { final Entity nyanedEntity = server.getEntityFromUuid(data.getUniqueId(NYANED_ENTITY_UUID_KEY)); if(nyanedEntity == null || nyanedEntity.isDead) { world.removeEntity(entity); return; } } if(data.getBoolean(HAS_NYAN_ENTITY_KEY)) { updateNyanEntity(server, (WorldServer) world, entity, data); } else if(!data.hasKey(HAS_NYAN_ENTITY_KEY)) { if(entity instanceof EntityPlayer || random.nextInt(10) == 0) { data.setBoolean(HAS_NYAN_ENTITY_KEY, true); updateNyanEntity(server, (WorldServer) world, entity, data); } else { data.setBoolean(HAS_NYAN_ENTITY_KEY, false); } } }
Example #14
Source File: ArenaManager.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent public void tickBoss(LivingEvent.LivingUpdateEvent event) { for (Arena arena : arenas) { if (event.getEntityLiving().getEntityId() != arena.getBossID()) continue; if (event.getEntityLiving().getDistance(arena.getCenter().getX() + 0.5, arena.getCenter().getY(), arena.getCenter().getZ() + 0.5) > arena.getRadius()) { event.getEntityLiving().move(MoverType.SELF, arena.getCenter().getX() + 0.5, arena.getCenter().getY() + 0.5, arena.getCenter().getZ() + 0.5); } } }
Example #15
Source File: AntiEffectsMod.java From ForgeHax with MIT License | 5 votes |
@SubscribeEvent public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) { EntityLivingBase living = event.getEntityLiving(); if (living.equals(MC.player)) { living.setInvisible(false); living.removePotionEffect(MobEffects.NAUSEA); living.removePotionEffect(MobEffects.INVISIBILITY); living.removePotionEffect(MobEffects.BLINDNESS); // removes particle effect FastReflection.Methods.EntityLivingBase_resetPotionEffectMetadata.invoke(living); } else if (no_particles.get()) { living.setInvisible(false); FastReflection.Methods.EntityLivingBase_resetPotionEffectMetadata.invoke(living); } }
Example #16
Source File: PigmenAngerCooldownService.java From ForgeHax with MIT License | 5 votes |
@SubscribeEvent public void onUpdate(LivingEvent.LivingUpdateEvent event) { if (event.getEntityLiving() instanceof EntityPigZombie) { // update pigmens anger level EntityPigZombie pigZombie = (EntityPigZombie) event.getEntityLiving(); if (pigZombie.isArmsRaised()) { FastReflection.Fields.EntityPigZombie_angerLevel.set(pigZombie, 400); } else if (pigZombie.isAngry()) { FastReflection.Fields.EntityPigZombie_angerLevel.set( pigZombie, FastReflection.Fields.EntityPigZombie_angerLevel.get(pigZombie) - 1); } } }
Example #17
Source File: LocalPlayerUpdateEventService.java From ForgeHax with MIT License | 5 votes |
@SubscribeEvent public void onUpdate(LivingEvent.LivingUpdateEvent event) { if (getWorld() != null && event.getEntity().getEntityWorld().isRemote && event.getEntityLiving().equals(getLocalPlayer())) { Event ev = new LocalPlayerUpdateEvent(event.getEntityLiving()); MinecraftForge.EVENT_BUS.post(ev); event.setCanceled(ev.isCanceled()); } }
Example #18
Source File: Events.java From ehacks-pro with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent public void onLiving(LivingEvent.LivingUpdateEvent event) { if (!cheatEnabled) { return; } ModuleController.INSTANCE.modules.stream().filter((mod) -> !(!mod.isActive() || Wrapper.INSTANCE.world() == null)).forEachOrdered((mod) -> { mod.onLiving(event); }); }
Example #19
Source File: DamagePopOffs.java From ehacks-pro with GNU General Public License v3.0 | 4 votes |
@Override public void onLiving(LivingEvent.LivingUpdateEvent event) { updateHealth(event.entityLiving); }
Example #20
Source File: PotionTimeSlow.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
@SubscribeEvent(priority = EventPriority.HIGHEST) public void onEntityJump(LivingEvent.LivingJumpEvent event) { stopEvent(event); }
Example #21
Source File: Module.java From ehacks-pro with GNU General Public License v3.0 | 4 votes |
public void onLiving(LivingEvent.LivingUpdateEvent event) { }
Example #22
Source File: ItemLegUpgrade.java From Cyberware with MIT License | 4 votes |
@SubscribeEvent public void playerJumps(LivingEvent.LivingJumpEvent event) { EntityLivingBase e = event.getEntityLiving(); ItemStack test = new ItemStack(this, 1, 0); if (CyberwareAPI.isCyberwareInstalled(e, test)) { int numLegs = 0; if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(CyberwareContent.cyberlimbs, 1, 2))) { numLegs++; } if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(CyberwareContent.cyberlimbs, 1, 3))) { numLegs++; } ICyberwareUserData ware = CyberwareAPI.getCapability(e); if (ware.usePower(test, this.getPowerConsumption(test))) { if (e.isSneaking()) { Vec3d vector = e.getLook(0.5F); double total = Math.abs(vector.zCoord + vector.xCoord); double jump = 0; if (jump >= 1) { jump = (jump + 2D) / 4D; } double y = vector.yCoord < total ? total : vector.yCoord; e.motionY += (numLegs * ((jump + 1) * y)) / 3F; e.motionZ += (jump + 1) * vector.zCoord * numLegs; e.motionX += (jump + 1) * vector.xCoord * numLegs; } else { e.motionY += numLegs * (0.2750000059604645D / 2D); } } } }
Example #23
Source File: EventHandlerWorld.java From Gadomancy with GNU Lesser General Public License v3.0 | 4 votes |
@SubscribeEvent(priority = EventPriority.LOWEST) public void on(LivingEvent.LivingUpdateEvent e) { if(!e.entityLiving.worldObj.isRemote) { lastUpdated = e.entityLiving; } }
Example #24
Source File: EntityEvents.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
public static boolean onLivingUpdateEvent(LivingEntity entity) { return MinecraftForge.EVENT_BUS.post(new LivingEvent.LivingUpdateEvent(entity)); }