protected void a(MobEffect mobeffect, boolean flag) { this.updateEffects = true; if (flag && !this.world.isStatic) { MobEffectList.byId[mobeffect.getEffectId()].a(this, this.aX(), mobeffect.getAmplifier()); MobEffectList.byId[mobeffect.getEffectId()].b(this, this.aX(), mobeffect.getAmplifier()); } }
public void addEffect(MobEffect mobeffect) { if (this.d(mobeffect)) { if (this.effects.containsKey(Integer.valueOf(mobeffect.getEffectId()))) { ((MobEffect) this.effects.get(Integer.valueOf(mobeffect.getEffectId()))).a(mobeffect); this.a((MobEffect) this.effects.get(Integer.valueOf(mobeffect.getEffectId())), true); } else { this.effects.put(Integer.valueOf(mobeffect.getEffectId()), mobeffect); this.a(mobeffect); } } }
public void a(NBTTagCompound nbttagcompound) { this.m(nbttagcompound.getFloat("AbsorptionAmount")); if (nbttagcompound.hasKey("Attributes") && this.world != null && !this.world.isStatic) { GenericAttributes.a( this.aX(), nbttagcompound.getList("Attributes"), this.world == null ? null : this.world.getLogger()); } if (nbttagcompound.hasKey("ActiveEffects")) { NBTTagList nbttaglist = nbttagcompound.getList("ActiveEffects"); for (int i = 0; i < nbttaglist.size(); ++i) { NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.get(i); MobEffect mobeffect = MobEffect.b(nbttagcompound1); this.effects.put(Integer.valueOf(mobeffect.getEffectId()), mobeffect); } } // CraftBukkit start if (nbttagcompound.hasKey("Bukkit.MaxHealth")) { NBTBase nbtbase = nbttagcompound.get("Bukkit.MaxHealth"); if (nbtbase.getTypeId() == 5) { this.getAttributeInstance(GenericAttributes.a) .setValue((double) ((NBTTagFloat) nbtbase).data); } else if (nbtbase.getTypeId() == 3) { this.getAttributeInstance(GenericAttributes.a) .setValue((double) ((NBTTagInt) nbtbase).data); } } // CraftBukkit end if (nbttagcompound.hasKey("HealF")) { this.setHealth(nbttagcompound.getFloat("HealF")); } else { NBTBase nbtbase = nbttagcompound.get("Health"); if (nbtbase == null) { this.setHealth(this.getMaxHealth()); } else if (nbtbase.getTypeId() == 5) { this.setHealth(((NBTTagFloat) nbtbase).data); } else if (nbtbase.getTypeId() == 2) { this.setHealth((float) ((NBTTagShort) nbtbase).data); } } this.hurtTicks = nbttagcompound.getShort("HurtTime"); this.deathTicks = nbttagcompound.getShort("DeathTime"); this.attackTicks = nbttagcompound.getShort("AttackTime"); }
protected void b(float f) { super.b(f); MobEffect mobeffect = this.getEffect(MobEffectList.JUMP); float f1 = mobeffect != null ? (float) (mobeffect.getAmplifier() + 1) : 0.0F; // CraftBukkit start float i = MathHelper.f(f - 3.0F - f1); if (i > 0) { EntityDamageEvent event = CraftEventFactory.callEntityDamageEvent( null, this, EntityDamageEvent.DamageCause.FALL, i); if (event.isCancelled()) { return; } i = (float) event.getDamage(); if (i > 0) { this.getBukkitEntity().setLastDamageCause(event); } } // CraftBukkit end if (i > 0) { if (i > 4) { this.makeSound("damage.fallbig", 1.0F, 1.0F); } else { this.makeSound("damage.fallsmall", 1.0F, 1.0F); } this.damageEntity(DamageSource.FALL, (float) i); int j = this.world.getTypeId( MathHelper.floor(this.locX), MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height), MathHelper.floor(this.locZ)); if (j > 0) { StepSound stepsound = Block.byId[j].stepSound; this.makeSound( stepsound.getStepSound(), stepsound.getVolume1() * 0.5F, stepsound.getVolume2() * 0.75F); } } }
public void b(NBTTagCompound nbttagcompound) { nbttagcompound.setFloat("HealF", this.getHealth()); nbttagcompound.setShort("Health", (short) ((int) Math.ceil((double) this.getHealth()))); nbttagcompound.setShort("HurtTime", (short) this.hurtTicks); nbttagcompound.setShort("DeathTime", (short) this.deathTicks); nbttagcompound.setShort("AttackTime", (short) this.attackTicks); nbttagcompound.setFloat("AbsorptionAmount", this.bn()); ItemStack[] aitemstack = this.getEquipment(); int i = aitemstack.length; int j; ItemStack itemstack; for (j = 0; j < i; ++j) { itemstack = aitemstack[j]; if (itemstack != null) { this.d.a(itemstack.D()); } } nbttagcompound.set("Attributes", GenericAttributes.a(this.aX())); aitemstack = this.getEquipment(); i = aitemstack.length; for (j = 0; j < i; ++j) { itemstack = aitemstack[j]; if (itemstack != null) { this.d.b(itemstack.D()); } } if (!this.effects.isEmpty()) { NBTTagList nbttaglist = new NBTTagList(); Iterator iterator = this.effects.values().iterator(); while (iterator.hasNext()) { MobEffect mobeffect = (MobEffect) iterator.next(); nbttaglist.add(mobeffect.a(new NBTTagCompound())); } nbttagcompound.set("ActiveEffects", nbttaglist); } }
public boolean d(MobEffect mobeffect) { if (this.getMonsterType() == EnumMonsterType.UNDEAD) { int i = mobeffect.getEffectId(); if (i == MobEffectList.REGENERATION.id || i == MobEffectList.POISON.id) { return false; } } return true; }
public void a(NBTTagCompound nbttagcompound) { this.m(nbttagcompound.getFloat("AbsorptionAmount")); if (nbttagcompound.hasKeyOfType("Attributes", 9) && this.world != null && !this.world.isStatic) { GenericAttributes.a(this.bc(), nbttagcompound.getList("Attributes", 10)); } if (nbttagcompound.hasKeyOfType("ActiveEffects", 9)) { NBTTagList nbttaglist = nbttagcompound.getList("ActiveEffects", 10); for (int i = 0; i < nbttaglist.size(); ++i) { NBTTagCompound nbttagcompound1 = nbttaglist.get(i); MobEffect mobeffect = MobEffect.b(nbttagcompound1); if (mobeffect != null) { this.effects.put(Integer.valueOf(mobeffect.getEffectId()), mobeffect); } } } if (nbttagcompound.hasKeyOfType("HealF", 99)) { this.setHealth(nbttagcompound.getFloat("HealF")); } else { NBTBase nbtbase = nbttagcompound.get("Health"); if (nbtbase == null) { this.setHealth(this.getMaxHealth()); } else if (nbtbase.getTypeId() == 5) { this.setHealth(((NBTTagFloat) nbtbase).h()); } else if (nbtbase.getTypeId() == 2) { this.setHealth((float) ((NBTTagShort) nbtbase).e()); } } this.hurtTicks = nbttagcompound.getShort("HurtTime"); this.deathTicks = nbttagcompound.getShort("DeathTime"); this.attackTicks = nbttagcompound.getShort("AttackTime"); }
public static int a(Collection var0) { int var1 = 3694022; if (var0.isEmpty()) { return 3694022; } else { float var2 = 0.0F; float var3 = 0.0F; float var4 = 0.0F; int var5 = 0; Iterator var6 = var0.iterator(); while (true) { MobEffect var7; do { if (!var6.hasNext()) { if (var5 == 0) { return 0; } var2 = var2 / (float) var5 * 255.0F; var3 = var3 / (float) var5 * 255.0F; var4 = var4 / (float) var5 * 255.0F; return (int) var2 << 16 | (int) var3 << 8 | (int) var4; } var7 = (MobEffect) var6.next(); } while (!var7.e()); int var8 = var7.a().g(); for (int var9 = 0; var9 <= var7.c(); ++var9) { var2 += (float) (var8 >> 16 & 255) / 255.0F; var3 += (float) (var8 >> 8 & 255) / 255.0F; var4 += (float) (var8 >> 0 & 255) / 255.0F; ++var5; } } } }
protected void b(float f) { super.b(f); MobEffect mobeffect = this.getEffect(MobEffectList.JUMP); float f1 = mobeffect != null ? (float) (mobeffect.getAmplifier() + 1) : 0.0F; int i = MathHelper.f(f - 3.0F - f1); if (i > 0) { this.makeSound(this.o(i), 1.0F, 1.0F); this.damageEntity(DamageSource.FALL, (float) i); int j = MathHelper.floor(this.locX); int k = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height); int l = MathHelper.floor(this.locZ); Block block = this.world.getType(j, k, l); if (block.getMaterial() != Material.AIR) { StepSound stepsound = block.stepSound; this.makeSound( stepsound.getStepSound(), stepsound.getVolume1() * 0.5F, stepsound.getVolume2() * 0.75F); } } }
public static List h(ItemStack var0) { ArrayList var1 = Lists.newArrayList(); var1.addAll(i(var0).b()); if (var0.hasTag() && var0.getTag().hasOfType("CustomPotionEffects", 9)) { NBTTagList var2 = var0.getTag().getList("CustomPotionEffects", 10); for (int var3 = 0; var3 < var2.getSize(); ++var3) { NBTTagCompound var4 = var2.getCompound(var3); MobEffect var5 = MobEffect.b(var4); if (var5 != null) { var1.add(var5); } } } return var1; }
protected void b(MobEffect mobeffect) { this.updateEffects = true; if (!this.world.isStatic) { MobEffectList.byId[mobeffect.getEffectId()].a(this, this.aX(), mobeffect.getAmplifier()); } }
protected void aJ() { Iterator iterator = this.effects.keySet().iterator(); while (iterator.hasNext()) { Integer integer = (Integer) iterator.next(); MobEffect mobeffect = (MobEffect) this.effects.get(integer); if (!mobeffect.tick(this)) { if (!this.world.isStatic) { iterator.remove(); this.b(mobeffect); } } else if (mobeffect.getDuration() % 600 == 0) { this.a(mobeffect, false); } } int i; if (this.updateEffects) { if (!this.world.isStatic) { if (this.effects.isEmpty()) { this.datawatcher.watch(8, Byte.valueOf((byte) 0)); this.datawatcher.watch(7, Integer.valueOf(0)); this.setInvisible(false); } else { i = PotionBrewer.a(this.effects.values()); this.datawatcher.watch( 8, Byte.valueOf((byte) (PotionBrewer.b(this.effects.values()) ? 1 : 0))); this.datawatcher.watch(7, Integer.valueOf(i)); this.setInvisible(this.hasEffect(MobEffectList.INVISIBILITY.id)); } } this.updateEffects = false; } i = this.datawatcher.getInt(7); boolean flag = this.datawatcher.getByte(8) > 0; if (i > 0) { boolean flag1 = false; if (!this.isInvisible()) { flag1 = this.random.nextBoolean(); } else { flag1 = this.random.nextInt(15) == 0; } if (flag) { flag1 &= this.random.nextInt(5) == 0; } if (flag1 && i > 0) { double d0 = (double) (i >> 16 & 255) / 255.0D; double d1 = (double) (i >> 8 & 255) / 255.0D; double d2 = (double) (i >> 0 & 255) / 255.0D; this.world.addParticle( flag ? "mobSpellAmbient" : "mobSpell", this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width, this.locY + this.random.nextDouble() * (double) this.length - (double) this.height, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, d0, d1, d2); } } }
public boolean d(MobEffect mobeffect) { return mobeffect.getEffectId() == MobEffectList.POISON.id ? false : super.d(mobeffect); }