aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java140
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java6
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java18
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java121
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java134
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityAnimalFarm.java377
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityTreeFarm.java183
7 files changed, 390 insertions, 589 deletions
diff --git a/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java b/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java
deleted file mode 100644
index 155feae83c..0000000000
--- a/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java
+++ /dev/null
@@ -1,140 +0,0 @@
-package gtPlusPlus.xmod.forestry.trees;
-
-import cpw.mods.fml.common.Optional;
-import gregtech.api.enums.OrePrefixes;
-import gtPlusPlus.api.objects.Logger;
-import gtPlusPlus.core.lib.LoadedMods;
-import gtPlusPlus.core.util.item.ItemUtils;
-import gtPlusPlus.core.util.reflect.ReflectionUtils;
-import net.minecraft.block.Block;
-import net.minecraft.block.BlockAir;
-import net.minecraft.block.material.Material;
-import net.minecraft.init.Blocks;
-import net.minecraft.item.ItemStack;
-
-public class TreefarmManager {
-
- public static boolean isHumusLoaded = false;
- public static boolean isForestryLogsLoaded = false;
- public static boolean isForestryFenceLoaded = false;
- public static boolean isForestrySaplingsLoaded = false;
- public static boolean isForestryLeavesLoaded = false;
- public static Block blockHumus;
-
- public static boolean isForestryValid(){
- if (!LoadedMods.Forestry){
- return false;
- }
- if (ReflectionUtils.doesClassExist("forestry.core.blocks.BlockSoil")){
- isHumusLoaded = true;
- }
- if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockLog")){
- isForestryLogsLoaded = true;
- }
- if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockArbFence")){
- isForestryFenceLoaded = true;
- }
- if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockSapling")){
- isForestrySaplingsLoaded = true;
- }
- if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockForestryLeaves")){
- isForestryLeavesLoaded = true;
- }
- return true;
- }
-
- @Optional.Method(modid = "Forestry")
- public static Block getHumus(){
- if(blockHumus != null){
- return blockHumus;
- }
- else if (ReflectionUtils.doesClassExist("forestry.core.blocks.BlockSoil")){
- try {
- final Class<?> humusClass = Class.forName("forestry.core.blocks.BlockSoil");
- final ItemStack humusStack = ItemUtils.getCorrectStacktype("Forestry:soil", 1);
- if (humusClass != null){
- blockHumus = Block.getBlockFromItem(humusStack.getItem());
- return Block.getBlockFromItem(humusStack.getItem());
- }
- } catch (final ClassNotFoundException e) {}
- }
- return null;
- }
-
- public static boolean isWoodLog(final Block log){
- final String tTool = log.getHarvestTool(0);
-
- 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")){
- 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);
- }
-
- public static boolean isLeaves(final Block log){
- if (log.getUnlocalizedName().toLowerCase().contains("leaf")){
- return true;
- }
- if (log.getUnlocalizedName().toLowerCase().contains("leaves")){
- return true;
- }
- if (log.getLocalizedName().toLowerCase().contains("leaf")){
- return true;
- }
- if (log.getLocalizedName().toLowerCase().contains("leaves")){
- return true;
- }
- return OrePrefixes.leaves.contains(new ItemStack(log, 1)) || (log.getMaterial() == Material.leaves);
- }
-
- public static boolean isSapling(final Block log){
- if (log != null){
- if (OrePrefixes.sapling.contains(new ItemStack(log, 1))){
- Logger.WARNING(""+log.getLocalizedName());
- }
- if (log.getLocalizedName().toLowerCase().contains("sapling")){
- Logger.WARNING(""+log.getLocalizedName());
- return true;
- }
- }
- return OrePrefixes.sapling.contains(new ItemStack(log, 1));
- }
-
- public static boolean isDirtBlock(final Block dirt){
- return (dirt == Blocks.dirt ? true : (dirt == Blocks.grass ? true : (getHumus() == null ? false : (dirt == blockHumus ? true : false))));
- }
-
- public static boolean isFenceBlock(final Block fence){
- return (fence == Blocks.fence ? true : (fence == Blocks.fence_gate ? true : (fence == Blocks.nether_brick_fence ? true : (OrePrefixes.fence.contains(new ItemStack(fence, 1)) ? true : false))));
- }
-
- public static boolean isAirBlock(final Block air){
-
- 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));
- }
-
- /*public static boolean isSaplingBlock(Block sapling){
- return (sapling == Blocks.sapling ? true : (sapling == Blocks.))
- }*/
-
-}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java
index 565c378179..3a60a3e93e 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java
@@ -24,9 +24,9 @@ public class GUI_TreeFarmer extends GT_GUIContainerMetaTile_Machine {
this.maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU;
this.storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU;
if (((CONTAINER_TreeFarmer) this.mContainer).mDisplayErrorCode == 0) {
- this.fontRendererObj.drawString("Current Power Stored: "+this.storedPower+"EU", 10, 52, 16448255);
- this.fontRendererObj.drawString("Max Power Storage: "+this.maxPower+"EU", 10, 60, 16448255);
- this.fontRendererObj.drawString("Current operations left: "+(this.storedPower/32), 10, 68, 16448255);
+ this.fontRendererObj.drawString("Current Power: "+this.storedPower+"EU", 8, 52, 16448255);
+ this.fontRendererObj.drawString("Max Power: "+this.maxPower+"EU", 8, 60, 16448255);
+ this.fontRendererObj.drawString("Current operations left: "+(this.storedPower/32), 8, 68, 16448255);
}
}
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
index ee1ade464d..0eec457d66 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
@@ -96,19 +96,11 @@ GT_MetaTileEntity_MultiBlockBase {
long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) *60);
String[] g = {
- "Progress:",
- (this.mProgresstime / 20) + "secs",
- (this.mMaxProgresstime / 20) + "secs",
- "Efficiency:",
- (this.mEfficiency / 100.0F) + "%",
- "Problems:",
- "" + (this.getIdealStatus() - this.getRepairStatus()),
- "Total Time Since Build: ",
- ""+weeks+" Weeks.",
- ""+days+" Days.",
- ""+hours+" Hours.",
- ""+minutes+" Minutes.",
- ""+second+" Seconds.",
+ "Progress: " + (this.mProgresstime / 20) +" / "+ (this.mMaxProgresstime / 20) + " secs",
+ "Efficiency: "+(this.mEfficiency / 100.0F) + "%",
+ "Problems: " + "" + (this.getIdealStatus() - this.getRepairStatus()),
+ "Total Time Since Built: " + ""+weeks+" Weeks, " + ""+days+" Days, ",
+ ""+hours+" Hours, " + ""+minutes+" Minutes, " + ""+second+" Seconds.",
"Total Time in ticks: "+this.mTotalRunTime};
return g;
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java
index 4d50a20fe7..148e92b7fa 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java
@@ -8,65 +8,68 @@ public class CasingTextureHandler2 {
public static IIcon getIcon(final int aSide, final int aMeta) { //Texture ID's. case 0 == ID[57]
if ((aMeta >= 0) && (aMeta < 16)) {
switch (aMeta) {
- //Centrifuge
- case 0:
- return TexturesGtBlock.Casing_Material_RedSteel.getIcon();
- //Coke Oven Frame
- case 1:
- return TexturesGtBlock.Casing_Material_HastelloyX.getIcon();
- //Coke Oven Casing Tier 1
- case 2:
- return TexturesGtBlock.Casing_Material_HastelloyN.getIcon();
- //Coke Oven Casing Tier 2
- case 3:
- return TexturesGtBlock.Casing_Material_Fluid_IncoloyDS.getIcon();
- //Material Press Casings
- case 4:
- return TexturesGtBlock.Casing_Material_Grisium.getIcon();
- //Sifter Structural
- case 5:
- return TexturesGtBlock.Casing_Machine_Metal_Panel_A.getIcon();
- //Sifter Sieve
- case 6:
- return TexturesGtBlock.Casing_Machine_Metal_Grate_A.getIcon();
-
- //Vanadium Radox Battery
- case 7:
- return TexturesGtBlock.Overlay_Machine_Cyber_B.getIcon();
- //Power Sub-Station Casing
- case 8:
- return TexturesGtBlock.Casing_Machine_Metal_Sheet_A.getIcon();
- //Cyclotron Coil
- case 9:
- return TexturesGtBlock.Overlay_Machine_Cyber_A.getIcon();
- //Cyclotron External Casing
- case 10:
- return Textures.BlockIcons.MACHINE_CASING_RADIATIONPROOF.getIcon();
- //Multitank Exterior Casing
- case 11:
- return TexturesGtBlock.Casing_Material_Tantalloy61.getIcon();
- //Reactor Casing I
- case 12:
- return TexturesGtBlock.Casing_Machine_Simple_Top.getIcon();
- //Reactor Casing II
- case 13:
- if (aSide <2) {
- return TexturesGtBlock.TEXTURE_TECH_A.getIcon();
- }
- else {
- return TexturesGtBlock.TEXTURE_TECH_B.getIcon();
- }
- case 14:
- return TexturesGtBlock.Casing_Material_RedSteel.getIcon();
- case 15:
- if (aSide <2) {
- return TexturesGtBlock.Casing_Machine_Acacia_Log.getIcon();
- }
- else {
- return TexturesGtBlock.Casing_Machine_Farm_Manager.getIcon();
- }
- default:
- return TexturesGtBlock.Overlay_UU_Matter.getIcon();
+ //Centrifuge
+ case 0:
+ return TexturesGtBlock.Casing_Material_RedSteel.getIcon();
+ //Coke Oven Frame
+ case 1:
+ return TexturesGtBlock.Casing_Material_HastelloyX.getIcon();
+ //Coke Oven Casing Tier 1
+ case 2:
+ return TexturesGtBlock.Casing_Material_HastelloyN.getIcon();
+ //Coke Oven Casing Tier 2
+ case 3:
+ return TexturesGtBlock.Casing_Material_Fluid_IncoloyDS.getIcon();
+ //Material Press Casings
+ case 4:
+ return TexturesGtBlock.Casing_Material_Grisium.getIcon();
+ //Sifter Structural
+ case 5:
+ return TexturesGtBlock.Casing_Machine_Metal_Panel_A.getIcon();
+ //Sifter Sieve
+ case 6:
+ return TexturesGtBlock.Casing_Machine_Metal_Grate_A.getIcon();
+
+ //Vanadium Radox Battery
+ case 7:
+ return TexturesGtBlock.Overlay_Machine_Cyber_B.getIcon();
+ //Power Sub-Station Casing
+ case 8:
+ return TexturesGtBlock.Casing_Machine_Metal_Sheet_A.getIcon();
+ //Cyclotron Coil
+ case 9:
+ return TexturesGtBlock.Overlay_Machine_Cyber_A.getIcon();
+ //Cyclotron External Casing
+ case 10:
+ return Textures.BlockIcons.MACHINE_CASING_RADIATIONPROOF.getIcon();
+ //Multitank Exterior Casing
+ case 11:
+ return TexturesGtBlock.Casing_Material_Tantalloy61.getIcon();
+ //Reactor Casing I
+ case 12:
+ return TexturesGtBlock.Casing_Machine_Simple_Top.getIcon();
+ //Reactor Casing II
+ case 13:
+ if (aSide <2) {
+ return TexturesGtBlock.TEXTURE_TECH_A.getIcon();
+ }
+ else {
+ return TexturesGtBlock.TEXTURE_TECH_B.getIcon();
+ }
+ case 14:
+ return TexturesGtBlock.Casing_Material_RedSteel.getIcon();
+ case 15:
+ if (aSide <2) {
+ if (aSide == 1) {
+ return TexturesGtBlock.Casing_Machine_Podzol.getIcon();
+ }
+ return TexturesGtBlock.Casing_Machine_Acacia_Log.getIcon();
+ }
+ else {
+ return TexturesGtBlock.Casing_Machine_Farm_Manager.getIcon();
+ }
+ default:
+ return TexturesGtBlock.Overlay_UU_Matter.getIcon();
}
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java
index d023307820..c6554939be 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java
@@ -2,6 +2,7 @@ package gtPlusPlus.xmod.gregtech.common.helpers;
import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableTreeFarmerParticles;
+import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.eventhandler.Event.Result;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.enums.Textures;
@@ -11,13 +12,17 @@ import gregtech.api.items.GT_MetaGenerated_Tool;
import gregtech.common.items.GT_MetaGenerated_Item_02;
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.lib.LoadedMods;
import gtPlusPlus.core.slots.SlotBuzzSaw.SAWTOOL;
import gtPlusPlus.core.util.fluid.FluidUtils;
+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.core.util.reflect.ReflectionUtils;
import net.minecraft.block.Block;
+import net.minecraft.block.BlockAir;
import net.minecraft.block.IGrowable;
+import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
@@ -199,7 +204,7 @@ public class TreeFarmHelper {
}
- if (TreefarmManager.isLeaves(testBlock) || TreefarmManager.isWoodLog(testBlock)){
+ if (isLeaves(testBlock) || isWoodLog(testBlock)){
Logger.WARNING("1:"+testBlock.getUnlocalizedName());
int posiX, posiY, posiZ;
posiX = aBaseMetaTileEntity.getXCoord()+xDir+i;
@@ -232,7 +237,7 @@ public class TreeFarmHelper {
//Utils.LOG_WARNING("Found "+aStack.getDisplayName()+" in the GUI slot.");
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") || aStack.getDisplayName().toLowerCase().contains("gt.metatool.01.10")){
+ if (aStack.getDisplayName().toLowerCase().contains("saw") || aStack.getDisplayName().toLowerCase().contains("gt.metatool.01")){
if (aStack.getItemDamage() == 10){
return SAWTOOL.SAW;
}
@@ -257,5 +262,128 @@ public class TreeFarmHelper {
}
return SAWTOOL.NONE;
}
+
+ public static boolean isHumusLoaded = false;
+ public static boolean isForestryLogsLoaded = false;
+ public static boolean isForestryFenceLoaded = false;
+ public static boolean isForestrySaplingsLoaded = false;
+ public static boolean isForestryLeavesLoaded = false;
+ public static Block blockHumus;
+
+ public static boolean isForestryValid(){
+ if (!LoadedMods.Forestry){
+ return false;
+ }
+ if (ReflectionUtils.doesClassExist("forestry.core.blocks.BlockSoil")){
+ isHumusLoaded = true;
+ }
+ if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockLog")){
+ isForestryLogsLoaded = true;
+ }
+ if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockArbFence")){
+ isForestryFenceLoaded = true;
+ }
+ if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockSapling")){
+ isForestrySaplingsLoaded = true;
+ }
+ if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockForestryLeaves")){
+ isForestryLeavesLoaded = true;
+ }
+ return true;
+ }
+
+ @Optional.Method(modid = "Forestry")
+ public static Block getHumus(){
+ if(blockHumus != null){
+ return blockHumus;
+ }
+ else if (ReflectionUtils.doesClassExist("forestry.core.blocks.BlockSoil")){
+ try {
+ final Class<?> humusClass = Class.forName("forestry.core.blocks.BlockSoil");
+ final ItemStack humusStack = ItemUtils.getCorrectStacktype("Forestry:soil", 1);
+ if (humusClass != null){
+ blockHumus = Block.getBlockFromItem(humusStack.getItem());
+ return Block.getBlockFromItem(humusStack.getItem());
+ }
+ } catch (final ClassNotFoundException e) {}
+ }
+ return null;
+ }
+
+ public static boolean isWoodLog(final Block log){
+ final String tTool = log.getHarvestTool(0);
+
+ 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")){
+ 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);
+ }
+
+ public static boolean isLeaves(final Block log){
+ if (log.getUnlocalizedName().toLowerCase().contains("leaf")){
+ return true;
+ }
+ if (log.getUnlocalizedName().toLowerCase().contains("leaves")){
+ return true;
+ }
+ if (log.getLocalizedName().toLowerCase().contains("leaf")){
+ return true;
+ }
+ if (log.getLocalizedName().toLowerCase().contains("leaves")){
+ return true;
+ }
+ return OrePrefixes.leaves.contains(new ItemStack(log, 1)) || (log.getMaterial() == Material.leaves);
+ }
+
+ public static boolean isSapling(final Block log){
+ if (log != null){
+ if (OrePrefixes.sapling.contains(new ItemStack(log, 1))){
+ Logger.WARNING(""+log.getLocalizedName());
+ }
+ if (log.getLocalizedName().toLowerCase().contains("sapling")){
+ Logger.WARNING(""+log.getLocalizedName());
+ return true;
+ }
+ }
+ return OrePrefixes.sapling.contains(new ItemStack(log, 1));
+ }
+
+ public static boolean isDirtBlock(final Block dirt){
+ return (dirt == Blocks.dirt ? true : (dirt == Blocks.grass ? true : (getHumus() == null ? false : (dirt == blockHumus ? true : false))));
+ }
+
+ public static boolean isFenceBlock(final Block fence){
+ return (fence == Blocks.fence ? true : (fence == Blocks.fence_gate ? true : (fence == Blocks.nether_brick_fence ? true : (OrePrefixes.fence.contains(new ItemStack(fence, 1)) ? true : false))));
+ }
+
+ public static boolean isAirBlock(final Block air){
+
+ 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));
+ }
+
+ /*public static boolean isSaplingBlock(Block sapling){
+ return (sapling == Blocks.sapling ? true : (sapling == Blocks.))
+ }*/
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityAnimalFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityAnimalFarm.java
index da83b3c3d1..f2f752a0eb 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityAnimalFarm.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityAnimalFarm.java
@@ -1,397 +1,82 @@
package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi;
-import java.lang.reflect.Field;
-
-import gregtech.api.GregTech_API;
-import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
-import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock;
-import gregtech.api.objects.GT_ItemStack;
-import gregtech.api.objects.GT_RenderedTexture;
-import gregtech.api.util.GT_Recipe;
-import gtPlusPlus.api.objects.Logger;
-import gtPlusPlus.core.lib.LoadedMods;
-import gtPlusPlus.xmod.forestry.trees.TreefarmManager;
-import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
-import net.minecraft.block.Block;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
public class GregtechMetaTileEntityAnimalFarm extends GT_MetaTileEntity_MultiBlockBase {
-
- private static final ITexture[] FACING_SIDE = {new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Tumbaga)};
- private static final ITexture[] FACING_FRONT = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBLASTFURNACE)};
- private static final ITexture[] FACING_ACTIVE = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBLASTFURNACE_ACTIVE)};
-
-
- //public ArrayList<GT_MetaTileEntity_TieredMachineBlock> mCasings = new ArrayList();
-
- private final boolean running = false;
- private boolean p1, p2, p3, p4, p5, p6;
- public ItemStack mOutputItem1;
- public ItemStack mOutputItem2;
- private Block Humus;
- private final boolean isForestryLoaded = TreefarmManager.isForestryValid();
-
- public GregtechMetaTileEntityAnimalFarm(final int aID, final String aName, final String aNameRegional) {
- super(aID, aName, aNameRegional);
- }
-
- public GregtechMetaTileEntityAnimalFarm(final String aName) {
+ public GregtechMetaTileEntityAnimalFarm(String aName) {
super(aName);
+ // TODO Auto-generated constructor stub
}
-
- @Override
- public String[] getDescription() {
- return new String[]{
- "Controller Block for the Animal Farmer",
- "How to get your first logs without an axe.",
- "Max Size(WxHxD): 9x1x9 (Controller, with upto 4 dirt out each direction on a flat plane.)",
- "Dirt for the rest! [D = Dirt, X = Controller]"
- };
- }
-
- @Override
- public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) {
- if (aSide == 1) {
- return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Acacia_Log), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Vent_Fast : TexturesGtBlock.Overlay_Machine_Vent)};
- }
- return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Farm_Manager)};
+
+ public GregtechMetaTileEntityAnimalFarm(int aID, String aName, String aNameRegional) {
+ super(aID, aName, aNameRegional);
+ // TODO Auto-generated constructor stub
}
@Override
- public GT_Recipe.GT_Recipe_Map getRecipeMap() {
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity p0) {
+ // TODO Auto-generated method stub
return null;
}
@Override
- public boolean isTeleporterCompatible() {
- return false;
- }
-
- @Override
- public boolean isFacingValid(final byte aFacing) {
- return aFacing > 1;
- }
-
- @Override
- public boolean isAccessAllowed(final EntityPlayer aPlayer) {
- return true;
- }
-
- @Override
- public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aCoverID) {
- return (GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover()) && (super.allowCoverOnSide(aSide, aCoverID));
- }
-
- @Override
- public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) {
- return new GregtechMetaTileEntityAnimalFarm(this.mName);
+ public String[] getDescription() {
+ // TODO Auto-generated method stub
+ return null;
}
@Override
- public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) {
- if (aBaseMetaTileEntity.isClientSide()) {
- return true;
- }
-
- return true;
+ public ITexture[] getTexture(IGregTechTileEntity p0, byte p1, byte p2, byte p3, boolean p4, boolean p5) {
+ // TODO Auto-generated method stub
+ return null;
}
@Override
- public boolean isCorrectMachinePart(final ItemStack aStack) {
- return true;
+ public boolean isCorrectMachinePart(ItemStack p0) {
+ // TODO Auto-generated method stub
+ return false;
}
@Override
- public boolean checkRecipe(final ItemStack aStack) {
- Logger.INFO("Working");
- /*if (!checkRecursiveBlocks()) {
- this.mEfficiency = 0;
- this.mEfficiencyIncrease = 0;
- this.mMaxProgresstime = 0;
- running = false;
- return false;
- }
-
- if (mEfficiency == 0) {
- this.mEfficiency = 10000;
- this.mEfficiencyIncrease = 10000;
- this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
- //GT_Pollution.addPollution(new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), mMaxProgresstime*5);
- return true;
- }*/
- this.mEfficiency = 0;
- this.mEfficiencyIncrease = 0;
- this.mMaxProgresstime = 0;
+ public boolean checkRecipe(ItemStack p0) {
+ // TODO Auto-generated method stub
return false;
}
-
- private Block getHumus(){
- if (!LoadedMods.Forestry){
- return null;
- }
- return TreefarmManager.getHumus();
- }
-
@Override
- public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) {
-
- //this.mCasings.clear();
- Logger.INFO("Step 1");
- 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++) {
- Logger.INFO("Step 2");
- for (int j = -7; j <= 7; j++) {
- Logger.INFO("Step 3");
- for (int h = 0; h <= 1; h++) {
- Logger.INFO("Step 4");
-
- final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j);
-
- //Farm Floor inner 14x14
- if (((i != -7) && (i != 7)) && ((j != -7) && (j != 7))) {
- Logger.INFO("Step 5 - H:"+h);
- // Farm Dirt Floor and Inner Air/Log space.
- if (h == 0) {
- //Dirt Floor
- if (!TreefarmManager.isDirtBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) {
- Logger.INFO("Dirt like block missing from inner 14x14.");
- Logger.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;
- }
- }
- // Inside fenced area, mostly air or trees or saplings
- 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));
- //return false;
- }*/
- }
-
- }
- //Dealt with inner 5x5, now deal with the exterior.
- else {
- Logger.INFO("Step 6 - H:"+h);
- //Deal with all 4 sides (Fenced area)
- if (h == 1) {
- if (!TreefarmManager.isFenceBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) {
- Logger.INFO("Fence/Gate missing from outside the second layer.");
- Logger.INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName());
- return false;
- }
- }
- //Deal with Bottom edges (Add Hatches/Busses first, othercheck make sure it's dirt) //TODO change the casings to not dirt~
- else if (h == 0) {
-
- try {
- this.addCasingToCasingList(tTileEntity);
- } catch (final Throwable t){}
-
- if ((!this.addMaintenanceToMachineList(tTileEntity, 77)) && (!this.addInputToMachineList(tTileEntity, 77)) && (!this.addOutputToMachineList(tTileEntity, 77)) && (!this.addEnergyInputToMachineList(tTileEntity, 77))) {
- if (((xDir + i) != 0) || ((zDir + j) != 0)) {//no controller
-
- if (!(aBaseMetaTileEntity.getMetaTileID() != 752)) {
- Logger.INFO("Fark Keeper Casings Missing from one of the edges on the bottom edge. x:"+(xDir+i)+" y:"+h+" z:"+(zDir+j)+" | "+aBaseMetaTileEntity.getClass());
- Logger.INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName());
- return false;
- }
- Logger.INFO("Found a farm keeper.");
- }
- }
- }
- Logger.INFO("Step a");
-
- }
- Logger.INFO("Step b");
- }
- Logger.INFO("Step c");
- }
- Logger.INFO("Step d");
- }
- Logger.INFO("Step 7");
-
- //Must have at least one energy hatch.
- if (this.mEnergyHatches != null) {
- for (int i = 0; i < this.mEnergyHatches.size(); i++) {
- if (this.mEnergyHatches.get(i).mTier < 2){
- Logger.INFO("You require at LEAST MV tier Energy Hatches.");
- Logger.INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getXCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getZCoord());
- return false;
- }
- }
- }
- //Must have at least one output hatch.
- if (this.mOutputHatches != null) {
- for (int i = 0; i < this.mOutputHatches.size(); i++) {
-
- if ((this.mOutputHatches.get(i).mTier < 2) && (this.mOutputHatches.get(i).getBaseMetaTileEntity() instanceof GregtechMTE_NuclearReactor)){
- Logger.INFO("You require at LEAST MV tier Output Hatches.");
- Logger.INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getXCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getZCoord());
- Logger.INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getInventoryName());
- return false;
- }
- }
- }
- //Must have at least one input hatch.
- if (this.mInputHatches != null) {
- for (int i = 0; i < this.mInputHatches.size(); i++) {
- if (this.mInputHatches.get(i).mTier < 2){
- Logger.INFO("You require at LEAST MV tier Input Hatches.");
- Logger.INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getXCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getZCoord());
- Logger.INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getInventoryName());
- return false;
- }
- }
- }
- this.mSolderingTool = true;
- //turnCasingActive(true);
- Logger.INFO("Multiblock Formed.");
- return true;
+ public boolean checkMachine(IGregTechTileEntity p0, ItemStack p1) {
+ // TODO Auto-generated method stub
+ return false;
}
@Override
- public int getMaxEfficiency(final ItemStack aStack) {
- return 10000;
+ public int getMaxEfficiency(ItemStack p0) {
+ // TODO Auto-generated method stub
+ return 0;
}
@Override
- public int getPollutionPerTick(final ItemStack aStack) {
+ public int getPollutionPerTick(ItemStack p0) {
+ // TODO Auto-generated method stub
return 0;
}
@Override
- public int getDamageToComponent(final ItemStack aStack) {
+ public int getDamageToComponent(ItemStack p0) {
+ // TODO Auto-generated method stub
return 0;
}
- public int getAmountOfOutputs() {
- return 1;
- }
-
@Override
- public boolean explodesOnComponentBreak(final ItemStack aStack) {
- return false;
- }
-
- public boolean addCasingToCasingList(final IGregTechTileEntity aTileEntity) {
- if (aTileEntity == null) {
- return false;
- }
- final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
- if (aMetaTileEntity == null) {
- return false;
- }
- if (aMetaTileEntity instanceof GT_MetaTileEntity_TieredMachineBlock) {
- //return this.mCasings.add((GT_MetaTileEntity_TieredMachineBlock) aMetaTileEntity);
- }
+ public boolean explodesOnComponentBreak(ItemStack p0) {
+ // TODO Auto-generated method stub
return false;
}
- private GT_MetaTileEntity_TieredMachineBlock changeTextureswithReflection(final GT_MetaTileEntity_TieredMachineBlock casing, final ITexture[][][] textureSet){
- final GT_MetaTileEntity_TieredMachineBlock cv = casing;
- //System.out.println("Before: "+cv.mTextures.hashCode());
- //Get declared field from class
- Field f;
- try {
- final Field[] x = cv.getClass().getFields();
- for (int i =0; i<x.length;i++){
- //Utils.LOG_INFO(x[i].getName());
- }
- try {
- //Try get the field variable
- f = cv.getClass().getField("mTextures");
- // set the accessiblity of the field to true, this will enable you to change the value
- f.setAccessible(true);
- //change the field value
- f.set(cv, textureSet);
- //Verify change in texture set
- //System.out.println("After: "+cv.mTextures.hashCode());
- return cv;
- } catch (final NoSuchFieldException e) {
- Logger.INFO("Could not find mTextures.");
- return casing;
- }
- } catch (SecurityException | IllegalArgumentException | IllegalAccessException e) {
- // TODO Auto-generated catch block
- //e.printStackTrace();
- return casing;
- }
- }
-
-
- public ITexture[][][] getTextureSet() {
- final ITexture[][][] rTextures = new ITexture[10][17][];
- for (byte i = -1; i < 16; i++) {
- rTextures[0][i + 1] = this.getFront(i);
- rTextures[1][i + 1] = this.getBack(i);
- rTextures[2][i + 1] = this.getBottom(i);
- rTextures[3][i + 1] = this.getTop(i);
- rTextures[4][i + 1] = this.getSides(i);
- rTextures[5][i + 1] = this.getFrontActive(i);
- rTextures[6][i + 1] = this.getBackActive(i);
- rTextures[7][i + 1] = this.getBottomActive(i);
- rTextures[8][i + 1] = this.getTopActive(i);
- rTextures[9][i + 1] = this.getSidesActive(i);
- }
- return rTextures;
- }
-
- public ITexture[] getFront(final byte aColor) {
- return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]};
- }
-
- public ITexture[] getBack(final byte aColor) {
- return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]};
- }
-
- public ITexture[] getBottom(final byte aColor) {
- return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]};
- }
-
- public ITexture[] getTop(final byte aColor) {
- return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]};
- }
-
- public ITexture[] getSides(final byte aColor) {
- return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]};
- }
-
- public ITexture[] getFrontActive(final byte aColor) {
- return this.getFront(aColor);
- }
-
- public ITexture[] getBackActive(final byte aColor) {
- return this.getBack(aColor);
- }
-
- public ITexture[] getBottomActive(final byte aColor) {
- return this.getBottom(aColor);
- }
-
- public ITexture[] getTopActive(final byte aColor) {
- return this.getTop(aColor);
- }
-
- public ITexture[] getSidesActive(final byte aColor) {
- return this.getSides(aColor);
- }
} \ No newline at end of file
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 5af18e1f8f..a831829f6b 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,12 +1,12 @@
package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi;
-import java.util.concurrent.TimeUnit;
-
import gregtech.api.GregTech_API;
+import gregtech.api.enums.GT_Values;
import gregtech.api.enums.TAE;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy;
import gregtech.api.objects.GT_ItemStack;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.*;
@@ -14,10 +14,12 @@ import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.core.block.ModBlocks;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.players.FakeFarmer;
+import gtPlusPlus.core.slots.SlotBuzzSaw.SAWTOOL;
import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_TreeFarmer;
import gtPlusPlus.xmod.gregtech.api.gui.GUI_TreeFarmer;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
+import gtPlusPlus.xmod.gregtech.common.helpers.TreeFarmHelper;
import net.minecraft.block.Block;
import net.minecraft.entity.player.*;
import net.minecraft.item.ItemStack;
@@ -27,15 +29,23 @@ import net.minecraft.server.MinecraftServer;
public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase {
public final static int TEX_INDEX = 31;
-
+ protected boolean mIsCurrentlyWorking = false;
+
/**
* Farm AI
*/
private EntityPlayerMP farmerAI;
public EntityPlayerMP getFakePlayer() {
- return this.farmerAI;
+ return this.farmerAI = checkFakePlayer();
+ }
+
+ public EntityPlayerMP checkFakePlayer() {
+ if (this.farmerAI == null) {
+ return new FakeFarmer(MinecraftServer.getServer().worldServerForDimension(this.getBaseMetaTileEntity().getWorld().provider.dimensionId));
+ }
+ return this.farmerAI;
}
-
+
public GregtechMetaTileEntityTreeFarm(final int aID, final String aName, final String aNameRegional) {
super(aID, aName, aNameRegional);
@@ -45,6 +55,10 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase
super(aName);
}
+ public boolean isCurrentlyWorking() {
+ return this.mIsCurrentlyWorking;
+ }
+
@Override
public String[] getDescription() {
return new String[]{
@@ -73,9 +87,9 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase
public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) {
if (aSide == 0) {
return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Acacia_Log)};
- }
+ }
if (aSide == 1) {
- return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Acacia_Log), new GT_RenderedTexture(true ? TexturesGtBlock.Overlay_Machine_Vent_Fast : TexturesGtBlock.Overlay_Machine_Vent)};
+ return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Acacia_Log), new GT_RenderedTexture(isCurrentlyWorking() ? TexturesGtBlock.Overlay_Machine_Vent_Fast : TexturesGtBlock.Overlay_Machine_Vent)};
}
return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Farm_Manager)};
}
@@ -136,7 +150,7 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase
aBaseMetaTileEntity.openGUI(aPlayer);
return true;
}
-
+
public Block getCasingBlock() {
return ModBlocks.blockCasings2Misc;
}
@@ -161,7 +175,7 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase
public boolean isGivingInformation() {
return true;
}
-
+
@Override
public String[] getInfoData() {
String[] mSuper = super.getInfoData();
@@ -179,6 +193,8 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase
}
@Override
public boolean onRunningTick(final ItemStack aStack) {
+ //Logger.INFO("s");
+
return super.onRunningTick(aStack);
}
@@ -186,34 +202,151 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase
public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
//Do Main Multi Logic first
super.onPostTick(aBaseMetaTileEntity, aTick);
-
+
//Do Tree Farm logic next on server side
- if (aBaseMetaTileEntity.isServerSide()) {
-
-
- //Set Forestry Fake player Sapling Planter
- if (this.farmerAI == null) {
- this.farmerAI = new FakeFarmer(MinecraftServer.getServer().worldServerForDimension(this.getBaseMetaTileEntity().getWorld().provider.dimensionId));
+ if (aBaseMetaTileEntity.isServerSide()) {
+
+ //Simple Repairs for a simple machine
+ if (isCurrentlyWorking()) {
+ this.mSolderingTool = true;
+ }
+
+ if (this.getBaseMetaTileEntity().isServerSide()) {
+ if (this.mEnergyHatches.size() > 0) {
+ for (GT_MetaTileEntity_Hatch_Energy j : this.mEnergyHatches) {
+ //Logger.INFO(""+j.getInputTier());
+ if (this.getEUVar() <= (this.maxEUStore()-GT_Values.V[(int) j.getInputTier()])) {
+ this.setEUVar(this.getEUVar()+GT_Values.V[(int) j.getInputTier()]);
+ j.setEUVar(j.getEUVar()-GT_Values.V[(int) j.getInputTier()]);
+ }
+ else if (this.getEUVar() > (this.maxEUStore()-GT_Values.V[(int) j.getInputTier()])) {
+ long diff = (this.maxEUStore()-this.getEUVar());
+ this.setEUVar(this.getEUVar()+diff);
+ j.setEUVar(j.getEUVar()-diff);
+ }
+ }
+ }
}
-
-
-
-
+
+
+
}
- //Client Side - do nothing
}
@Override
- public boolean checkRecipe(ItemStack p0) {
+ public boolean checkRecipe(ItemStack p0) {
+ mIsCurrentlyWorking = (isCorrectMachinePart(p0) && this.getEUVar() > 0);
+ if (isCurrentlyWorking()) {
+ return true;
+ }
return false;
}
@Override
- public boolean checkMachine(IGregTechTileEntity p0, ItemStack p1) {
- return false;
+ public boolean isCorrectMachinePart(final ItemStack aStack) {
+ boolean isValid = false;
+ final SAWTOOL currentInputItem = TreeFarmHelper.isCorrectMachinePart(aStack);
+ if (currentInputItem != SAWTOOL.NONE){
+ isValid = true;
+ }
+ return isValid;
+ }
+
+ @Override
+ public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) {
+ Logger.WARNING("Step 1");
+ 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++) {
+ Logger.WARNING("Step 2");
+ for (int j = -7; j <= 7; j++) {
+ Logger.WARNING("Step 3");
+ for (int h = 0; h <= 1; h++) {
+ Logger.WARNING("Step 4");
+ final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j);
+ //Farm Floor inner 14x14
+ if (((i != -7) && (i != 7)) && ((j != -7) && (j != 7))) {
+ Logger.WARNING("Step 5 - H:"+h);
+ // Farm Dirt Floor and Inner Air/Log space.
+ if (h == 0) {
+ //Dirt Floor
+ if (!TreeFarmHelper.isDirtBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) {
+ Logger.MACHINE_INFO("Dirt like block missing from inner 14x14.");
+ Logger.MACHINE_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName());
+ return false;
+ }
+ }
+ }
+ //Dealt with inner 5x5, now deal with the exterior.
+ else {
+ Logger.WARNING("Step 6 - H:"+h);
+ //Deal with all 4 sides (Fenced area)
+ if (h == 1) {
+ if (!TreeFarmHelper.isFenceBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) {
+ Logger.MACHINE_INFO("Fence/Gate missing from outside the second layer.");
+ Logger.MACHINE_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName());
+ return false;
+ }
+ }
+ //Deal with Bottom edges (Add Hatches/Busses first, othercheck make sure it's dirt) //TODO change the casings to not dirt~?
+ else if (h == 0) {
+ if (tTileEntity != null)
+ if ((!this.addMaintenanceToMachineList(tTileEntity, TAE.GTPP_INDEX(TEX_INDEX))) && (!this.addInputToMachineList(tTileEntity, TAE.GTPP_INDEX(TEX_INDEX))) && (!this.addOutputToMachineList(tTileEntity, TAE.GTPP_INDEX(TEX_INDEX))) && (!this.addEnergyInputToMachineList(tTileEntity, TAE.GTPP_INDEX(TEX_INDEX)))) {
+ if (((xDir + i) != 0) || ((zDir + j) != 0)) {//no controller
+
+ if (tTileEntity.getMetaTileID() != 752) {
+ Logger.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());
+ Logger.MACHINE_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()+" "+tTileEntity.getMetaTileID());
+ return false;
+ }
+ Logger.WARNING("Found a farm keeper.");
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //Must have at least one energy hatch.
+ if (this.mEnergyHatches != null) {
+ for (int i = 0; i < this.mEnergyHatches.size(); i++) {
+ if (this.mEnergyHatches.get(i).mTier < 1){
+ Logger.MACHINE_INFO("You require at LEAST MV tier Energy Hatches.");
+ Logger.MACHINE_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getXCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getZCoord());
+ return false;
+ }
+ }
+ }
+ //Must have at least one output hatch.
+ if (this.mOutputHatches != null) {
+ for (int i = 0; i < this.mOutputHatches.size(); i++) {
+
+ if (this.mOutputHatches.get(i).mTier < 1){
+ Logger.MACHINE_INFO("You require at LEAST MV tier Output Hatches.");
+ Logger.MACHINE_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getXCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getZCoord());
+ Logger.MACHINE_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getInventoryName());
+ return false;
+ }
+ }
+ }
+ //Must have at least one input hatch.
+ if (this.mInputHatches != null) {
+ for (int i = 0; i < this.mInputHatches.size(); i++) {
+ if (this.mInputHatches.get(i).mTier < 1){
+ Logger.MACHINE_INFO("You require at LEAST MV tier Input Hatches.");
+ Logger.MACHINE_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getXCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getZCoord());
+ Logger.MACHINE_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getInventoryName());
+ return false;
+ }
+ }
+ }
+ Logger.MACHINE_INFO("Multiblock Formed.");
+ return true;
}
@@ -225,7 +358,7 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase
@Override
public void onServerStart() {
- // TODO Auto-generated method stub
+ getFakePlayer();
super.onServerStart();
}