diff options
author | Jason Mitchell <mitchej@gmail.com> | 2024-08-11 12:51:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-11 15:51:41 -0400 |
commit | 5cd813a5405777a6c92b1af03f7439a97e9523f8 (patch) | |
tree | 0d81c74463e8401e893862758a411f5d90e45788 /src/main/java/gtPlusPlus/xmod/forestry | |
parent | 7e153794ad1f79afa0014b82593060ffedc54a61 (diff) | |
download | GT5-Unofficial-5cd813a5405777a6c92b1af03f7439a97e9523f8.tar.gz GT5-Unofficial-5cd813a5405777a6c92b1af03f7439a97e9523f8.tar.bz2 GT5-Unofficial-5cd813a5405777a6c92b1af03f7439a97e9523f8.zip |
Faster dev boot times (120s --> 80s while profiling) (#2866)
* Faster dev boot times (120s --> 80s while profiling)
* Clean up sloppy hard deps and properly gate them behind isModLoaded() checks.
* Include CoreTweaks as runtime only non publishable for faster boot as well
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(); } } + } |