From 8fb7d5eb672ee568116120de233ad310f750889d Mon Sep 17 00:00:00 2001 From: InfinityRaider Date: Sat, 3 Oct 2015 14:00:56 +0200 Subject: [PATCH] FlowerRegistry and AgriCraft compatibility update Add to CLA agreement --- cla-signatures.txt | 1 + .../apiculture/flowers/FlowerRegistry.java | 21 ++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/cla-signatures.txt b/cla-signatures.txt index 4674d93ab..4e6e77e4e 100644 --- a/cla-signatures.txt +++ b/cla-signatures.txt @@ -3,3 +3,4 @@ samtrion;samtrion@gmail.com;2015-01-18 GenuineSounds;GenuineSoundsLtd@gmail.com;2015-02-26 airbreather;airbreather@linux.com;2015-04-10 ganymedes01;foka_12@hotmail.com;2015-05-27 +infinityraider;theoneandonlyraider@gmail;com;2015-10-03 diff --git a/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java b/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java index 0f359cd4d..5319a650f 100644 --- a/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java +++ b/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java @@ -34,6 +34,7 @@ import net.minecraft.tileentity.TileEntityFlowerPot; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; +import net.minecraftforge.common.IPlantable; import net.minecraftforge.oredict.OreDictionary; import cpw.mods.fml.common.registry.GameRegistry; @@ -190,15 +191,21 @@ public final class FlowerRegistry implements IFlowerRegistry { meta = world.getBlockMetadata(x, y, z); } - if (PluginManager.Module.AGRICRAFT.isEnabled() && (flowerType.equals(FlowerManager.FlowerTypeWheat) || flowerType.equals(FlowerManager.FlowerTypeNether))) { + if (PluginManager.Module.AGRICRAFT.isEnabled()) { Block cropBlock = GameRegistry.findBlock("AgriCraft", "crops"); if (block == cropBlock) { - ArrayList drops = block.getDrops(world, x, y, z, 7, 0); - if (drops.get(1).getItem() == Items.wheat_seeds && flowerType.equals(FlowerManager.FlowerTypeWheat)) { - return true; - } - if (drops.get(1).getItem() == Items.nether_wart && flowerType.equals(FlowerManager.FlowerTypeNether)) { - return true; + if(block instanceof IPlantable) { + //For agricraft versions which implement IPlantable in the BlockCrop class + block = ((IPlantable) block).getPlant(world, x, y, z); + } else { + //For earlier versions of AgriCraft + ArrayList drops = block.getDrops(world, x, y, z, 7, 0); + if (drops.get(1).getItem() == Items.wheat_seeds && flowerType.equals(FlowerManager.FlowerTypeWheat)) { + return true; + } + if (drops.get(1).getItem() == Items.nether_wart && flowerType.equals(FlowerManager.FlowerTypeNether)) { + return true; + } } } }