aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java
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/common/blocks/GT_Block_Casings8.java
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/common/blocks/GT_Block_Casings8.java')
-rw-r--r--src/main/java/gregtech/common/blocks/GT_Block_Casings8.java114
1 files changed, 46 insertions, 68 deletions
diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java
index a8d04cd10f..6e6313c05c 100644
--- a/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java
+++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java
@@ -78,73 +78,53 @@ public class GT_Block_Casings8 extends GT_Block_Casings_Abstract {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int aSide, int aMeta) {
- switch (aMeta) {
- case 0:
- return Textures.BlockIcons.MACHINE_CASING_CHEMICALLY_INERT.getIcon();
- case 1:
- return Textures.BlockIcons.MACHINE_CASING_PIPE_POLYTETRAFLUOROETHYLENE.getIcon();
- case 2:
- return Textures.BlockIcons.MACHINE_CASING_MINING_NEUTRONIUM.getIcon();
- case 3:
- return Textures.BlockIcons.MACHINE_CASING_MINING_BLACKPLUTONIUM.getIcon();
- case 4:
- return Textures.BlockIcons.MACHINE_CASING_EXTREME_ENGINE_INTAKE.getIcon(); // changed color in a
- // terrible way
- case 5:
- return Textures.BlockIcons.MACHINE_CASING_ADVANCEDRADIATIONPROOF.getIcon();
- case 6:
- return Textures.BlockIcons.MACHINE_CASING_RHODIUM_PALLADIUM.getIcon();
- case 7:
- return Textures.BlockIcons.MACHINE_CASING_IRIDIUM.getIcon();
- case 8:
- return Textures.BlockIcons.MACHINE_CASING_MAGICAL.getIcon();
- case 9:
- return Textures.BlockIcons.MACHINE_CASING_ADVANCEDGAS.getIcon();
- case 10:
- return Textures.BlockIcons.MACHINE_CASING_RADIANT_NAQUADAH_ALLOY.getIcon();
- case 11:
- return Textures.BlockIcons.MACHINE_CASING_PCB_TIER_1.getIcon();
- case 12:
- return Textures.BlockIcons.MACHINE_CASING_PCB_TIER_2.getIcon();
- case 13:
- return Textures.BlockIcons.MACHINE_CASING_PCB_TIER_3.getIcon();
- case 14:
- return Textures.BlockIcons.INFINITY_COOLED_CASING.getIcon();
- }
- return Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon();
+ return switch (aMeta) {
+ case 0 -> Textures.BlockIcons.MACHINE_CASING_CHEMICALLY_INERT.getIcon();
+ case 1 -> Textures.BlockIcons.MACHINE_CASING_PIPE_POLYTETRAFLUOROETHYLENE.getIcon();
+ case 2 -> Textures.BlockIcons.MACHINE_CASING_MINING_NEUTRONIUM.getIcon();
+ case 3 -> Textures.BlockIcons.MACHINE_CASING_MINING_BLACKPLUTONIUM.getIcon();
+ case 4 -> Textures.BlockIcons.MACHINE_CASING_EXTREME_ENGINE_INTAKE.getIcon(); // changed color in a
+ // terrible way
+ case 5 -> Textures.BlockIcons.MACHINE_CASING_ADVANCEDRADIATIONPROOF.getIcon();
+ case 6 -> Textures.BlockIcons.MACHINE_CASING_RHODIUM_PALLADIUM.getIcon();
+ case 7 -> Textures.BlockIcons.MACHINE_CASING_IRIDIUM.getIcon();
+ case 8 -> Textures.BlockIcons.MACHINE_CASING_MAGICAL.getIcon();
+ case 9 -> Textures.BlockIcons.MACHINE_CASING_ADVANCEDGAS.getIcon();
+ case 10 -> Textures.BlockIcons.MACHINE_CASING_RADIANT_NAQUADAH_ALLOY.getIcon();
+ case 11 -> Textures.BlockIcons.MACHINE_CASING_PCB_TIER_1.getIcon();
+ case 12 -> Textures.BlockIcons.MACHINE_CASING_PCB_TIER_2.getIcon();
+ case 13 -> Textures.BlockIcons.MACHINE_CASING_PCB_TIER_3.getIcon();
+ case 14 -> Textures.BlockIcons.INFINITY_COOLED_CASING.getIcon();
+ default -> Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon();
+ };
}
@Deprecated
public IIcon getTurbineCasing(int meta, int iconIndex, boolean active) {
- switch (meta) {
- case 9:
- return active ? Textures.BlockIcons.TURBINE_ADVGASACTIVE[iconIndex].getIcon()
- : Textures.BlockIcons.TURBINEADVGAS[iconIndex].getIcon();
- default:
- return active ? Textures.BlockIcons.TURBINE_ACTIVE[iconIndex].getIcon()
- : Textures.BlockIcons.TURBINE[iconIndex].getIcon();
- }
+ return switch (meta) {
+ case 9 -> active ? Textures.BlockIcons.TURBINE_ADVGASACTIVE[iconIndex].getIcon()
+ : Textures.BlockIcons.TURBINEADVGAS[iconIndex].getIcon();
+ default -> active ? Textures.BlockIcons.TURBINE_ACTIVE[iconIndex].getIcon()
+ : Textures.BlockIcons.TURBINE[iconIndex].getIcon();
+ };
}
public IIcon getTurbineCasing(int meta, int iconIndex, boolean active, boolean hasTurbine) {
- switch (meta) {
- case 9:
- return active ? Textures.BlockIcons.TURBINE_ADVGASACTIVE[iconIndex].getIcon()
- : hasTurbine ? Textures.BlockIcons.TURBINEADVGAS[iconIndex].getIcon()
- : Textures.BlockIcons.TURBINE_ADVGASEMPTY[iconIndex].getIcon();
- default:
- return active ? Textures.BlockIcons.TURBINE_ACTIVE[iconIndex].getIcon()
- : hasTurbine ? Textures.BlockIcons.TURBINE[iconIndex].getIcon()
- : Textures.BlockIcons.TURBINE_EMPTY[iconIndex].getIcon();
- }
+ return switch (meta) {
+ case 9 -> active ? Textures.BlockIcons.TURBINE_ADVGASACTIVE[iconIndex].getIcon()
+ : hasTurbine ? Textures.BlockIcons.TURBINEADVGAS[iconIndex].getIcon()
+ : Textures.BlockIcons.TURBINE_ADVGASEMPTY[iconIndex].getIcon();
+ default -> active ? Textures.BlockIcons.TURBINE_ACTIVE[iconIndex].getIcon()
+ : hasTurbine ? Textures.BlockIcons.TURBINE[iconIndex].getIcon()
+ : Textures.BlockIcons.TURBINE_EMPTY[iconIndex].getIcon();
+ };
}
private static int isTurbineControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) {
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
- if (!(tTileEntity instanceof IGregTechTileEntity)) return 0;
- IGregTechTileEntity tTile = (IGregTechTileEntity) tTileEntity;
- if (tTile.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine && tTile.getFrontFacing() == aSide) {
- GT_MetaTileEntity_LargeTurbine turbine = (GT_MetaTileEntity_LargeTurbine) tTile.getMetaTileEntity();
+ if (!(tTileEntity instanceof IGregTechTileEntity tTile)) return 0;
+ if (tTile.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine turbine
+ && tTile.getFrontFacing() == aSide) {
if (turbine.isNewStyleRendering()) return 0;
if (tTile.isActive()) return 1;
return turbine.hasTurbine() ? 2 : 3;
@@ -163,7 +143,7 @@ public class GT_Block_Casings8 extends GT_Block_Casings_Abstract {
if (tMeta == 9) {
int tInvertLeftRightMod = aSide % 2 * 2 - 1;
switch (aSide / 2) {
- case 0:
+ case 0 -> {
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
if (i == 0 && j == 0) continue;
@@ -174,8 +154,8 @@ public class GT_Block_Casings8 extends GT_Block_Casings_Abstract {
}
}
}
- break;
- case 1:
+ }
+ case 1 -> {
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
if (i == 0 && j == 0) continue;
@@ -190,8 +170,8 @@ public class GT_Block_Casings8 extends GT_Block_Casings_Abstract {
}
}
}
- break;
- case 2:
+ }
+ case 2 -> {
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
if (i == 0 && j == 0) continue;
@@ -206,14 +186,12 @@ public class GT_Block_Casings8 extends GT_Block_Casings_Abstract {
}
}
}
- break;
- }
- switch (tMeta) {
- case 9:
- return Textures.BlockIcons.MACHINE_CASING_ADVANCEDGAS.getIcon();
- default:
- return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon();
+ }
}
+ return switch (tMeta) {
+ case 9 -> Textures.BlockIcons.MACHINE_CASING_ADVANCEDGAS.getIcon();
+ default -> Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon();
+ };
}
return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon();
}