From df0c84b6c85c85345eee24d117abb18d0c93afb6 Mon Sep 17 00:00:00 2001 From: Technus Date: Sun, 4 Jun 2017 20:46:32 +0200 Subject: Adding debug power generator --- .../classes/cElementalInstanceStackMap.java | 5 +- .../technus/tectech/loader/MachineLoader.java | 4 +- .../technus/tectech/thing/CustomItemList.java | 2 +- .../multi/GT_MetaTileEntity_MultiblockBase_EM.java | 6 +- .../tectech/thing/metaTileEntity/multi/other todo | 1 + .../GT_MetaTileEntity_DebugPowerGenerator.java | 205 +++++++++++++++++++++ .../GT_MetaTileEntity_DebugStructureWriter.java | 4 +- .../gui/GT_Container_DebugPowerGenerator.java | 153 +++++++++++++++ .../gui/GT_GUIContainer_DebugPowerGenerator.java | 33 ++++ 9 files changed, 404 insertions(+), 9 deletions(-) create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPowerGenerator.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_Container_DebugPowerGenerator.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DebugPowerGenerator.java (limited to 'src/main/java/com') diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalInstanceStackMap.java b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalInstanceStackMap.java index 6e1a0b8386..1d999b94b0 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalInstanceStackMap.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalInstanceStackMap.java @@ -268,13 +268,14 @@ public final class cElementalInstanceStackMap implements Comparable=0; + getBaseMetaTileEntity().setActive(producing); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + aBaseMetaTileEntity.setActive(producing); + if (aBaseMetaTileEntity.isActive()) { + setEUVar(maxEUStore()); + } else { + setEUVar(0); + } + } + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public String[] getDescription() { + return new String[]{ + CommonValues.tecMark, + this.mDescription, + EnumChatFormatting.BLUE + "Infinite Producer/Consumer", + EnumChatFormatting.BLUE + "Since i wanted one..." + }; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isInputFacing(byte aSide) { + return !producing && aSide != getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isOutputFacing(byte aSide) { + return producing && aSide != getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public long maxAmperesIn() { + return producing?0:Math.abs(AMP); + } + + @Override + public long maxAmperesOut() { + return producing?Math.abs(AMP):0; + } + + @Override + public long maxEUInput() { + return producing?0:Integer.MAX_VALUE; + } + + @Override + public long maxEUOutput() { + return producing?Math.abs(EUT):0; + } + + @Override + public long maxEUStore() { + return Math.abs((long)EUT*AMP)<<2; + } + + @Override + public long getMinimumStoredEU() { + return Math.abs((long)EUT*AMP); + } + + @Override + public int getProgresstime() { + return (int) getBaseMetaTileEntity().getUniversalEnergyStored(); + } + + @Override + public int maxProgresstime() { + return (int) getBaseMetaTileEntity().getUniversalEnergyCapacity(); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java index 9da90a7cc1..9ae3a6dfca 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java @@ -121,8 +121,8 @@ public class GT_MetaTileEntity_DebugStructureWriter extends GT_MetaTileEntity_Ti public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { if (aBaseMetaTileEntity.isClientSide()) return true; aBaseMetaTileEntity.openGUI(aPlayer); - if (TecTechConfig.DEBUG_MODE && aPlayer.getHeldItem() != null) - TecTech.Logger.info("UnlocalizedName: " + getUniqueIdentifier(aPlayer.getHeldItem())); + //if (TecTechConfig.DEBUG_MODE && aPlayer.getHeldItem() != null) + // TecTech.Logger.info("UnlocalizedName: " + getUniqueIdentifier(aPlayer.getHeldItem())); return true; } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_Container_DebugPowerGenerator.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_Container_DebugPowerGenerator.java new file mode 100644 index 0000000000..420ac76e8a --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_Container_DebugPowerGenerator.java @@ -0,0 +1,153 @@ +package com.github.technus.tectech.thing.metaTileEntity.single.gui; + +import com.github.technus.tectech.thing.metaTileEntity.single.GT_MetaTileEntity_DebugPowerGenerator; +import com.github.technus.tectech.thing.metaTileEntity.single.GT_MetaTileEntity_DebugStructureWriter; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.gui.GT_Slot_Holo; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +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; + +import java.util.Iterator; + +public class GT_Container_DebugPowerGenerator + extends GT_ContainerMetaTile_Machine { + public int EUT,AMP; + + public GT_Container_DebugPowerGenerator(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 59, false, false, 1)); + + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 59, false, false, 1)); + + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 59, false, false, 1)); + + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 59, false, false, 1)); + } + + @Override + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + if (aSlotIndex < 0) { + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); + if ((tSlot != null) && (this.mTileEntity.getMetaTileEntity() != null)) { + GT_MetaTileEntity_DebugPowerGenerator dpg = (GT_MetaTileEntity_DebugPowerGenerator) mTileEntity.getMetaTileEntity(); + switch (aSlotIndex) { + case 0: + dpg.EUT -= (aShifthold == 1 ? 512 : 64); + break; + case 1: + dpg.EUT /= (aShifthold == 1 ? 512 : 64); + break; + case 2: + dpg.AMP -= (aShifthold == 1 ? 512 : 64); + break; + case 3: + dpg.AMP /= (aShifthold == 1 ? 512 : 64); + break; + case 4: + dpg.EUT -= (aShifthold == 1 ? 16 : 1); + break; + case 5: + dpg.EUT /= (aShifthold == 1 ? 16 : 2); + break; + case 6: + dpg.AMP -= (aShifthold == 1 ? 16 : 1); + break; + case 7: + dpg.AMP /= (aShifthold == 1 ? 16 : 2); + break; + case 8: + dpg.EUT += (aShifthold == 1 ? 512 : 64); + break; + case 9: + dpg.EUT *= (aShifthold == 1 ? 512 : 64); + break; + case 10: + dpg.AMP += (aShifthold == 1 ? 512 : 64); + break; + case 11: + dpg.AMP *= (aShifthold == 1 ? 512 : 64); + break; + case 12: + dpg.EUT += (aShifthold == 1 ? 16 : 1); + break; + case 13: + dpg.EUT *= (aShifthold == 1 ? 16 : 2); + break; + case 14: + dpg.AMP += (aShifthold == 1 ? 16 : 1); + break; + case 15: + dpg.AMP *= (aShifthold == 1 ? 16 : 2); + break; + default: return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + dpg.producing=(long)AMP*EUT>=0; + return null; + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { + return; + } + + GT_MetaTileEntity_DebugPowerGenerator dpg = (GT_MetaTileEntity_DebugPowerGenerator) mTileEntity.getMetaTileEntity(); + EUT=dpg.EUT; + AMP=dpg.AMP; + + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + var1.sendProgressBarUpdate(this, 100, EUT & 0xFFFF); + var1.sendProgressBarUpdate(this, 101, EUT >>> 16); + var1.sendProgressBarUpdate(this, 102, AMP & 0xFFFF); + var1.sendProgressBarUpdate(this, 103, AMP >>> 16); + } + } + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 100: + this.EUT = (this.EUT & 0xFFFF0000 | par2); + break; + case 101: + this.EUT = (this.EUT & 0xFFFF | par2 << 16); + break; + case 102: + this.AMP = (this.AMP & 0xFFFF0000 | par2); + break; + case 103: + this.AMP = (this.AMP & 0xFFFF | par2 << 16); + break; + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DebugPowerGenerator.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DebugPowerGenerator.java new file mode 100644 index 0000000000..88ff02b8ba --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DebugPowerGenerator.java @@ -0,0 +1,33 @@ +package com.github.technus.tectech.thing.metaTileEntity.single.gui; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Utility; +import net.minecraft.entity.player.InventoryPlayer; + +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; +import static gregtech.api.enums.GT_Values.VN; + +public class GT_GUIContainer_DebugPowerGenerator extends GT_GUIContainerMetaTile_Machine { + public GT_GUIContainer_DebugPowerGenerator(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(new GT_Container_DebugPowerGenerator(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "Teleporter.png"); + } + + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + this.fontRendererObj.drawString("PowerThing", 46, 8, 16448255); + if (this.mContainer != null) { + GT_Container_DebugPowerGenerator dpg = (GT_Container_DebugPowerGenerator) mContainer; + this.fontRendererObj.drawString("EUT: " + dpg.EUT, 46, 24, 16448255); + this.fontRendererObj.drawString("TIER: " + VN[GT_Utility.getTier(dpg.EUT<0?-dpg.EUT:dpg.EUT)], 46, 32, 16448255); + this.fontRendererObj.drawString("AMP: " + dpg.AMP, 46, 40, 16448255); + this.fontRendererObj.drawString("SUM: " + (long)dpg.AMP*dpg.EUT, 46, 32, 16448255); + } + } + + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (this.width - this.xSize) / 2; + int y = (this.height - this.ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +} -- cgit