From 8809265f7649c0bb95f95dfa30ed5b1c4298c3e8 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Tue, 17 Dec 2013 17:26:02 -0600 Subject: [PATCH] Check pending blocks before falling back to world. Fixes BUKKIT-5122 When growing trees we use a BlockChangeDelegate which queues up the block changes so plugins can modify/block/log tree growing. However, we always check the actual world when checking for existing blocks. This means when the tree growing code checks to see if putting a leaf in a block is valid it may incorrectly overwrite a log block that should exist in that location. To ensure trees grow correctly we now check the delegate itself for blocks that match the queried location before checking the world. By: Travis Watkins --- .../craftbukkit/util/StructureGrowDelegate.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/StructureGrowDelegate.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/StructureGrowDelegate.java index 6566b9e0c..bb6a57965 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/StructureGrowDelegate.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/StructureGrowDelegate.java @@ -3,6 +3,8 @@ package org.bukkit.craftbukkit.util; import java.util.ArrayList; import java.util.List; +import net.minecraft.server.Block; +import net.minecraft.server.Blocks; import net.minecraft.server.World; import org.bukkit.BlockChangeDelegate; @@ -39,6 +41,12 @@ public class StructureGrowDelegate implements BlockChangeDelegate { } public int getTypeId(int x, int y, int z) { + for (BlockState state : blocks) { + if (state.getX() == x && state.getY() == y && state.getZ() == z) { + return state.getTypeId(); + } + } + return world.getBlockTypeIdAt(x, y, z); } @@ -51,6 +59,12 @@ public class StructureGrowDelegate implements BlockChangeDelegate { } public boolean isEmpty(int x, int y, int z) { + for (BlockState state : blocks) { + if (state.getX() == x && state.getY() == y && state.getZ() == z) { + return Block.e(state.getTypeId()) == Blocks.AIR; + } + } + return world.getBlockAt(x, y, z).isEmpty(); } }