diff options
Diffstat (limited to 'src/main/java/gregtech/api/gui')
37 files changed, 1159 insertions, 1056 deletions
diff --git a/src/main/java/gregtech/api/gui/GT_Container.java b/src/main/java/gregtech/api/gui/GT_Container.java index 843d34c1f3..b5aebf87f2 100644 --- a/src/main/java/gregtech/api/gui/GT_Container.java +++ b/src/main/java/gregtech/api/gui/GT_Container.java @@ -4,6 +4,7 @@ import gregtech.api.interfaces.IFluidAccess; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; +import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; @@ -14,8 +15,6 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; -import java.util.List; - /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! * <p/> @@ -109,8 +108,10 @@ public class GT_Container extends Container { if (aSlotIndex >= 0) { if (inventorySlots.get(aSlotIndex) == null || inventorySlots.get(aSlotIndex) instanceof GT_Slot_Holo) return null; - if (!(inventorySlots.get(aSlotIndex) instanceof GT_Slot_Armor)) if (aSlotIndex < getAllSlotCount()) - if (aSlotIndex < getSlotStartIndex() || aSlotIndex >= getSlotStartIndex() + getSlotCount()) return null; + if (!(inventorySlots.get(aSlotIndex) instanceof GT_Slot_Armor)) + if (aSlotIndex < getAllSlotCount()) + if (aSlotIndex < getSlotStartIndex() || aSlotIndex >= getSlotStartIndex() + getSlotCount()) + return null; } try { @@ -137,7 +138,8 @@ public class GT_Container extends Container { aPlayerInventory.setItemStack(null); } if (aMouseclick == 1) { - aPlayer.dropPlayerItemWithRandomChoice(aPlayerInventory.getItemStack().splitStack(1), true); + aPlayer.dropPlayerItemWithRandomChoice( + aPlayerInventory.getItemStack().splitStack(1), true); if (aPlayerInventory.getItemStack().stackSize == 0) { aPlayerInventory.setItemStack(null); } @@ -187,7 +189,9 @@ public class GT_Container extends Container { } aSlot.onPickupFromSlot(aPlayer, aPlayerInventory.getItemStack()); } else if (aSlot.isItemValid(mouseStack)) { - if (tTempStack.getItem() == mouseStack.getItem() && tTempStack.getItemDamage() == mouseStack.getItemDamage() && ItemStack.areItemStackTagsEqual(tTempStack, mouseStack)) { + if (tTempStack.getItem() == mouseStack.getItem() + && tTempStack.getItemDamage() == mouseStack.getItemDamage() + && ItemStack.areItemStackTagsEqual(tTempStack, mouseStack)) { tTempStackSize = aMouseclick == 0 ? mouseStack.stackSize : 1; if (tTempStackSize > aSlot.getSlotStackLimit() - tTempStack.stackSize) { tTempStackSize = aSlot.getSlotStackLimit() - tTempStack.stackSize; @@ -204,10 +208,15 @@ public class GT_Container extends Container { aSlot.putStack(mouseStack); aPlayerInventory.setItemStack(tTempStack); } - } else if (tTempStack.getItem() == mouseStack.getItem() && mouseStack.getMaxStackSize() > 1 && (!tTempStack.getHasSubtypes() || tTempStack.getItemDamage() == mouseStack.getItemDamage()) && ItemStack.areItemStackTagsEqual(tTempStack, mouseStack)) { + } else if (tTempStack.getItem() == mouseStack.getItem() + && mouseStack.getMaxStackSize() > 1 + && (!tTempStack.getHasSubtypes() + || tTempStack.getItemDamage() == mouseStack.getItemDamage()) + && ItemStack.areItemStackTagsEqual(tTempStack, mouseStack)) { tTempStackSize = tTempStack.stackSize; - if (tTempStackSize > 0 && tTempStackSize + mouseStack.stackSize <= mouseStack.getMaxStackSize()) { + if (tTempStackSize > 0 + && tTempStackSize + mouseStack.stackSize <= mouseStack.getMaxStackSize()) { mouseStack.stackSize += tTempStackSize; tTempStack = aSlot.decrStackSize(tTempStackSize); @@ -231,7 +240,8 @@ public class GT_Container extends Container { if (aSlot.canTakeStack(aPlayer)) { // get the stack at the specified hotbar slot. tTempStack = aPlayerInventory.getStackInSlot(aMouseclick); - boolean canSwap = tTempStack == null || aSlot.inventory == aPlayerInventory && aSlot.isItemValid(tTempStack); + boolean canSwap = + tTempStack == null || aSlot.inventory == aPlayerInventory && aSlot.isItemValid(tTempStack); tTempStackSize = -1; if (!canSwap) { @@ -260,7 +270,10 @@ public class GT_Container extends Container { aSlot.putStack(tTempStack); } } - } else if (aShifthold == 3 && aPlayer.capabilities.isCreativeMode && aPlayerInventory.getItemStack() == null && aSlotIndex >= 0) { + } else if (aShifthold == 3 + && aPlayer.capabilities.isCreativeMode + && aPlayerInventory.getItemStack() == null + && aSlotIndex >= 0) { aSlot = (Slot) this.inventorySlots.get(aSlotIndex); if (aSlot != null && aSlot.getHasStack()) { tTempStack = GT_Utility.copyOrNull(aSlot.getStack()); @@ -278,19 +291,26 @@ public class GT_Container extends Container { mTileEntity.markDirty(); - //null checks and checks if the item can be stacked (maxStackSize > 1) - if (getSlotCount() > 0 && slotObject != null && slotObject.getHasStack() && !(slotObject instanceof GT_Slot_Holo)) { + // null checks and checks if the item can be stacked (maxStackSize > 1) + if (getSlotCount() > 0 + && slotObject != null + && slotObject.getHasStack() + && !(slotObject instanceof GT_Slot_Holo)) { ItemStack stackInSlot = slotObject.getStack(); stack = GT_Utility.copyOrNull(stackInSlot); - //TileEntity -> Player + // TileEntity -> Player if (aSlotIndex < getAllSlotCount()) { if (doesBindPlayerInventory()) if (!mergeItemStack(stackInSlot, getAllSlotCount(), getAllSlotCount() + 36, true)) { return null; } - //Player -> TileEntity - } else if (!mergeItemStack(stackInSlot, getShiftClickStartIndex(), getShiftClickStartIndex() + getShiftClickSlotCount(), false)) { + // Player -> TileEntity + } else if (!mergeItemStack( + stackInSlot, + getShiftClickStartIndex(), + getShiftClickStartIndex() + getShiftClickSlotCount(), + false)) { return null; } @@ -321,10 +341,17 @@ public class GT_Container extends Container { ItemStack itemStack; if (aStack.isStackable()) { - while (aStack.stackSize > 0 && (!reverseOrder && slotIndex < aSlotCount || reverseOrder && slotIndex >= aStartIndex)) { + while (aStack.stackSize > 0 + && (!reverseOrder && slotIndex < aSlotCount || reverseOrder && slotIndex >= aStartIndex)) { slot = (Slot) this.inventorySlots.get(slotIndex); itemStack = slot.getStack(); - if (!(slot instanceof GT_Slot_Holo) && !(slot instanceof GT_Slot_Output) && slot.isItemValid(aStack) && itemStack != null && itemStack.getItem() == aStack.getItem() && (!aStack.getHasSubtypes() || aStack.getItemDamage() == itemStack.getItemDamage()) && ItemStack.areItemStackTagsEqual(aStack, itemStack)) { + if (!(slot instanceof GT_Slot_Holo) + && !(slot instanceof GT_Slot_Output) + && slot.isItemValid(aStack) + && itemStack != null + && itemStack.getItem() == aStack.getItem() + && (!aStack.getHasSubtypes() || aStack.getItemDamage() == itemStack.getItemDamage()) + && ItemStack.areItemStackTagsEqual(aStack, itemStack)) { int combinedStackSize = itemStack.stackSize + aStack.stackSize; if (itemStack.stackSize < mTileEntity.getInventoryStackLimit()) { if (combinedStackSize <= aStack.getMaxStackSize()) { @@ -569,14 +596,18 @@ public class GT_Container extends Container { return true; } - protected static ItemStack handleFluidSlotClick(IFluidAccess aFluidAccess, EntityPlayer aPlayer, boolean aProcessFullStack, boolean aCanDrain, boolean aCanFill) { + protected static ItemStack handleFluidSlotClick( + IFluidAccess aFluidAccess, + EntityPlayer aPlayer, + boolean aProcessFullStack, + boolean aCanDrain, + boolean aCanFill) { ItemStack tStackHeld = aPlayer.inventory.getItemStack(); ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); if (tStackSizedOne == null || tStackHeld.stackSize == 0) return null; FluidStack tInputFluid = aFluidAccess.get(); FluidStack tFluidHeld = GT_Utility.getFluidForFilledItem(tStackSizedOne, true); - if (tFluidHeld != null && tFluidHeld.amount <= 0) - tFluidHeld = null; + if (tFluidHeld != null && tFluidHeld.amount <= 0) tFluidHeld = null; if (tInputFluid == null) { // tank empty, consider fill only from now on if (!aCanFill) @@ -639,19 +670,17 @@ public class GT_Container extends Container { } replaceCursorItemStack(aPlayer, tFilledContainer); } - if (tTankStack.amount <= 0) - aFluidAccess.set(null); + if (tTankStack.amount <= 0) aFluidAccess.set(null); return tFilledContainer; } - protected static ItemStack fillFluid(IFluidAccess aFluidAccess, EntityPlayer aPlayer, FluidStack aFluidHeld, boolean aProcessFullStack) { + protected static ItemStack fillFluid( + IFluidAccess aFluidAccess, EntityPlayer aPlayer, FluidStack aFluidHeld, boolean aProcessFullStack) { // we are not using aMachine.fill() here any more, so we need to check for fluid type here ourselves - if (aFluidAccess.get() != null && !aFluidAccess.get().isFluidEqual(aFluidHeld)) - return null; + if (aFluidAccess.get() != null && !aFluidAccess.get().isFluidEqual(aFluidHeld)) return null; ItemStack tStackHeld = aPlayer.inventory.getItemStack(); ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); - if (tStackSizedOne == null) - return null; + if (tStackSizedOne == null) return null; int tFreeSpace = aFluidAccess.getCapacity() - (aFluidAccess.get() != null ? aFluidAccess.get().amount : 0); if (tFreeSpace <= 0) @@ -715,5 +744,4 @@ public class GT_Container extends Container { GT_Utility.addItemToPlayerInventory(aPlayer, tStackResult); } } - } diff --git a/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java b/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java index 97ee1d85a3..f2774bbd38 100644 --- a/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java +++ b/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java @@ -1,13 +1,12 @@ package gregtech.api.gui; -import java.util.List; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.metatileentity.IConfigurationCircuitSupport; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Utility; +import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; @@ -31,8 +30,7 @@ public class GT_ContainerMetaTile_Machine extends GT_Container { mInput = 0, mID = 0, mDisplayErrorCode = 0; - public long mEnergyLong = 0, - mStorageLong = 0; + public long mEnergyLong = 0, mStorageLong = 0; private int oActive = 0, oMaxProgressTime = 0, oProgressTime = 0, @@ -44,12 +42,10 @@ public class GT_ContainerMetaTile_Machine extends GT_Container { oInput = 0, oID = 0, oDisplayErrorCode = 0; - private long oEnergyLong = 0, - oStorageLong = 0; + private long oEnergyLong = 0, oStorageLong = 0; protected int mTimer = 0; protected Runnable circuitSlotClickCallback; - public GT_ContainerMetaTile_Machine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { super(aInventoryPlayer, aTileEntity); @@ -57,31 +53,32 @@ public class GT_ContainerMetaTile_Machine extends GT_Container { if (mTileEntity != null && mTileEntity.getMetaTileEntity() != null) { addSlots(aInventoryPlayer); - if (doesBindPlayerInventory()) - bindPlayerInventory(aInventoryPlayer); + if (doesBindPlayerInventory()) bindPlayerInventory(aInventoryPlayer); detectAndSendChanges(); } else { aInventoryPlayer.player.openContainer = aInventoryPlayer.player.inventoryContainer; } } - public GT_ContainerMetaTile_Machine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, boolean doesBindInventory) { + public GT_ContainerMetaTile_Machine( + InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, boolean doesBindInventory) { super(aInventoryPlayer, aTileEntity); mTileEntity = aTileEntity; if (mTileEntity != null && mTileEntity.getMetaTileEntity() != null) { addSlots(aInventoryPlayer); - if (doesBindPlayerInventory() && doesBindInventory) - bindPlayerInventory(aInventoryPlayer); + if (doesBindPlayerInventory() && doesBindInventory) bindPlayerInventory(aInventoryPlayer); detectAndSendChanges(); } else { aInventoryPlayer.player.openContainer = aInventoryPlayer.player.inventoryContainer; } } + protected void addCircuitSlot() { if (mTileEntity.getMetaTileEntity() instanceof IConfigurationCircuitSupport) { - IConfigurationCircuitSupport ccs = (IConfigurationCircuitSupport)mTileEntity.getMetaTileEntity(); - GT_Slot_Render slotCircuit = new GT_Slot_Render(mTileEntity, ccs.getCircuitSlot(), ccs.getCircuitSlotX(), ccs.getCircuitSlotY()); + IConfigurationCircuitSupport ccs = (IConfigurationCircuitSupport) mTileEntity.getMetaTileEntity(); + GT_Slot_Render slotCircuit = + new GT_Slot_Render(mTileEntity, ccs.getCircuitSlot(), ccs.getCircuitSlotX(), ccs.getCircuitSlotY()); addSlotToContainer(slotCircuit); slotCircuit.setEnabled(ccs.allowSelectCircuit()); } @@ -95,8 +92,7 @@ public class GT_ContainerMetaTile_Machine extends GT_Container { @Override public void detectAndSendChanges() { super.detectAndSendChanges(); - if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) - return; + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return; mStorage = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getEUCapacity()); mStorageLong = mTileEntity.getEUCapacity(); mEnergy = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getStoredEU()); @@ -261,17 +257,17 @@ public class GT_ContainerMetaTile_Machine extends GT_Container { public void setCircuitSlotClickCallback(Runnable circuitSlotClickCallback) { this.circuitSlotClickCallback = circuitSlotClickCallback; } + @Override public ItemStack slotClick(int aSlotNumber, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { if (mTileEntity.getMetaTileEntity() instanceof IConfigurationCircuitSupport) { IMetaTileEntity machine = mTileEntity.getMetaTileEntity(); - IConfigurationCircuitSupport ccs = (IConfigurationCircuitSupport)machine; + IConfigurationCircuitSupport ccs = (IConfigurationCircuitSupport) machine; if (ccs.allowSelectCircuit() && aSlotNumber == ccs.getCircuitGUISlot() && aMouseclick < 2) { ItemStack newCircuit; if (aShifthold == 1) { if (aMouseclick == 0) { - if (circuitSlotClickCallback != null) - circuitSlotClickCallback.run(); + if (circuitSlotClickCallback != null) circuitSlotClickCallback.run(); return null; } else { // clear @@ -282,7 +278,9 @@ public class GT_ContainerMetaTile_Machine extends GT_Container { List<ItemStack> tCircuits = ccs.getConfigurationCircuits(); int index = GT_Utility.findMatchingStackInList(tCircuits, cursorStack); if (index < 0) { - int curIndex = GT_Utility.findMatchingStackInList(tCircuits, machine.getStackInSlot(ccs.getCircuitSlot())) + 1; + int curIndex = GT_Utility.findMatchingStackInList( + tCircuits, machine.getStackInSlot(ccs.getCircuitSlot())) + + 1; if (aMouseclick == 0) { curIndex += 1; } else { diff --git a/src/main/java/gregtech/api/gui/GT_Container_2by2_Fluid.java b/src/main/java/gregtech/api/gui/GT_Container_2by2_Fluid.java index f8f4e3c886..35ed089c97 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_2by2_Fluid.java +++ b/src/main/java/gregtech/api/gui/GT_Container_2by2_Fluid.java @@ -38,15 +38,18 @@ public class GT_Container_2by2_Fluid extends GT_ContainerMetaTile_Machine { * I'd imagine this lag to become only more severe when playing MP over ethernet, which would have much more latency * than a memory connection */ - GT_MetaTileEntity_Hatch_MultiInput tTank = (GT_MetaTileEntity_Hatch_MultiInput) mTileEntity.getMetaTileEntity(); + GT_MetaTileEntity_Hatch_MultiInput tTank = + (GT_MetaTileEntity_Hatch_MultiInput) mTileEntity.getMetaTileEntity(); tTank.setDrainableStack(GT_Utility.getFluidFromDisplayStack(tTank.getStackInSlot(2))); } - GT_MetaTileEntity_Hatch_MultiInput tTank = (GT_MetaTileEntity_Hatch_MultiInput) mTileEntity.getMetaTileEntity(); + GT_MetaTileEntity_Hatch_MultiInput tTank = + (GT_MetaTileEntity_Hatch_MultiInput) mTileEntity.getMetaTileEntity(); MultiFluidAccess tDrainableAccess = MultiFluidAccess.from(tTank, aSlotIndex); ItemStack tStackHeld = aPlayer.inventory.getItemStack(); FluidStack tFluidHeld = GT_Utility.getFluidForFilledItem(tStackHeld, true); if (tDrainableAccess.isMatch(tFluidHeld, aSlotIndex)) - return handleFluidSlotClick(tDrainableAccess, aPlayer, aMouseclick == 0, true, !tTank.isDrainableStackSeparate()); + return handleFluidSlotClick( + tDrainableAccess, aPlayer, aMouseclick == 0, true, !tTank.isDrainableStackSeparate()); } return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java index 6db6d45a89..fc0b3270d2 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java @@ -1,23 +1,20 @@ package gregtech.api.gui; +import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine.OTHER_SLOT_COUNT; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.interfaces.IFluidAccess; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; -import gregtech.api.util.GT_Utility; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; 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.List; - -import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine.OTHER_SLOT_COUNT; - /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! * <p/> @@ -25,10 +22,7 @@ import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Basi */ public class GT_Container_BasicMachine extends GT_Container_BasicTank { - public boolean - mFluidTransfer = false, - mItemTransfer = false, - mStuttering = false; + public boolean mFluidTransfer = false, mItemTransfer = false, mStuttering = false; GT_Slot_Holo slotFluidTransferToggle; GT_Slot_Holo slotItemTransferToggle; @@ -198,9 +192,7 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { addSlotToContainer(slotBattery = new Slot(mTileEntity, 1, 80, 63)); addSlotToContainer(slotSpecial = new Slot(mTileEntity, 3, 125, 63)); addSlotToContainer(slotFluidInput = new GT_Slot_Render(mTileEntity, tStartIndex++, 53, 63)); - slotFluidInput.setEnabled(recipes != null - ? (recipes.hasFluidInputs()) - : (machine.getCapacity() != 0)); + slotFluidInput.setEnabled(recipes != null ? (recipes.hasFluidInputs()) : (machine.getCapacity() != 0)); } @Override @@ -220,19 +212,25 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { } return null; default: - if (aSlotNumber == OTHER_SLOT_COUNT + 1 + machine.mInputSlotCount + machine.mOutputItems.length && aMouseclick < 2) { + if (aSlotNumber == OTHER_SLOT_COUNT + 1 + machine.mInputSlotCount + machine.mOutputItems.length + && aMouseclick < 2) { if (mTileEntity.isClientSide()) { // see parent class slotClick for an explanation on why doing this - GT_MetaTileEntity_BasicTank tTank = (GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity(); + GT_MetaTileEntity_BasicTank tTank = + (GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity(); tTank.setFillableStack(GT_Utility.getFluidFromDisplayStack(tTank.getStackInSlot(2))); } GT_MetaTileEntity_BasicTank tTank = (GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity(); BasicTankFluidAccess tFillableAccess = BasicTankFluidAccess.from(tTank, true); GT_Recipe_Map recipes = machine.getRecipeList(); - //If the machine has recipes but no fluid inputs, disallow filling this slot with fluids. - ItemStack tToken = handleFluidSlotClick(tFillableAccess, aPlayer, aMouseclick == 0, true, (recipes == null || recipes.hasFluidInputs())); - if (mTileEntity.isServerSide() && tToken != null) - mTileEntity.markInventoryBeenModified(); + // If the machine has recipes but no fluid inputs, disallow filling this slot with fluids. + ItemStack tToken = handleFluidSlotClick( + tFillableAccess, + aPlayer, + aMouseclick == 0, + true, + (recipes == null || recipes.hasFluidInputs())); + if (mTileEntity.isServerSide() && tToken != null) mTileEntity.markInventoryBeenModified(); return tToken; } else { return super.slotClick(aSlotNumber, aMouseclick, aShifthold, aPlayer); diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java index d294b60ca9..23769ab0cc 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java @@ -55,7 +55,8 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine { } GT_MetaTileEntity_BasicTank tTank = (GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity(); BasicTankFluidAccess tDrainableAccess = BasicTankFluidAccess.from(tTank, false); - return handleFluidSlotClick(tDrainableAccess, aPlayer, aMouseclick == 0, true, !tTank.isDrainableStackSeparate()); + return handleFluidSlotClick( + tDrainableAccess, aPlayer, aMouseclick == 0, true, !tTank.isDrainableStackSeparate()); } return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } @@ -66,8 +67,7 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine { if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return; if (((GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity()).mFluid != null) mContent = ((GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity()).mFluid.amount; - else - mContent = 0; + else mContent = 0; for (Object crafter : this.crafters) { ICrafting player = (ICrafting) crafter; if (mTimer % 500 == 0 || oContent != mContent) { @@ -114,10 +114,8 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine { @Override public void set(FluidStack stack) { - if (mIsFillableStack) - mTank.setFillableStack(stack); - else - mTank.setDrainableStack(stack); + if (mIsFillableStack) mTank.setFillableStack(stack); + else mTank.setDrainableStack(stack); } @Override diff --git a/src/main/java/gregtech/api/gui/GT_Container_MaintenanceHatch.java b/src/main/java/gregtech/api/gui/GT_Container_MaintenanceHatch.java index c3758486ba..fcaf618b56 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_MaintenanceHatch.java +++ b/src/main/java/gregtech/api/gui/GT_Container_MaintenanceHatch.java @@ -19,13 +19,11 @@ public class GT_Container_MaintenanceHatch extends GT_ContainerMetaTile_Machine @Override public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex != 0) - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + if (aSlotIndex != 0) return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); ItemStack tStack = aPlayer.inventory.getItemStack(); if (tStack != null) { ((GT_MetaTileEntity_Hatch_Maintenance) mTileEntity.getMetaTileEntity()).onToolClick(tStack, aPlayer); - if (tStack.stackSize <= 0) - aPlayer.inventory.setItemStack(null); + if (tStack.stackSize <= 0) aPlayer.inventory.setItemStack(null); } return null; } diff --git a/src/main/java/gregtech/api/gui/GT_Container_MultiMachine.java b/src/main/java/gregtech/api/gui/GT_Container_MultiMachine.java index f5e9a83d19..722057950b 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_MultiMachine.java +++ b/src/main/java/gregtech/api/gui/GT_Container_MultiMachine.java @@ -14,7 +14,8 @@ public class GT_Container_MultiMachine extends GT_ContainerMetaTile_Machine { super(aInventoryPlayer, aTileEntity); } - public GT_Container_MultiMachine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, boolean bindInventory) { + public GT_Container_MultiMachine( + InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, boolean bindInventory) { super(aInventoryPlayer, aTileEntity, bindInventory); } diff --git a/src/main/java/gregtech/api/gui/GT_Container_SpecialFilter.java b/src/main/java/gregtech/api/gui/GT_Container_SpecialFilter.java index fef857a7ae..0622f52865 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_SpecialFilter.java +++ b/src/main/java/gregtech/api/gui/GT_Container_SpecialFilter.java @@ -48,51 +48,58 @@ public class GT_Container_SpecialFilter extends GT_ContainerMetaTile_Machine { return null; } if (aSlotIndex == 9) { - ((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).clickTypeIcon(aMouseclick != 0, aPlayer.inventory.getItemStack()); + ((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()) + .clickTypeIcon(aMouseclick != 0, aPlayer.inventory.getItemStack()); return null; } if (aSlotIndex == 10) { - ((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bOutput = (!((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bOutput); + ((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bOutput = + (!((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bOutput); if (((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bOutput) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("116","Emit Energy to Outputside")); + GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("116", "Emit Energy to Outputside")); } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("117","Don't emit Energy")); + GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("117", "Don't emit Energy")); } return null; } if (aSlotIndex == 11) { - ((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull = (!((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull); + ((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull = + (!((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull); if (((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("122","Emit Redstone if slots contain something")); + GT_Utility.sendChatToPlayer( + aPlayer, GT_Utility.trans("122", "Emit Redstone if slots contain something")); } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("123","Don't emit Redstone")); + GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("123", "Don't emit Redstone")); } return null; } if (aSlotIndex == 12) { - ((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bInvert = (!((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bInvert); + ((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bInvert = + (!((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bInvert); if (((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bInvert) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("120","Invert Redstone")); + GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("120", "Invert Redstone")); } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("121","Don't invert Redstone")); + GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("121", "Don't invert Redstone")); } return null; } if (aSlotIndex == 13) { - ((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bInvertFilter = (!((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bInvertFilter); + ((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bInvertFilter = + (!((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bInvertFilter); if (((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bInvertFilter) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("124","Invert Filter")); + GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("124", "Invert Filter")); } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("125","Don't invert Filter")); + GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("125", "Don't invert Filter")); } return null; } if (aSlotIndex == 14) { - ((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bNBTAllowed = (!((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bNBTAllowed); + ((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bNBTAllowed = + (!((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bNBTAllowed); if (((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bNBTAllowed) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("126","Ignore NBT")); + GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("126", "Ignore NBT")); } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("127","NBT has to match")); + GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("127", "NBT has to match")); } return null; } diff --git a/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java b/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java index c2a833503e..63c7b224b5 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java +++ b/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java @@ -1,24 +1,25 @@ package gregtech.api.gui; -import gregtech.api.util.ColorsMetadataSection; import gregtech.api.GregTech_API; +import gregtech.api.util.ColorsMetadataSection; +import java.io.IOException; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.IResource; import net.minecraft.util.ResourceLocation; -import java.io.IOException; - public class GT_GUIColorOverride { private ColorsMetadataSection cmSection; public GT_GUIColorOverride(String guiTexturePath) { try { - IResource ir = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation(guiTexturePath)); + IResource ir = + Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation(guiTexturePath)); if (ir.hasMetadata()) { cmSection = (ColorsMetadataSection) ir.getMetadata("colors"); } - } catch (IOException ignore) {} + } catch (IOException ignore) { + } } public int getTextColorOrDefault(String textType, int defaultColor) { diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer.java b/src/main/java/gregtech/api/gui/GT_GUIContainer.java index 5d3f0a59a1..281f910d8c 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer.java @@ -1,6 +1,7 @@ package gregtech.api.gui; -import gregtech.api.gui.GT_GUIColorOverride; +import static gregtech.GT_Mod.GT_FML_LOGGER; + import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.Tessellator; import net.minecraft.inventory.Container; @@ -8,10 +9,6 @@ import net.minecraft.inventory.Slot; import net.minecraft.util.ResourceLocation; import org.lwjgl.input.Mouse; -import java.io.IOException; - -import static gregtech.GT_Mod.GT_FML_LOGGER; - /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! * <p/> @@ -79,11 +76,9 @@ public class GT_GUIContainer extends GuiContainer { super.handleMouseInput(); } - protected void onMouseWheel(int mx, int my, int delta) { - } + protected void onMouseWheel(int mx, int my, int delta) {} - public boolean isMouseOverSlot(int slotIndex, int mx, int my) - { + public boolean isMouseOverSlot(int slotIndex, int mx, int my) { int size = inventorySlots.inventorySlots.size(); if (slotIndex < 0 || slotIndex >= size) { // slot does not exist somehow. log and carry on diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java b/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java index 8a744aee60..0752324678 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java @@ -17,16 +17,13 @@ import gregtech.api.net.GT_Packet_SetConfigurationCircuit; import gregtech.api.util.GT_TooltipDataCache; import gregtech.api.util.GT_Util; import gregtech.api.util.GT_Utility; - +import java.util.List; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; - -import java.util.List; - import org.lwjgl.opengl.GL11; /** @@ -46,27 +43,22 @@ public class GT_GUIContainerMetaTile_Machine extends GT_GUIContainer implements // Cover Tabs support. Subclasses can override display position, style and visuals by overriding setupCoverTabs public GT_GuiCoverTabLine coverTabs; - private static final int - COVER_TAB_LEFT = -16, - COVER_TAB_TOP = 1, - COVER_TAB_HEIGHT = 20, - COVER_TAB_WIDTH = 18, - COVER_TAB_SPACING = 2; - private static final DisplayStyle - COVER_TAB_X_DIR = DisplayStyle.NONE, - COVER_TAB_Y_DIR = DisplayStyle.NORMAL; - private static final GT_GuiTabIconSet TAB_ICONSET = new GT_GuiTabIconSet( - GT_GuiIcon.TAB_NORMAL, - GT_GuiIcon.TAB_HIGHLIGHT, - GT_GuiIcon.TAB_DISABLED); + private static final int COVER_TAB_LEFT = -16, + COVER_TAB_TOP = 1, + COVER_TAB_HEIGHT = 20, + COVER_TAB_WIDTH = 18, + COVER_TAB_SPACING = 2; + private static final DisplayStyle COVER_TAB_X_DIR = DisplayStyle.NONE, COVER_TAB_Y_DIR = DisplayStyle.NORMAL; + private static final GT_GuiTabIconSet TAB_ICONSET = + new GT_GuiTabIconSet(GT_GuiIcon.TAB_NORMAL, GT_GuiIcon.TAB_HIGHLIGHT, GT_GuiIcon.TAB_DISABLED); public GT_GUIContainerMetaTile_Machine(GT_ContainerMetaTile_Machine aContainer, String aGUIbackground) { super(aContainer, aGUIbackground); mContainer = aContainer; DisplayStyle preferredDisplayStyle = GT_Mod.gregtechproxy.mCoverTabsVisible - ? (GT_Mod.gregtechproxy.mCoverTabsFlipped ? DisplayStyle.INVERSE : DisplayStyle.NORMAL) - : DisplayStyle.NONE; + ? (GT_Mod.gregtechproxy.mCoverTabsFlipped ? DisplayStyle.INVERSE : DisplayStyle.NORMAL) + : DisplayStyle.NONE; setupCoverTabs(preferredDisplayStyle); // Only setup tooltips if they're currently enabled. @@ -78,8 +70,8 @@ public class GT_GUIContainerMetaTile_Machine extends GT_GUIContainer implements mContainer.setCircuitSlotClickCallback(this::openSelectCircuitDialog); } - public GT_GUIContainerMetaTile_Machine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, - String aGUIbackground) { + public GT_GUIContainerMetaTile_Machine( + InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aGUIbackground) { this(new GT_ContainerMetaTile_Machine(aInventoryPlayer, aTileEntity), aGUIbackground); } @@ -88,18 +80,18 @@ public class GT_GUIContainerMetaTile_Machine extends GT_GUIContainer implements */ protected void setupCoverTabs(DisplayStyle preferredDisplayStyle) { coverTabs = new GT_GuiCoverTabLine( - this, - COVER_TAB_LEFT, - COVER_TAB_TOP, - COVER_TAB_HEIGHT, - COVER_TAB_WIDTH, - COVER_TAB_SPACING, - COVER_TAB_X_DIR, - COVER_TAB_Y_DIR, - preferredDisplayStyle, - getTabBackground(), - getMachine().getBaseMetaTileEntity(), - getColorization()); + this, + COVER_TAB_LEFT, + COVER_TAB_TOP, + COVER_TAB_HEIGHT, + COVER_TAB_WIDTH, + COVER_TAB_SPACING, + COVER_TAB_X_DIR, + COVER_TAB_Y_DIR, + preferredDisplayStyle, + getTabBackground(), + getMachine().getBaseMetaTileEntity(), + getColorization()); } @Override @@ -152,15 +144,14 @@ public class GT_GUIContainerMetaTile_Machine extends GT_GUIContainer implements /** * @return This machine's MetaTileEntity */ - private MetaTileEntity getMachine() { - return (MetaTileEntity ) mContainer.mTileEntity.getMetaTileEntity(); + private MetaTileEntity getMachine() { + return (MetaTileEntity) mContainer.mTileEntity.getMetaTileEntity(); } // Tabs support @Override - protected void mouseClicked(int mouseX, int mouseY, int mouseButton) - { + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) { super.mouseClicked(mouseX, mouseY, mouseButton); // Check for clicked tabs coverTabs.onMouseClicked(mouseX, mouseY, mouseButton); @@ -188,11 +179,12 @@ public class GT_GUIContainerMetaTile_Machine extends GT_GUIContainer implements */ protected void setupTooltips() { if (mContainer.mTileEntity.getMetaTileEntity() instanceof IConfigurationCircuitSupport) { - IConfigurationCircuitSupport ccs = (IConfigurationCircuitSupport)mContainer.mTileEntity.getMetaTileEntity(); + IConfigurationCircuitSupport ccs = + (IConfigurationCircuitSupport) mContainer.mTileEntity.getMetaTileEntity(); if (ccs.allowSelectCircuit()) - addToolTip(new GT_GuiSlotTooltip(mContainer.getSlot(ccs.getCircuitGUISlot()), mTooltipCache.getData(GHOST_CIRCUIT_TOOLTIP))); + addToolTip(new GT_GuiSlotTooltip( + mContainer.getSlot(ccs.getCircuitGUISlot()), mTooltipCache.getData(GHOST_CIRCUIT_TOOLTIP))); } - } // GT_IToolTipRenderer and GT_ITabRenderer implementations @@ -200,30 +192,37 @@ public class GT_GUIContainerMetaTile_Machine extends GT_GUIContainer implements public void drawHoveringText(List text, int mouseX, int mouseY, FontRenderer font) { super.drawHoveringText(text, mouseX, mouseY, font); } + @Override public int getGuiTop() { return guiTop; } + @Override public int getGuiLeft() { return guiLeft; } + @Override public int getXSize() { return xSize; } + @Override public FontRenderer getFontRenderer() { return fontRendererObj; } + @Override public RenderItem getItemRenderer() { return itemRender; } + @Override public void addToolTip(GT_GuiTooltip toolTip) { mTooltipManager.addToolTip(toolTip); } + @Override public boolean removeToolTip(GT_GuiTooltip toolTip) { return mTooltipManager.removeToolTip(toolTip); @@ -232,11 +231,11 @@ public class GT_GUIContainerMetaTile_Machine extends GT_GUIContainer implements @Override protected void onMouseWheel(int mx, int my, int delta) { if (mContainer.mTileEntity.getMetaTileEntity() instanceof IConfigurationCircuitSupport) { - IConfigurationCircuitSupport ccs = (IConfigurationCircuitSupport)mContainer.mTileEntity.getMetaTileEntity(); + IConfigurationCircuitSupport ccs = + (IConfigurationCircuitSupport) mContainer.mTileEntity.getMetaTileEntity(); Slot slotCircuit = mContainer.getSlot(ccs.getCircuitGUISlot()); - if (slotCircuit != null && func_146978_c(slotCircuit.xDisplayPosition, - slotCircuit.yDisplayPosition, 16, 16, mx, my)) - { + if (slotCircuit != null + && func_146978_c(slotCircuit.xDisplayPosition, slotCircuit.yDisplayPosition, 16, 16, mx, my)) { // emulate click handleMouseClick(slotCircuit, -1, delta > 0 ? 1 : 0, 0); return; @@ -247,23 +246,22 @@ public class GT_GUIContainerMetaTile_Machine extends GT_GUIContainer implements private void openSelectCircuitDialog() { IMetaTileEntity machine = mContainer.mTileEntity.getMetaTileEntity(); - IConfigurationCircuitSupport ccs = (IConfigurationCircuitSupport)machine; + IConfigurationCircuitSupport ccs = (IConfigurationCircuitSupport) machine; List<ItemStack> circuits = ccs.getConfigurationCircuits(); mc.displayGuiScreen(new GT_GUIDialogSelectItem( - StatCollector.translateToLocal("GT5U.machines.select_circuit"), - machine.getStackForm(0), - this, - this::onCircuitSelected, - circuits, - GT_Utility.findMatchingStackInList(circuits, - machine.getStackInSlot(ccs.getCircuitSlot())))); + StatCollector.translateToLocal("GT5U.machines.select_circuit"), + machine.getStackForm(0), + this, + this::onCircuitSelected, + circuits, + GT_Utility.findMatchingStackInList(circuits, machine.getStackInSlot(ccs.getCircuitSlot())))); } private void onCircuitSelected(ItemStack selected) { GT_Values.NW.sendToServer(new GT_Packet_SetConfigurationCircuit(mContainer.mTileEntity, selected)); // we will not do any validation on client side // it doesn't get to actually decide what inventory contains anyway - IConfigurationCircuitSupport ccs = (IConfigurationCircuitSupport)mContainer.mTileEntity.getMetaTileEntity(); + IConfigurationCircuitSupport ccs = (IConfigurationCircuitSupport) mContainer.mTileEntity.getMetaTileEntity(); mContainer.mTileEntity.setInventorySlotContents(ccs.getCircuitSlot(), selected); } } diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_1by1.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_1by1.java index 7e85cb60f0..16ef27c941 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_1by1.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_1by1.java @@ -1,12 +1,12 @@ package gregtech.api.gui; +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; - public class GT_GUIContainer_1by1 extends GT_GUIContainerMetaTile_Machine { - + private final String mName; private final int textColor = this.getTextColorOrDefault("title", 0x404040); @@ -15,7 +15,8 @@ public class GT_GUIContainer_1by1 extends GT_GUIContainerMetaTile_Machine { mName = aName; } - public GT_GUIContainer_1by1(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { + public GT_GUIContainer_1by1( + InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { super(new GT_Container_1by1(aInventoryPlayer, aTileEntity), RES_PATH_GUI + aBackground + "1by1.png"); mName = aName; } diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2.java index acefe12459..909a5b0d6a 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2.java @@ -1,10 +1,10 @@ package gregtech.api.gui; +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; - public class GT_GUIContainer_2by2 extends GT_GUIContainerMetaTile_Machine { private final String mName; @@ -15,7 +15,8 @@ public class GT_GUIContainer_2by2 extends GT_GUIContainerMetaTile_Machine { mName = aName; } - public GT_GUIContainer_2by2(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { + public GT_GUIContainer_2by2( + InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { super(new GT_Container_2by2(aInventoryPlayer, aTileEntity), RES_PATH_GUI + aBackground + "2by2.png"); mName = aName; } diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2_Fluid.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2_Fluid.java index afabaa0a80..d896349f0a 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2_Fluid.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2_Fluid.java @@ -1,11 +1,11 @@ package gregtech.api.gui; +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.StatCollector; -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; - public class GT_GUIContainer_2by2_Fluid extends GT_GUIContainerMetaTile_Machine { private final String mName; @@ -29,5 +29,4 @@ public class GT_GUIContainer_2by2_Fluid extends GT_GUIContainerMetaTile_Machine int y = (height - ySize) / 2; drawTexturedModalRect(x, y, 0, 0, xSize, ySize); } - } diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_3by3.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_3by3.java index c2911fc67f..97caa08946 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_3by3.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_3by3.java @@ -1,10 +1,10 @@ package gregtech.api.gui; +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; - public class GT_GUIContainer_3by3 extends GT_GUIContainerMetaTile_Machine { private final String mName; @@ -15,7 +15,8 @@ public class GT_GUIContainer_3by3 extends GT_GUIContainerMetaTile_Machine { mName = aName; } - public GT_GUIContainer_3by3(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { + public GT_GUIContainer_3by3( + InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { super(new GT_Container_3by3(aInventoryPlayer, aTileEntity), RES_PATH_GUI + aBackground + "3by3.png"); mName = aName; } diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_4by4.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_4by4.java index b28129eede..40441e3093 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_4by4.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_4by4.java @@ -1,10 +1,10 @@ package gregtech.api.gui; +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; - public class GT_GUIContainer_4by4 extends GT_GUIContainerMetaTile_Machine { private final String mName; @@ -15,7 +15,8 @@ public class GT_GUIContainer_4by4 extends GT_GUIContainerMetaTile_Machine { mName = aName; } - public GT_GUIContainer_4by4(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { + public GT_GUIContainer_4by4( + InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { super(new GT_Container_4by4(aInventoryPlayer, aTileEntity), RES_PATH_GUI + aBackground + "4by4.png"); mName = aName; } diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java index 338d9e14a2..35dcf047a7 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java @@ -1,27 +1,23 @@ package gregtech.api.gui; +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + import gregtech.api.enums.GT_Values; import gregtech.api.gui.widgets.GT_GuiIcon; +import gregtech.api.gui.widgets.GT_GuiSlotTooltip; +import gregtech.api.gui.widgets.GT_GuiSmartTooltip; +import gregtech.api.gui.widgets.GT_GuiSmartTooltip.TooltipVisibilityProvider; import gregtech.api.gui.widgets.GT_GuiTabLine.GT_GuiTabIconSet; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine_Steel; -import gregtech.api.gui.widgets.GT_GuiSlotTooltip; -import gregtech.api.gui.widgets.GT_GuiSmartTooltip; -import gregtech.api.gui.widgets.GT_GuiSmartTooltip.TooltipVisibilityProvider; -import gregtech.api.net.GT_Packet_SetConfigurationCircuit; -import gregtech.common.power.Power; -import gregtech.api.util.GT_Utility; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.common.power.Power; import gregtech.nei.NEI_TransferRectHost; +import java.awt.Rectangle; import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; -import java.awt.Rectangle; - -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; - /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! * <p/> @@ -32,45 +28,47 @@ import static gregtech.api.enums.GT_Values.RES_PATH_GUI; */ public class GT_GUIContainer_BasicMachine extends GT_GUIContainerMetaTile_Machine implements NEI_TransferRectHost { private static final int NEEDS_STEAM_VENTING = 64; - private final static GT_GuiTabIconSet TAB_ICONSET_BRONZE = new GT_GuiTabIconSet( - GT_GuiIcon.TAB_NORMAL_BRONZE, - GT_GuiIcon.TAB_HIGHLIGHT_BRONZE, - GT_GuiIcon.TAB_DISABLED_BRONZE); - private final static GT_GuiTabIconSet TAB_ICONSET_STEEL = new GT_GuiTabIconSet( - GT_GuiIcon.TAB_NORMAL_STEEL, - GT_GuiIcon.TAB_HIGHLIGHT_STEEL, - GT_GuiIcon.TAB_DISABLED_STEEL); + private static final GT_GuiTabIconSet TAB_ICONSET_BRONZE = new GT_GuiTabIconSet( + GT_GuiIcon.TAB_NORMAL_BRONZE, GT_GuiIcon.TAB_HIGHLIGHT_BRONZE, GT_GuiIcon.TAB_DISABLED_BRONZE); + private static final GT_GuiTabIconSet TAB_ICONSET_STEEL = new GT_GuiTabIconSet( + GT_GuiIcon.TAB_NORMAL_STEEL, GT_GuiIcon.TAB_HIGHLIGHT_STEEL, GT_GuiIcon.TAB_DISABLED_STEEL); private final int textColor = this.getTextColorOrDefault("title", 0x404040); - public final String - mName, - mNEI; - public final byte - mProgressBarDirection, - mProgressBarAmount; - + public final String mName, mNEI; + public final byte mProgressBarDirection, mProgressBarAmount; + // Tooltip localization keys - private static final String - BATTERY_SLOT_TOOLTIP = "GT5U.machines.battery_slot.tooltip", - BATTERY_SLOT_TOOLTIP_ALT = "GT5U.machines.battery_slot.tooltip.alternative", - UNUSED_SLOT_TOOLTIP = "GT5U.machines.unused_slot.tooltip", - SPECIAL_SLOT_TOOLTIP = "GT5U.machines.special_slot.tooltip", - FLUID_INPUT_TOOLTIP = "GT5U.machines.fluid_input_slot.tooltip", - FLUID_OUTPUT_TOOLTIP = "GT5U.machines.fluid_output_slot.tooltip", - STALLED_STUTTERING_TOOLTIP = "GT5U.machines.stalled_stuttering.tooltip", - STALLED_VENT_TOOLTIP = "GT5U.machines.stalled_vent.tooltip", - FLUID_TRANSFER_TOOLTIP = "GT5U.machines.fluid_transfer.tooltip", - ITEM_TRANSFER_TOOLTIP = "GT5U.machines.item_transfer.tooltip", - POWER_SOURCE_KEY = "GT5U.machines.powersource."; - - public GT_GUIContainer_BasicMachine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, - String aTextureFile, String aNEI) { + private static final String BATTERY_SLOT_TOOLTIP = "GT5U.machines.battery_slot.tooltip", + BATTERY_SLOT_TOOLTIP_ALT = "GT5U.machines.battery_slot.tooltip.alternative", + UNUSED_SLOT_TOOLTIP = "GT5U.machines.unused_slot.tooltip", + SPECIAL_SLOT_TOOLTIP = "GT5U.machines.special_slot.tooltip", + FLUID_INPUT_TOOLTIP = "GT5U.machines.fluid_input_slot.tooltip", + FLUID_OUTPUT_TOOLTIP = "GT5U.machines.fluid_output_slot.tooltip", + STALLED_STUTTERING_TOOLTIP = "GT5U.machines.stalled_stuttering.tooltip", + STALLED_VENT_TOOLTIP = "GT5U.machines.stalled_vent.tooltip", + FLUID_TRANSFER_TOOLTIP = "GT5U.machines.fluid_transfer.tooltip", + ITEM_TRANSFER_TOOLTIP = "GT5U.machines.item_transfer.tooltip", + POWER_SOURCE_KEY = "GT5U.machines.powersource."; + + public GT_GUIContainer_BasicMachine( + InventoryPlayer aInventoryPlayer, + IGregTechTileEntity aTileEntity, + String aName, + String aTextureFile, + String aNEI) { this(aInventoryPlayer, aTileEntity, aName, aTextureFile, aNEI, (byte) 0, (byte) 1); } - public GT_GUIContainer_BasicMachine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, - String aTextureFile, String aNEI, byte aProgressBarDirection, byte aProgressBarAmount) { - super(new GT_Container_BasicMachine(aInventoryPlayer, aTileEntity), - RES_PATH_GUI + "basicmachines/" + aTextureFile); + public GT_GUIContainer_BasicMachine( + InventoryPlayer aInventoryPlayer, + IGregTechTileEntity aTileEntity, + String aName, + String aTextureFile, + String aNEI, + byte aProgressBarDirection, + byte aProgressBarAmount) { + super( + new GT_Container_BasicMachine(aInventoryPlayer, aTileEntity), + RES_PATH_GUI + "basicmachines/" + aTextureFile); mProgressBarDirection = aProgressBarDirection; mProgressBarAmount = (byte) Math.max(1, aProgressBarAmount); mName = aName; @@ -92,11 +90,14 @@ public class GT_GUIContainer_BasicMachine extends GT_GUIContainerMetaTile_Machin if (machine.isSteampowered()) { batterySlotTooltipKey = UNUSED_SLOT_TOOLTIP; batterySlotTooltipArgs = new String[0]; - addToolTip(new GT_GuiSmartTooltip(tProblemArea, new TooltipVisibilityProvider() { - public boolean shouldShowTooltip() { - return hasErrorCode(NEEDS_STEAM_VENTING); - } - }, mTooltipCache.getData(STALLED_VENT_TOOLTIP))); + addToolTip(new GT_GuiSmartTooltip( + tProblemArea, + new TooltipVisibilityProvider() { + public boolean shouldShowTooltip() { + return hasErrorCode(NEEDS_STEAM_VENTING); + } + }, + mTooltipCache.getData(STALLED_VENT_TOOLTIP))); } else { String pTier1 = powerTierName(machine.mTier); if (machine.mTier == GT_Values.VN.length - 1) { @@ -106,29 +107,36 @@ public class GT_GUIContainer_BasicMachine extends GT_GUIContainerMetaTile_Machin batterySlotTooltipKey = BATTERY_SLOT_TOOLTIP; batterySlotTooltipArgs = new String[] {pTier1, powerTierName((byte) (machine.mTier + 1))}; } - addToolTip(new GT_GuiSlotTooltip( container.slotFluidTransferToggle, - mTooltipCache.getData(FLUID_TRANSFER_TOOLTIP))); - addToolTip(new GT_GuiSlotTooltip( container.slotItemTransferToggle, - mTooltipCache.getData(ITEM_TRANSFER_TOOLTIP))); - } + addToolTip(new GT_GuiSlotTooltip( + container.slotFluidTransferToggle, mTooltipCache.getData(FLUID_TRANSFER_TOOLTIP))); + addToolTip(new GT_GuiSlotTooltip( + container.slotItemTransferToggle, mTooltipCache.getData(ITEM_TRANSFER_TOOLTIP))); + } if (recipes != null && recipes.hasFluidInputs()) { - addToolTip(new GT_GuiSlotTooltip(container.slotFluidInput, - mTooltipCache.getData(FLUID_INPUT_TOOLTIP, machine.getCapacity()))); + addToolTip(new GT_GuiSlotTooltip( + container.slotFluidInput, mTooltipCache.getData(FLUID_INPUT_TOOLTIP, machine.getCapacity()))); } if (recipes != null && recipes.hasFluidOutputs()) { - addToolTip(new GT_GuiSlotTooltip(container.slotFluidOutput, - mTooltipCache.getData(FLUID_OUTPUT_TOOLTIP, machine.getCapacity()))); + addToolTip(new GT_GuiSlotTooltip( + container.slotFluidOutput, mTooltipCache.getData(FLUID_OUTPUT_TOOLTIP, machine.getCapacity()))); } - addToolTip( new GT_GuiSlotTooltip(getContainer().slotBattery, - mTooltipCache.getData(batterySlotTooltipKey, batterySlotTooltipArgs))); - addToolTip(new GT_GuiSlotTooltip(container.slotSpecial, mTooltipCache.getData( - recipes != null && recipes.usesSpecialSlot() ? SPECIAL_SLOT_TOOLTIP : UNUSED_SLOT_TOOLTIP))); - addToolTip(new GT_GuiSmartTooltip(tProblemArea, new TooltipVisibilityProvider() { + addToolTip(new GT_GuiSlotTooltip( + getContainer().slotBattery, mTooltipCache.getData(batterySlotTooltipKey, batterySlotTooltipArgs))); + addToolTip(new GT_GuiSlotTooltip( + container.slotSpecial, + mTooltipCache.getData( + recipes != null && recipes.usesSpecialSlot() ? SPECIAL_SLOT_TOOLTIP : UNUSED_SLOT_TOOLTIP))); + addToolTip(new GT_GuiSmartTooltip( + tProblemArea, + new TooltipVisibilityProvider() { public boolean shouldShowTooltip() { return container.mStuttering && !hasErrorCode(NEEDS_STEAM_VENTING); } - }, mTooltipCache.getData(STALLED_STUTTERING_TOOLTIP, StatCollector.translateToLocal( - POWER_SOURCE_KEY + (machine.isSteampowered() ? "steam" : "power"))))); + }, + mTooltipCache.getData( + STALLED_STUTTERING_TOOLTIP, + StatCollector.translateToLocal( + POWER_SOURCE_KEY + (machine.isSteampowered() ? "steam" : "power"))))); } /** @@ -158,19 +166,23 @@ public class GT_GUIContainer_BasicMachine extends GT_GUIContainerMetaTile_Machin drawTexturedModalRect(x, y, 0, 0, xSize, ySize); if (mContainer != null) { if (!getMachine().isSteampowered()) { - if (getContainer().mFluidTransfer) - drawTexturedModalRect(x + 7, y + 62, 176, 18, 18, 18); - if (getContainer().mItemTransfer) - drawTexturedModalRect(x + 25, y + 62, 176, 36, 18, 18); + if (getContainer().mFluidTransfer) drawTexturedModalRect(x + 7, y + 62, 176, 18, 18, 18); + if (getContainer().mItemTransfer) drawTexturedModalRect(x + 25, y + 62, 176, 36, 18, 18); } - if (getContainer().mStuttering) - drawTexturedModalRect(x + 79, y + 44, 176, 54, 18, 18); + if (getContainer().mStuttering) drawTexturedModalRect(x + 79, y + 44, 176, 54, 18, 18); if (mContainer.mMaxProgressTime > 0) { int tSize = mProgressBarDirection < 2 ? 20 : 18; - int tProgress = Math.max(1, Math.min(tSize * mProgressBarAmount, (mContainer.mProgressTime > 0 ? 1 : 0) - + mContainer.mProgressTime * tSize * mProgressBarAmount / mContainer.mMaxProgressTime)) - % (tSize + 1); + int tProgress = Math.max( + 1, + Math.min( + tSize * mProgressBarAmount, + (mContainer.mProgressTime > 0 ? 1 : 0) + + mContainer.mProgressTime + * tSize + * mProgressBarAmount + / mContainer.mMaxProgressTime)) + % (tSize + 1); switch (mProgressBarDirection) { // yes, my OCD was mad at me before I did the Tabs. case 0: @@ -210,7 +222,8 @@ public class GT_GUIContainer_BasicMachine extends GT_GUIContainerMetaTile_Machin protected GT_GuiTabIconSet getTabBackground() { if (getMachine().isSteampowered()) { return getMachine() instanceof GT_MetaTileEntity_BasicMachine_Steel - ? TAB_ICONSET_STEEL : TAB_ICONSET_BRONZE; + ? TAB_ICONSET_STEEL + : TAB_ICONSET_BRONZE; } return super.getTabBackground(); } @@ -243,7 +256,7 @@ public class GT_GUIContainer_BasicMachine extends GT_GUIContainerMetaTile_Machin @Override public Object[] getNeiTransferRectArgs() { - return new Object[]{getMachine().getPower()}; + return new Object[] {getMachine().getPower()}; } @Override diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicTank.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicTank.java index a24060aaa4..034525c338 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicTank.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicTank.java @@ -1,19 +1,18 @@ package gregtech.api.gui; +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.StatCollector; -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; - public class GT_GUIContainer_BasicTank extends GT_GUIContainerMetaTile_Machine { private final String mName; - private final int - textColor = this.getTextColorOrDefault("text", 0xFAFAFF), - textColorTitle = this.getTextColorOrDefault("title", 0x404040), - textColorValue = this.getTextColorOrDefault("value", 0xFAFAFF); + private final int textColor = this.getTextColorOrDefault("text", 0xFAFAFF), + textColorTitle = this.getTextColorOrDefault("title", 0x404040), + textColorValue = this.getTextColorOrDefault("value", 0xFAFAFF); public GT_GUIContainer_BasicTank(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { super(new GT_Container_BasicTank(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "BasicTank.png"); @@ -22,11 +21,16 @@ public class GT_GUIContainer_BasicTank extends GT_GUIContainerMetaTile_Machine { @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, textColorTitle); + fontRendererObj.drawString( + StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, textColorTitle); fontRendererObj.drawString(mName, 8, 6, textColorTitle); if (mContainer != null) { fontRendererObj.drawString("Liquid Amount", 10, 20, textColor); - fontRendererObj.drawString(GT_Utility.parseNumberToString(((GT_Container_BasicTank) mContainer).mContent), 10, 30, textColorValue); + fontRendererObj.drawString( + GT_Utility.parseNumberToString(((GT_Container_BasicTank) mContainer).mContent), + 10, + 30, + textColorValue); } } diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_MaintenanceHatch.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_MaintenanceHatch.java index fe3c47fa95..07ca031345 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_MaintenanceHatch.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_MaintenanceHatch.java @@ -1,15 +1,13 @@ package gregtech.api.gui; +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; - public class GT_GUIContainer_MaintenanceHatch extends GT_GUIContainerMetaTile_Machine { - private final int - textColor = this.getTextColorOrDefault("text", 0x404040), - textColorTitle = this.getTextColorOrDefault("title", 0x404040); - + private final int textColor = this.getTextColorOrDefault("text", 0x404040), + textColorTitle = this.getTextColorOrDefault("title", 0x404040); public GT_GUIContainer_MaintenanceHatch(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { super(new GT_Container_MaintenanceHatch(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "Maintenance.png"); diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_MultiMachine.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_MultiMachine.java index 69a3d26b2e..98268cd667 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_MultiMachine.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_MultiMachine.java @@ -1,5 +1,7 @@ package gregtech.api.gui; +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; @@ -9,9 +11,6 @@ import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeTurbin import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; - - /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! * <p/> @@ -22,12 +21,14 @@ import static gregtech.api.enums.GT_Values.RES_PATH_GUI; public class GT_GUIContainer_MultiMachine extends GT_GUIContainerMetaTile_Machine { String mName = ""; - private final int - textColor = this.getTextColorOrDefault("text", 0xFAFAFF), - textColorTitle = this.getTextColorOrDefault("title", 0xFAFAFF); - - public GT_GUIContainer_MultiMachine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aTextureFile) { - super(new GT_Container_MultiMachine(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "multimachines/" + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); + private final int textColor = this.getTextColorOrDefault("text", 0xFAFAFF), + textColorTitle = this.getTextColorOrDefault("title", 0xFAFAFF); + + public GT_GUIContainer_MultiMachine( + InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aTextureFile) { + super( + new GT_Container_MultiMachine(aInventoryPlayer, aTileEntity), + RES_PATH_GUI + "multimachines/" + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); mName = aName; } @@ -74,8 +75,9 @@ public class GT_GUIContainer_MultiMachine extends GT_GUIContainerMetaTile_Machin line_counter += 8; } - - if (mContainer != null) {//(mWrench ? 0 : 1) | (mScrewdriver ? 0 : 2) | (mSoftHammer ? 0 : 4) | (mHardHammer ? 0 : 8) | (mSolderingTool ? 0 : 16) | (mCrowbar ? 0 : 32) | (mMachine ? 0 : 64)); + if (mContainer + != null) { // (mWrench ? 0 : 1) | (mScrewdriver ? 0 : 2) | (mSoftHammer ? 0 : 4) | (mHardHammer ? 0 : 8) + // | (mSolderingTool ? 0 : 16) | (mCrowbar ? 0 : 32) | (mMachine ? 0 : 64)); if ((mContainer.mDisplayErrorCode & 1) != 0) { fontRendererObj.drawString(GT_Utility.trans("132", "Pipe is loose."), 10, line_counter, textColor); line_counter += 8; @@ -92,46 +94,60 @@ public class GT_GUIContainer_MultiMachine extends GT_GUIContainerMetaTile_Machin } if ((mContainer.mDisplayErrorCode & 8) != 0) { - fontRendererObj.drawString(GT_Utility.trans("135", "Platings are dented."), 10, line_counter, textColor); + fontRendererObj.drawString( + GT_Utility.trans("135", "Platings are dented."), 10, line_counter, textColor); line_counter += 8; } if ((mContainer.mDisplayErrorCode & 16) != 0) { - fontRendererObj.drawString(GT_Utility.trans("136", "Circuitry burned out."), 10, line_counter, textColor); + fontRendererObj.drawString( + GT_Utility.trans("136", "Circuitry burned out."), 10, line_counter, textColor); line_counter += 8; } if ((mContainer.mDisplayErrorCode & 32) != 0) { - fontRendererObj.drawString(GT_Utility.trans("137", "That doesn't belong there."), 10, line_counter, textColor); + fontRendererObj.drawString( + GT_Utility.trans("137", "That doesn't belong there."), 10, line_counter, textColor); line_counter += 8; } if ((mContainer.mDisplayErrorCode & 64) != 0) { - fontRendererObj.drawString(GT_Utility.trans("138", "Incomplete Structure."), 10, line_counter, textColor); + fontRendererObj.drawString( + GT_Utility.trans("138", "Incomplete Structure."), 10, line_counter, textColor); line_counter += 8; } if (mContainer.mDisplayErrorCode == 0) { if (mContainer.mActive == 0) { - fontRendererObj.drawString(GT_Utility.trans("139", "Hit with Soft Mallet"), 10, line_counter, textColor); + fontRendererObj.drawString( + GT_Utility.trans("139", "Hit with Soft Mallet"), 10, line_counter, textColor); line_counter += 8; - fontRendererObj.drawString(GT_Utility.trans("140", "to (re-)start the Machine"), 10, line_counter, textColor); + fontRendererObj.drawString( + GT_Utility.trans("140", "to (re-)start the Machine"), 10, line_counter, textColor); line_counter += 8; - fontRendererObj.drawString(GT_Utility.trans("141", "if it doesn't start."), 10, line_counter, textColor); + fontRendererObj.drawString( + GT_Utility.trans("141", "if it doesn't start."), 10, line_counter, textColor); line_counter += 8; } else { - fontRendererObj.drawString(GT_Utility.trans("142", "Running perfectly."), 10, line_counter, textColor); + fontRendererObj.drawString( + GT_Utility.trans("142", "Running perfectly."), 10, line_counter, textColor); line_counter += 8; } if (mContainer.mTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_DrillerBase) { ItemStack tItem = mContainer.mTileEntity.getMetaTileEntity().getStackInSlot(1); - if (tItem == null || !GT_Utility.areStacksEqual(tItem, GT_ModHandler.getIC2Item("miningPipe", 1L))) { - fontRendererObj.drawString(GT_Utility.trans("143", "Missing Mining Pipe"), 10, line_counter, textColor); + if (tItem == null + || !GT_Utility.areStacksEqual(tItem, GT_ModHandler.getIC2Item("miningPipe", 1L))) { + fontRendererObj.drawString( + GT_Utility.trans("143", "Missing Mining Pipe"), 10, line_counter, textColor); } } else if (mContainer.mTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine) { ItemStack tItem = mContainer.mTileEntity.getMetaTileEntity().getStackInSlot(1); - if (tItem == null || !(tItem.getItem() == GT_MetaGenerated_Tool_01.INSTANCE && tItem.getItemDamage() >= 170 && tItem.getItemDamage() <= 177)) { - fontRendererObj.drawString(GT_Utility.trans("144", "Missing Turbine Rotor"), 10, line_counter, textColor); + if (tItem == null + || !(tItem.getItem() == GT_MetaGenerated_Tool_01.INSTANCE + && tItem.getItemDamage() >= 170 + && tItem.getItemDamage() <= 177)) { + fontRendererObj.drawString( + GT_Utility.trans("144", "Missing Turbine Rotor"), 10, line_counter, textColor); } } } diff --git a/src/main/java/gregtech/api/gui/GT_GUICover.java b/src/main/java/gregtech/api/gui/GT_GUICover.java index 4f61c95dd3..635a27d6ef 100644 --- a/src/main/java/gregtech/api/gui/GT_GUICover.java +++ b/src/main/java/gregtech/api/gui/GT_GUICover.java @@ -31,19 +31,18 @@ public abstract class GT_GUICover extends GT_GUIScreen { public void setParentGuiId(int parentGuiId) { this.parentGuiId = parentGuiId; } - @Override public void closeScreen() { // If this cover was given a guiId, tell the server to open it for us when this GUI closes. if (parentGuiId != -1 && tile.isUseableByPlayer(mc.thePlayer)) { GT_Values.NW.sendToServer(new GT_Packet_GtTileEntityGuiRequest( - tile.getXCoord(), - tile.getYCoord(), - tile.getZCoord(), - parentGuiId, - tile.getWorld().provider.dimensionId, - mc.thePlayer.getEntityId())); + tile.getXCoord(), + tile.getYCoord(), + tile.getZCoord(), + parentGuiId, + tile.getWorld().provider.dimensionId, + mc.thePlayer.getEntityId())); } else { this.mc.displayGuiScreen(null); this.mc.setIngameFocus(); diff --git a/src/main/java/gregtech/api/gui/GT_GUIDialogSelectItem.java b/src/main/java/gregtech/api/gui/GT_GUIDialogSelectItem.java index 0aec243967..c077b02bf7 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIDialogSelectItem.java +++ b/src/main/java/gregtech/api/gui/GT_GUIDialogSelectItem.java @@ -4,215 +4,227 @@ import gregtech.api.gui.widgets.GT_GuiFakeItemButton; import gregtech.api.gui.widgets.GT_GuiIcon; import gregtech.api.gui.widgets.GT_GuiIconButton; import gregtech.api.util.GT_Utility; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Consumer; - public class GT_GUIDialogSelectItem extends GT_GUIScreen { - public static final int UNSELECTED = -1; - private static final int cols = 9; - private static final int rows = 3; - private final int textColor = this.getTextColorOrDefault("text",0xff555555); - private final GuiScreen parent; - private final Consumer<ItemStack> selectedCallback; - // passed in stack - private final List<ItemStack> stacks; - // all slots not including btnCurrent - private final List<GT_GuiFakeItemButton> slots = new ArrayList<>(); - // the currently selected slot content - private final GT_GuiFakeItemButton btnCurrent = new GT_GuiFakeItemButton(this, 8, 25, GT_GuiIcon.SLOT_DARKGRAY).setMimicSlot(true); - private final boolean noDeselect; - private int selected; - private int scroll = 0; - private GT_GuiIconButton btnUp; - private GT_GuiIconButton btnDown; - - - public GT_GUIDialogSelectItem(String header, ItemStack headerItem, GuiScreen parent, Consumer<ItemStack> selectedCallback, List<ItemStack> stacks) { - this(header, headerItem, parent, selectedCallback, stacks, UNSELECTED); - } - - public GT_GUIDialogSelectItem(String header, ItemStack headerItem, GuiScreen parent, Consumer<ItemStack> selectedCallback, List<ItemStack> stacks, int selected) { - this(header, headerItem, parent, selectedCallback, stacks, selected, false); - } - - /** - * Open a dialog to select an item from given list. Given callback may be called zero or more times depending on user action. - * @param header Header text - * @param headerItem ItemStack to use as Dialog icon - * @param parent open which GUIScreen when this dialog is closed. use null if it has no parent. - * @param selectedCallback callback upon selected - * @param stacks list to choose from - * @param selected preselected item. Use {@link #UNSELECTED} for unselected. Invalid selected will be clamped to 0 or highest index - * @param noDeselect true if player cannot deselect, false otherwise. If this is set to true, selectedCallback is guaranteed to be called with a nonnull stack - */ - public GT_GUIDialogSelectItem(String header, ItemStack headerItem, GuiScreen parent, Consumer<ItemStack> selectedCallback, List<ItemStack> stacks, int selected, boolean noDeselect) { - super(176, 107, header); - this.noDeselect = noDeselect; - if (headerItem != null) - this.headerIcon.setItem(headerItem); - this.parent = parent; - this.selectedCallback = selectedCallback; - this.stacks = stacks; - - if (stacks.size() > rows * cols) { - btnUp = new GT_GuiIconButton(this, 0, 134, 25, GT_GuiIcon.GREEN_ARROW_UP); - btnDown = new GT_GuiIconButton(this, 1, 152, 25, GT_GuiIcon.GREEN_ARROW_DOWN); - } - - for (int i = 0; i < rows; i++) { - for (int j = 0; j < cols; j++) { - slots.add(new GT_GuiFakeItemButton(this, 8 + 18 * j, 44 + 18 * i, GT_GuiIcon.SLOT_GRAY).setMimicSlot(true)); - } - } - - setSelected(noDeselect ? Math.max(0, selected) : selected); - ensureSelectedDisplayed(); - } - - @Override - protected void onInitGui(int guiLeft, int guiTop, int gui_width, int gui_height) { - btnCurrent.setX(8 + 2 + fontRendererObj.getStringWidth(StatCollector.translateToLocal("GT5U.gui.select.current"))); - } - - @Override - public void closeScreen() { - selectedCallback.accept(getCandidate(getSelected())); - mc.displayGuiScreen(parent); - if (parent == null) - mc.setIngameFocus(); - } - - @Override - public void buttonClicked(GuiButton button) { - switch (button.id) { - case 0: - setScroll(scroll - 1); - return; - case 1: - setScroll(scroll + 1); - return; - } - super.buttonClicked(button); - } - - @Override - public void drawExtras(int mouseX, int mouseY, float parTicks) { - int y = 25 + (18 - getFontRenderer().FONT_HEIGHT) / 2; - getFontRenderer().drawString(StatCollector.translateToLocal("GT5U.gui.select.current"), 8, y, textColor); - super.drawExtras(mouseX, mouseY, parTicks); - } - - @Override - public void mouseClicked(int x, int y, int button) { - int mx = x - guiLeft, my = y - guiTop; - if (button == 0) { - if (btnCurrent.getBounds().contains(mx, my)) { - ensureSelectedDisplayed(); - return; - } - - for (int i = 0, slotsSize = slots.size(); i < slotsSize; i++) { - GT_GuiFakeItemButton slot = slots.get(i); - if (slot.getBounds().contains(mx, my)) { - setSelected(slotIndexToListIndex(i)); - return; - } - } - } else if (button == 1 && getSelected() >= 0) { - if (btnCurrent.getBounds().contains(mx, my)) { - setSelected(UNSELECTED); - return; - } - GT_GuiFakeItemButton slot = getSlot(listIndexToSlotIndex(getSelected())); - if (slot != null && slot.getBounds().contains(mx, my)) { - setSelected(UNSELECTED); - } - } - super.mouseClicked(x, y, button); - } - - @Override - public void onMouseWheel(int x, int y, int delta) { - if (delta < 0) - setScroll(scroll + 1); - else if (delta > 0) - setScroll(scroll - 1); - } - - private void fillSlots() { - for (int i = 0, j = scroll * cols; i < slots.size(); i++, j++) { - slots.get(i) - .setItem(getCandidate(j)) - .setBgIcon(j == getSelected() ? GT_GuiIcon.SLOT_DARKGRAY : GT_GuiIcon.SLOT_GRAY); - } - } - - private void ensureSelectedDisplayed() { - if (getSelected() < scroll * cols) { - setScroll(getSelected() / cols); - } else if (getSelected() > (scroll + rows) * cols) { - setScroll((getSelected() - (rows - 1) * cols) / cols); - } else { - // called nonetheless to update button enabled states - setScroll(scroll); - } - } - - private int slotIndexToListIndex(int index) { - int mapped = scroll * cols + index; - return mapped >= stacks.size() ? UNSELECTED : mapped; - } - - private int listIndexToSlotIndex(int index) { - return index - scroll * cols; - } - - public int getSelected() { - return selected; - } - - public void setSelected(int selected) { - if (selected == this.selected) return; - int newSelected = GT_Utility.clamp(selected, UNSELECTED, stacks.size() - 1); - - if (noDeselect && newSelected == UNSELECTED) - return; - - GT_GuiFakeItemButton selectedSlot = getSlot(this.selected); - if (selectedSlot != null) - selectedSlot.setBgIcon(GT_GuiIcon.SLOT_GRAY); - - this.selected = newSelected; - - btnCurrent.setItem(getCandidate(this.selected)); - - selectedSlot = getSlot(this.selected); - if (selectedSlot != null) - selectedSlot.setBgIcon(GT_GuiIcon.SLOT_DARKGRAY); - } - - private void setScroll(int scroll) { - if (stacks.size() > rows * cols) { - int lo = 0; - int hi = (stacks.size() - rows * cols) / cols + 1; - this.scroll = GT_Utility.clamp(scroll, lo, hi); - btnUp.enabled = this.scroll != lo; - btnDown.enabled = this.scroll != hi; - } - fillSlots(); - } - - private ItemStack getCandidate(int listIndex) { - return listIndex < 0 || listIndex >= stacks.size() ? null : stacks.get(listIndex); - } - - private GT_GuiFakeItemButton getSlot(int slotIndex) { - return slotIndex < 0 || slotIndex >= slots.size() ? null : slots.get(slotIndex); - } + public static final int UNSELECTED = -1; + private static final int cols = 9; + private static final int rows = 3; + private final int textColor = this.getTextColorOrDefault("text", 0xff555555); + private final GuiScreen parent; + private final Consumer<ItemStack> selectedCallback; + // passed in stack + private final List<ItemStack> stacks; + // all slots not including btnCurrent + private final List<GT_GuiFakeItemButton> slots = new ArrayList<>(); + // the currently selected slot content + private final GT_GuiFakeItemButton btnCurrent = + new GT_GuiFakeItemButton(this, 8, 25, GT_GuiIcon.SLOT_DARKGRAY).setMimicSlot(true); + private final boolean noDeselect; + private int selected; + private int scroll = 0; + private GT_GuiIconButton btnUp; + private GT_GuiIconButton btnDown; + + public GT_GUIDialogSelectItem( + String header, + ItemStack headerItem, + GuiScreen parent, + Consumer<ItemStack> selectedCallback, + List<ItemStack> stacks) { + this(header, headerItem, parent, selectedCallback, stacks, UNSELECTED); + } + + public GT_GUIDialogSelectItem( + String header, + ItemStack headerItem, + GuiScreen parent, + Consumer<ItemStack> selectedCallback, + List<ItemStack> stacks, + int selected) { + this(header, headerItem, parent, selectedCallback, stacks, selected, false); + } + + /** + * Open a dialog to select an item from given list. Given callback may be called zero or more times depending on user action. + * @param header Header text + * @param headerItem ItemStack to use as Dialog icon + * @param parent open which GUIScreen when this dialog is closed. use null if it has no parent. + * @param selectedCallback callback upon selected + * @param stacks list to choose from + * @param selected preselected item. Use {@link #UNSELECTED} for unselected. Invalid selected will be clamped to 0 or highest index + * @param noDeselect true if player cannot deselect, false otherwise. If this is set to true, selectedCallback is guaranteed to be called with a nonnull stack + */ + public GT_GUIDialogSelectItem( + String header, + ItemStack headerItem, + GuiScreen parent, + Consumer<ItemStack> selectedCallback, + List<ItemStack> stacks, + int selected, + boolean noDeselect) { + super(176, 107, header); + this.noDeselect = noDeselect; + if (headerItem != null) this.headerIcon.setItem(headerItem); + this.parent = parent; + this.selectedCallback = selectedCallback; + this.stacks = stacks; + + if (stacks.size() > rows * cols) { + btnUp = new GT_GuiIconButton(this, 0, 134, 25, GT_GuiIcon.GREEN_ARROW_UP); + btnDown = new GT_GuiIconButton(this, 1, 152, 25, GT_GuiIcon.GREEN_ARROW_DOWN); + } + + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + slots.add(new GT_GuiFakeItemButton(this, 8 + 18 * j, 44 + 18 * i, GT_GuiIcon.SLOT_GRAY) + .setMimicSlot(true)); + } + } + + setSelected(noDeselect ? Math.max(0, selected) : selected); + ensureSelectedDisplayed(); + } + + @Override + protected void onInitGui(int guiLeft, int guiTop, int gui_width, int gui_height) { + btnCurrent.setX( + 8 + 2 + fontRendererObj.getStringWidth(StatCollector.translateToLocal("GT5U.gui.select.current"))); + } + + @Override + public void closeScreen() { + selectedCallback.accept(getCandidate(getSelected())); + mc.displayGuiScreen(parent); + if (parent == null) mc.setIngameFocus(); + } + + @Override + public void buttonClicked(GuiButton button) { + switch (button.id) { + case 0: + setScroll(scroll - 1); + return; + case 1: + setScroll(scroll + 1); + return; + } + super.buttonClicked(button); + } + + @Override + public void drawExtras(int mouseX, int mouseY, float parTicks) { + int y = 25 + (18 - getFontRenderer().FONT_HEIGHT) / 2; + getFontRenderer().drawString(StatCollector.translateToLocal("GT5U.gui.select.current"), 8, y, textColor); + super.drawExtras(mouseX, mouseY, parTicks); + } + + @Override + public void mouseClicked(int x, int y, int button) { + int mx = x - guiLeft, my = y - guiTop; + if (button == 0) { + if (btnCurrent.getBounds().contains(mx, my)) { + ensureSelectedDisplayed(); + return; + } + + for (int i = 0, slotsSize = slots.size(); i < slotsSize; i++) { + GT_GuiFakeItemButton slot = slots.get(i); + if (slot.getBounds().contains(mx, my)) { + setSelected(slotIndexToListIndex(i)); + return; + } + } + } else if (button == 1 && getSelected() >= 0) { + if (btnCurrent.getBounds().contains(mx, my)) { + setSelected(UNSELECTED); + return; + } + GT_GuiFakeItemButton slot = getSlot(listIndexToSlotIndex(getSelected())); + if (slot != null && slot.getBounds().contains(mx, my)) { + setSelected(UNSELECTED); + } + } + super.mouseClicked(x, y, button); + } + + @Override + public void onMouseWheel(int x, int y, int delta) { + if (delta < 0) setScroll(scroll + 1); + else if (delta > 0) setScroll(scroll - 1); + } + + private void fillSlots() { + for (int i = 0, j = scroll * cols; i < slots.size(); i++, j++) { + slots.get(i) + .setItem(getCandidate(j)) + .setBgIcon(j == getSelected() ? GT_GuiIcon.SLOT_DARKGRAY : GT_GuiIcon.SLOT_GRAY); + } + } + + private void ensureSelectedDisplayed() { + if (getSelected() < scroll * cols) { + setScroll(getSelected() / cols); + } else if (getSelected() > (scroll + rows) * cols) { + setScroll((getSelected() - (rows - 1) * cols) / cols); + } else { + // called nonetheless to update button enabled states + setScroll(scroll); + } + } + + private int slotIndexToListIndex(int index) { + int mapped = scroll * cols + index; + return mapped >= stacks.size() ? UNSELECTED : mapped; + } + + private int listIndexToSlotIndex(int index) { + return index - scroll * cols; + } + + public int getSelected() { + return selected; + } + + public void setSelected(int selected) { + if (selected == this.selected) return; + int newSelected = GT_Utility.clamp(selected, UNSELECTED, stacks.size() - 1); + + if (noDeselect && newSelected == UNSELECTED) return; + + GT_GuiFakeItemButton selectedSlot = getSlot(this.selected); + if (selectedSlot != null) selectedSlot.setBgIcon(GT_GuiIcon.SLOT_GRAY); + + this.selected = newSelected; + + btnCurrent.setItem(getCandidate(this.selected)); + + selectedSlot = getSlot(this.selected); + if (selectedSlot != null) selectedSlot.setBgIcon(GT_GuiIcon.SLOT_DARKGRAY); + } + + private void setScroll(int scroll) { + if (stacks.size() > rows * cols) { + int lo = 0; + int hi = (stacks.size() - rows * cols) / cols + 1; + this.scroll = GT_Utility.clamp(scroll, lo, hi); + btnUp.enabled = this.scroll != lo; + btnDown.enabled = this.scroll != hi; + } + fillSlots(); + } + + private ItemStack getCandidate(int listIndex) { + return listIndex < 0 || listIndex >= stacks.size() ? null : stacks.get(listIndex); + } + + private GT_GuiFakeItemButton getSlot(int slotIndex) { + return slotIndex < 0 || slotIndex >= slots.size() ? null : slots.get(slotIndex); + } } diff --git a/src/main/java/gregtech/api/gui/GT_GUIScreen.java b/src/main/java/gregtech/api/gui/GT_GUIScreen.java index 1efaddea35..281be1e55d 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIScreen.java +++ b/src/main/java/gregtech/api/gui/GT_GUIScreen.java @@ -1,13 +1,14 @@ package gregtech.api.gui; import gregtech.api.enums.Dyes; -import gregtech.api.gui.GT_GUIColorOverride; import gregtech.api.gui.widgets.GT_GuiFakeItemButton; import gregtech.api.gui.widgets.GT_GuiIntegerTextBox; import gregtech.api.gui.widgets.GT_GuiTooltip; import gregtech.api.gui.widgets.GT_GuiTooltipManager; import gregtech.api.gui.widgets.GT_GuiTooltipManager.GT_IToolTipRenderer; import gregtech.api.interfaces.IGuiScreen; +import java.util.ArrayList; +import java.util.List; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; @@ -19,316 +20,305 @@ import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - public abstract class GT_GUIScreen extends GuiScreen implements GT_IToolTipRenderer, IGuiScreen { - protected GT_GuiTooltipManager ttManager = new GT_GuiTooltipManager(); + protected GT_GuiTooltipManager ttManager = new GT_GuiTooltipManager(); - protected int gui_width = 176; - protected int gui_height = 107; - protected int guiTop, guiLeft; - protected boolean drawButtons = true; + protected int gui_width = 176; + protected int gui_height = 107; + protected int guiTop, guiLeft; + protected boolean drawButtons = true; private ResourceLocation mGUIbackgroundLocation; - private GuiButton selectedButton; + private GuiButton selectedButton; private GT_GUIColorOverride colorOverride; private final int textColor; - private final static String guiTexturePath = "gregtech:textures/gui/GuiCover.png"; + private static final String guiTexturePath = "gregtech:textures/gui/GuiCover.png"; - public String header; - public GT_GuiFakeItemButton headerIcon; + public String header; + public GT_GuiFakeItemButton headerIcon; - protected List<IGuiElement> elements = new ArrayList<>(); - protected List<GT_GuiIntegerTextBox> textBoxes = new ArrayList<>(); + protected List<IGuiElement> elements = new ArrayList<>(); + protected List<GT_GuiIntegerTextBox> textBoxes = new ArrayList<>(); - public GT_GUIScreen(int width, int height, String header) { + public GT_GUIScreen(int width, int height, String header) { this.gui_width = width; - this.gui_height = height; - this.header = header; - this.headerIcon = new GT_GuiFakeItemButton(this, 5, 5, null); + this.gui_height = height; + this.header = header; + this.headerIcon = new GT_GuiFakeItemButton(this, 5, 5, null); this.mGUIbackgroundLocation = new ResourceLocation(guiTexturePath); this.colorOverride = new GT_GUIColorOverride(guiTexturePath); this.textColor = getTextColorOrDefault("title", 0xFF222222); - } + } - @Override - public void initGui() { - guiLeft = (this.width - this.gui_width) / 2; - guiTop = (this.height - this.gui_height) / 2; + @Override + public void initGui() { + guiLeft = (this.width - this.gui_width) / 2; + guiTop = (this.height - this.gui_height) / 2; - for (IGuiElement element : elements) { - if (element instanceof GuiButton) - buttonList.add(element); - if (element instanceof GT_GuiIntegerTextBox) - textBoxes.add((GT_GuiIntegerTextBox) element); - } + for (IGuiElement element : elements) { + if (element instanceof GuiButton) buttonList.add(element); + if (element instanceof GT_GuiIntegerTextBox) textBoxes.add((GT_GuiIntegerTextBox) element); + } - onInitGui(guiLeft, guiTop, gui_width, gui_height); + onInitGui(guiLeft, guiTop, gui_width, gui_height); - for (IGuiElement element : elements) { - element.onInit(); - } - super.initGui(); - } + for (IGuiElement element : elements) { + element.onInit(); + } + super.initGui(); + } - protected abstract void onInitGui(int guiLeft, int guiTop, int gui_width, int gui_height); + protected abstract void onInitGui(int guiLeft, int guiTop, int gui_width, int gui_height); protected int getTextColorOrDefault(String textType, int defaultColor) { return colorOverride.getTextColorOrDefault(textType, defaultColor); } - public void onMouseWheel(int x, int y, int delta) { - } - - @Override - public void handleMouseInput() { - int delta = Mouse.getEventDWheel(); - if (delta != 0) { - int i = Mouse.getEventX() * this.width / this.mc.displayWidth; - int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; - onMouseWheel(i, j, delta); - } - super.handleMouseInput(); - } - - @Override - public void drawScreen(int mouseX, int mouseY, float parTicks) { - drawDefaultBackground(); - - drawBackground(mouseX, mouseY, parTicks); - - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - if (drawButtons) { - RenderHelper.enableGUIStandardItemLighting(); - for (IGuiElement e : elements) - e.draw(mouseX, mouseY, parTicks); - } - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - - GL11.glPushMatrix(); - GL11.glTranslatef(guiLeft, guiTop, 0.0F); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - - GL11.glDisable(GL11.GL_LIGHTING); - drawForegroundLayer(mouseX, mouseY, parTicks); - GL11.glEnable(GL11.GL_LIGHTING); - - GL11.glPopMatrix(); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - RenderHelper.enableStandardItemLighting(); - } - - public void drawForegroundLayer(int mouseX, int mouseY, float parTicks) { - drawExtras(mouseX, mouseY, parTicks); - ttManager.onTick(this, mouseX, mouseY); - } - - public void drawBackground(int mouseX, int mouseY, float parTicks) { - short[] color = Dyes.MACHINE_METAL.getRGBA(); - GL11.glColor3ub((byte) color[0], (byte) color[1], (byte) color[2]); - this.mc.renderEngine.bindTexture(mGUIbackgroundLocation); - drawTexturedModalRect(guiLeft, guiTop, 0,0, gui_width, gui_height); - } - - public void drawExtras(int mouseX, int mouseY, float parTicks) { - this.fontRendererObj.drawString(header, 25, 9, textColor); - } - - @Override - public boolean doesGuiPauseGame() - { - return false; - } - - public void closeScreen() { - this.mc.displayGuiScreen(null); - this.mc.setIngameFocus(); - } - - @Override - public void updateScreen() { - super.updateScreen(); - for (GuiTextField f : textBoxes) { - f.updateCursorCounter(); - } - } - - @Override - public void mouseClicked(int x, int y, int button) { - for (GT_GuiIntegerTextBox tBox : textBoxes) { - boolean hadFocus = tBox.isFocused(); - if (tBox.isEnabled() || hadFocus) - tBox.mouseClicked(x,y,button); - - if (tBox.isFocused() && button == 1 && tBox.isEnabled()) //rightclick -> lcear it - tBox.setText("0"); - else if (hadFocus && !tBox.isFocused()) - applyTextBox(tBox); - } - super.mouseClicked(x, y, button); - } - - @Override - public void keyTyped(char c, int key) { - GT_GuiIntegerTextBox focusedTextBox = null; - for (GT_GuiIntegerTextBox textBox : textBoxes) { - if (textBox.isFocused()) - focusedTextBox = textBox; - } - - if (key == 1) { //esc - if(focusedTextBox != null) { - resetTextBox(focusedTextBox); - setFocusedTextBox(null); - return; - } else { - closeScreen(); - // don't fall through to parent - return; - } - } - - if (c == '\t') { //tab - for (int i = 0; i < textBoxes.size(); i++) { - GT_GuiIntegerTextBox box = textBoxes.get(i); - if (box.isFocused()) { - applyTextBox(box); - setFocusedTextBox(((i+1) < textBoxes.size()) ? textBoxes.get(i+1) : null); - return; - } - } - if (!textBoxes.isEmpty()) - setFocusedTextBox(textBoxes.get(0)); - return; - } - - if (focusedTextBox != null && focusedTextBox.textboxKeyTyped(c, key)){ - return; - } - - if (key == 28 && focusedTextBox != null) { // enter - applyTextBox(focusedTextBox); - setFocusedTextBox(null); - return; - } - - if (key == this.mc.gameSettings.keyBindInventory.getKeyCode()) { - if (focusedTextBox != null) { - applyTextBox(focusedTextBox); - setFocusedTextBox(null); - return; - } - closeScreen(); - return; - } - super.keyTyped(c, key); - } - - /** - * Button - */ - - @Override - public void actionPerformed(GuiButton button) { - selectedButton = button; - } - - @Override - public void clearSelectedButton() { - selectedButton = null; - } - @Override - public GuiButton getSelectedButton(){return selectedButton;} - - @Override - public void buttonClicked(GuiButton button) { - - } - - /** - * TextBoxes - */ - private void setFocusedTextBox(GT_GuiIntegerTextBox boxToFocus) { - for (GT_GuiIntegerTextBox textBox : textBoxes) { - textBox.setFocused(textBox.equals(boxToFocus) && textBox.isEnabled()); - } - } - - /** - * Given textbox's value might have changed. - */ - public void applyTextBox(GT_GuiIntegerTextBox box) { - - } - - /** - * Reset the given textbox to the last valid value, <b>NOT</b> 0. - */ - public void resetTextBox(GT_GuiIntegerTextBox box) { - - } - - /** - * GT_IToolTipRenderer - */ - @Override - public void drawHoveringText(List text, int mouseX, int mouseY, FontRenderer render) { - super.drawHoveringText(text, mouseX, mouseY, render); - } - @Override - public FontRenderer getFontRenderer() { - return super.fontRendererObj; - } - @Override - public void addToolTip(GT_GuiTooltip toolTip) { - ttManager.addToolTip(toolTip); - } - @Override - public boolean removeToolTip(GT_GuiTooltip toolTip) { - return ttManager.removeToolTip(toolTip); - } - - /** - * Junk - */ - @Override - public int getGuiTop() { - return guiTop; - } - @Override - public int getGuiLeft() { - return guiLeft; - } - @Override - public int getXSize() { - return gui_width; - } - @Override - public int getYSize() { - return gui_height; - } - - @Override - public RenderItem getItemRenderer() { - return itemRender; - } - - @Override - public void addElement(IGuiElement element) { - if (elements.contains(element)) - return; - elements.add(element); - } - @Override - public boolean removeElement(IGuiElement element) { - return elements.remove(element); - } + public void onMouseWheel(int x, int y, int delta) {} + + @Override + public void handleMouseInput() { + int delta = Mouse.getEventDWheel(); + if (delta != 0) { + int i = Mouse.getEventX() * this.width / this.mc.displayWidth; + int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; + onMouseWheel(i, j, delta); + } + super.handleMouseInput(); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float parTicks) { + drawDefaultBackground(); + + drawBackground(mouseX, mouseY, parTicks); + + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + if (drawButtons) { + RenderHelper.enableGUIStandardItemLighting(); + for (IGuiElement e : elements) e.draw(mouseX, mouseY, parTicks); + } + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + + GL11.glPushMatrix(); + GL11.glTranslatef(guiLeft, guiTop, 0.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + GL11.glDisable(GL11.GL_LIGHTING); + drawForegroundLayer(mouseX, mouseY, parTicks); + GL11.glEnable(GL11.GL_LIGHTING); + + GL11.glPopMatrix(); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + RenderHelper.enableStandardItemLighting(); + } + + public void drawForegroundLayer(int mouseX, int mouseY, float parTicks) { + drawExtras(mouseX, mouseY, parTicks); + ttManager.onTick(this, mouseX, mouseY); + } + + public void drawBackground(int mouseX, int mouseY, float parTicks) { + short[] color = Dyes.MACHINE_METAL.getRGBA(); + GL11.glColor3ub((byte) color[0], (byte) color[1], (byte) color[2]); + this.mc.renderEngine.bindTexture(mGUIbackgroundLocation); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, gui_width, gui_height); + } + + public void drawExtras(int mouseX, int mouseY, float parTicks) { + this.fontRendererObj.drawString(header, 25, 9, textColor); + } + + @Override + public boolean doesGuiPauseGame() { + return false; + } + + public void closeScreen() { + this.mc.displayGuiScreen(null); + this.mc.setIngameFocus(); + } + + @Override + public void updateScreen() { + super.updateScreen(); + for (GuiTextField f : textBoxes) { + f.updateCursorCounter(); + } + } + + @Override + public void mouseClicked(int x, int y, int button) { + for (GT_GuiIntegerTextBox tBox : textBoxes) { + boolean hadFocus = tBox.isFocused(); + if (tBox.isEnabled() || hadFocus) tBox.mouseClicked(x, y, button); + + if (tBox.isFocused() && button == 1 && tBox.isEnabled()) // rightclick -> lcear it + tBox.setText("0"); + else if (hadFocus && !tBox.isFocused()) applyTextBox(tBox); + } + super.mouseClicked(x, y, button); + } + + @Override + public void keyTyped(char c, int key) { + GT_GuiIntegerTextBox focusedTextBox = null; + for (GT_GuiIntegerTextBox textBox : textBoxes) { + if (textBox.isFocused()) focusedTextBox = textBox; + } + + if (key == 1) { // esc + if (focusedTextBox != null) { + resetTextBox(focusedTextBox); + setFocusedTextBox(null); + return; + } else { + closeScreen(); + // don't fall through to parent + return; + } + } + + if (c == '\t') { // tab + for (int i = 0; i < textBoxes.size(); i++) { + GT_GuiIntegerTextBox box = textBoxes.get(i); + if (box.isFocused()) { + applyTextBox(box); + setFocusedTextBox(((i + 1) < textBoxes.size()) ? textBoxes.get(i + 1) : null); + return; + } + } + if (!textBoxes.isEmpty()) setFocusedTextBox(textBoxes.get(0)); + return; + } + + if (focusedTextBox != null && focusedTextBox.textboxKeyTyped(c, key)) { + return; + } + + if (key == 28 && focusedTextBox != null) { // enter + applyTextBox(focusedTextBox); + setFocusedTextBox(null); + return; + } + + if (key == this.mc.gameSettings.keyBindInventory.getKeyCode()) { + if (focusedTextBox != null) { + applyTextBox(focusedTextBox); + setFocusedTextBox(null); + return; + } + closeScreen(); + return; + } + super.keyTyped(c, key); + } + + /** + * Button + */ + @Override + public void actionPerformed(GuiButton button) { + selectedButton = button; + } + + @Override + public void clearSelectedButton() { + selectedButton = null; + } + + @Override + public GuiButton getSelectedButton() { + return selectedButton; + } + + @Override + public void buttonClicked(GuiButton button) {} + + /** + * TextBoxes + */ + private void setFocusedTextBox(GT_GuiIntegerTextBox boxToFocus) { + for (GT_GuiIntegerTextBox textBox : textBoxes) { + textBox.setFocused(textBox.equals(boxToFocus) && textBox.isEnabled()); + } + } + + /** + * Given textbox's value might have changed. + */ + public void applyTextBox(GT_GuiIntegerTextBox box) {} + + /** + * Reset the given textbox to the last valid value, <b>NOT</b> 0. + */ + public void resetTextBox(GT_GuiIntegerTextBox box) {} + + /** + * GT_IToolTipRenderer + */ + @Override + public void drawHoveringText(List text, int mouseX, int mouseY, FontRenderer render) { + super.drawHoveringText(text, mouseX, mouseY, render); + } + + @Override + public FontRenderer getFontRenderer() { + return super.fontRendererObj; + } + + @Override + public void addToolTip(GT_GuiTooltip toolTip) { + ttManager.addToolTip(toolTip); + } + + @Override + public boolean removeToolTip(GT_GuiTooltip toolTip) { + return ttManager.removeToolTip(toolTip); + } + + /** + * Junk + */ + @Override + public int getGuiTop() { + return guiTop; + } + + @Override + public int getGuiLeft() { + return guiLeft; + } + + @Override + public int getXSize() { + return gui_width; + } + + @Override + public int getYSize() { + return gui_height; + } + + @Override + public RenderItem getItemRenderer() { + return itemRender; + } + + @Override + public void addElement(IGuiElement element) { + if (elements.contains(element)) return; + elements.add(element); + } + + @Override + public boolean removeElement(IGuiElement element) { + return elements.remove(element); + } } diff --git a/src/main/java/gregtech/api/gui/GT_Slot_Holo.java b/src/main/java/gregtech/api/gui/GT_Slot_Holo.java index ea1b8b82f8..bf5f8886b3 100644 --- a/src/main/java/gregtech/api/gui/GT_Slot_Holo.java +++ b/src/main/java/gregtech/api/gui/GT_Slot_Holo.java @@ -10,12 +10,17 @@ import net.minecraft.item.ItemStack; public class GT_Slot_Holo extends Slot { public final int mSlotIndex; public boolean mEnabled = true; - public boolean - mCanInsertItem, - mCanStackItem; + public boolean mCanInsertItem, mCanStackItem; public int mMaxStacksize = 127; - public GT_Slot_Holo(IInventory inventory, int slotIndex, int xPos, int yPos, boolean aCanInsertItem, boolean aCanStackItem, int aMaxStacksize) { + public GT_Slot_Holo( + IInventory inventory, + int slotIndex, + int xPos, + int yPos, + boolean aCanInsertItem, + boolean aCanStackItem, + int aMaxStacksize) { super(inventory, slotIndex, xPos, yPos); mCanInsertItem = aCanInsertItem; mCanStackItem = aCanStackItem; @@ -40,8 +45,7 @@ public class GT_Slot_Holo extends Slot { @Override public ItemStack decrStackSize(int amount) { - if (!mCanStackItem) - return null; + if (!mCanStackItem) return null; return super.decrStackSize(amount); } @@ -71,8 +75,7 @@ public class GT_Slot_Holo extends Slot { */ @Override @SideOnly(Side.CLIENT) - public boolean func_111238_b() - { + public boolean func_111238_b() { return isEnabled(); } } diff --git a/src/main/java/gregtech/api/gui/GT_Slot_Holo_ME.java b/src/main/java/gregtech/api/gui/GT_Slot_Holo_ME.java index 08a11d29f4..205a6d74dc 100644 --- a/src/main/java/gregtech/api/gui/GT_Slot_Holo_ME.java +++ b/src/main/java/gregtech/api/gui/GT_Slot_Holo_ME.java @@ -3,7 +3,8 @@ package gregtech.api.gui; import net.minecraft.inventory.IInventory; public class GT_Slot_Holo_ME extends GT_Slot_Holo { - public GT_Slot_Holo_ME(IInventory inventory, int slotIndex, int xPos, int yPos, boolean aCanInsertItem, boolean aCanStackItem) { + public GT_Slot_Holo_ME( + IInventory inventory, int slotIndex, int xPos, int yPos, boolean aCanInsertItem, boolean aCanStackItem) { super(inventory, slotIndex, xPos, yPos, aCanInsertItem, aCanStackItem, Integer.MAX_VALUE); } } diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java index 8f729771f6..525618589b 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java @@ -1,36 +1,34 @@ package gregtech.api.gui.widgets; -import java.awt.Rectangle; -import java.util.List; - -import org.lwjgl.opengl.GL11; - import codechicken.nei.api.API; import codechicken.nei.api.INEIGuiAdapter; -import gregtech.api.enums.Dyes; import gregtech.api.enums.GT_Values; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.net.GT_Packet_GtTileEntityGuiRequest; import gregtech.common.GT_Proxy; +import java.awt.Rectangle; +import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; +import org.lwjgl.opengl.GL11; /** * Let's you access a GregTech IGregTechTileEntity's covers as tabs on the GUI's sides */ public class GT_GuiCoverTabLine extends GT_GuiTabLine { // Names of the block a cover could be on - private final static String[] SIDES = new String[]{ + private static final String[] SIDES = new String[] { "GT5U.interface.coverTabs.down", "GT5U.interface.coverTabs.up", "GT5U.interface.coverTabs.north", "GT5U.interface.coverTabs.south", "GT5U.interface.coverTabs.west", - "GT5U.interface.coverTabs.east"}; + "GT5U.interface.coverTabs.east" + }; // Not sure there's a point in JIT translation but that's what this is private String[] translatedSides; @@ -39,7 +37,7 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine { /** * Let's you access an IGregTechTileEntity's covers as tabs on the GUI's sides - * + * * @param gui GT_ITabRenderer gui which this tab line attaches to * @param tabLineLeft left position of the tab line in relation to the gui * @param tabLineTop top position of the tab line in relation to the gui @@ -56,9 +54,19 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine { * @param tile The IGregTechTileEntity the covers of which we are accessing * @param colorization The colorization of the GUI we are adding tabs to */ - public GT_GuiCoverTabLine(GT_GUIContainerMetaTile_Machine gui, int tabLineLeft, int tabLineTop, int tabHeight, - int tabWidth, int tabSpacing, DisplayStyle xDir, DisplayStyle yDir, DisplayStyle displayMode, - GT_GuiTabIconSet tabBackground, IGregTechTileEntity tile, int colorization) { + public GT_GuiCoverTabLine( + GT_GUIContainerMetaTile_Machine gui, + int tabLineLeft, + int tabLineTop, + int tabHeight, + int tabWidth, + int tabSpacing, + DisplayStyle xDir, + DisplayStyle yDir, + DisplayStyle displayMode, + GT_GuiTabIconSet tabBackground, + IGregTechTileEntity tile, + int colorization) { super(gui, 6, tabLineLeft, tabLineTop, tabHeight, tabWidth, tabSpacing, xDir, yDir, displayMode, tabBackground); this.tile = tile; this.colorization = colorization; @@ -76,12 +84,13 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine { addCoverToTabs(tSide, cover); } } - } + } @Override protected void drawBackground(float parTicks, int mouseX, int mouseY) { // Apply this tile's coloration to draw the background - GL11.glColor3ub((byte) ((colorization >> 16) & 0xFF), (byte) ((colorization >> 8) & 0xFF), (byte) (colorization & 0xFF)); + GL11.glColor3ub((byte) ((colorization >> 16) & 0xFF), (byte) ((colorization >> 8) & 0xFF), (byte) + (colorization & 0xFF)); super.drawBackground(parTicks, mouseX, mouseY); } @@ -89,13 +98,13 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine { protected void tabClicked(int tabId, int mouseButton) { if (mouseButton == 0 && mTabs[tabId].enabled) { GT_Values.NW.sendToServer(new GT_Packet_GtTileEntityGuiRequest( - this.tile.getXCoord(), - this.tile.getYCoord(), - this.tile.getZCoord(), - tabId + GT_Proxy.GUI_ID_COVER_SIDE_BASE, - this.tile.getWorld().provider.dimensionId, - Minecraft.getMinecraft().thePlayer.getEntityId(), - 0)); + this.tile.getXCoord(), + this.tile.getYCoord(), + this.tile.getZCoord(), + tabId + GT_Proxy.GUI_ID_COVER_SIDE_BASE, + this.tile.getWorld().provider.dimensionId, + Minecraft.getMinecraft().thePlayer.getEntityId(), + 0)); } } @@ -108,7 +117,6 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine { boolean enabled = this.tile.getCoverBehaviorAtSideNew(side).hasCoverGUI(); this.setTab(side, cover, null, getTooltipForCoverTab(side, cover, enabled)); this.setTabEnabled(side, enabled); - } /** @@ -119,12 +127,13 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine { * @return This cover tab's tooltip */ private String[] getTooltipForCoverTab(byte side, ItemStack cover, boolean enabled) { - List<String> tooltip = cover.getTooltip(Minecraft.getMinecraft().thePlayer, true); - tooltip.set(0, + List<String> tooltip = cover.getTooltip(Minecraft.getMinecraft().thePlayer, true); + tooltip.set( + 0, (enabled ? EnumChatFormatting.UNDERLINE : EnumChatFormatting.DARK_GRAY) - + getSideDescription(side) - + (enabled ? EnumChatFormatting.RESET + ": " : ": " + EnumChatFormatting.RESET) - + tooltip.get(0)); + + getSideDescription(side) + + (enabled ? EnumChatFormatting.RESET + ": " : ": " + EnumChatFormatting.RESET) + + tooltip.get(0)); return tooltip.toArray(new String[0]); } @@ -138,7 +147,7 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine { if (this.translatedSides[side] == null) { this.translatedSides[side] = StatCollector.translateToLocal(SIDES[side]); } - return this.translatedSides[side] ; + return this.translatedSides[side]; } return null; } @@ -146,7 +155,7 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine { /** * Hide any NEI slots that would intersect with a cover tab */ - static class CoverTabLineNEIHandler extends INEIGuiAdapter{ + static class CoverTabLineNEIHandler extends INEIGuiAdapter { @Override public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) { Rectangle neiSlotArea = new Rectangle(x, y, w, h); @@ -155,7 +164,7 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine { if (!tabLine.visible) { return false; } - for (int i = 0; i < tabLine.mTabs.length; i++ ) { + for (int i = 0; i < tabLine.mTabs.length; i++) { if (tabLine.mTabs[i] != null && tabLine.mTabs[i].getBounds().intersects(neiSlotArea)) { return true; } @@ -164,6 +173,7 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine { return false; } } + static { API.registerNEIGuiHandler(new CoverTabLineNEIHandler()); } diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java index 045730dd7f..7a57c49515 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java @@ -3,15 +3,14 @@ package gregtech.api.gui.widgets; import codechicken.lib.gui.GuiDraw; import gregtech.api.interfaces.IGuiScreen; import gregtech.api.util.GT_UtilityClient; +import java.awt.*; +import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -import java.awt.*; -import java.util.List; - public class GT_GuiFakeItemButton implements IGuiScreen.IGuiElement { private GT_GuiIcon bgIcon; @@ -42,14 +41,13 @@ public class GT_GuiFakeItemButton implements IGuiScreen.IGuiElement { this.gui = gui; this.bgIcon = bgIcon; item = null; - rectangle = new Rectangle(x, y, 18, 18); + rectangle = new Rectangle(x, y, 18, 18); gui.addElement(this); } public GT_GuiFakeItemButton setItem(ItemStack i) { item = i; - if (getMimicSlot()) - updateTooltip(); + if (getMimicSlot()) updateTooltip(); return this; } @@ -57,7 +55,7 @@ public class GT_GuiFakeItemButton implements IGuiScreen.IGuiElement { itemTooltips = item == null ? null : GT_UtilityClient.getTooltip(item, true); } - public ItemStack getItem(){ + public ItemStack getItem() { return item; } @@ -95,8 +93,7 @@ public class GT_GuiFakeItemButton implements IGuiScreen.IGuiElement { @Override public void onRemoved() { - if (mimicSlot) - gui.removeToolTip(tooltip); + if (mimicSlot) gui.removeToolTip(tooltip); } @Override @@ -106,8 +103,8 @@ public class GT_GuiFakeItemButton implements IGuiScreen.IGuiElement { GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - if (bgIcon != null){ - GT_GuiIcon.render(bgIcon, xPosition-1, yPosition-1, 18, 18,0,true); + if (bgIcon != null) { + GT_GuiIcon.render(bgIcon, xPosition - 1, yPosition - 1, 18, 18, 0, true); } if (item != null) { @@ -115,10 +112,15 @@ public class GT_GuiFakeItemButton implements IGuiScreen.IGuiElement { GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glEnable(GL12.GL_RESCALE_NORMAL); } - gui.getItemRenderer().renderItemAndEffectIntoGUI(gui.getFontRenderer(), Minecraft.getMinecraft().getTextureManager(), item, xPosition, yPosition); - - if (item.getItem() instanceof ItemBlock) - GL11.glPopAttrib(); + gui.getItemRenderer() + .renderItemAndEffectIntoGUI( + gui.getFontRenderer(), + Minecraft.getMinecraft().getTextureManager(), + item, + xPosition, + yPosition); + + if (item.getItem() instanceof ItemBlock) GL11.glPopAttrib(); } if (getMimicSlot()) diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java index 0d6c2da243..37e1a6d960 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java @@ -1,61 +1,59 @@ package gregtech.api.gui.widgets; -import java.util.Arrays; - import gregtech.api.interfaces.IGuiIcon; +import java.util.Arrays; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.ResourceLocation; -public enum GT_GuiIcon implements IGuiIcon{ - BUTTON_NORMAL (0, 0, 0), - BUTTON_DOWN (0, 32, 0), - BUTTON_HIGHLIGHT (0, 32*2, 0), - BUTTON_HIGHLIGHT_DOWN (0, 32*3, 0), - BUTTON_DISABLED (0, 32*4, 0), - - DISABLE (0, 0, 32), - REDSTONE_OFF (0, 32, 32), - REDSTONE_ON (0, 32*2, 32), - CHECKMARK (0, 32*3, 32), - CROSS (0, 32*4, 32), - WHITELIST (0, 32*5, 32), - BLACKLIST (0, 32*6, 32), - PROGRESS (0, 32*7, 32), - - EXPORT (0, 0, 32*2), - IMPORT (0, 32, 32*2), - ALLOW_INPUT (0, 32*2, 32*2), - BLOCK_INPUT (0, 32*3, 32*2), - GREEN_ARROW_UP (0, 32*4, 32*2), - GREEN_ARROW_DOWN (0, 32*5, 32*2), - CYCLIC (0, 32*6, 32*2), - - SLOT_DARKGRAY (1, 176,0,18,18), - SLOT_GRAY (1, 176,18,18,18), - - TAB_NORMAL (2, 0, 0,18,20), - TAB_HIGHLIGHT (2, 18, 0,18,20), - TAB_DISABLED (2, 18*2, 0,18,20), - TAB_NORMAL_BRONZE (2, 0, 20,18,20), - TAB_HIGHLIGHT_BRONZE (2, 18, 20,18,20), - TAB_DISABLED_BRONZE (2, 18*2, 20,18,20), - TAB_NORMAL_STEEL (2, 0,2*20,18,20), - TAB_HIGHLIGHT_STEEL (2, 18,2*20,18,20), - TAB_DISABLED_STEEL (2, 18*2,2*20,18,20), - TAB_NORMAL_BRICK (2, 0,3*20,18,20), - TAB_HIGHLIGHT_BRICK (2, 18,3*20,18,20), - TAB_DISABLED_BRICK (2, 18*2,3*20,18,20), - TAB_INFO_GRAY (2, 220, 0,18,20), - TAB_INFO_BLUE (2,220+18, 0,18,20), -; - +public enum GT_GuiIcon implements IGuiIcon { + BUTTON_NORMAL(0, 0, 0), + BUTTON_DOWN(0, 32, 0), + BUTTON_HIGHLIGHT(0, 32 * 2, 0), + BUTTON_HIGHLIGHT_DOWN(0, 32 * 3, 0), + BUTTON_DISABLED(0, 32 * 4, 0), + + DISABLE(0, 0, 32), + REDSTONE_OFF(0, 32, 32), + REDSTONE_ON(0, 32 * 2, 32), + CHECKMARK(0, 32 * 3, 32), + CROSS(0, 32 * 4, 32), + WHITELIST(0, 32 * 5, 32), + BLACKLIST(0, 32 * 6, 32), + PROGRESS(0, 32 * 7, 32), + + EXPORT(0, 0, 32 * 2), + IMPORT(0, 32, 32 * 2), + ALLOW_INPUT(0, 32 * 2, 32 * 2), + BLOCK_INPUT(0, 32 * 3, 32 * 2), + GREEN_ARROW_UP(0, 32 * 4, 32 * 2), + GREEN_ARROW_DOWN(0, 32 * 5, 32 * 2), + CYCLIC(0, 32 * 6, 32 * 2), + + SLOT_DARKGRAY(1, 176, 0, 18, 18), + SLOT_GRAY(1, 176, 18, 18, 18), + + TAB_NORMAL(2, 0, 0, 18, 20), + TAB_HIGHLIGHT(2, 18, 0, 18, 20), + TAB_DISABLED(2, 18 * 2, 0, 18, 20), + TAB_NORMAL_BRONZE(2, 0, 20, 18, 20), + TAB_HIGHLIGHT_BRONZE(2, 18, 20, 18, 20), + TAB_DISABLED_BRONZE(2, 18 * 2, 20, 18, 20), + TAB_NORMAL_STEEL(2, 0, 2 * 20, 18, 20), + TAB_HIGHLIGHT_STEEL(2, 18, 2 * 20, 18, 20), + TAB_DISABLED_STEEL(2, 18 * 2, 2 * 20, 18, 20), + TAB_NORMAL_BRICK(2, 0, 3 * 20, 18, 20), + TAB_HIGHLIGHT_BRICK(2, 18, 3 * 20, 18, 20), + TAB_DISABLED_BRICK(2, 18 * 2, 3 * 20, 18, 20), + TAB_INFO_GRAY(2, 220, 0, 18, 20), + TAB_INFO_BLUE(2, 220 + 18, 0, 18, 20), + ; private static final int T_SIZE = 256; private static ResourceLocation[] TEXTURES = { - new ResourceLocation("gregtech", "textures/gui/GuiButtons.png"), - new ResourceLocation("gregtech", "textures/gui/GuiCover.png"), - new ResourceLocation("gregtech", "textures/gui/GuiTabs.png"), + new ResourceLocation("gregtech", "textures/gui/GuiButtons.png"), + new ResourceLocation("gregtech", "textures/gui/GuiCover.png"), + new ResourceLocation("gregtech", "textures/gui/GuiTabs.png"), }; public final int x, y, width, height; @@ -72,25 +70,34 @@ public enum GT_GuiIcon implements IGuiIcon{ } GT_GuiIcon(int texID, int x, int y) { - this(texID, x, y,32,32,null); + this(texID, x, y, 32, 32, null); } + GT_GuiIcon(int texID, int x, int y, int width, int height) { - this(texID, x, y, width, height,null); + this(texID, x, y, width, height, null); } - public static void render(IGuiIcon icon, double x, double y, double width, double height, double zLevel, - boolean doDraw) { + + public static void render( + IGuiIcon icon, double x, double y, double width, double height, double zLevel, boolean doDraw) { render(icon, x, y, width, height, zLevel, doDraw, false); } - public static void render(IGuiIcon icon, double x, double y, double width, double height, double zLevel, - boolean doDraw, boolean flipHoritontally) { + public static void render( + IGuiIcon icon, + double x, + double y, + double width, + double height, + double zLevel, + boolean doDraw, + boolean flipHoritontally) { Tessellator tess = Tessellator.instance; if (doDraw) { Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURES[icon.getTexId()]); tess.startDrawingQuads(); } double minU = (double) (icon.getX() + (flipHoritontally ? icon.getWidth() : 0)) / T_SIZE; - double maxU = (double) (icon.getX() + (flipHoritontally ? 0: icon.getWidth())) / T_SIZE; + double maxU = (double) (icon.getX() + (flipHoritontally ? 0 : icon.getWidth())) / T_SIZE; double minV = (double) icon.getY() / T_SIZE; double maxV = (double) (icon.getY() + icon.getHeight()) / T_SIZE; tess.addVertexWithUV(x, y + height, zLevel, minU, maxV); @@ -98,11 +105,9 @@ public enum GT_GuiIcon implements IGuiIcon{ tess.addVertexWithUV(x + width, y + 0, zLevel, maxU, minV); tess.addVertexWithUV(x, y + 0, zLevel, minU, minV); - if (icon.getOverlay() != null) - render(icon.getOverlay(), x, y, width, height, zLevel, false); + if (icon.getOverlay() != null) render(icon.getOverlay(), x, y, width, height, zLevel, false); - if (doDraw) - tess.draw(); + if (doDraw) tess.draw(); } /** diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java index 9de9b03df4..fd9a879902 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java @@ -1,10 +1,10 @@ package gregtech.api.gui.widgets; import gregtech.api.interfaces.IGuiScreen; +import java.awt.Rectangle; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import org.lwjgl.opengl.GL11; -import java.awt.Rectangle; public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElement { public static final int DEFAULT_WIDTH = 16; @@ -16,7 +16,6 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen private GT_GuiTooltip tooltip; - public GT_GuiIconButton(IGuiScreen gui, int id, int x, int y, GT_GuiIcon icon) { super(id, x, y, DEFAULT_WIDTH, DEFAULT_HEIGHT, ""); this.gui = gui; @@ -28,8 +27,7 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen @Override public void onInit() { - if (tooltip != null) - gui.addToolTip(tooltip); + if (tooltip != null) gui.addToolTip(tooltip); xPosition = x0 + gui.getGuiLeft(); yPosition = y0 + gui.getGuiTop(); } @@ -41,12 +39,14 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen @Override public void drawButton(Minecraft mc, int mouseX, int mouseY) { - if (this.tooltip != null) - this.tooltip.enabled = true; + if (this.tooltip != null) this.tooltip.enabled = true; if (this.visible) { - //moused over - this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + width && mouseY < this.yPosition + height; + // moused over + this.field_146123_n = mouseX >= this.xPosition + && mouseY >= this.yPosition + && mouseX < this.xPosition + width + && mouseY < this.yPosition + height; mouseDragged(mc, mouseX, mouseY); @@ -56,17 +56,15 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen int x = xPosition; int y = yPosition; - if(!this.field_146123_n) { - // GL11.glColor4f(200F/255F, 210F/255F, 1, 1); - } - else - GL11.glColor4f(1, 1, 1, 1); + if (!this.field_146123_n) { + // GL11.glColor4f(200F/255F, 210F/255F, 1, 1); + } else GL11.glColor4f(1, 1, 1, 1); GT_GuiIcon.render(getButtonTexture(this.field_146123_n), x, y, width, height, 0, true); GL11.glColor4f(1, 1, 1, 1); if (icon != null) { - GT_GuiIcon.render(icon, x, y, width, height , 0, true); + GT_GuiIcon.render(icon, x, y, width, height, 0, true); } GL11.glPopAttrib(); @@ -76,13 +74,11 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen @Override public void mouseReleased(int mouseX, int mouseY) { this.gui.clearSelectedButton(); - if(mousePressed(Minecraft.getMinecraft(), mouseX, mouseY)) - this.gui.buttonClicked(this); + if (mousePressed(Minecraft.getMinecraft(), mouseX, mouseY)) this.gui.buttonClicked(this); } public GT_GuiIcon getButtonTexture(boolean mouseOver) { - if (!enabled) - return GT_GuiIcon.BUTTON_DISABLED; + if (!enabled) return GT_GuiIcon.BUTTON_DISABLED; if (this.equals(this.gui.getSelectedButton())) return mouseOver ? GT_GuiIcon.BUTTON_HIGHLIGHT_DOWN : GT_GuiIcon.BUTTON_DOWN; @@ -92,6 +88,7 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen public GT_GuiIcon getIcon() { return icon; } + public GT_GuiIconButton setIcon(GT_GuiIcon icon) { this.icon = icon; return this; @@ -102,10 +99,8 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen } public GT_GuiIconButton setTooltipText(String... text) { - if (tooltip == null) - tooltip = new GT_GuiTooltip(getBounds(), text); - else - tooltip.setToolTipText(text); + if (tooltip == null) tooltip = new GT_GuiTooltip(getBounds(), text); + else tooltip.setToolTipText(text); return this; } diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java index e7b6b9971d..113b19711b 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java @@ -13,7 +13,15 @@ public class GT_GuiIconCheckButton extends GT_GuiIconButton { this(gui, id, x, y, checkedIcon, normalIcon, null, null); } - public GT_GuiIconCheckButton(IGuiScreen gui, int id, int x, int y, GT_GuiIcon checkedIcon, GT_GuiIcon normalIcon, String checkedTooltip, String normalTooltip) { + public GT_GuiIconCheckButton( + IGuiScreen gui, + int id, + int x, + int y, + GT_GuiIcon checkedIcon, + GT_GuiIcon normalIcon, + String checkedTooltip, + String normalTooltip) { super(gui, id, x, y, normalIcon); this.checkedIcon = checkedIcon; this.normalIcon = normalIcon; @@ -23,8 +31,7 @@ public class GT_GuiIconCheckButton extends GT_GuiIconButton { @Override public GT_GuiIcon getButtonTexture(boolean mouseOver) { - if (!enabled) - return GT_GuiIcon.BUTTON_DISABLED; + if (!enabled) return GT_GuiIcon.BUTTON_DISABLED; if (this.equals(super.gui.getSelectedButton())) return mouseOver ? GT_GuiIcon.BUTTON_HIGHLIGHT_DOWN : GT_GuiIcon.BUTTON_DOWN; return mouseOver ? GT_GuiIcon.BUTTON_HIGHLIGHT : GT_GuiIcon.BUTTON_NORMAL; diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java index e2ba53e4c9..3e2ac1e296 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java @@ -1,11 +1,10 @@ package gregtech.api.gui.widgets; import gregtech.api.interfaces.IGuiScreen; +import java.awt.*; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiTextField; -import java.awt.*; - public class GT_GuiIntegerTextBox extends GuiTextField implements IGuiScreen.IGuiElement { private final int x0, y0; private final IGuiScreen gui; @@ -44,7 +43,17 @@ public class GT_GuiIntegerTextBox extends GuiTextField implements IGuiScreen.IGu @Override public boolean textboxKeyTyped(char c, int key) { - if (validChar(c, key) || c == 1 || c == 3 || c == 22 || c == 24 || key == 14 || key == 199 || key == 203 || key == 205 || key == 207 || key == 211) { + if (validChar(c, key) + || c == 1 + || c == 3 + || c == 22 + || c == 24 + || key == 14 + || key == 199 + || key == 203 + || key == 205 + || key == 207 + || key == 211) { return super.textboxKeyTyped(c, key); } return false; diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiSlotTooltip.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiSlotTooltip.java index 1fb25ecb1a..105e919149 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiSlotTooltip.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiSlotTooltip.java @@ -1,8 +1,7 @@ package gregtech.api.gui.widgets; -import java.awt.Rectangle; - import gregtech.api.util.GT_TooltipDataCache.TooltipData; +import java.awt.Rectangle; import net.minecraft.inventory.Slot; public class GT_GuiSlotTooltip extends GT_GuiTooltip { diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiSmartTooltip.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiSmartTooltip.java index d4f7df6d2c..2bb28fb929 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiSmartTooltip.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiSmartTooltip.java @@ -1,13 +1,13 @@ package gregtech.api.gui.widgets; +import gregtech.api.util.GT_TooltipDataCache.TooltipData; import java.awt.Rectangle; -import gregtech.api.util.GT_TooltipDataCache.TooltipData; +public class GT_GuiSmartTooltip extends GT_GuiTooltip { + public interface TooltipVisibilityProvider { + boolean shouldShowTooltip(); + } -public class GT_GuiSmartTooltip extends GT_GuiTooltip{ - public interface TooltipVisibilityProvider { - boolean shouldShowTooltip(); - } private final TooltipVisibilityProvider visibilityProvider; public GT_GuiSmartTooltip(Rectangle bounds, TooltipVisibilityProvider visibilityProvider, TooltipData data) { @@ -21,5 +21,4 @@ public class GT_GuiSmartTooltip extends GT_GuiTooltip{ // If disabled by super, stay disabled. this.enabled = this.enabled && this.visibilityProvider.shouldShowTooltip(); } - } diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiTab.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiTab.java index 60672db880..1bb2f6dbb7 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiTab.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiTab.java @@ -1,16 +1,14 @@ package gregtech.api.gui.widgets; -import java.awt.Rectangle; - -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; - import gregtech.api.gui.widgets.GT_GuiTabLine.GT_GuiTabIconSet; import gregtech.api.gui.widgets.GT_GuiTabLine.GT_ITabRenderer; import gregtech.api.interfaces.IGuiIcon; +import java.awt.Rectangle; import net.minecraft.client.Minecraft; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; /** * A tab to be attached to a tab line @@ -18,10 +16,7 @@ import net.minecraft.item.ItemStack; public class GT_GuiTab { private static final int SLOT_SIZE = 18; - public boolean - visible = true, - mousedOver, - enabled = true; + public boolean visible = true, mousedOver, enabled = true; private Rectangle bounds; private GT_GuiTabIconSet tabBackground; @@ -33,7 +28,7 @@ public class GT_GuiTab { /** * A tab to be attached to a tab line - * + * * @param gui IGregTechTileEntity the tab line this tab belongs to is attached to * @param id both the ID and position in the tab line of this tab * @param bounds bounds of this tab @@ -43,8 +38,15 @@ public class GT_GuiTab { * @param tooltipText tooltip of this tab * @param flipHorizontally whether to draw this tab on the right side of the IGregTechTileEntity */ - public GT_GuiTab( GT_ITabRenderer gui, int id, Rectangle bounds, GT_GuiTabIconSet tabBackground, ItemStack item, - IGuiIcon overlay, String[] tooltipText, boolean flipHorizontally) { + public GT_GuiTab( + GT_ITabRenderer gui, + int id, + Rectangle bounds, + GT_GuiTabIconSet tabBackground, + ItemStack item, + IGuiIcon overlay, + String[] tooltipText, + boolean flipHorizontally) { this.gui = gui; this.bounds = bounds; this.item = item; @@ -56,13 +58,13 @@ public class GT_GuiTab { this.flipHorizontally = flipHorizontally; } - public GT_GuiTab( GT_ITabRenderer gui, int id, Rectangle bounds, GT_GuiTabIconSet tabBackground) { + public GT_GuiTab(GT_ITabRenderer gui, int id, Rectangle bounds, GT_GuiTabIconSet tabBackground) { this(gui, id, bounds, tabBackground, null, null, null, false); } /** * Set this tab's tooltip text - * + * * @param text * @return This tab for chaining */ @@ -70,8 +72,7 @@ public class GT_GuiTab { if (tooltip == null) { tooltip = new GT_GuiTooltip(bounds, text); gui.addToolTip(tooltip); - } - else { + } else { tooltip.setToolTipText(text); } return this; @@ -86,21 +87,28 @@ public class GT_GuiTab { /** * Draw the background texture for this tab - * + * * @param mouseX * @param mouseY * @param parTicks */ public void drawBackground(int mouseX, int mouseY, float parTicks) { if (this.visible) { - GT_GuiIcon.render(getBackgroundTexture(), bounds.x, bounds.y, bounds.width, bounds.height, 1, true, - this.flipHorizontally); + GT_GuiIcon.render( + getBackgroundTexture(), + bounds.x, + bounds.y, + bounds.width, + bounds.height, + 1, + true, + this.flipHorizontally); } } /** * Draw overlay textures and items atop the background texture - * + * * @param mouseX * @param mouseY * @param parTicks @@ -119,19 +127,22 @@ public class GT_GuiTab { } if (item != null) { GL11.glPushAttrib(GL11.GL_ENABLE_BIT); - + if (item.getItem() instanceof ItemBlock) { GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glEnable(GL12.GL_RESCALE_NORMAL); } int margin = (bounds.height - SLOT_SIZE); - gui.getItemRenderer().renderItemAndEffectIntoGUI(gui.getFontRenderer(), - Minecraft.getMinecraft().getTextureManager(), item, - bounds.x + (this.flipHorizontally ? 0 : margin), bounds.y + margin); - - if (item.getItem() instanceof ItemBlock) - GL11.glPopAttrib(); - + gui.getItemRenderer() + .renderItemAndEffectIntoGUI( + gui.getFontRenderer(), + Minecraft.getMinecraft().getTextureManager(), + item, + bounds.x + (this.flipHorizontally ? 0 : margin), + bounds.y + margin); + + if (item.getItem() instanceof ItemBlock) GL11.glPopAttrib(); + GL11.glPopAttrib(); } } @@ -141,8 +152,7 @@ public class GT_GuiTab { * @return the texture this tab should currently use as it's background */ protected IGuiIcon getBackgroundTexture() { - if (!enabled) - return tabBackground.disabled; + if (!enabled) return tabBackground.disabled; return mousedOver ? tabBackground.highlight : tabBackground.normal; } @@ -156,11 +166,11 @@ public class GT_GuiTab { /** * Reposition this tab on the screen - * + * * @param xPos * @param yPos */ public void setPosition(int xPos, int yPos) { - this.bounds = new Rectangle( xPos, yPos, bounds.width, bounds.height); + this.bounds = new Rectangle(xPos, yPos, bounds.width, bounds.height); } } diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java index e7ac596dee..ff0ccc2ac1 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java @@ -1,13 +1,11 @@ package gregtech.api.gui.widgets; -import java.awt.Rectangle; - -import org.lwjgl.opengl.GL11; - import gregtech.api.interfaces.IGuiIcon; +import java.awt.Rectangle; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.item.ItemStack; +import org.lwjgl.opengl.GL11; /** * Draws clickable and configurable tabs on the left or right side of another GUI @@ -20,11 +18,11 @@ public class GT_GuiTabLine { public IGuiIcon disabled; public IGuiIcon normal; public IGuiIcon highlight; - + public GT_GuiTabIconSet(IGuiIcon normalIcon, IGuiIcon highlightIcon, IGuiIcon disabledIcon) { - this. normal = normalIcon; - this. highlight = highlightIcon; - this. disabled = disabledIcon; + this.normal = normalIcon; + this.highlight = highlightIcon; + this.disabled = disabledIcon; } } @@ -32,11 +30,12 @@ public class GT_GuiTabLine { * Controls the rendering style of the tab line */ public static enum DisplayStyle { - NONE((byte)0), - NORMAL((byte)1), - INVERSE((byte)-1); + NONE((byte) 0), + NORMAL((byte) 1), + INVERSE((byte) -1); private byte value; + DisplayStyle(byte value) { this.value = value; } @@ -52,43 +51,37 @@ public class GT_GuiTabLine { */ public interface GT_ITabRenderer { int getGuiLeft(); + int getGuiTop(); + int getXSize(); RenderItem getItemRenderer(); + FontRenderer getFontRenderer(); - void addToolTip(GT_GuiTooltip tooltip); + void addToolTip(GT_GuiTooltip tooltip); + boolean removeToolTip(GT_GuiTooltip tooltip); } // The tabs are arranged according to their index in this array protected final GT_GuiTab[] mTabs; - private int - tabLineLeft, - tabLineTop, - tabHeight, - tabWidth, - tabSpacing; - + private int tabLineLeft, tabLineTop, tabHeight, tabWidth, tabSpacing; + // In which direction to draw the tab line - private DisplayStyle - xDir, - yDir; + private DisplayStyle xDir, yDir; // Whether to display on the right side of the GT_ITabRenderer instead of left - protected boolean - flipHorizontally, - visible; + protected boolean flipHorizontally, visible; private GT_GuiTabIconSet tabBackground; private GT_ITabRenderer gui; - /** * Draws clickable and configurable tabs on the left or right side of a GT_ITabRenderer - * + * * @param gui GT_ITabRenderer gui which this tab line attaches to * @param numTabs number of tab positions in this tab line * @param tabLineLeft left position of the tab line in relation to the gui @@ -104,8 +97,18 @@ public class GT_GuiTabLine { * (NORMAL), on it's right side (INVERSE) or not at all (NONE) * @param tabBackground the set of textures used to draw this tab line's tab backgrounds */ - public GT_GuiTabLine(GT_ITabRenderer gui, int numTabs, int tabLineLeft, int tabLineTop, int tabHeight, int tabWidth, - int tabSpacing, DisplayStyle xDir, DisplayStyle yDir, DisplayStyle displayMode, GT_GuiTabIconSet tabBackground) { + public GT_GuiTabLine( + GT_ITabRenderer gui, + int numTabs, + int tabLineLeft, + int tabLineTop, + int tabHeight, + int tabWidth, + int tabSpacing, + DisplayStyle xDir, + DisplayStyle yDir, + DisplayStyle displayMode, + GT_GuiTabIconSet tabBackground) { this.gui = gui; this.mTabs = new GT_GuiTab[numTabs]; this.tabLineLeft = tabLineLeft; @@ -123,34 +126,37 @@ public class GT_GuiTabLine { /** * Creates a new tab at the specified position with the given parameters. * This class handles the positioning. - * + * * @param tabId * @param item * @param overlay * @param text */ public void setTab(int tabId, ItemStack item, IGuiIcon overlay, String[] text) { - mTabs[tabId] = new GT_GuiTab( this.gui, tabId, getBoundsForTab(tabId), - this.tabBackground, item, overlay, text, this.flipHorizontally); + mTabs[tabId] = new GT_GuiTab( + this.gui, + tabId, + getBoundsForTab(tabId), + this.tabBackground, + item, + overlay, + text, + this.flipHorizontally); } /** * Get the bounds a given tab should occupy - * + * * @param tabId * @return */ protected Rectangle getBoundsForTab(int tabId) { - return new Rectangle ( - getTabX(tabId), - getTabY(tabId), - this.tabWidth, - this.tabHeight); + return new Rectangle(getTabX(tabId), getTabY(tabId), this.tabWidth, this.tabHeight); } /** * Enable or disable a tab. Disabled tabs have a dark background. - * + * * @param tabId * @param value */ @@ -159,13 +165,12 @@ public class GT_GuiTabLine { mTabs[tabId].enabled = value; } } - /** * Draw the tabs for this tab bar * GT_ITabRenderer must call this method on drawGuiContainerBackgroundLayer * or on drawScreen. - * + * * @param parTicks * @param mouseX * @param mouseY @@ -183,7 +188,7 @@ public class GT_GuiTabLine { /** * Draw the tab's backgrounds first - * + * * @param parTicks * @param mouseX * @param mouseY @@ -198,7 +203,7 @@ public class GT_GuiTabLine { /** * Draw anything that overlays the tab's background texture - * + * * @param parTicks * @param mouseX * @param mouseY @@ -214,13 +219,13 @@ public class GT_GuiTabLine { /** * Call tabClick for every tab that was clicked. * GT_ITabRenderer must call this method on mouseClicked. - * + * * @param mouseX * @param mouseY * @param mouseButton */ public void onMouseClicked(int mouseX, int mouseY, int mouseButton) { - for(int tabId = 0; tabId < mTabs.length; tabId++) { + for (int tabId = 0; tabId < mTabs.length; tabId++) { if (mTabs[tabId] != null && mTabs[tabId].getBounds().contains(mouseX, mouseY)) { tabClicked(tabId, mouseButton); return; @@ -230,11 +235,11 @@ public class GT_GuiTabLine { /** * Act on a tab being clicked. - * + * * @param tabId * @param mouseButton */ - protected void tabClicked(int tabId, int mouseButton) { } + protected void tabClicked(int tabId, int mouseButton) {} /** * Reposition ourselves whenever the GT_ITabRenderer does so. @@ -250,18 +255,19 @@ public class GT_GuiTabLine { /** * Get the proper X position for a given tab - * + * * @param tabId * @return */ private int getTabX(int tabId) { - return this.gui.getGuiLeft() + (flipHorizontally ? (gui.getXSize() - tabLineLeft - tabWidth) : tabLineLeft) - + (tabId * (tabWidth + tabSpacing) * xDir.getValue()); + return this.gui.getGuiLeft() + + (flipHorizontally ? (gui.getXSize() - tabLineLeft - tabWidth) : tabLineLeft) + + (tabId * (tabWidth + tabSpacing) * xDir.getValue()); } /** * Get the proper Y position for a given tab - * + * * @param tabId * @return */ diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java index 21648b74fe..ab755eb2c3 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java @@ -1,15 +1,13 @@ package gregtech.api.gui.widgets; +import gregtech.api.util.GT_TooltipDataCache.TooltipData; import java.awt.Rectangle; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.Objects; - import org.lwjgl.input.Keyboard; -import gregtech.api.util.GT_TooltipDataCache.TooltipData; public class GT_GuiTooltip { protected Rectangle bounds; @@ -20,7 +18,7 @@ public class GT_GuiTooltip { /** * Used to create a tooltip that will appear over the specified bounds. * This will initially be a "static" tooltip that doesn't respect verbosity levels or respond to the shift key. - * + * * @param bounds * @param text */ @@ -32,7 +30,7 @@ public class GT_GuiTooltip { /** * Used to create a tooltip that will appear over the specified bounds. * This will initially be a "dynamic" tooltip that respects verbosity levels and responds to the shift key. - * + * * @param bounds * @param data */ @@ -43,10 +41,10 @@ public class GT_GuiTooltip { } private TooltipData sanitizeTooltipData(TooltipData data) { - if (data.text == null){ + if (data.text == null) { data.text = Arrays.asList(new String[0]); } - if (data.shiftText == null){ + if (data.shiftText == null) { data.shiftText = Arrays.asList(new String[0]); } return data; @@ -65,12 +63,11 @@ public class GT_GuiTooltip { /** * Called once this tooltip has been determined to be enabled */ - protected void updateText() { - } + protected void updateText() {} /** * Used to set a "static" tooltip that doesn't respect verbosity levels or respond to the shift key - * + * * @param text */ public void setToolTipText(String... text) { @@ -80,17 +77,17 @@ public class GT_GuiTooltip { /** * Used to set a "dynamic" tooltip that respects verbosity levels and responds to the shift key - * + * * @param data */ public void setToolTipText(TooltipData data) { // Trust that the tooltips have already been formatted and colored, just make sure it has no nulls this.data = sanitizeTooltipData(data); } - + /** * Apply tooltip colors in case the text doesn't contain them and return as tooltip data - * + * * @param text * @return colored tooltip lines as list */ @@ -100,18 +97,15 @@ public class GT_GuiTooltip { list = new ArrayList<>(text.length); for (int i = 0; i < text.length; i++) { if (text[i] == null) continue; - if (list.isEmpty()) - list.add("\u00a7f" + text[i]); - else - list.add("\u00a77" + text[i]); + if (list.isEmpty()) list.add("\u00a7f" + text[i]); + else list.add("\u00a77" + text[i]); } } else { list = Collections.emptyList(); } - return new TooltipData(list, list) ; + return new TooltipData(list, list); } - public List<String> getToolTipText() { return this.displayedText; } diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltipManager.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltipManager.java index abee1774f9..1c31670071 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltipManager.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltipManager.java @@ -1,16 +1,19 @@ package gregtech.api.gui.widgets; -import net.minecraft.client.gui.FontRenderer; - import java.util.ArrayList; import java.util.List; +import net.minecraft.client.gui.FontRenderer; public class GT_GuiTooltipManager { public interface GT_IToolTipRenderer { int getGuiLeft(); + int getGuiTop(); + int getXSize(); + FontRenderer getFontRenderer(); + void drawHoveringText(List<String> text, int mouseX, int mouseY, FontRenderer font); } @@ -29,8 +32,8 @@ public class GT_GuiTooltipManager { } public final void onTick(GT_IToolTipRenderer render, int mouseX, int mouseY) { - if ((Math.abs(mouseX-lastMouseX) < 2 ) && (Math.abs(mouseY-lastMouseY) < 2 )) { - mouseStopped = Math.min(mouseStopped+1, 50); + if ((Math.abs(mouseX - lastMouseX) < 2) && (Math.abs(mouseY - lastMouseY) < 2)) { + mouseStopped = Math.min(mouseStopped + 1, 50); } else { mouseStopped = 0; } @@ -43,7 +46,9 @@ public class GT_GuiTooltipManager { for (GT_GuiTooltip tip : tips) { // Give the tooltip the opportunity to decide whether they should be enabled tip.onTick(); - if (tip.enabled && (!tip.isDelayed() || mouseStopped > DELAY) && tip.getBounds().contains(mouseX, mouseY)) { + if (tip.enabled + && (!tip.isDelayed() || mouseStopped > DELAY) + && tip.getBounds().contains(mouseX, mouseY)) { tip.updateText(); drawTooltip(tip, mouseX, mouseY, render); break; @@ -53,10 +58,9 @@ public class GT_GuiTooltipManager { private void drawTooltip(GT_GuiTooltip tip, int mouseX, int mouseY, GT_IToolTipRenderer render) { List<String> text = tip.getToolTipText(); - if (text == null) - return; + if (text == null) return; - if (mouseX > render.getGuiLeft() + render.getXSize()/2) { + if (mouseX > render.getGuiLeft() + render.getXSize() / 2) { int maxWidth = 0; for (String s : text) { int w = render.getFontRenderer().getStringWidth(s); @@ -69,5 +73,4 @@ public class GT_GuiTooltipManager { render.drawHoveringText(text, mouseX, mouseY, render.getFontRenderer()); } - } |