From b088958c9f6935d356b6c087c8e8106b400aa24f Mon Sep 17 00:00:00 2001 From: Raven Szewczyk Date: Sat, 1 Apr 2023 20:06:12 +0100 Subject: 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 --- .../java/gregtech/api/enums/ConfigCategories.java | 12 +- src/main/java/gregtech/api/enums/Dyes.java | 2 +- src/main/java/gregtech/api/enums/GT_Values.java | 25 +- src/main/java/gregtech/api/enums/OrePrefixes.java | 287 +++---- .../java/gregtech/api/graphs/GenerateNodeMap.java | 3 +- .../gregtech/api/graphs/GenerateNodeMapPower.java | 10 +- src/main/java/gregtech/api/graphs/Node.java | 2 +- src/main/java/gregtech/api/graphs/PowerNodes.java | 3 +- .../api/graphs/consumers/NodeEnergyReceiver.java | 35 +- .../gregtech/api/graphs/paths/PowerNodePath.java | 4 +- src/main/java/gregtech/api/gui/GT_Container.java | 22 +- .../api/gui/GT_ContainerMetaTile_Machine.java | 91 +-- .../api/gui/GT_Container_BasicMachine.java | 27 +- .../gregtech/api/gui/GT_Container_BasicTank.java | 14 +- .../java/gregtech/api/gui/GT_GUIColorOverride.java | 41 +- .../api/gui/GT_GUIContainerMetaTile_Machine.java | 8 +- .../api/gui/GT_GUIContainer_BasicMachine.java | 76 +- .../gregtech/api/gui/GT_GUIDialogSelectItem.java | 8 +- src/main/java/gregtech/api/gui/GT_GUIScreen.java | 7 +- .../gregtech/api/gui/modularui/GT_UIInfos.java | 6 +- .../gregtech/api/gui/modularui/SteamTexture.java | 32 +- .../java/gregtech/api/gui/widgets/GT_GuiIcon.java | 6 +- .../gregtech/api/gui/widgets/GT_GuiTabLine.java | 14 +- .../gregtech/api/gui/widgets/GT_GuiTooltip.java | 13 +- .../java/gregtech/api/interfaces/ICondition.java | 4 + .../gregtech/api/interfaces/IIconContainer.java | 6 +- .../interfaces/tileentity/IEnergyConnected.java | 6 +- .../tileentity/IExperimentalEnergyTileEntity.java | 4 +- .../api/items/GT_Block_LongDistancePipe.java | 2 +- .../gregtech/api/items/GT_BreederCell_Item.java | 21 +- .../gregtech/api/items/GT_CoolantCellIC_Item.java | 2 +- .../gregtech/api/items/GT_CoolantCell_Item.java | 37 +- .../gregtech/api/items/GT_EnergyArmor_Item.java | 33 +- .../java/gregtech/api/items/GT_Generic_Item.java | 2 +- .../java/gregtech/api/items/GT_MetaBase_Item.java | 7 +- .../gregtech/api/items/GT_MetaGenerated_Item.java | 6 +- .../api/items/GT_MetaGenerated_Item_X01.java | 2 +- .../api/items/GT_MetaGenerated_Item_X32.java | 2 +- .../gregtech/api/items/GT_MetaGenerated_Tool.java | 11 +- .../api/items/GT_RadioactiveCellIC_Item.java | 15 +- .../api/items/GT_RadioactiveCell_Item.java | 20 +- .../gregtech/api/items/GT_SolderingTool_Item.java | 3 - .../gregtech/api/items/GT_Spray_Foam_Item.java | 33 +- .../gregtech/api/items/GT_Spray_Pepper_Item.java | 1 - .../api/metatileentity/BaseMetaPipeEntity.java | 28 +- .../api/metatileentity/BaseMetaTileEntity.java | 32 +- .../api/metatileentity/BaseTileEntity.java | 9 +- .../api/metatileentity/CoverableTileEntity.java | 23 +- .../api/metatileentity/MetaPipeEntity.java | 35 +- .../api/metatileentity/MetaTileEntity.java | 35 +- .../implementations/GT_MetaPipeEntity_Cable.java | 3 +- .../implementations/GT_MetaPipeEntity_Fluid.java | 116 ++- .../GT_MetaTileEntity_BasicBatteryBuffer.java | 120 ++- .../GT_MetaTileEntity_BasicGenerator.java | 3 +- .../GT_MetaTileEntity_BasicMachine.java | 39 +- .../GT_MetaTileEntity_BasicMachine_Bronze.java | 49 +- .../GT_MetaTileEntity_BasicMachine_GT_Recipe.java | 826 ++++++--------------- .../implementations/GT_MetaTileEntity_Buffer.java | 68 +- .../GT_MetaTileEntity_CubicMultiBlockBase.java | 2 +- ...MetaTileEntity_ExtendedPowerMultiBlockBase.java | 2 +- .../GT_MetaTileEntity_Hatch_DataAccess.java | 23 +- .../GT_MetaTileEntity_Hatch_InputBus.java | 16 +- .../GT_MetaTileEntity_Hatch_Maintenance.java | 3 +- .../GT_MetaTileEntity_Hatch_Output.java | 40 +- .../GT_MetaTileEntity_Hatch_OutputBus.java | 18 +- .../GT_MetaTileEntity_MultiBlockBase.java | 43 +- .../GT_MetaTileEntity_Transformer.java | 4 +- .../api/multitileentity/MultiTileEntityBlock.java | 12 +- .../MultiTileEntityBlockInternal.java | 4 +- .../MultiTileEntityItemInternal.java | 4 +- .../multitileentity/MultiTileEntityRegistry.java | 2 +- .../machine/MultiTileBasicMachine.java | 38 +- .../multiblock/base/MultiBlockController.java | 7 +- .../multiblock/base/MultiBlockPart.java | 22 +- .../api/net/GT_Packet_GtTileEntityGuiRequest.java | 3 +- .../api/net/GT_Packet_MultiTileEntity.java | 17 +- .../api/net/GT_Packet_RequestCoverData.java | 3 +- .../gregtech/api/net/GT_Packet_SetLockedFluid.java | 3 +- .../api/net/GT_Packet_TileEntityCoverGUI.java | 3 +- .../api/objects/AE2DigitalChestHandler.java | 2 +- .../java/gregtech/api/objects/GT_ArrayList.java | 1 + src/main/java/gregtech/api/objects/GT_HashSet.java | 2 +- src/main/java/gregtech/api/objects/ItemData.java | 22 +- .../api/util/ColorsMetadataSectionSerializer.java | 3 +- .../gregtech/api/util/GT_AssemblyLineUtils.java | 14 +- .../gregtech/api/util/GT_Assemblyline_Server.java | 159 ++-- src/main/java/gregtech/api/util/GT_BaseCrop.java | 35 +- src/main/java/gregtech/api/util/GT_CLS_Compat.java | 8 +- .../gregtech/api/util/GT_ChunkAssociatedData.java | 12 +- .../gregtech/api/util/GT_HatchElementBuilder.java | 8 +- src/main/java/gregtech/api/util/GT_Log.java | 2 +- src/main/java/gregtech/api/util/GT_ModHandler.java | 209 +++--- .../gregtech/api/util/GT_OreDictUnificator.java | 2 +- .../java/gregtech/api/util/GT_ParallelHelper.java | 4 +- .../api/util/GT_ProcessingArray_Manager.java | 2 +- src/main/java/gregtech/api/util/GT_Recipe.java | 56 +- .../java/gregtech/api/util/GT_RecipeBuilder.java | 3 +- .../java/gregtech/api/util/GT_RecipeConstants.java | 3 +- .../gregtech/api/util/GT_RecipeRegistrator.java | 48 +- .../java/gregtech/api/util/GT_RenderingWorld.java | 3 +- .../gregtech/api/util/GT_StructureUtility.java | 19 +- .../gregtech/api/util/GT_TooltipDataCache.java | 2 +- src/main/java/gregtech/api/util/GT_Utility.java | 142 ++-- .../java/gregtech/api/util/LightingHelper.java | 25 +- src/main/java/gregtech/api/world/GT_Worldgen.java | 3 +- .../java/gregtech/api/world/GT_Worldgen_Ore.java | 2 +- 106 files changed, 1316 insertions(+), 2095 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/enums/ConfigCategories.java b/src/main/java/gregtech/api/enums/ConfigCategories.java index e4a647db22..a85d569d74 100644 --- a/src/main/java/gregtech/api/enums/ConfigCategories.java +++ b/src/main/java/gregtech/api/enums/ConfigCategories.java @@ -9,14 +9,14 @@ public enum ConfigCategories { public enum IDs { crops, - enchantments; + enchantments } public enum Materials { heatdamage, oreprocessingoutputmultiplier, blastfurnacerequirements, - blastinductionsmelter,; + blastinductionsmelter, } public enum Recipes { @@ -27,7 +27,7 @@ public enum ConfigCategories { recipereplacements, storageblockcrafting, storageblockdecrafting, - crops; + crops } public enum Machines { @@ -47,11 +47,11 @@ public enum ConfigCategories { massfabamplifier, maceration, rockcrushing, - pulverization; + pulverization } public enum Fuels { - boilerfuels; + boilerfuels } public enum Tools { @@ -62,6 +62,6 @@ public enum ConfigCategories { hammertripleplate, hammerquadrupleplate, hammerquintupleplate, - scoop; + scoop } } diff --git a/src/main/java/gregtech/api/enums/Dyes.java b/src/main/java/gregtech/api/enums/Dyes.java index a0b9f87593..165545b26c 100644 --- a/src/main/java/gregtech/api/enums/Dyes.java +++ b/src/main/java/gregtech/api/enums/Dyes.java @@ -48,7 +48,7 @@ public enum Dyes implements IColorModulationContainer { public final String mName; public final short[] mRGBa; public final short[] mOriginalRGBa; - private final ArrayList mFluidDyes = new GT_ArrayList(false, 1); + private final ArrayList mFluidDyes = new GT_ArrayList<>(false, 1); Dyes(int aIndex, int aR, int aG, int aB, String aName) { mIndex = (byte) aIndex; diff --git a/src/main/java/gregtech/api/enums/GT_Values.java b/src/main/java/gregtech/api/enums/GT_Values.java index eb742c902f..1a9422f374 100644 --- a/src/main/java/gregtech/api/enums/GT_Values.java +++ b/src/main/java/gregtech/api/enums/GT_Values.java @@ -170,13 +170,10 @@ public class GT_Values { EnumChatFormatting.DARK_GREEN.toString(), // UV, 8 EnumChatFormatting.DARK_RED.toString(), // UHV, 9 EnumChatFormatting.DARK_PURPLE.toString(), // UEV, 10 - EnumChatFormatting.DARK_BLUE.toString() + EnumChatFormatting.BOLD.toString(), // UIV, 11 - EnumChatFormatting.RED.toString() + EnumChatFormatting.BOLD.toString() - + EnumChatFormatting.UNDERLINE.toString(), // UMV, 12 - EnumChatFormatting.DARK_RED.toString() + EnumChatFormatting.BOLD.toString() - + EnumChatFormatting.UNDERLINE.toString(), // UXV, 13 - EnumChatFormatting.WHITE.toString() + EnumChatFormatting.BOLD.toString() - + EnumChatFormatting.UNDERLINE.toString(), // MAX, 14 + EnumChatFormatting.DARK_BLUE.toString() + EnumChatFormatting.BOLD, // UIV, 11 + EnumChatFormatting.RED.toString() + EnumChatFormatting.BOLD + EnumChatFormatting.UNDERLINE, // UMV, 12 + EnumChatFormatting.DARK_RED.toString() + EnumChatFormatting.BOLD + EnumChatFormatting.UNDERLINE, // UXV, 13 + EnumChatFormatting.WHITE.toString() + EnumChatFormatting.BOLD + EnumChatFormatting.UNDERLINE, // MAX, 14 EnumChatFormatting.OBFUSCATED.toString() // ~~~, 15 }; @@ -547,4 +544,18 @@ public class GT_Values { public static double getMaxPlasmaTurbineEfficiency() { return maxPlasmaTurbineEfficiency; } + + private static final long[] EXPLOSION_LOOKUP_V = new long[] { V[0], V[1], V[2], V[3], V[4], V[4] * 2, V[5], V[6], + V[7], V[8], V[8] * 2, V[9], V[10], V[11], V[12], V[12] * 2, V[13], V[14], V[15] }; + private static final float[] EXPLOSION_LOOKUP_POWER = new float[] { 1.0F, 2.0F, 3.0F, 4.0F, 5.0F, 6.0F, 7.0F, 8.0F, + 9.0F, 10.0F, 11.0F, 12.0F, 13.0F, 14.0F, 15.0F, 16.0F, 17.0F, 18.0F, 19.0F, 20.0F }; + + public static float getExplosionPowerForVoltage(long voltage) { + for (int i = 0; i < EXPLOSION_LOOKUP_V.length; i++) { + if (voltage < EXPLOSION_LOOKUP_V[i]) { + return EXPLOSION_LOOKUP_POWER[i]; + } + } + return EXPLOSION_LOOKUP_POWER[EXPLOSION_LOOKUP_POWER.length - 1]; + } } diff --git a/src/main/java/gregtech/api/enums/OrePrefixes.java b/src/main/java/gregtech/api/enums/OrePrefixes.java index 4139f90db1..8d3201f6ca 100644 --- a/src/main/java/gregtech/api/enums/OrePrefixes.java +++ b/src/main/java/gregtech/api/enums/OrePrefixes.java @@ -863,87 +863,79 @@ public enum OrePrefixes { itemCasing.mGeneratedItems.addAll(itemCasing.mGeneratedItems); // ----- - toolHeadFile.mCondition = new ICondition.And( - new ICondition.Not(SubTag.NO_SMASHING), - new ICondition.Not(SubTag.BOUNCY)); - toolHeadSaw.mCondition = new ICondition.And( - new ICondition.Not(SubTag.NO_SMASHING), - new ICondition.Not(SubTag.BOUNCY)); - toolHeadDrill.mCondition = new ICondition.And( - new ICondition.Not(SubTag.NO_SMASHING), - new ICondition.Not(SubTag.BOUNCY)); - toolHeadChainsaw.mCondition = new ICondition.And( - new ICondition.Not(SubTag.NO_SMASHING), - new ICondition.Not(SubTag.BOUNCY)); - toolHeadWrench.mCondition = new ICondition.And( - new ICondition.Not(SubTag.NO_SMASHING), - new ICondition.Not(SubTag.BOUNCY)); - toolHeadBuzzSaw.mCondition = new ICondition.And( - new ICondition.Not(SubTag.NO_SMASHING), - new ICondition.Not(SubTag.BOUNCY)); - turbineBlade.mCondition = new ICondition.And( - new ICondition.Not(SubTag.NO_SMASHING), - new ICondition.Not(SubTag.BOUNCY)); - - rotor.mCondition = new ICondition.Nor(SubTag.CRYSTAL, SubTag.STONE, SubTag.BOUNCY); - - spring.mCondition = new ICondition.Or( + toolHeadFile.mCondition = new ICondition.And<>( + new ICondition.Not<>(SubTag.NO_SMASHING), + new ICondition.Not<>(SubTag.BOUNCY)); + toolHeadSaw.mCondition = new ICondition.And<>( + new ICondition.Not<>(SubTag.NO_SMASHING), + new ICondition.Not<>(SubTag.BOUNCY)); + toolHeadDrill.mCondition = new ICondition.And<>( + new ICondition.Not<>(SubTag.NO_SMASHING), + new ICondition.Not<>(SubTag.BOUNCY)); + toolHeadChainsaw.mCondition = new ICondition.And<>( + new ICondition.Not<>(SubTag.NO_SMASHING), + new ICondition.Not<>(SubTag.BOUNCY)); + toolHeadWrench.mCondition = new ICondition.And<>( + new ICondition.Not<>(SubTag.NO_SMASHING), + new ICondition.Not<>(SubTag.BOUNCY)); + toolHeadBuzzSaw.mCondition = new ICondition.And<>( + new ICondition.Not<>(SubTag.NO_SMASHING), + new ICondition.Not<>(SubTag.BOUNCY)); + turbineBlade.mCondition = new ICondition.And<>( + new ICondition.Not<>(SubTag.NO_SMASHING), + new ICondition.Not<>(SubTag.BOUNCY)); + + rotor.mCondition = new ICondition.Nor<>(SubTag.CRYSTAL, SubTag.STONE, SubTag.BOUNCY); + + spring.mCondition = new ICondition.Or<>( SubTag.STRETCHY, SubTag.BOUNCY, - new ICondition.Not(SubTag.NO_SMASHING)); - springSmall.mCondition = new ICondition.Or( + new ICondition.Not<>(SubTag.NO_SMASHING)); + springSmall.mCondition = new ICondition.Or<>( SubTag.STRETCHY, SubTag.BOUNCY, - new ICondition.Not(SubTag.NO_SMASHING)); + new ICondition.Not<>(SubTag.NO_SMASHING)); - gemChipped.mCondition = new ICondition.And( + gemChipped.mCondition = new ICondition.And<>( SubTag.TRANSPARENT, SubTag.CRYSTAL, - new ICondition.Not(SubTag.QUARTZ), - new ICondition.Not(SubTag.PEARL), - new ICondition.Not(SubTag.MAGICAL)); - gemFlawed.mCondition = new ICondition.And( + new ICondition.Not<>(SubTag.QUARTZ), + new ICondition.Not<>(SubTag.PEARL), + new ICondition.Not<>(SubTag.MAGICAL)); + gemFlawed.mCondition = new ICondition.And<>( SubTag.TRANSPARENT, SubTag.CRYSTAL, - new ICondition.Not(SubTag.QUARTZ), - new ICondition.Not(SubTag.PEARL), - new ICondition.Not(SubTag.MAGICAL)); - gemFlawless.mCondition = new ICondition.And( + new ICondition.Not<>(SubTag.QUARTZ), + new ICondition.Not<>(SubTag.PEARL), + new ICondition.Not<>(SubTag.MAGICAL)); + gemFlawless.mCondition = new ICondition.And<>( SubTag.TRANSPARENT, SubTag.CRYSTAL, - new ICondition.Not(SubTag.QUARTZ), - new ICondition.Not(SubTag.PEARL), - new ICondition.Not(SubTag.MAGICAL)); - gemExquisite.mCondition = new ICondition.And( + new ICondition.Not<>(SubTag.QUARTZ), + new ICondition.Not<>(SubTag.PEARL), + new ICondition.Not<>(SubTag.MAGICAL)); + gemExquisite.mCondition = new ICondition.And<>( SubTag.TRANSPARENT, SubTag.CRYSTAL, - new ICondition.Not(SubTag.QUARTZ), - new ICondition.Not(SubTag.PEARL), - new ICondition.Not(SubTag.MAGICAL)); + new ICondition.Not<>(SubTag.QUARTZ), + new ICondition.Not<>(SubTag.PEARL), + new ICondition.Not<>(SubTag.MAGICAL)); - lens.mCondition = new ICondition.Or( + lens.mCondition = new ICondition.Or<>( SubTag.MAGICAL, - new ICondition.And(SubTag.TRANSPARENT, SubTag.HAS_COLOR)); - - plateDouble.mCondition = new ICondition.Or( - SubTag.PAPER, - new ICondition.Not(SubTag.NO_SMASHING)); - plateTriple.mCondition = new ICondition.Or( - SubTag.PAPER, - new ICondition.Not(SubTag.NO_SMASHING)); - plateQuadruple.mCondition = new ICondition.Or( - SubTag.PAPER, - new ICondition.Not(SubTag.NO_SMASHING)); - plateQuintuple.mCondition = new ICondition.Or( - SubTag.PAPER, - new ICondition.Not(SubTag.NO_SMASHING)); - - plateDense.mCondition = new ICondition.Not(SubTag.NO_SMASHING); - - ingotDouble.mCondition = new ICondition.Not(SubTag.NO_SMASHING); - ingotTriple.mCondition = new ICondition.Not(SubTag.NO_SMASHING); - ingotQuadruple.mCondition = new ICondition.Not(SubTag.NO_SMASHING); - ingotQuintuple.mCondition = new ICondition.Not(SubTag.NO_SMASHING); + new ICondition.And<>(SubTag.TRANSPARENT, SubTag.HAS_COLOR)); + + plateDouble.mCondition = new ICondition.Or<>(SubTag.PAPER, new ICondition.Not<>(SubTag.NO_SMASHING)); + plateTriple.mCondition = new ICondition.Or<>(SubTag.PAPER, new ICondition.Not<>(SubTag.NO_SMASHING)); + plateQuadruple.mCondition = new ICondition.Or<>(SubTag.PAPER, new ICondition.Not<>(SubTag.NO_SMASHING)); + plateQuintuple.mCondition = new ICondition.Or<>(SubTag.PAPER, new ICondition.Not<>(SubTag.NO_SMASHING)); + + plateDense.mCondition = new ICondition.Not<>(SubTag.NO_SMASHING); + + ingotDouble.mCondition = new ICondition.Not<>(SubTag.NO_SMASHING); + ingotTriple.mCondition = new ICondition.Not<>(SubTag.NO_SMASHING); + ingotQuadruple.mCondition = new ICondition.Not<>(SubTag.NO_SMASHING); + ingotQuintuple.mCondition = new ICondition.Not<>(SubTag.NO_SMASHING); wireFine.mCondition = SubTag.METAL; @@ -998,18 +990,17 @@ public enum OrePrefixes { public final String mRegularLocalName, mLocalizedMaterialPre, mLocalizedMaterialPost; public final boolean mIsUsedForOreProcessing, mIsEnchantable, mIsUnificatable, mIsMaterialBased, mIsSelfReferencing, mIsContainer, mDontUnificateActively, mIsUsedForBlocks, mAllowNormalRecycling, mGenerateDefaultItem; - public final List mAspects = new ArrayList(); - public final Collection mFamiliarPrefixes = new HashSet(); + public final List mAspects = new ArrayList<>(); + public final Collection mFamiliarPrefixes = new HashSet<>(); /** * Used to determine the amount of Material this Prefix contains. Multiply or Divide GregTech_API.MATERIAL_UNIT to * get the Amounts in comparision to one Ingot. 0 = Null Negative = Undefined Amount */ public final long mMaterialAmount; - public final Collection mDisabledItems = new HashSet(), - mNotGeneratedItems = new HashSet(), mIgnoredMaterials = new HashSet(), - mGeneratedItems = new HashSet(); - private final ArrayList mOreProcessing = new ArrayList(); + public final Collection mDisabledItems = new HashSet<>(), mNotGeneratedItems = new HashSet<>(), + mIgnoredMaterials = new HashSet<>(), mGeneratedItems = new HashSet<>(); + private final ArrayList mOreProcessing = new ArrayList<>(); public ItemStack mContainerItem = null; public ICondition mCondition = null; public byte mDefaultStackSize = 64; @@ -1508,8 +1499,6 @@ public enum OrePrefixes { || aMaterial == Materials.Uranium235 || aMaterial == Materials.Plutonium241 || aMaterial == Materials.Americium - || aMaterial == Materials.Neutronium - || aMaterial == Materials.Bronze || aMaterial == Materials.Brass || aMaterial == Materials.Electrum || aMaterial == Materials.NaquadahEnriched @@ -1576,7 +1565,7 @@ public enum OrePrefixes { !aPrefix.mDisabledItems.contains(aMaterial)); if (!aEnableComponent) { // Disable component if false and is not already in disabled list aPrefix.disableComponent(aMaterial); - } else if (aEnableComponent) { // Enable component if true and is not already in enabled list + } else { // Enable component if true and is not already in enabled list aPrefix.enableComponent(aMaterial); } } @@ -1742,151 +1731,115 @@ public enum OrePrefixes { public String getDefaultLocalNameFormatForItem(Materials aMaterial) { // Certain Materials have slightly different Localizations. switch (this) { - case crateGtDust: + case crateGtDust -> { return mLocalizedMaterialPre + OrePrefixes.dust.getDefaultLocalNameFormatForItem(aMaterial); - case crateGtIngot: + } + case crateGtIngot -> { return mLocalizedMaterialPre + OrePrefixes.ingot.getDefaultLocalNameFormatForItem(aMaterial); - case crateGtGem: + } + case crateGtGem -> { return mLocalizedMaterialPre + OrePrefixes.gem.getDefaultLocalNameFormatForItem(aMaterial); - case crateGtPlate: + } + case crateGtPlate -> { return mLocalizedMaterialPre + OrePrefixes.plate.getDefaultLocalNameFormatForItem(aMaterial); + } } switch (aMaterial.mName) { - case "Glass": - case "BorosilicateGlass": + case "Glass", "BorosilicateGlass" -> { if (name().startsWith("gem")) return mLocalizedMaterialPre + "%material" + " Crystal"; if (name().startsWith("plate")) return mLocalizedMaterialPre + "%material" + " Pane"; if (name().startsWith("ingot")) return mLocalizedMaterialPre + "%material" + " Bar"; if (name().startsWith("nugget")) return mLocalizedMaterialPre + "%material" + " Chip"; - break; - case "Wheat": + } + case "Wheat" -> { if (name().startsWith("dust")) return mLocalizedMaterialPre + "Flour"; - break; - case "Ice": + } + case "Ice" -> { if (name().startsWith("dust")) return mLocalizedMaterialPre + "Crushed Ice"; - break; - case "Wood": - case "WoodSealed": + } + case "Wood", "WoodSealed" -> { if (name().startsWith("bolt")) return "Short " + "%material" + " Stick"; if (name().startsWith("stick")) return mLocalizedMaterialPre + "%material" + " Stick"; if (name().startsWith("dust")) return mLocalizedMaterialPre + "%material" + " Pulp"; if (name().startsWith("nugget")) return mLocalizedMaterialPre + "%material" + " Chip"; if (name().startsWith("plate")) return mLocalizedMaterialPre + "%material" + " Plank"; - break; - case "Plastic": - case "Rubber": - case "Polyethylene": - case "Epoxid": - case "EpoxidFiberReinforced": - case "Polydimethylsiloxane": - case "Silicone": - case "Polysiloxane": - case "Polycaprolactam": - case "Polytetrafluoroethylene": - case "PolyvinylChloride": - case "Polystyrene": - case "StyreneButadieneRubber": + } + case "Plastic", "Rubber", "Polyethylene", "Epoxid", "EpoxidFiberReinforced", "Polydimethylsiloxane", "Silicone", "Polysiloxane", "Polycaprolactam", "Polytetrafluoroethylene", "PolyvinylChloride", "Polystyrene", "StyreneButadieneRubber" -> { if (name().startsWith("dust")) return mLocalizedMaterialPre + "%material" + " Pulp"; if (name().startsWith("plate")) return mLocalizedMaterialPre + "%material" + " Sheet"; if (name().startsWith("ingot")) return mLocalizedMaterialPre + "%material" + " Bar"; if (name().startsWith("nugget")) return mLocalizedMaterialPre + "%material" + " Chip"; if (name().startsWith("foil")) return "Thin " + "%material" + " Sheet"; - break; - case "FierySteel": + } + case "FierySteel" -> { if (mIsContainer) return mLocalizedMaterialPre + "Fiery Blood" + mLocalizedMaterialPost; - break; - case "Steeleaf": + } + case "Steeleaf" -> { if (name().startsWith("ingot")) return mLocalizedMaterialPre + "%material"; - break; - case "Bone": + } + case "Bone" -> { if (name().startsWith("dust")) return mLocalizedMaterialPre + "Bone Meal"; - break; - case "Blaze": - case "Milk": - case "Cocoa": - case "Chocolate": - case "Coffee": - case "Chili": - case "Cheese": - case "Snow": + } + case "Blaze", "Milk", "Cocoa", "Chocolate", "Coffee", "Chili", "Cheese", "Snow" -> { if (name().startsWith("dust")) return mLocalizedMaterialPre + "%material" + " Powder"; - break; - case "Paper": + } + case "Paper" -> { if (name().startsWith("dust")) return mLocalizedMaterialPre + "Chad"; switch (this) { - case plate: + case plate -> { return "Sheet of Paper"; - case plateDouble: + } + case plateDouble -> { return "Paperboard"; - case plateTriple: + } + case plateTriple -> { return "Carton"; - case plateQuadruple: + } + case plateQuadruple -> { return "Cardboard"; - case plateQuintuple: + } + case plateQuintuple -> { return "Thick Cardboard"; - case plateDense: + } + case plateDense -> { return "Strong Cardboard"; + } } - break; - case "MeatRaw": + } + case "MeatRaw" -> { if (name().startsWith("dust")) return mLocalizedMaterialPre + "Mince Meat"; - break; - case "MeatCooked": + } + case "MeatCooked" -> { if (name().startsWith("dust")) return mLocalizedMaterialPre + "Cooked Mince Meat"; - break; - case "Ash": - case "DarkAsh": - case "Gunpowder": - case "Sugar": - case "Salt": - case "RockSalt": - case "VolcanicAsh": - case "RareEarth": + } + case "Ash", "DarkAsh", "Gunpowder", "Sugar", "Salt", "RockSalt", "VolcanicAsh", "RareEarth" -> { if (name().startsWith("dust")) return mLocalizedMaterialPre + "%material"; - break; - case "Vermiculite": - case "Bentonite": - case "Kaolinite": - case "Talc": - case "BasalticMineralSand": - case "GraniticMineralSand": - case "GlauconiteSand": - case "CassiteriteSand": - case "GarnetSand": - case "QuartzSand": - case "Pitchblende": - case "FullersEarth": + } + case "Vermiculite", "Bentonite", "Kaolinite", "Talc", "BasalticMineralSand", "GraniticMineralSand", "GlauconiteSand", "CassiteriteSand", "GarnetSand", "QuartzSand", "Pitchblende", "FullersEarth" -> { if (name().startsWith("dust")) return mLocalizedMaterialPre + "%material"; switch (this) { - case crushedCentrifuged: - case crushedPurified: + case crushedCentrifuged, crushedPurified -> { return mLocalizedMaterialPre + "%material"; - case crushed: + } + case crushed -> { return "Ground " + "%material"; + } } - break; + } } if (ProcessingModSupport.aEnableThaumcraftMats) { switch (aMaterial.mName) { - case "InfusedAir": - case "InfusedDull": - case "InfusedEarth": - case "InfusedEntropy": - case "InfusedFire": - case "InfusedOrder": - case "InfusedVis": - case "InfusedWater": + case "InfusedAir", "InfusedDull", "InfusedEarth", "InfusedEntropy", "InfusedFire", "InfusedOrder", "InfusedVis", "InfusedWater" -> { if (name().startsWith("gem")) return mLocalizedMaterialPre + "Shard of " + "%material"; if (name().startsWith("crystal")) return mLocalizedMaterialPre + "Shard of " + "%material"; if (name().startsWith("plate")) return mLocalizedMaterialPre + "%material" + " Crystal Plate"; if (name().startsWith("dust")) return mLocalizedMaterialPre + "%material" + " Crystal Powder"; switch (this) { - case crushedCentrifuged: - case crushedPurified: - case crushed: + case crushedCentrifuged, crushedPurified, crushed -> { return mLocalizedMaterialPre + "%material" + " Crystals"; + } } - break; + } } } // Use Standard Localization diff --git a/src/main/java/gregtech/api/graphs/GenerateNodeMap.java b/src/main/java/gregtech/api/graphs/GenerateNodeMap.java index fba74b0aec..b64020f33d 100644 --- a/src/main/java/gregtech/api/graphs/GenerateNodeMap.java +++ b/src/main/java/gregtech/api/graphs/GenerateNodeMap.java @@ -18,8 +18,7 @@ public abstract class GenerateNodeMap { // clearing the node map to make sure it is gone on reset public static void clearNodeMap(Node aNode, int aReturnNodeValue) { - if (aNode.mTileEntity instanceof BaseMetaPipeEntity) { - final BaseMetaPipeEntity tPipe = (BaseMetaPipeEntity) aNode.mTileEntity; + if (aNode.mTileEntity instanceof BaseMetaPipeEntity tPipe) { tPipe.setNode(null); tPipe.setNodePath(null); if (aNode.mSelfPath != null) { diff --git a/src/main/java/gregtech/api/graphs/GenerateNodeMapPower.java b/src/main/java/gregtech/api/graphs/GenerateNodeMapPower.java index 26c3c60ef1..67591040e9 100644 --- a/src/main/java/gregtech/api/graphs/GenerateNodeMapPower.java +++ b/src/main/java/gregtech/api/graphs/GenerateNodeMapPower.java @@ -39,16 +39,14 @@ public class GenerateNodeMapPower extends GenerateNodeMap { @Override protected boolean addConsumer(TileEntity aTileEntity, byte aSide, int aNodeValue, ArrayList aConsumers) { - if (aTileEntity instanceof BaseMetaTileEntity) { - BaseMetaTileEntity tBaseTileEntity = (BaseMetaTileEntity) aTileEntity; + if (aTileEntity instanceof BaseMetaTileEntity tBaseTileEntity) { if (tBaseTileEntity.inputEnergyFrom(aSide, false)) { ConsumerNode tConsumerNode = new NodeGTBaseMetaTile(aNodeValue, tBaseTileEntity, aSide, aConsumers); aConsumers.add(tConsumerNode); return true; } - } else if (aTileEntity instanceof IEnergyConnected) { - IEnergyConnected tTileEntity = (IEnergyConnected) aTileEntity; + } else if (aTileEntity instanceof IEnergyConnected tTileEntity) { if (tTileEntity.inputEnergyFrom(aSide, false)) { ConsumerNode tConsumerNode = new NodeEnergyConnected(aNodeValue, tTileEntity, aSide, aConsumers); aConsumers.add(tConsumerNode); @@ -97,8 +95,8 @@ public class GenerateNodeMapPower extends GenerateNodeMap { @Override protected Node getEmptyNode(int aNodeValue, byte aSide, TileEntity aTileEntity, ArrayList aConsumers) { - Node tNode = new EmptyPowerConsumer(aNodeValue, aTileEntity, aSide, aConsumers); - aConsumers.add((ConsumerNode) tNode); + ConsumerNode tNode = new EmptyPowerConsumer(aNodeValue, aTileEntity, aSide, aConsumers); + aConsumers.add(tNode); return tNode; } diff --git a/src/main/java/gregtech/api/graphs/Node.java b/src/main/java/gregtech/api/graphs/Node.java index 38b3cd0e37..005b32a5b7 100644 --- a/src/main/java/gregtech/api/graphs/Node.java +++ b/src/main/java/gregtech/api/graphs/Node.java @@ -32,7 +32,7 @@ public class Node { public int mNodeValue; public int mHighestNodeValue; - public class ReturnPair { + public static class ReturnPair { public NodePath mReturnPath; public Lock returnLock; diff --git a/src/main/java/gregtech/api/graphs/PowerNodes.java b/src/main/java/gregtech/api/graphs/PowerNodes.java index 12416f6d72..22f1e02add 100644 --- a/src/main/java/gregtech/api/graphs/PowerNodes.java +++ b/src/main/java/gregtech/api/graphs/PowerNodes.java @@ -30,7 +30,6 @@ public class PowerNodes { if (tNextNode.mNodeValue == tConsumer.mNodeValue) { tAmpsUsed += processNodeInject(aCurrentNode, tConsumer, j, aMaxAmps - tAmpsUsed, aVoltage); tConsumer = (ConsumerNode) aConsumers.getNextNode(); - break; } else { if (aPreviousNode == tNextNode) return tAmpsUsed; tAmpsUsed += processNextNode( @@ -41,8 +40,8 @@ public class PowerNodes { aMaxAmps - tAmpsUsed, aVoltage); tConsumer = (ConsumerNode) aConsumers.getNode(); - break; } + break; } } } else { diff --git a/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java b/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java index c7c4cbeba5..fec34c9d66 100644 --- a/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java +++ b/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java @@ -1,7 +1,5 @@ package gregtech.api.graphs.consumers; -import static gregtech.api.enums.GT_Values.V; - import java.util.ArrayList; import net.minecraft.init.Blocks; @@ -12,6 +10,7 @@ import net.minecraftforge.common.util.ForgeDirection; import cofh.api.energy.IEnergyReceiver; import gregtech.GT_Mod; import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; import gregtech.api.enums.SoundResource; import gregtech.api.util.GT_Utility; import gregtech.api.util.WorldSpawnedEventBuilder; @@ -51,37 +50,7 @@ public class NodeEnergyReceiver extends ConsumerNode { // copied from IEnergyConnected private void explode(int aRfOut) { if (aRfOut > 32L * GregTech_API.mEUtoRF / 100L) { - int aExplosionPower = aRfOut; - float tStrength = aExplosionPower < V[0] ? 1.0F - : aExplosionPower < V[1] ? 2.0F - : aExplosionPower < V[2] ? 3.0F - : aExplosionPower < V[3] ? 4.0F - : aExplosionPower < V[4] ? 5.0F - : aExplosionPower < V[4] * 2 ? 6.0F - : aExplosionPower < V[5] ? 7.0F - : aExplosionPower < V[6] ? 8.0F - : aExplosionPower < V[7] ? 9.0F - : aExplosionPower < V[8] ? 10.0F - : aExplosionPower < V[8] * 2 - ? 11.0F - : aExplosionPower - < V[9] ? 12.0F - : aExplosionPower - < V[10] ? 13.0F - : aExplosionPower - < V[11] ? 14.0F - : aExplosionPower - < V[12] ? 15.0F - : aExplosionPower - < V[12] * 2 - ? 16.0F - : aExplosionPower - < V[13] ? 17.0F - : aExplosionPower - < V[14] ? 18.0F - : aExplosionPower - < V[15] ? 19.0F - : 20.0F; + float tStrength = GT_Values.getExplosionPowerForVoltage(aRfOut); int tX = mTileEntity.xCoord, tY = mTileEntity.yCoord, tZ = mTileEntity.zCoord; World tWorld = mTileEntity.getWorldObj(); GT_Utility.sendSoundToPlayers(tWorld, SoundResource.IC2_MACHINES_MACHINE_OVERLOAD, 1.0F, -1, tX, tY, tZ); diff --git a/src/main/java/gregtech/api/graphs/paths/PowerNodePath.java b/src/main/java/gregtech/api/graphs/paths/PowerNodePath.java index 7d9a76524e..97edd5757c 100644 --- a/src/main/java/gregtech/api/graphs/paths/PowerNodePath.java +++ b/src/main/java/gregtech/api/graphs/paths/PowerNodePath.java @@ -90,8 +90,8 @@ public class PowerNodePath extends NodePath { public long getVoltage(MetaPipeEntity aCable) { int tLoss = 0; if (mCountUp) { - for (int i = 0; i < mPipes.length; i++) { - GT_MetaPipeEntity_Cable tCable = (GT_MetaPipeEntity_Cable) mPipes[i]; + for (MetaPipeEntity mPipe : mPipes) { + GT_MetaPipeEntity_Cable tCable = (GT_MetaPipeEntity_Cable) mPipe; tLoss += tCable.mCableLossPerMeter; if (aCable == tCable) { return Math.max(mVoltage - tLoss, 0); 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 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 cache = CacheBuilder.newBuilder() .softValues() - .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; - } - }); +