From 9649317bee1a0621cd4a7ea0e9295571832d629d Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Thu, 12 Jan 2017 00:14:34 +1000 Subject: $ Tree Farmer now grows saplings and has a particle effect. (This is configurable). + Added a getSimpleStack method for blocks, to simplify life. --- .../xmod/forestry/trees/TreefarmManager.java | 57 +++++++++++++--------- 1 file changed, 35 insertions(+), 22 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java') diff --git a/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java b/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java index 65bc3231aa..ba8ffd8284 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java +++ b/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java @@ -2,6 +2,7 @@ package gtPlusPlus.xmod.forestry.trees; import gregtech.api.enums.OrePrefixes; import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.block.Block; @@ -41,35 +42,47 @@ public class TreefarmManager { } return true; } - + @Optional.Method(modid = "Forestry") public static Block getHumus(){ - if(blockHumus != null){ - return blockHumus; - } - else if (ReflectionUtils.doesClassExist("forestry.core.blocks.BlockSoil")){ - try { - Class humusClass = Class.forName("forestry.core.blocks.BlockSoil"); - ItemStack humusStack = ItemUtils.getCorrectStacktype("Forestry:soil", 1); - if (humusClass != null){ - blockHumus = Block.getBlockFromItem(humusStack.getItem()); - return Block.getBlockFromItem(humusStack.getItem()); - } - } catch (ClassNotFoundException e) {} + if(blockHumus != null){ + return blockHumus; + } + else if (ReflectionUtils.doesClassExist("forestry.core.blocks.BlockSoil")){ + try { + Class humusClass = Class.forName("forestry.core.blocks.BlockSoil"); + ItemStack humusStack = ItemUtils.getCorrectStacktype("Forestry:soil", 1); + if (humusClass != null){ + blockHumus = Block.getBlockFromItem(humusStack.getItem()); + return Block.getBlockFromItem(humusStack.getItem()); + } + } catch (ClassNotFoundException e) {} + } + return null; } - return null; -} - + public static boolean isWoodLog(Block log){ String tTool = log.getHarvestTool(0); return OrePrefixes.log.contains(new ItemStack(log, 1))&& ((tTool != null) && (tTool.equals("axe"))) || (log.getMaterial() == Material.wood); } - + public static boolean isLeaves(Block log){ - String tTool = log.getHarvestTool(0); return OrePrefixes.leaves.contains(new ItemStack(log, 1)) || (log.getMaterial() == Material.leaves); } + public static boolean isSapling(Block log){ + if (log != null){ + if (OrePrefixes.sapling.contains(new ItemStack(log, 1))){ + Utils.LOG_INFO(""+log.getLocalizedName()); + } + if (log.getLocalizedName().toLowerCase().contains("sapling")){ + Utils.LOG_INFO(""+log.getLocalizedName()); + return true; + } + } + return OrePrefixes.sapling.contains(new ItemStack(log, 1)); + } + public static boolean isDirtBlock(Block dirt){ return (dirt == Blocks.dirt ? true : (dirt == Blocks.grass ? true : (getHumus() == null ? false : (dirt == blockHumus ? true : false)))); } @@ -77,16 +90,16 @@ public class TreefarmManager { public static boolean isFenceBlock(Block fence){ return (fence == Blocks.fence ? true : (fence == Blocks.fence_gate ? true : (fence == Blocks.nether_brick_fence ? true : false))); } - + public static boolean isAirBlock(Block air){ - + if (air.getLocalizedName().toLowerCase().contains("air")){ return true; } - + return (air == Blocks.air ? true : (air instanceof BlockAir ? true : false)); } - + /*public static boolean isSaplingBlock(Block sapling){ return (sapling == Blocks.sapling ? true : (sapling == Blocks.)) }*/ -- cgit