diff options
Diffstat (limited to 'src/main')
23 files changed, 119 insertions, 688 deletions
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index 1d0dee0b..04f5bc68 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -1294,6 +1294,13 @@ public abstract class Entity { public EntityItem a(ItemStack itemstack, float f) { if (itemstack.count != 0 && itemstack.getItem() != null) { + // CraftBukkit start - Capture drops for death event + if (this instanceof EntityLiving && ((EntityLiving) this).drops != null) { + ((EntityLiving) this).drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); + return null; + } + // CraftBukkit end + EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack); entityitem.pickupDelay = 10; diff --git a/src/main/java/net/minecraft/server/EntityBlaze.java b/src/main/java/net/minecraft/server/EntityBlaze.java deleted file mode 100644 index 790185c5..00000000 --- a/src/main/java/net/minecraft/server/EntityBlaze.java +++ /dev/null @@ -1,159 +0,0 @@ -package net.minecraft.server; - -public class EntityBlaze extends EntityMonster { - - private float bp = 0.5F; - private int bq; - private int br; - - public EntityBlaze(World world) { - super(world); - this.fireProof = true; - this.b = 10; - } - - protected void aC() { - super.aC(); - this.getAttributeInstance(GenericAttributes.e).setValue(6.0D); - } - - protected void c() { - super.c(); - this.datawatcher.a(16, new Byte((byte) 0)); - } - - protected String t() { - return "mob.blaze.breathe"; - } - - protected String aS() { - return "mob.blaze.hit"; - } - - protected String aT() { - return "mob.blaze.death"; - } - - public float d(float f) { - return 1.0F; - } - - public void e() { - if (!this.world.isStatic) { - if (this.K()) { - this.damageEntity(DamageSource.DROWN, 1.0F); - } - - --this.bq; - if (this.bq <= 0) { - this.bq = 100; - this.bp = 0.5F + (float) this.random.nextGaussian() * 3.0F; - } - - if (this.bT() != null && this.bT().locY + (double) this.bT().getHeadHeight() > this.locY + (double) this.getHeadHeight() + (double) this.bp) { - this.motY += (0.30000001192092896D - this.motY) * 0.30000001192092896D; - } - } - - if (this.random.nextInt(24) == 0) { - this.world.makeSound(this.locX + 0.5D, this.locY + 0.5D, this.locZ + 0.5D, "fire.fire", 1.0F + this.random.nextFloat(), this.random.nextFloat() * 0.7F + 0.3F); - } - - if (!this.onGround && this.motY < 0.0D) { - this.motY *= 0.6D; - } - - for (int i = 0; i < 2; ++i) { - this.world.addParticle("largesmoke", this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width, this.locY + this.random.nextDouble() * (double) this.length, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, 0.0D, 0.0D, 0.0D); - } - - super.e(); - } - - protected void a(Entity entity, float f) { - if (this.attackTicks <= 0 && f < 2.0F && entity.boundingBox.e > this.boundingBox.b && entity.boundingBox.b < this.boundingBox.e) { - this.attackTicks = 20; - this.n(entity); - } else if (f < 30.0F) { - double d0 = entity.locX - this.locX; - double d1 = entity.boundingBox.b + (double) (entity.length / 2.0F) - (this.locY + (double) (this.length / 2.0F)); - double d2 = entity.locZ - this.locZ; - - if (this.attackTicks == 0) { - ++this.br; - if (this.br == 1) { - this.attackTicks = 60; - this.a(true); - } else if (this.br <= 4) { - this.attackTicks = 6; - } else { - this.attackTicks = 100; - this.br = 0; - this.a(false); - } - - if (this.br > 1) { - float f1 = MathHelper.c(f) * 0.5F; - - this.world.a((EntityHuman) null, 1009, (int) this.locX, (int) this.locY, (int) this.locZ, 0); - - for (int i = 0; i < 1; ++i) { - EntitySmallFireball entitysmallfireball = new EntitySmallFireball(this.world, this, d0 + this.random.nextGaussian() * (double) f1, d1, d2 + this.random.nextGaussian() * (double) f1); - - entitysmallfireball.locY = this.locY + (double) (this.length / 2.0F) + 0.5D; - this.world.addEntity(entitysmallfireball); - } - } - } - - this.yaw = (float) (Math.atan2(d2, d0) * 180.0D / 3.1415927410125732D) - 90.0F; - this.bn = true; - } - } - - protected void b(float f) {} - - protected Item getLoot() { - return Items.BLAZE_ROD; - } - - public boolean isBurning() { - return this.bZ(); - } - - protected void dropDeathLoot(boolean flag, int i) { - // CraftBukkit start - java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); - - if (flag) { - int j = this.random.nextInt(2 + i); - - if (j > 0) { - loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(Items.BLAZE_ROD), j)); - } - } - - org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot); - // CraftBukkit end - } - - public boolean bZ() { - return (this.datawatcher.getByte(16) & 1) != 0; - } - - public void a(boolean flag) { - byte b0 = this.datawatcher.getByte(16); - - if (flag) { - b0 = (byte) (b0 | 1); - } else { - b0 &= -2; - } - - this.datawatcher.watch(16, Byte.valueOf(b0)); - } - - protected boolean j_() { - return true; - } -} diff --git a/src/main/java/net/minecraft/server/EntityChicken.java b/src/main/java/net/minecraft/server/EntityChicken.java index f7438b9c..a73f8f89 100644 --- a/src/main/java/net/minecraft/server/EntityChicken.java +++ b/src/main/java/net/minecraft/server/EntityChicken.java @@ -1,7 +1,5 @@ package net.minecraft.server; -import org.bukkit.craftbukkit.util.CraftMagicNumbers; // CraftBukkit - public class EntityChicken extends EntityAnimal { public float bp; @@ -94,22 +92,17 @@ public class EntityChicken extends EntityAnimal { } protected void dropDeathLoot(boolean flag, int i) { - // CraftBukkit start - Whole method - java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); int j = this.random.nextInt(3) + this.random.nextInt(1 + i); - if (j > 0) { - loot.add(new org.bukkit.inventory.ItemStack(CraftMagicNumbers.getMaterial(Items.FEATHER), j)); + for (int k = 0; k < j; ++k) { + this.a(Items.FEATHER, 1); } if (this.isBurning()) { - loot.add(new org.bukkit.inventory.ItemStack(CraftMagicNumbers.getMaterial(Items.COOKED_CHICKEN), 1)); + this.a(Items.COOKED_CHICKEN, 1); } else { - loot.add(new org.bukkit.inventory.ItemStack(CraftMagicNumbers.getMaterial(Items.RAW_CHICKEN), 1)); + this.a(Items.RAW_CHICKEN, 1); } - - org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot); - // CraftBukkit end } public EntityChicken b(EntityAgeable entityageable) { diff --git a/src/main/java/net/minecraft/server/EntityCow.java b/src/main/java/net/minecraft/server/EntityCow.java index 43c1243b..4a955d09 100644 --- a/src/main/java/net/minecraft/server/EntityCow.java +++ b/src/main/java/net/minecraft/server/EntityCow.java @@ -3,7 +3,6 @@ package net.minecraft.server; // CraftBukkit start import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.craftbukkit.util.CraftMagicNumbers; // CraftBukkit end public class EntityCow extends EntityAnimal { @@ -57,24 +56,23 @@ public class EntityCow extends EntityAnimal { } protected void dropDeathLoot(boolean flag, int i) { - // CraftBukkit start - Whole method - java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); int j = this.random.nextInt(3) + this.random.nextInt(1 + i); int k; - if (j > 0) { - loot.add(new org.bukkit.inventory.ItemStack(CraftMagicNumbers.getMaterial(Items.LEATHER), j)); + for (k = 0; k < j; ++k) { + this.a(Items.LEATHER, 1); } j = this.random.nextInt(3) + 1 + this.random.nextInt(1 + i); - if (j > 0) { - loot.add(new org.bukkit.inventory.ItemStack(this.isBurning() ? CraftMagicNumbers.getMaterial(Items.COOKED_BEEF) : CraftMagicNumbers.getMaterial(Items.RAW_BEEF), j)); + for (k = 0; k < j; ++k) { + if (this.isBurning()) { + this.a(Items.COOKED_BEEF, 1); + } else { + this.a(Items.RAW_BEEF, 1); + } } - - CraftEventFactory.callEntityDeathEvent(this, loot); - // CraftBukkit end } public boolean a(EntityHuman entityhuman) { diff --git a/src/main/java/net/minecraft/server/EntityCreeper.java b/src/main/java/net/minecraft/server/EntityCreeper.java index e5d72b79..24302a6b 100644 --- a/src/main/java/net/minecraft/server/EntityCreeper.java +++ b/src/main/java/net/minecraft/server/EntityCreeper.java @@ -117,45 +117,30 @@ public class EntityCreeper extends EntityMonster { } public void die(DamageSource damagesource) { - // CraftBukkit start - Rearranged the method (super call to end, drop to dropDeathLoot) + // super.die(damagesource); // CraftBukkit - Moved to end if (damagesource.getEntity() instanceof EntitySkeleton) { int i = Item.b(Items.RECORD_1); int j = Item.b(Items.RECORD_12); int k = i + this.random.nextInt(j - i + 1); - // this.a(Item.d(k), 1); // CraftBukkit + // CraftBukkit start - Store record for now, drop in dropDeathLoot + // this.a(Item.d(k), 1); this.record = k; + // CraftBukkit end } - super.die(damagesource); - // CraftBukkit end + super.die(damagesource); // CraftBukkit - Moved from above } // CraftBukkit start - Whole method protected void dropDeathLoot(boolean flag, int i) { - Item j = this.getLoot(); - - java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); - - if (j != null) { - int k = this.random.nextInt(3); - - if (i > 0) { - k += this.random.nextInt(i + 1); - } - - if (k > 0) { - loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(j), k)); - } - } + super.dropDeathLoot(flag, i); // Drop a music disc? if (this.record != -1) { - loot.add(new org.bukkit.inventory.ItemStack(this.record, 1)); // TODO: Material + this.a(Item.d(this.record), 1); this.record = -1; } - - CraftEventFactory.callEntityDeathEvent(this, loot); // raise event even for those times when the entity does not drop loot } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/EntityEnderman.java b/src/main/java/net/minecraft/server/EntityEnderman.java index 0f02e7d6..172228bc 100644 --- a/src/main/java/net/minecraft/server/EntityEnderman.java +++ b/src/main/java/net/minecraft/server/EntityEnderman.java @@ -306,16 +306,11 @@ public class EntityEnderman extends EntityMonster { Item item = this.getLoot(); if (item != null) { - // CraftBukkit start - Whole method - java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); - int count = this.random.nextInt(2 + i); + int j = this.random.nextInt(2 + i); - if (count > 0) { - loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), count)); + for (int k = 0; k < j; ++k) { + this.a(item, 1); } - - CraftEventFactory.callEntityDeathEvent(this, loot); - // CraftBukkit end } } diff --git a/src/main/java/net/minecraft/server/EntityGhast.java b/src/main/java/net/minecraft/server/EntityGhast.java index 00fd1ec3..cd1fd3b6 100644 --- a/src/main/java/net/minecraft/server/EntityGhast.java +++ b/src/main/java/net/minecraft/server/EntityGhast.java @@ -2,7 +2,6 @@ package net.minecraft.server; // CraftBukkit start import org.bukkit.craftbukkit.entity.CraftEntity; -import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit end @@ -198,24 +197,19 @@ public class EntityGhast extends EntityFlying implements IMonster { } protected void dropDeathLoot(boolean flag, int i) { - // CraftBukkit start - java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); int j = this.random.nextInt(2) + this.random.nextInt(1 + i); int k; - if (j > 0) { - loot.add(CraftItemStack.asNewCraftStack(Items.GHAST_TEAR, j)); + for (k = 0; k < j; ++k) { + this.a(Items.GHAST_TEAR, 1); } j = this.random.nextInt(3) + this.random.nextInt(1 + i); - if (j > 0) { - loot.add(CraftItemStack.asNewCraftStack(Items.SULPHUR, j)); + for (k = 0; k < j; ++k) { + this.a(Items.SULPHUR, 1); } - - org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot); - // CraftBukkit end } protected float be() { diff --git a/src/main/java/net/minecraft/server/EntityHorse.java b/src/main/java/net/minecraft/server/EntityHorse.java index 7d67210e..544c0082 100644 --- a/src/main/java/net/minecraft/server/EntityHorse.java +++ b/src/main/java/net/minecraft/server/EntityHorse.java @@ -708,11 +708,24 @@ public class EntityHorse extends EntityAnimal implements IInventoryListener { public void die(DamageSource damagesource) { super.die(damagesource); + /* CraftBukkit start - Handle chest dropping in dropDeathLoot below if (!this.world.isStatic) { this.cK(); } + // CraftBukkit end */ } + // CraftBukkit start - Add method + protected void dropDeathLoot(boolean flag, int i) { + super.dropDeathLoot(flag, i); + + // Moved from die method above + if (!this.world.isStatic) { + this.cK(); // Should be dropChest + } + } + // CraftBukkit end + public void e() { if (this.random.nextInt(200) == 0) { this.cR(); diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java index 11450ac5..12e10366 100644 --- a/src/main/java/net/minecraft/server/EntityInsentient.java +++ b/src/main/java/net/minecraft/server/EntityInsentient.java @@ -6,7 +6,6 @@ import java.util.UUID; // CraftBukkit start import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.event.entity.EntityUnleashEvent; import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason; // CraftBukkit end @@ -172,8 +171,6 @@ public abstract class EntityInsentient extends EntityLiving { } protected void dropDeathLoot(boolean flag, int i) { - // CraftBukkit start - Whole method - List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); Item item = this.getLoot(); if (item != null) { @@ -183,32 +180,10 @@ public abstract class EntityInsentient extends EntityLiving { j += this.random.nextInt(i + 1); } - if (j > 0) { - loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), j)); + for (int k = 0; k < j; ++k) { + this.a(item, 1); } } - - // Determine rare item drops and add them to the loot - if (this.lastDamageByPlayerTime > 0) { - int k = this.random.nextInt(200) - i; - - if (k < 5) { - ItemStack itemstack = this.getRareDrop(k <= 0 ? 1 : 0); - if (itemstack != null) { - loot.add(CraftItemStack.asCraftMirror(itemstack)); - } - } - } - - // Include equipment - for (ItemStack stack : this.dropEquipment(this.lastDamageByPlayerTime > 0, i)) { - if (stack != null) { - loot.add(CraftItemStack.asCraftMirror(stack)); - } - } - - CraftEventFactory.callEntityDeathEvent(this, loot); // raise event even for those times when the entity does not drop loot - // CraftBukkit end } public void b(NBTTagCompound nbttagcompound) { @@ -573,10 +548,7 @@ public abstract class EntityInsentient extends EntityLiving { return this.equipment; } - // CraftBukkit start - return array of dropped items - protected ItemStack[] dropEquipment(boolean flag, int i) { - ItemStack[] dropped = new ItemStack[this.equipment.length]; - // CraftBukkit end + protected void dropEquipment(boolean flag, int i) { for (int j = 0; j < this.getEquipment().length; ++j) { ItemStack itemstack = this.getEquipment(j); boolean flag1 = this.dropChances[j] > 1.0F; @@ -597,13 +569,9 @@ public abstract class EntityInsentient extends EntityLiving { itemstack.setData(l); } - // CraftBukkit start - // this.a(itemstack, 0.0F); - dropped[j] = itemstack; - // CraftBukkit end + this.a(itemstack, 0.0F); } } - return dropped; // CraftBukkit } protected void bC() { diff --git a/src/main/java/net/minecraft/server/EntityIronGolem.java b/src/main/java/net/minecraft/server/EntityIronGolem.java index dec42cdd..1f557a8a 100644 --- a/src/main/java/net/minecraft/server/EntityIronGolem.java +++ b/src/main/java/net/minecraft/server/EntityIronGolem.java @@ -1,7 +1,5 @@ package net.minecraft.server; -import org.bukkit.craftbukkit.inventory.CraftItemStack; // CraftBukkit - public class EntityIronGolem extends EntityGolem { private int bq; @@ -145,24 +143,19 @@ public class EntityIronGolem extends EntityGolem { } protected void dropDeathLoot(boolean flag, int i) { - // CraftBukkit start - java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); int j = this.random.nextInt(3); int k; - if (j > 0) { - loot.add(CraftItemStack.asNewCraftStack(Item.getItemOf(Blocks.RED_ROSE), j)); + for (k = 0; k < j; ++k) { + this.a(Item.getItemOf(Blocks.RED_ROSE), 1, 0.0F); } k = 3 + this.random.nextInt(3); - if (k > 0) { - loot.add(CraftItemStack.asNewCraftStack(Items.IRON_INGOT, k)); + for (int l = 0; l < k; ++l) { + this.a(Items.IRON_INGOT, 1); } - - org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot); - // CraftBukkit end } public int cb() { diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java index 60db3063..b3bf43ae 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -8,6 +8,7 @@ import java.util.Random; import java.util.UUID; // CraftBukkit start +import java.util.ArrayList; import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityRegainHealthEvent; @@ -77,6 +78,7 @@ public abstract class EntityLiving extends Entity { // CraftBukkit start public int expToDrop; public int maxAirTicks = 300; + ArrayList<org.bukkit.inventory.ItemStack> drops = null; // CraftBukkit end public EntityLiving(World world) { @@ -781,28 +783,31 @@ public abstract class EntityLiving extends Entity { } if (this.aF() && this.world.getGameRules().getBoolean("doMobLoot")) { + this.drops = new ArrayList<org.bukkit.inventory.ItemStack>(); // CraftBukkit - Setup drop capture + this.dropDeathLoot(this.lastDamageByPlayerTime > 0, i); this.dropEquipment(this.lastDamageByPlayerTime > 0, i); - if (false && this.lastDamageByPlayerTime > 0) { // CraftBukkit - move rare item drop call to dropDeathLoot + if (this.lastDamageByPlayerTime > 0) { int j = this.random.nextInt(200) - i; if (j < 5) { this.getRareDrop(j <= 0 ? 1 : 0); } } - } else { // CraftBukkit - CraftEventFactory.callEntityDeathEvent(this); // CraftBukkit + + // CraftBukkit start - Call death event + CraftEventFactory.callEntityDeathEvent(this, this.drops); + this.drops = null; + } else { + CraftEventFactory.callEntityDeathEvent(this); + // CraftBukkit end } } this.world.broadcastEntityEffect(this, (byte) 3); } - // CraftBukkit start - return dropped equipment for EntityDeathEvent processing - protected ItemStack[] dropEquipment(boolean flag, int i) { - return new ItemStack[this.getEquipment().length]; - } - // CraftBukkit end + protected void dropEquipment(boolean flag, int i) {} public void a(Entity entity, float f, double d0, double d1) { if (this.random.nextDouble() >= this.getAttributeInstance(GenericAttributes.c).getValue()) { @@ -830,11 +835,7 @@ public abstract class EntityLiving extends Entity { return "game.neutral.die"; } - // CraftBukkit start - Change return type to ItemStack - protected ItemStack getRareDrop(int i) { - return null; - } - // CraftBukkit end + protected void getRareDrop(int i) {} protected void dropDeathLoot(boolean flag, int i) {} diff --git a/src/main/java/net/minecraft/server/EntityMagmaCube.java b/src/main/java/net/minecraft/server/EntityMagmaCube.java deleted file mode 100644 index fd50f11b..00000000 --- a/src/main/java/net/minecraft/server/EntityMagmaCube.java +++ /dev/null @@ -1,98 +0,0 @@ -package net.minecraft.server; - -public class EntityMagmaCube extends EntitySlime { - - public EntityMagmaCube(World world) { - super(world); - this.fireProof = true; - } - - protected void aC() { - super.aC(); - this.getAttributeInstance(GenericAttributes.d).setValue(0.20000000298023224D); - } - - public boolean canSpawn() { - return this.world.difficulty != EnumDifficulty.PEACEFUL && this.world.b(this.boundingBox) && this.world.getCubes(this, this.boundingBox).isEmpty() && !this.world.containsLiquid(this.boundingBox); - } - - public int aU() { - return this.getSize() * 3; - } - - public float d(float f) { - return 1.0F; - } - - protected String bP() { - return "flame"; - } - - protected EntitySlime bQ() { - return new EntityMagmaCube(this.world); - } - - protected Item getLoot() { - return Items.MAGMA_CREAM; - } - - protected void dropDeathLoot(boolean flag, int i) { - // CraftBukkit start - Whole method - java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); - Item item = this.getLoot(); - - if (item != null && this.getSize() > 1) { - int j = this.random.nextInt(4) - 2; - - if (i > 0) { - j += this.random.nextInt(i + 1); - } - - if (j > 0) { - loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), j)); - } - } - - org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot); - // CraftBukkit end - } - - public boolean isBurning() { - return false; - } - - protected int bR() { - return super.bR() * 4; - } - - protected void bS() { - this.h *= 0.9F; - } - - protected void bi() { - this.motY = (double) (0.42F + (float) this.getSize() * 0.1F); - this.al = true; - } - - protected void b(float f) {} - - protected boolean bT() { - return true; - } - - protected int bU() { - return super.bU() + 2; - } - - protected String bV() { - return this.getSize() > 1 ? "mob.magmacube.big" : "mob.magmacube.small"; - } - - public boolean O() { - return false; - } - - protected boolean bW() { - return true; - } -} diff --git a/src/main/java/net/minecraft/server/EntityOcelot.java b/src/main/java/net/minecraft/server/EntityOcelot.java index 603e53da..1ce9fb88 100644 --- a/src/main/java/net/minecraft/server/EntityOcelot.java +++ b/src/main/java/net/minecraft/server/EntityOcelot.java @@ -106,9 +106,7 @@ public class EntityOcelot extends EntityTameableAnimal { } } - protected void dropDeathLoot(boolean flag, int i) { - org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this); // CraftBukkit - Call EntityDeathEvent - } + protected void dropDeathLoot(boolean flag, int i) {} public boolean a(EntityHuman entityhuman) { ItemStack itemstack = entityhuman.inventory.getItemInHand(); diff --git a/src/main/java/net/minecraft/server/EntityPig.java b/src/main/java/net/minecraft/server/EntityPig.java index 7e249ad2..c14bbf6c 100644 --- a/src/main/java/net/minecraft/server/EntityPig.java +++ b/src/main/java/net/minecraft/server/EntityPig.java @@ -1,9 +1,6 @@ package net.minecraft.server; -// CraftBukkit start -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.craftbukkit.util.CraftMagicNumbers; -// CraftBukkit end +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit public class EntityPig extends EntityAnimal { @@ -92,24 +89,19 @@ public class EntityPig extends EntityAnimal { } protected void dropDeathLoot(boolean flag, int i) { - // CraftBukkit start - java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); int j = this.random.nextInt(3) + 1 + this.random.nextInt(1 + i); - if (j > 0) { + for (int k = 0; k < j; ++k) { if (this.isBurning()) { - loot.add(new org.bukkit.inventory.ItemStack(CraftMagicNumbers.getMaterial(Items.GRILLED_PORK), j)); + this.a(Items.GRILLED_PORK, 1); } else { - loot.add(new org.bukkit.inventory.ItemStack(CraftMagicNumbers.getMaterial(Items.PORK), j)); + this.a(Items.PORK, 1); } } if (this.hasSaddle()) { - loot.add(new org.bukkit.inventory.ItemStack(CraftMagicNumbers.getMaterial(Items.SADDLE), 1)); + this.a(Items.SADDLE, 1); } - - CraftEventFactory.callEntityDeathEvent(this, loot); - // CraftBukkit end } public boolean hasSaddle() { diff --git a/src/main/java/net/minecraft/server/EntityPigZombie.java b/src/main/java/net/minecraft/server/EntityPigZombie.java index ec268506..26fb4b94 100644 --- a/src/main/java/net/minecraft/server/EntityPigZombie.java +++ b/src/main/java/net/minecraft/server/EntityPigZombie.java @@ -3,10 +3,7 @@ package net.minecraft.server; import java.util.List; import java.util.UUID; -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.event.entity.EntityTargetEvent; -// CraftBukkit end +import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit public class EntityPigZombie extends EntityZombie { @@ -128,45 +125,28 @@ public class EntityPigZombie extends EntityZombie { } protected void dropDeathLoot(boolean flag, int i) { - // CraftBukkit start - List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); int j = this.random.nextInt(2 + i); - if (j > 0) { - loot.add(CraftItemStack.asNewCraftStack(Items.ROTTEN_FLESH, j)); - } - - j = this.random.nextInt(2 + i); + int k; - if (j > 0) { - loot.add(CraftItemStack.asNewCraftStack(Items.GOLD_NUGGET, j)); + for (k = 0; k < j; ++k) { + this.a(Items.ROTTEN_FLESH, 1); } - // Determine rare item drops and add them to the loot - if (this.lastDamageByPlayerTime > 0) { - int k = this.random.nextInt(200) - i; + j = this.random.nextInt(2 + i); - if (k < 5) { - ItemStack itemstack = this.getRareDrop(k <= 0 ? 1 : 0); - if (itemstack != null) { - loot.add(CraftItemStack.asCraftMirror(itemstack)); - } - } + for (k = 0; k < j; ++k) { + this.a(Items.GOLD_NUGGET, 1); } - - org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot); - // CraftBukkit end } public boolean a(EntityHuman entityhuman) { return false; } - // CraftBukkit start - Return rare dropped item instead of dropping it - protected ItemStack getRareDrop(int i) { - return new ItemStack(Items.GOLD_INGOT, 1, 0); + protected void getRareDrop(int i) { + this.a(Items.GOLD_INGOT, 1); } - // CraftBukkit end protected void bC() { this.setEquipment(0, new ItemStack(Items.GOLD_SWORD)); diff --git a/src/main/java/net/minecraft/server/EntitySheep.java b/src/main/java/net/minecraft/server/EntitySheep.java index 47e60923..4d96d53a 100644 --- a/src/main/java/net/minecraft/server/EntitySheep.java +++ b/src/main/java/net/minecraft/server/EntitySheep.java @@ -61,15 +61,9 @@ public class EntitySheep extends EntityAnimal { } protected void dropDeathLoot(boolean flag, int i) { - // CraftBukkit start - Whole method - java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); - if (!this.isSheared()) { - loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.WOOL, 1, (short) 0, (byte) this.getColor())); + this.a(new ItemStack(Item.getItemOf(Blocks.WOOL), 1, this.getColor()), 0.0F); } - - org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot); - // CraftBukkit end } protected Item getLoot() { diff --git a/src/main/java/net/minecraft/server/EntitySkeleton.java b/src/main/java/net/minecraft/server/EntitySkeleton.java index fd3fd3bf..47bbff12 100644 --- a/src/main/java/net/minecraft/server/EntitySkeleton.java +++ b/src/main/java/net/minecraft/server/EntitySkeleton.java @@ -137,49 +137,34 @@ public class EntitySkeleton extends EntityMonster implements IRangedEntity { } protected void dropDeathLoot(boolean flag, int i) { - // CraftBukkit start - Whole method - java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); + int j; + int k; if (this.getSkeletonType() == 1) { - int count = this.random.nextInt(3 + i) - 1; - if (count > 0) { - loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.COAL, count)); + j = this.random.nextInt(3 + i) - 1; + + for (k = 0; k < j; ++k) { + this.a(Items.COAL, 1); } } else { - int count = this.random.nextInt(3 + i); - if (count > 0) { - loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.ARROW, count)); - } - } + j = this.random.nextInt(3 + i); - int count = this.random.nextInt(3 + i); - if (count > 0) { - loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.BONE, count)); + for (k = 0; k < j; ++k) { + this.a(Items.ARROW, 1); + } } - // Determine rare item drops and add them to the loot - if (this.lastDamageByPlayerTime > 0) { - int k = this.random.nextInt(200) - i; + j = this.random.nextInt(3 + i); - if (k < 5) { - ItemStack itemstack = this.getRareDrop(k <= 0 ? 1 : 0); - if (itemstack != null) { - loot.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)); - } - } + for (k = 0; k < j; ++k) { + this.a(Items.BONE, 1); } - - org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot); - // CraftBukkit end } - // CraftBukkit - return rare dropped item instead of dropping it - protected ItemStack getRareDrop(int i) { + protected void getRareDrop(int i) { if (this.getSkeletonType() == 1) { - return new ItemStack(Items.SKULL, 1, 1); // CraftBukkit + this.a(new ItemStack(Items.SKULL, 1, 1), 0.0F); } - - return null; // CraftBukkit } protected void bC() { diff --git a/src/main/java/net/minecraft/server/EntitySnowman.java b/src/main/java/net/minecraft/server/EntitySnowman.java index b3020b75..603bb70e 100644 --- a/src/main/java/net/minecraft/server/EntitySnowman.java +++ b/src/main/java/net/minecraft/server/EntitySnowman.java @@ -68,16 +68,11 @@ public class EntitySnowman extends EntityGolem implements IRangedEntity { } protected void dropDeathLoot(boolean flag, int i) { - // CraftBukkit start - java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); int j = this.random.nextInt(16); - if (j > 0) { - loot.add(new org.bukkit.inventory.ItemStack(CraftMagicNumbers.getMaterial(Items.SNOW_BALL), j)); + for (int k = 0; k < j; ++k) { + this.a(Items.SNOW_BALL, 1); } - - CraftEventFactory.callEntityDeathEvent(this, loot); - // CraftBukkit end } public void a(EntityLiving entityliving, float f) { diff --git a/src/main/java/net/minecraft/server/EntitySpider.java b/src/main/java/net/minecraft/server/EntitySpider.java index 67a23f65..8d5bff2c 100644 --- a/src/main/java/net/minecraft/server/EntitySpider.java +++ b/src/main/java/net/minecraft/server/EntitySpider.java @@ -1,9 +1,6 @@ package net.minecraft.server; -// CraftBukkit start -import org.bukkit.craftbukkit.util.CraftMagicNumbers; -import org.bukkit.event.entity.EntityTargetEvent; -// CraftBukkti end +import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit public class EntitySpider extends EntityMonster { @@ -97,25 +94,10 @@ public class EntitySpider extends EntityMonster { } protected void dropDeathLoot(boolean flag, int i) { - // CraftBukkit start - Whole method; adapted from super.dropDeathLoot. - java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); - - int k = this.random.nextInt(3); - - if (i > 0) { - k += this.random.nextInt(i + 1); - } - - if (k > 0) { - loot.add(new org.bukkit.inventory.ItemStack(CraftMagicNumbers.getMaterial(Items.STRING), k)); - } - + super.dropDeathLoot(flag, i); if (flag && (this.random.nextInt(3) == 0 || this.random.nextInt(1 + i) > 0)) { - loot.add(new org.bukkit.inventory.ItemStack(CraftMagicNumbers.getMaterial(Items.SPIDER_EYE), 1)); + this.a(Items.SPIDER_EYE, 1); } - - org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot); // raise event even for those times when the entity does not drop loot - // CraftBukkit end } public boolean h_() { diff --git a/src/main/java/net/minecraft/server/EntitySquid.java b/src/main/java/net/minecraft/server/EntitySquid.java index f47ef643..493b3d8b 100644 --- a/src/main/java/net/minecraft/server/EntitySquid.java +++ b/src/main/java/net/minecraft/server/EntitySquid.java @@ -55,16 +55,11 @@ public class EntitySquid extends EntityWaterAnimal { } protected void dropDeathLoot(boolean flag, int i) { - // CraftBukkit start - Whole method - java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); + int j = this.random.nextInt(3 + i) + 1; - int count = this.random.nextInt(3 + i) + 1; - if (count > 0) { - loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.INK_SACK, count)); + for (int k = 0; k < j; ++k) { + this.a(new ItemStack(Items.INK_SACK, 1, 0), 0.0F); } - - org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot); - // CraftBukkit end } /* CraftBukkit start - Delegate to Entity to use existing inWater value diff --git a/src/main/java/net/minecraft/server/EntityWitch.java b/src/main/java/net/minecraft/server/EntityWitch.java deleted file mode 100644 index 0f5126a4..00000000 --- a/src/main/java/net/minecraft/server/EntityWitch.java +++ /dev/null @@ -1,176 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -import java.util.List; -import java.util.UUID; - -public class EntityWitch extends EntityMonster implements IRangedEntity { - - private static final UUID bp = UUID.fromString("5CD17E52-A79A-43D3-A529-90FDE04B181E"); - private static final AttributeModifier bq = (new AttributeModifier(bp, "Drinking speed penalty", -0.25D, 0)).a(false); - private static final Item[] br = new Item[] { Items.GLOWSTONE_DUST, Items.SUGAR, Items.REDSTONE, Items.SPIDER_EYE, Items.GLASS_BOTTLE, Items.SULPHUR, Items.STICK, Items.STICK}; - private int bs; - - public EntityWitch(World world) { - super(world); - this.goalSelector.a(1, new PathfinderGoalFloat(this)); - this.goalSelector.a(2, new PathfinderGoalArrowAttack(this, 1.0D, 60, 10.0F)); - this.goalSelector.a(2, new PathfinderGoalRandomStroll(this, 1.0D)); - this.goalSelector.a(3, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); - this.goalSelector.a(3, new PathfinderGoalRandomLookaround(this)); - this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, false)); - this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, 0, true)); - } - - protected void c() { - super.c(); - this.getDataWatcher().a(21, Byte.valueOf((byte) 0)); - } - - protected String t() { - return "mob.witch.idle"; - } - - protected String aS() { - return "mob.witch.hurt"; - } - - protected String aT() { - return "mob.witch.death"; - } - - public void a(boolean flag) { - this.getDataWatcher().watch(21, Byte.valueOf((byte) (flag ? 1 : 0))); - } - - public boolean bZ() { - return this.getDataWatcher().getByte(21) == 1; - } - - protected void aC() { - super.aC(); - this.getAttributeInstance(GenericAttributes.a).setValue(26.0D); - this.getAttributeInstance(GenericAttributes.d).setValue(0.25D); - } - - public boolean bj() { - return true; - } - - public void e() { - if (!this.world.isStatic) { - if (this.bZ()) { - if (this.bs-- <= 0) { - this.a(false); - ItemStack itemstack = this.bd(); - - this.setEquipment(0, (ItemStack) null); - if (itemstack != null && itemstack.getItem() == Items.POTION) { - List list = Items.POTION.g(itemstack); - - if (list != null) { - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - MobEffect mobeffect = (MobEffect) iterator.next(); - - this.addEffect(new MobEffect(mobeffect)); - } - } - } - - this.getAttributeInstance(GenericAttributes.d).b(bq); - } - } else { - short short1 = -1; - - if (this.random.nextFloat() < 0.15F && this.a(Material.WATER) && !this.hasEffect(MobEffectList.WATER_BREATHING)) { - short1 = 8237; - } else if (this.random.nextFloat() < 0.15F && this.isBurning() && !this.hasEffect(MobEffectList.FIRE_RESISTANCE)) { - short1 = 16307; - } else if (this.random.nextFloat() < 0.05F && this.getHealth() < this.getMaxHealth()) { - short1 = 16341; - } else if (this.random.nextFloat() < 0.25F && this.getGoalTarget() != null && !this.hasEffect(MobEffectList.FASTER_MOVEMENT) && this.getGoalTarget().f(this) > 121.0D) { - short1 = 16274; - } else if (this.random.nextFloat() < 0.25F && this.getGoalTarget() != null && !this.hasEffect(MobEffectList.FASTER_MOVEMENT) && this.getGoalTarget().f(this) > 121.0D) { - short1 = 16274; - } - - if (short1 > -1) { - this.setEquipment(0, new ItemStack(Items.POTION, 1, short1)); - this.bs = this.bd().n(); - this.a(true); - AttributeInstance attributeinstance = this.getAttributeInstance(GenericAttributes.d); - - attributeinstance.b(bq); - attributeinstance.a(bq); - } - } - - if (this.random.nextFloat() < 7.5E-4F) { - this.world.broadcastEntityEffect(this, (byte) 15); - } - } - - super.e(); - } - - protected float c(DamageSource damagesource, float f) { - f = super.c(damagesource, f); - if (damagesource.getEntity() == this) { - f = 0.0F; - } - - if (damagesource.s()) { - f = (float) ((double) f * 0.15D); - } - - return f; - } - - protected void dropDeathLoot(boolean flag, int i) { - // CraftBukkit start - java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); - - int j = this.random.nextInt(3) + 1; - - for (int k = 0; k < j; ++k) { - int l = this.random.nextInt(3); - Item item = br[this.random.nextInt(br.length)]; - - if (i > 0) { - l += this.random.nextInt(i + 1); - } - - if (l > 0) { - loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), l)); - } - } - - org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot); - // CraftBukkit end - } - - public void a(EntityLiving entityliving, float f) { - if (!this.bZ()) { - EntityPotion entitypotion = new EntityPotion(this.world, this, 32732); - - entitypotion.pitch -= -20.0F; - double d0 = entityliving.locX + entityliving.motX - this.locX; - double d1 = entityliving.locY + (double) entityliving.getHeadHeight() - 1.100000023841858D - this.locY; - double d2 = entityliving.locZ + entityliving.motZ - this.locZ; - float f1 = MathHelper.sqrt(d0 * d0 + d2 * d2); - - if (f1 >= 8.0F && !entityliving.hasEffect(MobEffectList.SLOWER_MOVEMENT)) { - entitypotion.setPotionValue(32698); - } else if (entityliving.getHealth() >= 8.0F && !entityliving.hasEffect(MobEffectList.POISON)) { - entitypotion.setPotionValue(32660); - } else if (f1 <= 3.0F && !entityliving.hasEffect(MobEffectList.WEAKNESS) && this.random.nextFloat() < 0.25F) { - entitypotion.setPotionValue(32696); - } - - entitypotion.shoot(d0, d1 + (double) (f1 * 0.2F), d2, 0.75F, 8.0F); - this.world.addEntity(entitypotion); - } - } -} diff --git a/src/main/java/net/minecraft/server/EntityWither.java b/src/main/java/net/minecraft/server/EntityWither.java index 352f7396..906428dc 100644 --- a/src/main/java/net/minecraft/server/EntityWither.java +++ b/src/main/java/net/minecraft/server/EntityWither.java @@ -400,11 +400,7 @@ public class EntityWither extends EntityMonster implements IRangedEntity { } protected void dropDeathLoot(boolean flag, int i) { - // CraftBukkit start - java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); - loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(Items.NETHER_STAR), 1)); - CraftEventFactory.callEntityDeathEvent(this, loot); - // CraftBukkit end + this.a(Items.NETHER_STAR, 1); if (!this.world.isStatic) { Iterator iterator = this.world.a(EntityHuman.class, this.boundingBox.grow(50.0D, 100.0D, 50.0D)).iterator(); diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java index ecb4abe1..58666de6 100644 --- a/src/main/java/net/minecraft/server/EntityZombie.java +++ b/src/main/java/net/minecraft/server/EntityZombie.java @@ -273,20 +273,20 @@ public class EntityZombie extends EntityMonster { return EnumMonsterType.UNDEAD; } - // CraftBukkit start - Return rare dropped item instead of dropping it - protected ItemStack getRareDrop(int i) { + protected void getRareDrop(int i) { switch (this.random.nextInt(3)) { - case 0: - return new ItemStack(Items.IRON_INGOT, 1, 0); - case 1: - return new ItemStack(Items.CARROT, 1, 0); - case 2: - return new ItemStack(Items.POTATO, 1, 0); - default: - return null; + case 0: + this.a(Items.IRON_INGOT, 1); + break; + + case 1: + this.a(Items.CARROT, 1); + break; + + case 2: + this.a(Items.POTATO, 1); } } - // CraftBukkit end protected void bC() { super.bC(); |