@SubscribeEvent public void onTick(LivingEvent.LivingUpdateEvent event) { if (!event.getEntityLiving().getEntityWorld().isRemote && event.getEntityLiving() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); if (player.getFoodStats().needFood()) { for (ItemStack stack : player.inventory.mainInventory) { if (stack.getItem().equals(ItemRegistry.meatFeederItem)) { int filledAmount = ((MeatFeederItem) stack.getItem()).getFilledAmount(stack); if (filledAmount >= 200) { ((MeatFeederItem) stack.getItem()).drain(stack, 200); player.getFoodStats().setFoodLevel(player.getFoodStats().getFoodLevel() + 1); return; } } } } } }
public static EntityPlayer getPlayer(Event event) { if(event instanceof LivingEvent && ((LivingEvent)event).getEntity() instanceof EntityPlayer) return (EntityPlayer)((LivingEvent)event).getEntity(); if(event instanceof RenderGameOverlayEvent || event instanceof RenderWorldLastEvent || event instanceof ClientTickEvent) return HarshenCastle.proxy.getPlayer(); if(event instanceof PlayerTickEvent) return ((PlayerTickEvent)event).player; if(event instanceof PlayerEvent) return ((PlayerEvent)event).player; if(event instanceof net.minecraftforge.event.entity.player.PlayerEvent) return ((net.minecraftforge.event.entity.player.PlayerEvent)event).getEntityPlayer(); if(event instanceof PlayerPunchedEvent) return ((PlayerPunchedEvent)event).attacker; if(event instanceof LivingDropsEvent && isSourceFromPlayer(((LivingDropsEvent)event).getSource())) return getPlayerFromSource(((LivingDropsEvent)event).getSource()); return null; }
@SubscribeEvent public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) { if (!(event.getEntity() instanceof EntityPlayer)) { return; } EntityPlayer player = (EntityPlayer) event.getEntity(); if (player.isDead) { this.hueManager.adjustColor(new Color(255, 0, 0)); return; } BlockPos pos = player.getPosition(); Chunk chunk = this.world.getChunkFromBlockCoords(pos); Biome biome = chunk.getBiome(pos, this.world.getBiomeProvider()); String color = this.biomeMap.get(biome.getRegistryName().getResourcePath()); if (color != null) { this.hueManager.adjustColor(color); } }
@SubscribeEvent public void onUpdate(LivingEvent.LivingUpdateEvent ev) { EntityLivingBase entity = ev.getEntityLiving(); for (EntityEquipmentSlot slot : armor) { Map<UUID, AbilitySeries> associated = map.get(slot); ItemStack stack = entity.getItemStackFromSlot(slot); if (!stack.isEmpty() && RandoresItemData.hasData(stack) && stack.getItem() instanceof RandoresItemArmor && EmpoweredEnchantment.appliedTo(stack)) { RandoresWorldData.delegateVoid(new RandoresItemData(stack), def -> { associated.put(entity.getPersistentID(), def.getAbilitySeries()); def.getAbilitySeries().onArmorUpdate(entity); }, () -> {}); } else if (associated.containsKey(entity.getPersistentID())) { associated.remove(entity.getPersistentID()).onArmorCancel(entity); } } }
@SubscribeEvent public void maximumOvercluck(LivingEvent.LivingUpdateEvent event) { if (!event.getEntityLiving().worldObj.isRemote && event.getEntityLiving() instanceof EntityChicken) { EntityChicken chicken = (EntityChicken)event.getEntityLiving(); NBTTagCompound tag = chicken.getEntityData(); if (!chicken.isChild() && tag.hasKey(ItemGeneric.TAG_OVERCLUCK)) { int timer = tag.getInteger(ItemGeneric.TAG_OVERCLUCK); tag.setInteger(ItemGeneric.TAG_OVERCLUCK, --timer); if (--timer <= 0) { chicken.playSound(SoundEvents.ENTITY_CHICKEN_EGG, 1.0F, (chicken.worldObj.rand.nextFloat() - chicken.worldObj.rand.nextFloat()) * 0.2F + 1.0F); chicken.dropItem(Items.EGG, 1); timer = chicken.worldObj.rand.nextInt(60) + 900; tag.setInteger(ItemGeneric.TAG_OVERCLUCK, timer); } } } }
@SubscribeEvent public void stopJump(LivingEvent.LivingJumpEvent event) { EntityLivingBase living=event.getEntityLiving(); if ((living.getActivePotionEffect(TF2weapons.stun) != null && living.getActivePotionEffect(TF2weapons.bombmrs) == null) || living.getActivePotionEffect(TF2weapons.charging) != null || (living.getHeldItemMainhand() != null && living.getHeldItemMainhand().getItem() instanceof ItemMinigun && living.hasCapability(TF2weapons.WEAPONS_CAP, null) && living.getCapability(TF2weapons.WEAPONS_CAP, null).chargeTicks > 0)) { living.isAirBorne = false; living.motionY -= 0.5f; if (living.isSprinting()) { float f = living.rotationYaw * 0.017453292F; living.motionX += MathHelper.sin(f) * 0.2F; living.motionZ -= MathHelper.cos(f) * 0.2F; } } }
@SubscribeEvent public void updateEntity(final LivingEvent.LivingUpdateEvent event) { if (event.entity.worldObj.isRemote) { return; } if (event.entity.getEntityData().hasKey("CursedEarth")) { int c = event.entity.getEntityData().getInteger("CursedEarth"); if (c == 0) { event.entity.setDead(); NetworkHandler.sendParticle(event.entity.worldObj, "smoke", event.entity.posX, event.entity.posY + event.entity.height / 4.0f, event.entity.posZ, 0.0, 0.0, 0.0, false); } else { --c; event.entity.getEntityData().setInteger("CursedEarth", c); } } }
@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); } } }
@SubscribeEvent public void tickEntity(LivingEvent.LivingUpdateEvent event) { if (event.getEntityLiving().getEntityData().hasKey("jump_timer")) { int x = event.getEntityLiving().getEntityData().getInteger("jump_timer"); if (event.getEntityLiving().collidedVertically) { event.getEntityLiving().getEntityData().removeTag("jump_timer"); event.getEntityLiving().getEntityData().removeTag("jump_count"); return; } if (x <= 0) { event.getEntityLiving().getEntityData().removeTag("jump_timer"); event.getEntityLiving().getEntityData().removeTag("jump_count"); } else event.getEntityLiving().getEntityData().setInteger("jump_timer", x - 1); } }
@SubscribeEvent public void entityEvent(LivingEvent.LivingUpdateEvent event) { if (event.entity instanceof EntityPlayer) { if (((EntityPlayer) event.entity).getCurrentEquippedItem() != null) { canItemShowTess = (RFUtilities.TE_LOADED && (/*(((EntityPlayer) event.entity).getCurrentEquippedItem().getItem() instanceof ItemToolBase || ((EntityPlayer) event.entity).getCurrentEquippedItem().getItem() instanceof ItemMultimeter)) || (*/(EntityPlayer) event.entity).getCurrentEquippedItem().getItem() instanceof ItemDialer); } else { canItemShowTess = false; } } }
@SubscribeEvent public void entityEvent(LivingEvent.LivingUpdateEvent event) { if (event.entity instanceof EntityPlayer) { if (((EntityPlayer) event.entity).getCurrentEquippedItem() != null) { canItemShowTess = (RFUtilities.TE_LOADED && (((EntityPlayer) event.entity).getCurrentEquippedItem().getItem() instanceof ItemToolBase || ((EntityPlayer) event.entity).getCurrentEquippedItem().getItem() instanceof ItemMultimeter)) || ((EntityPlayer) event.entity).getCurrentEquippedItem().getItem() instanceof ItemDialer; } else { canItemShowTess = false; } } }
@SubscribeEvent @SuppressWarnings("unused") public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) { EntityLivingBase entity = event.getEntityLiving(); if(entity.getEntityWorld().isRemote) { return; } PotionTracker tracker = CapabilityPotionTracker.getPotionTracker(entity); if(tracker == null) { return; } Collection<PotionEffect> potions = entity.getActivePotionEffects(); tracker.updatePotionEffects(potions.stream() .filter(p -> p.getPotion() instanceof ISpecialPotion) .map(PotionEffect::getPotion).collect(Collectors.toList())); }
@SubscribeEvent public void onSkeletonUpdate(LivingEvent.LivingUpdateEvent event) { if (!(event.getEntityLiving() instanceof EntitySkeleton)) { return; } EntitySkeleton skeleton = (EntitySkeleton) event.getEntityLiving(); EntityAITasks tasks = skeleton.tasks; boolean containsOld = false; Iterator<EntityAITasks.EntityAITaskEntry> itr = tasks.taskEntries.iterator(); while (itr.hasNext()) { EntityAITasks.EntityAITaskEntry entry = itr.next(); if (entry.action instanceof EntityAIAttackRangedBow) { itr.remove(); } if (entry.action instanceof EntityAIAttackRanged) { containsOld = true; } } if (!containsOld) { tasks.addTask(4, new EntityAIAttackRanged(skeleton, 1.0D, 20, 15.0F)); } }
@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)); } } }
/** * Used for the Piston Boots to give them their amazing powers. * * @param event */ @SubscribeEvent public void onPlayerJump(LivingEvent.LivingJumpEvent event) { if (event.entity != null && event.entityLiving instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.entity; if (Wearing.isWearingBoots(player) && player.onGround) { ServerActions.pistonBootsJump(player); } } }
@SubscribeEvent public void onEntityJump(LivingEvent.LivingJumpEvent event) { if(event.entityLiving != null && event.entityLiving instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)event.entityLiving; if(player.getCurrentArmor(0) != null && player.getCurrentArmor(0).getItem() == AdvancedUtilitiesItems.runningShoes) { player.motionY+=0.05D; } if(player.getCurrentArmor(1) != null && player.getCurrentArmor(1).getItem() == AdvancedUtilitiesItems.steamLegs) { if(player.inventory.armorItemInSlot(1).stackTagCompound != null) { NBTTagCompound tag = player.inventory.armorItemInSlot(1).stackTagCompound; if(tag.getInteger("tankAmount") > 0) { player.motionY+=0.05D; } } } } }
@SubscribeEvent public void entityUpdate(LivingEvent.LivingUpdateEvent event) { if (event.entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.entity; if (player.getHeldItem() != null && player.getHeldItem().getItem() == CPCItems.hiltBlack) { player.addPotionEffect(new PotionEffect(Potion.blindness.id, 50, 1)); player.addPotionEffect(new PotionEffect(Potion.wither.id, 50, 1)); World world = player.worldObj; if (world.isRemote) { world.spawnParticle("reddust", player.posX, player.posY - 0.4D, player.posZ, 0.0D, 0.0D, 0.0D); if ((new Random()).nextInt(100) < 25) { world.spawnParticle("smoke", player.posX, player.posY - 0.4D, player.posZ, 0.0D, 0.0D, 0.0D); } } } else { player.removePotionEffect(Potion.wither.id); //player.removePotionEffect(Potion.blindness.id); } } }
@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++; }
@SubscribeEvent public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) { if(!event.entityLiving.worldObj.isRemote && event.entityLiving instanceof EntityZombie) { EntityZombie zombie = (EntityZombie)event.entityLiving; boolean currentItemIsCamera = zombie.getHeldItem() != null && zombie.getHeldItem().getItem() instanceof ItemCamera; if(currentItemIsCamera) { if(zombie.getRNG().nextFloat() < 0.003F) { EntityPhotoreal photo = new EntityPhotoreal(zombie.worldObj); photo.setLocationAndAngles(zombie.posX, zombie.posY + 1.62D, zombie.posZ, zombie.rotationYaw, zombie.rotationPitch); photo.setup(zombie.posX, zombie.posY + 1.62D, zombie.posZ, zombie.rotationYaw, zombie.rotationPitch, 860, 480); event.entityLiving.worldObj.spawnEntityInWorld(photo); } } } }
@SubscribeEvent public void onEntityUpdate(LivingEvent.LivingUpdateEvent e) { //POTION EFFECT //For poison immunity poison EntityLivingBase entity = e.entityLiving; if (entity.isPotionActive(ModPotions.poisonImmunity) && entity.isPotionActive(Potion.poison)) { entity.removePotionEffect(Potion.poison.getId()); } if (entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; World world = player.worldObj; //Purifying effect of crystal armor if (ArmorSetUtils.isWearingArmorOfType(player, ItemPrysmalArmor.class) && !world.isRemote && world.rand.nextInt(1000) <= ArmorSetUtils.getNumDonnedArmor(player, ItemPrysmalArmor.class, null)) { ThaumcraftApiHelper.addStickyWarpToPlayer(player, -1); } //Warp compounding effect from being in Xth'uoth int totalWarp = Thaumcraft.proxy.getPlayerKnowledge().getWarpTotal(player.getCommandSenderName()); if (player.dimension == ConfigHandler.DIM_ID && !world.isRemote && world.rand.nextInt(8000) <= totalWarp) { ThaumcraftApiHelper.addStickyWarpToPlayer(player, 1); } } }
@SubscribeEvent public void updateEntity(LivingEvent.LivingUpdateEvent event){ if(event.getEntity() instanceof EntityPlayer && event.getEntity().getAir() <= 300 - Config.ARMOR_TICKS_PER_LANOLIN){ // The entity is a player and is not at full air if(event.getEntity().isInsideOfMaterial(Material.WATER)){ for(int i = 0; i < 4; i++){ ItemStack armorPiece = ((EntityPlayer) event.getEntity()).inventory.armorInventory.get(i); if(armorPiece != ItemStack.EMPTY){ NBTTagCompound tags = armorPiece.getTagCompound(); if(tags != null && tags.hasKey("lanolin")){ // Found armor with lanolin. Reset air and remove a piece of lanolin. event.getEntity().setAir(300); if(tags.getInteger("lanolin") == 1){ // No more lanolin on this item, remove the tag tags.removeTag("lanolin"); } else{ tags.setInteger("lanolin", tags.getInteger("lanolin")-1); } armorPiece.setTagCompound(tags); ((EntityPlayer) event.getEntity()).inventory.armorInventory.set(i, armorPiece); break; } } } } } }
@SubscribeEvent public void playerUpdate(LivingEvent.LivingUpdateEvent event) { if (!event.getEntity().world.isRemote && event.getEntity() instanceof EntityPlayerMP) { final EntityPlayerMP player = (EntityPlayerMP) event.getEntity(); final Optional<IEnergy> optional = EnergyHandler.getEnergy(player); if (optional.isPresent()) { final IEnergy energy = optional.get(); energyRegen(player, energy); } } }
@SubscribeEvent public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) { if (EntityUtils.isDrivenByPlayer(event.getEntity()) && getRidingEntity() instanceof AbstractHorse) { IAttribute JUMP_STRENGTH = FastReflection.Fields.AbstractHorse_JUMP_STRENGTH.get(getRidingEntity()); IAttribute MOVEMENT_SPEED = FastReflection.Fields.SharedMonsterAttributes_MOVEMENT_SPEED.get(getRidingEntity()); ((EntityLivingBase) getRidingEntity()).getEntityAttribute(JUMP_STRENGTH).setBaseValue(jumpHeight.getAsDouble()); ((EntityLivingBase) getRidingEntity()).getEntityAttribute(MOVEMENT_SPEED).setBaseValue(speed.getAsDouble()); } }
@SubscribeEvent public void onUpdate(LivingEvent.LivingUpdateEvent event) { if(MC.world != null && event.getEntityLiving().equals(MC.player)) { Event ev = new LocalPlayerUpdateEvent(event.getEntityLiving()); MinecraftForge.EVENT_BUS.post(ev); event.setCanceled(ev.isCanceled()); } }
@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); } } }
@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); } }
@SubscribeEvent public void onLiving(LivingEvent.LivingUpdateEvent e) { if (e.getEntityLiving() instanceof EntityEnderman) { EntityEnderman enderman = (EntityEnderman) e.getEntityLiving(); if (enderman.getAttackTarget() == null) { MCPrivateUtils.setEndermanScreaming(enderman, false); } } }
@SubscribeEvent public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) { if(Clef.config.zombiesCanUseInstruments == 1 && !event.getEntityLiving().world.isRemote && event.getEntityLiving() instanceof EntityZombie) { EntityZombie zombie = (EntityZombie)event.getEntityLiving(); if(zombie.getRNG().nextFloat() < 0.004F &&ItemInstrument.getUsableInstrument(zombie) != null && getTrackPlayedByPlayer(zombie) == null) { Track track = Clef.eventHandlerServer.findTrackByBand("zombies"); if(track != null) { if(track.zombies.add(zombie.getEntityId())) { Clef.channel.sendToAll(new PacketPlayingTracks(track)); } } else { TrackFile randTrack = AbcLibrary.tracks.get(zombie.getRNG().nextInt(AbcLibrary.tracks.size())); track = new Track(RandomStringUtils.randomAscii(IOUtil.IDENTIFIER_LENGTH), "zombies", randTrack.md5, randTrack.track, false); if(track.getTrack().trackLength > 0) { track.playAtProgress(zombie.getRNG().nextInt(track.getTrack().trackLength)); } Clef.eventHandlerServer.tracksPlaying.add(track); track.zombies.add(zombie.getEntityId()); Clef.channel.sendToAll(new PacketPlayingTracks(track)); } } } }
@SubscribeEvent public static void applyEffectBacon(LivingEvent.LivingUpdateEvent e) { if (e.getEntity() instanceof OinkBacon) { OinkBacon piggy = (OinkBacon) e.getEntity(); if (baconGlow) { piggy.addPotionEffect(new PotionEffect(MobEffects.GLOWING, 5, 10, false, false)); } } }
@SubscribeEvent public static void applyEffectSausage(LivingEvent.LivingUpdateEvent e) { if (e.getEntity() instanceof OinkSausage) { OinkSausage piggy = (OinkSausage) e.getEntity(); if (sausageGlow) { piggy.addPotionEffect(new PotionEffect(MobEffects.GLOWING, 5, 10, false, false)); } } }
@SubscribeEvent public static void onEntityUpdate(LivingEvent.LivingUpdateEvent e) { if (e.getEntityLiving() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) e.getEntityLiving(); if (e.getEntityLiving().isPotionActive(TheOink.oinkFly)) { player.capabilities.allowFlying = true; }else{ player.capabilities.isFlying = false; player.capabilities.allowFlying = false; } } }
@SubscribeEvent public void onLivingJump(LivingEvent.LivingJumpEvent event) { if (event.getEntityLiving() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); PossessivePlayer possessivePlayer = PossessHandler.get(player); if (possessivePlayer != null) { for (EntityPossessHandler handler : PossessHandler.getPossessHandlers(possessivePlayer.getPossessing())) { handler.onJump(possessivePlayer, player); } } } }
@SubscribeEvent public void entTick(final LivingEvent.LivingUpdateEvent event) { if (event.entity.worldObj.isRemote) { return; } ItemAngelRing.foundItem = true; if (!XUHelper.hasPersistantNBT(event.entity) || !XUHelper.getPersistantNBT(event.entity).hasKey("XU|Flying", 1)) { return; } Byte t = XUHelper.getPersistantNBT(event.entity).getByte("XU|Flying"); t = (byte)(t - 1); if (t == 0) { XUHelper.getPersistantNBT(event.entity).removeTag("XU|Flying"); if (event.entity instanceof EntityPlayerMP) { final EntityPlayerMP entityPlayer = (EntityPlayerMP)event.entity; ItemAngelRing.removePlayer((EntityPlayer)entityPlayer); if (!entityPlayer.capabilities.isCreativeMode) { entityPlayer.capabilities.allowFlying = false; entityPlayer.capabilities.isFlying = false; entityPlayer.sendPlayerAbilities(); } } } else { XUHelper.getPersistantNBT(event.entity).setByte("XU|Flying", (byte)t); } }
@SubscribeEvent public void Siege(final LivingEvent.LivingUpdateEvent event) { if (event.entity.worldObj.isRemote) { return; } if (EventHandlerSiege.SiegeParticipants.isEmpty()) { if (event.entityLiving.getEntityData().hasKey("Siege")) { event.entity.setDead(); endSiege(event.entity.worldObj, true); } return; } if (event.entityLiving.worldObj.rand.nextInt(1000) == 0) { checkPlayers(); } if (event.entityLiving.worldObj.provider.dimensionId != 1) { return; } if (event.entityLiving instanceof EntityMob && ((EntityMob)event.entityLiving).getAttackTarget() == null && event.entityLiving.getEntityData().hasKey("Siege")) { final int i = EventHandlerSiege.rand.nextInt(EventHandlerSiege.SiegeParticipants.size()); final EntityPlayer player = event.entityLiving.worldObj.getPlayerEntityByName((String)EventHandlerSiege.SiegeParticipants.get(i)); if (player != null) { ((EntityMob)event.entityLiving).setAttackTarget((EntityLivingBase)player); ((EntityMob)event.entityLiving).setTarget((Entity)player); } else { EventHandlerSiege.SiegeParticipants.remove(i); } } if (event.entityLiving instanceof EntityPlayer) { final EntityPlayer player2 = (EntityPlayer)event.entityLiving; if (player2.motionY == 0.0 && player2.fallDistance == 0.0f && !player2.onGround && !player2.isOnLadder() && !player2.isInWater() && player2.ridingEntity == null) { player2.attackEntityFrom(DamageSource.generic, 0.5f); } } }
@SubscribeEvent public void livingUpdate(LivingEvent.LivingUpdateEvent event) { if (event.getEntity() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.getEntity(); if (player.getHeldItemMainhand() != ItemStack.EMPTY) { if (player.getHeldItemMainhand().getItem() == Items.APPLE) { player.setFire(5); } } } }
@SideOnly(Side.SERVER) @SubscribeEvent public void onPlayerUpdateEvent(LivingEvent.LivingUpdateEvent e) { if(!(e.entity instanceof EntityPlayer)) { return; } EntityPlayer player = (EntityPlayer) e.entity; if(player.lastTickPosX != player.posX || player.lastTickPosZ != player.posZ) { TileCore tile = AgeOfKingdom.serverProxy.getClosestTileCore(player); String groundName = tile.getAokName().equals("null") ? "Non" : tile.getAokName(); AgeOfKingdom.channel.sendTo(new GuiMainScreenMessage(GuiMainScreenMessage.Type.SEND_LAND_NAME, groundName), (EntityPlayerMP) player); } }
@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); } } }
@SubscribeEvent public void ai(LivingEvent.LivingUpdateEvent event) { if (event.getEntityLiving() instanceof EntityPlayer) return; EntityLivingBase potentialPotion = event.getEntityLiving().getRevengeTarget(); if (potentialPotion != null && potentialPotion.isPotionActive(this)) { event.getEntityLiving().setRevengeTarget(null); } }
@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; }
@SubscribeEvent public void onPlayerLivingUpdate(LivingEvent.LivingUpdateEvent event) { if (active) { if (!(event.getEntityLiving() instanceof EntityPlayerSP)) return; if (((EntityPlayerSP) event.getEntityLiving()).movementInput instanceof ControllerMovementInput) return; Minecraft.getMinecraft().player.movementInput = new ControllerMovementInput(Minecraft.getMinecraft().gameSettings); Minecraft.getMinecraft().mouseHelper = new ControllerMouseHelper(); } }