diff options
author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2022-01-19 12:58:01 +0000 |
---|---|---|
committer | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2022-01-19 14:33:26 +0000 |
commit | aa0267acca1030b96b95569472ee8663e5cb34b3 (patch) | |
tree | 18e565bcb617648509cefb1eecc1918b9fc1effd /src/main/java/gtPlusPlus/xmod/gregtech/api/gui | |
parent | e5eeec1ffc3eab063c765da7bb889017d87aabdd (diff) | |
download | GT5-Unofficial-aa0267acca1030b96b95569472ee8663e5cb34b3.tar.gz GT5-Unofficial-aa0267acca1030b96b95569472ee8663e5cb34b3.tar.bz2 GT5-Unofficial-aa0267acca1030b96b95569472ee8663e5cb34b3.zip |
Added GT4 Redstone Circuit Block.
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api/gui')
2 files changed, 238 insertions, 0 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_RedstoneCircuitBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_RedstoneCircuitBlock.java new file mode 100644 index 0000000000..acae0d39c5 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_RedstoneCircuitBlock.java @@ -0,0 +1,176 @@ +package gtPlusPlus.xmod.gregtech.api.gui.computer; + +import java.util.Iterator; + +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 gregtech.api.util.GT_Utility; +import gtPlusPlus.xmod.gregtech.common.tileentities.redstone.GT_MetaTileEntity_RedstoneCircuitBlock; +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 net.minecraftforge.oredict.OreDictionary; + +public class GT_Container_RedstoneCircuitBlock extends GT_ContainerMetaTile_Machine { + + public GT_Container_RedstoneCircuitBlock(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 8, 6, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 8, 24, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 8, 42, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 8, 60, false, true, 1)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 152, 6, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 152, 24, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 152, 42, false, true, 1)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 1, 26, 6, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 24, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 3, 26, 42, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 4, 26, 60, false, true, 1)); + } + + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + if (aSlotIndex < 0 || aSlotIndex > 6) + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + + Slot tSlot = (Slot) inventorySlots.get(aSlotIndex); + if (tSlot != null) { + if (mTileEntity.getMetaTileEntity() == null) + return null; + if (aSlotIndex < 4) { + ItemStack tStack = aPlayer.inventory.getItemStack(); + if (tStack == null) { + ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).changeGateData(aSlotIndex, aMouseclick == 0 ? aShifthold == 0 ? +1 : aShifthold == 1 ? +128 : +16 : aShifthold == 0 ? -1 : aShifthold == 1 ? -128 : -16); + } + else { + tStack = GT_Utility.copy(tStack); + if (aMouseclick != 0) + tStack.setItemDamage(OreDictionary.WILDCARD_VALUE); + ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).stackGateData(aSlotIndex, tStack); + } + return null; + } + else if (aSlotIndex == 4) { + ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).switchOutput(); + } + else if (aSlotIndex == 5) { + mTileEntity.setActive(!mTileEntity.isActive()); + } + else if (aSlotIndex == 6) { + if (aMouseclick == 0) + ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).switchGateForward(aShifthold != 0); + else + ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).switchGateBackward(aShifthold != 0); + } + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + public int mData[] = new int[]{0, 0, 0, 0, 0, 0, 0, 0}, mGate = 0; + + @SuppressWarnings("rawtypes") + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) + return; + mGate = ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).mGate; + mData = ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).mGateData; + + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + var1.sendProgressBarUpdate(this, 100, mGate & 65535); + var1.sendProgressBarUpdate(this, 101, mGate >>> 16); + var1.sendProgressBarUpdate(this, 102, mData[0] & 65535); + var1.sendProgressBarUpdate(this, 103, mData[0] >>> 16); + var1.sendProgressBarUpdate(this, 104, mData[1] & 65535); + var1.sendProgressBarUpdate(this, 105, mData[1] >>> 16); + var1.sendProgressBarUpdate(this, 106, mData[2] & 65535); + var1.sendProgressBarUpdate(this, 107, mData[2] >>> 16); + var1.sendProgressBarUpdate(this, 108, mData[3] & 65535); + var1.sendProgressBarUpdate(this, 109, mData[3] >>> 16); + var1.sendProgressBarUpdate(this, 110, mData[4] & 65535); + var1.sendProgressBarUpdate(this, 111, mData[4] >>> 16); + var1.sendProgressBarUpdate(this, 112, mData[5] & 65535); + var1.sendProgressBarUpdate(this, 113, mData[5] >>> 16); + var1.sendProgressBarUpdate(this, 114, mData[6] & 65535); + var1.sendProgressBarUpdate(this, 115, mData[6] >>> 16); + var1.sendProgressBarUpdate(this, 116, mData[7] & 65535); + var1.sendProgressBarUpdate(this, 117, mData[7] >>> 16); + } + } + + public void addCraftingToCrafters(ICrafting par1ICrafting) { + super.addCraftingToCrafters(par1ICrafting); + } + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 100 : + mGate = mGate & -65536 | par2; + break; + case 101 : + mGate = mGate & 65535 | par2 << 16; + break; + case 102 : + mData[0] = mData[0] & -65536 | par2; + break; + case 103 : + mData[0] = mData[0] & 65535 | par2 << 16; + break; + case 104 : + mData[1] = mData[1] & -65536 | par2; + break; + case 105 : + mData[1] = mData[1] & 65535 | par2 << 16; + break; + case 106 : + mData[2] = mData[2] & -65536 | par2; + break; + case 107 : + mData[2] = mData[2] & 65535 | par2 << 16; + break; + case 108 : + mData[3] = mData[3] & -65536 | par2; + break; + case 109 : + mData[3] = mData[3] & 65535 | par2 << 16; + break; + case 110 : + mData[4] = mData[4] & -65536 | par2; + break; + case 111 : + mData[4] = mData[4] & 65535 | par2 << 16; + break; + case 112 : + mData[5] = mData[5] & -65536 | par2; + break; + case 113 : + mData[5] = mData[5] & 65535 | par2 << 16; + break; + case 114 : + mData[6] = mData[6] & -65536 | par2; + break; + case 115 : + mData[6] = mData[6] & 65535 | par2 << 16; + break; + case 116 : + mData[7] = mData[7] & -65536 | par2; + break; + case 117 : + mData[7] = mData[7] & 65535 | par2 << 16; + break; + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_RedstoneCircuitBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_RedstoneCircuitBlock.java new file mode 100644 index 0000000000..89636fbaf2 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_RedstoneCircuitBlock.java @@ -0,0 +1,62 @@ +package gtPlusPlus.xmod.gregtech.api.gui.computer; + +import gregtech.api.GregTech_API; +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_CircuitryBehavior; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.entity.player.InventoryPlayer; + +public class GT_GUIContainer_RedstoneCircuitBlock extends GT_GUIContainerMetaTile_Machine { + + public GT_GUIContainer_RedstoneCircuitBlock(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(new GT_Container_RedstoneCircuitBlock(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "RedstoneCircuitBlock.png"); + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + GT_CircuitryBehavior tCircuit = GregTech_API.sCircuitryBehaviors.get(((GT_Container_RedstoneCircuitBlock) mContainer).mGate); + if (tCircuit != null) { + this.fontRendererObj.drawString(tCircuit.getName(), 46, 8, 16448255); + this.fontRendererObj.drawString(tCircuit.getDescription(), 46, 19, 16448255); + + this.fontRendererObj.drawString(tCircuit.getDataDescription(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 0), 46, 33, 16448255); + this.fontRendererObj.drawString(tCircuit.getDataDescription(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 1), 46, 44, 16448255); + this.fontRendererObj.drawString(tCircuit.getDataDescription(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 2), 46, 55, 16448255); + this.fontRendererObj.drawString(tCircuit.getDataDescription(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 3), 46, 66, 16448255); + + String tString; + tString = tCircuit.getDataDisplay(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 0); + this.fontRendererObj.drawString(tString == null ? GT_Utility.parseNumberToString(((GT_Container_RedstoneCircuitBlock) mContainer).mData[0]) : tString, 99, 33, 16448255); + tString = tCircuit.getDataDisplay(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 1); + this.fontRendererObj.drawString(tString == null ? GT_Utility.parseNumberToString(((GT_Container_RedstoneCircuitBlock) mContainer).mData[1]) : tString, 99, 44, 16448255); + tString = tCircuit.getDataDisplay(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 2); + this.fontRendererObj.drawString(tString == null ? GT_Utility.parseNumberToString(((GT_Container_RedstoneCircuitBlock) mContainer).mData[2]) : tString, 99, 55, 16448255); + tString = tCircuit.getDataDisplay(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 3); + this.fontRendererObj.drawString(tString == null ? GT_Utility.parseNumberToString(((GT_Container_RedstoneCircuitBlock) mContainer).mData[3]) : tString, 99, 66, 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); + + if (mContainer != null) { + if (((GT_Container_RedstoneCircuitBlock) mContainer).mOutput > 0) + drawTexturedModalRect(x + 151, y + 5, 176, 0, 18, 18); + if ((((GT_Container_RedstoneCircuitBlock) mContainer).mActive & 1) > 0) + drawTexturedModalRect(x + 151, y + 23, 176, 18, 18, 18); + if (((GT_Container_RedstoneCircuitBlock) mContainer).mDisplayErrorCode > 0) + if ((((GT_Container_RedstoneCircuitBlock) mContainer).mTileEntity.getTimer() / 5) % 2 == 0) + drawTexturedModalRect(x + 140, y + 9, 194, 0, 7, 7); + else + ; + else + drawTexturedModalRect(x + 140, y + 9, 201, 0, 7, 7); + } + } +} |