From b69897ff3d815af9f2faa0c38b1e1a4015c76120 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 16 Nov 2014 15:00:04 -0800 Subject: [PATCH] Fix #326. Don't pollinate decorative vanilla leaves --- src/main/java/forestry/core/utils/Utils.java | 33 +++++++++++--------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/main/java/forestry/core/utils/Utils.java b/src/main/java/forestry/core/utils/Utils.java index c9d24355e..543109033 100755 --- a/src/main/java/forestry/core/utils/Utils.java +++ b/src/main/java/forestry/core/utils/Utils.java @@ -356,7 +356,7 @@ public class Utils { return ersatz; } - public static IPollinatable getOrCreatePollinatable(GameProfile owner, World world, int x, int y, int z) { + public static IPollinatable getOrCreatePollinatable(GameProfile owner, World world, final int x, final int y, final int z) { TileEntity tile = world.getTileEntity(x, y, z); IPollinatable receiver = null; @@ -364,21 +364,26 @@ public class Utils { receiver = (IPollinatable) tile; else if (!world.isAirBlock(x, y, z)) { + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + if (Blocks.leaves == block || Blocks.leaves2 == block) { + if ((meta & 4) != 0) { + // no-decay vanilla leaves. http://minecraft.gamepedia.com/Data_values#Leaves + // Treat them as decorative and don't pollinate. + return null; + } + meta = meta % 3; + } + // Test for ersatz genomes for (Map.Entry entry : AlleleManager.ersatzSpecimen.entrySet()) { - if (!StackUtils.equals(world.getBlock(x, y, z), entry.getKey())) - continue; - - int meta = world.getBlockMetadata(x, y, z); - if (StackUtils.equals(Blocks.leaves, entry.getKey())) - meta = meta & 3; - if (entry.getKey().getItemDamage() != meta) - continue; - - // We matched, replace the leaf block with ours and set the ersatz genome - PluginArboriculture.treeInterface.setLeaves(world, entry.getValue(), owner, x, y, z); - // Now let's pollinate - receiver = (IPollinatable) world.getTileEntity(x, y, z); + if (block == StackUtils.getBlock(entry.getKey()) && entry.getKey().getItemDamage() == meta) { + // We matched, replace the leaf block with ours and set the ersatz genome + PluginArboriculture.treeInterface.setLeaves(world, entry.getValue(), owner, x, y, z); + // Now let's pollinate + receiver = (IPollinatable) world.getTileEntity(x, y, z); + } } }