aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/gui
diff options
context:
space:
mode:
authorRaven Szewczyk <git@eigenraven.me>2023-04-01 20:06:12 +0100
committerGitHub <noreply@github.com>2023-04-01 19:06:12 +0000
commitb088958c9f6935d356b6c087c8e8106b400aa24f (patch)
treebe608fac08ba158f1226a4fb9f5b1ed459bac2a9 /src/main/java/gregtech/api/gui
parente52cd9c3458584e58073df5cd9cde1302994f266 (diff)
downloadGT5-Unofficial-b088958c9f6935d356b6c087c8e8106b400aa24f.tar.gz
GT5-Unofficial-b088958c9f6935d356b6c087c8e8106b400aa24f.tar.bz2
GT5-Unofficial-b088958c9f6935d356b6c087c8e8106b400aa24f.zip
Jabel, Generic injection and mostly automatic code cleanup (#1829)
* Enable Jabel&Generic injection, fix type error caused by this * add missing <> * Infer generic types automatically * Parametrize cast types * Use enhanced for loops * Unnecessary boxing * Unnecessary unboxing * Use Objects.equals * Explicit type can be replaced with `<>` * Collapse identical catch blocks * Add SafeVarargs where applicable * Anonymous type can be replaced with lambda * Use List.sort directly * Lambda can be a method reference * Statement lambda can be an expression lambda * Use string switches * Instanceof pattern matching * Text block can be used * Migrate to enhanced switch * Java style array declarations * Unnecessary toString() * More unnecessary String conversions * Unnecessary modifiers * Unnecessary semicolons * Fix duplicate conditions * Extract common code from if branches * Replace switches with ifs for 1-2 cases * Inner class may be static * Minor performance issues * Replace string appending in loops with string builders * Fix IntelliJ using the wrong empty list method * Use Long.compare * Generic arguments: getSubItems * Generic arguments: getSubBlocks * Raw types warnings * Fix remaining missing generics * Too weak variable type leads to unnecessary cast * Redundant type casts * Redundant array length check * Redundant vararg arrays * Manual min/max implementations * A couple missed inspections * Goodbye explosion power ternary ladder * Apply spotless * Get rid of the other two big ternary ladders * Binary search explosion power * Don't overcomplicate things
Diffstat (limited to 'src/main/java/gregtech/api/gui')
-rw-r--r--src/main/java/gregtech/api/gui/GT_Container.java22
-rw-r--r--src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java91
-rw-r--r--src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java27
-rw-r--r--src/main/java/gregtech/api/gui/GT_Container_BasicTank.java14
-rw-r--r--src/main/java/gregtech/api/gui/GT_GUIColorOverride.java41
-rw-r--r--src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java8
-rw-r--r--src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java76
-rw-r--r--src/main/java/gregtech/api/gui/GT_GUIDialogSelectItem.java8
-rw-r--r--src/main/java/gregtech/api/gui/GT_GUIScreen.java7
-rw-r--r--src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java6
-rw-r--r--src/main/java/gregtech/api/gui/modularui/SteamTexture.java32
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java6
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java14
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java13
14 files changed, 149 insertions, 216 deletions
diff --git a/src/main/java/gregtech/api/gui/GT_Container.java b/src/main/java/gregtech/api/gui/GT_Container.java
index 1c6b4ff60a..819171ae02 100644
--- a/src/main/java/gregtech/api/gui/GT_Container.java
+++ b/src/main/java/gregtech/api/gui/GT_Container.java
@@ -149,7 +149,7 @@ public class GT_Container extends Container {
}
}
} else if (aShifthold == 1) {
- aSlot = (Slot) this.inventorySlots.get(aSlotIndex);
+ aSlot = this.inventorySlots.get(aSlotIndex);
if (aSlot != null && aSlot.canTakeStack(aPlayer)) {
tTempStack = this.transferStackInSlot(aPlayer, aSlotIndex);
if (tTempStack != null) {
@@ -165,7 +165,7 @@ public class GT_Container extends Container {
if (aSlotIndex < 0) {
return null;
}
- aSlot = (Slot) this.inventorySlots.get(aSlotIndex);
+ aSlot = this.inventorySlots.get(aSlotIndex);
if (aSlot != null) {
tTempStack = aSlot.getStack();
ItemStack mouseStack = aPlayerInventory.getItemStack();
@@ -239,7 +239,7 @@ public class GT_Container extends Container {
// number key from 1 to 9
// aMouseclick == 0 means number 1, aMouseclick == 8 means number 9
} else if (aShifthold == 2 && aMouseclick >= 0 && aMouseclick < 9) {
- aSlot = (Slot) this.inventorySlots.get(aSlotIndex);
+ aSlot = this.inventorySlots.get(aSlotIndex);
if (aSlot.canTakeStack(aPlayer)) {
// get the stack at the specified hotbar slot.
@@ -277,7 +277,7 @@ public class GT_Container extends Container {
} else if (aShifthold == 3 && aPlayer.capabilities.isCreativeMode
&& aPlayerInventory.getItemStack() == null
&& aSlotIndex >= 0) {
- aSlot = (Slot) this.inventorySlots.get(aSlotIndex);
+ aSlot = this.inventorySlots.get(aSlotIndex);
if (aSlot != null && aSlot.getHasStack()) {
tTempStack = GT_Utility.copyOrNull(aSlot.getStack());
tTempStack.stackSize = tTempStack.getMaxStackSize();
@@ -290,7 +290,7 @@ public class GT_Container extends Container {
@Override
public ItemStack transferStackInSlot(EntityPlayer aPlayer, int aSlotIndex) {
ItemStack stack = null;
- Slot slotObject = (Slot) inventorySlots.get(aSlotIndex);
+ Slot slotObject = inventorySlots.get(aSlotIndex);
mTileEntity.markDirty();
@@ -345,7 +345,7 @@ public class GT_Container extends Container {
if (aStack.isStackable()) {
while (aStack.stackSize > 0
&& (!reverseOrder && slotIndex < aSlotCount || reverseOrder && slotIndex >= aStartIndex)) {
- slot = (Slot) this.inventorySlots.get(slotIndex);
+ slot = this.inventorySlots.get(slotIndex);
itemStack = slot.getStack();
if (!(slot instanceof GT_Slot_Holo) && !(slot instanceof GT_Slot_Output)
&& slot.isItemValid(aStack)
@@ -384,7 +384,7 @@ public class GT_Container extends Container {
}
while (!reverseOrder && slotIndex < aSlotCount || reverseOrder && slotIndex >= aStartIndex) {
- slot = (Slot) this.inventorySlots.get(slotIndex);
+ slot = this.inventorySlots.get(slotIndex);
itemStack = slot.getStack();
if (slot.isItemValid(aStack) && itemStack == null) {
@@ -427,7 +427,7 @@ public class GT_Container extends Container {
}
@Override
- public List getInventory() {
+ public List<ItemStack> getInventory() {
try {
return super.getInventory();
} catch (Throwable e) {
@@ -643,8 +643,7 @@ public class GT_Container extends Container {
if (tStackSizedOne == null || tStackHeld.stackSize == 0) return null;
int tOriginalFluidAmount = tTankStack.amount;
ItemStack tFilledContainer = GT_Utility.fillFluidContainer(tTankStack, tStackSizedOne, true, false);
- if (tFilledContainer == null && tStackSizedOne.getItem() instanceof IFluidContainerItem) {
- IFluidContainerItem tContainerItem = (IFluidContainerItem) tStackSizedOne.getItem();
+ if (tFilledContainer == null && tStackSizedOne.getItem() instanceof IFluidContainerItem tContainerItem) {
int tFilledAmount = tContainerItem.fill(tStackSizedOne, tTankStack, true);
if (tFilledAmount > 0) {
tFilledContainer = tStackSizedOne;
@@ -694,9 +693,8 @@ public class GT_Container extends Container {
tStackEmptied = GT_Utility.getContainerForFilledItem(tStackSizedOne, false);
tAmountTaken = aFluidHeld.amount;
}
- if (tStackEmptied == null && tStackSizedOne.getItem() instanceof IFluidContainerItem) {
+ if (tStackEmptied == null && tStackSizedOne.getItem() instanceof IFluidContainerItem container) {
// either partially accepted, or is IFluidContainerItem
- IFluidContainerItem container = (IFluidContainerItem) tStackSizedOne.getItem();
FluidStack tDrained = container.drain(tStackSizedOne, tFreeSpace, true);
if (tDrained != null && tDrained.amount > 0) {
// something is actually drained - change the cell and drop it to player
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 4627362e66..3f2b45064d 100644
--- a/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java
+++ b/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java
@@ -59,8 +59,7 @@ public class GT_ContainerMetaTile_Machine extends GT_Container {
}
protected void addCircuitSlot() {
- if (mTileEntity.getMetaTileEntity() instanceof IConfigurationCircuitSupport) {
- IConfigurationCircuitSupport ccs = (IConfigurationCircuitSupport) mTileEntity.getMetaTileEntity();
+ if (mTileEntity.getMetaTileEntity() instanceof IConfigurationCircuitSupport ccs) {
GT_Slot_Render slotCircuit = new GT_Slot_Render(
mTileEntity,
ccs.getCircuitSlot(),
@@ -94,8 +93,8 @@ public class GT_ContainerMetaTile_Machine extends GT_Container {
mActive = mTileEntity.isActive() ? 1 : 0;
mTimer++;
- for (Object crafter : this.crafters) {
- ICrafting player = (ICrafting) crafter;
+ for (ICrafting crafter : this.crafters) {
+ ICrafting player = crafter;
if (mTimer % 500 == 10 || oEnergy != mEnergy) {
player.sendProgressBarUpdate(this, 0, mEnergy & 65535);
player.sendProgressBarUpdate(this, 1, mEnergy >>> 16);
@@ -165,69 +164,27 @@ public class GT_ContainerMetaTile_Machine extends GT_Container {
public void updateProgressBar(int id, int value) {
super.updateProgressBar(id, value);
switch (id) {
- case 0:
- mEnergy = mEnergy & 0xffff0000 | value & 0x0000ffff;
- break;
- case 1:
- mEnergy = mEnergy & 0x0000ffff | value << 16;
- break;
- case 2:
- mStorage = mStorage & 0xffff0000 | value & 0x0000ffff;
- break;
- case 3:
- mStorage = mStorage & 0x0000ffff | value << 16;
- break;
- case 4:
- mOutput = value;
- break;
- case 5:
- mInput = value;
- break;
- case 6:
- mDisplayErrorCode = value;
- break;
- case 11:
- mProgressTime = mProgressTime & 0xffff0000 | value;
- break;
- case 12:
- mProgressTime = mProgressTime & 0x0000ffff | value << 16;
- break;
- case 13:
- mMaxProgressTime = mMaxProgressTime & 0xffff0000 | value & 0x0000ffff;
- break;
- case 14:
- mMaxProgressTime = mMaxProgressTime & 0x0000ffff | value << 16;
- break;
- case 15:
- mID = value;
- break;
- case 16:
- mActive = value;
- break;
- case 17:
- mSteam = mSteam & 0xffff0000 | value & 0x0000ffff;
- break;
- case 18:
- mSteam = mSteam & 0x0000ffff | value << 16;
- break;
- case 19:
- mSteamStorage = mSteamStorage & 0xffff0000 | value & 0x0000ffff;
- break;
- case 20:
- mSteamStorage = mSteamStorage & 0x0000ffff | value << 16;
- break;
- case 21:
- mEnergyLong = mEnergyLong & 0xffffffff00000000L | value & 0x00000000ffffffffL;
- break;
- case 22:
- mEnergyLong = mEnergyLong & 0x00000000ffffffffL | (long) value << 32;
- break;
- case 23:
- mStorageLong = mStorageLong & 0xffffffff00000000L | value & 0x00000000ffffffffL;
- break;
- case 24:
- mStorageLong = mStorageLong & 0x00000000ffffffffL | (long) value << 32;
- break;
+ case 0 -> mEnergy = mEnergy & 0xffff0000 | value & 0x0000ffff;
+ case 1 -> mEnergy = mEnergy & 0x0000ffff | value << 16;
+ case 2 -> mStorage = mStorage & 0xffff0000 | value & 0x0000ffff;
+ case 3 -> mStorage = mStorage & 0x0000ffff | value << 16;
+ case 4 -> mOutput = value;
+ case 5 -> mInput = value;
+ case 6 -> mDisplayErrorCode = value;
+ case 11 -> mProgressTime = mProgressTime & 0xffff0000 | value;
+ case 12 -> mProgressTime = mProgressTime & 0x0000ffff | value << 16;
+ case 13 -> mMaxProgressTime = mMaxProgressTime & 0xffff0000 | value & 0x0000ffff;
+ case 14 -> mMaxProgressTime = mMaxProgressTime & 0x0000ffff | value << 16;
+ case 15 -> mID = value;
+ case 16 -> mActive = value;
+ case 17 -> mSteam = mSteam & 0xffff0000 | value & 0x0000ffff;
+ case 18 -> mSteam = mSteam & 0x0000ffff | value << 16;
+ case 19 -> mSteamStorage = mSteamStorage & 0xffff0000 | value & 0x0000ffff;
+ case 20 -> mSteamStorage = mSteamStorage & 0x0000ffff | value << 16;
+ case 21 -> mEnergyLong = mEnergyLong & 0xffffffff00000000L | value & 0x00000000ffffffffL;
+ case 22 -> mEnergyLong = mEnergyLong & 0x00000000ffffffffL | (long) value << 32;
+ case 23 -> mStorageLong = mStorageLong & 0xffffffff00000000L | value & 0x00000000ffffffffL;
+ case 24 -> mStorageLong = mStorageLong & 0x00000000ffffffffL | (long) value << 32;
}
}
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 101c1cba83..976d7e8127 100644
--- a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java
+++ b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java
@@ -203,23 +203,25 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank {
GT_MetaTileEntity_BasicMachine machine = getMachine();
if (machine == null) return null;
switch (aSlotNumber) {
- case 0:
+ case 0 -> {
if (slotFluidTransferToggle.isEnabled()) {
machine.mFluidTransfer = !machine.mFluidTransfer;
}
return null;
- case 1:
+ }
+ case 1 -> {
if (slotItemTransferToggle.isEnabled()) {
machine.mItemTransfer = !machine.mItemTransfer;
}
return null;
- default:
+ }
+ default -> {
if (aSlotNumber == OTHER_SLOT_COUNT + 1 + machine.mInputSlotCount + machine.mOutputItems.length
&& aMouseclick < 2) {
GT_MetaTileEntity_BasicTank tTank = (GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity();
if (mTileEntity.isClientSide()) {
// see parent class slotClick for an explanation on why doing this
- Slot slot = (Slot) inventorySlots.get(aSlotNumber);
+ Slot slot = inventorySlots.get(aSlotNumber);
tTank.setFillableStack(GT_Utility.getFluidFromDisplayStack(slot.getStack()));
}
IFluidAccess tFillableAccess = constructFluidAccess(tTank, true);
@@ -236,6 +238,7 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank {
} else {
return super.slotClick(aSlotNumber, aMouseclick, aShifthold, aPlayer);
}
+ }
}
}
@@ -248,8 +251,8 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank {
mItemTransfer = getMachine().mItemTransfer;
mStuttering = getMachine().mStuttering;
- for (Object crafter : this.crafters) {
- ICrafting player = (ICrafting) crafter;
+ for (ICrafting crafter : this.crafters) {
+ ICrafting player = crafter;
player.sendProgressBarUpdate(this, 102, mFluidTransfer ? 1 : 0);
player.sendProgressBarUpdate(this, 103, mItemTransfer ? 1 : 0);
player.sendProgressBarUpdate(this, 104, mStuttering ? 1 : 0);
@@ -266,15 +269,9 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank {
public void updateProgressBar(int id, int value) {
super.updateProgressBar(id, value);
switch (id) {
- case 102:
- mFluidTransfer = (value != 0);
- break;
- case 103:
- mItemTransfer = (value != 0);
- break;
- case 104:
- mStuttering = (value != 0);
- break;
+ case 102 -> mFluidTransfer = (value != 0);
+ case 103 -> mItemTransfer = (value != 0);
+ case 104 -> mStuttering = (value != 0);
}
}
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 5aa793f8f6..f463b35f7c 100644
--- a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java
+++ b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java
@@ -51,7 +51,7 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine {
* to become only more severe when playing MP over ethernet, which would have much more latency than a
* memory connection
*/
- Slot slot = (Slot) inventorySlots.get(aSlotIndex);
+ Slot slot = inventorySlots.get(aSlotIndex);
tTank.setDrainableStack(GT_Utility.getFluidFromDisplayStack(slot.getStack()));
}
IFluidAccess tDrainableAccess = constructFluidAccess(tTank, false);
@@ -77,8 +77,8 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine {
}
public void sendProgressBar() {
- for (Object crafter : this.crafters) {
- ICrafting player = (ICrafting) crafter;
+ for (ICrafting crafter : this.crafters) {
+ ICrafting player = crafter;
if (mTimer % 500 == 0 || oContent != mContent) {
player.sendProgressBarUpdate(this, 100, mContent & 65535);
player.sendProgressBarUpdate(this, 101, mContent >>> 16);
@@ -91,12 +91,8 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine {
public void updateProgressBar(int id, int value) {
super.updateProgressBar(id, value);
switch (id) {
- case 100:
- mContent = mContent & 0xffff0000 | value & 0x0000ffff;
- break;
- case 101:
- mContent = mContent & 0xffff | value << 16;
- break;
+ case 100 -> mContent = mContent & 0xffff0000 | value & 0x0000ffff;
+ case 101 -> mContent = mContent & 0xffff | value << 16;
}
}
diff --git a/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java b/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java
index 06ddf16d02..7c6328bb34 100644
--- a/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java
+++ b/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java
@@ -23,27 +23,26 @@ public class GT_GUIColorOverride {
private static final Object NOT_FOUND = new Object();
private static final LoadingCache<ResourceLocation, Object> cache = CacheBuilder.newBuilder()
.softValues()
- .build(
- new CacheLoader<ResourceLocation, Object>() {
-
- @Override
- public Object load(
- @Nonnull ResourceLocation key)
- throws Exception {
- IResource ir = Minecraft.getMinecraft()
- .getResourceManager()
- .getResource(
- key);
- if (ir.hasMetadata())
- return ir.getMetadata(
- "colors");
- // return a dummy
- // object because
- // LoadingCache
- // doesn't like null
- return NOT_FOUND;
- }
- });
+ .build(new CacheLoader<>() {
+
+ @Override
+ public Object load(
+ @Nonnull ResourceLocation key)
+ throws Exception {
+ IResource ir = Minecraft.getMinecraft()
+ .getResourceManager()
+ .getResource(
+ key);
+ if (ir.hasMetadata())
+ return ir.getMetadata(
+ "colors");
+ // return a dummy
+ // object because
+ // LoadingCache
+ // doesn't like null
+ return NOT_FOUND;
+ }
+ });
private static final GT_GUIColorOverride FALLBACK = new GT_GUIColorOverride();
private ColorsMetadataSection cmSection;
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 e44b4f0cbc..cbccdc5385 100644
--- a/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java
+++ b/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java
@@ -180,8 +180,7 @@ public class GT_GUIContainerMetaTile_Machine extends GT_GUIContainer implements
* are enabled.
*/
protected void setupTooltips() {
- if (mContainer.mTileEntity.getMetaTileEntity() instanceof IConfigurationCircuitSupport) {
- IConfigurationCircuitSupport ccs = (IConfigurationCircuitSupport) mContainer.mTileEntity.getMetaTileEntity();
+ if (mContainer.mTileEntity.getMetaTileEntity() instanceof IConfigurationCircuitSupport ccs) {
if (ccs.allowSelectCircuit()) addToolTip(
new GT_GuiSlotTooltip(
mContainer.getSlot(ccs.getCircuitGUISlot()),
@@ -191,7 +190,7 @@ public class GT_GUIContainerMetaTile_Machine extends GT_GUIContainer implements
// GT_IToolTipRenderer and GT_ITabRenderer implementations
@Override
- public void drawHoveringText(List text, int mouseX, int mouseY, FontRenderer font) {
+ public void drawHoveringText(List<String> text, int mouseX, int mouseY, FontRenderer font) {
super.drawHoveringText(text, mouseX, mouseY, font);
}
@@ -232,8 +231,7 @@ 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();
+ if (mContainer.mTileEntity.getMetaTileEntity() instanceof IConfigurationCircuitSupport ccs) {
Slot slotCircuit = mContainer.getSlot(ccs.getCircuitGUISlot());
if (slotCircuit != null
&& func_146978_c(slotCircuit.xDisplayPosition, slotCircuit.yDisplayPosition, 16, 16, mx, my)) {
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 899d8331bc..eb0122093c 100644
--- a/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java
+++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java
@@ -11,7 +11,6 @@ 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;
@@ -84,12 +83,11 @@ 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,
+ () -> hasErrorCode(NEEDS_STEAM_VENTING),
+ mTooltipCache.getData(STALLED_VENT_TOOLTIP)));
} else {
String pTier1 = powerTierName(machine.mTier);
if (machine.mTier == GT_Values.VN.length - 1) {
@@ -130,21 +128,19 @@ public class GT_GUIContainer_BasicMachine extends GT_GUIContainerMetaTile_Machin
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")))));
+ addToolTip(
+ new GT_GuiSmartTooltip(
+ tProblemArea,
+ () -> container.mStuttering && !hasErrorCode(NEEDS_STEAM_VENTING),
+ mTooltipCache.getData(
+ STALLED_STUTTERING_TOOLTIP,
+ StatCollector.translateToLocal(
+ POWER_SOURCE_KEY + (machine.isSteampowered() ? "steam" : "power")))));
}
/**
* Apply proper coloration to a machine's power tier short name
- *
+ *
* @param machineTier
* @return colored power tier short name
*/
@@ -187,34 +183,38 @@ public class GT_GUIContainer_BasicMachine extends GT_GUIContainerMetaTile_Machin
% (tSize + 1);
switch (mProgressBarDirection) { // yes, my OCD was mad at me before I did the Tabs.
- case 0:
- drawTexturedModalRect(x + 78, y + 24, 176, 0, tProgress, 18);
- break;
- case 1:
- drawTexturedModalRect(x + 78 + 20 - tProgress, y + 24, 176 + 20 - tProgress, 0, tProgress, 18);
- break;
- case 2:
- drawTexturedModalRect(x + 78, y + 24, 176, 0, 20, tProgress);
- break;
- case 3:
- drawTexturedModalRect(x + 78, y + 24 + 18 - tProgress, 176, 18 - tProgress, 20, tProgress);
- break;
- case 4:
+ case 0 -> drawTexturedModalRect(x + 78, y + 24, 176, 0, tProgress, 18);
+ case 1 -> drawTexturedModalRect(
+ x + 78 + 20 - tProgress,
+ y + 24,
+ 176 + 20 - tProgress,
+ 0,
+ tProgress,
+ 18);
+ case 2 -> drawTexturedModalRect(x + 78, y + 24, 176, 0, 20, tProgress);
+ case 3 -> drawTexturedModalRect(
+ x + 78,
+ y + 24 + 18 - tProgress,
+ 176,
+ 18 - tProgress,
+ 20,
+ tProgress);
+ case 4 -> {
tProgress = 20 - tProgress;
drawTexturedModalRect(x + 78, y + 24, 176, 0, tProgress, 18);
- break;
- case 5:
+ }
+ case 5 -> {
tProgress = 20 - tProgress;
drawTexturedModalRect(x + 78 + 20 - tProgress, y + 24, 176 + 20 - tProgress, 0, tProgress, 18);
- break;
- case 6:
+ }
+ case 6 -> {
tProgress = 18 - tProgress;
drawTexturedModalRect(x + 78, y + 24, 176, 0, 20, tProgress);
- break;
- case 7:
+ }
+ case 7 -> {
tProgress = 18 - tProgress;
drawTexturedModalRect(x + 78, y + 24 + 18 - tProgress, 176, 18 - tProgress, 20, tProgress);
- break;
+ }
}
}
}
diff --git a/src/main/java/gregtech/api/gui/GT_GUIDialogSelectItem.java b/src/main/java/gregtech/api/gui/GT_GUIDialogSelectItem.java
index fed1671484..1f95def197 100644
--- a/src/main/java/gregtech/api/gui/GT_GUIDialogSelectItem.java
+++ b/src/main/java/gregtech/api/gui/GT_GUIDialogSelectItem.java
@@ -52,7 +52,7 @@ public class GT_GUIDialogSelectItem extends GT_GUIScreen {
/**
* 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.
@@ -105,12 +105,14 @@ public class GT_GUIDialogSelectItem extends GT_GUIScreen {
@Override
public void buttonClicked(GuiButton button) {
switch (button.id) {
- case 0:
+ case 0 -> {
setScroll(scroll - 1);
return;
- case 1:
+ }
+ case 1 -> {
setScroll(scroll + 1);
return;
+ }
}
super.buttonClicked(button);
}
diff --git a/src/main/java/gregtech/api/gui/GT_GUIScreen.java b/src/main/java/gregtech/api/gui/GT_GUIScreen.java
index 1aa9ccc24c..52ecbe8ab5 100644
--- a/src/main/java/gregtech/api/gui/GT_GUIScreen.java
+++ b/src/main/java/gregtech/api/gui/GT_GUIScreen.java
@@ -61,7 +61,7 @@ public abstract class GT_GUIScreen extends GuiScreen implements GT_IToolTipRende
guiTop = (this.height - this.gui_height) / 2;
for (IGuiElement element : elements) {
- if (element instanceof GuiButton) buttonList.add(element);
+ if (element instanceof GuiButton button) buttonList.add(button);
if (element instanceof GT_GuiIntegerTextBox) textBoxes.add((GT_GuiIntegerTextBox) element);
}
@@ -181,12 +181,11 @@ public abstract class GT_GUIScreen extends GuiScreen implements GT_IToolTipRende
if (focusedTextBox != null) {
resetTextBox(focusedTextBox);
setFocusedTextBox(null);
- return;
} else {
closeScreen();
// don't fall through to parent
- return;
}
+ return;
}
if (c == '\t') { // tab
@@ -268,7 +267,7 @@ public abstract class GT_GUIScreen extends GuiScreen implements GT_IToolTipRende
* GT_IToolTipRenderer
*/
@Override
- public void drawHoveringText(List text, int mouseX, int mouseY, FontRenderer render) {
+ public void drawHoveringText(List<String> text, int mouseX, int mouseY, FontRenderer render) {
super.drawHoveringText(text, mouseX, mouseY, render);
}
diff --git a/src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java b/src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java
index e068cd967e..4d004429b0 100644
--- a/src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java
+++ b/src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java
@@ -89,8 +89,7 @@ public class GT_UIInfos {
UIBuilder.of()
.container((player, world, x, y, z) -> {
final TileEntity te = world.getTileEntity(x, y, z);
- if (!(te instanceof ICoverable)) return null;
- final ICoverable gtTileEntity = (ICoverable) te;
+ if (!(te instanceof ICoverable gtTileEntity)) return null;
GT_CoverBehaviorBase<?> cover = gtTileEntity.getCoverBehaviorAtSideNew(side);
return createCoverContainer(
player,
@@ -103,8 +102,7 @@ public class GT_UIInfos {
.gui((player, world, x, y, z) -> {
if (!world.isRemote) return null;
final TileEntity te = world.getTileEntity(x, y, z);
- if (!(te instanceof ICoverable)) return null;
- final ICoverable gtTileEntity = (ICoverable) te;
+ if (!(te instanceof ICoverable gtTileEntity)) return null;
final GT_CoverBehaviorBase<?> cover = gtTileEntity.getCoverBehaviorAtSideNew(side);
return createCoverGuiContainer(
player,
diff --git a/src/main/java/gregtech/api/gui/modularui/SteamTexture.java b/src/main/java/gregtech/api/gui/modularui/SteamTexture.java
index 619b19e232..7cebd957f2 100644
--- a/src/main/java/gregtech/api/gui/modularui/SteamTexture.java
+++ b/src/main/java/gregtech/api/gui/modularui/SteamTexture.java
@@ -50,29 +50,21 @@ public class SteamTexture {
}
public UITexture get(SteamVariant variant) {
- switch (variant) {
- case BRONZE:
- return bronzeTexture;
- case STEEL:
- return steelTexture;
- case PRIMITIVE:
- return primitiveTexture;
- default:
- return null;
- }
+ return switch (variant) {
+ case BRONZE -> bronzeTexture;
+ case STEEL -> steelTexture;
+ case PRIMITIVE -> primitiveTexture;
+ default -> null;
+ };
}
public AdaptableUITexture getAdaptable(SteamVariant variant) {
- switch (variant) {
- case BRONZE:
- return (AdaptableUITexture) bronzeTexture;
- case STEEL:
- return (AdaptableUITexture) steelTexture;
- case PRIMITIVE:
- return (AdaptableUITexture) primitiveTexture;
- default:
- return null;
- }
+ return switch (variant) {
+ case BRONZE -> (AdaptableUITexture) bronzeTexture;
+ case STEEL -> (AdaptableUITexture) steelTexture;
+ case PRIMITIVE -> (AdaptableUITexture) primitiveTexture;
+ default -> null;
+ };
}
public UITexture get(boolean isHighPressure) {
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 01c8671678..cb149547b4 100644
--- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java
@@ -119,10 +119,8 @@ public enum GT_GuiIcon implements IGuiIcon {
if (location == null || location.length == 0) return;
int startIndex = TEXTURES.length;
- TEXTURES = (ResourceLocation[]) Arrays.copyOf(TEXTURES, location.length);
- for (int i = 0; i < location.length; i++) {
- TEXTURES[startIndex + i] = location[i];
- }
+ TEXTURES = Arrays.copyOf(TEXTURES, location.length);
+ System.arraycopy(location, 0, TEXTURES, startIndex + 0, location.length);
}
@Override
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 9caf51cd4b..01a0f3c8b1 100644
--- a/src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java
@@ -34,7 +34,7 @@ public class GT_GuiTabLine {
/**
* Controls the rendering style of the tab line
*/
- public static enum DisplayStyle {
+ public enum DisplayStyle {
NONE((byte) 0),
NORMAL((byte) 1),
@@ -189,9 +189,9 @@ public class GT_GuiTabLine {
* @param mouseY
*/
protected void drawOverlays(float parTicks, int mouseX, int mouseY) {
- for (int i = 0; i < mTabs.length; i++) {
- if (mTabs[i] != null) {
- mTabs[i].drawOverlays(mouseX, mouseY, parTicks);
+ for (GT_GuiTab mTab : mTabs) {
+ if (mTab != null) {
+ mTab.drawOverlays(mouseX, mouseY, parTicks);
}
}
}
@@ -204,9 +204,9 @@ public class GT_GuiTabLine {
* @param mouseY
*/
protected void drawBackground(float parTicks, int mouseX, int mouseY) {
- for (int i = 0; i < mTabs.length; i++) {
- if (mTabs[i] != null) {
- mTabs[i].drawBackground(mouseX, mouseY, parTicks);
+ for (GT_GuiTab mTab : mTabs) {
+ if (mTab != null) {
+ mTab.drawBackground(mouseX, mouseY, parTicks);
}
}
}
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 1162630d5e..326e744382 100644
--- a/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java
@@ -2,7 +2,6 @@ package gregtech.api.gui.widgets;
import java.awt.Rectangle;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -44,10 +43,10 @@ public class GT_GuiTooltip {
private TooltipData sanitizeTooltipData(TooltipData data) {
if (data.text == null) {
- data.text = Arrays.asList(new String[0]);
+ data.text = Collections.emptyList();
}
if (data.shiftText == null) {
- data.shiftText = Arrays.asList(new String[0]);
+ data.shiftText = Collections.emptyList();
}
return data;
}
@@ -97,10 +96,10 @@ public class GT_GuiTooltip {
List<String> list;
if (text != null) {
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]);
+ for (String s : text) {
+ if (s == null) continue;
+ if (list.isEmpty()) list.add("\u00a7f" + s);
+ else list.add("\u00a77" + s);
}
} else {
list = Collections.emptyList();