diff options
author | Celtic Minstrel <celtic.minstrel.ca@some.place> | 2012-03-10 23:19:09 -0500 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2012-03-21 13:11:47 -0400 |
commit | 1c95413f49432104c9c50671b11cf99417d4fcc5 (patch) | |
tree | 2feb535101048c86b32db76000aeb21995292129 /src/main | |
parent | 5ba892804158ba81b655826469363eefa8f0baaa (diff) | |
download | craftbukkit-1c95413f49432104c9c50671b11cf99417d4fcc5.tar craftbukkit-1c95413f49432104c9c50671b11cf99417d4fcc5.tar.gz craftbukkit-1c95413f49432104c9c50671b11cf99417d4fcc5.tar.lz craftbukkit-1c95413f49432104c9c50671b11cf99417d4fcc5.tar.xz craftbukkit-1c95413f49432104c9c50671b11cf99417d4fcc5.zip |
[Bleeding] Fix for creeper getDrops() not reporting the music disk if it was killed by a skeleton. Addresses BUKKIT-1133
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityCreeper.java | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/src/main/java/net/minecraft/server/EntityCreeper.java b/src/main/java/net/minecraft/server/EntityCreeper.java index 00f92a01..4618910b 100644 --- a/src/main/java/net/minecraft/server/EntityCreeper.java +++ b/src/main/java/net/minecraft/server/EntityCreeper.java @@ -1,11 +1,17 @@ package net.minecraft.server; -import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit +// CraftBukkit start +import java.util.List; + +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.entity.ExplosionPrimeEvent; +// CraftBukkit end public class EntityCreeper extends EntityMonster { int fuseTicks; int b; + private int record = -1; // CraftBukkit public EntityCreeper(World world) { super(world); @@ -91,12 +97,43 @@ public class EntityCreeper extends EntityMonster { } public void die(DamageSource damagesource) { - super.die(damagesource); + // CraftBukkit start - rearranged the method (super call to end, drop to dropDeathLoot) if (damagesource.getEntity() instanceof EntitySkeleton) { - this.b(Item.RECORD_1.id + this.random.nextInt(10), 1); + // this.b(Item.RECORD_1.id + this.random.nextInt(10), 1); // CraftBukkit + this.record = Item.RECORD_1.id + this.random.nextInt(10); } + super.die(damagesource); + // CraftBukkit end } + // CraftBukkit start - whole method + protected void dropDeathLoot(boolean flag, int i) { + int j = this.getLootId(); + + List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); + + if (j > 0) { + 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(j, k)); + } + } + + // Drop a music disc? + if (this.record != -1) { + loot.add(new org.bukkit.inventory.ItemStack(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 + public boolean a(Entity entity) { return true; } @@ -131,8 +168,9 @@ public class EntityCreeper extends EntityMonster { public void setPowered(boolean powered) { if (!powered) { this.datawatcher.watch(17, Byte.valueOf((byte) 0)); - } else + } else { + this.datawatcher.watch(17, Byte.valueOf((byte) 1)); + } // CraftBukkit end - this.datawatcher.watch(17, Byte.valueOf((byte) 1)); } } |