diff options
Diffstat (limited to 'src/Java/gtPlusPlus')
4 files changed, 344 insertions, 36 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MetaTileMachineLong.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MetaTileMachineLong.java new file mode 100644 index 0000000000..6a3322ab2e --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MetaTileMachineLong.java @@ -0,0 +1,244 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import gregtech.api.gui.GT_Container; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_LanguageManager; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; + +import java.util.Iterator; + +public class CONTAINER_MetaTileMachineLong extends GT_Container { + + public int mActive = 0, mMaxProgressTime = 0, mProgressTime = 0, mSteam = 0, mSteamStorage = 0, mOutput = 0, mInput = 0, mID = 0, mDisplayErrorCode = 0; + private int oActive = 0, oMaxProgressTime = 0, oProgressTime = 0, oSteam = 0, oSteamStorage = 0, oOutput = 0, oInput = 0, oID = 0, oDisplayErrorCode = 0, mTimer = 0; + + public long pEnergy, pStorage; + private long nEnergy, nStorage; + + public short pIntMaxCountCurrent, pIntMaxCountMax; + private short nIntMaxCountCurrent, nIntMaxCountMax; + + public CONTAINER_MetaTileMachineLong(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + + mTileEntity = aTileEntity; + + if (mTileEntity != null && mTileEntity.getMetaTileEntity() != null) { + addSlots(aInventoryPlayer); + if (doesBindPlayerInventory()) bindPlayerInventory(aInventoryPlayer); + detectAndSendChanges(); + } else { + aInventoryPlayer.player.openContainer = aInventoryPlayer.player.inventoryContainer; + } + } + public CONTAINER_MetaTileMachineLong(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, boolean doesBindInventory) { + super(aInventoryPlayer, aTileEntity); + mTileEntity = aTileEntity; + + if (mTileEntity != null && mTileEntity.getMetaTileEntity() != null) { + addSlots(aInventoryPlayer); + if (doesBindPlayerInventory() && doesBindInventory) bindPlayerInventory(aInventoryPlayer); + detectAndSendChanges(); + } else { + aInventoryPlayer.player.openContainer = aInventoryPlayer.player.inventoryContainer; + } + } + + private Pair<Integer, Integer> getPowerStored(){ + final long mStoredPower = this.pEnergy; + long mMaxInts = (mStoredPower/Integer.MAX_VALUE); + long mLeftOver = (mStoredPower % Integer.MAX_VALUE); + if (mMaxInts < 0 || mMaxInts >= /*4294967298L*/ Integer.MAX_VALUE) { + return new Pair<Integer, Integer>(-1, 0); + } + if (mLeftOver < 0 || mLeftOver > Integer.MAX_VALUE) { + mLeftOver = 0; + } + Pair<Integer, Integer> power = new Pair<Integer, Integer>((int) mMaxInts, (int) mLeftOver); + return power; + } + + private Pair<Integer, Integer> getMaxPowerStored(){ + final long mMaxStoredPower = this.pStorage; + long mMaxInts = (mMaxStoredPower/Integer.MAX_VALUE); + long mLeftOver = (mMaxStoredPower % Integer.MAX_VALUE); + if (mMaxInts < 0 || mMaxInts >= /*4294967298L*/ Integer.MAX_VALUE) { + return new Pair<Integer, Integer>(-1, 0); + } + if (mLeftOver < 0 || mLeftOver > Integer.MAX_VALUE) { + mLeftOver = 0; + } + Pair<Integer, Integer> power = new Pair<Integer, Integer>((int) mMaxInts, (int) mLeftOver); + return power; + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return; + pStorage = Math.min(Long.MAX_VALUE, mTileEntity.getEUCapacity()); + pEnergy = Math.min(Long.MAX_VALUE, mTileEntity.getStoredEU()); + mSteamStorage = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getSteamCapacity()); + mSteam = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getStoredSteam()); + mOutput = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getOutputVoltage()); + mInput = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getInputVoltage()); + mDisplayErrorCode = mTileEntity.getErrorDisplayID(); + mProgressTime = mTileEntity.getProgress(); + mMaxProgressTime = mTileEntity.getMaxProgress(); + mActive = mTileEntity.isActive() ? 1 : 0; + mTimer++; + + Pair<Integer, Integer> powerPacket = getPowerStored(); + Pair<Integer, Integer> maxPowerPacket = getMaxPowerStored(); + + int mPacketsToSend = powerPacket.getKey(); + int mLeftOverPowerStored = powerPacket.getValue(); + + int mMaxStorageA = maxPowerPacket.getKey(); + int mMaxStorageB = maxPowerPacket.getValue(); + + //Someone has a VERY FULL power supply. + if (mPacketsToSend == -1) { + Logger.INFO("TOO MUCH MATH - USE BIGINTEGER - GAME BREAKING BUG MAY OCCUR"); + return; + } + + + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + if (mTimer % 500 == 10 || nEnergy != pEnergy) { + var1.sendProgressBarUpdate(this, 0, mLeftOverPowerStored & 65535); + var1.sendProgressBarUpdate(this, 1, mLeftOverPowerStored >>> 16); + var1.sendProgressBarUpdate(this, 7730, mPacketsToSend); + } + if (mTimer % 500 == 10 || nStorage != pStorage) { + var1.sendProgressBarUpdate(this, 2, mMaxStorageB & 65535); + var1.sendProgressBarUpdate(this, 3, mMaxStorageB >>> 16); + var1.sendProgressBarUpdate(this, 7731, mMaxStorageA); + } + if (mTimer % 500 == 10 || oOutput != mOutput) { + var1.sendProgressBarUpdate(this, 4, mOutput); + } + if (mTimer % 500 == 10 || oInput != mInput) { + var1.sendProgressBarUpdate(this, 5, mInput); + } + if (mTimer % 500 == 10 || oDisplayErrorCode != mDisplayErrorCode) { + var1.sendProgressBarUpdate(this, 6, mDisplayErrorCode); + } + if (mTimer % 500 == 10 || oProgressTime != mProgressTime) { + var1.sendProgressBarUpdate(this, 11, mProgressTime & 65535); + var1.sendProgressBarUpdate(this, 12, mProgressTime >>> 16); + } + if (mTimer % 500 == 10 || oMaxProgressTime != mMaxProgressTime) { + var1.sendProgressBarUpdate(this, 13, mMaxProgressTime & 65535); + var1.sendProgressBarUpdate(this, 14, mMaxProgressTime >>> 16); + } + if (mTimer % 500 == 10 || oID != mID) { + var1.sendProgressBarUpdate(this, 15, mID); + } + if (mTimer % 500 == 10 || oActive != mActive) { + var1.sendProgressBarUpdate(this, 16, mActive); + } + if (mTimer % 500 == 10 || oSteam != mSteam) { + var1.sendProgressBarUpdate(this, 17, mSteam & 65535); + var1.sendProgressBarUpdate(this, 18, mSteam >>> 16); + } + if (mTimer % 500 == 10 || oSteamStorage != mSteamStorage) { + var1.sendProgressBarUpdate(this, 19, mSteamStorage & 65535); + var1.sendProgressBarUpdate(this, 20, mSteamStorage >>> 16); + } + } + + oID = mID; + oSteam = mSteam; + oInput = mInput; + oActive = mActive; + oOutput = mOutput; + nEnergy = pEnergy; + nStorage = pStorage; + oSteamStorage = mSteamStorage; + oProgressTime = mProgressTime; + oMaxProgressTime = mMaxProgressTime; + oDisplayErrorCode = mDisplayErrorCode; + } + + @SideOnly(Side.CLIENT) + @Override + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + /*case 7730: + pIntMaxCountCurrent = par2;*/ + case 0: + pEnergy = pEnergy & -65536 | par2; + break; + case 1: + pEnergy = pEnergy & 65535 | par2 << 16; + break; + case 2: + pStorage = pStorage & -65536 | par2; + break; + case 3: + pStorage = pStorage & 65535 | par2 << 16; + break; + case 4: + mOutput = par2; + break; + case 5: + mInput = par2; + break; + case 6: + mDisplayErrorCode = par2; + break; + case 11: + mProgressTime = mProgressTime & -65536 | par2; + break; + case 12: + mProgressTime = mProgressTime & 65535 | par2 << 16; + break; + case 13: + mMaxProgressTime = mMaxProgressTime & -65536 | par2; + break; + case 14: + mMaxProgressTime = mMaxProgressTime & 65535 | par2 << 16; + break; + case 15: + mID = par2; + break; + case 16: + mActive = par2; + break; + case 17: + mSteam = mSteam & -65536 | par2; + break; + case 18: + mSteam = mSteam & 65535 | par2 << 16; + break; + case 19: + mSteamStorage = mSteamStorage & -65536 | par2; + break; + case 20: + mSteamStorage = mSteamStorage & 65535 | par2 << 16; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return mTileEntity.isUseableByPlayer(player); + } + + public String trans(String aKey, String aEnglish){ + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_"+aKey, aEnglish, false); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_PowerSubStation.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_PowerSubStation.java index feef884867..bc7625805f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_PowerSubStation.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_PowerSubStation.java @@ -11,6 +11,7 @@ import gtPlusPlus.core.slots.SlotNoInput; import net.minecraft.entity.player.InventoryPlayer; public class CONTAINER_PowerSubStation extends GT_Container_MultiMachine { + public CONTAINER_PowerSubStation(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { super(aInventoryPlayer, aTileEntity); } @@ -23,6 +24,11 @@ public class CONTAINER_PowerSubStation extends GT_Container_MultiMachine { public void addSlots(final InventoryPlayer aInventoryPlayer) { this.addSlotToContainer(new Slot((IInventory) this.mTileEntity, 1, 155, 5)); this.addSlotToContainer(new SlotNoInput((IInventory) this.mTileEntity, 2, 155, 23)); + + for (int i = 0; i < 9; ++i) { + this.addSlotToContainer(new Slot((IInventory) aInventoryPlayer, i, 8 + i * 18, 167)); + } + } public int getSlotCount() { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_PowerSubStation.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_PowerSubStation.java index c69391025c..65ba8610dd 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_PowerSubStation.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_PowerSubStation.java @@ -4,28 +4,44 @@ import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.ItemUtils; - import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GT_MetaGenerated_Tool; + import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; +import gregtech.api.enums.Textures; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; public class GUI_PowerSubStation extends GT_GUIContainerMetaTile_Machine { public String mNEI; String mName; + boolean[] mRepairStatus = new boolean[6]; + private static IIcon[] mGregToolIcons = new IIcon[6]; public GUI_PowerSubStation(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aNEI) { - super(new CONTAINER_PowerSubStation(aInventoryPlayer, aTileEntity, false), - CORE.RES_PATH_GUI + "PowerSubStation.png"); + super(new CONTAINER_PowerSubStation(aInventoryPlayer, aTileEntity, false), CORE.RES_PATH_GUI + "PowerSubStation.png"); this.mName = aName; this.mNEI = aNEI; /** The X size of the inventory window in pixels. */ this.xSize = 196; /** The Y size of the inventory window in pixels. */ - this.ySize = 191; + this.ySize = 191; + for (IIcon g : mGregToolIcons) { + if (g == null) { + getToolTextures(); + } + } + } + + private static final boolean getToolTextures() { + mGregToolIcons[0] = Textures.ItemIcons.WRENCH.getIcon(); + mGregToolIcons[1] = Textures.ItemIcons.HANDLE_SCREWDRIVER.getIcon(); + mGregToolIcons[2] = Textures.ItemIcons.MORTAR.getIcon(); + mGregToolIcons[3] = Textures.ItemIcons.JACKHAMMER.getIcon(); + mGregToolIcons[4] = Textures.ItemIcons.HANDLE_SOLDERING.getIcon(); + mGregToolIcons[5] = Textures.ItemIcons.CROWBAR.getIcon(); + return true; } protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { @@ -34,24 +50,51 @@ public class GUI_PowerSubStation extends GT_GUIContainerMetaTile_Machine { this.fontRendererObj.drawString("Error Code: "+((CONTAINER_PowerSubStation) this.mContainer).mDisplayErrorCode, 10, 142, 16448255); + this.fontRendererObj.drawString("In", 178, 10, 16448255); + this.fontRendererObj.drawString("Out", 176, 28, 16448255); + if (((this.mContainer).mDisplayErrorCode & 1) != 0) { this.fontRendererObj.drawString("Pipe is loose.", 10, 8, 16448255); + mRepairStatus[0] = false; } + else { + mRepairStatus[0] = true; + } if ((((CONTAINER_PowerSubStation) this.mContainer).mDisplayErrorCode & 2) != 0) { this.fontRendererObj.drawString("Screws are missing.", 10, 16, 16448255); + mRepairStatus[1] = false; } + else { + mRepairStatus[1] = true; + } if ((((CONTAINER_PowerSubStation) this.mContainer).mDisplayErrorCode & 4) != 0) { this.fontRendererObj.drawString("Something is stuck.", 10, 24, 16448255); + mRepairStatus[2] = false; } + else { + mRepairStatus[2] = true; + } if ((((CONTAINER_PowerSubStation) this.mContainer).mDisplayErrorCode & 8) != 0) { this.fontRendererObj.drawString("Platings are dented.", 10, 32, 16448255); + mRepairStatus[3] = false; } + else { + mRepairStatus[3] = true; + } if ((((CONTAINER_PowerSubStation) this.mContainer).mDisplayErrorCode & 16) != 0) { this.fontRendererObj.drawString("Circuitry burned out.", 10, 40, 16448255); + mRepairStatus[4] = false; } + else { + mRepairStatus[4] = true; + } if ((((CONTAINER_PowerSubStation) this.mContainer).mDisplayErrorCode & 32) != 0) { this.fontRendererObj.drawString("That doesn't belong there.", 10, 48, 16448255); - } + mRepairStatus[5] = false; + } + else { + mRepairStatus[5] = true; + } if (((CONTAINER_PowerSubStation) this.mContainer).mDisplayErrorCode == 0) { if (((CONTAINER_PowerSubStation) this.mContainer).mActive == 0) { this.fontRendererObj.drawString( @@ -67,14 +110,10 @@ public class GUI_PowerSubStation extends GT_GUIContainerMetaTile_Machine { } else if (this.mContainer.mEnergy > 640000000 && this.mContainer.mEnergy < 640010000) { this.fontRendererObj.drawString("640,000,000 EU", 50, 155, 16711680); } else { - this.fontRendererObj.drawString(GT_Utility.formatNumbers((long) this.mContainer.mEnergy) + " EU", 50, - 155, 16711680); + this.fontRendererObj.drawString(GT_Utility.formatNumbers((long) this.mContainer.mEnergy) + " EU", + 50, 155, 16711680); } } - else { - Logger.INFO("Bad Container"); - this.fontRendererObj.drawString("Bad Container", 8, 30, 16448255); - } } protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { @@ -92,27 +131,44 @@ public class GUI_PowerSubStation extends GT_GUIContainerMetaTile_Machine { final double tScale = this.mContainer.mEnergy / this.mContainer.mStorage; this.drawTexturedModalRect(x + 5, y + 156, 0, 251, Math.min(147, (int) (tScale * 148.0)), 5); - IIcon texture = null; - ItemStack tempStack = null; + //A1 + this.drawTexturedModalRect(x + 154, y + 76, 238, (!mRepairStatus[0] ? 0 : 18), 18, 18); + //A2 + this.drawTexturedModalRect(x + 154 + 20, y + 76, 238, (!mRepairStatus[1] ? 0 : 18), 18, 18); + //B1 + this.drawTexturedModalRect(x + 154, y + 76 + 18, 238, (!mRepairStatus[2] ? 0 : 18), 18, 18); + //B2 + this.drawTexturedModalRect(x + 154 + 20, y + 76 + 18, 238, (!mRepairStatus[3] ? 0 : 18), 18, 18); + //C1 + this.drawTexturedModalRect(x + 154, y + 76 + 36, 238, (!mRepairStatus[4] ? 0 : 18), 18, 18); + //C2 + this.drawTexturedModalRect(x + 154 + 20, y + 76 + 36, 238, (!mRepairStatus[5] ? 0 : 18), 18, 18); - tempStack = ItemUtils.getItemStackOfAmountFromOreDict("toolWrench", 1); - if (tempStack != null) { - texture = tempStack.getItem().getIcon(tempStack, 0); - if (texture != null) { - this.drawTexturedModelRectFromIcon(x + 154, y + 76, texture, 9, 9); - texture = tempStack.getItem().getIcon(tempStack, 1); - this.drawTexturedModelRectFromIcon(x + 154, y + 76, texture, 9, 9); - } - else { - this.drawTexturedModalRect(x + 154, y + 76, 0, 251, 18, 5); - } + + if (mGregToolIcons[0] != null) { + //this.drawTexturedModelRectFromIcon(x + 154, y + 76, mGregToolIcons[0], 18, 18); } - - //Maint Done - //this.drawTexturedModalRect(x + 154, y + 76, 238, 0, 18, 18); + if (mGregToolIcons[1] != null) { + //this.drawTexturedModelRectFromIcon(x + 154 + 20, y + 76, mGregToolIcons[1], 18, 18); + } + if (mGregToolIcons[2] != null) { + //this.drawTexturedModelRectFromIcon(x + 154, y + 76 + 18, mGregToolIcons[2], 9, 9); + } + if (mGregToolIcons[3] != null) { + //this.drawTexturedModelRectFromIcon(x + 154 + 20, y + 76 + 18, mGregToolIcons[3], 9, 9); + } + if (mGregToolIcons[4] != null) { + //this.drawTexturedModelRectFromIcon(x + 154, y + 76 + 36, mGregToolIcons[4], 9, 9); + } + if (mGregToolIcons[5] != null) { + //this.drawTexturedModelRectFromIcon(x + 154 + 20, y + 76 + 36, mGregToolIcons[5], 9, 9); + } + + /*//Maint Done + this.drawTexturedModalRect(x + 154, y + 76, 238, 0, 18, 18); //Maint Required - //this.drawTexturedModalRect(x + 154, y + 76, 238, 18, 18, 18); + this.drawTexturedModalRect(x + 154 + 20, y + 76, 238, 18, 18, 18);*/ } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java index f8b42bc629..d77edb631b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java @@ -480,24 +480,26 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe } else { storedEnergyText = EnumChatFormatting.GREEN + GT_Utility.formatNumbers(this.getEUVar()) + EnumChatFormatting.RESET; } + + int errorCode = this.getBaseMetaTileEntity().getErrorDisplayID(); + boolean mMaint = (errorCode != 0); return new String[]{ "Ergon Energy - District Sub-Station", - "Stored EU:" + storedEnergyText, + "Stored EU: " + storedEnergyText, "Capacity: " + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(this.maxEUStore()) + EnumChatFormatting.RESET, "Running Costs: " + EnumChatFormatting.RED + GT_Utility.formatNumbers(this.computeEnergyTax()) + EnumChatFormatting.RESET + " EU/t", "Controller Mode: " + mode, + "Requires Maintenance: " + (!mMaint ? EnumChatFormatting.GREEN : EnumChatFormatting.RED)+ mMaint + EnumChatFormatting.RESET +" | Code: ["+(!mMaint ? EnumChatFormatting.GREEN : EnumChatFormatting.RED) + errorCode + EnumChatFormatting.RESET +"]", + "----------------------", "Stats for Nerds", "Total Input: " + EnumChatFormatting.BLUE + GT_Utility.formatNumbers(this.mTotalEnergyAdded) + EnumChatFormatting.RESET + " EU", "Total Output: " + EnumChatFormatting.GOLD + GT_Utility.formatNumbers(this.mTotalEnergyConsumed) + EnumChatFormatting.RESET + " EU", "Total Costs: " + EnumChatFormatting.RED + GT_Utility.formatNumbers(this.mTotalEnergyLost) + EnumChatFormatting.RESET + " EU", "Total Time Since Built: ", - ""+weeks+" Weeks.", - ""+days+" Days.", - ""+hours+" Hours.", - ""+minutes+" Minutes.", - ""+second+" Seconds.", + ""+weeks+" Weeks, "+days+" Days,", + ""+hours+" Hours, "+minutes+" Minutes, "+second+" Seconds.", "Total Time in ticks: "+this.mTotalRunTime }; |