diff options
author | feildmaster <admin@feildmaster.com> | 2012-03-23 06:08:54 -0500 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2012-03-23 07:18:20 -0400 |
commit | 40e096273576ec5f0f49490f3167095d8678cbd8 (patch) | |
tree | 8b322b89c49f47ac5156ee3968444683328c3634 /src | |
parent | ff22e4e3419b0bef85b6cf0e8cefe27711fc27ff (diff) | |
download | craftbukkit-40e096273576ec5f0f49490f3167095d8678cbd8.tar craftbukkit-40e096273576ec5f0f49490f3167095d8678cbd8.tar.gz craftbukkit-40e096273576ec5f0f49490f3167095d8678cbd8.tar.lz craftbukkit-40e096273576ec5f0f49490f3167095d8678cbd8.tar.xz craftbukkit-40e096273576ec5f0f49490f3167095d8678cbd8.zip |
Seriously fix natural drops. Fixes BUKKIT-1297 and fixes BUKKIT-1295
Diffstat (limited to 'src')
11 files changed, 27 insertions, 35 deletions
diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java index d61be04c..805caf90 100644 --- a/src/main/java/net/minecraft/server/Block.java +++ b/src/main/java/net/minecraft/server/Block.java @@ -164,7 +164,7 @@ public class Block { public final Material material; public float frictionFactor; private String name; - protected ArrayList<ItemStack> dropList; // CraftBukkit + protected ArrayList<ItemStack> dropList = new ArrayList<ItemStack>(); // CraftBukkit protected Block(int i, Material material) { this.bR = true; @@ -339,6 +339,7 @@ public class Block { public final void b(World world, int i, int j, int k, int l, int i1) { this.dropNaturally(world, i, j, k, l, 1.0F, i1); + this.doActualDrop(world, i, j, k); // CraftBukkit } public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) { @@ -360,15 +361,11 @@ public class Block { protected void a(World world, int i, int j, int k, ItemStack itemstack) { // CraftBukkit start - the logic of this function is moved into finishDrop - if (this.dropList != null) { - this.dropList.add(itemstack); - } else { - this.finishDrop(world, i, j, k, itemstack); - } + // This is such a hackish change it's rediculous. + this.dropList.add(itemstack); } public final void finishDrop(World world, int i, int j, int k, ItemStack itemstack) { - this.dropList = null; // CraftBukkit end if (!world.isStatic) { float f = 0.7F; @@ -542,13 +539,14 @@ public class Block { entityhuman.a(StatisticList.C[this.id], 1); entityhuman.c(0.025F); // CraftBukkit start - A way to separate statistics from the logic of determining what to drop - this.doActualDrop(world, entityhuman, i, j, k, l); + this.doActualDrop(world, i, j, k); } - public void doActualDrop(World world, EntityHuman entityhuman, int i, int j, int k, int l) { - for (ItemStack stack : dropList) { + public void doActualDrop(World world, int i, int j, int k) { + for (ItemStack stack : this.dropList) { finishDrop(world, i, j, k, stack); } + this.dropList.clear(); } public void setDrops(ArrayList<ItemStack> drops) { @@ -556,7 +554,6 @@ public class Block { } public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) { - this.dropList = new ArrayList<ItemStack>(); // CraftBukkit end if (this.h() && EnchantmentManager.hasSilkTouchEnchantment(entityhuman.inventory)) { ItemStack itemstack = this.a_(l); diff --git a/src/main/java/net/minecraft/server/BlockDeadBush.java b/src/main/java/net/minecraft/server/BlockDeadBush.java index 7486f92e..60f53b88 100644 --- a/src/main/java/net/minecraft/server/BlockDeadBush.java +++ b/src/main/java/net/minecraft/server/BlockDeadBush.java @@ -30,7 +30,7 @@ public class BlockDeadBush extends BlockFlower { /* CraftBukkit start - moved this line into calculateDrops this.a(world, i, j, k, new ItemStack(Block.DEAD_BUSH, 1, l)); */ - this.doActualDrop(world, entityhuman, i, j, k, l); + this.doActualDrop(world, i, j, k); // CraftBukkit end } else { super.a(world, entityhuman, i, j, k, l); @@ -40,9 +40,8 @@ public class BlockDeadBush extends BlockFlower { // CraftBukkit start - Calculate drops public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) { if (!world.isStatic && entityhuman.U() != null && entityhuman.U().id == Item.SHEARS.id) { - super.dropList = new ArrayList<ItemStack>(); this.a(world, i, j, k, new ItemStack(Block.DEAD_BUSH, 1, l)); - return super.dropList; + return this.dropList; } else { return super.calculateDrops(world, entityhuman, i, j, k, l); } diff --git a/src/main/java/net/minecraft/server/BlockLeaves.java b/src/main/java/net/minecraft/server/BlockLeaves.java index 686f0f89..6345fafc 100644 --- a/src/main/java/net/minecraft/server/BlockLeaves.java +++ b/src/main/java/net/minecraft/server/BlockLeaves.java @@ -165,7 +165,7 @@ public class BlockLeaves extends BlockTransparant { /* CraftBukkit start - moved this line into calculateDrops this.a(world, i, j, k, new ItemStack(Block.LEAVES.id, 1, l & 3)); */ - this.doActualDrop(world, entityhuman, i, j, k, l); + this.doActualDrop(world, i, j, k); // CraftBukkit end } else { super.a(world, entityhuman, i, j, k, l); @@ -175,9 +175,8 @@ public class BlockLeaves extends BlockTransparant { // CraftBukkit start - Calculate drops public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) { if (!world.isStatic && entityhuman.U() != null && entityhuman.U().id == Item.SHEARS.id) { - super.dropList = new ArrayList<ItemStack>(); this.a(world, i, j, k, new ItemStack(Block.LEAVES.id, 1, l & 3)); - return super.dropList; + return this.dropList; } else { return super.calculateDrops(world, entityhuman, i, j, k, l); } diff --git a/src/main/java/net/minecraft/server/BlockLongGrass.java b/src/main/java/net/minecraft/server/BlockLongGrass.java index 4a052a5a..f98ae327 100644 --- a/src/main/java/net/minecraft/server/BlockLongGrass.java +++ b/src/main/java/net/minecraft/server/BlockLongGrass.java @@ -30,7 +30,7 @@ public class BlockLongGrass extends BlockFlower { /* CraftBukkit start - moved this line into calculateDrops this.a(world, i, j, k, new ItemStack(Block.LONG_GRASS, 1, l)); */ - this.doActualDrop(world, entityhuman, i, j, k, l); + this.doActualDrop(world, i, j, k); // CraftBukkit end } else { super.a(world, entityhuman, i, j, k, l); @@ -40,9 +40,8 @@ public class BlockLongGrass extends BlockFlower { // CraftBukkit start - Calculate drops public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) { if (!world.isStatic && entityhuman.U() != null && entityhuman.U().id == Item.SHEARS.id) { - super.dropList = new ArrayList<ItemStack>(); this.a(world, i, j, k, new ItemStack(Block.LONG_GRASS, 1, l)); - return super.dropList; + return this.dropList; } else { return super.calculateDrops(world, entityhuman, i, j, k, l); } diff --git a/src/main/java/net/minecraft/server/BlockPistonExtension.java b/src/main/java/net/minecraft/server/BlockPistonExtension.java index 28adc7f3..3ead3a4a 100644 --- a/src/main/java/net/minecraft/server/BlockPistonExtension.java +++ b/src/main/java/net/minecraft/server/BlockPistonExtension.java @@ -17,7 +17,7 @@ public class BlockPistonExtension extends Block { public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int d) { super.calculateDrops(world, entityhuman, i, j, k, d); int l = world.getData(i, j, k) & 0x7; - if (l > 5 || l < 0) return super.dropList; + if (l > 5 || l < 0) return this.dropList; int i1 = Facing.OPPOSITE_FACING[b(l)]; i += Facing.b[i1]; @@ -26,9 +26,9 @@ public class BlockPistonExtension extends Block { int j1 = world.getTypeId(i, j, k); if (j1 == Block.PISTON.id || j1 == Block.PISTON_STICKY.id) { - super.dropList.add(new ItemStack(Block.byId[j1], 1)); + this.dropList.add(new ItemStack(Block.byId[j1], 1)); } - return super.dropList; + return this.dropList; } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/BlockSnow.java b/src/main/java/net/minecraft/server/BlockSnow.java index 3c6cfe15..ea63188a 100644 --- a/src/main/java/net/minecraft/server/BlockSnow.java +++ b/src/main/java/net/minecraft/server/BlockSnow.java @@ -66,8 +66,8 @@ public class BlockSnow extends Block { entityitem.pickupDelay = 10; world.addEntity(entityitem); - // */ - super.doActualDrop(world, entityhuman, i, j, k, l); + */ + this.doActualDrop(world, i, j, k); // CraftBukkit end world.setTypeId(i, j, k, 0); entityhuman.a(StatisticList.C[this.id], 1); @@ -75,9 +75,8 @@ public class BlockSnow extends Block { // CraftBukkit start - Calculate drops public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) { - super.dropList = new ArrayList<ItemStack>(); this.a(world, i, j, k, new ItemStack(Item.SNOW_BALL.id, 1, 1)); - return super.dropList; + return this.dropList; } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/BlockVine.java b/src/main/java/net/minecraft/server/BlockVine.java index 0fbdbb49..2180dc17 100644 --- a/src/main/java/net/minecraft/server/BlockVine.java +++ b/src/main/java/net/minecraft/server/BlockVine.java @@ -290,7 +290,7 @@ public class BlockVine extends Block { /* CraftBukkit start - moved this line into calculateDrops this.a(world, i, j, k, new ItemStack(Block.VINE, 1, 0)); */ - this.doActualDrop(world, entityhuman, i, j, k, l); + this.doActualDrop(world, i, j, k); // CraftBukkit end } else { super.a(world, entityhuman, i, j, k, l); diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java index e4ba3207..d00d4232 100644 --- a/src/main/java/net/minecraft/server/Explosion.java +++ b/src/main/java/net/minecraft/server/Explosion.java @@ -243,10 +243,11 @@ public class Explosion { this.world.a("smoke", d0, d1, d2, d3, d4, d5); } - // CraftBukkit - stop explosions from putting out fire + // CraftBukkit start - stop explosions from putting out fire if (i1 > 0 && i1 != Block.FIRE.id) { - // CraftBukkit Block.byId[i1].dropNaturally(this.world, j, k, l, this.world.getData(j, k, l), event.getYield(), 0); + Block.byId[i1].doActualDrop(this.world, j, k, l); + // CraftBukkit end this.world.setTypeId(j, k, l, 0); Block.byId[i1].wasExploded(this.world, j, k, l); } diff --git a/src/main/java/net/minecraft/server/ItemInWorldManager.java b/src/main/java/net/minecraft/server/ItemInWorldManager.java index 8a3ece84..fbaf45ba 100644 --- a/src/main/java/net/minecraft/server/ItemInWorldManager.java +++ b/src/main/java/net/minecraft/server/ItemInWorldManager.java @@ -218,7 +218,7 @@ public class ItemInWorldManager { if (this.isCreative()) { // CraftBukkit start - honour additions to drop list - Block.byId[l].doActualDrop(this.world, this.player, i, j, k, i1); + Block.byId[l].doActualDrop(this.world, i, j, k); // CraftBukkit end ((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world)); } else { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 25967d91..602f806f 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -1056,6 +1056,7 @@ public class CraftWorld implements World { int blockZ = block.getZ(); // following code is lifted from Explosion.a(boolean), and modified net.minecraft.server.Block.byId[blockId].dropNaturally(this.world, blockX, blockY, blockZ, block.getData(), yield, 0); + net.minecraft.server.Block.byId[blockId].doActualDrop(this.world, blockX, blockY, blockZ); block.setType(org.bukkit.Material.AIR); // not sure what this does, seems to have something to do with the 'base' material of a block. // For example, WOODEN_STAIRS does something with WOOD in this method diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index b667b21d..6e89ef4d 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -348,10 +348,7 @@ public class CraftBlock implements Block { setTypeId(Material.AIR.getId()); if (block != null) { - block.dropNaturally(chunk.getHandle().world, x, y, z, data, 1.0F, 0); - for (ItemStack item : getDrops()) { - block.finishDrop(chunk.getHandle().world, x, y, z, CraftItemStack.createNMSItemStack(item)); - } + block.b(chunk.getHandle().world, x, y, z, data, 0); return true; } return false; |