From 6c09066e224ac85b8a6464eaf8f53edfeb4beda4 Mon Sep 17 00:00:00 2001 From: Nate Mortensen Date: Mon, 1 Jul 2013 06:03:00 -0500 Subject: Update CraftBukkit to 1.6.1 --- .../java/net/minecraft/server/EntityZombie.java | 186 +++++++++++++-------- 1 file changed, 119 insertions(+), 67 deletions(-) (limited to 'src/main/java/net/minecraft/server/EntityZombie.java') diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java index 352127d0..75ca31c0 100644 --- a/src/main/java/net/minecraft/server/EntityZombie.java +++ b/src/main/java/net/minecraft/server/EntityZombie.java @@ -1,6 +1,7 @@ package net.minecraft.server; import java.util.Calendar; +import java.util.UUID; //CraftBukkit start import org.bukkit.craftbukkit.entity.CraftLivingEntity; @@ -10,34 +11,35 @@ import org.bukkit.event.entity.EntityCombustEvent; public class EntityZombie extends EntityMonster { - private int d = 0; + protected static final IAttribute bp = (new AttributeRanged("zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).a("Spawn Reinforcements Chance"); + private static final UUID bq = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836"); + private static final AttributeModifier br = new AttributeModifier(bq, "Baby speed boost", 0.5D, 0); + private int bs; private int lastTick = MinecraftServer.currentTick; // CraftBukkit public EntityZombie(World world) { super(world); - this.texture = "/mob/zombie.png"; - this.bI = 0.23F; this.getNavigation().b(true); this.goalSelector.a(0, new PathfinderGoalFloat(this)); this.goalSelector.a(1, new PathfinderGoalBreakDoor(this)); - this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, EntityHuman.class, this.bI, false)); - this.goalSelector.a(3, new PathfinderGoalMeleeAttack(this, EntityVillager.class, this.bI, true)); - this.goalSelector.a(4, new PathfinderGoalMoveTowardsRestriction(this, this.bI)); - this.goalSelector.a(5, new PathfinderGoalMoveThroughVillage(this, this.bI, false)); - this.goalSelector.a(6, new PathfinderGoalRandomStroll(this, this.bI)); + this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, EntityHuman.class, 1.0D, false)); + this.goalSelector.a(3, new PathfinderGoalMeleeAttack(this, EntityVillager.class, 1.0D, true)); + this.goalSelector.a(4, new PathfinderGoalMoveTowardsRestriction(this, 1.0D)); + this.goalSelector.a(5, new PathfinderGoalMoveThroughVillage(this, 1.0D, false)); + this.goalSelector.a(6, new PathfinderGoalRandomStroll(this, 1.0D)); this.goalSelector.a(7, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); this.goalSelector.a(7, new PathfinderGoalRandomLookaround(this)); this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true)); - this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, 16.0F, 0, true)); - this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, 16.0F, 0, false)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, 0, true)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, 0, false)); } - protected int ay() { - return 40; - } - - public float bE() { - return super.bE() * (this.isBaby() ? 1.5F : 1.0F); + protected void ax() { + super.ax(); + this.a(GenericAttributes.b).a(40.0D); + this.a(GenericAttributes.d).a(0.23000000417232513D); + this.a(GenericAttributes.e).a(3.0D); + this.aT().b(bp).a(this.random.nextDouble() * 0.10000000149011612D); } protected void a() { @@ -47,12 +49,8 @@ public class EntityZombie extends EntityMonster { this.getDataWatcher().a(14, Byte.valueOf((byte) 0)); } - public int getMaxHealth() { - return 20; - } - - public int aZ() { - int i = super.aZ() + 2; + public int aM() { + int i = super.aM() + 2; if (i > 20) { i = 20; @@ -61,7 +59,7 @@ public class EntityZombie extends EntityMonster { return i; } - protected boolean bh() { + protected boolean bb() { return true; } @@ -70,7 +68,15 @@ public class EntityZombie extends EntityMonster { } public void setBaby(boolean flag) { - this.getDataWatcher().watch(12, Byte.valueOf((byte) (flag ? 1 : 0))); // CraftBukkit - added flag + this.getDataWatcher().watch(12, Byte.valueOf((byte) (flag ? 1 : 0))); + if (this.world != null && !this.world.isStatic) { + AttributeInstance attributeinstance = this.a(GenericAttributes.d); + + attributeinstance.b(br); + if (flag) { + attributeinstance.a(br); + } + } } public boolean isVillager() { @@ -83,7 +89,7 @@ public class EntityZombie extends EntityMonster { public void c() { if (this.world.v() && !this.world.isStatic && !this.isBaby()) { - float f = this.c(1.0F); + float f = this.d(1.0F); if (f > 0.5F && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.world.l(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ))) { boolean flag = true; @@ -117,9 +123,52 @@ public class EntityZombie extends EntityMonster { super.c(); } + public boolean damageEntity(DamageSource damagesource, float f) { + if (!super.damageEntity(damagesource, f)) { + return false; + } else { + EntityLiving entityliving = this.getGoalTarget(); + + if (entityliving == null && this.bJ() instanceof EntityLiving) { + entityliving = (EntityLiving) this.bJ(); + } + + if (entityliving == null && damagesource.getEntity() instanceof EntityLiving) { + entityliving = (EntityLiving) damagesource.getEntity(); + } + + if (entityliving != null && this.world.difficulty >= 3 && (double) this.random.nextFloat() < this.a(bp).e()) { + int i = MathHelper.floor(this.locX); + int j = MathHelper.floor(this.locY); + int k = MathHelper.floor(this.locZ); + EntityZombie entityzombie = new EntityZombie(this.world); + + for (int l = 0; l < 50; ++l) { + int i1 = i + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1); + int j1 = j + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1); + int k1 = k + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1); + + if (this.world.w(i1, j1 - 1, k1) && this.world.getLightLevel(i1, j1, k1) < 10) { + entityzombie.setPosition((double) i1, (double) j1, (double) k1); + if (this.world.b(entityzombie.boundingBox) && this.world.getCubes(entityzombie, entityzombie.boundingBox).isEmpty() && !this.world.containsLiquid(entityzombie.boundingBox)) { + this.world.addEntity(entityzombie); + entityzombie.setGoalTarget(entityliving); + entityzombie.a((GroupDataEntity) null); + this.a(bp).a(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0)); + entityzombie.a(bp).a(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0)); + break; + } + } + } + } + + return true; + } + } + public void l_() { - if (!this.world.isStatic && this.o()) { - int i = this.q(); + if (!this.world.isStatic && this.bR()) { + int i = this.bT(); // CraftBukkit start - Use wall time instead of ticks for villager conversion int elapsedTicks = MinecraftServer.currentTick - this.lastTick; @@ -127,9 +176,9 @@ public class EntityZombie extends EntityMonster { i *= elapsedTicks; // CraftBukkit end - this.d -= i; - if (this.d <= 0) { - this.p(); + this.bs -= i; + if (this.bs <= 0) { + this.bS(); } } @@ -139,7 +188,7 @@ public class EntityZombie extends EntityMonster { public boolean m(Entity entity) { boolean flag = super.m(entity); - if (flag && this.bG() == null && this.isBurning() && this.random.nextFloat() < (float) this.world.difficulty * 0.3F) { + if (flag && this.aV() == null && this.isBurning() && this.random.nextFloat() < (float) this.world.difficulty * 0.3F) { // CraftBukkit start EntityCombustByEntityEvent event = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 2 * this.world.difficulty); this.world.getServer().getPluginManager().callEvent(event); @@ -153,28 +202,15 @@ public class EntityZombie extends EntityMonster { return flag; } - public int c(Entity entity) { - ItemStack itemstack = this.bG(); - // CraftBukkit - getMaxHealth() -> ((CraftLivingEntity) this.bukkitEntity).getMaxHealth() - float f = (float) (((CraftLivingEntity) this.bukkitEntity).getMaxHealth() - this.getHealth()) / (float) ((CraftLivingEntity) this.bukkitEntity).getMaxHealth(); - int i = 3 + MathHelper.d(f * 4.0F); - - if (itemstack != null) { - i += itemstack.a((Entity) this); - } - - return i; - } - - protected String bb() { + protected String r() { return "mob.zombie.say"; } - protected String bc() { + protected String aK() { return "mob.zombie.hurt"; } - protected String bd() { + protected String aL() { return "mob.zombie.death"; } @@ -205,8 +241,8 @@ public class EntityZombie extends EntityMonster { } // CraftBukkit end - protected void bH() { - super.bH(); + protected void bs() { + super.bs(); if (this.random.nextFloat() < (this.world.difficulty == 3 ? 0.05F : 0.01F)) { int i = this.random.nextInt(3); @@ -228,7 +264,7 @@ public class EntityZombie extends EntityMonster { nbttagcompound.setBoolean("IsVillager", true); } - nbttagcompound.setInt("ConversionTime", this.o() ? this.d : -1); + nbttagcompound.setInt("ConversionTime", this.bR() ? this.bs : -1); } public void a(NBTTagCompound nbttagcompound) { @@ -255,9 +291,9 @@ public class EntityZombie extends EntityMonster { EntityZombie entityzombie = new EntityZombie(this.world); - entityzombie.k(entityliving); + entityzombie.j(entityliving); this.world.kill(entityliving); - entityzombie.bJ(); + entityzombie.a((GroupDataEntity) null); entityzombie.setVillager(true); if (entityliving.isBaby()) { entityzombie.setBaby(true); @@ -268,26 +304,38 @@ public class EntityZombie extends EntityMonster { } } - public void bJ() { - this.h(this.random.nextFloat() < au[this.world.difficulty]); + public GroupDataEntity a(GroupDataEntity groupdataentity) { + groupdataentity = super.a(groupdataentity); + float f = this.world.b(this.locX, this.locY, this.locZ); + + this.h(this.random.nextFloat() < 0.55F * f); if (this.world.random.nextFloat() < 0.05F) { this.setVillager(true); } - this.bH(); - this.bI(); + this.bs(); + this.bt(); if (this.getEquipment(4) == null) { - Calendar calendar = this.world.V(); + Calendar calendar = this.world.W(); if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31 && this.random.nextFloat() < 0.25F) { this.setEquipment(4, new ItemStack(this.random.nextFloat() < 0.1F ? Block.JACK_O_LANTERN : Block.PUMPKIN)); this.dropChances[4] = 0.0F; } } + + this.a(GenericAttributes.c).a(new AttributeModifier("Random spawn bonus", this.random.nextDouble() * 0.05000000074505806D, 0)); + this.a(GenericAttributes.b).a(new AttributeModifier("Random zombie-spawn bonus", this.random.nextDouble() * 1.5D, 2)); + if (this.random.nextFloat() < f * 0.05F) { + this.a(bp).a(new AttributeModifier("Leader zombie bonus", this.random.nextDouble() * 0.25D + 0.5D, 0)); + this.a(GenericAttributes.a).a(new AttributeModifier("Leader zombie bonus", this.random.nextDouble() * 3.0D + 1.0D, 2)); + } + + return groupdataentity; } - public boolean a_(EntityHuman entityhuman) { - ItemStack itemstack = entityhuman.cd(); + public boolean a(EntityHuman entityhuman) { + ItemStack itemstack = entityhuman.bt(); if (itemstack != null && itemstack.getItem() == Item.GOLDEN_APPLE && itemstack.getData() == 0 && this.isVillager() && this.hasEffect(MobEffectList.WEAKNESS)) { if (!entityhuman.abilities.canInstantlyBuild) { @@ -309,23 +357,27 @@ public class EntityZombie extends EntityMonster { } protected void a(int i) { - this.d = i; + this.bs = i; this.getDataWatcher().watch(14, Byte.valueOf((byte) 1)); - this.o(MobEffectList.WEAKNESS.id); + this.k(MobEffectList.WEAKNESS.id); this.addEffect(new MobEffect(MobEffectList.INCREASE_DAMAGE.id, i, Math.min(this.world.difficulty - 1, 0))); this.world.broadcastEntityEffect(this, (byte) 16); } - public boolean o() { + protected boolean isTypeNotPersistent() { + return !this.bR(); + } + + public boolean bR() { return this.getDataWatcher().getByte(14) == 1; } - protected void p() { + protected void bS() { EntityVillager entityvillager = new EntityVillager(this.world); - entityvillager.k(this); - entityvillager.bJ(); - entityvillager.q(); + entityvillager.j(this); + entityvillager.a((GroupDataEntity) null); + entityvillager.bT(); if (this.isBaby()) { entityvillager.setAge(-24000); } @@ -336,7 +388,7 @@ public class EntityZombie extends EntityMonster { this.world.a((EntityHuman) null, 1017, (int) this.locX, (int) this.locY, (int) this.locZ, 0); } - protected int q() { + protected int bT() { int i = 1; if (this.random.nextFloat() < 0.01F) { -- cgit v1.2.3