aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2017-01-22 19:04:57 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2017-01-22 19:04:57 +1000
commitc1b64f033bb479ebbb031eb7b33ac8831d040c00 (patch)
treefd3a7c5e01c6c54194d86ceb9a9e2211a4aed942 /src/Java/gtPlusPlus
parent9dd4ec3dce97a5aff9a1501a684fe02a75055940 (diff)
downloadGT5-Unofficial-c1b64f033bb479ebbb031eb7b33ac8831d040c00.tar.gz
GT5-Unofficial-c1b64f033bb479ebbb031eb7b33ac8831d040c00.tar.bz2
GT5-Unofficial-c1b64f033bb479ebbb031eb7b33ac8831d040c00.zip
+ Added a FarmAI to the Tree Farmer, which handles Forestry saplings. (Will eventually also do block breaks too).
+ Added handling of the block break particles.
Diffstat (limited to 'src/Java/gtPlusPlus')
-rw-r--r--src/Java/gtPlusPlus/core/lib/CORE.java2
-rw-r--r--src/Java/gtPlusPlus/core/players/FakeFarmer.java84
-rw-r--r--src/Java/gtPlusPlus/core/util/particles/BlockBreakParticles.java17
-rw-r--r--src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java18
-rw-r--r--src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java5
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityTreeFarm.java346
6 files changed, 316 insertions, 156 deletions
diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java
index 4988db3402..8c38ae9bb3 100644
--- a/src/Java/gtPlusPlus/core/lib/CORE.java
+++ b/src/Java/gtPlusPlus/core/lib/CORE.java
@@ -18,7 +18,7 @@ import net.minecraftforge.common.config.Configuration;
public class CORE {
protected CORE(){
-
+ //import cpw.mods.fml.common.Optional;
}
public final static float PI = (float) Math.PI;
diff --git a/src/Java/gtPlusPlus/core/players/FakeFarmer.java b/src/Java/gtPlusPlus/core/players/FakeFarmer.java
new file mode 100644
index 0000000000..a7db952efd
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/players/FakeFarmer.java
@@ -0,0 +1,84 @@
+package gtPlusPlus.core.players;
+
+import java.util.UUID;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.item.ItemStack;
+import net.minecraft.network.play.client.C15PacketClientSettings;
+import net.minecraft.server.management.ItemInWorldManager;
+import net.minecraft.stats.StatBase;
+import net.minecraft.util.*;
+import net.minecraft.world.World;
+import net.minecraft.world.WorldServer;
+
+import com.mojang.authlib.GameProfile;
+
+import cpw.mods.fml.common.FMLCommonHandler;
+
+public class FakeFarmer extends EntityPlayerMP {
+ private static final UUID uuid = UUID.fromString("c1ddfd7f-120a-4437-8b64-38660d3ec62d");
+
+ private static GameProfile FAKE_PROFILE = new GameProfile(uuid, "[GT_Farm_Manager]");
+
+ public FakeFarmer(WorldServer world) {
+ super(FMLCommonHandler.instance().getMinecraftServerInstance(), world, FAKE_PROFILE, new ItemInWorldManager(world));
+ }
+
+ @Override
+ public boolean canCommandSenderUseCommand(int i, String s) {
+ return false;
+ }
+
+ @Override
+ public ChunkCoordinates getPlayerCoordinates() {
+ return new ChunkCoordinates(0, 0, 0);
+ }
+
+ @Override
+ public void addChatComponentMessage(IChatComponent chatmessagecomponent) {
+ }
+
+ @Override
+ public void addChatMessage(IChatComponent p_145747_1_) {
+ }
+
+ @Override
+ public void addStat(StatBase par1StatBase, int par2) {
+ }
+
+ @Override
+ public void openGui(Object mod, int modGuiId, World world, int x, int y, int z) {
+ }
+
+ @Override
+ public boolean isEntityInvulnerable() {
+ return true;
+ }
+
+ @Override
+ public boolean canAttackPlayer(EntityPlayer player) {
+ return false;
+ }
+
+ @Override
+ public void onDeath(DamageSource source) {
+ }
+
+ @Override
+ public void onUpdate() {
+ }
+
+ @Override
+ public void travelToDimension(int dim) {
+ }
+
+ @Override
+ public void func_147100_a(C15PacketClientSettings pkt) {
+ }
+
+ @Override
+ public boolean canPlayerEdit(int par1, int par2, int par3, int par4, ItemStack par5ItemStack) {
+ return true;
+ }
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/util/particles/BlockBreakParticles.java b/src/Java/gtPlusPlus/core/util/particles/BlockBreakParticles.java
new file mode 100644
index 0000000000..df0910da99
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/util/particles/BlockBreakParticles.java
@@ -0,0 +1,17 @@
+package gtPlusPlus.core.util.particles;
+
+import gtPlusPlus.xmod.forestry.HANDLER_FR;
+import net.minecraft.block.Block;
+import net.minecraft.world.World;
+
+public class BlockBreakParticles {
+
+ public BlockBreakParticles(World world, int x, int y, int z, Block block){
+ try {
+ HANDLER_FR.createBlockBreakParticles(world, x, y, z, block);
+ } catch (Throwable T){
+
+ }
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java b/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java
index cc2e77c448..e92aa40ca2 100644
--- a/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java
+++ b/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java
@@ -1,10 +1,14 @@
package gtPlusPlus.xmod.forestry;
+import forestry.core.proxy.Proxies;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.lib.LoadedMods;
import gtPlusPlus.xmod.forestry.bees.alveary.AlvearyHandler;
import gtPlusPlus.xmod.forestry.bees.items.FR_ItemRegistry;
import gtPlusPlus.xmod.forestry.bees.recipe.FR_Gregtech_Recipes;
+import net.minecraft.block.Block;
+import net.minecraft.world.World;
+import cpw.mods.fml.common.Optional;
public class HANDLER_FR {
@@ -29,4 +33,18 @@ public class HANDLER_FR {
FR_Gregtech_Recipes.registerItems();
}
}
+
+ public static boolean createBlockBreakParticles(World world, int x, int y, int z, Block block){
+ if (LoadedMods.Forestry){
+ createBlockBreakParticles_INTERNAL(world, x, y, z, block);
+ }
+ return false;
+ }
+
+ @Optional.Method(modid = "Forestry")
+ private static void createBlockBreakParticles_INTERNAL(World world, int x, int y, int z, Block block){
+ Proxies.common.addBlockDestroyEffects(world, x, y, z, block, 0);
+ }
+
+
}
diff --git a/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java b/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java
index 121c1849b5..5617d820d0 100644
--- a/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java
+++ b/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java
@@ -67,6 +67,11 @@ public class TreefarmManager {
if (log == Blocks.log || log == Blocks.log2){
return true;
}
+
+ //Forestry/General Compat
+ if (log.getClass().getName().toLowerCase().contains("blocklog")){
+ return true;
+ }
//IC2 Rubber Tree Compat
if (log.getClass().getName().toLowerCase().contains("rubwood") || log.getClass().getName().toLowerCase().contains("rubleaves")){
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityTreeFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityTreeFarm.java
index 1f8d812639..56c5e9b8dc 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityTreeFarm.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityTreeFarm.java
@@ -1,5 +1,10 @@
package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi;
+import forestry.api.arboriculture.ITree;
+import forestry.api.arboriculture.TreeManager;
+import forestry.api.genetics.IIndividual;
+import forestry.core.utils.GeneticsUtil;
+import forestry.plugins.PluginManager;
import gregtech.api.GregTech_API;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.interfaces.ITexture;
@@ -11,10 +16,13 @@ import gregtech.api.objects.GT_ItemStack;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
+import gtPlusPlus.core.lib.LoadedMods;
+import gtPlusPlus.core.players.FakeFarmer;
import gtPlusPlus.core.slots.SlotBuzzSaw.SAWTOOL;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.item.ItemUtils;
import gtPlusPlus.core.util.math.MathUtils;
+import gtPlusPlus.core.util.particles.BlockBreakParticles;
import gtPlusPlus.xmod.forestry.trees.TreefarmManager;
import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_TreeFarmer;
import gtPlusPlus.xmod.gregtech.api.gui.GUI_TreeFarmer;
@@ -24,12 +32,12 @@ import gtPlusPlus.xmod.gregtech.common.helpers.TreeFarmHelper;
import java.util.ArrayList;
import net.minecraft.block.Block;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.entity.player.InventoryPlayer;
-import net.minecraft.init.Blocks;
+import net.minecraft.entity.player.*;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
+import cpw.mods.fml.common.Optional;
public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlockBase {
@@ -38,6 +46,8 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
/* private */ private int cleanupTicks = 0;
/* private */ public long mInternalPower = 0;
/* private */ private static int powerDrain = 32;
+
+ private EntityPlayerMP farmerAI;
private SAWTOOL mCurrentMachineTool = SAWTOOL.NONE;
private boolean canChop = false;
@@ -66,7 +76,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
"Blue/Yellow: Controller"
};
}
-
+
public long getStoredInternalPower(){
//Utils.LOG_MACHINE_INFO("returning "+this.mInternalPower+"EU to the called method.");
return this.mInternalPower;
@@ -159,10 +169,10 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
return new GUI_TreeFarmer(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "TreeFarmer.png");
}
- @Override
+ @Override
public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
- return new CONTAINER_TreeFarmer(aPlayerInventory, aBaseMetaTileEntity);
- }
+ return new CONTAINER_TreeFarmer(aPlayerInventory, aBaseMetaTileEntity);
+ }
@Override
public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
@@ -223,11 +233,6 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
if (!TreefarmManager.isDirtBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) {
Utils.LOG_MACHINE_INFO("Dirt like block missing from inner 14x14.");
Utils.LOG_MACHINE_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName());
- aBaseMetaTileEntity.getWorld().setBlock(
- (aBaseMetaTileEntity.getXCoord()+(xDir+i)),
- (aBaseMetaTileEntity.getYCoord()+(h)),
- (aBaseMetaTileEntity.getZCoord()+(zDir+j)),
- Blocks.melon_block);
return false;
}
}
@@ -308,7 +313,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
@Override
public int getPollutionPerTick(final ItemStack aStack) {
- return 0;
+ return 1;
}
@Override
@@ -334,122 +339,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
return false;
}
- //Tree Manager
- private void tickTrees(){
- if (treeCheckTicks > 200){
- treeCheckTicks = 0;
- }
- else {
- treeCheckTicks++;
- }
- }
-
- private void tickSaplings(){
- if (plantSaplingTicks > 200){
- plantSaplingTicks = 0;
- }
- else {
- plantSaplingTicks++;
- }
- }
- private void tickCleanup(){
- if (cleanupTicks > 600){
- cleanupTicks = 0;
- }
- else {
- cleanupTicks++;
- }
- }
-
- private void tickHandler(){
- //Count Sapling Timer
- tickSaplings();
- //Count Tree Cutting Timer
- tickTrees();
- //Tick Cleanup script Timer.
- tickCleanup();
- }
-
-
- @Override
- public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
- //super.onPostTick(aBaseMetaTileEntity, aTick);
- if (aBaseMetaTileEntity.isServerSide()) {
-
- //Does it have a tool this cycle to cut?
- boolean validCuttingTool = false;
- boolean isRepaired = isMachineRepaired();
- //Add some Power
- addPowerToInternalStorage();
-
- //Check Inventory slots [1] - Find a valid Buzzsaw Blade or a Saw
- try {
- validCuttingTool = isCorrectMachinePart(mInventory[1]);
- if (validCuttingTool){
- this.mMaxProgresstime = 600;
- String materialName = GT_MetaGenerated_Tool.getPrimaryMaterial(mInventory[1]).mDefaultLocalName;
- if (materialName.toLowerCase().contains("null")){
-
- }
- else {
-
- }
- }
- else {
- this.mMaxProgresstime = 0;
- }
- } catch (NullPointerException t){}
-
- if (isRepaired){
- //If Machine can work and it's only once every 5 seconds this will tick.
- if (canChop){
- //Set Machine State
- if (treeCheckTicks == 200){
- Utils.LOG_MACHINE_INFO("Looking For Trees - Serverside | "+treeCheckTicks);
- //Find wood to Cut
- if (validCuttingTool){
- findLogs(aBaseMetaTileEntity);
- }
- else {
- Utils.LOG_MACHINE_INFO("Did not find a valid saw or Buzzsaw blade.");
- }
- }
- }
- else {
- if (plantSaplingTicks == 100){
- Utils.LOG_MACHINE_INFO("Looking For space to plant saplings - Serverside | "+plantSaplingTicks);
- //Plant Some Saplings
- plantSaplings(aBaseMetaTileEntity);
- }
- else if (plantSaplingTicks == 200){
- Utils.LOG_MACHINE_INFO("Looking For Saplings to grow - Serverside | "+plantSaplingTicks);
- //Try Grow some Saplings
- findSaplings(aBaseMetaTileEntity);
- //Set can work state
- this.mInputBusses = new ArrayList<GT_MetaTileEntity_Hatch_InputBus>();
- this.mEnergyHatches = new ArrayList<GT_MetaTileEntity_Hatch_Energy>();
- canChop = checkMachine(aBaseMetaTileEntity, mInventory[1]);
- }
- }
- //Call Cleanup Task last, before ticking.
- if (cleanupTicks == 600){
- Utils.LOG_MACHINE_INFO("Looking For rubbish to cleanup - Serverside | "+cleanupTicks);
- //cleanUp(aBaseMetaTileEntity);
- }
- //Tick TE
- tickHandler();
- }
- else {
- if (treeCheckTicks == 200 || plantSaplingTicks == 100 || plantSaplingTicks == 200 || cleanupTicks == 600){
- Utils.LOG_MACHINE_INFO("Machine is not fully repaired, not ticking.");
- }
- }
-
- }
- //Client Side - do nothing
-
- }
private boolean findLogs(final IGregTechTileEntity aBaseMetaTileEntity){
@@ -579,24 +469,15 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
Utils.LOG_MACHINE_INFO("found "+n.getDisplayName());
if (OrePrefixes.sapling.contains(n) || n.getDisplayName().toLowerCase().contains("sapling")){
Utils.LOG_MACHINE_INFO(""+n.getDisplayName());
+
counter = n.stackSize;
- //Works for everything but forestry saplings - TODO
- Block saplingToPlace;
- if (n.getClass().getName().toLowerCase().contains("forestry")){
- Utils.LOG_MACHINE_INFO("It's a forestry sapling, trying magic.");
- saplingToPlace = Block.getBlockFromItem(ItemUtils.getItem("Forestry:saplingGE"));
-
- }
- else {
- saplingToPlace = Block.getBlockFromItem(n.getItem());
- }
+ Block saplingToPlace = Block.getBlockFromItem(n.getItem());
+
//Find Gaps for Saplings after scanning Item Busses
for (int i = -7; i <= 7; i++) {
INNER : for (int j = -7; j <= 7; j++) {
- int h = 1;
-
-
+ int h = 1;
if (counter > 0){
if ((i != -7 && i != 7) && (j != -7 && j != 7)) {
if (TreefarmManager.isAirBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))){
@@ -607,12 +488,18 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
posY = aBaseMetaTileEntity.getYCoord()+h;
posZ = aBaseMetaTileEntity.getZCoord()+zDir+j;
- //If sapling block is not null
- if (saplingToPlace != null){
- Utils.LOG_MACHINE_INFO("Placing Sapling Block.");
+ //If sapling block is not null || Ignore if forestry is loaded.
+ if ((saplingToPlace != null && !LoadedMods.Forestry) || LoadedMods.Forestry){
+
//Plant Sapling
- //world.setBlock(posX, posY, posZ, saplingToPlace);
- //world.setBlockMetadataWithNotify(posX, posY, posZ, n.getItemDamage(), 4);
+ if (!LoadedMods.Forestry){
+ world.setBlock(posX, posY, posZ, saplingToPlace);
+ world.setBlockMetadataWithNotify(posX, posY, posZ, n.getItemDamage(), 4);
+ }
+ else {
+ plantSaplingAt(n, this.getBaseMetaTileEntity().getWorld(), posX, posY, posZ);
+ }
+
//Deplete Input stack
depleteInputEx(n);
drainEnergyInput(powerDrain);
@@ -642,12 +529,12 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
continue INNER;
}
}
-
- } //TODO
+
+ } //TODO
else {
break OUTER;
}
-
+
}
}
}
@@ -666,6 +553,19 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
Utils.LOG_MACHINE_INFO("Tried to plant saplings: | "+saplings );
return true;
}
+
+ @Optional.Method(modid = "Forestry")
+ public boolean plantSaplingAt(ItemStack germling, World world, int x, int y, int z) {
+ Utils.LOG_MACHINE_INFO("Planting Sapling with Forestry method, since it's installed.");
+ if (PluginManager.Module.ARBORICULTURE.isEnabled()) {
+ IIndividual tree = GeneticsUtil.getGeneticEquivalent(germling);
+ if (!(tree instanceof ITree)) {
+ return false;
+ }
+ return TreeManager.treeRoot.plantSapling(world, (ITree) tree, farmerAI.getGameProfile(), x, y, z);
+ }
+ return germling.copy().tryPlaceItemIntoWorld(farmerAI, world, x, y - 1, z, 1, 0.0F, 0.0F, 0.0F);
+ }
private boolean cutLog(final World world, final int x, final int y, final int z){
//Utils.LOG_MACHINE_INFO("Cutting Log");
@@ -695,6 +595,8 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
int dropMeta = world.getBlockMetadata(x, y, z);
ArrayList<ItemStack> blockDrops = block.getDrops(world, x, y, z, dropMeta, 0);
ItemStack[] drops = ItemUtils.getBlockDrops(blockDrops);
+
+ //Add Drops
if (drops != null){
for (ItemStack outputs : drops){
if (chanceForLeaves > 990){
@@ -704,17 +606,21 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
updateSlots();
}
}
- //Remove drop that was added to the bus.
- world.setBlockToAir(x, y, z);
- return true;
- }
+
+ }
+
+ //Remove drop that was added to the bus.
+ world.setBlockToAir(x, y, z);
+ new BlockBreakParticles(world, x, y, z, block);
+ return true;
+
} catch (NullPointerException e){}
return false;
}
-
-
+
+
public boolean depleteInputEx(ItemStack aStack) {
if (GT_Utility.isStackInvalid(aStack)) return false;
@@ -737,4 +643,134 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
return false;
}
+ //Tree Manager
+ private void tickTrees(){
+ if (treeCheckTicks > 200){
+ treeCheckTicks = 0;
+ }
+ else {
+ treeCheckTicks++;
+ }
+ }
+
+ private void tickSaplings(){
+ if (plantSaplingTicks > 200){
+ plantSaplingTicks = 0;
+ }
+ else {
+ plantSaplingTicks++;
+ }
+ }
+
+ private void tickCleanup(){
+ if (cleanupTicks > 600){
+ cleanupTicks = 0;
+ }
+ else {
+ cleanupTicks++;
+ }
+ }
+
+ private void tickHandler(){
+ //Count Sapling Timer
+ tickSaplings();
+ //Count Tree Cutting Timer
+ tickTrees();
+ //Tick Cleanup script Timer.
+ tickCleanup();
+ }
+
+ public EntityPlayerMP getFakePlayer() {
+ return this.farmerAI;
+ }
+
+ @Override
+ public boolean onRunningTick(ItemStack aStack) {
+ return super.onRunningTick(aStack);
+ }
+
+ @Override
+ public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
+ //super.onPostTick(aBaseMetaTileEntity, aTick);
+ if (aBaseMetaTileEntity.isServerSide()) {
+
+ //Does it have a tool this cycle to cut?
+ boolean validCuttingTool = false;
+ boolean isRepaired = isMachineRepaired();
+ //Add some Power
+ addPowerToInternalStorage();
+
+ //Set Forestry Fake player Sapling Planter
+ if (this.farmerAI == null) {
+ this.farmerAI = new FakeFarmer(MinecraftServer.getServer().worldServerForDimension(this.getBaseMetaTileEntity().getWorld().provider.dimensionId));
+ }
+
+ //Check Inventory slots [1] - Find a valid Buzzsaw Blade or a Saw
+ try {
+ validCuttingTool = isCorrectMachinePart(mInventory[1]);
+ if (validCuttingTool){
+ this.mMaxProgresstime = 600;
+ String materialName = GT_MetaGenerated_Tool.getPrimaryMaterial(mInventory[1]).mDefaultLocalName;
+ if (materialName.toLowerCase().contains("null")){
+
+ }
+ else {
+
+ }
+ }
+ else {
+ this.mMaxProgresstime = 0;
+ }
+ } catch (NullPointerException t){}
+
+ if (isRepaired){
+ //If Machine can work and it's only once every 5 seconds this will tick.
+ if (canChop){
+ //Set Machine State
+ if (treeCheckTicks == 200){
+ Utils.LOG_MACHINE_INFO("Looking For Trees - Serverside | "+treeCheckTicks);
+ //Find wood to Cut
+ if (validCuttingTool){
+ findLogs(aBaseMetaTileEntity);
+ }
+ else {
+ Utils.LOG_MACHINE_INFO("Did not find a valid saw or Buzzsaw blade.");
+ }
+ }
+ }
+ else {
+ if (plantSaplingTicks == 100){
+ Utils.LOG_MACHINE_INFO("Looking For space to plant saplings - Serverside | "+plantSaplingTicks);
+ //Plant Some Saplings
+ plantSaplings(aBaseMetaTileEntity);
+ }
+ else if (plantSaplingTicks == 200){
+ Utils.LOG_MACHINE_INFO("Looking For Saplings to grow - Serverside | "+plantSaplingTicks);
+ //Try Grow some Saplings
+ findSaplings(aBaseMetaTileEntity);
+ //Set can work state
+ this.mInputBusses = new ArrayList<GT_MetaTileEntity_Hatch_InputBus>();
+ this.mEnergyHatches = new ArrayList<GT_MetaTileEntity_Hatch_Energy>();
+ canChop = checkMachine(aBaseMetaTileEntity, mInventory[1]);
+ }
+ }
+ //Call Cleanup Task last, before ticking.
+ if (cleanupTicks == 600){
+ Utils.LOG_MACHINE_INFO("Looking For rubbish to cleanup - Serverside | "+cleanupTicks);
+ //cleanUp(aBaseMetaTileEntity);
+ }
+ //Tick TE
+ tickHandler();
+ }
+ else {
+ if (treeCheckTicks == 200 || plantSaplingTicks == 100 || plantSaplingTicks == 200 || cleanupTicks == 600){
+ Utils.LOG_MACHINE_INFO("Machine is not fully repaired, not ticking.");
+ }
+ }
+
+ }
+ //Client Side - do nothing
+
+ }
+
} \ No newline at end of file