From 972b2087f202d1b8ebe4195ee83e967f45241b82 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Mon, 19 Dec 2011 16:41:55 +0000 Subject: [PATCH] Fixed bonemeal not being consumed on failed growth attempts. This fixes BUKKIT-337. Thanks to md-5 for the pull request! --- src/main/java/net/minecraft/server/BlockMushroom.java | 7 +++++-- src/main/java/net/minecraft/server/BlockSapling.java | 4 ++++ src/main/java/net/minecraft/server/WorldGenBigTree.java | 3 --- src/main/java/net/minecraft/server/WorldGenForest.java | 3 --- .../java/net/minecraft/server/WorldGenHugeMushroom.java | 3 --- src/main/java/net/minecraft/server/WorldGenTaiga2.java | 3 --- src/main/java/net/minecraft/server/WorldGenTrees.java | 3 --- 7 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/main/java/net/minecraft/server/BlockMushroom.java b/src/main/java/net/minecraft/server/BlockMushroom.java index 3c6e662eb4..2d8cf25fc9 100644 --- a/src/main/java/net/minecraft/server/BlockMushroom.java +++ b/src/main/java/net/minecraft/server/BlockMushroom.java @@ -108,10 +108,13 @@ public class BlockMushroom extends BlockFlower { event = new StructureGrowEvent(location, TreeType.RED_MUSHROOM, bonemeal, player, new ArrayList()); worldgenhugemushroom = new WorldGenHugeMushroom(1); } - if (worldgenhugemushroom != null && event != null){ + if (worldgenhugemushroom != null && event != null) { grown = worldgenhugemushroom.grow(world, random, i, j, k, event, itemstack, world.getWorld()); + if (event.isFromBonemeal() && itemstack != null) { + --itemstack.count; + } } - if (!grown || event.isCancelled()){ + if (!grown || event.isCancelled()) { world.setRawTypeIdAndData(i, j, k, this.id, l); return false; } diff --git a/src/main/java/net/minecraft/server/BlockSapling.java b/src/main/java/net/minecraft/server/BlockSapling.java index db1a3caa11..c9877ba86c 100644 --- a/src/main/java/net/minecraft/server/BlockSapling.java +++ b/src/main/java/net/minecraft/server/BlockSapling.java @@ -70,6 +70,9 @@ public class BlockSapling extends BlockFlower { if (event == null) { return; } + if (event.isFromBonemeal() && itemstack != null) { + --itemstack.count; + } if (!grownTree || event.isCancelled()) { world.setRawTypeIdAndData(i, j, k, this.id, l); } @@ -82,6 +85,7 @@ public class BlockSapling extends BlockFlower { // CraftBukkit start private class BlockChangeWithNotify implements BlockChangeDelegate { + World world; BlockChangeWithNotify(World world) { diff --git a/src/main/java/net/minecraft/server/WorldGenBigTree.java b/src/main/java/net/minecraft/server/WorldGenBigTree.java index 0407b8f53c..14d122a26f 100644 --- a/src/main/java/net/minecraft/server/WorldGenBigTree.java +++ b/src/main/java/net/minecraft/server/WorldGenBigTree.java @@ -401,9 +401,6 @@ public class WorldGenBigTree extends WorldGenerator { for (BlockState state : event.getBlocks()) { state.update(); } - if (event.isFromBonemeal() && itemstack != null) { - --itemstack.count; - } } } // Craftbukkit end diff --git a/src/main/java/net/minecraft/server/WorldGenForest.java b/src/main/java/net/minecraft/server/WorldGenForest.java index 8b014d28a6..3d0ce870e9 100644 --- a/src/main/java/net/minecraft/server/WorldGenForest.java +++ b/src/main/java/net/minecraft/server/WorldGenForest.java @@ -126,9 +126,6 @@ public class WorldGenForest extends WorldGenerator { for (BlockState state : event.getBlocks()) { state.update(true); } - if (event.isFromBonemeal() && itemstack != null) { - --itemstack.count; - } } } // Craftbukkit end diff --git a/src/main/java/net/minecraft/server/WorldGenHugeMushroom.java b/src/main/java/net/minecraft/server/WorldGenHugeMushroom.java index 1da757d884..95ab4979df 100644 --- a/src/main/java/net/minecraft/server/WorldGenHugeMushroom.java +++ b/src/main/java/net/minecraft/server/WorldGenHugeMushroom.java @@ -196,9 +196,6 @@ public class WorldGenHugeMushroom extends WorldGenerator { for (BlockState state : event.getBlocks()) { state.update(true); } - if (event.isFromBonemeal() && itemstack != null) { - --itemstack.count; - } } } // Craftbukkit end diff --git a/src/main/java/net/minecraft/server/WorldGenTaiga2.java b/src/main/java/net/minecraft/server/WorldGenTaiga2.java index c20ffc01a3..47da3a9980 100644 --- a/src/main/java/net/minecraft/server/WorldGenTaiga2.java +++ b/src/main/java/net/minecraft/server/WorldGenTaiga2.java @@ -144,9 +144,6 @@ public class WorldGenTaiga2 extends WorldGenerator { for (BlockState state : event.getBlocks()) { state.update(true); } - if (event.isFromBonemeal() && itemstack != null) { - --itemstack.count; - } } } // Craftbukkit end diff --git a/src/main/java/net/minecraft/server/WorldGenTrees.java b/src/main/java/net/minecraft/server/WorldGenTrees.java index c9c81b64ba..8bcc065210 100644 --- a/src/main/java/net/minecraft/server/WorldGenTrees.java +++ b/src/main/java/net/minecraft/server/WorldGenTrees.java @@ -124,9 +124,6 @@ public class WorldGenTrees extends WorldGenerator { for (BlockState state : event.getBlocks()) { state.update(true); } - if (event.isFromBonemeal() && itemstack != null) { - --itemstack.count; - } } } // Craftbukkit end