aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2017-01-20 16:56:01 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2017-01-20 16:56:01 +1000
commit6d609f499069ed4ae4e808ccc446c6acda51cdec (patch)
tree001f5b44c6326911a4c765725cc7820628c4ffab /src/Java/gtPlusPlus/xmod
parenta6bb1b33da251f4a2ec7a6d6facb4864e9905341 (diff)
downloadGT5-Unofficial-6d609f499069ed4ae4e808ccc446c6acda51cdec.tar.gz
GT5-Unofficial-6d609f499069ed4ae4e808ccc446c6acda51cdec.tar.bz2
GT5-Unofficial-6d609f499069ed4ae4e808ccc446c6acda51cdec.zip
+ Added a new kind of logging message, just for machines, so that people may debug them easily without TOTAL DEBUG mode.
+ Added support for the TreeFarmer to use Saws/Buzzsaws to cut things. They are now required. + Added a GUI for the Tree Farmer. + Added a custom slot class just for Buzzsaw and Saw items. % Tweaked power handling for findLogs() in the Tree Farmer class, it wasn't checking the internal power buffer.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod')
-rw-r--r--src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java34
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java36
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java64
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityTreeFarm.java274
4 files changed, 288 insertions, 120 deletions
diff --git a/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java b/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java
index e00a7ad1a4..9579d0b846 100644
--- a/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java
+++ b/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java
@@ -1,7 +1,10 @@
package gtPlusPlus.xmod.forestry.trees;
import gregtech.api.enums.OrePrefixes;
+import gregtech.api.items.GT_MetaGenerated_Tool;
+import gregtech.common.items.GT_MetaGenerated_Item_02;
import gtPlusPlus.core.lib.LoadedMods;
+import gtPlusPlus.core.slots.SlotBuzzSaw.SAWTOOL;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.item.ItemUtils;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
@@ -63,16 +66,16 @@ public class TreefarmManager {
public static boolean isWoodLog(Block log){
String tTool = log.getHarvestTool(0);
-
+
if (log == Blocks.log || log == Blocks.log2){
return true;
}
-
+
//IC2 Rubber Tree Compat
if (log.getClass().getName().toLowerCase().contains("rubwood") || log.getClass().getName().toLowerCase().contains("rubleaves")){
return true;
}
-
+
return OrePrefixes.log.contains(new ItemStack(log, 1))&& ((tTool != null) && (tTool.equals("axe"))) || (log.getMaterial() != Material.wood) ? false : (OrePrefixes.fence.contains(new ItemStack(log, 1)) ? false : true);
}
@@ -106,11 +109,11 @@ public class TreefarmManager {
if (air.getLocalizedName().toLowerCase().contains("air")){
return true;
}
-
+
if (air.getClass().getName().toLowerCase().contains("residual") || air.getClass().getName().toLowerCase().contains("heat")){
return true;
}
-
+
//Utils.LOG_INFO("Found "+air.getLocalizedName());
return (air == Blocks.air ? true : (air instanceof BlockAir ? true : false));
@@ -120,4 +123,25 @@ public class TreefarmManager {
return (sapling == Blocks.sapling ? true : (sapling == Blocks.))
}*/
+ public static SAWTOOL isCorrectMachinePart(final ItemStack aStack) {
+ if (aStack != null){
+ if (aStack.getItem() instanceof GT_MetaGenerated_Item_02 || aStack.getItem() instanceof GT_MetaGenerated_Tool){
+ if (OrePrefixes.craftingTool.contains(aStack)){
+ if (aStack.getDisplayName().toLowerCase().contains("saw")){
+ if (aStack.getItemDamage() == 10){
+ return SAWTOOL.NONE;
+ }
+ else if (aStack.getItemDamage() == 140){
+ return SAWTOOL.NONE;
+ }
+ else {
+ return SAWTOOL.NONE;
+ }
+ }
+ }
+ }
+ }
+ return SAWTOOL.NONE;
+ }
+
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java
new file mode 100644
index 0000000000..144f0b9e8f
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java
@@ -0,0 +1,36 @@
+package gtPlusPlus.xmod.gregtech.api.gui;
+
+import gregtech.api.gui.GT_ContainerMetaTile_Machine;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gtPlusPlus.core.slots.SlotBuzzSaw;
+import net.minecraft.entity.player.InventoryPlayer;
+
+/**
+ * NEVER INCLUDE THIS FILE IN YOUR MOD!!!
+ * <p/>
+ * The Container I use for all my Basic Machines
+ */
+public class CONTAINER_TreeFarmer extends GT_ContainerMetaTile_Machine {
+ public CONTAINER_TreeFarmer(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) {
+ super(aInventoryPlayer, aTileEntity);
+ }
+
+ public CONTAINER_TreeFarmer(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, boolean bindInventory) {
+ super(aInventoryPlayer, aTileEntity, bindInventory);
+ }
+
+ @Override
+ public void addSlots(InventoryPlayer aInventoryPlayer) {
+ addSlotToContainer(new SlotBuzzSaw(mTileEntity, 1, 80, 35));
+ }
+
+ @Override
+ public int getSlotCount() {
+ return 1;
+ }
+
+ @Override
+ public int getShiftClickSlotCount() {
+ return 0;
+ }
+}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java
new file mode 100644
index 0000000000..034119ed0b
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java
@@ -0,0 +1,64 @@
+package gtPlusPlus.xmod.gregtech.api.gui;
+
+
+import gregtech.api.gui.GT_GUIContainerMetaTile_Machine;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gtPlusPlus.core.lib.CORE;
+import net.minecraft.entity.player.InventoryPlayer;
+
+/**
+ * NEVER INCLUDE THIS FILE IN YOUR MOD!!!
+ * <p/>
+ * The GUI-Container I use for all my Basic Machines
+ * <p/>
+ * As the NEI-RecipeTransferRect Handler can't handle one GUI-Class for all GUIs I needed to produce some dummy-classes which extend this class
+ */
+public class GUI_TreeFarmer extends GT_GUIContainerMetaTile_Machine {
+
+ String mName = "";
+
+ public GUI_TreeFarmer(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aTextureFile) {
+ super(new CONTAINER_TreeFarmer(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile));
+ mName = aName;
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int par1, int par2) {
+ fontRendererObj.drawString(mName, 64, 8, 16448255);
+
+ /*if (mContainer != null) {
+ if ((((CONTAINER_TreeFarmer) mContainer).mDisplayErrorCode & 1) != 0)
+ fontRendererObj.drawString("Pipe is loose.", 10, 16, 16448255);
+ if ((((CONTAINER_TreeFarmer) mContainer).mDisplayErrorCode & 2) != 0)
+ fontRendererObj.drawString("Screws are missing.", 10, 24, 16448255);
+ if ((((CONTAINER_TreeFarmer) mContainer).mDisplayErrorCode & 4) != 0)
+ fontRendererObj.drawString("Something is stuck.", 10, 32, 16448255);
+ if ((((CONTAINER_TreeFarmer) mContainer).mDisplayErrorCode & 8) != 0)
+ fontRendererObj.drawString("Platings are dented.", 10, 40, 16448255);
+ if ((((CONTAINER_TreeFarmer) mContainer).mDisplayErrorCode & 16) != 0)
+ fontRendererObj.drawString("Circuitry burned out.", 10, 48, 16448255);
+ if ((((CONTAINER_TreeFarmer) mContainer).mDisplayErrorCode & 32) != 0)
+ fontRendererObj.drawString("That doesn't belong there.", 10, 56, 16448255);
+ if ((((CONTAINER_TreeFarmer) mContainer).mDisplayErrorCode & 64) != 0)
+ fontRendererObj.drawString("Incomplete Structure.", 10, 64, 16448255);
+
+ if (((CONTAINER_TreeFarmer) mContainer).mDisplayErrorCode == 0) {
+ if (((CONTAINER_TreeFarmer) mContainer).mActive == 0) {
+ fontRendererObj.drawString("Hit with Soft Hammer", 10, 16, 16448255);
+ fontRendererObj.drawString("to (re-)start the Machine", 10, 24, 16448255);
+ fontRendererObj.drawString("if it doesn't start.", 10, 32, 16448255);
+ } else {
+ fontRendererObj.drawString("Running perfectly.", 10, 16, 16448255);
+ }
+ }
+ }*/
+ }
+
+ @Override
+ protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
+ super.drawGuiContainerBackgroundLayer(par1, par2, par3);
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+ }
+}
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 f779f0767a..7dd678acd6 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
@@ -6,16 +6,19 @@ import gregtech.api.enums.OrePrefixes;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.items.GT_MetaGenerated_Tool;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.implementations.*;
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.slots.SlotBuzzSaw.SAWTOOL;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.item.ItemUtils;
import gtPlusPlus.core.util.math.MathUtils;
import gtPlusPlus.xmod.forestry.trees.TreefarmManager;
+import gtPlusPlus.xmod.gregtech.api.gui.GUI_TreeFarmer;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
import java.util.ArrayList;
@@ -23,6 +26,7 @@ import java.util.ArrayList;
import net.minecraft.block.Block;
import net.minecraft.block.IGrowable;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -43,6 +47,12 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
/* private */ private boolean canChop = false;
/* private */ private long mInternalPower = 0;
/* private */ private static int powerDrain = 32;
+
+ private SAWTOOL mCurrentMachineTool = SAWTOOL.NONE;
+
+ private int cuttingNumber = 0;
+ private int cuttingNumber2 = 0;
+ private int cuttingNumber3 = 0;
public GregtechMetaTileEntityTreeFarm(final int aID, final String aName, final String aNameRegional) {
super(aID, aName, aNameRegional);
@@ -60,7 +70,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
"Max Size(WxHxD): 9x1x9 (Controller, with upto 4 dirt out each direction on a flat plane.)"
};
}
-
+
@Override
public void saveNBTData(NBTTagCompound aNBT) {
@@ -77,10 +87,10 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
@Override
public boolean drainEnergyInput(long aEU) {
this.mInternalPower = (this.mInternalPower-32);
- Utils.LOG_INFO("Draining internal power storage by 32EU. Stored:"+this.mInternalPower);
+ Utils.LOG_MACHINE_INFO("Draining internal power storage by 32EU. Stored:"+this.mInternalPower);
return true;
}
-
+
public boolean addPowerToInternalStorage(){
if (this.mEnergyHatches.size() > 0) {
for (final GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches){
@@ -90,7 +100,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
if (this.mInternalPower<(maxEUStore()-128)){
tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(128, false);
this.mInternalPower = (this.mInternalPower+128);
- //Utils.LOG_INFO("Increasing internal power storage by 128EU. Stored:"+this.mInternalPower);
+ //Utils.LOG_MACHINE_INFO("Increasing internal power storage by 128EU. Stored:"+this.mInternalPower);
}
}
}
@@ -99,7 +109,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
}
return true;
}
-
+
@Override
public long maxEUStore() {
return 3244800; //13*13*150*128
@@ -144,18 +154,39 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
}
@Override
- public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) {
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new GUI_TreeFarmer(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "TreeFarmer.png");
+ }
+
+ @Override
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
+ if (aBaseMetaTileEntity.isClientSide()) {
+ return true;
+ }
+ aBaseMetaTileEntity.openGUI(aPlayer);
return true;
}
@Override
public boolean isCorrectMachinePart(final ItemStack aStack) {
- return true;
+ boolean isValid = false;
+ SAWTOOL currentInputItem = TreefarmManager.isCorrectMachinePart(aStack);
+ if (currentInputItem != SAWTOOL.NONE){
+ if (currentInputItem == SAWTOOL.SAW){
+ mCurrentMachineTool = SAWTOOL.SAW;
+ isValid = true;
+ }
+ else if (currentInputItem == SAWTOOL.BUZZSAW){
+ mCurrentMachineTool = SAWTOOL.BUZZSAW;
+ isValid = true;
+ }
+ }
+ return isValid;
}
@Override
public boolean checkRecipe(final ItemStack aStack) {
- Utils.LOG_INFO("Working");
+ Utils.LOG_MACHINE_INFO("Working");
this.mEfficiency = 0;
this.mEfficiencyIncrease = 0;
this.mMaxProgresstime = 0;
@@ -186,8 +217,8 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
if (h == 0) {
//Dirt Floor
if (!TreefarmManager.isDirtBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) {
- Utils.LOG_INFO("Dirt like block missing from inner 14x14.");
- Utils.LOG_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName());
+ 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)),
@@ -201,9 +232,9 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
//else if (h == 1){
//Farm Inner 14x14
/*if (!TreefarmManager.isWoodLog(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j)) || !TreefarmManager.isAirBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j)) || !aBaseMetaTileEntity.getAirOffset(xDir+i, h, zDir+j)) {
- Utils.LOG_INFO("Wood like block missing from inner 14x14, layer 2."); //TODO
- Utils.LOG_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName());
- Utils.LOG_INFO("Found at x:"+(xDir+i)+" y:"+h+" z:"+(zDir+j));
+ Utils.LOG_MACHINE_INFO("Wood like block missing from inner 14x14, layer 2."); //TODO
+ Utils.LOG_MACHINE_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName());
+ Utils.LOG_MACHINE_INFO("Found at x:"+(xDir+i)+" y:"+h+" z:"+(zDir+j));
//return false;
}*/
//}
@@ -215,8 +246,8 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
//Deal with all 4 sides (Fenced area)
if (h == 1) {
if (!TreefarmManager.isFenceBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) {
- Utils.LOG_INFO("Fence/Gate missing from outside the second layer.");
- Utils.LOG_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName());
+ Utils.LOG_MACHINE_INFO("Fence/Gate missing from outside the second layer.");
+ Utils.LOG_MACHINE_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName());
return false;
}
}
@@ -226,8 +257,8 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
if ((xDir + i != 0) || (zDir + j != 0)) {//no controller
if (tTileEntity.getMetaTileID() != 752) {
- Utils.LOG_INFO("Farm Keeper Casings Missing from one of the edges on the bottom edge. x:"+(xDir+i)+" y:"+h+" z:"+(zDir+j)+" | "+aBaseMetaTileEntity.getClass());
- Utils.LOG_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()+" "+tTileEntity.getMetaTileID());
+ Utils.LOG_MACHINE_INFO("Farm Keeper Casings Missing from one of the edges on the bottom edge. x:"+(xDir+i)+" y:"+h+" z:"+(zDir+j)+" | "+aBaseMetaTileEntity.getClass());
+ Utils.LOG_MACHINE_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()+" "+tTileEntity.getMetaTileID());
return false;
}
Utils.LOG_WARNING("Found a farm keeper.");
@@ -280,7 +311,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
}
mSolderingTool = true;
//turnCasingActive(true);
- //Utils.LOG_INFO("Multiblock Formed.");
+ //Utils.LOG_MACHINE_INFO("Multiblock Formed.");
return true;
}
@@ -296,7 +327,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
@Override
public int getDamageToComponent(final ItemStack aStack) {
- return 0;
+ return 1;
}
@Override
@@ -353,32 +384,49 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
if (aBaseMetaTileEntity.isServerSide()) {
-
+
+ //Does it have a tool this cycle to cut?
+ boolean validCuttingTool = false;
+
//Add some Power
addPowerToInternalStorage();
-
+
//Check Inventory slots [1] - Find a valid Buzzsaw Blade or a Saw
try {
- Utils.LOG_INFO(mInventory[1].getDisplayName());
+ validCuttingTool = isCorrectMachinePart(mInventory[1]);
+ if (validCuttingTool){
+ String materialName = GT_MetaGenerated_Tool.getPrimaryMaterial(mInventory[1]).mDefaultLocalName;
+ if (materialName.toLowerCase().contains("null")){
+
+ }
+ else {
+
+ }
+ }
} catch (NullPointerException t){}
//If Machine can work and it's only once every 5 seconds this will tick.
if (mMachine){
//Set Machine State
if (treeCheckTicks == 200){
- Utils.LOG_INFO("Looking For Trees - Serverside | "+treeCheckTicks);
+ Utils.LOG_MACHINE_INFO("Looking For Trees - Serverside | "+treeCheckTicks);
//Find wood to Cut
- findLogs(aBaseMetaTileEntity);
+ if (validCuttingTool){
+ findLogs(aBaseMetaTileEntity);
+ }
+ else {
+ Utils.LOG_INFO("Did not find a valid saw or Buzzsaw blade.");
+ }
}
}
else {
if (plantSaplingTicks == 100){
- Utils.LOG_INFO("Looking For space to plant saplings - Serverside | "+plantSaplingTicks);
+ Utils.LOG_MACHINE_INFO("Looking For space to plant saplings - Serverside | "+plantSaplingTicks);
//Plant Some Saplings
plantSaplings(aBaseMetaTileEntity);
}
else if (plantSaplingTicks == 200){
- Utils.LOG_INFO("Looking For Saplings to grow - Serverside | "+plantSaplingTicks);
+ Utils.LOG_MACHINE_INFO("Looking For Saplings to grow - Serverside | "+plantSaplingTicks);
//Try Grow some Saplings
findSaplings(aBaseMetaTileEntity);
//Set can work state
@@ -389,7 +437,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
}
//Call Cleanup Task last, before ticking.
if (cleanupTicks == 600){
- Utils.LOG_INFO("Looking For rubbish to cleanup - Serverside | "+cleanupTicks);
+ Utils.LOG_MACHINE_INFO("Looking For rubbish to cleanup - Serverside | "+cleanupTicks);
//cleanUp(aBaseMetaTileEntity);
}
//Tick TE
@@ -401,47 +449,43 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
private boolean findLogs(final IGregTechTileEntity aBaseMetaTileEntity){
- Utils.LOG_INFO("called findLogs()");
+ Utils.LOG_MACHINE_INFO("called findLogs()");
int logsCut = 0;
final int xDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 7;
final int zDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 7;
final World world = aBaseMetaTileEntity.getWorld();
int posX, posY, posZ;
-
+
if (this.mEnergyHatches.size() > 0) {
for (final GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches){
if (isValidMetaTileEntity(tHatch)) {
- if (tHatch.getEUVar() >= 128) {
-
+ if (mInternalPower >= 128) {
+
for (int i = -7; i <= 7; i++) {
for (int j = -7; j <= 7; j++) {
for (int h=1;h<150;h++){
- if ((i != -7 && i != 7) && (j != -7 && j != 7)) {
-
- Block loopBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j);
-
- if (TreefarmManager.isWoodLog(loopBlock) || TreefarmManager.isLeaves(loopBlock)){
-
- long tempStoredEU = tHatch.getEUVar();
-
+ if ((i != -7 && i != 7) && (j != -7 && j != 7)) {
+ Block loopBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j);
+ if (TreefarmManager.isWoodLog(loopBlock) || TreefarmManager.isLeaves(loopBlock)){
+ long tempStoredEU = mInternalPower;
if (tempStoredEU >= powerDrain){
- //Utils.LOG_INFO("Cutting a "+loopBlock.getLocalizedName()+", currently stored:"+tempStoredEU+" | max:"+tHatch.maxEUStore());
+ Utils.LOG_MACHINE_INFO("Cutting a "+loopBlock.getLocalizedName()+", currently stored:"+tempStoredEU+" | max:"+maxEUStore());
//tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(128 * 1, false);
drainEnergyInput(powerDrain);
-
- long tempStoredEU2 = tHatch.getEUVar();
+
+ long tempStoredEU2 = mInternalPower;
if (tempStoredEU != tempStoredEU2){
if (tempStoredEU == (tempStoredEU2+powerDrain)){
- //Utils.LOG_INFO(powerDrain+"EU was drained.");
+ Utils.LOG_MACHINE_INFO(powerDrain+"EU was drained.");
}
else {
- //Utils.LOG_INFO(""+(tempStoredEU-tempStoredEU2)+"EU was drained.");
+ Utils.LOG_MACHINE_INFO(""+(tempStoredEU-tempStoredEU2)+"EU was drained.");
}
}
else {
- //Utils.LOG_INFO("Stored EU did not change.");
+ Utils.LOG_MACHINE_INFO("Stored EU did not change.");
}
-
+
posX = aBaseMetaTileEntity.getXCoord()+xDir+i;
posY = aBaseMetaTileEntity.getYCoord()+h;
posZ = aBaseMetaTileEntity.getZCoord()+zDir+j;
@@ -449,7 +493,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
logsCut++;
}
else {
- Utils.LOG_INFO("Not enough power to cut.");
+ Utils.LOG_MACHINE_INFO("Not enough power to cut.");
}
}
}
@@ -458,28 +502,28 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
}
}
else {
- //Utils.LOG_INFO("Not enough Power | can hold:"+maxEUStore()+" | holding:"+aBaseMetaTileEntity.getStoredEU());
+ Utils.LOG_MACHINE_INFO("Not enough Power | can hold:"+maxEUStore()+" | holding:"+aBaseMetaTileEntity.getStoredEU());
}
}
else {
- Utils.LOG_INFO("Invalid Hatch Entitity");
+ Utils.LOG_MACHINE_INFO("Invalid Hatch Entitity");
}
}
}
else {
- Utils.LOG_INFO("No energy hatches found.");
+ Utils.LOG_MACHINE_INFO("No energy hatches found.");
}
-
-
+
+
mMachine = false;
if (logsCut > 250)
cleanUp(aBaseMetaTileEntity);
- //Utils.LOG_INFO("general failure | maybe there is no logs, not an error. | cut:"+logsCut );
+ //Utils.LOG_MACHINE_INFO("general failure | maybe there is no logs, not an error. | cut:"+logsCut );
return false;
}
private static boolean cleanUp(final IGregTechTileEntity aBaseMetaTileEntity){
- Utils.LOG_INFO("called cleanUp()");
+ Utils.LOG_MACHINE_INFO("called cleanUp()");
int cleanedUp = 0;
final int xDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 7;
final int zDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 7;
@@ -491,7 +535,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
posiX = aBaseMetaTileEntity.getXCoord()+xDir+i;
posiY = aBaseMetaTileEntity.getYCoord()+h;
posiZ = aBaseMetaTileEntity.getZCoord()+zDir+j;
- //Utils.LOG_INFO("Cleaning Up some leftovers.");
+ //Utils.LOG_MACHINE_INFO("Cleaning Up some leftovers.");
cleanedUp++;
aBaseMetaTileEntity.getWorld().setBlockToAir(posiX, posiY, posiZ);
}
@@ -500,32 +544,32 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
}
}
- Utils.LOG_INFO("cleaning up | "+cleanedUp );
+ Utils.LOG_MACHINE_INFO("cleaning up | "+cleanedUp );
return true;
}
private boolean findSaplings(final IGregTechTileEntity aBaseMetaTileEntity){
- Utils.LOG_INFO("called findSaplings()");
+ Utils.LOG_MACHINE_INFO("called findSaplings()");
int saplings = 0;
final int xDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 7;
final int zDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 7;
for (int i = -7; i <= 7; i++) {
for (int j = -7; j <= 7; j++) {
int h = 1;
- //Utils.LOG_INFO("Looking for saplings.");
+ //Utils.LOG_MACHINE_INFO("Looking for saplings.");
if (TreefarmManager.isSapling(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))){
int posiX, posiY, posiZ;
posiX = aBaseMetaTileEntity.getXCoord()+xDir+i;
posiY = aBaseMetaTileEntity.getYCoord()+h;
posiZ = aBaseMetaTileEntity.getZCoord()+zDir+j;
- //Utils.LOG_INFO("Found a sapling to grow.");
+ //Utils.LOG_MACHINE_INFO("Found a sapling to grow.");
saplings++;
drainEnergyInput(powerDrain);
applyBonemeal(aBaseMetaTileEntity.getWorld(), posiX, posiY, posiZ);
}
}
}
- Utils.LOG_INFO("Tried to grow saplings: | "+saplings );
+ Utils.LOG_MACHINE_INFO("Tried to grow saplings: | "+saplings );
return true;
}
@@ -545,7 +589,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
}
private boolean plantSaplings(final IGregTechTileEntity aBaseMetaTileEntity){
- Utils.LOG_INFO("called plantSaplings()");
+ Utils.LOG_MACHINE_INFO("called plantSaplings()");
World world = aBaseMetaTileEntity.getWorld();
ArrayList<ItemStack> r = getStoredInputs();
int saplings = 0;
@@ -553,16 +597,16 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
final int zDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 7;
int counter = 0;
if (r.size() > 0){
- Utils.LOG_INFO("| r was not null. "+r.size()+" |");
+ Utils.LOG_MACHINE_INFO("| r was not null. "+r.size()+" |");
for (ItemStack n : r){
- Utils.LOG_INFO("found "+n.getDisplayName());
+ Utils.LOG_MACHINE_INFO("found "+n.getDisplayName());
if (OrePrefixes.sapling.contains(n) || n.getDisplayName().toLowerCase().contains("sapling")){
- Utils.LOG_INFO(""+n.getDisplayName());
+ 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_INFO("It's a forestry sapling, trying magic.");
+ Utils.LOG_MACHINE_INFO("It's a forestry sapling, trying magic.");
saplingToPlace = Block.getBlockFromItem(ItemUtils.getItem("Forestry:saplingGE"));
}
@@ -575,71 +619,71 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
for (int j = -7; j <= 7; j++) {
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))){
-
- //Get block location to place sapling block
- int posX, posY, posZ;
- posX = aBaseMetaTileEntity.getXCoord()+xDir+i;
- posY = aBaseMetaTileEntity.getYCoord()+h;
- posZ = aBaseMetaTileEntity.getZCoord()+zDir+j;
-
- //If sapling block is not null
- if (saplingToPlace != null){
- Utils.LOG_INFO("Placing Sapling Block.");
- //Plant Sapling
- world.setBlock(posX, posY, posZ, saplingToPlace);
- world.setBlockMetadataWithNotify(posX, posY, posZ, n.getItemDamage(), 4);
- //Deplete Input stack
- depleteInputEx(n);
- drainEnergyInput(powerDrain);
- counter--;
- //Update slot contents?
- updateSlots();
-
- //Test If Inputs Changed
- ArrayList<ItemStack> temp = getStoredInputs();
- if (r != temp){
- Utils.LOG_INFO("Inputs changed, updating.");
- for (ItemStack xr : r){
- Utils.LOG_INFO("xr:"+xr.getDisplayName()+"x"+xr.stackSize);
- }
- for (ItemStack xc : temp){
- Utils.LOG_INFO("xc:"+xc.getDisplayName()+"x"+xc.stackSize);
+ if ((i != -7 && i != 7) && (j != -7 && j != 7)) {
+ if (TreefarmManager.isAirBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))){
+
+ //Get block location to place sapling block
+ int posX, posY, posZ;
+ posX = aBaseMetaTileEntity.getXCoord()+xDir+i;
+ 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.");
+ //Plant Sapling
+ world.setBlock(posX, posY, posZ, saplingToPlace);
+ world.setBlockMetadataWithNotify(posX, posY, posZ, n.getItemDamage(), 4);
+ //Deplete Input stack
+ depleteInputEx(n);
+ drainEnergyInput(powerDrain);
+ counter--;
+ //Update slot contents?
+ updateSlots();
+
+ //Test If Inputs Changed
+ ArrayList<ItemStack> temp = getStoredInputs();
+ if (r != temp){
+ Utils.LOG_MACHINE_INFO("Inputs changed, updating.");
+ for (ItemStack xr : r){
+ Utils.LOG_MACHINE_INFO("xr:"+xr.getDisplayName()+"x"+xr.stackSize);
+ }
+ for (ItemStack xc : temp){
+ Utils.LOG_MACHINE_INFO("xc:"+xc.getDisplayName()+"x"+xc.stackSize);
+ }
+ r = temp;
}
- r = temp;
}
- }
+ else {
+ Utils.LOG_MACHINE_INFO(n.getDisplayName()+" did not have a valid block.");
+ }
+ }
else {
- Utils.LOG_INFO(n.getDisplayName()+" did not have a valid block.");
+ //Utils.LOG_MACHINE_INFO("No space for sapling, no air.");
+ continue;
}
- }
- else {
- Utils.LOG_INFO("No space for sapling, no air.");
- continue;
}
- }
}
}
}
else {
- Utils.LOG_INFO("item was not a sapling");
+ Utils.LOG_MACHINE_INFO("item was not a sapling");
continue;
}
}
}
else{
- /*Utils.LOG_INFO("Input stack empty or null - hatch count "+this.mInputBusses.size());
+ /*Utils.LOG_MACHINE_INFO("Input stack empty or null - hatch count "+this.mInputBusses.size());
for (GT_MetaTileEntity_Hatch_InputBus x : this.mInputBusses){
- Utils.LOG_INFO("x:"+x.getBaseMetaTileEntity().getXCoord()+" | y:"+x.getBaseMetaTileEntity().getYCoord()+" | z:"+x.getBaseMetaTileEntity().getZCoord());
+ Utils.LOG_MACHINE_INFO("x:"+x.getBaseMetaTileEntity().getXCoord()+" | y:"+x.getBaseMetaTileEntity().getYCoord()+" | z:"+x.getBaseMetaTileEntity().getZCoord());
}*/
}
- Utils.LOG_INFO("Tried to plant saplings: | "+saplings );
+ Utils.LOG_MACHINE_INFO("Tried to plant saplings: | "+saplings );
return true;
}
private boolean cutLog(final World world, final int x, final int y, final int z){
- //Utils.LOG_INFO("Cutting Log");
+ //Utils.LOG_MACHINE_INFO("Cutting Log");
try {
final Block block = world.getBlock(x, y, z);
int chanceForLeaves = 1000;
@@ -647,9 +691,9 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
if (block.getUnlocalizedName().toLowerCase().contains("leaves")){
chanceForLeaves = MathUtils.randInt(1, 1000);
if (chanceForLeaves > 990)
- Utils.LOG_INFO("Found some leaves that will drop, chance to drop item "+chanceForLeaves+", needed 990-1000.");
+ Utils.LOG_MACHINE_INFO("Found some leaves that will drop, chance to drop item "+chanceForLeaves+", needed 990-1000.");
}
-
+
//IC2 Sticky Rubber handling
if (block.getUnlocalizedName().toLowerCase().contains("blockrubwood") || block.getUnlocalizedName().toLowerCase().contains("blockrubleaves")){
ItemStack rubberResin = ItemUtils.getCorrectStacktype("IC2:itemHarz", 1);
@@ -657,7 +701,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
int multiplier = MathUtils.randInt(1, 3);
if (chanceForRubber > 7 && chanceForLeaves > 990){
rubberResin.stackSize = multiplier;
- Utils.LOG_INFO("Adding "+rubberResin.getDisplayName()+" x"+rubberResin.stackSize);
+ Utils.LOG_MACHINE_INFO("Adding "+rubberResin.getDisplayName()+" x"+rubberResin.stackSize);
addOutput(rubberResin);
updateSlots();
}
@@ -669,7 +713,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
if (drops != null){
for (ItemStack outputs : drops){
if (chanceForLeaves > 990){
- Utils.LOG_INFO("Adding 1x "+outputs.getDisplayName());
+ Utils.LOG_MACHINE_INFO("Adding 1x "+outputs.getDisplayName());
addOutput(outputs);
//Update bus contents.
updateSlots();
@@ -701,7 +745,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
}
BonemealEvent event = new BonemealEvent(player, world, block, intX, intY, intZ);
if (MinecraftForge.EVENT_BUS.post(event)){
- Utils.LOG_INFO("Not sure why this returned false");
+ Utils.LOG_MACHINE_INFO("Not sure why this returned false");
return false;
}
if (event.getResult() == Result.ALLOW){
@@ -785,7 +829,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock
public boolean depleteInputEx(ItemStack aStack) {
if (GT_Utility.isStackInvalid(aStack)) return false;
- Utils.LOG_INFO("Taking one sapling away from in input bus.");
+ Utils.LOG_MACHINE_INFO("Taking one sapling away from in input bus.");
for (GT_MetaTileEntity_Hatch_InputBus tHatch : this.mInputBusses) {
tHatch.mRecipeMap = getRecipeMap();