@SubscribeEvent public void livingUpdate(LivingUpdateEvent event) { World world = event.getEntity().getEntityWorld(); if (world.isRemote) { return; } if (world.getTotalWorldTime() % 20 != 0) { return; } if (!(event.getEntity() instanceof EntityLiving)) { return; } if (event.getEntity().getTags().contains(NemesisSystem.TAG_BODY_GUARD)) { handleBodyGuardUpdate(event); } }
@SubscribeEvent public void livingUpdate(LivingUpdateEvent event) { /*if (!event.entityLiving.worldObj.isRemote) { if (event.entityLiving instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.entityLiving; if (player.dimension == ModDimensions.CUBE_ID) { CubeManager manager; if ((manager = CubeManager.getInstance()) != null) { manager.checkPosition((EntityPlayerMP) player); } } } }*/ }
@SubscribeEvent public void entityUpdate(LivingUpdateEvent event){ if(event.getEntityLiving() !=null){ if(event.getEntityLiving() instanceof EntityPlayer){ EntityPlayer player = (EntityPlayer)event.getEntityLiving(); updateWings(player); ExtendedPlayer exPlayer = ExtendedPlayerProvider.getExtendedPlayer(player); if(exPlayer !=null){ if(exPlayer.hasFailed && player.isEntityAlive()){ ItemUtil.givePlayerItem(player, new ItemStack(ModBlocks.failureBlock)); exPlayer.hasFailed = false; } } } } }
@SubscribeEvent public void onEntityUpdate(LivingUpdateEvent event) { if (event.entityLiving.isPotionActive(ItemRegistry1.customPotion)) { if (event.entityLiving.worldObj.rand.nextInt(20) == 0) { } if (event.entityLiving.isPotionActive(ItemRegistry1.customPotion2)) { if (event.entityLiving.worldObj.rand.nextInt(20) == 0) { } } if (event.entityLiving.isPotionActive(ItemRegistry1.customPotion3)) { if (event.entityLiving.worldObj.rand.nextInt(20) == 0) { } } if (event.entityLiving.isPotionActive(ItemRegistry1.customPotion4)) { if (event.entityLiving.worldObj.rand.nextInt(20) == 0) { } } } }
@SubscribeEvent public void onZombieVillagerDeath(LivingUpdateEvent event) { if (!event.getEntity().getEntityWorld().isRemote && event.getEntity().isDead && event.getEntity() instanceof EntityZombieVillager) { EntityLiving convertTo = null; if (hasRoyalEffect(event)) { convertTo = new EntityVillageLord(event.getEntity().world); } else if (hasLoyalEffect(event)) { convertTo = new EntityGuard(event.getEntity().world); } if (convertTo == null) { return; } if (handlePossibleConversion((EntityLiving) event.getEntity(), convertTo)) { removeVillager(event); } } }
@SubscribeEvent public void onLivingTick(LivingUpdateEvent event) { PotionEffect effect = event.getEntityLiving().getActivePotionEffect(PotionRegistry.REDSTONE_NEEDLE); if (effect == null) return; if (effect.getAmplifier() >= 4) { if (event.getEntityLiving() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); if (player.capabilities.isFlying && !player.isCreative()) player.capabilities.isFlying = false; } } }
@SubscribeEvent public void onLivingUpdate(LivingUpdateEvent event) { if (!(event.entityLiving instanceof EntityPlayer)) { return; } EntityPlayer player = (EntityPlayer) event.entityLiving; int i = 0; for (int j = 0; j < player.inventory.armorInventory.length; ++j) { if (player.inventory.armorInventory[j] != null && player.inventory.armorInventory[j].getItem() instanceof ItemTeambattleArmor) { int k = ((ItemTeambattleArmor) player.inventory.armorInventory[j].getItem()).damageReduceAmount; i += k; } } player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0F + i); if (player.getHealth() > player.getMaxHealth()) { player.setHealth(player.getMaxHealth()); } }
@SubscribeEvent public void onEntityUpdate (LivingUpdateEvent event) { final EntityLivingBase entity = event.getEntityLiving(); if (entity instanceof EntitySheep) { final ModifiableAttributeInstance instance = (ModifiableAttributeInstance) entity.getEntityAttribute(SharedMonsterAttributes.ARMOR); final boolean hasModifier = instance.hasModifier(sheepArmor); final boolean isSheared = ((EntitySheep) entity).getSheared(); if (!isSheared && !hasModifier) { instance.applyModifier(sheepArmor); } else if (isSheared && hasModifier) { instance.removeModifier(sheepArmor); } } }
/** Handle all player updates */ @SubscribeEvent public void onPlayerUpdate(LivingUpdateEvent e) { if(e.getEntity() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)e.getEntity(); // serverside things if (!player.worldObj.isRemote) { EntityPlayerMP mp = (EntityPlayerMP)player; // repair tools and armor handleRepair(mp); // handle potion things handleServerPotionEffects(mp); // handle portal things handleTeleportation(mp); } // common things onStepBootsWear(player); } }
@SubscribeEvent public void onLivingUpdate(LivingUpdateEvent event) { if (event.entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)event.entity; ItemStack itemstack = player.getHeldItem(); if (player.ticksExisted % 2 == 0) { if (mc.getSoundHandler().isSoundPlaying(FNAFSoundHandler.deathStatic) && !(mc.currentScreen instanceof GuiGameOver)) { mc.getSoundHandler().stopSound(FNAFSoundHandler.deathStatic); } } } }
@SubscribeEvent // Previously had event.entityLiving (uses EntityLivingBase) instead of Entity public void onLivingUpdateEvent(LivingUpdateEvent event) { // if (event.entity != null && event.entity instanceof EntityPlayer) { // EntityPlayer player = (EntityPlayer) event.entity; if (event.entityLiving != null && event.entityLiving instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.entityLiving; if (DragonPlayer.get(player).isDragon()) { if (!event.entityLiving.worldObj.isRemote) { player.capabilities.allowFlying = true; ItemDragonEgg.applyAbilities(player, false); // player.sendPlayerAbilities(); // 7/2/15 Removed as a test, don't think this is needed! } else { player.capabilities.allowFlying = true; ItemDragonEgg.applyAbilities(player, true); } } } }
@SubscribeEvent public void onLivingUpdate(LivingUpdateEvent livingUpdate) { Entity ent = livingUpdate.entityLiving; if(!ent.getEntityData().hasKey(KEY_DESPAWN_TIME)) { return; } if(fieldpersistenceRequired == null) { ent.getEntityData().removeTag(KEY_DESPAWN_TIME); return; } long despawnTime = ent.getEntityData().getLong(KEY_DESPAWN_TIME); if(despawnTime <= livingUpdate.entity.worldObj.getTotalWorldTime() ) { try { fieldpersistenceRequired.setBoolean(livingUpdate.entityLiving, false); ent.getEntityData().removeTag(KEY_DESPAWN_TIME); } catch (Exception e) { Log.warn("BlockPoweredSpawner.onLivingUpdate: Error occured allowing entity to despawn: " + e); ent.getEntityData().removeTag(KEY_DESPAWN_TIME); } } }
@SubscribeEvent public void onEntityUpdate(LivingUpdateEvent event) { if (event.getEntityLiving() instanceof EntityPlayer) {//some of the items need an off switch EntityPlayer player = (EntityPlayer) event.getEntityLiving(); final IPlayerExtendedProperties data = CapabilityRegistry.getPlayerProperties(player); if (data.isStepHeightOn()) { if (player.isSneaking()) { //make sure that, when sneaking, dont fall off!! player.stepHeight = 0.9F; } else { player.stepHeight = 1.0F + (1F / 16F);//PATH BLOCKS etc are 1/16th downif MY feature turns this on, then do it } } else if (data.doForceStepOff()) { //otherwise, dont automatically force it off. only force it off the once if player is toggling FROM on TO off with my feature player.stepHeight = 0.5F; } //else leave it alone (allows other mods to turn it on without me disrupting) } }
@SubscribeEvent public void onPlayerUpdate(LivingUpdateEvent event) { if (event.getEntityLiving() instanceof EntityPlayer == false) { return; } EntityPlayer player = (EntityPlayer) event.getEntityLiving(); IPlayerExtendedProperties props = CapabilityRegistry.getPlayerProperties(player); int flyingTicks = props.getFlyingTimer();//TICKS NOT SECONDS if (flyingTicks > 1) {//it decays at 1 not zero so that we only set flying False once, not constantly. avoids having boolean flag props.setFlyingTimer(props.getFlyingTimer() - 1); setFlying(player); } else if (flyingTicks == 1) { //times up! only 1/20 of a second left props.setFlyingTimer(0);//skip ahead to zero setNonFlying(player); } //else it is zero. so this is the same as null/undefined/ so player has never eaten or it wore off. }
@SubscribeEvent public void onEntityUpdate(LivingUpdateEvent event) { EntityLivingBase playerRider = event.getEntityLiving(); if (playerRider != null && playerRider instanceof EntityPlayer && playerRider.getEntityData().hasKey(KEY_MOUNTENTITY) && playerRider.isRiding() == false) { World world = playerRider.getEntityWorld(); int eid = playerRider.getEntityData().getInteger(KEY_MOUNTENTITY); if (eid >= 0) { Entity maybeHorse = world.getEntityByID(eid); if (maybeHorse != null && maybeHorse.isDead == false) { //if we were dismounted from an ender pearl, get and consume this entity id, wiping it out for next time if (playerRider.startRiding(maybeHorse, true)) { playerRider.getEntityData().removeTag(KEY_MOUNTENTITY);//.setInteger(KEY_MOUNTENTITY, -1); } } } } }
@SubscribeEvent public void onEntityUpdate(LivingUpdateEvent event) { //check if NOT holding this harm if (event.getEntityLiving() instanceof EntityPlayer == false) { return; } EntityPlayer player = (EntityPlayer) event.getEntityLiving(); //Ticking ItemStack armor = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); int level = 0; if (armor.isEmpty() == false && EnchantmentHelper.getEnchantments(armor) != null && EnchantmentHelper.getEnchantments(armor).containsKey(this)) { //todo: maybe any armor? level = EnchantmentHelper.getEnchantments(armor).get(this); } if (level > 0) { turnReachOn(player); } else { //was it on before, do we need to do an off hit if (player.getEntityData().hasKey(NBT_REACH_ON) && player.getEntityData().getBoolean(NBT_REACH_ON)) { turnReachOff(player); } } }
@SubscribeEvent public void onEntityUpdate(LivingUpdateEvent event) { if (event.getEntity() instanceof EntityPlayer) { EntityPlayer p = (EntityPlayer) event.getEntity(); ItemStack armor = p.getItemStackFromSlot(EntityEquipmentSlot.FEET); int level = 0; if (armor.isEmpty() == false && EnchantmentHelper.getEnchantments(armor) != null && EnchantmentHelper.getEnchantments(armor).containsKey(this)) { //todo: maybe any armor? level = EnchantmentHelper.getEnchantments(armor).get(this); } if (level > 0) { setLiquidWalk(p); } } }
@SubscribeEvent public void onEntityUpdate(LivingUpdateEvent event) { if (event.getEntity() instanceof EntityPlayer) { EntityPlayer p = (EntityPlayer) event.getEntity(); ItemStack armorStack = getFirstArmorStackWithEnchant(p); if (armorStack.isEmpty()) { return; } //if you are on the ground (or not airborne, should be same thing if ((p.isAirBorne == false || p.onGround) && UtilNBT.getItemStackNBTVal(armorStack, NBT_USES) > 0) { //you have landed on the ground, dont count previous jumps UtilNBT.setItemStackNBTVal(armorStack, NBT_USES, 0); } } }
@SubscribeEvent public void entityLivingEvent(LivingUpdateEvent event) { EntityLivingBase entityLiving = event.entityLiving; if(!(entityLiving instanceof IEntityNonOxygenBreather)) { return; } if (entityLiving.ticksExisted % 100 == 0) { CelestialBody body; boolean isInSealedArea = OxygenUtil.isAABBInBreathableAirBlock(entityLiving); if (entityLiving.worldObj.provider instanceof IGalacticraftWorldProvider) { body = ((IGalacticraftWorldProvider)entityLiving.worldObj.provider).getCelestialBody(); } else { body = GalacticraftCore.planetOverworld; } if(!((IEntityNonOxygenBreather)entityLiving).canBreatheIn(body.atmosphere, isInSealedArea)) { // should I add these events about suffocation that GC does? entityLiving.attackEntityFrom(DamageSourceAR.dsSuffocate, 1); } } }
@SuppressWarnings("rawtypes") private void handleChunkEntityBB(LivingUpdateEvent event) { //System.out.println("handling bounding boxes"); Entity entity = event.entity; AxisAlignedBB entityBB = entity.getEntityBoundingBox(); if (entityBB != null) { //System.out.println("bounding box is not null"); List chunkEntities = entity.worldObj.getEntitiesWithinAABB(ChunkEntity.class, entityBB); Iterator iterator = chunkEntities.iterator(); while (iterator.hasNext()) { ChunkEntity chunk = (ChunkEntity)iterator.next(); chunk.handleEntity(event.entity); } } }
@SubscribeEvent public void update( LivingUpdateEvent event ) { if ( !( event.entity instanceof EntityPlayer ) ) { return; } EntityPlayer player = ( EntityPlayer ) event.entity; ItemStack chestplate = player.inventory.armorItemInSlot( 2 ); if ( !player.capabilities.isFlying && chestplate != null && chestplate.getItem() == ComponentEquipment.items.chestplate ) { try { Class c = Class.forName( "thaumcraft.common.items.armor.Hover" ); Method m = c.getMethod( "handleHoverArmor", EntityPlayer.class, ItemStack.class ); m.invoke( null, player, chestplate ); } catch ( Exception exception ) { exception.printStackTrace(); } } }
@SubscribeEvent public void onLivingUpdate(LivingUpdateEvent event) { if (event.getEntityLiving() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); float step = PlayerTracker.getPlayerData(player).getAbilities().getStepAssist(); float steps = 0.5F * (step + 1); if (steps > player.stepHeight) { player.stepHeight = steps; player.getEntityData().setBoolean("HasRewardStepAssist", true); } if (step == 0.5F && player.getEntityData().hasKey("HasRewardStepAssist")) { player.getEntityData().removeTag("HasRewardStepAssist"); player.stepHeight = 0.5F; } } }
@SubscribeEvent public void onTick(LivingUpdateEvent event) { if(!event.entity.worldObj.isRemote && event.entity.worldObj.provider.dimensionId == this.dimId) { IAtmosphere atmosType = getAtmosphereType(event.entity); if(event.entity instanceof EntityPlayer && atmosType != prevAtmosphere.get(event.entity)) { PacketHandler.sendToPlayer(new PacketAtmSync(atmosType.getUnlocalizedName(), getAtmospherePressure(event.entity)), (EntityPlayer)event.entity); prevAtmosphere.put((EntityPlayer)event.entity, atmosType); } if(atmosType.canTick()) { AtmosphereEvent event2 = new AtmosphereEvent.AtmosphereTickEvent(event.entity, atmosType); MinecraftForge.EVENT_BUS.post(event2); if(!event2.isCanceled() && !Configuration.bypassEntity.contains(event.entity.getClass())) atmosType.onTick((EntityLivingBase)event.entityLiving); } } }
@SubscribeEvent public void playerTick(LivingUpdateEvent event) { if(event.entity.worldObj.isRemote && event.entity.posY > 260 && event.entity.posY < 270 && event.entity.motionY < -.1) { RocketEventHandler.destroyOrbitalTextures(event.entity.worldObj); } if(event.entity.isInWater()) { if(AtmosphereType.LOWOXYGEN.isImmune(event.entityLiving)) event.entity.setAir(300); } if(!event.entity.worldObj.isRemote && event.entity.worldObj.getTotalWorldTime() % 20 ==0 && event.entity instanceof EntityPlayer) { if(DimensionManager.getInstance().getDimensionProperties(event.entity.worldObj.provider.dimensionId).getName().equals("Luna") && event.entity.getDistanceSq(67, 80, 2347) < 512 ) { ((EntityPlayer)event.entity).triggerAchievement(ARAchivements.weReallyWentToTheMoon); } } }
@SubscribeEvent public void darkRealm(LivingUpdateEvent event){ if(event.getEntityLiving() instanceof EntityPlayerMP){ WorldServer worldServer = (WorldServer)event.getEntityLiving().world; EntityPlayerMP player = (EntityPlayerMP)event.getEntityLiving(); if(player.dimension == ACLib.omothol_id && player.posY <= 0){ player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 80, 255)); player.addPotionEffect(new PotionEffect(MobEffects.BLINDNESS, 20)); player.mcServer.getPlayerList().transferPlayerToDimension(player, ACLib.dark_realm_id, new TeleporterDarkRealm(worldServer)); // player.addStat(ACAchievements.enter_dark_realm, 1); } } if(event.getEntityLiving().dimension == ACLib.dark_realm_id && !(event.getEntityLiving() instanceof EntityPlayer)){ Random rand = new Random(); if(ACConfig.particleEntity) event.getEntityLiving().world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, event.getEntityLiving().posX + (rand.nextDouble() - 0.5D) * event.getEntityLiving().width, event.getEntityLiving().posY + rand.nextDouble() * event.getEntityLiving().height, event.getEntityLiving().posZ + (rand.nextDouble() - 0.5D) * event.getEntityLiving().width, 0,0,0); } }
@SubscribeEvent public void onEntityUpdate(LivingUpdateEvent event) { if(event.entityLiving == null){return;} if(event.entityLiving instanceof EntityPlayer) { SpellGhost.onPlayerUpdate(event); SpellRegistry.tickSpellTimer((EntityPlayer)event.entityLiving); } PotionRegistry.tickSlowfall(event); PotionRegistry.tickWaterwalk(event); //PotionRegistry.tickLavawalk(event); //PotionRegistry.tickFrost(event); }
private static void tickLiquidWalk(LivingUpdateEvent event, Block liquid) { World world = event.entityLiving.worldObj; if(world.getBlockState(event.entityLiving.getPosition().down()).getBlock() == liquid && world.isAirBlock(event.entityLiving.getPosition()) && event.entityLiving.motionY < 0) { if(event.entityLiving instanceof EntityPlayer) //now wait here, since if we are a sneaking player we cancel it { EntityPlayer p = (EntityPlayer)event.entityLiving; if(p.isSneaking()) return;//let them slip down into it } event.entityLiving.motionY = 0;//stop falling event.entityLiving.onGround = true; //act as if on solid ground event.entityLiving.setAIMoveSpeed(0.1F);//walking and not sprinting is this speed } }
public static void tickSlowfall(LivingUpdateEvent event) { if(event.entityLiving.isPotionActive(PotionRegistry.slowfall)) { if(event.entityLiving instanceof EntityPlayer) //now wait here, since if we are a sneaking player we cancel { EntityPlayer p = (EntityPlayer)event.entityLiving; if(p.isSneaking()) { return;//so fall normally for now } } //else: so we are either a non-sneaking player, or a non player entity //a normal fall seems to go up to 0, -1.2, -1.4, -1.6, then flattens out at -0.078 if(event.entityLiving.motionY < 0) { event.entityLiving.motionY *= ModSpells.cfg.slowfallSpeed; event.entityLiving.fallDistance = 0f; //for no fall damage } } }
@SubscribeEvent public void removeNullPotionEffects(LivingUpdateEvent event) { EntityLivingBase entityLiving = event.entityLiving; if (entityLiving.ticksExisted < 20) { Collection potionEffects = entityLiving.getActivePotionEffects(); Iterator iterator = potionEffects.iterator(); while (iterator.hasNext()) { PotionEffect potionEffectToRemove = (PotionEffect) iterator.next(); if (Potion.potionTypes[potionEffectToRemove.getPotionID()] == null) { ProjectZuluLog.info("Found Invalid Potion Effect. Removing Effect with ID %s.", potionEffectToRemove.getPotionID()); iterator.remove(); } } } }
@SubscribeEvent public void mobUseJetpack(LivingUpdateEvent evt) { if (!evt.entityLiving.worldObj.isRemote && evt.entityLiving instanceof EntityMob) { ItemStack armor = evt.entityLiving.getEquipmentInSlot(3); if (armor != null && armor.getItem() instanceof ItemJetpack) { ItemJetpack jetpackItem = (ItemJetpack) armor.getItem(); Jetpack jetpack = jetpackItem.getPack(armor); if (jetpack != null) { if (jetpack instanceof JetpackPotato || MathHelper.RANDOM.nextInt(3) == 0) { jetpack.setMobMode(armor); jetpack.flyUser(evt.entityLiving, armor, jetpackItem, false); } } if (evt.entityLiving.posY > evt.entityLiving.worldObj.getActualHeight() + 10) { evt.entityLiving.attackEntityFrom(DamageSource.generic, 80); } } } }
@SubscribeEvent public void onLivingUpdate(LivingUpdateEvent event) { if (event.entityLiving.worldObj.isRemote) {return;} if (event.entityLiving instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)(event.entityLiving); ItemStack[] gear = TravellersGearAPI.getExtendedInventory(player); for (int i=0; i<gear.length; i++) { if (gear[i] != null) { ArtifactEventHandler.doTriggerUpdate(gear[i], player); ArtifactEventHandler.doTriggerEquippedUpdate(gear[i], player); } } } }
@SubscribeEvent public void onLivingUpdate(LivingUpdateEvent event) { if (event.entityLiving.worldObj.isRemote) {return;} if (event.entityLiving instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)(event.entityLiving); IInventory baubles = BaublesApi.getBaubles(player); for (int i=0; i<baubles.getSizeInventory(); i++) { ItemStack stack = baubles.getStackInSlot(i); if (stack != null) { ArtifactEventHandler.doTriggerUpdate(stack, player); ArtifactEventHandler.doTriggerEquippedUpdate(stack, player); } } } }
@SubscribeEvent public void onLivingUpdate(LivingUpdateEvent event) { if (event.entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.entity; ZSSPlayerInfo.get(player).onUpdate(); if (player.motionY < -0.25D) { boolean flag = player.getHeldItem() != null && player.getHeldItem().getItem() == ZSSItems.rocsFeather; if (flag || (player.getCurrentArmor(ArmorIndex.WORN_HELM) != null && player.getCurrentArmor(ArmorIndex.WORN_HELM).getItem() == ZSSItems.maskDeku)) { player.motionY = -0.25D; player.fallDistance = 0.0F; } } } if (event.entity instanceof EntityLivingBase) { ZSSEntityInfo.get((EntityLivingBase) event.entity).onUpdate(); } if (event.entity instanceof EntityVillager) { ZSSVillagerInfo.get((EntityVillager) event.entity).onUpdate(); } }
@SubscribeEvent public void onEntityUpdate(LivingUpdateEvent event){ if(Compat.bm && event.entityLiving != null && event.entityLiving instanceof EntityPlayer && !event.entityLiving.worldObj.isRemote){ EntityPlayer player = (EntityPlayer)event.entityLiving; String name = player.getDisplayName(); if(player.isPotionActive(DarkPotions.bloodSeal)){ try { if (lastLP.containsKey(name)) { if (SoulNetworkHandler.getCurrentEssence(name) > lastLP.get(name)) SoulNetworkHandler.setCurrentEssence(name, lastLP.get(name)); else lastLP.put(name, SoulNetworkHandler.getCurrentEssence(name)); } else lastLP.put(name, SoulNetworkHandler.getCurrentEssence(name)); } catch(Throwable e){ Compat.bm = false; } } else if(lastLP.containsKey(name)) lastLP.remove(name); } }
@SubscribeEvent public void onEntityUpdate(LivingUpdateEvent event) { if(event.entityLiving.isPotionActive(ModPotions.bleeding)) { if(event.entityLiving.worldObj.rand.nextInt(40) == 0) { event.entityLiving.attackEntityFrom(new DamageSource("allthethings:bleeding"), 1); event.entityLiving.worldObj.spawnParticle("splash", event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, 1.0D, 1.0D, 1.0D); } } else if(event.entityLiving.isPotionActive(ModPotions.leadPoison)) { if(event.entityLiving.worldObj.rand.nextInt(40) == 0) { event.entityLiving.attackEntityFrom(new DamageSource("allthethings:leadPoison"), 2); if (event.entityLiving instanceof EntityPlayer) { ((EntityPlayer)event.entityLiving).addExhaustion(20.0F); } event.entityLiving.worldObj.spawnParticle("splash", (event.entityLiving.posX+0.5F)-0.27000001072883606D, (event.entityLiving.posY+0.7F)+0.2199999988079071D, (event.entityLiving.posZ+0.5F), 0.0D, 0.0D, 0.0D); } } else if(event.entityLiving.isPotionActive(ModPotions.lessening)) { if(event.entityLiving instanceof EntityPlayerMP && ((EntityPlayerMP) event.entityLiving).theItemInWorldManager.getGameType() == GameType.CREATIVE) return; else if(event.entityLiving.getHealth() <= 1 || event.entityLiving.getEntityAttribute(SharedMonsterAttributes.maxHealth).getAttributeValue() <= 2.0) { event.entityLiving.attackEntityFrom(new DamageSource("allthethings:lessening"), 9001); } } }
@SubscribeEvent public void removeNullPotionEffects(LivingUpdateEvent event) { EntityLivingBase entityLiving = event.entityLiving; if (entityLiving.ticksExisted < 20) { Collection potionEffects = entityLiving.getActivePotionEffects(); Iterator iterator = potionEffects.iterator(); try { while (iterator.hasNext()) { PotionEffect potionEffectToRemove = (PotionEffect) iterator.next(); if (Potion.potionTypes[potionEffectToRemove.getPotionID()] == null) { ProjectZuluLog.info("Found Invalid Potion Effect. Removing Effect with ID %s.", potionEffectToRemove.getPotionID()); iterator.remove(); } } } catch(ArrayIndexOutOfBoundsException exception) { ProjectZuluLog.info("Error encountered when removing Effect"); } } }
@SubscribeEvent public void onLivingUpdate(LivingUpdateEvent event) { EntityLivingBase entity = event.entityLiving; ItemStack heldItem = entity.getHeldItem(); ItemStack tool = ItemHelper.getSelectedTool(heldItem); ItemStack previousTool = this.previousTool.containsKey(entity) ? this.previousTool.get(entity) : null; if (!ItemStack.areItemStacksEqual(previousTool, tool)) { if (previousTool != null) { event.entityLiving.getAttributeMap().removeAttributeModifiers(previousTool.getAttributeModifiers()); } if (tool != null) { event.entityLiving.getAttributeMap().applyAttributeModifiers(tool.getAttributeModifiers()); } try { this.previousTool.put(entity, tool == null ? null : tool.copy()); } catch (ConcurrentModificationException c) { SlimevoidCore.console(CoreLib.MOD_ID, "Phew, that was close! onLivingUpdate could not update " + entity + "'s previous item.", LogLevel.WARNING.ordinal()); } } }
@SubscribeEvent public void onLivingUpdate(LivingUpdateEvent livingUpdate) { Entity ent = livingUpdate.getEntityLiving(); if (!ent.getEntityData().hasKey(KEY_SPAWNED_BY_POWERED_SPAWNER)) { return; } if (fieldpersistenceRequired == null) { ent.getEntityData().removeTag(KEY_SPAWNED_BY_POWERED_SPAWNER); return; } long spawnTime = ent.getEntityData().getLong(KEY_SPAWNED_BY_POWERED_SPAWNER); long livedFor = livingUpdate.getEntity().world.getTotalWorldTime() - spawnTime; if (livedFor > SpawnerConfig.poweredSpawnerDespawnTimeSeconds.get() * 20) { try { fieldpersistenceRequired.setBoolean(livingUpdate.getEntityLiving(), false); ent.getEntityData().removeTag(KEY_SPAWNED_BY_POWERED_SPAWNER); } catch (Exception e) { Log.warn("BlockPoweredSpawner.onLivingUpdate: Error occured allowing entity to despawn: " + e); ent.getEntityData().removeTag(KEY_SPAWNED_BY_POWERED_SPAWNER); } } }
@SubscribeEvent public void onEntityUpdate(LivingUpdateEvent event) { EntityLivingBase living = event.getEntityLiving(); if(living instanceof IBurnInDay && living.world.isDaytime() && !living.world.isRemote && !living.isChild() && ((IBurnInDay)living).shouldBurn() && living.getBrightness() > 0.5F && living.getRNG().nextFloat() * 30.0F < (living.getBrightness() - 0.4F) * 2.0F && living.world.canSeeSky(new BlockPos(living.posX, living.posY + (double)living.getEyeHeight(), living.posZ))) { boolean flag = true; ItemStack itemstack = living.getItemStackFromSlot(EntityEquipmentSlot.HEAD); if (!itemstack.isEmpty()) { if (itemstack.isItemStackDamageable()) { itemstack.setItemDamage(itemstack.getItemDamage() + living.getRNG().nextInt(2)); if (itemstack.getItemDamage() >= itemstack.getMaxDamage()) { living.renderBrokenItemStack(itemstack); living.setItemStackToSlot(EntityEquipmentSlot.HEAD, ItemStack.EMPTY); } } flag = false; } if (flag) { living.setFire(8); } } }
@SubscribeEvent public void onEntityTick(LivingUpdateEvent event) { int i = 0; for(EntityEquipmentSlot slot : EntityEquipmentSlot.values()) if(slot.getSlotType() == Type.ARMOR && allArmour.contains(event.getEntityLiving().getItemStackFromSlot(slot).getItem())) i++; if(i == 4) { event.getEntityLiving().addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, 225, 0, false, false)); event.getEntityLiving().addPotionEffect(new PotionEffect(MobEffects.SPEED, 30, 0, false, false)); event.getEntityLiving().addPotionEffect(new PotionEffect(HarshenPotions.potionSoulless, 330, 0, false, false)); } }