diff options
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/forestry')
-rw-r--r-- | src/main/java/gtPlusPlus/xmod/forestry/ForestryTreeHandler.java | 94 | ||||
-rw-r--r-- | src/main/java/gtPlusPlus/xmod/forestry/HANDLER_FR.java | 1 |
2 files changed, 95 insertions, 0 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/forestry/ForestryTreeHandler.java b/src/main/java/gtPlusPlus/xmod/forestry/ForestryTreeHandler.java new file mode 100644 index 0000000000..1f64eacb5c --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/forestry/ForestryTreeHandler.java @@ -0,0 +1,94 @@ +package gtPlusPlus.xmod.forestry; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import binnie.extratrees.genetics.ExtraTreeSpecies; +import forestry.api.arboriculture.EnumGermlingType; +import forestry.api.arboriculture.EnumWoodType; +import forestry.api.arboriculture.ITree; +import forestry.api.arboriculture.TreeManager; +import forestry.arboriculture.genetics.TreeDefinition; +import forestry.plugins.PluginArboriculture; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntityTreeFarm; + +public class ForestryTreeHandler { + + public static void generateForestryTrees() { + for (TreeDefinition tree : TreeDefinition.values()) { + String speciesUID = tree.getUID(); + + ItemStack sapling = tree.getMemberStack(EnumGermlingType.SAPLING); + + ItemStack log; + EnumWoodType woodType = ReflectionUtils.getField(tree, "woodType"); + if (woodType != null) { + log = TreeManager.woodItemAccess.getLog(woodType, false); + } else { + log = ReflectionUtils.getField(tree, "vanillaWood"); + } + + ItemStack leaves = new ItemStack(PluginArboriculture.blocks.leaves, 1, 0); + if (speciesUID != null) { + NBTTagCompound nbtTagCompound = new NBTTagCompound(); + nbtTagCompound.setString("species", speciesUID); + leaves.setTagCompound(nbtTagCompound); + } + + ItemStack fruit = null; + ITree individual = tree.getIndividual(); + if (individual.canBearFruit()) { + ItemStack[] produceList = individual.getProduceList(); + if (produceList != null && produceList.length > 0) { + fruit = individual.getProduceList()[0]; + } + } + + GregtechMetaTileEntityTreeFarm.registerForestryTree( + speciesUID, + sapling == null ? null : sapling.copy(), + log == null ? null : log.copy(), + leaves == null ? null : leaves.copy(), + fruit == null ? null : fruit.copy()); + } + } + + public static void generateExtraTreesTrees() { + for (ExtraTreeSpecies species : ExtraTreeSpecies.values()) { + + String speciesUID = species.getUID(); + + ITree individual = TreeManager.treeRoot.templateAsIndividual(species.getTemplate()); + ItemStack sapling = TreeManager.treeRoot.getMemberStack(individual, 0); + + ItemStack log = null; + if (species.getLog() != null) { + log = species.getLog() + .getItemStack(); + } + + ItemStack leaves = new ItemStack(PluginArboriculture.blocks.leaves, 1, 0); + if (speciesUID != null) { + NBTTagCompound nbtTagCompound = new NBTTagCompound(); + nbtTagCompound.setString("species", speciesUID); + leaves.setTagCompound(nbtTagCompound); + } + + ItemStack fruit = null; + if (individual.canBearFruit()) { + ItemStack[] produceList = individual.getProduceList(); + if (produceList != null && produceList.length > 0) { + fruit = individual.getProduceList()[0]; + } + } + + GregtechMetaTileEntityTreeFarm.registerForestryTree( + speciesUID, + sapling == null ? null : sapling.copy(), + log == null ? null : log.copy(), + leaves == null ? null : leaves.copy(), + fruit == null ? null : fruit.copy()); + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/forestry/HANDLER_FR.java b/src/main/java/gtPlusPlus/xmod/forestry/HANDLER_FR.java index a1b96d0f2f..dc2d277283 100644 --- a/src/main/java/gtPlusPlus/xmod/forestry/HANDLER_FR.java +++ b/src/main/java/gtPlusPlus/xmod/forestry/HANDLER_FR.java @@ -20,4 +20,5 @@ public class HANDLER_FR { new GTPP_Bees(); } } + } |