diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2017-07-03 19:57:27 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2017-07-03 19:57:27 +1000 |
commit | e0f84fd004e8a4d216bf21e905a733339dd3bc10 (patch) | |
tree | 6122805d18e0691ee1ce299bc10f2308b7f3a676 /src/Java | |
parent | 74fea0370bd77a703499267f0ccc2f6978628df4 (diff) | |
download | GT5-Unofficial-e0f84fd004e8a4d216bf21e905a733339dd3bc10.tar.gz GT5-Unofficial-e0f84fd004e8a4d216bf21e905a733339dd3bc10.tar.bz2 GT5-Unofficial-e0f84fd004e8a4d216bf21e905a733339dd3bc10.zip |
+ Added a new GUI for the Pollution Cleaners.
Diffstat (limited to 'src/Java')
3 files changed, 358 insertions, 17 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/CONTAINER_PollutionCleaner.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/CONTAINER_PollutionCleaner.java new file mode 100644 index 0000000000..17a207a2d1 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/CONTAINER_PollutionCleaner.java @@ -0,0 +1,256 @@ +package gtPlusPlus.xmod.gregtech.api.gui.basic; + +import java.util.Iterator; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.gui.*; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + * <p/> + * The Container I use for all my Basic Machines + */ +public class CONTAINER_PollutionCleaner extends GT_Container_BasicTank { + + public boolean mFluidTransfer = false, mItemTransfer = false, mStuttering = false; + + public CONTAINER_PollutionCleaner(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 8, 63, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 26, 63, false, true, 1)); + addSlotToContainer(new GT_Slot_Render(mTileEntity, 2, 107, 63)); + + int tStartIndex = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).getInputSlot(); + + switch (((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mInputSlotCount) { + case 0: + break; + case 1: + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 25)); + break; + case 2: + //addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 25)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 25)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 107, 25)); + break; + case 3: + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 25)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 25)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 25)); + break; + case 4: + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 16)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 16)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 34)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 34)); + break; + case 5: + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 16)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 16)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 16)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 34)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 34)); + break; + case 6: + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 16)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 16)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 16)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 34)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 34)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 34)); + break; + case 7: + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 7)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 7)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 7)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 25)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 25)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 25)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 43)); + break; + case 8: + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 7)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 7)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 7)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 25)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 25)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 25)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 43)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 43)); + break; + default: + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 7)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 7)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 7)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 25)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 25)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 25)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 43)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 43)); + addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 43)); + break; + } + + tStartIndex = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).getOutputSlot(); + + switch (((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mOutputItems.length) { + case 0: + break; + case 1: + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 25)); + break; + case 2: + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 25)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 25)); + break; + case 3: + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 25)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 25)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 143, 25)); + break; + case 4: + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 16)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 16)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 34)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 34)); + break; + case 5: + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 16)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 16)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 143, 16)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 34)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 34)); + break; + case 6: + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 16)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 16)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 143, 16)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 34)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 34)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 143, 34)); + break; + case 7: + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 7)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 7)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 143, 7)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 25)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 25)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 143, 25)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 43)); + break; + case 8: + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 7)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 7)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 143, 7)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 25)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 25)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 143, 25)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 43)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 43)); + break; + default: + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 7)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 7)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 143, 7)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 25)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 25)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 143, 25)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 43)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 43)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 143, 43)); + break; + } + + addSlotToContainer(new Slot(mTileEntity, 1, 80, 63)); + addSlotToContainer(new Slot(mTileEntity, 3, 125, 63)); + addSlotToContainer(new GT_Slot_Render(mTileEntity, tStartIndex++, 53, 63)); + } + + @Override + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + switch (aSlotIndex) { + case 0: + if (mTileEntity.getMetaTileEntity() == null) return null; + ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mFluidTransfer = !((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mFluidTransfer; + return null; + case 1: + if (mTileEntity.getMetaTileEntity() == null) return null; + ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mItemTransfer = !((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mItemTransfer; + return null; + default: + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return; + + mFluidTransfer = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mFluidTransfer; + mItemTransfer = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mItemTransfer; + mStuttering = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mStuttering; + + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + var1.sendProgressBarUpdate(this, 102, mFluidTransfer ? 1 : 0); + var1.sendProgressBarUpdate(this, 103, mItemTransfer ? 1 : 0); + var1.sendProgressBarUpdate(this, 104, mStuttering ? 1 : 0); + } + } + + @Override + public void addCraftingToCrafters(ICrafting par1ICrafting) { + super.addCraftingToCrafters(par1ICrafting); + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 102: + mFluidTransfer = (par2 != 0); + break; + case 103: + mItemTransfer = (par2 != 0); + break; + case 104: + mStuttering = (par2 != 0); + break; + } + } + + @Override + public int getSlotStartIndex() { + return 3; + } + + @Override + public int getShiftClickStartIndex() { + return 3; + } + + @Override + public int getSlotCount() { + return getShiftClickSlotCount() + ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mOutputItems.length + 2; + } + + @Override + public int getShiftClickSlotCount() { + return ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mInputSlotCount; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java new file mode 100644 index 0000000000..a9784864ca --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java @@ -0,0 +1,64 @@ +package gtPlusPlus.xmod.gregtech.api.gui.basic; + +import java.util.ArrayList; +import java.util.List; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.entity.player.InventoryPlayer; + +public class GUI_PollutionCleaner extends GT_GUIContainerMetaTile_Machine { + public final String mName; + public final String mNEI; + public final byte mProgressBarDirection; + public final byte mProgressBarAmount; + + public GUI_PollutionCleaner(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, + final String aName, final String aTextureFile) { + this(aInventoryPlayer, aTileEntity, aName, aTextureFile, "PollutionCleaner",(byte) 0, (byte) 1); + } + + public GUI_PollutionCleaner(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, + final String aName, final String aTextureFile, final String aNEI, final byte aProgressBarDirection, + final byte aProgressBarAmount) { + super(new CONTAINER_PollutionCleaner(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "PollutionCleaner.png"); + this.mProgressBarDirection = aProgressBarDirection; + this.mProgressBarAmount = (byte) Math.max(1, aProgressBarAmount); + this.mName = aName; + this.mNEI = aNEI; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString(this.mName, 8, 4, 4210752); + this.drawTooltip(par1, par2); + } + + private void drawTooltip(final int x2, final int y2) { + final int xStart = (this.width - this.xSize) / 2; + final int yStart = (this.height - this.ySize) / 2; + final int x3 = x2 - xStart; + final int y3 = y2 - yStart + 5; + final List<String> list = new ArrayList<String>(); + if (y3 >= 67 && y3 <= 84) { + if (x3 >= 7 && x3 <= 24) { + list.add("Fluid Auto-Output"); + } + if (x3 >= 25 && x3 <= 42) { + list.add("Item Auto-Output"); + } + } + if (!list.isEmpty()) { + this.drawHoveringText(list, x3, y3, this.fontRendererObj); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java index b8f6578448..0d848f5295 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java @@ -14,7 +14,10 @@ import gregtech.api.util.GT_Utility; import gregtech.common.GT_Pollution; import gregtech.common.items.GT_MetaGenerated_Tool_01; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.gui.basic.CONTAINER_PollutionCleaner; +import gtPlusPlus.xmod.gregtech.api.gui.basic.GUI_PollutionCleaner; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -30,7 +33,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi private float mDamageFactorHigh = (float) 0.6000000238418579; public GregtechMetaAtmosphericReconditioner(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 1, "Making sure you don't live in Gwalior", 1, 1, "Recycler.png", "", + super(aID, aName, aNameRegional, aTier, 2, "Making sure you don't live in Gwalior - Uses 2A", 2, 0, "Recycler.png", "", new ITexture[]{ new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_MASSFAB_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_MASSFAB), @@ -44,11 +47,11 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi } public GregtechMetaAtmosphericReconditioner(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { - super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + super(aName, aTier, 2, aDescription, aTextures, 2, 0, aGUIName, aNEIName); } public GregtechMetaAtmosphericReconditioner(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { - super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + super(aName, aTier, 2, aDescription, aTextures, 2, 0, aGUIName, aNEIName); } @Override @@ -115,23 +118,21 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi } //Power Drain - - if (aTick % 1L == 0L){ - long drainEU = V[mTier]; - if (aBaseMetaTileEntity.isActive() && aBaseMetaTileEntity.getStoredEU() >= drainEU){ - if(aBaseMetaTileEntity.decreaseStoredEnergyUnits(drainEU, false)){ - Utils.LOG_INFO("Draining "+drainEU+" EU"); - } + long drainEU = V[mTier]; + if (aBaseMetaTileEntity.isActive() && aBaseMetaTileEntity.getStoredEU() >= drainEU){ + if(aBaseMetaTileEntity.decreaseStoredEnergyUnits(drainEU, false)){ + Utils.LOG_INFO("Draining "+drainEU+" EU"); } - else if (!aBaseMetaTileEntity.isActive() && aBaseMetaTileEntity.getStoredEU() >= drainEU/4){ - if(aBaseMetaTileEntity.decreaseStoredEnergyUnits((drainEU/4), false)){ - //Utils.LOG_INFO("Draining "+(drainEU/4)+" EU"); - } - } - else { - aBaseMetaTileEntity.setActive(false); + } + else if (!aBaseMetaTileEntity.isActive() && aBaseMetaTileEntity.getStoredEU() >= drainEU/4){ + if(aBaseMetaTileEntity.decreaseStoredEnergyUnits((drainEU/4), false)){ + //Utils.LOG_INFO("Draining "+(drainEU/4)+" EU"); } } + else { + aBaseMetaTileEntity.setActive(false); + } + //Only try once/sec. if (aTick % 20L == 0L){ @@ -344,4 +345,24 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi return (after<before); } + + + + + @Override + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_PollutionCleaner(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_PollutionCleaner(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), this.mGUIName); + } + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + //If trying to go to filter slot, return false + return super.canInsertItem(aIndex, aStack, aSide); + } + }
\ No newline at end of file |