1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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.MTETreeFarm;
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];
}
}
MTETreeFarm.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];
}
}
MTETreeFarm.registerForestryTree(
speciesUID,
sapling == null ? null : sapling.copy(),
log == null ? null : log.copy(),
leaves == null ? null : leaves.copy(),
fruit == null ? null : fruit.copy());
}
}
}
|