From c7536873578a600131e5ca647fac664594efbfd3 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Sun, 9 Jan 2022 02:29:10 +0000 Subject: Ported some GT4 content: Added GT Crop Managers. Added GT Auto Crafting Tables. Added GT Inventory Managers. --- .../GT_Container_ElectricAutoWorkbench.java | 141 +++++++++++ .../GT_Container_ElectricInventoryManager.java | 267 +++++++++++++++++++++ .../GT_GUIContainer_ElectricAutoWorkbench.java | 59 +++++ .../GT_GUIContainer_ElectricInventoryManager.java | 58 +++++ 4 files changed, 525 insertions(+) create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_Container_ElectricAutoWorkbench.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_Container_ElectricInventoryManager.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricAutoWorkbench.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricInventoryManager.java (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation') diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_Container_ElectricAutoWorkbench.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_Container_ElectricAutoWorkbench.java new file mode 100644 index 0000000000..1af597c05a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_Container_ElectricAutoWorkbench.java @@ -0,0 +1,141 @@ +package gtPlusPlus.xmod.gregtech.api.gui.automation; + +import com.google.gson.JsonObject; + +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.gui.GT_Slot_Output; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_ElectricAutoWorkbench; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_CropHarvestor; +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; + +public class GT_Container_ElectricAutoWorkbench extends GT_ContainerMetaTile_Machine { + + public int mMode; + public int mThroughPut; + + public GT_Container_ElectricAutoWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new Slot(mTileEntity, 0, 8, 5)); + addSlotToContainer(new Slot(mTileEntity, 1, 26, 5)); + addSlotToContainer(new Slot(mTileEntity, 2, 44, 5)); + addSlotToContainer(new Slot(mTileEntity, 3, 8, 23)); + addSlotToContainer(new Slot(mTileEntity, 4, 26, 23)); + addSlotToContainer(new Slot(mTileEntity, 5, 44, 23)); + addSlotToContainer(new Slot(mTileEntity, 6, 8, 41)); + addSlotToContainer(new Slot(mTileEntity, 7, 26, 41)); + addSlotToContainer(new Slot(mTileEntity, 8, 44, 41)); + + addSlotToContainer(new GT_Slot_Output(mTileEntity, 9, 8, 60)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 10, 26, 60)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 11, 44, 60)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 12, 62, 60)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 13, 80, 60)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 14, 98, 60)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 15, 116, 60)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 16, 134, 60)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 17, 152, 60)); + + addSlotToContainer(new GT_Slot_Output(mTileEntity, 18, 152, 41)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 19, 64, 6, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 20, 81, 6, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 21, 98, 6, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 22, 64, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 23, 81, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 24, 98, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 25, 64, 40, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 26, 81, 40, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 27, 98, 40, false, false, 1)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 28, 152, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 29, 121, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 29, 121, 5, false, false, 1)); + } + + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + if (aSlotIndex < 18) return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + + Slot tSlot = (Slot)inventorySlots.get(aSlotIndex); + if (tSlot != null) { + if (mTileEntity.getMetaTileEntity() == null) return null; + if (aSlotIndex > 18 && aSlotIndex < 28) { + ItemStack tStack = aPlayer.inventory.getItemStack(); + if (tStack != null) { + tStack = GT_Utility.copy(1, tStack); + } + tSlot.putStack(tStack); + return null; + } + if (aSlotIndex == 28) return null; + if (aSlotIndex == 29) { + if (aMouseclick == 0) { + ((GT_MetaTileEntity_ElectricAutoWorkbench)mTileEntity.getMetaTileEntity()).switchModeForward(); + } else { + ((GT_MetaTileEntity_ElectricAutoWorkbench)mTileEntity.getMetaTileEntity()).switchModeBackward(); + } + return null; + } + if (aSlotIndex == 30) { + ((GT_MetaTileEntity_ElectricAutoWorkbench)mTileEntity.getMetaTileEntity()).switchThrough(); + return null; + } + } + + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + public int getSlotCount() { + return 19; + } + + public int getShiftClickSlotCount() { + return 9; + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { + return; + } + mMode = ((GT_MetaTileEntity_ElectricAutoWorkbench) mTileEntity.getMetaTileEntity()).mMode; + mThroughPut = ((GT_MetaTileEntity_ElectricAutoWorkbench) mTileEntity.getMetaTileEntity()).mThroughPut; + for (Object crafter : this.crafters) { + ICrafting var1 = (ICrafting) crafter; + var1.sendProgressBarUpdate(this, 103, this.mMode); + var1.sendProgressBarUpdate(this, 104, this.mThroughPut); + } + } + + @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 103: + this.mMode = par2; + break; + case 104: + this.mThroughPut = par2; + break; + } + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_Container_ElectricInventoryManager.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_Container_ElectricInventoryManager.java new file mode 100644 index 0000000000..3e8f509dfd --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_Container_ElectricInventoryManager.java @@ -0,0 +1,267 @@ +package gtPlusPlus.xmod.gregtech.api.gui.automation; + +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.automation.GT_MetaTileEntity_ElectricInventoryManager; +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_ElectricInventoryManager extends GT_ContainerMetaTile_Machine { + + public int[] mTargetDirections = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + public int[] mRangeDirections = new int[]{0, 0, 0, 0}; + public int mTargetInOut; + public int mTargetEnergy; + + public GT_Container_ElectricInventoryManager(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new Slot(mTileEntity, 0, 155, 5)); + addSlotToContainer(new Slot(mTileEntity, 1, 155, 23)); + addSlotToContainer(new Slot(mTileEntity, 2, 155, 41)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 3, 5, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 4, 5, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 5, 5, 41, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 6, 61, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 7, 61, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 8, 61, 41, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 9, 80, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 10, 80, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 11, 80, 41, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 12, 136, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 13, 136, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 14, 136, 41, false, true, 1)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 24, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 24, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 24, 41, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 42, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 42, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 42, 41, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 99, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 99, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 99, 41, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 117, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 117, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 117, 41, false, true, 1)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 24, 60, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 42, 60, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 99, 60, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 117, 60, false, true, 1)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 5, 60, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 61, 60, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 80, 60, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 136, 60, false, true, 1)); + } + + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + if (aSlotIndex < 3 || aSlotIndex >= getAllSlotCount()) + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + Slot tSlot = (Slot) inventorySlots.get(aSlotIndex); + if (tSlot != null) { + if (mTileEntity.getMetaTileEntity() == null) + return null; + if (aSlotIndex < 15) { + ItemStack tStack = aPlayer.inventory.getItemStack(); + if (tStack != null) { + tStack = GT_Utility.copy(tStack); + if (aMouseclick != 0) { + tStack.setItemDamage(OreDictionary.WILDCARD_VALUE); + } + tSlot.putStack(tStack); + } + else { + if (tSlot.getStack() != null) { + if (aMouseclick == 0) { + tSlot.getStack().stackSize -= (aShifthold == 1 ? 8 : 1); + if (tSlot.getStack().stackSize <= 0) { + tSlot.putStack(null); + } + } + else { + tSlot.getStack().stackSize += (aShifthold == 1 ? 8 : 1); + if (tSlot.getStack().stackSize > tSlot.getStack().getMaxStackSize()) { + tSlot.getStack().stackSize = tSlot.getStack().getMaxStackSize(); + } + } + } + } + return null; + } + else if (aSlotIndex >= 27 && aSlotIndex <= 30) { + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).iterateRangeDirection(aSlotIndex - 27); + } + else if (aSlotIndex >= 31 && aSlotIndex <= 34) { + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).switchRangeEnergy(aSlotIndex - 31); + } + else if (aSlotIndex % 3 == 0) { + if (aMouseclick != 0) + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).switchSlot1InOut((aSlotIndex - 15) / 3); + else + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).iterateSlot1Direction((aSlotIndex - 15) / 3); + } + else if (aSlotIndex % 3 == 1) { + if (aMouseclick != 0) + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).switchSlot2InOut((aSlotIndex - 16) / 3); + else + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).iterateSlot2Direction((aSlotIndex - 16) / 3); + } + else if (aSlotIndex % 3 == 2) { + if (aMouseclick != 0) + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).switchSlot3InOut((aSlotIndex - 17) / 3); + else + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).iterateSlot3Direction((aSlotIndex - 17) / 3); + } + } + return null; + } + + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { + return; + } + mTargetDirections = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + mRangeDirections = new int[]{0, 0, 0, 0}; + + mRangeDirections[0] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeDirection(0); + mRangeDirections[1] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeDirection(1); + mRangeDirections[2] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeDirection(2); + mRangeDirections[3] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeDirection(3); + + mTargetDirections[0] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1Direction(0); + mTargetDirections[1] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2Direction(0); + mTargetDirections[2] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3Direction(0); + mTargetDirections[3] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1Direction(1); + mTargetDirections[4] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2Direction(1); + mTargetDirections[5] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3Direction(1); + mTargetDirections[6] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1Direction(2); + mTargetDirections[7] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2Direction(2); + mTargetDirections[8] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3Direction(2); + mTargetDirections[9] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1Direction(3); + mTargetDirections[10] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2Direction(3); + mTargetDirections[11] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3Direction(3); + + mTargetInOut = 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1InOut(0) ? 1 << 0 : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2InOut(0) ? 1 << 1 : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3InOut(0) ? 1 << 2 : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1InOut(1) ? 1 << 3 : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2InOut(1) ? 1 << 4 : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3InOut(1) ? 1 << 5 : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1InOut(2) ? 1 << 6 : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2InOut(2) ? 1 << 7 : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3InOut(2) ? 1 << 8 : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1InOut(3) ? 1 << 9 : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2InOut(3) ? 1 << 10 : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3InOut(3) ? 1 << 11 : 0; + + mTargetEnergy = 0; + mTargetEnergy |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeEnergy(0) ? 1 << 0 : 0; + mTargetEnergy |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeEnergy(1) ? 1 << 1 : 0; + mTargetEnergy |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeEnergy(2) ? 1 << 2 : 0; + mTargetEnergy |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeEnergy(3) ? 1 << 3 : 0; + + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + for (int i = 0; i < 12; i++) + var1.sendProgressBarUpdate(this, 100 + i, mTargetDirections[i]); + var1.sendProgressBarUpdate(this, 113, mTargetInOut); + var1.sendProgressBarUpdate(this, 114, mTargetEnergy); + for (int i = 0; i < 4; i++) + var1.sendProgressBarUpdate(this, 115 + i, mRangeDirections[i]); + } + } + + @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 100 : + mTargetDirections[0] = par2; + break; + case 101 : + mTargetDirections[1] = par2; + break; + case 102 : + mTargetDirections[2] = par2; + break; + case 103 : + mTargetDirections[3] = par2; + break; + case 104 : + mTargetDirections[4] = par2; + break; + case 105 : + mTargetDirections[5] = par2; + break; + case 106 : + mTargetDirections[6] = par2; + break; + case 107 : + mTargetDirections[7] = par2; + break; + case 108 : + mTargetDirections[8] = par2; + break; + case 109 : + mTargetDirections[9] = par2; + break; + case 110 : + mTargetDirections[10] = par2; + break; + case 111 : + mTargetDirections[11] = par2; + break; + + case 113 : + mTargetInOut = par2; + break; + case 114 : + mTargetEnergy = par2; + break; + case 115 : + mRangeDirections[0] = par2; + break; + case 116 : + mRangeDirections[1] = par2; + break; + case 117 : + mRangeDirections[2] = par2; + break; + case 118 : + mRangeDirections[3] = par2; + break; + } + } + + public int getSlotCount() { + return 3; + } + + public int getShiftClickSlotCount() { + return 3; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricAutoWorkbench.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricAutoWorkbench.java new file mode 100644 index 0000000000..7d381c0e8a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricAutoWorkbench.java @@ -0,0 +1,59 @@ +package gtPlusPlus.xmod.gregtech.api.gui.automation; + +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 gtPlusPlus.xmod.gregtech.api.gui.basic.GT_Container_CropHarvestor; +import net.minecraft.entity.player.InventoryPlayer; + +public class GT_GUIContainer_ElectricAutoWorkbench extends GT_GUIContainerMetaTile_Machine { + + private static final String[] mModeText = new String[] {"Normal Crafting Table", "???", "1x1", "2x2", "3x3", "Unifier", "Dust", "???", "Hammer?", "Circle"}; + + public GT_GUIContainer_ElectricAutoWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(new GT_Container_ElectricAutoWorkbench(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "ElectricAutoWorkbench.png"); + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + drawTooltip(par1, par2); + } + + @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) { + int tMode = ((GT_Container_ElectricAutoWorkbench)mContainer).mMode; + if (tMode != 0) drawTexturedModalRect(x + 120, y + 40, tMode*18, 166, 18, 18); + tMode = ((GT_Container_ElectricAutoWorkbench)mContainer).mThroughPut; + drawTexturedModalRect(x + 120, y + 4, tMode*18, 184, 18, 18); + } + } + + 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; + List list = new ArrayList<>(); + String[] mModeText = new String[] {"Normal Crafting Table", "???", "1x1", "2x2", "3x3", "Unifier", "Dust", "???", "Hammer?", "Circle"}; + if (y3 >= 45 && y3 <= 62) { + if (x3 >= 120 && x3 <= 137) { + list.add("Mode: "+mModeText[((GT_Container_ElectricAutoWorkbench) mContainer).mMode]); + /*switch (((GT_Container_ElectricAutoWorkbench) mContainer).mMode) { + case 0: + list.add("Mode: "); + }*/ + } + } + if (!list.isEmpty()) + drawHoveringText(list, x3, y3, fontRendererObj); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricInventoryManager.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricInventoryManager.java new file mode 100644 index 0000000000..cf57d3faf1 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricInventoryManager.java @@ -0,0 +1,58 @@ +package gtPlusPlus.xmod.gregtech.api.gui.automation; + +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 GT_GUIContainer_ElectricInventoryManager extends GT_GUIContainerMetaTile_Machine { + + public GT_GUIContainer_ElectricInventoryManager(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(new GT_Container_ElectricInventoryManager(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "InventoryManager.png"); + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + + } + + @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) { + drawTexturedModalRect(x + 4, y + 4, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[0]*18, 202, 18, 54); + drawTexturedModalRect(x + 60, y + 4, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[1]*18, 202, 18, 54); + drawTexturedModalRect(x + 79, y + 4, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[2]*18, 202, 18, 54); + drawTexturedModalRect(x + 135, y + 4, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[3]*18, 202, 18, 54); + + drawTexturedModalRect(x + 23, y + 59, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[0]*18+126, 166, 18, 18); + drawTexturedModalRect(x + 41, y + 59, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[1]*18+126, 166, 18, 18); + drawTexturedModalRect(x + 98, y + 59, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[2]*18+126, 166, 18, 18); + drawTexturedModalRect(x + 116, y + 59, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[3]*18+126, 166, 18, 18); + + drawTexturedModalRect(x + 4, y + 59, 108, (((GT_Container_ElectricInventoryManager)mContainer).mTargetEnergy & 1)!=0?184:166, 18, 18); + drawTexturedModalRect(x + 60, y + 59, 108, (((GT_Container_ElectricInventoryManager)mContainer).mTargetEnergy & 2)!=0?184:166, 18, 18); + drawTexturedModalRect(x + 79, y + 59, 108, (((GT_Container_ElectricInventoryManager)mContainer).mTargetEnergy & 4)!=0?184:166, 18, 18); + drawTexturedModalRect(x + 135, y + 59, 108, (((GT_Container_ElectricInventoryManager)mContainer).mTargetEnergy & 8)!=0?184:166, 18, 18); + + int i = -1; + + drawTexturedModalRect(x + 23, y + 4, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1< Date: Wed, 19 Jan 2022 14:31:09 +0000 Subject: Added textures for Redstone Circuit Block. Fixed GUI tooltips breaking block lighting. Fixed creative energy buffer not keeping it's tier on world load. --- .../GT_GUIContainer_ElectricAutoWorkbench.java | 5 +- .../gui/basic/GT_GUIContainer_CropHarvestor.java | 5 +- .../api/gui/basic/GUI_PollutionCleaner.java | 2 + .../GT_GUIContainer_RedstoneCircuitBlock.java | 33 +++++ .../api/gui/fluidreactor/GUI_FluidReactor.java | 3 + .../GT_GUIContainer_AdvancedWorkbench.java | 2 + .../creative/GregtechMetaCreativeEnergyBuffer.java | 120 ++++++++--------- .../GT_MetaTileEntity_RedstoneCircuitBlock.java | 143 +++++++++++++++------ .../storage/GregtechMetaEnergyBuffer.java | 12 +- 9 files changed, 214 insertions(+), 111 deletions(-) (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation') diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricAutoWorkbench.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricAutoWorkbench.java index 7d381c0e8a..90f8380d14 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricAutoWorkbench.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricAutoWorkbench.java @@ -7,6 +7,7 @@ import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.gui.basic.GT_Container_CropHarvestor; +import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.player.InventoryPlayer; public class GT_GUIContainer_ElectricAutoWorkbench extends GT_GUIContainerMetaTile_Machine { @@ -53,7 +54,9 @@ public class GT_GUIContainer_ElectricAutoWorkbench extends GT_GUIContainerMetaTi }*/ } } - if (!list.isEmpty()) + if (!list.isEmpty()) { drawHoveringText(list, x3, y3, fontRendererObj); + RenderHelper.enableGUIStandardItemLighting(); + } } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GT_GUIContainer_CropHarvestor.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GT_GUIContainer_CropHarvestor.java index ff2894f94a..504ae61b4a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GT_GUIContainer_CropHarvestor.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GT_GUIContainer_CropHarvestor.java @@ -7,6 +7,7 @@ import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.common.gui.GT_Container_Boiler; import gtPlusPlus.core.lib.CORE; +import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.player.InventoryPlayer; public class GT_GUIContainer_CropHarvestor extends GT_GUIContainerMetaTile_Machine { @@ -65,8 +66,10 @@ public class GT_GUIContainer_CropHarvestor extends GT_GUIContainerMetaTile_Machi list.add("Water: "+aWater+"L / "+((GT_Container_CropHarvestor) mContainer).mTileEntity.getMetaTileEntity().getCapacity()+"L"); } } - if (!list.isEmpty()) + if (!list.isEmpty()) { drawHoveringText(list, x, y, fontRendererObj); + RenderHelper.enableGUIStandardItemLighting(); + } } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java index 3b96731f00..96e8e362ef 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java @@ -6,6 +6,7 @@ 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.client.renderer.RenderHelper; import net.minecraft.entity.player.InventoryPlayer; public class GUI_PollutionCleaner extends GT_GUIContainerMetaTile_Machine { @@ -52,6 +53,7 @@ public class GUI_PollutionCleaner extends GT_GUIContainerMetaTile_Machine { } if (!list.isEmpty()) { this.drawHoveringText(list, x3, y3, this.fontRendererObj); + RenderHelper.enableGUIStandardItemLighting(); } } 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 index 89636fbaf2..53d60c3a68 100644 --- 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 @@ -1,11 +1,15 @@ package gtPlusPlus.xmod.gregtech.api.gui.computer; +import java.util.ArrayList; +import java.util.List; + 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.client.renderer.RenderHelper; import net.minecraft.entity.player.InventoryPlayer; public class GT_GUIContainer_RedstoneCircuitBlock extends GT_GUIContainerMetaTile_Machine { @@ -36,6 +40,7 @@ public class GT_GUIContainer_RedstoneCircuitBlock extends GT_GUIContainerMetaTil 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); } + this.drawTooltip(par1, par2); } @Override @@ -59,4 +64,32 @@ public class GT_GUIContainer_RedstoneCircuitBlock extends GT_GUIContainerMetaTil drawTexturedModalRect(x + 140, y + 9, 201, 0, 7, 7); } } + + 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 list = new ArrayList(); + + int y = 10; + if (x3 >= 151 && x3 <= 168) { + if (y3 >= y && y3 <= (y + 17)) { + list.add("Toggle EU Output"); + } + if (y3 >= (y + 18) && y3 <= (y + 35)) { + list.add("Toggle Active State"); + } + if (y3 >= (y + 36) && y3 <= (y + 53)) { + list.add("Change Redstone Circuit"); + } + } + + if (!list.isEmpty()) { + //RenderHelper.enableGUIStandardItemLighting(); + this.drawHoveringText(list, x3, y3, this.fontRendererObj); + RenderHelper.enableGUIStandardItemLighting(); + } + //RenderHelper.enableStandardItemLighting(); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/fluidreactor/GUI_FluidReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/fluidreactor/GUI_FluidReactor.java index 1be79b40cc..4d35df251c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/fluidreactor/GUI_FluidReactor.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/fluidreactor/GUI_FluidReactor.java @@ -7,6 +7,8 @@ import gtPlusPlus.core.lib.CORE; import java.util.ArrayList; import java.util.List; + +import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.player.InventoryPlayer; public class GUI_FluidReactor extends GT_GUIContainerMetaTile_Machine { @@ -54,6 +56,7 @@ public class GUI_FluidReactor extends GT_GUIContainerMetaTile_Machine { if (!list.isEmpty()) { this.drawHoveringText(list, x, y, this.fontRendererObj); + RenderHelper.enableGUIStandardItemLighting(); } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/workbench/GT_GUIContainer_AdvancedWorkbench.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/workbench/GT_GUIContainer_AdvancedWorkbench.java index fc3041f553..094a7a7eb9 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/workbench/GT_GUIContainer_AdvancedWorkbench.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/workbench/GT_GUIContainer_AdvancedWorkbench.java @@ -8,6 +8,7 @@ import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.sys.KeyboardUtils; +import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.player.InventoryPlayer; public class GT_GUIContainer_AdvancedWorkbench extends GT_GUIContainerMetaTile_Machine { @@ -71,6 +72,7 @@ public class GT_GUIContainer_AdvancedWorkbench extends GT_GUIContainerMetaTile_M } if (!list.isEmpty()) { this.drawHoveringText(list, x3, y3, this.fontRendererObj); + RenderHelper.enableGUIStandardItemLighting(); } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java index a62a5d16c8..2e4e1ce7dd 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java @@ -5,18 +5,12 @@ import static gregtech.api.enums.GT_Values.V; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_RenderedTexture; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; @@ -26,34 +20,35 @@ import gtPlusPlus.core.util.sys.KeyboardUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GregtechMetaEnergyBuffer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! * - * This is the main construct for my Basic Machines such as the Automatic Extractor - * Extend this class to make a simple Machine + * This is the main construct for my Basic Machines such as the Automatic + * Extractor Extend this class to make a simple Machine */ public class GregtechMetaCreativeEnergyBuffer extends GregtechMetaEnergyBuffer { - - public GregtechMetaCreativeEnergyBuffer(final String aName, final int aTier, - final String aDescription, final ITexture[][][] aTextures, final int aSlotCount) { + private int mVoltageTier = 3; + + public GregtechMetaCreativeEnergyBuffer(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures, final int aSlotCount) { super(aName, aTier, aDescription, aTextures, aSlotCount); // TODO Auto-generated constructor stub } - public GregtechMetaCreativeEnergyBuffer(final int aID, final String aName, - final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { + public GregtechMetaCreativeEnergyBuffer(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { super(aID, aName, aNameRegional, aTier, aDescription, aSlotCount); } @Override public String[] getDescription() { - return new String[] {this.mDescription, - "Use Screwdriver to change voltage", - "Hold Shift while using Screwdriver to change amperage", - EnumChatFormatting.GREEN+"CREATIVE MACHINE", - CORE.GT_Tooltip}; + return new String[]{this.mDescription, "Use Screwdriver to change voltage", "Hold Shift while using Screwdriver to change amperage", EnumChatFormatting.GREEN + + "CREATIVE MACHINE", CORE.GT_Tooltip}; } /* @@ -66,27 +61,23 @@ public class GregtechMetaCreativeEnergyBuffer extends GregtechMetaEnergyBuffer { CustomIcon k; boolean j = MathUtils.isNumberEven(this.mTier); final ITexture[][][] rTextures = new ITexture[2][17][]; - k = j ? g : h; + k = j ? g : h; for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = new ITexture[] { new GT_RenderedTexture(k) }; - rTextures[1][i + 1] = new ITexture[] { - new GT_RenderedTexture(k), this.mInventory.length > 4 ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] - : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] }; + rTextures[0][i + 1] = new ITexture[]{new GT_RenderedTexture(k)}; + rTextures[1][i + + 1] = new ITexture[]{new GT_RenderedTexture(k), this.mInventory.length > 4 ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]}; } return rTextures; } @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, - final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, - final boolean aRedstone) { + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { return this.mTextures[aSide == aFacing ? 1 : 0][aColorIndex + 1]; } @Override public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaCreativeEnergyBuffer(this.mName, this.mTier, this.mDescription, - this.mTextures, this.mInventory.length); + return new GregtechMetaCreativeEnergyBuffer(this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); } @Override @@ -101,43 +92,49 @@ public class GregtechMetaCreativeEnergyBuffer extends GregtechMetaEnergyBuffer { @Override public long maxEUInput() { - return V[this.mTier]; + return V[mVoltageTier]; } @Override public long maxEUOutput() { - return V[this.mTier]; + return V[mVoltageTier]; } @Override public long maxAmperesIn() { - return 16; + return aCurrentOutputAmperage; } @Override public long maxAmperesOut() { - return 16; + return aCurrentOutputAmperage; } - @Override public int getProgresstime() {return Integer.MAX_VALUE;} - @Override public int maxProgresstime() {return Integer.MAX_VALUE;} - @Override public boolean isAccessAllowed(final EntityPlayer aPlayer) {return true;} + @Override + public int getProgresstime() { + return Integer.MAX_VALUE; + } + @Override + public int maxProgresstime() { + return Integer.MAX_VALUE; + } + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { return null; } @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { return null; } @Override public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - this.getBaseMetaTileEntity().increaseStoredEnergyUnits(Integer.MAX_VALUE, true); if (aBaseMetaTileEntity.isServerSide()) { aBaseMetaTileEntity.increaseStoredEnergyUnits(Integer.MAX_VALUE, true); } @@ -156,12 +153,7 @@ public class GregtechMetaCreativeEnergyBuffer extends GregtechMetaEnergyBuffer { @Override public String[] getInfoData() { String[] infoData = super.getInfoData(); - return new String[] { - infoData[0], - "THIS IS A CREATIVE ITEM - FOR TESTING | Tier: "+this.mTier, - infoData[1], - infoData[2] - }; + return new String[]{infoData[0], "THIS IS A CREATIVE ITEM - FOR TESTING | Tier: " + this.mTier, infoData[1], infoData[2]}; } @Override @@ -171,59 +163,59 @@ public class GregtechMetaCreativeEnergyBuffer extends GregtechMetaEnergyBuffer { @Override public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setByte("mTier", this.mTier); + aNBT.setInteger("mVoltageTier", this.mVoltageTier); super.saveNBTData(aNBT); } @Override public void loadNBTData(NBTTagCompound aNBT) { + this.mVoltageTier = aNBT.getInteger("mVoltageTier"); super.loadNBTData(aNBT); - this.mTier = aNBT.getByte("mTier"); } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (KeyboardUtils.isShiftKeyDown()) { - super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); } else { - if (this.mTier < (CORE.GTNH ? GT_Values.V.length-1 : 9)) { - this.mTier++; + if (this.mVoltageTier < (GT_Values.VN[9].equals("UHV") ? GT_Values.V.length - 1 : 9)) { + this.mVoltageTier++; } else { - this.mTier = 0; + this.mVoltageTier = 0; } this.markDirty(); try { - Field field = ReflectionUtils.getField(this.getClass(), "mTextures"); + Field field = ReflectionUtils.getField(this.getClass(), "mTextures"); field.setAccessible(true); Field modifiersField = Field.class.getDeclaredField("modifiers"); modifiersField.setAccessible(true); modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); ITexture[][][] V = getTextureSet(null); if (V != null) { - Logger.REFLECTION("Got Valid Textures."); + Logger.REFLECTION("Got Valid Textures."); if (this.getBaseMetaTileEntity().isClientSide()) { - Logger.REFLECTION("Clientside Call."); + Logger.REFLECTION("Clientside Call."); Logger.REFLECTION("Refreshing Textures on buffer."); field.set(this, V); Logger.REFLECTION("Refreshed Textures on buffer."); } else { - Logger.REFLECTION("Serverside Call."); + Logger.REFLECTION("Serverside Call."); } } else { - Logger.REFLECTION("Bad mTextures setter."); - } + Logger.REFLECTION("Bad mTextures setter."); + } } catch (Throwable t) { - //Bad refresh. + // Bad refresh. t.printStackTrace(); Logger.REFLECTION("Bad mTextures setter."); } - PlayerUtils.messagePlayer(aPlayer, "Now running at "+GT_Values.VOLTAGE_NAMES[this.mTier]+"."); - } - + PlayerUtils.messagePlayer(aPlayer, "Now running at " + GT_Values.VOLTAGE_NAMES[this.mTier] + "."); + } + } -} \ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneCircuitBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneCircuitBlock.java index e3779d1e9b..180091b2eb 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneCircuitBlock.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/redstone/GT_MetaTileEntity_RedstoneCircuitBlock.java @@ -3,15 +3,18 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.redstone; import java.util.*; import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.IRedstoneCircuitBlock; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.*; import gtPlusPlus.xmod.gregtech.api.gui.computer.GT_Container_RedstoneCircuitBlock; import gtPlusPlus.xmod.gregtech.api.gui.computer.GT_GUIContainer_RedstoneCircuitBlock; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -25,18 +28,18 @@ public class GT_MetaTileEntity_RedstoneCircuitBlock extends GT_MetaTileEntity_Re public boolean bOutput = true; public GT_MetaTileEntity_RedstoneCircuitBlock(int aID) { - super(aID, "redstone.circuit", "Redstone Circuit Block", 0, 0, "Computes Redstone"); + super(aID, "redstone.circuit", "Redstone Circuit Block", 1, 5, "Computes Redstone"); } public GT_MetaTileEntity_RedstoneCircuitBlock(final String aName, String aDescription, final ITexture[][][] aTextures) { - super(aName, 0, 0, aDescription, aTextures); + super(aName, 1, 5, aDescription, aTextures); } @Override public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_RedstoneCircuitBlock(this.mName, mDescription, this.mTextures); } - + @Override public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { return new GT_Container_RedstoneCircuitBlock(aPlayerInventory, aBaseMetaTileEntity); @@ -51,50 +54,75 @@ public class GT_MetaTileEntity_RedstoneCircuitBlock extends GT_MetaTileEntity_Re public boolean hasSidedRedstoneOutputBehavior() { return true; } - + @Override public boolean isEnetInput() { return true; } - + @Override public boolean isEnetOutput() { return true; } - + @Override public boolean isInputFacing(byte aSide) { - return !isOutputFacing(aSide); + return true; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isPneumatic() { + return false; + } + + @Override + public boolean isSteampowered() { + return false; } - + @Override public boolean isOutputFacing(byte aSide) { - return getBaseMetaTileEntity().getBackFacing() == aSide; + return true; } - + @Override public long getMinimumStoredEU() { - return 500; + return 512; } - + @Override public long maxEUInput() { - return 32; + return GT_Values.V[1]; } - + @Override public long maxEUOutput() { - return bOutput ? 32 : 0; + return bOutput ? GT_Values.V[1] : 0; } - + + @Override + public long maxAmperesIn() { + return 2; + } + + @Override + public long maxAmperesOut() { + return 1; + } + @Override public int getSizeInventory() { return 5; } - + @Override public long maxEUStore() { - return 1000; + return GT_Values.V[3] * 1024; } @Override @@ -106,7 +134,6 @@ public class GT_MetaTileEntity_RedstoneCircuitBlock extends GT_MetaTileEntity_Re return true; } - @Override public void saveNBTData(NBTTagCompound aNBT) { aNBT.setInteger("mGate", mGate); @@ -202,9 +229,9 @@ public class GT_MetaTileEntity_RedstoneCircuitBlock extends GT_MetaTileEntity_Re try { tBehaviour.initParameters(mGateData, this); } - catch (Throwable e) { - GT_Log.err.print(e); - } + catch (Throwable e) { + GT_Log.err.print(e); + } validateGateData(); } @@ -214,9 +241,9 @@ public class GT_MetaTileEntity_RedstoneCircuitBlock extends GT_MetaTileEntity_Re try { tBehaviour.validateParameters(mGateData, this); } - catch (Throwable e) { - GT_Log.err.print(e); - } + catch (Throwable e) { + GT_Log.err.print(e); + } } @Override @@ -232,7 +259,7 @@ public class GT_MetaTileEntity_RedstoneCircuitBlock extends GT_MetaTileEntity_Re getBaseMetaTileEntity().setGenericRedstoneOutput(true); if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().isServerSide()) { mInventory[0] = mInventory[1] = mInventory[2] = mInventory[3] = mInventory[4] = null; - if (getBaseMetaTileEntity().getUniversalEnergyStored() > 400) { + if (getBaseMetaTileEntity().getUniversalEnergyStored() >= getMinimumStoredEU()) { if (getBaseMetaTileEntity().isActive()) { GT_CircuitryBehavior tBehaviour = GregTech_API.sCircuitryBehaviors.get(mGate); if (tBehaviour != null) { @@ -257,29 +284,28 @@ public class GT_MetaTileEntity_RedstoneCircuitBlock extends GT_MetaTileEntity_Re else { getBaseMetaTileEntity().setErrorDisplayID(1); } - } + } } - /** The Item List for Covers */ public static final Map sCoversItems = new HashMap(); - + private static void initCovers() { for (GT_ItemStack aKey : GregTech_API.sCovers.keySet()) { ItemStack aStack = aKey.toStack().copy(); if (aStack != null) { - sCoversItems.put(GT_Utility.stackToInt(aStack), aStack); + sCoversItems.put(GT_Utility.stackToInt(aStack), aStack); } } } - + public static ItemStack getCoverByID(int aStack) { if (sCoversItems.isEmpty()) { initCovers(); } return sCoversItems.get(Integer.valueOf(aStack)); } - + @Override public byte getOutputFacing() { return getBaseMetaTileEntity().getBackFacing(); @@ -378,14 +404,55 @@ public class GT_MetaTileEntity_RedstoneCircuitBlock extends GT_MetaTileEntity_Re } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - // TODO Auto-generated method stub - return null; + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getSides(i); + rTextures[1][i + 1] = this.getSides(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getSidesActive(i); + rTextures[6][i + 1] = this.getSidesActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; } @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - // TODO Auto-generated method stub - return null; + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive || hasRedstoneSignal() ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + + 1]; } + + private GT_RenderedTexture getBase() { + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_Off)}; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[]{getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Top_On)}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_Off)}; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[]{getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Bottom_On)}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_Off)}; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[]{getBase(), new GT_RenderedTexture(TexturesGtBlock.Casing_Redstone_Side_On)}; + } + } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java index 320e2175b0..5c7cfed334 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java @@ -2,12 +2,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.storage; import static gregtech.api.enums.GT_Values.V; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; - import gregtech.api.enums.Textures; import gregtech.api.gui.GT_Container_1by1; import gregtech.api.gui.GT_GUIContainer_1by1; @@ -17,12 +11,16 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { -- cgit