aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/forestry/trees/ForestrySapling.java
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2017-01-17 19:41:46 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2017-01-17 19:41:46 +1000
commit5834a266fdf425ad56558db71691f9b3b0df5e31 (patch)
treeeb2123fde62da27795417fbe9b6afcd31b383adf /src/Java/gtPlusPlus/xmod/forestry/trees/ForestrySapling.java
parent289e41515842ec89d01bfa593504163f75d0950c (diff)
downloadGT5-Unofficial-5834a266fdf425ad56558db71691f9b3b0df5e31.tar.gz
GT5-Unofficial-5834a266fdf425ad56558db71691f9b3b0df5e31.tar.bz2
GT5-Unofficial-5834a266fdf425ad56558db71691f9b3b0df5e31.zip
% Tried to improve the logic for the Tree Farmer, to support Forestry 4.
% Moved COFH API related files. + Added a child mod, for misc handling. $$ Borrowed some code from MFR, to attempt forestry support. (Credit left, will re-do if I even get it working).
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/forestry/trees/ForestrySapling.java')
-rw-r--r--src/Java/gtPlusPlus/xmod/forestry/trees/ForestrySapling.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/xmod/forestry/trees/ForestrySapling.java b/src/Java/gtPlusPlus/xmod/forestry/trees/ForestrySapling.java
new file mode 100644
index 0000000000..7c81ea0928
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/forestry/trees/ForestrySapling.java
@@ -0,0 +1,55 @@
+package gtPlusPlus.xmod.forestry.trees;
+
+import java.util.Random;
+
+import net.minecraft.block.Block;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
+import powercrystals.minefactoryreloaded.api.ReplacementBlock;
+import powercrystals.minefactoryreloaded.farmables.plantables.PlantableStandard;
+import forestry.api.arboriculture.ITreeRoot;
+import forestry.api.genetics.AlleleManager;
+
+public class ForestrySapling extends PlantableStandard
+{
+ private ITreeRoot root;
+
+ public ForestrySapling(Item item, Block block)
+ {
+ super(item, block, WILDCARD, null);
+ root = (ITreeRoot)AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees");
+ _plantedBlock = new ReplacementBlock((Block)null) {
+ @Override
+ public boolean replaceBlock(World world, int x, int y, int z, ItemStack stack) {
+ return root.plantSapling(world, root.getMember(stack), null, x, y, z);
+ }
+ };
+ }
+
+ public Block getPlant()
+ {
+ return _block;
+ }
+
+ @Override
+ public boolean canBePlantedHere(World world, int x, int y, int z, ItemStack stack)
+ {
+ if (!world.isAirBlock(x, y, z))
+ return false;
+
+ return root.getMember(stack).canStay(world, x, y, z);
+ }
+
+ public boolean canFertilize(World world, int x, int y, int z)
+ {
+ return true;
+ }
+
+ public boolean fertilize(World world, Random rand, int x, int y, int z)
+ {
+ Block block = world.getBlock(x, y, z);
+ root.getTree(world, x, y, z).getTreeGenerator(world, x, y, z, true).generate(world, rand, x, y, z);
+ return world.getBlock(x, y, z) != block;
+ }
+}