diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2017-01-21 17:05:51 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2017-01-21 17:05:51 +1000 |
commit | 9dd4ec3dce97a5aff9a1501a684fe02a75055940 (patch) | |
tree | 8025e6b7b8a267f4ae0e96d21488158e4348591b | |
parent | 2750e87c0532c98cab77362fbe248d0dba4627fd (diff) | |
download | GT5-Unofficial-9dd4ec3dce97a5aff9a1501a684fe02a75055940.tar.gz GT5-Unofficial-9dd4ec3dce97a5aff9a1501a684fe02a75055940.tar.bz2 GT5-Unofficial-9dd4ec3dce97a5aff9a1501a684fe02a75055940.zip |
+ Added information about the power stored and operations remaining to the Tree Farmer GUI. Thanks to @Dragon2488 for showing me how Container syncing should be done properly.
% Rewrote the Tooltip for the Tree Farmer Controller block.
% Changed the Tree Farmer GUI, moved the item slot up 18px and added a console for the power information.
$ Fixed the tool check returning Null when valid tools were present in the Tree Farmer.
5 files changed, 107 insertions, 77 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java index 144f0b9e8f..4f94b661d8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java @@ -3,14 +3,18 @@ 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 gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityTreeFarm; + +import java.util.List; + import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; -/** - * 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 long maxEU = 0; + public long storedEU = 0; + public CONTAINER_TreeFarmer(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { super(aInventoryPlayer, aTileEntity); } @@ -21,7 +25,7 @@ public class CONTAINER_TreeFarmer extends GT_ContainerMetaTile_Machine { @Override public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new SlotBuzzSaw(mTileEntity, 1, 80, 35)); + addSlotToContainer(new SlotBuzzSaw(mTileEntity, 1, 80, 17)); } @Override @@ -33,4 +37,30 @@ public class CONTAINER_TreeFarmer extends GT_ContainerMetaTile_Machine { public int getShiftClickSlotCount() { return 0; } -} + + @Override + public void updateProgressBar(int id, int value) { + super.updateProgressBar(id, value); + switch (id) { + case 100: + this.maxEU = value; + return; + case 101: + this.storedEU = value; + break; + default: + break; + } + } + + @SuppressWarnings("unchecked") + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + for(ICrafting crafting : (List<ICrafting>)crafters) { + crafting.sendProgressBarUpdate(this, 100, (int) ((GregtechMetaTileEntityTreeFarm) this.mTileEntity.getMetaTileEntity()).maxEUStore()); + crafting.sendProgressBarUpdate(this, 101, (int) ((GregtechMetaTileEntityTreeFarm) this.mTileEntity.getMetaTileEntity()).getStoredInternalPower()); + } + } + +}
\ No newline at end of file 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 034119ed0b..25cd4863a8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java @@ -6,59 +6,38 @@ 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); - } + String mName = ""; + long maxPower = 0; + long storedPower = 0; + + 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, 6, 16448255); + if (mContainer != null) { + maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU; + storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU; + if (((CONTAINER_TreeFarmer) mContainer).mDisplayErrorCode == 0) { + fontRendererObj.drawString("Current Power Stored: "+storedPower+"EU", 10, 52, 16448255); + fontRendererObj.drawString("Max Power Storage: "+maxPower+"EU", 10, 60, 16448255); + fontRendererObj.drawString("Current operations left: "+(storedPower/32), 10, 68, 16448255); + } + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU; + storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU; + 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/helpers/TreeFarmHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java index b687ac1559..ce49a684fd 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java @@ -153,10 +153,10 @@ public class TreeFarmHelper { if (OrePrefixes.craftingTool.contains(aStack)){ if (aStack.getDisplayName().toLowerCase().contains("saw")){ if (aStack.getItemDamage() == 10){ - return SAWTOOL.NONE; + return SAWTOOL.SAW; } else if (aStack.getItemDamage() == 140){ - return SAWTOOL.NONE; + return SAWTOOL.BUZZSAW; } else { return SAWTOOL.NONE; 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 55c57164e4..1f8d812639 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 @@ -16,6 +16,7 @@ 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.CONTAINER_TreeFarmer; import gtPlusPlus.xmod.gregtech.api.gui.GUI_TreeFarmer; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.helpers.TreeFarmHelper; @@ -35,11 +36,11 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock /* private */ private int treeCheckTicks = 0; /* private */ private int plantSaplingTicks = 0; /* private */ private int cleanupTicks = 0; - /* private */ private boolean canChop = false; - /* private */ private long mInternalPower = 0; + /* private */ public long mInternalPower = 0; /* private */ private static int powerDrain = 32; private SAWTOOL mCurrentMachineTool = SAWTOOL.NONE; + private boolean canChop = false; private int cuttingNumber = 0; private int cuttingNumber2 = 0; @@ -58,9 +59,18 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock return new String[]{ "Controller Block for the Tree 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.)" + "Size(WxHxD): 15x2x15", + "Purple: Farm Keeper Blocks", + "Dark Purple: Dirt/Grass/Podzol/Humus", + "Light Blue: Fence/Fence Gate", + "Blue/Yellow: Controller" }; } + + public long getStoredInternalPower(){ + //Utils.LOG_MACHINE_INFO("returning "+this.mInternalPower+"EU to the called method."); + return this.mInternalPower; + } @Override @@ -109,7 +119,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock @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_Acacia_Log), new GT_RenderedTexture(canChop ? TexturesGtBlock.Overlay_Machine_Vent_Fast : TexturesGtBlock.Overlay_Machine_Vent)}; } return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Farm_Manager)}; } @@ -147,7 +157,12 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return new GUI_TreeFarmer(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "TreeFarmer.png"); - } + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_TreeFarmer(aPlayerInventory, aBaseMetaTileEntity); + } @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { @@ -165,13 +180,15 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock if (currentInputItem != SAWTOOL.NONE){ if (currentInputItem == SAWTOOL.SAW){ mCurrentMachineTool = SAWTOOL.SAW; - isValid = true; } - else if (currentInputItem == SAWTOOL.BUZZSAW){ + else { mCurrentMachineTool = SAWTOOL.BUZZSAW; - isValid = true; } - } + isValid = true; + } + else { + //Utils.LOG_MACHINE_INFO("Found "+aStack.getDisplayName()); + } return isValid; } @@ -357,7 +374,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock @Override public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - + //super.onPostTick(aBaseMetaTileEntity, aTick); if (aBaseMetaTileEntity.isServerSide()) { //Does it have a tool this cycle to cut? @@ -370,6 +387,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock try { validCuttingTool = isCorrectMachinePart(mInventory[1]); if (validCuttingTool){ + this.mMaxProgresstime = 600; String materialName = GT_MetaGenerated_Tool.getPrimaryMaterial(mInventory[1]).mDefaultLocalName; if (materialName.toLowerCase().contains("null")){ @@ -378,11 +396,14 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock } } + else { + this.mMaxProgresstime = 0; + } } catch (NullPointerException t){} if (isRepaired){ //If Machine can work and it's only once every 5 seconds this will tick. - if (mMachine){ + if (canChop){ //Set Machine State if (treeCheckTicks == 200){ Utils.LOG_MACHINE_INFO("Looking For Trees - Serverside | "+treeCheckTicks); @@ -408,7 +429,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock //Set can work state this.mInputBusses = new ArrayList<GT_MetaTileEntity_Hatch_InputBus>(); this.mEnergyHatches = new ArrayList<GT_MetaTileEntity_Hatch_Energy>(); - mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]); + canChop = checkMachine(aBaseMetaTileEntity, mInventory[1]); } } //Call Cleanup Task last, before ticking. @@ -497,7 +518,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock } - mMachine = false; + canChop = false; if (logsCut > 250) TreeFarmHelper.cleanUp(aBaseMetaTileEntity); //Utils.LOG_MACHINE_INFO("general failure | maybe there is no logs, not an error. | cut:"+logsCut ); @@ -590,8 +611,8 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock 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); + //world.setBlock(posX, posY, posZ, saplingToPlace); + //world.setBlockMetadataWithNotify(posX, posY, posZ, n.getItemDamage(), 4); //Deplete Input stack depleteInputEx(n); drainEnergyInput(powerDrain); diff --git a/src/resources/assets/miscutils/textures/gui/TreeFarmer.png b/src/resources/assets/miscutils/textures/gui/TreeFarmer.png Binary files differindex 6b668e0712..df42131b5b 100644 --- a/src/resources/assets/miscutils/textures/gui/TreeFarmer.png +++ b/src/resources/assets/miscutils/textures/gui/TreeFarmer.png |