diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2017-01-08 13:26:26 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2017-01-08 13:26:26 +1000 |
commit | b7aed15f0ed43f7c4e809d82cfa6e95fb8a0b9ea (patch) | |
tree | 280a9522f0fa3958885987dac3ad98960575ea3a /src/Java/gtPlusPlus/xmod | |
parent | d5f700a2279ee19386609663c40471daf69d5fbb (diff) | |
download | GT5-Unofficial-b7aed15f0ed43f7c4e809d82cfa6e95fb8a0b9ea.tar.gz GT5-Unofficial-b7aed15f0ed43f7c4e809d82cfa6e95fb8a0b9ea.tar.bz2 GT5-Unofficial-b7aed15f0ed43f7c4e809d82cfa6e95fb8a0b9ea.zip |
$ Rewrote the logic for tree chopping, now the Tree Farmer cuts tree and clears leaves for upto 150 blocks above it.
+ Added a isLeaves check to TreefarmManager.java.
+ Added a placeholder casing texture for the Tree Farmer. (ID 77)
+ Added vanilla Podzol and Acacia log textures.
% Changed the textures on TreeFarmer blocks.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod')
7 files changed, 627 insertions, 57 deletions
diff --git a/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java b/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java index 95c2bcf125..65bc3231aa 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java +++ b/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java @@ -64,6 +64,11 @@ public class TreefarmManager { String tTool = log.getHarvestTool(0); return OrePrefixes.log.contains(new ItemStack(log, 1))&& ((tTool != null) && (tTool.equals("axe"))) || (log.getMaterial() == Material.wood); } + + public static boolean isLeaves(Block log){ + String tTool = log.getHarvestTool(0); + return OrePrefixes.leaves.contains(new ItemStack(log, 1)) || (log.getMaterial() == Material.leaves); + } public static boolean isDirtBlock(Block dirt){ return (dirt == Blocks.dirt ? true : (dirt == Blocks.grass ? true : (getHumus() == null ? false : (dirt == blockHumus ? true : false)))); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaTreeFarmerBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaTreeFarmerBase.java index b76ca01bbc..9ebf6b3a2d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaTreeFarmerBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaTreeFarmerBase.java @@ -141,11 +141,11 @@ public abstract class GregtechMetaTreeFarmerBase extends GT_MetaTileEntity_Tiere } public ITexture[] getBottom(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Farm_Manager)}; + return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Acacia_Log)}; } public ITexture[] getTop(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Farm_Manager)}; + return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Podzol)}; } public ITexture[] getSides(byte aColor) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java index 4f5744e5ec..2a0717af5d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java @@ -24,8 +24,8 @@ extends GregtechMetaCasingBlocksAbstract { GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Structural Glass Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Hastelloy-N Sealant Block"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Hastelloy-X Structural Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Incoloy-DS Fluid Containment Block"); //60 - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Placeholder Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Incoloy-DS Fluid Containment Block"); //76 + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Placeholder Casing"); //IS A PLACEHOLDER DO NOT CHANGE GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Placeholder Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Incoloy Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Placeholder Casing"); 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 aa4a4f603e..7bf0ea4644 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java @@ -21,7 +21,7 @@ public class CasingTextureHandler2 { return TexturesGtBlock.Casing_Material_Fluid_IncoloyDS.getIcon(); //Material Press Casings case 4: - return TexturesGtBlock._PlaceHolder.getIcon(); + return TexturesGtBlock.Casing_Machine_Farm_Manager.getIcon(); //Electrolyzer Casings case 5: return TexturesGtBlock._PlaceHolder.getIcon(); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java index 689b02474a..e2882a6e47 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -13,7 +13,7 @@ public class TexturesGtBlock { /* * Handles Custom Textures. */ - + public static class CustomIcon implements IIconContainer, Runnable { protected IIcon mIcon; protected String mIconName; @@ -45,8 +45,8 @@ public class TexturesGtBlock { return TextureMap.locationBlocksTexture; } } - - + + /* * Add Some Custom Textures below. * I am not sure whether or not I need to declare them as such, but better to be safe than sorry. @@ -58,7 +58,7 @@ public class TexturesGtBlock { private static final CustomIcon Internal_PlaceHolder = new CustomIcon("TileEntities/_PlaceHolder"); public static final CustomIcon _PlaceHolder = Internal_PlaceHolder; - + //Machine Casings //Simple private static final CustomIcon Internal_Casing_Machine_Simple_Top = new CustomIcon("TileEntities/machine_top"); @@ -75,7 +75,7 @@ public class TexturesGtBlock { public static final CustomIcon Casing_Machine_Dimensional = Internal_Casing_Machine_Dimensional; private static final CustomIcon Internal_Casing_Machine_Dimensional_Adv = new CustomIcon("TileEntities/high_adv_machine_dimensional"); public static final CustomIcon Casing_Machine_Dimensional_Adv = Internal_Casing_Machine_Dimensional_Adv; - + //Material Casings private static final CustomIcon Internal_Casing_Tantalloy61 = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TANTALLOY61"); public static final CustomIcon Casing_Material_Tantalloy61 = Internal_Casing_Tantalloy61; @@ -91,7 +91,7 @@ public class TexturesGtBlock { public static final CustomIcon Casing_Material_Zeron100 = Internal_Casing_Zeron100; private static final CustomIcon Internal_Casing_Potin = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_POTIN"); public static final CustomIcon Casing_Material_Potin = Internal_Casing_Potin; - + private static final CustomIcon Internal_Casing_Grisium = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_GRISIUM"); public static final CustomIcon Casing_Material_Grisium = Internal_Casing_Grisium; private static final CustomIcon Internal_Casing_Incoloy020 = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_INCOLOY_020"); @@ -102,7 +102,7 @@ public class TexturesGtBlock { public static final CustomIcon Casing_Material_IncoloyMA956 = Internal_Casing_IncoloyMA956; private static final CustomIcon Internal_Casing_ZirconiumCarbide = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_ZIRCONIUM_CARBIDE"); public static final CustomIcon Casing_Material_ZirconiumCarbide = Internal_Casing_ZirconiumCarbide; - + private static final CustomIcon Internal_Casing_HastelloyX = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_HASTELLOY_X"); public static final CustomIcon Casing_Material_HastelloyX = Internal_Casing_HastelloyX; @@ -110,22 +110,28 @@ public class TexturesGtBlock { public static final CustomIcon Casing_Material_HastelloyN = Internal_Casing_HastelloyN; private static final CustomIcon Internal_Casing_Fluid_IncoloyDS = new CustomIcon("TileEntities/MACHINE_CASING_FLUID_INCOLOY_DS"); public static final CustomIcon Casing_Material_Fluid_IncoloyDS = Internal_Casing_Fluid_IncoloyDS; - + //Material Machine/Firebox Casings private static final CustomIcon Internal_Casing_Staballoy_Firebox = new CustomIcon("TileEntities/MACHINE_CASING_FIREBOX_STABALLOY"); public static final CustomIcon Casing_Staballoy_Firebox = Internal_Casing_Staballoy_Firebox; - + //Misc Casings private static final CustomIcon Internal_Casing_Machine_Redstone_Off = new CustomIcon("TileEntities/cover_redstone_conductor"); public static final CustomIcon Casing_Machine_Redstone_Off = Internal_Casing_Machine_Redstone_Off; private static final CustomIcon Internal_Casing_Machine_Redstone_On = new CustomIcon("TileEntities/cover_redstone_emitter"); public static final CustomIcon Casing_Machine_Redstone_On = Internal_Casing_Machine_Redstone_On; - + //MACHINE_CASING_FARM_MANAGER_STRUCTURAL //Farm Manager Casings private static final CustomIcon Internal_Casing_Machine_Farm_Manager = new CustomIcon("TileEntities/MACHINE_CASING_FARM_MANAGER_STRUCTURAL"); public static final CustomIcon Casing_Machine_Farm_Manager = Internal_Casing_Machine_Farm_Manager; - + //Acacia_Log + private static final CustomIcon Internal_Casing_Machine_Acacia_Log = new CustomIcon("TileEntities/log_acacia_top"); + public static final CustomIcon Casing_Machine_Acacia_Log = Internal_Casing_Machine_Acacia_Log; + //Podzol Top + private static final CustomIcon Internal_Casing_Machine_Podzol = new CustomIcon("TileEntities/dirt_podzol_top"); + public static final CustomIcon Casing_Machine_Podzol = Internal_Casing_Machine_Podzol; + //Overlays //Fan Textures private static final CustomIcon Internal_Overlay_Machine_Vent = new CustomIcon("TileEntities/machine_top_vent_rotating"); 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 new file mode 100644 index 0000000000..e6abbbd063 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityAnimalFarm.java @@ -0,0 +1,410 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +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.core.lib.LoadedMods; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.forestry.trees.TreefarmManager; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +import java.lang.reflect.Field; +import java.util.ArrayList; + +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 boolean running = false; + private boolean p1, p2, p3, p4, p5, p6; + public int mMaxProgresstime = 0; + public int mUpdate = 5; + public int mProgresstime = 0; + public boolean mMachine = false; + public ItemStack mOutputItem1; + public ItemStack mOutputItem2; + private Block Humus; + private boolean isForestryLoaded = TreefarmManager.isForestryValid(); + + public GregtechMetaTileEntityAnimalFarm(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntityAnimalFarm(String aName) { + super(aName); + } + + @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(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, 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)}; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { + return (GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover()) && (super.allowCoverOnSide(aSide, aCoverID)); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityAnimalFarm(this.mName); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + + return true; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + Utils.LOG_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; + return false; + } + + + private Block getHumus(){ + if (!LoadedMods.Forestry){ + return null; + } + return TreefarmManager.getHumus(); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + + this.mCasings.clear(); + Utils.LOG_INFO("Step 1"); + int xDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 7; + int zDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 7; + + for (int i = -7; i <= 7; i++) { + Utils.LOG_INFO("Step 2"); + for (int j = -7; j <= 7; j++) { + Utils.LOG_INFO("Step 3"); + for (int h = 0; h <= 1; h++) { + Utils.LOG_INFO("Step 4"); + + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + + //Farm Floor inner 14x14 + if ((i != -7 && i != 7) && (j != -7 && j != 7)) { + Utils.LOG_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))) { + Utils.LOG_INFO("Dirt like block missing from inner 14x14."); + Utils.LOG_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 { + Utils.LOG_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))) { + Utils.LOG_INFO("Fence/Gate missing from outside the second layer."); + Utils.LOG_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 { + addCasingToCasingList(tTileEntity); + } catch (Throwable t){} + + if ((!addMaintenanceToMachineList(tTileEntity, 77)) && (!addInputToMachineList(tTileEntity, 77)) && (!addOutputToMachineList(tTileEntity, 77)) && (!addEnergyInputToMachineList(tTileEntity, 77))) { + if ((xDir + i != 0) || (zDir + j != 0)) {//no controller + + if (!(aBaseMetaTileEntity.getMetaTileID() != 752)) { + Utils.LOG_INFO("Fark 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()); + return false; + } + Utils.LOG_INFO("Found a farm keeper."); + } + } + } + Utils.LOG_INFO("Step a"); + + } + Utils.LOG_INFO("Step b"); + } + Utils.LOG_INFO("Step c"); + } + Utils.LOG_INFO("Step d"); + } + Utils.LOG_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){ + Utils.LOG_INFO("You require at LEAST MV tier Energy Hatches."); + Utils.LOG_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)){ + Utils.LOG_INFO("You require at LEAST MV tier Output Hatches."); + Utils.LOG_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getXCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getZCoord()); + Utils.LOG_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){ + Utils.LOG_INFO("You require at LEAST MV tier Input Hatches."); + Utils.LOG_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getXCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getZCoord()); + Utils.LOG_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getInventoryName()); + return false; + } + } + } + mSolderingTool = true; + turnCasingActive(true); + Utils.LOG_INFO("Multiblock Formed."); + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + public boolean addCasingToCasingList(IGregTechTileEntity aTileEntity) { + if (aTileEntity == null) + return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) + return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_TieredMachineBlock) { + return this.mCasings.add((GT_MetaTileEntity_TieredMachineBlock) aMetaTileEntity); + } + return false; + } + + public boolean turnCasingActive(boolean status) { + if (this.mCasings != null) { + Utils.LOG_INFO("Changing casing Textures."); + for (GT_MetaTileEntity_TieredMachineBlock hatch : this.mCasings) { + hatch = changeTextureswithReflection(hatch, getTextureSet()); + } + } + return true; + } + + private GT_MetaTileEntity_TieredMachineBlock changeTextureswithReflection(GT_MetaTileEntity_TieredMachineBlock casing, ITexture[][][] textureSet){ + GT_MetaTileEntity_TieredMachineBlock cv = casing; + System.out.println("Before: "+cv.mTextures.hashCode()); + //Get declared field from class + Field f; + try { + 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 (NoSuchFieldException e) { + Utils.LOG_INFO("Could not find mTextures."); + return casing; + } + } catch (SecurityException | IllegalArgumentException | IllegalAccessException e) { + // TODO Auto-generated catch block + //e.printStackTrace(); + return casing; + } + } + + + public ITexture[][][] getTextureSet() { + ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = getFront(i); + rTextures[1][i + 1] = getBack(i); + rTextures[2][i + 1] = getBottom(i); + rTextures[3][i + 1] = getTop(i); + rTextures[4][i + 1] = getSides(i); + rTextures[5][i + 1] = getFrontActive(i); + rTextures[6][i + 1] = getBackActive(i); + rTextures[7][i + 1] = getBottomActive(i); + rTextures[8][i + 1] = getTopActive(i); + rTextures[9][i + 1] = getSidesActive(i); + } + return rTextures; + } + + public ITexture[] getFront(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; + } + + public ITexture[] getBack(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; + } + + public ITexture[] getBottom(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; + } + + public ITexture[] getTop(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; + } + + public ITexture[] getSides(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; + } + + public ITexture[] getFrontActive(byte aColor) { + return getFront(aColor); + } + + public ITexture[] getBackActive(byte aColor) { + return getBack(aColor); + } + + public ITexture[] getBottomActive(byte aColor) { + return getBottom(aColor); + } + + public ITexture[] getTopActive(byte aColor) { + return getTop(aColor); + } + + public ITexture[] getSidesActive(byte aColor) { + return 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 8edf2b4c2d..0c8fe98d17 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,8 +6,7 @@ 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.metatileentity.implementations.*; import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; @@ -23,6 +22,7 @@ import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlockBase { @@ -39,11 +39,11 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock public int mMaxProgresstime = 0; public int mUpdate = 5; public int mProgresstime = 0; - public boolean mMachine = false; public ItemStack mOutputItem1; public ItemStack mOutputItem2; private Block Humus; private boolean isForestryLoaded = TreefarmManager.isForestryValid(); + private int treeCheckTicks = 0; public GregtechMetaTileEntityTreeFarm(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -74,9 +74,9 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { if (aSide == 1) { - return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Tumbaga), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Vent_Fast : TexturesGtBlock.Overlay_Machine_Vent)}; + 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_Material_Tumbaga)}; + return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Farm_Manager)}; } @Override @@ -157,28 +157,28 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { this.mCasings.clear(); - Utils.LOG_INFO("Step 1"); + Utils.LOG_WARNING("Step 1"); int xDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 7; int zDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 7; for (int i = -7; i <= 7; i++) { - Utils.LOG_INFO("Step 2"); + Utils.LOG_WARNING("Step 2"); for (int j = -7; j <= 7; j++) { - Utils.LOG_INFO("Step 3"); + Utils.LOG_WARNING("Step 3"); for (int h = 0; h <= 1; h++) { - Utils.LOG_INFO("Step 4"); + Utils.LOG_WARNING("Step 4"); IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); //Farm Floor inner 14x14 if ((i != -7 && i != 7) && (j != -7 && j != 7)) { - Utils.LOG_INFO("Step 5 - H:"+h); + Utils.LOG_WARNING("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))) { - 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_WARNING("Dirt like block missing from inner 14x14."); + Utils.LOG_WARNING("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); aBaseMetaTileEntity.getWorld().setBlock( (aBaseMetaTileEntity.getXCoord()+(xDir+i)), (aBaseMetaTileEntity.getYCoord()+(h)), @@ -191,9 +191,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_WARNING("Wood like block missing from inner 14x14, layer 2."); //TODO + Utils.LOG_WARNING("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); + Utils.LOG_WARNING("Found at x:"+(xDir+i)+" y:"+h+" z:"+(zDir+j)); //return false; }*/ } @@ -201,12 +201,12 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock } //Dealt with inner 5x5, now deal with the exterior. else { - Utils.LOG_INFO("Step 6 - H:"+h); + Utils.LOG_WARNING("Step 6 - H:"+h); //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_WARNING("Fence/Gate missing from outside the second layer."); + Utils.LOG_WARNING("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); return false; } } @@ -217,28 +217,28 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock addCasingToCasingList(tTileEntity); } catch (Throwable t){} - if ((!addMaintenanceToMachineList(tTileEntity, 70)) && (!addInputToMachineList(tTileEntity, 70)) && (!addOutputToMachineList(tTileEntity, 70)) && (!addEnergyInputToMachineList(tTileEntity, 70))) { + if ((!addMaintenanceToMachineList(tTileEntity, 77)) && (!addInputToMachineList(tTileEntity, 77)) && (!addOutputToMachineList(tTileEntity, 77)) && (!addEnergyInputToMachineList(tTileEntity, 77))) { if ((xDir + i != 0) || (zDir + j != 0)) {//no controller if (!(aBaseMetaTileEntity.getMetaTileID() != 752)) { - Utils.LOG_INFO("Fark 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()); + Utils.LOG_WARNING("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_WARNING("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); return false; } - Utils.LOG_INFO("Found a farm keeper."); + Utils.LOG_WARNING("Found a farm keeper."); } } } - Utils.LOG_INFO("Step a"); + Utils.LOG_WARNING("Step a"); } - Utils.LOG_INFO("Step b"); + Utils.LOG_WARNING("Step b"); } - Utils.LOG_INFO("Step c"); + Utils.LOG_WARNING("Step c"); } - Utils.LOG_INFO("Step d"); + Utils.LOG_WARNING("Step d"); } - Utils.LOG_INFO("Step 7"); + Utils.LOG_WARNING("Step 7"); //Must have at least one energy hatch. if (this.mEnergyHatches != null) { @@ -274,8 +274,8 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock } } mSolderingTool = true; - turnCasingActive(true); - Utils.LOG_INFO("Multiblock Formed."); + //turnCasingActive(true); + //Utils.LOG_INFO("Multiblock Formed."); return true; } @@ -304,6 +304,155 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock return false; } + + //Tree Manager + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + + if (aBaseMetaTileEntity.isServerSide()) { + + //Check Inventory slots [1] + try { + Utils.LOG_INFO(mInventory[1].getDisplayName()); + } catch (Throwable t){} + + //Update Tick Timer Last - Do Not move up the call stack + if (treeCheckTicks > 100){ + treeCheckTicks = 0; + } + else { + treeCheckTicks++; + } + + //Set Machine State + if (treeCheckTicks == 100){ + mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]); + + //If Machine can work and it's only one of two times a second this will tick, tick. + if (mMachine){ + Utils.LOG_INFO("Looking For Trees - Serverside | "+treeCheckTicks); + boolean b = findLogs(aBaseMetaTileEntity); + Utils.LOG_INFO("Did I manage to find/cut logs? "+b); + } + } + + + + + } + //Client Side - do nothing + + } + + private boolean findLogs(IGregTechTileEntity aBaseMetaTileEntity){ + + Utils.LOG_INFO("called findLogs()"); + int logsCut = 0; + + int xDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 7; + 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++) { + for (int h=1;h<150;h++){ + + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + + //Farm Floor inner 14x14 + if ((i != -7 && i != 7) && (j != -7 && j != 7)) { + + //Farm Inner 13*13 + + //Make sure it's not logs and return. + 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; + } + + if (TreefarmManager.isLeaves(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("Cleaning Up some leaves."); + aBaseMetaTileEntity.getWorld().setBlockToAir(posiX, posiY, posiZ); + } + + if (TreefarmManager.isWoodLog(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j)) || TreefarmManager.isWoodLog(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))){ + Utils.LOG_INFO("Found A log of some kind I can chop."); + if (this.mEnergyHatches != null) { + for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches){ + if (isValidMetaTileEntity(tHatch)) { + //Utils.LOG_INFO("Hatch ["+"]| can hold:"+maxEUStore()+" | holding:"+tHatch.getEUVar()); + if (tHatch.getEUVar() >= 128) { + Utils.LOG_INFO("I should cut wood instead of print messages."); + Utils.LOG_INFO("Found at x:"+(xDir+i)+" y:"+h+" z:"+(zDir+j)); + logsCut++; + //tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(128 * 1, false); + + World world = aBaseMetaTileEntity.getWorld(); + int posX, posY, posZ; + posX = aBaseMetaTileEntity.getXCoord()+xDir+i; + posY = aBaseMetaTileEntity.getYCoord()+h; + posZ = aBaseMetaTileEntity.getZCoord()+zDir+j; + cutLog(world, posX, posY, posZ); + //Cut A Log + } + else { + //Utils.LOG_INFO("Not enough Power | can hold:"+maxEUStore()+" | holding:"+aBaseMetaTileEntity.getStoredEU()); + } + } + else { + Utils.LOG_INFO("Invalid Hatch Entitity"); + } + //End For loop + } + } + else { + Utils.LOG_INFO("No energy hatches found."); + } + } + + } + /*else { + Utils.LOG_INFO("tried scanning edge or fence"); + return false; + }*/ + + } + } + } + Utils.LOG_INFO("general failure | cut:"+logsCut ); + return false; + } + + + private boolean cutLog (World world, int X, int Y, int Z){ + Utils.LOG_INFO("Cutting Log"); + try { + Block block = world.getBlock(X, Y, Z); + Utils.LOG_WARNING(block.toString()); + block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); + world.setBlockToAir(X, Y, Z); + return true; + } catch (NullPointerException e){} + return false; + } + + + + + + + + + + + + + public boolean addCasingToCasingList(IGregTechTileEntity aTileEntity) { if (aTileEntity == null) return false; @@ -326,7 +475,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock return true; } - private GT_MetaTileEntity_TieredMachineBlock changeTextureswithReflection(GT_MetaTileEntity_TieredMachineBlock casing, ITexture[][][] textureSet){ + private static GT_MetaTileEntity_TieredMachineBlock changeTextureswithReflection(GT_MetaTileEntity_TieredMachineBlock casing, ITexture[][][] textureSet){ GT_MetaTileEntity_TieredMachineBlock cv = casing; System.out.println("Before: "+cv.mTextures.hashCode()); //Get declared field from class @@ -358,7 +507,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock } - public ITexture[][][] getTextureSet() { + public static ITexture[][][] getTextureSet() { ITexture[][][] rTextures = new ITexture[10][17][]; for (byte i = -1; i < 16; i++) { rTextures[0][i + 1] = getFront(i); @@ -375,43 +524,43 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock return rTextures; } - public ITexture[] getFront(byte aColor) { + public static ITexture[] getFront(byte aColor) { return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; } - public ITexture[] getBack(byte aColor) { + public static ITexture[] getBack(byte aColor) { return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; } - public ITexture[] getBottom(byte aColor) { + public static ITexture[] getBottom(byte aColor) { return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; } - public ITexture[] getTop(byte aColor) { + public static ITexture[] getTop(byte aColor) { return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; } - public ITexture[] getSides(byte aColor) { + public static ITexture[] getSides(byte aColor) { return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; } - public ITexture[] getFrontActive(byte aColor) { + public static ITexture[] getFrontActive(byte aColor) { return getFront(aColor); } - public ITexture[] getBackActive(byte aColor) { + public static ITexture[] getBackActive(byte aColor) { return getBack(aColor); } - public ITexture[] getBottomActive(byte aColor) { + public static ITexture[] getBottomActive(byte aColor) { return getBottom(aColor); } - public ITexture[] getTopActive(byte aColor) { + public static ITexture[] getTopActive(byte aColor) { return getTop(aColor); } - public ITexture[] getSidesActive(byte aColor) { + public static ITexture[] getSidesActive(byte aColor) { return getSides(aColor); } |