diff options
author | Raven Szewczyk <git@eigenraven.me> | 2023-04-01 20:06:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-01 19:06:12 +0000 |
commit | b088958c9f6935d356b6c087c8e8106b400aa24f (patch) | |
tree | be608fac08ba158f1226a4fb9f5b1ed459bac2a9 /src/main/java/gregtech/api/util | |
parent | e52cd9c3458584e58073df5cd9cde1302994f266 (diff) | |
download | GT5-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/util')
21 files changed, 337 insertions, 422 deletions
diff --git a/src/main/java/gregtech/api/util/ColorsMetadataSectionSerializer.java b/src/main/java/gregtech/api/util/ColorsMetadataSectionSerializer.java index 41b6e0013e..ae480343b2 100644 --- a/src/main/java/gregtech/api/util/ColorsMetadataSectionSerializer.java +++ b/src/main/java/gregtech/api/util/ColorsMetadataSectionSerializer.java @@ -11,7 +11,6 @@ import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -20,7 +19,7 @@ import gregtech.api.GregTech_API; import gregtech.api.enums.Dyes; @SideOnly(Side.CLIENT) -public class ColorsMetadataSectionSerializer extends BaseMetadataSectionSerializer implements JsonSerializer { +public class ColorsMetadataSectionSerializer extends BaseMetadataSectionSerializer { public ColorsMetadataSection deserialize(JsonElement metadataColors, Type type, JsonDeserializationContext context) { diff --git a/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java b/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java index 9f648fa7e0..7dc15f994d 100644 --- a/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java +++ b/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java @@ -28,15 +28,15 @@ public class GT_AssemblyLineUtils { /** * A cache of Recipes using the Output as Key. */ - private static HashMap<GT_ItemStack, GT_Recipe_AssemblyLine> sRecipeCacheByOutput = new HashMap<GT_ItemStack, GT_Recipe_AssemblyLine>(); + private static HashMap<GT_ItemStack, GT_Recipe_AssemblyLine> sRecipeCacheByOutput = new HashMap<>(); /** * A cache of Recipes using the Recipe Hash String as Key. */ - private static HashMap<String, GT_Recipe_AssemblyLine> sRecipeCacheByRecipeHash = new HashMap<String, GT_Recipe_AssemblyLine>(); + private static HashMap<String, GT_Recipe_AssemblyLine> sRecipeCacheByRecipeHash = new HashMap<>(); /** * Checks the DataStick for deprecated/invalid recipes, updating them as required. - * + * * @param aDataStick - The DataStick to process * @return Is this DataStick now valid with a current recipe? */ @@ -57,7 +57,7 @@ public class GT_AssemblyLineUtils { /** * Finds an Assembly Line recipe from a DataStick. - * + * * @param aDataStick - The DataStick to check. * @return The GT_Recipe_AssemblyLine recipe contained on the DataStick, if any. */ @@ -67,7 +67,7 @@ public class GT_AssemblyLineUtils { /** * Finds an Assembly Line recipe from a DataStick. - * + * * @param aDataStick - The DataStick to check. * @param aReturnBuiltRecipe - Do we return a GT_Recipe_AssemblyLine built from the data on the Data Stick instead * of searching the Recipe Map? @@ -197,7 +197,7 @@ public class GT_AssemblyLineUtils { /** * Finds a GT_Recipe_AssemblyLine based on the expected output ItemStack. - * + * * @param aOutput - The Output of a GT_Recipe_AssemblyLine. * @return First found GT_Recipe_AssemblyLine with matching output. */ @@ -321,7 +321,7 @@ public class GT_AssemblyLineUtils { /** * Get the Output ItemStack from a Data Stick. - * + * * @param aDataStick - The Data Stick to check. * @return Output ItemStack contained on the Data Stick. */ diff --git a/src/main/java/gregtech/api/util/GT_Assemblyline_Server.java b/src/main/java/gregtech/api/util/GT_Assemblyline_Server.java index fa58c1d614..7a1515ec0c 100644 --- a/src/main/java/gregtech/api/util/GT_Assemblyline_Server.java +++ b/src/main/java/gregtech/api/util/GT_Assemblyline_Server.java @@ -16,10 +16,10 @@ import gregtech.api.enums.MaterialsBotania; public class GT_Assemblyline_Server { - public static LinkedHashMap<String, String> lServerNames = new LinkedHashMap<String, String>(); - private static LinkedHashMap<String, String> internal2 = new LinkedHashMap<String, String>(), - internal3 = new LinkedHashMap<String, String>(), internal4 = new LinkedHashMap<String, String>(); - private static HashMap<String, Property> internal = new HashMap<String, Property>(); + public static LinkedHashMap<String, String> lServerNames = new LinkedHashMap<>(); + private static LinkedHashMap<String, String> internal2 = new LinkedHashMap<>(), internal3 = new LinkedHashMap<>(), + internal4 = new LinkedHashMap<>(); + private static HashMap<String, Property> internal = new HashMap<>(); public static void fillMap(FMLPreInitializationEvent aEvent) { @@ -224,71 +224,54 @@ public class GT_Assemblyline_Server { t = t.substring(0, 1); int i = Integer.parseInt(t); switch (i) { - case 1: - mMats = new Materials[] { Materials.Adamantium, Materials.Aluminium, - Materials.Americium, Materials.AnnealedCopper, Materials.Antimony, - Materials.Arsenic, Materials.AstralSilver, Materials.BatteryAlloy, - Materials.Beryllium, Materials.Bismuth, Materials.BismuthBronze, - Materials.BlackBronze, Materials.BlackSteel, Materials.BlueAlloy, - Materials.BlueSteel, Materials.Brass }; - break; - case 2: - mMats = new Materials[] { Materials.Bronze, Materials.Caesium, - Materials.Cerium, Materials.Chrome, Materials.ChromiumDioxide, - Materials.Cobalt, Materials.CobaltBrass, Materials.Copper, - Materials.Cupronickel, Materials.DamascusSteel, Materials.DarkIron, - Materials.DeepIron, Materials.Desh, Materials.Duranium, - Materials.Dysprosium, Materials.Electrum }; - break; - case 3: - mMats = new Materials[] { Materials.ElectrumFlux, Materials.Enderium, - Materials.Erbium, Materials.Europium, Materials.FierySteel, - Materials.Gadolinium, Materials.Gallium, Materials.Holmium, - Materials.HSLA, Materials.Indium, Materials.InfusedGold, - Materials.Invar, Materials.Iridium, Materials.IronMagnetic, - Materials.IronWood, Materials.Kanthal }; - break; - case 4: - mMats = new Materials[] { Materials.Knightmetal, Materials.Lanthanum, - Materials.Lead, Materials.Lutetium, Materials.Magnalium, - Materials.Magnesium, Materials.Manganese, Materials.MeteoricIron, - Materials.MeteoricSteel, Materials.Trinium, Materials.Mithril, - Materials.Molybdenum, Materials.Naquadah, Materials.NaquadahAlloy, - Materials.NaquadahEnriched, Materials.Naquadria }; - break; - case 5: - mMats = new Materials[] { Materials.Neodymium, Materials.NeodymiumMagnetic, - Materials.Neutronium, Materials.Nichrome, Materials.Nickel, - Materials.Niobium, Materials.NiobiumNitride, - Materials.NiobiumTitanium, Materials.Osmiridium, Materials.Osmium, - Materials.Palladium, Materials.PigIron, Materials.Platinum, - Materials.Plutonium, Materials.Plutonium241, - Materials.Praseodymium }; - break; - case 6: - mMats = new Materials[] { Materials.Promethium, Materials.RedAlloy, - Materials.RedSteel, Materials.RoseGold, Materials.Rubidium, - Materials.Samarium, Materials.Scandium, Materials.ShadowIron, - Materials.ShadowSteel, Materials.Silicon, Materials.Silver, - Materials.SolderingAlloy, Materials.StainlessSteel, Materials.Steel, - Materials.SteelMagnetic, Materials.SterlingSilver }; - break; - case 7: - mMats = new Materials[] { Materials.Sunnarium, Materials.Tantalum, - Materials.Tellurium, Materials.Terbium, Materials.Thaumium, - Materials.Thorium, Materials.Thulium, Materials.Tin, - Materials.TinAlloy, Materials.Titanium, Materials.Tritanium, - Materials.Tungsten, Materials.TungstenSteel, Materials.Ultimet, - Materials.Uranium, Materials.Uranium235 }; - break; - case 8: - mMats = new Materials[] { Materials.Vanadium, Materials.VanadiumGallium, - Materials.WroughtIron, Materials.Ytterbium, Materials.Yttrium, - Materials.YttriumBariumCuprate, Materials.Zinc, - Materials.TungstenCarbide, Materials.VanadiumSteel, Materials.HSSG, - Materials.HSSE, Materials.HSSS, Materials.Steeleaf, - Materials.Ichorium, Materials.Firestone }; - break; + case 1 -> mMats = new Materials[] { Materials.Adamantium, Materials.Aluminium, + Materials.Americium, Materials.AnnealedCopper, Materials.Antimony, + Materials.Arsenic, Materials.AstralSilver, Materials.BatteryAlloy, + Materials.Beryllium, Materials.Bismuth, Materials.BismuthBronze, + Materials.BlackBronze, Materials.BlackSteel, Materials.BlueAlloy, + Materials.BlueSteel, Materials.Brass }; + case 2 -> mMats = new Materials[] { Materials.Bronze, Materials.Caesium, + Materials.Cerium, Materials.Chrome, Materials.ChromiumDioxide, + Materials.Cobalt, Materials.CobaltBrass, Materials.Copper, + Materials.Cupronickel, Materials.DamascusSteel, Materials.DarkIron, + Materials.DeepIron, Materials.Desh, Materials.Duranium, + Materials.Dysprosium, Materials.Electrum }; + case 3 -> mMats = new Materials[] { Materials.ElectrumFlux, Materials.Enderium, + Materials.Erbium, Materials.Europium, Materials.FierySteel, + Materials.Gadolinium, Materials.Gallium, Materials.Holmium, + Materials.HSLA, Materials.Indium, Materials.InfusedGold, + Materials.Invar, Materials.Iridium, Materials.IronMagnetic, + Materials.IronWood, Materials.Kanthal }; + case 4 -> mMats = new Materials[] { Materials.Knightmetal, Materials.Lanthanum, + Materials.Lead, Materials.Lutetium, Materials.Magnalium, + Materials.Magnesium, Materials.Manganese, Materials.MeteoricIron, + Materials.MeteoricSteel, Materials.Trinium, Materials.Mithril, + Materials.Molybdenum, Materials.Naquadah, Materials.NaquadahAlloy, + Materials.NaquadahEnriched, Materials.Naquadria }; + case 5 -> mMats = new Materials[] { Materials.Neodymium, + Materials.NeodymiumMagnetic, Materials.Neutronium, Materials.Nichrome, + Materials.Nickel, Materials.Niobium, Materials.NiobiumNitride, + Materials.NiobiumTitanium, Materials.Osmiridium, Materials.Osmium, + Materials.Palladium, Materials.PigIron, Materials.Platinum, + Materials.Plutonium, Materials.Plutonium241, Materials.Praseodymium }; + case 6 -> mMats = new Materials[] { Materials.Promethium, Materials.RedAlloy, + Materials.RedSteel, Materials.RoseGold, Materials.Rubidium, + Materials.Samarium, Materials.Scandium, Materials.ShadowIron, + Materials.ShadowSteel, Materials.Silicon, Materials.Silver, + Materials.SolderingAlloy, Materials.StainlessSteel, Materials.Steel, + Materials.SteelMagnetic, Materials.SterlingSilver }; + case 7 -> mMats = new Materials[] { Materials.Sunnarium, Materials.Tantalum, + Materials.Tellurium, Materials.Terbium, Materials.Thaumium, + Materials.Thorium, Materials.Thulium, Materials.Tin, Materials.TinAlloy, + Materials.Titanium, Materials.Tritanium, Materials.Tungsten, + Materials.TungstenSteel, Materials.Ultimet, Materials.Uranium, + Materials.Uranium235 }; + case 8 -> mMats = new Materials[] { Materials.Vanadium, + Materials.VanadiumGallium, Materials.WroughtIron, Materials.Ytterbium, + Materials.Yttrium, Materials.YttriumBariumCuprate, Materials.Zinc, + Materials.TungstenCarbide, Materials.VanadiumSteel, Materials.HSSG, + Materials.HSSE, Materials.HSSS, Materials.Steeleaf, Materials.Ichorium, + Materials.Firestone }; } t = entry.getKey() .substring( @@ -307,28 +290,22 @@ public class GT_Assemblyline_Server { t = t.substring(0, 1); int i = Integer.parseInt(t); switch (i) { - case 1: - mMats = new Materials[] { Materials.InfusedAir, Materials.Amber, - Materials.Amethyst, Materials.InfusedWater, Materials.BlueTopaz, - Materials.CertusQuartz, Materials.Dilithium, Materials.EnderEye, - Materials.EnderPearl, Materials.FoolsRuby, Materials.Force, - Materials.Forcicium, Materials.Forcillium, Materials.GreenSapphire, - Materials.InfusedFire, Materials.Jasper, MaterialsBotania.ManaDiamond, - MaterialsBotania.BotaniaDragonstone }; - break; - case 2: - mMats = new Materials[] { Materials.Lazurite, Materials.Lignite, - Materials.Monazite, Materials.Niter, Materials.Olivine, Materials.Opal, - Materials.InfusedOrder, Materials.InfusedEntropy, Materials.Phosphorus, - Materials.Quartzite, Materials.GarnetRed, Materials.Ruby, - Materials.Sapphire, Materials.Sodalite, Materials.Tanzanite, - Materials.InfusedEarth }; - break; - case 3: - mMats = new Materials[] { Materials.Topaz, Materials.Vinteum, - Materials.GarnetYellow, Materials.NetherStar, Materials.Charcoal, - Materials.Blaze }; - break; + case 1 -> mMats = new Materials[] { Materials.InfusedAir, Materials.Amber, + Materials.Amethyst, Materials.InfusedWater, Materials.BlueTopaz, + Materials.CertusQuartz, Materials.Dilithium, Materials.EnderEye, + Materials.EnderPearl, Materials.FoolsRuby, Materials.Force, + Materials.Forcicium, Materials.Forcillium, Materials.GreenSapphire, + Materials.InfusedFire, Materials.Jasper, MaterialsBotania.ManaDiamond, + MaterialsBotania.BotaniaDragonstone }; + case 2 -> mMats = new Materials[] { Materials.Lazurite, Materials.Lignite, + Materials.Monazite, Materials.Niter, Materials.Olivine, Materials.Opal, + Materials.InfusedOrder, Materials.InfusedEntropy, Materials.Phosphorus, + Materials.Quartzite, Materials.GarnetRed, Materials.Ruby, + Materials.Sapphire, Materials.Sodalite, Materials.Tanzanite, + Materials.InfusedEarth }; + case 3 -> mMats = new Materials[] { Materials.Topaz, Materials.Vinteum, + Materials.GarnetYellow, Materials.NetherStar, Materials.Charcoal, + Materials.Blaze }; } t = entry.getKey() .substring( diff --git a/src/main/java/gregtech/api/util/GT_BaseCrop.java b/src/main/java/gregtech/api/util/GT_BaseCrop.java index e66866cd8f..a586ad672e 100644 --- a/src/main/java/gregtech/api/util/GT_BaseCrop.java +++ b/src/main/java/gregtech/api/util/GT_BaseCrop.java @@ -3,6 +3,7 @@ package gregtech.api.util; import static gregtech.api.enums.GT_Values.E; import static gregtech.api.enums.ModIDs.IC2CropPlugin; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; @@ -27,11 +28,18 @@ import ic2.api.crops.ICropTile; public class GT_BaseCrop extends CropCard implements ICropCardInfo { - public static ArrayList<GT_BaseCrop> sCropList = new ArrayList<GT_BaseCrop>(); - private String mName = E, mDiscoveredBy = "Gregorius Techneticies", mAttributes[]; - private int mTier = 0, mMaxSize = 0, mAfterHarvestSize = 0, mHarvestSize = 0, mStats[] = new int[5], - mGrowthSpeed = 0; - private ItemStack mDrop = null, mSpecialDrops[] = null; + public static ArrayList<GT_BaseCrop> sCropList = new ArrayList<>(); + private String mName = E; + private String mDiscoveredBy = "Gregorius Techneticies"; + private String[] mAttributes; + private int mTier = 0; + private int mMaxSize = 0; + private int mAfterHarvestSize = 0; + private int mHarvestSize = 0; + private int[] mStats = new int[5]; + private int mGrowthSpeed = 0; + private ItemStack mDrop = null; + private ItemStack[] mSpecialDrops = null; private Materials mBlock = null; private static boolean bIc2NeiLoaded = IC2CropPlugin.isModLoaded(); @@ -123,19 +131,8 @@ public class GT_BaseCrop extends CropCard implements ICropCardInfo { Class.forName("speiger.src.crops.api.CropPluginAPI") .getField("instance"), this); - } catch (IllegalAccessException ex) { - bIc2NeiLoaded = false; - } catch (IllegalArgumentException ex) { - bIc2NeiLoaded = false; - } catch (java.lang.reflect.InvocationTargetException ex) { - bIc2NeiLoaded = false; - } catch (NoSuchFieldException ex) { - bIc2NeiLoaded = false; - } catch (NoSuchMethodException ex) { - bIc2NeiLoaded = false; - } catch (SecurityException ex) { - bIc2NeiLoaded = false; - } catch (ClassNotFoundException ex) { + } catch (IllegalAccessException | ClassNotFoundException | SecurityException | NoSuchMethodException + | NoSuchFieldException | InvocationTargetException | IllegalArgumentException ex) { bIc2NeiLoaded = false; } } @@ -294,7 +291,7 @@ public class GT_BaseCrop extends CropCard implements ICropCardInfo { @Override public List<String> getCropInformation() { if (mBlock != null) { - ArrayList<String> result = new ArrayList<String>(1); + ArrayList<String> result = new ArrayList<>(1); result.add( String.format( "Requires %s Ore or Block of %s as soil block to reach full growth.", diff --git a/src/main/java/gregtech/api/util/GT_CLS_Compat.java b/src/main/java/gregtech/api/util/GT_CLS_Compat.java index a7cae35d59..4dff5f65f9 100644 --- a/src/main/java/gregtech/api/util/GT_CLS_Compat.java +++ b/src/main/java/gregtech/api/util/GT_CLS_Compat.java @@ -105,11 +105,11 @@ public class GT_CLS_Compat { if (nextBakingMsgAt < now) { nextBakingMsgAt = now + bakingMsgEvery; GT_Mod.GT_FML_LOGGER.info( - String.format("%s - Baking: %d%%", materialsType, (Integer) (currentStep * 100 / sizeStep))); + String.format("%s - Baking: %d%%", materialsType, currentStep * 100 / sizeStep)); } action.accept(m); currentStep += 1; - } ; + } GT_Mod.GT_FML_LOGGER.info(String.format("%s - Baking: Done", materialsType)); try { progressBarStep.set(progressBar, currentStep); @@ -130,7 +130,7 @@ public class GT_CLS_Compat { mEvents, progressBar, m -> m.mMaterial, - m -> GT_Proxy.registerRecipes(m)); + GT_Proxy::registerRecipes); ProgressManager.pop(progressBar); isRegisteringGTmaterials.set(null, false); } @@ -147,7 +147,7 @@ public class GT_CLS_Compat { replacedVanillaItemsSet, progressBar, m -> m.mDefaultLocalName, - m -> GT_PostLoad.doActualRegistration(m)); + GT_PostLoad::doActualRegistration); } public static void pushToDisplayProgress() throws InvocationTargetException, IllegalAccessException { diff --git a/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java b/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java index 113d8cc420..afbcf6145f 100644 --- a/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java +++ b/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java @@ -189,7 +189,7 @@ public abstract class GT_ChunkAssociatedData<T extends GT_ChunkAssociatedData.ID } private void saveRegions(Stream<SuperRegion> stream) { - stream.filter(r -> r.isDirty()) + stream.filter(SuperRegion::isDirty) .map(c -> (Runnable) c::save) .map(r -> CompletableFuture.runAsync(r, IO_WORKERS)) .reduce(CompletableFuture::allOf) @@ -447,12 +447,10 @@ public abstract class GT_ChunkAssociatedData<T extends GT_ChunkAssociatedData.ID World world = Objects.requireNonNull(this.world.get(), "Attempting to load region of another world!"); try (DataInputStream input = new DataInputStream(new FileInputStream(file))) { byte b = input.readByte(); - switch (b) { - case 0: - loadV0(input, world); - break; - default: - GT_Log.err.printf("Unknown ChunkAssociatedData version %d\n", b); + if (b == 0) { + loadV0(input, world); + } else { + GT_Log.err.printf("Unknown ChunkAssociatedData version %d\n", b); } } } diff --git a/src/main/java/gregtech/api/util/GT_HatchElementBuilder.java b/src/main/java/gregtech/api/util/GT_HatchElementBuilder.java index 6c6ac4bc62..c3057f3caa 100644 --- a/src/main/java/gregtech/api/util/GT_HatchElementBuilder.java +++ b/src/main/java/gregtech/api/util/GT_HatchElementBuilder.java @@ -268,7 +268,7 @@ public class GT_HatchElementBuilder<T> { * This will clear the sides set by previous call to this or {@link #allowOnly(ForgeDirection...)} * <p> * Usually mandatory for multis with multiple slices, and otherwise not needed if it contains a single slice only. - * + * * @param facings disallowed direction in ABC coordinate system */ public GT_HatchElementBuilder<T> disallowOnly(ForgeDirection... facings) { @@ -284,7 +284,7 @@ public class GT_HatchElementBuilder<T> { * This will clear the sides set by previous call to this or {@link #disallowOnly(ForgeDirection...)} * <p> * Usually mandatory for multis with multiple slices, and otherwise not needed if it contains a single slice only. - * + * * @param facings allowed direction in ABC coordinate system */ public GT_HatchElementBuilder<T> allowOnly(ForgeDirection... facings) { @@ -376,7 +376,7 @@ public class GT_HatchElementBuilder<T> { } if (mHatchItemFilter == null) { // no item filter -> no placement - return new IStructureElementNoPlacement<T>() { + return new IStructureElementNoPlacement<>() { @Override public boolean check(T t, World world, int x, int y, int z) { @@ -392,7 +392,7 @@ public class GT_HatchElementBuilder<T> { } }; } - return new IStructureElement<T>() { + return new IStructureElement<>() { private String mHint = mHatchItemType == null ? "unspecified GT hatch" : mHatchItemType.get(); diff --git a/src/main/java/gregtech/api/util/GT_Log.java b/src/main/java/gregtech/api/util/GT_Log.java index db7edf7779..2d00c2e061 100644 --- a/src/main/java/gregtech/api/util/GT_Log.java +++ b/src/main/java/gregtech/api/util/GT_Log.java @@ -25,7 +25,7 @@ public class GT_Log { public static class LogBuffer extends PrintStream { - public final List<String> mBufferedOreDictLog = new ArrayList<String>(); + public final List<String> mBufferedOreDictLog = new ArrayList<>(); public LogBuffer() { super(new OutputStream() { diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java index ec3f8a2b70..3dff430782 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -706,42 +706,34 @@ public class GT_ModHandler { .contains("ic2.itemPurifiedCrushed")))) continue; switch (aGTRecipeMap.mUnlocalizedName) { - case "gt.recipe.macerator": - case "gt.recipe.extractor": - case "gt.recipe.compressor": - aGTRecipeMap.addRecipe( - true, - new ItemStack[] { GT_Utility.copyAmount( - iRecipeInputRecipeOutputEntry.getKey() - .getAmount(), - tStack) }, - iRecipeInputRecipeOutputEntry.getValue().items.toArray( - new ItemStack[0]), - null, - null, - null, - null, - 300, - 2, - 0); - break; - case "gt.recipe.thermalcentrifuge": - aGTRecipeMap.addRecipe( - true, - new ItemStack[] { GT_Utility.copyAmount( - iRecipeInputRecipeOutputEntry.getKey() - .getAmount(), - tStack) }, - iRecipeInputRecipeOutputEntry.getValue().items.toArray( - new ItemStack[0]), - null, - null, - null, - null, - 500, - 48, - 0); - break; + case "gt.recipe.macerator", "gt.recipe.extractor", "gt.recipe.compressor" -> aGTRecipeMap.addRecipe( + true, + new ItemStack[] { GT_Utility.copyAmount( + iRecipeInputRecipeOutputEntry.getKey() + .getAmount(), + tStack) }, + iRecipeInputRecipeOutputEntry.getValue().items.toArray(new ItemStack[0]), + null, + null, + null, + null, + 300, + 2, + 0); + case "gt.recipe.thermalcentrifuge" -> aGTRecipeMap.addRecipe( + true, + new ItemStack[] { GT_Utility.copyAmount( + iRecipeInputRecipeOutputEntry.getKey() + .getAmount(), + tStack) }, + iRecipeInputRecipeOutputEntry.getValue().items.toArray(new ItemStack[0]), + null, + null, + null, + null, + 500, + 48, + 0); } } catch (Exception e) { System.err.println(e); @@ -1066,7 +1058,7 @@ public class GT_ModHandler { for (byte i = 0; i < aRecipe.length; i++) { if (aRecipe[i] instanceof IItemContainer) aRecipe[i] = ((IItemContainer) aRecipe[i]).get(1); - else if (aRecipe[i] instanceof Enum) aRecipe[i] = ((Enum) aRecipe[i]).name(); + else if (aRecipe[i] instanceof Enum) aRecipe[i] = ((Enum<?>) aRecipe[i]).name(); else if (!(aRecipe[i] == null || aRecipe[i] instanceof ItemStack || aRecipe[i] instanceof ItemData || aRecipe[i] instanceof String @@ -1092,62 +1084,62 @@ public class GT_ModHandler { for (char c : s.toString() .toCharArray()) { switch (c) { - case 'b': + case 'b' -> { tRecipeList.add(c); tRecipeList.add(ToolDictNames.craftingToolBlade.name()); - break; - case 'c': + } + case 'c' -> { tRecipeList.add(c); tRecipeList.add(ToolDictNames.craftingToolCrowbar.name()); - break; - case 'd': + } + case 'd' -> { tRecipeList.add(c); tRecipeList.add(ToolDictNames.craftingToolScrewdriver.name()); - break; - case 'f': + } + case 'f' -> { tRecipeList.add(c); tRecipeList.add(ToolDictNames.craftingToolFile.name()); - break; - case 'h': + } + case 'h' -> { tRecipeList.add(c); tRecipeList.add(ToolDictNames.craftingToolHardHammer.name()); - break; - case 'i': + } + case 'i' -> { tRecipeList.add(c); tRecipeList.add(ToolDictNames.craftingToolSolderingIron.name()); - break; - case 'j': + } + case 'j' -> { tRecipeList.add(c); tRecipeList.add(ToolDictNames.craftingToolSolderingMetal.name()); - break; - case 'k': + } + case 'k' -> { tRecipeList.add(c); tRecipeList.add(ToolDictNames.craftingToolKnife.name()); - break; - case 'm': + } + case 'm' -> { tRecipeList.add(c); tRecipeList.add(ToolDictNames.craftingToolMortar.name()); - break; - case 'p': + } + case 'p' -> { tRecipeList.add(c); tRecipeList.add(ToolDictNames.craftingToolDrawplate.name()); - break; - case 'r': + } + case 'r' -> { tRecipeList.add(c); tRecipeList.add(ToolDictNames.craftingToolSoftHammer.name()); - break; - case 's': + } + case 's' -> { tRecipeList.add(c); tRecipeList.add(ToolDictNames.craftingToolSaw.name()); - break; - case 'w': + } + case 'w' -> { tRecipeList.add(c); tRecipeList.add(ToolDictNames.craftingToolWrench.name()); - break; - case 'x': + } + case 'x' -> { tRecipeList.add(c); tRecipeList.add(ToolDictNames.craftingToolWireCutter.name()); - break; + } } } } @@ -1175,28 +1167,17 @@ public class GT_ModHandler { } Character chr = (Character) aRecipe[idx]; Object in = aRecipe[idx + 1]; - if (in instanceof ItemStack) { - ItemStack is = (ItemStack) in; + if (in instanceof ItemStack is) { tItemStackMap.put(chr, GT_Utility.copyOrNull(is)); tItemDataMap.put(chr, GT_OreDictUnificator.getItemData(is)); } else if (in instanceof ItemData) { String tString = in.toString(); switch (tString) { - case "plankWood": - tItemDataMap.put(chr, new ItemData(Materials.Wood, M)); - break; - case "stoneNetherrack": - tItemDataMap.put(chr, new ItemData(Materials.Netherrack, M)); - break; - case "stoneObsidian": - tItemDataMap.put(chr, new ItemData(Materials.Obsidian, M)); - break; - case "stoneEndstone": - tItemDataMap.put(chr, new ItemData(Materials.Endstone, M)); - break; - default: - tItemDataMap.put(chr, (ItemData) in); - break; + case "plankWood" -> tItemDataMap.put(chr, new ItemData(Materials.Wood, M)); + case "stoneNetherrack" -> tItemDataMap.put(chr, new ItemData(Materials.Netherrack, M)); + case "stoneObsidian" -> tItemDataMap.put(chr, new ItemData(Materials.Obsidian, M)); + case "stoneEndstone" -> tItemDataMap.put(chr, new ItemData(Materials.Endstone, M)); + default -> tItemDataMap.put(chr, (ItemData) in); } ItemStack tStack = GT_OreDictUnificator.getFirstOre(in, 1); if (tStack == null) tRemoveRecipe = false; @@ -1360,7 +1341,7 @@ public class GT_ModHandler { if (aRecipe == null || aRecipe.length <= 0) return false; for (byte i = 0; i < aRecipe.length; i++) { if (aRecipe[i] instanceof IItemContainer) aRecipe[i] = ((IItemContainer) aRecipe[i]).get(1); - else if (aRecipe[i] instanceof Enum) aRecipe[i] = ((Enum) aRecipe[i]).name(); + else if (aRecipe[i] instanceof Enum) aRecipe[i] = ((Enum<?>) aRecipe[i]).name(); else if (!(aRecipe[i] == null || aRecipe[i] instanceof ItemStack || aRecipe[i] instanceof String || aRecipe[i] instanceof Character)) @@ -1424,10 +1405,10 @@ public class GT_ModHandler { */ public static boolean removeFurnaceSmelting(ItemStack aInput) { if (aInput != null) { - for (Object tInput : FurnaceRecipes.smelting() - .getSmeltingList() - .keySet()) { - if (GT_Utility.isStackValid(tInput) && GT_Utility.areStacksEqual(aInput, (ItemStack) tInput, true)) { + for (ItemStack tInput : FurnaceRecipes.smelting() + .getSmeltingList() + .keySet()) { + if (GT_Utility.isStackValid(tInput) && GT_Utility.areStacksEqual(aInput, tInput, true)) { FurnaceRecipes.smelting() .getSmeltingList() .remove(tInput); @@ -1448,7 +1429,7 @@ public class GT_ModHandler { .values() .removeIf( tOutput -> GT_Utility.isStackValid(tOutput) - && GT_Utility.areStacksEqual(aOutput, (ItemStack) tOutput, true)); + && GT_Utility.areStacksEqual(aOutput, tOutput, true)); } return false; } @@ -1692,7 +1673,7 @@ public class GT_ModHandler { int tNewDamage = tStack1.getMaxDamage() + tStack1.getItemDamage() - tStack2.getItemDamage() + tStack1.getMaxDamage() / 20; - return new ItemStack(tStack1.getItem(), 1, tNewDamage < 0 ? 0 : tNewDamage); + return new ItemStack(tStack1.getItem(), 1, Math.max(tNewDamage, 0)); } } @@ -1767,8 +1748,8 @@ public class GT_ModHandler { if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished) sSingleNonBlockDamagableRecipeList.clear(); if (sSingleNonBlockDamagableRecipeList.isEmpty()) { - for (IRecipe tRecipe : (ArrayList<IRecipe>) CraftingManager.getInstance() - .getRecipeList()) { + for (IRecipe tRecipe : CraftingManager.getInstance() + .getRecipeList()) { ItemStack tStack = tRecipe.getRecipeOutput(); if (GT_Utility.isStackValid(tStack) && tStack.getMaxStackSize() == 1 && tStack.getMaxDamage() > 0 @@ -1787,7 +1768,7 @@ public class GT_ModHandler { temp = false; break; } - if (tObject instanceof List && ((List) tObject).isEmpty()) { + if (tObject instanceof List && ((List<?>) tObject).isEmpty()) { temp = false; break; } @@ -1843,27 +1824,26 @@ public class GT_ModHandler { */ public static List<ItemStack> getRecipeOutputsBuffered(ItemStack... aRecipe) { - if (bufferedRecipes == null) bufferedRecipes = (List<IRecipe>) CraftingManager.getInstance() - .getRecipeList() - .stream() - .filter( - tRecipe -> !(tRecipe instanceof ShapelessRecipes) - && !(tRecipe instanceof ShapelessOreRecipe) - && !(tRecipe instanceof IGT_CraftingRecipe)) - .filter(tRecipe -> { - try { - ItemStack tOutput = ((IRecipe) tRecipe).getRecipeOutput(); - if (tOutput.stackSize == 1 - && tOutput.getMaxDamage() - > 0 - && tOutput.getMaxStackSize() - == 1) { - return true; - } - } catch (Exception ignored) {} - return false; - }) - .collect(Collectors.toList()); + if (bufferedRecipes == null) bufferedRecipes = CraftingManager.getInstance() + .getRecipeList() + .stream() + .filter( + tRecipe -> !(tRecipe instanceof ShapelessRecipes) + && !(tRecipe instanceof ShapelessOreRecipe) + && !(tRecipe instanceof IGT_CraftingRecipe)) + .filter(tRecipe -> { + try { + ItemStack tOutput = tRecipe.getRecipeOutput(); + if (tOutput.stackSize == 1 + && tOutput.getMaxDamage() > 0 + && tOutput.getMaxStackSize() + == 1) { + return true; + } + } catch (Exception ignored) {} + return false; + }) + .collect(Collectors.toList()); return getRecipeOutputs(bufferedRecipes, false, aRecipe); } @@ -2209,8 +2189,7 @@ public class GT_ModHandler { public static boolean useSolderingIron(ItemStack aStack, EntityLivingBase aPlayer, IInventory aExternalInventory) { if (aPlayer == null || aStack == null) return false; if (GT_Utility.isStackInList(aStack, GregTech_API.sSolderingToolList)) { - if (aPlayer instanceof EntityPlayer) { - EntityPlayer tPlayer = (EntityPlayer) aPlayer; + if (aPlayer instanceof EntityPlayer tPlayer) { if (tPlayer.capabilities.isCreativeMode) return true; if (isElectricItem(aStack) && ic2.api.item.ElectricItem.manager.getCharge(aStack) > 1000.0d) { if (consumeSolderingMaterial(tPlayer) diff --git a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java index 6670b86363..b8072f7b3b 100644 --- a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java +++ b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java @@ -305,7 +305,7 @@ public class GT_OreDictUnificator { ItemStack[] aStacks = {}; if (obj instanceof ItemStack) aStacks = new ItemStack[] { (ItemStack) obj }; else if (obj instanceof ItemStack[]) aStacks = (ItemStack[]) obj; - else if (obj instanceof List) aStacks = (ItemStack[]) ((List) obj).toArray(new ItemStack[0]); + else if (obj instanceof List) aStacks = (ItemStack[]) ((List<?>) obj).toArray(new ItemStack[0]); List<ItemStack> rList = new ArrayList<>(); for (ItemStack aStack : aStacks) { if (aStack == null) continue; diff --git a/src/main/java/gregtech/api/util/GT_ParallelHelper.java b/src/main/java/gregtech/api/util/GT_ParallelHelper.java index c12f8ec378..0914d2be29 100644 --- a/src/main/java/gregtech/api/util/GT_ParallelHelper.java +++ b/src/main/java/gregtech/api/util/GT_ParallelHelper.java @@ -32,7 +32,7 @@ public class GT_ParallelHelper { /** * @mMachineMulti a MultiTileEntity Controller */ - private MultiBlockController mMachineMulti; + private MultiBlockController<?> mMachineMulti; /** * @mRecipe Recipe used when trying to calculate parallels */ @@ -87,7 +87,7 @@ public class GT_ParallelHelper { /** * Enables void protection on a multitile multiblock. Experimental! Still needs to be worked on */ - public GT_ParallelHelper enableVoidProtection(MultiBlockController aMachineMulti) { + public GT_ParallelHelper enableVoidProtection(MultiBlockController<?> aMachineMulti) { mVoidProtection = true; mMachineMulti = aMachineMulti; return this; diff --git a/src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java b/src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java index 50014afdd1..66bc16cae3 100644 --- a/src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java +++ b/src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java @@ -7,7 +7,7 @@ import gregtech.api.util.GT_Recipe.GT_Recipe_Map; public class GT_ProcessingArray_Manager { - private static final HashMap<String, GT_Recipe_Map> mRecipeSaves = new HashMap<String, GT_Recipe_Map>(); + private static final HashMap<String, GT_Recipe_Map> mRecipeSaves = new HashMap<>(); private static final HashMap<String, SoundResource> machineSounds = new HashMap<>(); // Adds recipe Maps to the PA using the machines unlocalized name. diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 7f39ef694d..b5603619af 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -317,31 +317,27 @@ public class GT_Recipe implements Comparable<GT_Recipe> { if (mInputs.length > 0 && aSpecialValue > 0) { switch (aType) { // Diesel Generator - case 0: + case 0 -> { GT_Recipe_Map.sDieselFuels.addRecipe(this); GT_Recipe_Map.sLargeBoilerFakeFuels.addDieselRecipe(this); - break; + } // Gas Turbine - case 1: - GT_Recipe_Map.sTurbineFuels.addRecipe(this); - break; + case 1 -> GT_Recipe_Map.sTurbineFuels.addRecipe(this); + // Thermal Generator - case 2: - GT_Recipe_Map.sHotFuels.addRecipe(this); - break; + case 2 -> GT_Recipe_Map.sHotFuels.addRecipe(this); + // Plasma Generator - case 4: - GT_Recipe_Map.sPlasmaFuels.addRecipe(this); - break; + case 4 -> GT_Recipe_Map.sPlasmaFuels.addRecipe(this); + // Magic Generator - case 5: - GT_Recipe_Map.sMagicFuels.addRecipe(this); - break; + case 5 -> GT_Recipe_Map.sMagicFuels.addRecipe(this); + // Fluid Generator. Usually 3. Every wrong Type ends up in the Semifluid Generator - default: + default -> { GT_Recipe_Map.sDenseLiquidFuels.addRecipe(this); GT_Recipe_Map.sLargeBoilerFakeFuels.addDenseLiquidRecipe(this); - break; + } } } } @@ -889,7 +885,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { public static class GT_Recipe_AssemblyLine { - public static final ArrayList<GT_Recipe_AssemblyLine> sAssemblylineRecipes = new ArrayList<GT_Recipe_AssemblyLine>(); + public static final ArrayList<GT_Recipe_AssemblyLine> sAssemblylineRecipes = new ArrayList<>(); static { if (!Boolean.getBoolean("com.gtnh.gt5u.ignore-invalid-assline-recipe")) @@ -993,10 +989,9 @@ public class GT_Recipe implements Comparable<GT_Recipe> { if (this == obj) { return true; } - if (!(obj instanceof GT_Recipe_AssemblyLine)) { + if (!(obj instanceof GT_Recipe_AssemblyLine other)) { return false; } - GT_Recipe_AssemblyLine other = (GT_Recipe_AssemblyLine) obj; if (this.mInputs.length != other.mInputs.length) { return false; } @@ -1244,13 +1239,12 @@ public class GT_Recipe implements Comparable<GT_Recipe> { public IDrawable getOverlayForSlot(boolean isFluid, boolean isOutput, int index, boolean isSpecial) { if (isOutput) { switch (index) { - case 0: - case 2: - case 6: - case 8: + case 0, 2, 6, 8 -> { return GT_UITextures.OVERLAY_SLOT_CIRCUIT; - case 4: + } + case 4 -> { return GT_UITextures.OVERLAY_SLOT_WRENCH; + } } } return super.getOverlayForSlot(isFluid, isOutput, index, isSpecial); @@ -4057,15 +4051,11 @@ public class GT_Recipe implements Comparable<GT_Recipe> { if (progressBarImageSize != 0) { return progressBarImageSize; } - switch (progressBarDirection) { - case UP: - case DOWN: - return progressBarSize.height; - case CIRCULAR_CW: - return Math.max(progressBarSize.width, progressBarSize.height); - default: - return progressBarSize.width; - } + return switch (progressBarDirection) { + case UP, DOWN -> progressBarSize.height; + case CIRCULAR_CW -> Math.max(progressBarSize.width, progressBarSize.height); + default -> progressBarSize.width; + }; } /** diff --git a/src/main/java/gregtech/api/util/GT_RecipeBuilder.java b/src/main/java/gregtech/api/util/GT_RecipeBuilder.java index dc3dd8bba1..eeeb60de94 100644 --- a/src/main/java/gregtech/api/util/GT_RecipeBuilder.java +++ b/src/main/java/gregtech/api/util/GT_RecipeBuilder.java @@ -141,8 +141,7 @@ public class GT_RecipeBuilder { alts[i] = new ItemStack[] { (ItemStack) input }; } else if (input instanceof ItemStack[]) { alts[i] = ((ItemStack[]) input).clone(); - } else if (input instanceof Object[]) { - Object[] arr = (Object[]) input; + } else if (input instanceof Object[]arr) { if (arr.length != 2) continue; List<ItemStack> ores = GT_OreDictUnificator.getOres(arr[0]); if (ores.isEmpty()) continue; diff --git a/src/main/java/gregtech/api/util/GT_RecipeConstants.java b/src/main/java/gregtech/api/util/GT_RecipeConstants.java index 701e1ee4a8..206cb38118 100644 --- a/src/main/java/gregtech/api/util/GT_RecipeConstants.java +++ b/src/main/java/gregtech/api/util/GT_RecipeConstants.java @@ -149,8 +149,7 @@ public class GT_RecipeConstants { tPersistentHash = tPersistentHash * 31 + GT_Utility.persistentHash(alt, true, false); } tPersistentHash *= 31; - } else if (input instanceof Object[]) { - Object[] objs = (Object[]) input; + } else if (input instanceof Object[]objs) { Arrays.sort( alts, Comparator.<ItemStack, String>comparing( diff --git a/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java index b6a4b960c7..19afbb9ff0 100644 --- a/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java +++ b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java @@ -40,7 +40,7 @@ public class GT_RecipeRegistrator { * List of Materials, which are used in the Creation of Sticks. All Rod Materials are automatically added to this * List. */ - public static final List<Materials> sRodMaterialList = new ArrayList<Materials>(); + public static final List<Materials> sRodMaterialList = new ArrayList<>(); private static final ItemStack sMt1 = new ItemStack(Blocks.dirt, 1, 0), sMt2 = new ItemStack(Blocks.dirt, 1, 0); private static final String s_H = "h", s_F = "f", s_I = "I", s_P = "P", s_R = "R"; @@ -591,31 +591,23 @@ public class GT_RecipeRegistrator { true)) { if (null != (tStack = GT_ModHandler.removeRecipe(tRecipe.shape))) { switch (sShapesA[i].length) { - case 2: - GT_ModHandler.addCraftingRecipe( - tStack, - GT_ModHandler.RecipeBits.BUFFERED, - new Object[] { sShapesA[i][1], s_P.charAt(0), aPlate, s_R.charAt(0), - OrePrefixes.stick.get(tMaterial), s_I.charAt(0), - aItemData }); - break; - case 3: - GT_ModHandler.addCraftingRecipe( - tStack, - GT_ModHandler.RecipeBits.BUFFERED, - new Object[] { sShapesA[i][1], sShapesA[i][2], s_P.charAt(0), - aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), - s_I.charAt(0), aItemData }); - break; - default: - GT_ModHandler.addCraftingRecipe( - tStack, - GT_ModHandler.RecipeBits.BUFFERED, - new Object[] { sShapesA[i][1], sShapesA[i][2], sShapesA[i][3], - s_P.charAt(0), aPlate, s_R.charAt(0), - OrePrefixes.stick.get(tMaterial), s_I.charAt(0), - aItemData }); - break; + case 2 -> GT_ModHandler.addCraftingRecipe( + tStack, + GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { sShapesA[i][1], s_P.charAt(0), aPlate, s_R.charAt(0), + OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData }); + case 3 -> GT_ModHandler.addCraftingRecipe( + tStack, + GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { sShapesA[i][1], sShapesA[i][2], s_P.charAt(0), aPlate, + s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), + aItemData }); + default -> GT_ModHandler.addCraftingRecipe( + tStack, + GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { sShapesA[i][1], sShapesA[i][2], sShapesA[i][3], + s_P.charAt(0), aPlate, s_R.charAt(0), + OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData }); } } } @@ -628,7 +620,7 @@ public class GT_RecipeRegistrator { /** * Registers wiremill recipes for given material using integrated circuits. - * + * * @param aMaterial material to register * @param baseDuration base duration ticks for ingot -> 1x wire recipe * @param aEUt EU/t for recipe If you provide a proper EU tier for recipe processing then aEUt will be @@ -646,7 +638,7 @@ public class GT_RecipeRegistrator { /** * Registers wiremill recipes for given material using integrated circuits. - * + * * @param aMaterial material to register * @param baseDuration base duration ticks for ingot -> 1x wire recipe * @param aEUt EU/t for recipe diff --git a/src/main/java/gregtech/api/util/GT_RenderingWorld.java b/src/main/java/gregtech/api/util/GT_RenderingWorld.java index b8caa59554..4ada7decab 100644 --- a/src/main/java/gregtech/api/util/GT_RenderingWorld.java +++ b/src/main/java/gregtech/api/util/GT_RenderingWorld.java @@ -3,6 +3,7 @@ package gregtech.api.util; import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import java.util.Objects; import java.util.Set; import net.minecraft.block.Block; @@ -181,7 +182,7 @@ public class GT_RenderingWorld implements IBlockAccess { BlockInfo blockInfo = (BlockInfo) o; if (meta != blockInfo.meta) return false; - return block != null ? block.equals(blockInfo.block) : blockInfo.block == null; + return Objects.equals(block, blockInfo.block); } @Override diff --git a/src/main/java/gregtech/api/util/GT_StructureUtility.java b/src/main/java/gregtech/api/util/GT_StructureUtility.java index 80fc64a8c3..703e056bc9 100644 --- a/src/main/java/gregtech/api/util/GT_StructureUtility.java +++ b/src/main/java/gregtech/api/util/GT_StructureUtility.java @@ -59,15 +59,14 @@ public class GT_StructureUtility { public static <T> IStructureElement<T> ofFrame(Materials aFrameMaterial) { if (aFrameMaterial == null) throw new IllegalArgumentException(); - return new IStructureElement<T>() { + return new IStructureElement<>() { private IIcon[] mIcons; @Override public boolean check(T t, World world, int x, int y, int z) { TileEntity tBase = world.getTileEntity(x, y, z); - if (tBase instanceof BaseMetaPipeEntity) { - BaseMetaPipeEntity tPipeBase = (BaseMetaPipeEntity) tBase; + if (tBase instanceof BaseMetaPipeEntity tPipeBase) { if (tPipeBase.isInvalidTileEntity()) return false; if (tPipeBase.getMetaTileEntity() instanceof GT_MetaPipeEntity_Frame) return aFrameMaterial == ((GT_MetaPipeEntity_Frame) tPipeBase.getMetaTileEntity()).mMaterial; @@ -88,9 +87,9 @@ public class GT_StructureUtility { @Override public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { ItemStack tFrameStack = getFrameStack(); - if (!GT_Utility.isStackValid(tFrameStack) || !(tFrameStack.getItem() instanceof ItemBlock)) + if (!GT_Utility.isStackValid(tFrameStack) + || !(tFrameStack.getItem() instanceof ItemBlock tFrameStackItem)) return false; - ItemBlock tFrameStackItem = (ItemBlock) tFrameStack.getItem(); return tFrameStackItem.placeBlockAt( tFrameStack, null, @@ -171,7 +170,7 @@ public class GT_StructureUtility { if (aHatchAdder == null || aHintBlock == null) { throw new IllegalArgumentException(); } - return new IStructureElementNoPlacement<T>() { + return new IStructureElementNoPlacement<>() { @Override public boolean check(T t, World world, int x, int y, int z) { @@ -194,7 +193,7 @@ public class GT_StructureUtility { if (aHatchAdder == null) { throw new IllegalArgumentException(); } - return new IStructureElement<T>() { + return new IStructureElement<>() { @Override public boolean check(T t, World world, int x, int y, int z) { @@ -280,7 +279,7 @@ public class GT_StructureUtility { if (aHatchAdder == null) { throw new IllegalArgumentException(); } - return new IStructureElement<T>() { + return new IStructureElement<>() { @Override public boolean check(T t, World world, int x, int y, int z) { @@ -379,7 +378,7 @@ public class GT_StructureUtility { if (aHatchAdder == null || aHintBlock == null) { throw new IllegalArgumentException(); } - return new IStructureElement<T>() { + return new IStructureElement<>() { @Override public boolean check(T t, World world, int x, int y, int z) { @@ -446,7 +445,7 @@ public class GT_StructureUtility { if (aHeatingCoilSetter == null || aHeatingCoilGetter == null) { throw new IllegalArgumentException(); } - return new IStructureElement<T>() { + return new IStructureElement<>() { @Override public boolean check(T t, World world, int x, int y, int z) { diff --git a/src/main/java/gregtech/api/util/GT_TooltipDataCache.java b/src/main/java/gregtech/api/util/GT_TooltipDataCache.java index 699517d288..cb702688cf 100644 --- a/src/main/java/gregtech/api/util/GT_TooltipDataCache.java +++ b/src/main/java/gregtech/api/util/GT_TooltipDataCache.java @@ -72,7 +72,7 @@ public class GT_TooltipDataCache { * @return The lines for the key and all of it's subkeys */ private List<String> getAllLines(String key, Object... args) { - List<String> lines = new ArrayList<String>(); + List<String> lines = new ArrayList<>(); String keyToLookup = key; int i = 1; // First loop has no .number postfix while (StatCollector.canTranslate(keyToLookup)) { diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 859c1ab84b..12e5022ef0 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -82,6 +82,8 @@ import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.oredict.OreDictionary; +import buildcraft.api.transport.IPipeTile; +import cofh.api.energy.IEnergyReceiver; import cofh.api.transport.IItemDuct; import com.google.auto.value.AutoValue; @@ -212,7 +214,7 @@ public class GT_Utility { return rField; } - public static Field getField(Class aObject, String aField) { + public static Field getField(Class<?> aObject, String aField) { Field rField = null; try { rField = aObject.getDeclaredField(aField); @@ -223,7 +225,7 @@ public class GT_Utility { return rField; } - public static Method getMethod(Class aObject, String aMethod, Class<?>... aParameterTypes) { + public static Method getMethod(Class<?> aObject, String aMethod, Class<?>... aParameterTypes) { Method rMethod = null; try { rMethod = aObject.getMethod(aMethod, aParameterTypes); @@ -248,7 +250,7 @@ public class GT_Utility { public static Field getField(Object aObject, String aField, boolean aPrivate, boolean aLogErrors) { try { - Field tField = (aObject instanceof Class) ? ((Class) aObject).getDeclaredField(aField) + Field tField = (aObject instanceof Class) ? ((Class<?>) aObject).getDeclaredField(aField) : (aObject instanceof String) ? Class.forName((String) aObject) .getDeclaredField(aField) : aObject.getClass() @@ -263,7 +265,7 @@ public class GT_Utility { public static Object getFieldContent(Object aObject, String aField, boolean aPrivate, boolean aLogErrors) { try { - Field tField = (aObject instanceof Class) ? ((Class) aObject).getDeclaredField(aField) + Field tField = (aObject instanceof Class) ? ((Class<?>) aObject).getDeclaredField(aField) : (aObject instanceof String) ? Class.forName((String) aObject) .getDeclaredField(aField) : aObject.getClass() @@ -290,7 +292,7 @@ public class GT_Utility { Class<?>[] tParameterTypes = new Class<?>[aParameters.length]; for (byte i = 0; i < aParameters.length; i++) { if (aParameters[i] instanceof Class) { - tParameterTypes[i] = (Class) aParameters[i]; + tParameterTypes[i] = (Class<?>) aParameters[i]; aParameters[i] = null; } else { tParameterTypes[i] = aParameters[i].getClass(); @@ -306,7 +308,7 @@ public class GT_Utility { } } - Method tMethod = (aObject instanceof Class) ? ((Class) aObject).getMethod(aMethod, tParameterTypes) + Method tMethod = (aObject instanceof Class) ? ((Class<?>) aObject).getMethod(aMethod, tParameterTypes) : aObject.getClass() .getMethod(aMethod, tParameterTypes); if (aPrivate) tMethod.setAccessible(true); @@ -375,7 +377,7 @@ public class GT_Utility { } } - if (tPotionHashmap != null) return ((HashMap) tPotionHashmap.get(aPlayer)).get(aPotionIndex) != null; + if (tPotionHashmap != null) return ((HashMap<?, ?>) tPotionHashmap.get(aPlayer)).get(aPotionIndex) != null; } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); } @@ -406,7 +408,7 @@ public class GT_Utility { } } - if (tPotionHashmap != null) ((HashMap) tPotionHashmap.get(aPlayer)).remove(aPotionIndex); + if (tPotionHashmap != null) ((HashMap<?, ?>) tPotionHashmap.get(aPlayer)).remove(aPotionIndex); } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); } @@ -436,7 +438,7 @@ public class GT_Utility { public static ItemStack suckOneItemStackAt(World aWorld, double aX, double aY, double aZ, double aL, double aH, double aW) { - for (EntityItem tItem : (ArrayList<EntityItem>) aWorld.getEntitiesWithinAABB( + for (EntityItem tItem : aWorld.getEntitiesWithinAABB( EntityItem.class, AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + aL, aY + aH, aZ + aW))) { if (!tItem.isDead) { @@ -477,21 +479,21 @@ public class GT_Utility { public static void checkAvailabilities() { if (CHECK_ALL) { try { - Class tClass = IItemDuct.class; + Class<IItemDuct> tClass = IItemDuct.class; tClass.getCanonicalName(); TE_CHECK = true; } catch (Throwable e) { /**/ } try { - Class tClass = buildcraft.api.transport.IPipeTile.class; + Class<IPipeTile> tClass = buildcraft.api.transport.IPipeTile.class; tClass.getCanonicalName(); BC_CHECK = true; } catch (Throwable e) { /**/ } try { - Class tClass = cofh.api.energy.IEnergyReceiver.class; + Class<IEnergyReceiver> tClass = cofh.api.energy.IEnergyReceiver.class; tClass.getCanonicalName(); RF_CHECK = true; } catch (Throwable e) { @@ -820,8 +822,7 @@ public class GT_Utility { } // if target is an inventory, e.g. chest, machine, drawers... - if (aTileEntity2 instanceof IInventory) { - final IInventory tPutInventory = (IInventory) aTileEntity2; + if (aTileEntity2 instanceof IInventory tPutInventory) { // partially filled slot spare space mapping. // value is the sum of all spare space left not counting completely empty slot @@ -1261,8 +1262,7 @@ public class GT_Utility { if (tMovedItemCount > 0) return tMovedItemCount; } - if (aDoCheckChests && aTileEntity1 instanceof TileEntityChest) { - TileEntityChest tTileEntity1 = (TileEntityChest) aTileEntity1; + if (aDoCheckChests && aTileEntity1 instanceof TileEntityChest tTileEntity1) { if (tTileEntity1.adjacentChestChecked) { byte tAmount = 0; if (tTileEntity1.adjacentChestXNeg != null) { @@ -1321,8 +1321,7 @@ public class GT_Utility { if (tAmount != 0) return tAmount; } } - if (aDoCheckChests && aTileEntity2 instanceof TileEntityChest) { - TileEntityChest tTileEntity2 = (TileEntityChest) aTileEntity2; + if (aDoCheckChests && aTileEntity2 instanceof TileEntityChest tTileEntity2) { if (tTileEntity2.adjacentChestChecked) { byte tAmount = 0; if (tTileEntity2.adjacentChestXNeg != null) { @@ -1566,8 +1565,7 @@ public class GT_Utility { } if (tMovedItemCount > 0) return tMovedItemCount; - if (aDoCheckChests && toTile instanceof TileEntityChest) { - TileEntityChest tTileEntity2 = (TileEntityChest) toTile; + if (aDoCheckChests && toTile instanceof TileEntityChest tTileEntity2) { if (tTileEntity2.adjacentChestChecked) { if (tTileEntity2.adjacentChestXNeg != null) { tMovedItemCount = moveFromSlotToSide( @@ -2342,11 +2340,12 @@ public class GT_Utility { return listContains(aObject, Arrays.asList(aObjects)); } - public static boolean listContains(Object aObject, Collection aObjects) { + public static boolean listContains(Object aObject, Collection<?> aObjects) { if (aObjects == null) return false; return aObjects.contains(aObject); } + @SafeVarargs public static <T> boolean arrayContainsNonNull(T... aArray) { if (aArray != null) for (Object tObject : aArray) if (tObject != null) return true; return false; @@ -2355,6 +2354,7 @@ public class GT_Utility { /** * Note: use {@link ArrayExt#withoutNulls(Object[], IntFunction)} if you want an array as a result. */ + @SafeVarargs public static <T> ArrayList<T> getArrayListWithoutNulls(T... aArray) { if (aArray == null) return new ArrayList<>(); ArrayList<T> rList = new ArrayList<>(Arrays.asList(aArray)); @@ -2365,6 +2365,7 @@ public class GT_Utility { /** * Note: use {@link ArrayExt#withoutTrailingNulls(Object[], IntFunction)} if you want an array as a result. */ + @SafeVarargs public static <T> ArrayList<T> getArrayListWithoutTrailingNulls(T... aArray) { if (aArray == null) return new ArrayList<>(); ArrayList<T> rList = new ArrayList<>(Arrays.asList(aArray)); @@ -2731,7 +2732,7 @@ public class GT_Utility { Map<Integer, Integer> tEnchantments = EnchantmentHelper.getEnchantments(aStack); Integer tLevel = tEnchantments.get(Enchantment_Hazmat.INSTANCE.effectId); - if (tLevel != null && tLevel.intValue() >= 1) { + if (tLevel != null && tLevel >= 1) { return true; } return false; @@ -3002,6 +3003,7 @@ public class GT_Utility { return aList.get(aIndex); } + @SafeVarargs public static <E> E selectItemInList(int aIndex, E aReplacement, E... aList) { if (aList == null || aList.length == 0) return aReplacement; if (aList.length <= aIndex) return aList[aList.length - 1]; @@ -3053,7 +3055,7 @@ public class GT_Utility { /** * Why the fuck do neither Java nor Guava have a Function to do this? */ - public static <X, Y extends Comparable> LinkedHashMap<X, Y> sortMapByValuesDescending(Map<X, Y> aMap) { + public static <X, Y extends Comparable<Y>> LinkedHashMap<X, Y> sortMapByValuesDescending(Map<X, Y> aMap) { List<Map.Entry<X, Y>> tEntrySet = new LinkedList<>(aMap.entrySet()); tEntrySet.sort((aValue1, aValue2) -> { return aValue2.getValue() @@ -3101,9 +3103,9 @@ public class GT_Utility { if (entity.riddenByEntity != null) entity.riddenByEntity.mountEntity(null); World startWorld = entity.worldObj; - World destinationWorld = FMLCommonHandler.instance() - .getMinecraftServerInstance() - .worldServerForDimension(aDimension); + WorldServer destinationWorld = FMLCommonHandler.instance() + .getMinecraftServerInstance() + .worldServerForDimension(aDimension); if (destinationWorld == null) { return false; @@ -3143,7 +3145,7 @@ public class GT_Utility { entity.setLocationAndAngles(aX, aY, aZ, entity.rotationYaw, entity.rotationPitch); - ((WorldServer) destinationWorld).theChunkProviderServer.loadChunk((int) aX >> 4, (int) aZ >> 4); + destinationWorld.theChunkProviderServer.loadChunk((int) aX >> 4, (int) aZ >> 4); destinationWorld.theProfiler.startSection("placing"); if (interDimensional) { @@ -3171,7 +3173,7 @@ public class GT_Utility { EntityPlayerMP player = (EntityPlayerMP) entity; if (interDimensional) { player.mcServer.getConfigurationManager() - .func_72375_a(player, (WorldServer) destinationWorld); + .func_72375_a(player, destinationWorld); } player.playerNetServerHandler.setPlayerLocation(aX, aY, aZ, player.rotationYaw, player.rotationPitch); } @@ -3180,13 +3182,13 @@ public class GT_Utility { if (((entity instanceof EntityPlayerMP)) && interDimensional) { EntityPlayerMP player = (EntityPlayerMP) entity; - player.theItemInWorldManager.setWorld((WorldServer) destinationWorld); + player.theItemInWorldManager.setWorld(destinationWorld); player.mcServer.getConfigurationManager() - .updateTimeAndWeatherForPlayer(player, (WorldServer) destinationWorld); + .updateTimeAndWeatherForPlayer(player, destinationWorld); player.mcServer.getConfigurationManager() .syncPlayerInventory(player); - for (PotionEffect potionEffect : (Iterable<PotionEffect>) player.getActivePotionEffects()) { + for (PotionEffect potionEffect : player.getActivePotionEffects()) { player.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(player.getEntityId(), potionEffect)); } @@ -3500,9 +3502,8 @@ public class GT_Utility { if (D1) e.printStackTrace(GT_Log.err); } try { - if (tTileEntity instanceof ic2.api.crops.ICropTile) { + if (tTileEntity instanceof ic2.api.crops.ICropTile crop) { rEUAmount += 1000; - final ic2.api.crops.ICropTile crop = (ic2.api.crops.ICropTile) tTileEntity; if (crop.getScanLevel() < 4) crop.setScanLevel((byte) 4); if (crop.getCrop() != null) { tList.add( @@ -3548,8 +3549,7 @@ public class GT_Utility { } try { - if (tTileEntity instanceof forestry.arboriculture.tiles.TileLeaves) { - final forestry.arboriculture.tiles.TileLeaves tileLeaves = (forestry.arboriculture.tiles.TileLeaves) tTileEntity; + if (tTileEntity instanceof forestry.arboriculture.tiles.TileLeaves tileLeaves) { final forestry.api.arboriculture.ITree tree = tileLeaves.getTree(); if (tree != null) { rEUAmount += 1000; @@ -3638,22 +3638,15 @@ public class GT_Utility { * like on the Texture Sheet. return values should always be between [0.0F and 0.99F]. */ public static float[] getClickedFacingCoords(byte aSide, float aX, float aY, float aZ) { - switch (aSide) { - case 0: - return new float[] { Math.min(0.99F, Math.max(0, 1 - aX)), Math.min(0.99F, Math.max(0, aZ)) }; - case 1: - return new float[] { Math.min(0.99F, Math.max(0, aX)), Math.min(0.99F, Math.max(0, aZ)) }; - case 2: - return new float[] { Math.min(0.99F, Math.max(0, 1 - aX)), Math.min(0.99F, Math.max(0, 1 - aY)) }; - case 3: - return new float[] { Math.min(0.99F, Math.max(0, aX)), Math.min(0.99F, Math.max(0, 1 - aY)) }; - case 4: - return new float[] { Math.min(0.99F, Math.max(0, aZ)), Math.min(0.99F, Math.max(0, 1 - aY)) }; - case 5: - return new float[] { Math.min(0.99F, Math.max(0, 1 - aZ)), Math.min(0.99F, Math.max(0, 1 - aY)) }; - default: - return new float[] { 0.5F, 0.5F }; - } + return switch (aSide) { + case 0 -> new float[] { Math.min(0.99F, Math.max(0, 1 - aX)), Math.min(0.99F, Math.max(0, aZ)) }; + case 1 -> new float[] { Math.min(0.99F, Math.max(0, aX)), Math.min(0.99F, Math.max(0, aZ)) }; + case 2 -> new float[] { Math.min(0.99F, Math.max(0, 1 - aX)), Math.min(0.99F, Math.max(0, 1 - aY)) }; + case 3 -> new float[] { Math.min(0.99F, Math.max(0, aX)), Math.min(0.99F, Math.max(0, 1 - aY)) }; + case 4 -> new float[] { Math.min(0.99F, Math.max(0, aZ)), Math.min(0.99F, Math.max(0, 1 - aY)) }; + case 5 -> new float[] { Math.min(0.99F, Math.max(0, 1 - aZ)), Math.min(0.99F, Math.max(0, 1 - aY)) }; + default -> new float[] { 0.5F, 0.5F }; + }; } /** @@ -3663,8 +3656,7 @@ public class GT_Utility { public static byte determineWrenchingSide(byte aSide, float aX, float aY, float aZ) { byte tBack = getOppositeSide(aSide); switch (aSide) { - case 0: - case 1: + case 0, 1 -> { if (aX < 0.25) { if (aZ < 0.25) return tBack; if (aZ > 0.75) return tBack; @@ -3678,8 +3670,8 @@ public class GT_Utility { if (aZ < 0.25) return 2; if (aZ > 0.75) return 3; return aSide; - case 2: - case 3: + } + case 2, 3 -> { if (aX < 0.25) { if (aY < 0.25) return tBack; if (aY > 0.75) return tBack; @@ -3693,8 +3685,8 @@ public class GT_Utility { if (aY < 0.25) return 0; if (aY > 0.75) return 1; return aSide; - case 4: - case 5: + } + case 4, 5 -> { if (aZ < 0.25) { if (aY < 0.25) return tBack; if (aY > 0.75) return tBack; @@ -3708,6 +3700,7 @@ public class GT_Utility { if (aY < 0.25) return 0; if (aY > 0.75) return 1; return aSide; + } } return -1; } @@ -3846,14 +3839,14 @@ public class GT_Utility { return; } ArrayList<String> tTagsToRemove = new ArrayList<>(); - for (Object tKey : aNBT.func_150296_c()) { - NBTBase tValue = aNBT.getTag((String) tKey); + for (String tKey : aNBT.func_150296_c()) { + NBTBase tValue = aNBT.getTag(tKey); if (tValue == null || (tValue instanceof NBTPrimitive && ((NBTPrimitive) tValue).func_150291_c() == 0) || (tValue instanceof NBTTagString && isStringInvalid(((NBTTagString) tValue).func_150285_a_()))) - tTagsToRemove.add((String) tKey); + tTagsToRemove.add(tKey); } - for (Object tKey : tTagsToRemove) aNBT.removeTag((String) tKey); + for (String tKey : tTagsToRemove) aNBT.removeTag(tKey); aStack.setTagCompound(aNBT.hasNoTags() ? null : aNBT); } @@ -4074,17 +4067,17 @@ public class GT_Utility { if (tOils != null) fillBookWithList(tNBTList, "Oils%s\n\n", "\n", 9, tOils); - tPageText = "Oil notes\n\n" + "Prospects from NW to SE 576 chunks" - + "(9 8x8 oilfields)\n around and gives min-max amount" - + "\n\n" - + "[1][2][3]" - + "\n" - + "[4][5][6]" - + "\n" - + "[7][8][9]" - + "\n" - + "\n" - + "[5] - Prospector in this 8x8 area"; + tPageText = """ + Oil notes + + Prospects from NW to SE 576 chunks(9 8x8 oilfields) + around and gives min-max amount + + [1][2][3] + [4][5][6] + [7][8][9] + + [5] - Prospector in this 8x8 area"""; tNBTList.appendTag(new NBTTagString(tPageText)); tPageText = "Corners of [5] are \n" + tOilsPosStr + "\n" + "P - Prospector in 8x8 field"; @@ -4373,8 +4366,7 @@ public class GT_Utility { ItemStack toAdd = ((ItemStack) o.getKey()).copy(); toAdd.stackSize = amount; inputs.add(toAdd); - } else if (o.getKey() instanceof String) { - final String dictName = (String) o.getKey(); + } else if (o.getKey() instanceof String dictName) { // Do not register tools dictName in inputs if (ToolDictNames.contains(dictName)) continue; ItemStack stack = GT_OreDictUnificator.get(dictName, null, amount, false, true); @@ -4434,7 +4426,7 @@ public class GT_Utility { } public static int clamp(int val, int lo, int hi) { - return val > hi ? hi : val < lo ? lo : val; + return MathHelper.clamp_int(val, lo, hi); } public static int ceilDiv(int lhs, int rhs) { diff --git a/src/main/java/gregtech/api/util/LightingHelper.java b/src/main/java/gregtech/api/util/LightingHelper.java index 25897487d2..986ac9d3aa 100644 --- a/src/main/java/gregtech/api/util/LightingHelper.java +++ b/src/main/java/gregtech/api/util/LightingHelper.java @@ -307,22 +307,15 @@ public class LightingHelper { * @see #setupLightingZPos(Block, int, int, int) */ public LightingHelper setupLighting(Block block, int x, int y, int z, byte facing) { - switch (facing) { - case 0: - return setupLightingYNeg(block, x, y, z); - case 1: - return setupLightingYPos(block, x, y, z); - case 2: - return setupLightingZNeg(block, x, y, z); - case 3: - return setupLightingZPos(block, x, y, z); - case 4: - return setupLightingXNeg(block, x, y, z); - case 5: - return setupLightingXPos(block, x, y, z); - default: - throw new IllegalArgumentException("Unknown side: " + facing); - } + return switch (facing) { + case 0 -> setupLightingYNeg(block, x, y, z); + case 1 -> setupLightingYPos(block, x, y, z); + case 2 -> setupLightingZNeg(block, x, y, z); + case 3 -> setupLightingZPos(block, x, y, z); + case 4 -> setupLightingXNeg(block, x, y, z); + case 5 -> setupLightingXPos(block, x, y, z); + default -> throw new IllegalArgumentException("Unknown side: " + facing); + }; } /** |