diff options
Diffstat (limited to 'src/main/java/gregtech/api')
106 files changed, 1316 insertions, 2095 deletions
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<Fluid> mFluidDyes = new GT_ArrayList<Fluid>(false, 1); + private final ArrayList<Fluid> 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<ISubTagContainer>( - new ICondition.Not<ISubTagContainer>(SubTag.NO_SMASHING), - new ICondition.Not<ISubTagContainer>(SubTag.BOUNCY)); - toolHeadSaw.mCondition = new ICondition.And<ISubTagContainer>( - new ICondition.Not<ISubTagContainer>(SubTag.NO_SMASHING), - new ICondition.Not<ISubTagContainer>(SubTag.BOUNCY)); - toolHeadDrill.mCondition = new ICondition.And<ISubTagContainer>( - new ICondition.Not<ISubTagContainer>(SubTag.NO_SMASHING), - new ICondition.Not<ISubTagContainer>(SubTag.BOUNCY)); - toolHeadChainsaw.mCondition = new ICondition.And<ISubTagContainer>( - new ICondition.Not<ISubTagContainer>(SubTag.NO_SMASHING), - new ICondition.Not<ISubTagContainer>(SubTag.BOUNCY)); - toolHeadWrench.mCondition = new ICondition.And<ISubTagContainer>( - new ICondition.Not<ISubTagContainer>(SubTag.NO_SMASHING), - new ICondition.Not<ISubTagContainer>(SubTag.BOUNCY)); - toolHeadBuzzSaw.mCondition = new ICondition.And<ISubTagContainer>( - new ICondition.Not<ISubTagContainer>(SubTag.NO_SMASHING), - new ICondition.Not<ISubTagContainer>(SubTag.BOUNCY)); - turbineBlade.mCondition = new ICondition.And<ISubTagContainer>( - new ICondition.Not<ISubTagContainer>(SubTag.NO_SMASHING), - new ICondition.Not<ISubTagContainer>(SubTag.BOUNCY)); - - rotor.mCondition = new ICondition.Nor<ISubTagContainer>(SubTag.CRYSTAL, SubTag.STONE, SubTag.BOUNCY); - - spring.mCondition = new ICondition.Or<ISubTagContainer>( + 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<ISubTagContainer>(SubTag.NO_SMASHING)); - springSmall.mCondition = new ICondition.Or<ISubTagContainer>( + new ICondition.Not<>(SubTag.NO_SMASHING)); + springSmall.mCondition = new ICondition.Or<>( SubTag.STRETCHY, SubTag.BOUNCY, - new ICondition.Not<ISubTagContainer>(SubTag.NO_SMASHING)); + new ICondition.Not<>(SubTag.NO_SMASHING)); - gemChipped.mCondition = new ICondition.And<ISubTagContainer>( + gemChipped.mCondition = new ICondition.And<>( SubTag.TRANSPARENT, SubTag.CRYSTAL, - new ICondition.Not<ISubTagContainer>(SubTag.QUARTZ), - new ICondition.Not<ISubTagContainer>(SubTag.PEARL), - new ICondition.Not<ISubTagContainer>(SubTag.MAGICAL)); - gemFlawed.mCondition = new ICondition.And<ISubTagContainer>( + 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<ISubTagContainer>(SubTag.QUARTZ), - new ICondition.Not<ISubTagContainer>(SubTag.PEARL), - new ICondition.Not<ISubTagContainer>(SubTag.MAGICAL)); - gemFlawless.mCondition = new ICondition.And<ISubTagContainer>( + 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<ISubTagContainer>(SubTag.QUARTZ), - new ICondition.Not<ISubTagContainer>(SubTag.PEARL), - new ICondition.Not<ISubTagContainer>(SubTag.MAGICAL)); - gemExquisite.mCondition = new ICondition.And<ISubTagContainer>( + 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<ISubTagContainer>(SubTag.QUARTZ), - new ICondition.Not<ISubTagContainer>(SubTag.PEARL), - new ICondition.Not<ISubTagContainer>(SubTag.MAGICAL)); + new ICondition.Not<>(SubTag.QUARTZ), + new ICondition.Not<>(SubTag.PEARL), + new ICondition.Not<>(SubTag.MAGICAL)); - lens.mCondition = new ICondition.Or<ISubTagContainer>( + lens.mCondition = new ICondition.Or<>( SubTag.MAGICAL, - new ICondition.And<ISubTagContainer>(SubTag.TRANSPARENT, SubTag.HAS_COLOR)); - - plateDouble.mCondition = new ICondition.Or<ISubTagContainer>( - SubTag.PAPER, - new ICondition.Not<ISubTagContainer>(SubTag.NO_SMASHING)); - plateTriple.mCondition = new ICondition.Or<ISubTagContainer>( - SubTag.PAPER, - new ICondition.Not<ISubTagContainer>(SubTag.NO_SMASHING)); - plateQuadruple.mCondition = new ICondition.Or<ISubTagContainer>( - SubTag.PAPER, - new ICondition.Not<ISubTagContainer>(SubTag.NO_SMASHING)); - plateQuintuple.mCondition = new ICondition.Or<ISubTagContainer>( - SubTag.PAPER, - new ICondition.Not<ISubTagContainer>(SubTag.NO_SMASHING)); - - plateDense.mCondition = new ICondition.Not<ISubTagContainer>(SubTag.NO_SMASHING); - - ingotDouble.mCondition = new ICondition.Not<ISubTagContainer>(SubTag.NO_SMASHING); - ingotTriple.mCondition = new ICondition.Not<ISubTagContainer>(SubTag.NO_SMASHING); - ingotQuadruple.mCondition = new ICondition.Not<ISubTagContainer>(SubTag.NO_SMASHING); - ingotQuintuple.mCondition = new ICondition.Not<ISubTagContainer>(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<TC_AspectStack> mAspects = new ArrayList<TC_AspectStack>(); - public final Collection<OrePrefixes> mFamiliarPrefixes = new HashSet<OrePrefixes>(); + public final List<TC_AspectStack> mAspects = new ArrayList<>(); + public final Collection<OrePrefixes> 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<Materials> mDisabledItems = new HashSet<Materials>(), - mNotGeneratedItems = new HashSet<Materials>(), mIgnoredMaterials = new HashSet<Materials>(), - mGeneratedItems = new HashSet<Materials>(); - private final ArrayList<IOreRecipeRegistrator> mOreProcessing = new ArrayList<IOreRecipeRegistrator>(); + public final Collection<Materials> mDisabledItems = new HashSet<>(), mNotGeneratedItems = new HashSet<>(), + mIgnoredMaterials = new HashSet<>(), mGeneratedItems = new HashSet<>(); + private final ArrayList<IOreRecipeRegistrator> mOreProcessing = new ArrayList<>(); public ItemStack mContainerItem = null; public ICondition<ISubTagContainer> 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<ConsumerNode> 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<ConsumerNode> 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<ItemStack> getInventory() { try { return super.getInventory(); } catch (Throwable e) { @@ -643,8 +643,7 @@ public class GT_Container extends Container { if (tStackSizedOne == null || tStackHeld.stackSize == 0) return null; int tOriginalFluidAmount = tTankStack.amount; ItemStack tFilledContainer = GT_Utility.fillFluidContainer(tTankStack, tStackSizedOne, true, false); - if (tFilledContainer == null && tStackSizedOne.getItem() instanceof IFluidContainerItem) { - IFluidContainerItem tContainerItem = (IFluidContainerItem) tStackSizedOne.getItem(); + if (tFilledContainer == null && tStackSizedOne.getItem() instanceof IFluidContainerItem tContainerItem) { int tFilledAmount = tContainerItem.fill(tStackSizedOne, tTankStack, true); if (tFilledAmount > 0) { tFilledContainer = tStackSizedOne; @@ -694,9 +693,8 @@ public class GT_Container extends Container { tStackEmptied = GT_Utility.getContainerForFilledItem(tStackSizedOne, false); tAmountTaken = aFluidHeld.amount; } - if (tStackEmptied == null && tStackSizedOne.getItem() instanceof IFluidContainerItem) { + if (tStackEmptied == null && tStackSizedOne.getItem() instanceof IFluidContainerItem container) { // either partially accepted, or is IFluidContainerItem - IFluidContainerItem container = (IFluidContainerItem) tStackSizedOne.getItem(); FluidStack tDrained = container.drain(tStackSizedOne, tFreeSpace, true); if (tDrained != null && tDrained.amount > 0) { // something is actually drained - change the cell and drop it to player diff --git a/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java b/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java index 4627362e66..3f2b45064d 100644 --- a/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java +++ b/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java @@ -59,8 +59,7 @@ public class GT_ContainerMetaTile_Machine extends GT_Container { } protected void addCircuitSlot() { - if (mTileEntity.getMetaTileEntity() instanceof IConfigurationCircuitSupport) { - IConfigurationCircuitSupport ccs = (IConfigurationCircuitSupport) mTileEntity.getMetaTileEntity(); + if (mTileEntity.getMetaTileEntity() instanceof IConfigurationCircuitSupport ccs) { GT_Slot_Render slotCircuit = new GT_Slot_Render( mTileEntity, ccs.getCircuitSlot(), @@ -94,8 +93,8 @@ public class GT_ContainerMetaTile_Machine extends GT_Container { mActive = mTileEntity.isActive() ? 1 : 0; mTimer++; - for (Object crafter : this.crafters) { - ICrafting player = (ICrafting) crafter; + for (ICrafting crafter : this.crafters) { + ICrafting player = crafter; if (mTimer % 500 == 10 || oEnergy != mEnergy) { player.sendProgressBarUpdate(this, 0, mEnergy & 65535); player.sendProgressBarUpdate(this, 1, mEnergy >>> 16); @@ -165,69 +164,27 @@ public class GT_ContainerMetaTile_Machine extends GT_Container { public void updateProgressBar(int id, int value) { super.updateProgressBar(id, value); switch (id) { - case 0: - mEnergy = mEnergy & 0xffff0000 | value & 0x0000ffff; - break; - case 1: - mEnergy = mEnergy & 0x0000ffff | value << 16; - break; - case 2: - mStorage = mStorage & 0xffff0000 | value & 0x0000ffff; - break; - case 3: - mStorage = mStorage & 0x0000ffff | value << 16; - break; - case 4: - mOutput = value; - break; - case 5: - mInput = value; - break; - case 6: - mDisplayErrorCode = value; - break; - case 11: - mProgressTime = mProgressTime & 0xffff0000 | value; - break; - case 12: - mProgressTime = mProgressTime & 0x0000ffff | value << 16; - break; - case 13: - mMaxProgressTime = mMaxProgressTime & 0xffff0000 | value & 0x0000ffff; - break; - case 14: - mMaxProgressTime = mMaxProgressTime & 0x0000ffff | value << 16; - break; - case 15: - mID = value; - break; - case 16: - mActive = value; - break; - case 17: - mSteam = mSteam & 0xffff0000 | value & 0x0000ffff; - break; - case 18: - mSteam = mSteam & 0x0000ffff | value << 16; - break; - case 19: - mSteamStorage = mSteamStorage & 0xffff0000 | value & 0x0000ffff; - break; - case 20: - mSteamStorage = mSteamStorage & 0x0000ffff | value << 16; - break; - case 21: - mEnergyLong = mEnergyLong & 0xffffffff00000000L | value & 0x00000000ffffffffL; - break; - case 22: - mEnergyLong = mEnergyLong & 0x00000000ffffffffL | (long) value << 32; - break; - case 23: - mStorageLong = mStorageLong & 0xffffffff00000000L | value & 0x00000000ffffffffL; - break; - case 24: - mStorageLong = mStorageLong & 0x00000000ffffffffL | (long) value << 32; - break; + case 0 -> mEnergy = mEnergy & 0xffff0000 | value & 0x0000ffff; + case 1 -> mEnergy = mEnergy & 0x0000ffff | value << 16; + case 2 -> mStorage = mStorage & 0xffff0000 | value & 0x0000ffff; + case 3 -> mStorage = mStorage & 0x0000ffff | value << 16; + case 4 -> mOutput = value; + case 5 -> mInput = value; + case 6 -> mDisplayErrorCode = value; + case 11 -> mProgressTime = mProgressTime & 0xffff0000 | value; + case 12 -> mProgressTime = mProgressTime & 0x0000ffff | value << 16; + case 13 -> mMaxProgressTime = mMaxProgressTime & 0xffff0000 | value & 0x0000ffff; + case 14 -> mMaxProgressTime = mMaxProgressTime & 0x0000ffff | value << 16; + case 15 -> mID = value; + case 16 -> mActive = value; + case 17 -> mSteam = mSteam & 0xffff0000 | value & 0x0000ffff; + case 18 -> mSteam = mSteam & 0x0000ffff | value << 16; + case 19 -> mSteamStorage = mSteamStorage & 0xffff0000 | value & 0x0000ffff; + case 20 -> mSteamStorage = mSteamStorage & 0x0000ffff | value << 16; + case 21 -> mEnergyLong = mEnergyLong & 0xffffffff00000000L | value & 0x00000000ffffffffL; + case 22 -> mEnergyLong = mEnergyLong & 0x00000000ffffffffL | (long) value << 32; + case 23 -> mStorageLong = mStorageLong & 0xffffffff00000000L | value & 0x00000000ffffffffL; + case 24 -> mStorageLong = mStorageLong & 0x00000000ffffffffL | (long) value << 32; } } diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java index 101c1cba83..976d7e8127 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java @@ -203,23 +203,25 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { GT_MetaTileEntity_BasicMachine machine = getMachine(); if (machine == null) return null; switch (aSlotNumber) { - case 0: + case 0 -> { if (slotFluidTransferToggle.isEnabled()) { machine.mFluidTransfer = !machine.mFluidTransfer; } return null; - case 1: + } + case 1 -> { if (slotItemTransferToggle.isEnabled()) { machine.mItemTransfer = !machine.mItemTransfer; } return null; - default: + } + default -> { if (aSlotNumber == OTHER_SLOT_COUNT + 1 + machine.mInputSlotCount + machine.mOutputItems.length && aMouseclick < 2) { GT_MetaTileEntity_BasicTank tTank = (GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity(); if (mTileEntity.isClientSide()) { // see parent class slotClick for an explanation on why doing this - Slot slot = (Slot) inventorySlots.get(aSlotNumber); + Slot slot = inventorySlots.get(aSlotNumber); tTank.setFillableStack(GT_Utility.getFluidFromDisplayStack(slot.getStack())); } IFluidAccess tFillableAccess = constructFluidAccess(tTank, true); @@ -236,6 +238,7 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { } else { return super.slotClick(aSlotNumber, aMouseclick, aShifthold, aPlayer); } + } } } @@ -248,8 +251,8 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { mItemTransfer = getMachine().mItemTransfer; mStuttering = getMachine().mStuttering; - for (Object crafter : this.crafters) { - ICrafting player = (ICrafting) crafter; + for (ICrafting crafter : this.crafters) { + ICrafting player = crafter; player.sendProgressBarUpdate(this, 102, mFluidTransfer ? 1 : 0); player.sendProgressBarUpdate(this, 103, mItemTransfer ? 1 : 0); player.sendProgressBarUpdate(this, 104, mStuttering ? 1 : 0); @@ -266,15 +269,9 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { public void updateProgressBar(int id, int value) { super.updateProgressBar(id, value); switch (id) { - case 102: - mFluidTransfer = (value != 0); - break; - case 103: - mItemTransfer = (value != 0); - break; - case 104: - mStuttering = (value != 0); - break; + case 102 -> mFluidTransfer = (value != 0); + case 103 -> mItemTransfer = (value != 0); + case 104 -> mStuttering = (value != 0); } } diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java index 5aa793f8f6..f463b35f7c 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java @@ -51,7 +51,7 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine { * to become only more severe when playing MP over ethernet, which would have much more latency than a * memory connection */ - Slot slot = (Slot) inventorySlots.get(aSlotIndex); + Slot slot = inventorySlots.get(aSlotIndex); tTank.setDrainableStack(GT_Utility.getFluidFromDisplayStack(slot.getStack())); } IFluidAccess tDrainableAccess = constructFluidAccess(tTank, false); @@ -77,8 +77,8 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine { } public void sendProgressBar() { - for (Object crafter : this.crafters) { - ICrafting player = (ICrafting) crafter; + for (ICrafting crafter : this.crafters) { + ICrafting player = crafter; if (mTimer % 500 == 0 || oContent != mContent) { player.sendProgressBarUpdate(this, 100, mContent & 65535); player.sendProgressBarUpdate(this, 101, mContent >>> 16); @@ -91,12 +91,8 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine { public void updateProgressBar(int id, int value) { super.updateProgressBar(id, value); switch (id) { - case 100: - mContent = mContent & 0xffff0000 | value & 0x0000ffff; - break; - case 101: - mContent = mContent & 0xffff | value << 16; - break; + case 100 -> mContent = mContent & 0xffff0000 | value & 0x0000ffff; + case 101 -> mContent = mContent & 0xffff | value << 16; } } diff --git a/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java b/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java index 06ddf16d02..7c6328bb34 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java +++ b/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java @@ -23,27 +23,26 @@ public class GT_GUIColorOverride { private static final Object NOT_FOUND = new Object(); private static final LoadingCache<ResourceLocation, Object> cache = CacheBuilder.newBuilder() .softValues() - .build( - new CacheLoader<ResourceLocation, Object>() { - - @Override - public Object load( - @Nonnull ResourceLocation key) - throws Exception { - IResource ir = Minecraft.getMinecraft() - .getResourceManager() - .getResource( - key); - if (ir.hasMetadata()) - return ir.getMetadata( - "colors"); - // return a dummy - // object because - // LoadingCache - // doesn't like null - return NOT_FOUND; - } - }); + .build(new CacheLoader<>() { + + @Override + public Object load( + @Nonnull ResourceLocation key) + throws Exception { + IResource ir = Minecraft.getMinecraft() + .getResourceManager() + .getResource( + key); + if (ir.hasMetadata()) + return ir.getMetadata( + "colors"); + // return a dummy + // object because + // LoadingCache + // doesn't like null + return NOT_FOUND; + } + }); private static final GT_GUIColorOverride FALLBACK = new GT_GUIColorOverride(); private ColorsMetadataSection cmSection; diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java b/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java index e44b4f0cbc..cbccdc5385 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java @@ -180,8 +180,7 @@ public class GT_GUIContainerMetaTile_Machine extends GT_GUIContainer implements * are enabled. */ protected void setupTooltips() { - if (mContainer.mTileEntity.getMetaTileEntity() instanceof IConfigurationCircuitSupport) { - IConfigurationCircuitSupport ccs = (IConfigurationCircuitSupport) mContainer.mTileEntity.getMetaTileEntity(); + if (mContainer.mTileEntity.getMetaTileEntity() instanceof IConfigurationCircuitSupport ccs) { if (ccs.allowSelectCircuit()) addToolTip( new GT_GuiSlotTooltip( mContainer.getSlot(ccs.getCircuitGUISlot()), @@ -191,7 +190,7 @@ public class GT_GUIContainerMetaTile_Machine extends GT_GUIContainer implements // GT_IToolTipRenderer and GT_ITabRenderer implementations @Override - public void drawHoveringText(List text, int mouseX, int mouseY, FontRenderer font) { + public void drawHoveringText(List<String> text, int mouseX, int mouseY, FontRenderer font) { super.drawHoveringText(text, mouseX, mouseY, font); } @@ -232,8 +231,7 @@ public class GT_GUIContainerMetaTile_Machine extends GT_GUIContainer implements @Override protected void onMouseWheel(int mx, int my, int delta) { - if (mContainer.mTileEntity.getMetaTileEntity() instanceof IConfigurationCircuitSupport) { - IConfigurationCircuitSupport ccs = (IConfigurationCircuitSupport) mContainer.mTileEntity.getMetaTileEntity(); + if (mContainer.mTileEntity.getMetaTileEntity() instanceof IConfigurationCircuitSupport ccs) { Slot slotCircuit = mContainer.getSlot(ccs.getCircuitGUISlot()); if (slotCircuit != null && func_146978_c(slotCircuit.xDisplayPosition, slotCircuit.yDisplayPosition, 16, 16, mx, my)) { diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java index 899d8331bc..eb0122093c 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java @@ -11,7 +11,6 @@ import gregtech.api.enums.GT_Values; import gregtech.api.gui.widgets.GT_GuiIcon; import gregtech.api.gui.widgets.GT_GuiSlotTooltip; import gregtech.api.gui.widgets.GT_GuiSmartTooltip; -import gregtech.api.gui.widgets.GT_GuiSmartTooltip.TooltipVisibilityProvider; import gregtech.api.gui.widgets.GT_GuiTabLine.GT_GuiTabIconSet; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; @@ -84,12 +83,11 @@ public class GT_GUIContainer_BasicMachine extends GT_GUIContainerMetaTile_Machin if (machine.isSteampowered()) { batterySlotTooltipKey = UNUSED_SLOT_TOOLTIP; batterySlotTooltipArgs = new String[0]; - addToolTip(new GT_GuiSmartTooltip(tProblemArea, new TooltipVisibilityProvider() { - - public boolean shouldShowTooltip() { - return hasErrorCode(NEEDS_STEAM_VENTING); - } - }, mTooltipCache.getData(STALLED_VENT_TOOLTIP))); + addToolTip( + new GT_GuiSmartTooltip( + tProblemArea, + () -> hasErrorCode(NEEDS_STEAM_VENTING), + mTooltipCache.getData(STALLED_VENT_TOOLTIP))); } else { String pTier1 = powerTierName(machine.mTier); if (machine.mTier == GT_Values.VN.length - 1) { @@ -130,21 +128,19 @@ public class GT_GUIContainer_BasicMachine extends GT_GUIContainerMetaTile_Machin mTooltipCache.getData( recipes != null && recipes.usesSpecialSlot() ? SPECIAL_SLOT_TOOLTIP : UNUSED_SLOT_TOOLTIP))); - addToolTip(new GT_GuiSmartTooltip(tProblemArea, new TooltipVisibilityProvider() { - - public boolean shouldShowTooltip() { - return container.mStuttering && !hasErrorCode(NEEDS_STEAM_VENTING); - } - }, - mTooltipCache.getData( - STALLED_STUTTERING_TOOLTIP, - StatCollector.translateToLocal( - POWER_SOURCE_KEY + (machine.isSteampowered() ? "steam" : "power"))))); + addToolTip( + new GT_GuiSmartTooltip( + tProblemArea, + () -> container.mStuttering && !hasErrorCode(NEEDS_STEAM_VENTING), + mTooltipCache.getData( + STALLED_STUTTERING_TOOLTIP, + StatCollector.translateToLocal( + POWER_SOURCE_KEY + (machine.isSteampowered() ? "steam" : "power"))))); } /** * Apply proper coloration to a machine's power tier short name - * + * * @param machineTier * @return colored power tier short name */ @@ -187,34 +183,38 @@ public class GT_GUIContainer_BasicMachine extends GT_GUIContainerMetaTile_Machin % (tSize + 1); switch (mProgressBarDirection) { // yes, my OCD was mad at me before I did the Tabs. - case 0: - drawTexturedModalRect(x + 78, y + 24, 176, 0, tProgress, 18); - break; - case 1: - drawTexturedModalRect(x + 78 + 20 - tProgress, y + 24, 176 + 20 - tProgress, 0, tProgress, 18); - break; - case 2: - drawTexturedModalRect(x + 78, y + 24, 176, 0, 20, tProgress); - break; - case 3: - drawTexturedModalRect(x + 78, y + 24 + 18 - tProgress, 176, 18 - tProgress, 20, tProgress); - break; - case 4: + case 0 -> drawTexturedModalRect(x + 78, y + 24, 176, 0, tProgress, 18); + case 1 -> drawTexturedModalRect( + x + 78 + 20 - tProgress, + y + 24, + 176 + 20 - tProgress, + 0, + tProgress, + 18); + case 2 -> drawTexturedModalRect(x + 78, y + 24, 176, 0, 20, tProgress); + case 3 -> drawTexturedModalRect( + x + 78, + y + 24 + 18 - tProgress, + 176, + 18 - tProgress, + 20, + tProgress); + case 4 -> { tProgress = 20 - tProgress; drawTexturedModalRect(x + 78, y + 24, 176, 0, tProgress, 18); - break; - case 5: + } + case 5 -> { tProgress = 20 - tProgress; drawTexturedModalRect(x + 78 + 20 - tProgress, y + 24, 176 + 20 - tProgress, 0, tProgress, 18); - break; - case 6: + } + case 6 -> { tProgress = 18 - tProgress; drawTexturedModalRect(x + 78, y + 24, 176, 0, 20, tProgress); - break; - case 7: + } + case 7 -> { tProgress = 18 - tProgress; drawTexturedModalRect(x + 78, y + 24 + 18 - tProgress, 176, 18 - tProgress, 20, tProgress); - break; + } } } } diff --git a/src/main/java/gregtech/api/gui/GT_GUIDialogSelectItem.java b/src/main/java/gregtech/api/gui/GT_GUIDialogSelectItem.java index fed1671484..1f95def197 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIDialogSelectItem.java +++ b/src/main/java/gregtech/api/gui/GT_GUIDialogSelectItem.java @@ -52,7 +52,7 @@ public class GT_GUIDialogSelectItem extends GT_GUIScreen { /** * Open a dialog to select an item from given list. Given callback may be called zero or more times depending on * user action. - * + * * @param header Header text * @param headerItem ItemStack to use as Dialog icon * @param parent open which GUIScreen when this dialog is closed. use null if it has no parent. @@ -105,12 +105,14 @@ public class GT_GUIDialogSelectItem extends GT_GUIScreen { @Override public void buttonClicked(GuiButton button) { switch (button.id) { - case 0: + case 0 -> { setScroll(scroll - 1); return; - case 1: + } + case 1 -> { setScroll(scroll + 1); return; + } } super.buttonClicked(button); } diff --git a/src/main/java/gregtech/api/gui/GT_GUIScreen.java b/src/main/java/gregtech/api/gui/GT_GUIScreen.java index 1aa9ccc24c..52ecbe8ab5 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIScreen.java +++ b/src/main/java/gregtech/api/gui/GT_GUIScreen.java @@ -61,7 +61,7 @@ public abstract class GT_GUIScreen extends GuiScreen implements GT_IToolTipRende guiTop = (this.height - this.gui_height) / 2; for (IGuiElement element : elements) { - if (element instanceof GuiButton) buttonList.add(element); + if (element instanceof GuiButton button) buttonList.add(button); if (element instanceof GT_GuiIntegerTextBox) textBoxes.add((GT_GuiIntegerTextBox) element); } @@ -181,12 +181,11 @@ public abstract class GT_GUIScreen extends GuiScreen implements GT_IToolTipRende if (focusedTextBox != null) { resetTextBox(focusedTextBox); setFocusedTextBox(null); - return; } else { closeScreen(); // don't fall through to parent - return; } + return; } if (c == '\t') { // tab @@ -268,7 +267,7 @@ public abstract class GT_GUIScreen extends GuiScreen implements GT_IToolTipRende * GT_IToolTipRenderer */ @Override - public void drawHoveringText(List text, int mouseX, int mouseY, FontRenderer render) { + public void drawHoveringText(List<String> text, int mouseX, int mouseY, FontRenderer render) { super.drawHoveringText(text, mouseX, mouseY, render); } diff --git a/src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java b/src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java index e068cd967e..4d004429b0 100644 --- a/src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java +++ b/src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java @@ -89,8 +89,7 @@ public class GT_UIInfos { UIBuilder.of() .container((player, world, x, y, z) -> { final TileEntity te = world.getTileEntity(x, y, z); - if (!(te instanceof ICoverable)) return null; - final ICoverable gtTileEntity = (ICoverable) te; + if (!(te instanceof ICoverable gtTileEntity)) return null; GT_CoverBehaviorBase<?> cover = gtTileEntity.getCoverBehaviorAtSideNew(side); return createCoverContainer( player, @@ -103,8 +102,7 @@ public class GT_UIInfos { .gui((player, world, x, y, z) -> { if (!world.isRemote) return null; final TileEntity te = world.getTileEntity(x, y, z); - if (!(te instanceof ICoverable)) return null; - final ICoverable gtTileEntity = (ICoverable) te; + if (!(te instanceof ICoverable gtTileEntity)) return null; final GT_CoverBehaviorBase<?> cover = gtTileEntity.getCoverBehaviorAtSideNew(side); return createCoverGuiContainer( player, diff --git a/src/main/java/gregtech/api/gui/modularui/SteamTexture.java b/src/main/java/gregtech/api/gui/modularui/SteamTexture.java index 619b19e232..7cebd957f2 100644 --- a/src/main/java/gregtech/api/gui/modularui/SteamTexture.java +++ b/src/main/java/gregtech/api/gui/modularui/SteamTexture.java @@ -50,29 +50,21 @@ public class SteamTexture { } public UITexture get(SteamVariant variant) { - switch (variant) { - case BRONZE: - return bronzeTexture; - case STEEL: - return steelTexture; - case PRIMITIVE: - return primitiveTexture; - default: - return null; - } + return switch (variant) { + case BRONZE -> bronzeTexture; + case STEEL -> steelTexture; + case PRIMITIVE -> primitiveTexture; + default -> null; + }; } public AdaptableUITexture getAdaptable(SteamVariant variant) { - switch (variant) { - case BRONZE: - return (AdaptableUITexture) bronzeTexture; - case STEEL: - return (AdaptableUITexture) steelTexture; - case PRIMITIVE: - return (AdaptableUITexture) primitiveTexture; - default: - return null; - } + return switch (variant) { + case BRONZE -> (AdaptableUITexture) bronzeTexture; + case STEEL -> (AdaptableUITexture) steelTexture; + case PRIMITIVE -> (AdaptableUITexture) primitiveTexture; + default -> null; + }; } public UITexture get(boolean isHighPressure) { diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java index 01c8671678..cb149547b4 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java @@ -119,10 +119,8 @@ public enum GT_GuiIcon implements IGuiIcon { if (location == null || location.length == 0) return; int startIndex = TEXTURES.length; - TEXTURES = (ResourceLocation[]) Arrays.copyOf(TEXTURES, location.length); - for (int i = 0; i < location.length; i++) { - TEXTURES[startIndex + i] = location[i]; - } + TEXTURES = Arrays.copyOf(TEXTURES, location.length); + System.arraycopy(location, 0, TEXTURES, startIndex + 0, location.length); } @Override diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java index 9caf51cd4b..01a0f3c8b1 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java @@ -34,7 +34,7 @@ public class GT_GuiTabLine { /** * Controls the rendering style of the tab line */ - public static enum DisplayStyle { + public enum DisplayStyle { NONE((byte) 0), NORMAL((byte) 1), @@ -189,9 +189,9 @@ public class GT_GuiTabLine { * @param mouseY */ protected void drawOverlays(float parTicks, int mouseX, int mouseY) { - for (int i = 0; i < mTabs.length; i++) { - if (mTabs[i] != null) { - mTabs[i].drawOverlays(mouseX, mouseY, parTicks); + for (GT_GuiTab mTab : mTabs) { + if (mTab != null) { + mTab.drawOverlays(mouseX, mouseY, parTicks); } } } @@ -204,9 +204,9 @@ public class GT_GuiTabLine { * @param mouseY */ protected void drawBackground(float parTicks, int mouseX, int mouseY) { - for (int i = 0; i < mTabs.length; i++) { - if (mTabs[i] != null) { - mTabs[i].drawBackground(mouseX, mouseY, parTicks); + for (GT_GuiTab mTab : mTabs) { + if (mTab != null) { + mTab.drawBackground(mouseX, mouseY, parTicks); } } } diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java index 1162630d5e..326e744382 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java @@ -2,7 +2,6 @@ package gregtech.api.gui.widgets; import java.awt.Rectangle; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -44,10 +43,10 @@ public class GT_GuiTooltip { private TooltipData sanitizeTooltipData(TooltipData data) { if (data.text == null) { - data.text = Arrays.asList(new String[0]); + data.text = Collections.emptyList(); } if (data.shiftText == null) { - data.shiftText = Arrays.asList(new String[0]); + data.shiftText = Collections.emptyList(); } return data; } @@ -97,10 +96,10 @@ public class GT_GuiTooltip { List<String> list; if (text != null) { list = new ArrayList<>(text.length); - for (int i = 0; i < text.length; i++) { - if (text[i] == null) continue; - if (list.isEmpty()) list.add("\u00a7f" + text[i]); - else list.add("\u00a77" + text[i]); + for (String s : text) { + if (s == null) continue; + if (list.isEmpty()) list.add("\u00a7f" + s); + else list.add("\u00a77" + s); } } else { list = Collections.emptyList(); diff --git a/src/main/java/gregtech/api/interfaces/ICondition.java b/src/main/java/gregtech/api/interfaces/ICondition.java index 554cd2df77..9c7033b3d7 100644 --- a/src/main/java/gregtech/api/interfaces/ICondition.java +++ b/src/main/java/gregtech/api/interfaces/ICondition.java @@ -24,6 +24,7 @@ public interface ICondition<O> { private final ICondition<O>[] mConditions; + @SafeVarargs public Or(ICondition<O>... aConditions) { mConditions = aConditions; } @@ -39,6 +40,7 @@ public interface ICondition<O> { private final ICondition<O>[] mConditions; + @SafeVarargs public Nor(ICondition<O>... aConditions) { mConditions = aConditions; } @@ -54,6 +56,7 @@ public interface ICondition<O> { private final ICondition<O>[] mConditions; + @SafeVarargs public And(ICondition<O>... aConditions) { mConditions = aConditions; } @@ -69,6 +72,7 @@ public interface ICondition<O> { private final ICondition<O>[] mConditions; + @SafeVarargs public Nand(ICondition<O>... aConditions) { mConditions = aConditions; } diff --git a/src/main/java/gregtech/api/interfaces/IIconContainer.java b/src/main/java/gregtech/api/interfaces/IIconContainer.java index fbb9e53519..b76b4c5e9c 100644 --- a/src/main/java/gregtech/api/interfaces/IIconContainer.java +++ b/src/main/java/gregtech/api/interfaces/IIconContainer.java @@ -28,7 +28,7 @@ public interface IIconContainer { @SideOnly(Side.CLIENT) default int getIconPasses() { return 1; - }; + } /** * @return the Default Texture File for this Icon. @@ -37,12 +37,12 @@ public interface IIconContainer { ResourceLocation getTextureFile(); @SideOnly(Side.CLIENT) - public default short[] getIconColor(int aRenderPass) { + default short[] getIconColor(int aRenderPass) { return UNCOLORED_RBGA; } @SideOnly(Side.CLIENT) - public default boolean isUsingColorModulation(int aRenderPass) { + default boolean isUsingColorModulation(int aRenderPass) { return aRenderPass == 0; } } diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java b/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java index 37a7d2fc5c..1affdb0d74 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java @@ -60,11 +60,10 @@ public interface IEnergyConnected extends IColoredTileEntity { */ public static long emitEnergyToNetwork(long aVoltage, long aAmperage, IEnergyConnected aEmitter) { long rUsedAmperes = 0; - if (!(aEmitter instanceof IHasWorldObjectAndCoords)) { + if (!(aEmitter instanceof IHasWorldObjectAndCoords emitterTile)) { return 0; } - IHasWorldObjectAndCoords emitterTile = (IHasWorldObjectAndCoords) aEmitter; for (byte i = 0, j = 0; i < 6 && aAmperage > rUsedAmperes; i++) { if (!aEmitter.outputsEnergyTo(i)) { continue; @@ -72,8 +71,7 @@ public interface IEnergyConnected extends IColoredTileEntity { j = GT_Utility.getOppositeSide(i); final TileEntity tTileEntity = emitterTile.getTileEntityAtSide(i); - if (tTileEntity instanceof PowerLogicHost) { - PowerLogicHost host = (PowerLogicHost) tTileEntity; + if (tTileEntity instanceof PowerLogicHost host) { PowerLogic logic = host.getPowerLogic(j); if (logic == null || logic.isEnergyReceiver()) { diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IExperimentalEnergyTileEntity.java b/src/main/java/gregtech/api/interfaces/tileentity/IExperimentalEnergyTileEntity.java index 119a1af207..1f0c7f4b1c 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IExperimentalEnergyTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IExperimentalEnergyTileEntity.java @@ -51,14 +51,14 @@ public interface IExperimentalEnergyTileEntity extends IColoredTileEntity, IHasW private static void checkAvailabilities() { if (CHECK_ALL) { try { - Class tClass = cofh.api.energy.IEnergyReceiver.class; + Class<IEnergyReceiver> tClass = cofh.api.energy.IEnergyReceiver.class; tClass.getCanonicalName(); RF_ENERGY = true; } catch (Throwable e) { /**/ } try { - Class tClass = ic2.api.energy.tile.IEnergySink.class; + Class<IEnergySink> tClass = ic2.api.energy.tile.IEnergySink.class; tClass.getCanonicalName(); IC_ENERGY = true; } catch (Throwable e) { diff --git a/src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java b/src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java index 3830ec6e52..36dff21cb0 100644 --- a/src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java +++ b/src/main/java/gregtech/api/items/GT_Block_LongDistancePipe.java @@ -115,7 +115,7 @@ public class GT_Block_LongDistancePipe extends GT_Generic_Block { @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item aItem, CreativeTabs aCreativeTab, List aList) { + public void getSubBlocks(Item aItem, CreativeTabs aCreativeTab, List<ItemStack> aList) { for (int i = 0; i < 3; i++) { ItemStack aStack = new ItemStack(aItem, 1, i); if (!aStack.getDisplayName() diff --git a/src/main/java/gregtech/api/items/GT_BreederCell_Item.java b/src/main/java/gregtech/api/items/GT_BreederCell_Item.java index 3371a1a261..144fc0d39e 100644 --- a/src/main/java/gregtech/api/items/GT_BreederCell_Item.java +++ b/src/main/java/gregtech/api/items/GT_BreederCell_Item.java @@ -67,8 +67,7 @@ public class GT_BreederCell_Item extends GT_Generic_Item implements IReactorComp @Override public void onUpdate(ItemStack stack, World world, Entity entity, int slotIndex, boolean isCurrentItem) { - if ((entity instanceof EntityLivingBase)) { - EntityLivingBase entityLiving = (EntityLivingBase) entity; + if ((entity instanceof EntityLivingBase entityLiving)) { if (!GregTech_API.mIC2Classic && !GT_Utility.isWearingFullRadioHazmat(entityLiving)) { IC2Potion.radiation.applyTo(entityLiving, 20, 1); } @@ -79,19 +78,11 @@ public class GT_BreederCell_Item extends GT_Generic_Item implements IReactorComp public void addAdditionalToolTips(List<String> aList, ItemStack aStack, EntityPlayer aPlayer) { aList.add(transItem("019", "Bath with neutron in a hot reactor")); int rDmg = aStack.getItemDamage() * 4 / getMaxDamage(); - EnumChatFormatting color2; - switch (rDmg) { - case 0: - color2 = EnumChatFormatting.DARK_GRAY; - break; - case 1: - case 2: - color2 = EnumChatFormatting.GRAY; - break; - default: - color2 = EnumChatFormatting.WHITE; - break; - } + EnumChatFormatting color2 = switch (rDmg) { + case 0 -> EnumChatFormatting.DARK_GRAY; + case 1, 2 -> EnumChatFormatting.GRAY; + default -> EnumChatFormatting.WHITE; + }; aList.add( String.format( transItem("020", "Progress: %s/%s"), diff --git a/src/main/java/gregtech/api/items/GT_CoolantCellIC_Item.java b/src/main/java/gregtech/api/items/GT_CoolantCellIC_Item.java index 73d3dc3be8..492d009364 100644 --- a/src/main/java/gregtech/api/items/GT_CoolantCellIC_Item.java +++ b/src/main/java/gregtech/api/items/GT_CoolantCellIC_Item.java @@ -51,7 +51,7 @@ public class GT_CoolantCellIC_Item extends GT_CoolantCell_Item implements IReact } tHeat += aHeat; if (tHeat > this.heatStorage) { - aReactor.setItemAt(x, y, (ItemStack) null); + aReactor.setItemAt(x, y, null); aHeat = this.heatStorage - tHeat + 1; } else { if (tHeat < 0) { diff --git a/src/main/java/gregtech/api/items/GT_CoolantCell_Item.java b/src/main/java/gregtech/api/items/GT_CoolantCell_Item.java index b6530df95c..1b9a6de98a 100644 --- a/src/main/java/gregtech/api/items/GT_CoolantCell_Item.java +++ b/src/main/java/gregtech/api/items/GT_CoolantCell_Item.java @@ -54,36 +54,19 @@ public class GT_CoolantCell_Item extends GT_Generic_Item { public void addAdditionalToolTips(List<String> aList, ItemStack aStack, EntityPlayer aPlayer) { super.addAdditionalToolTips(aList, aStack, aPlayer); int rHeat = getHeatOfStack(aStack) * 10 / this.heatStorage; - EnumChatFormatting color; - switch (rHeat) { - case 0: - color = EnumChatFormatting.BLUE; - break; - case 1: - case 2: - color = EnumChatFormatting.GREEN; - break; - case 3: - case 4: - case 5: - case 6: - color = EnumChatFormatting.YELLOW; - break; - case 7: - case 8: - color = EnumChatFormatting.RED; - break; - default: - color = EnumChatFormatting.DARK_RED; - break; - } + EnumChatFormatting color = switch (rHeat) { + case 0 -> EnumChatFormatting.BLUE; + case 1, 2 -> EnumChatFormatting.GREEN; + case 3, 4, 5, 6 -> EnumChatFormatting.YELLOW; + case 7, 8 -> EnumChatFormatting.RED; + default -> EnumChatFormatting.DARK_RED; + }; aList.add( EnumChatFormatting.WHITE + String.format(transItem("000", "Stored Heat: %s"), "" + color + getHeatOfStack(aStack))); - switch (getControlTagOfStack(aStack)) { - case 1: - aList.add(StatCollector.translateToLocal("ic2.reactoritem.heatwarning.line1")); - aList.add(StatCollector.translateToLocal("ic2.reactoritem.heatwarning.line2")); + if (getControlTagOfStack(aStack) == 1) { + aList.add(StatCollector.translateToLocal("ic2.reactoritem.heatwarning.line1")); + aList.add(StatCollector.translateToLocal("ic2.reactoritem.heatwarning.line2")); } } diff --git a/src/main/java/gregtech/api/items/GT_EnergyArmor_Item.java b/src/main/java/gregtech/api/items/GT_EnergyArmor_Item.java index d9c164f3ab..d69d6d93b9 100644 --- a/src/main/java/gregtech/api/items/GT_EnergyArmor_Item.java +++ b/src/main/java/gregtech/api/items/GT_EnergyArmor_Item.java @@ -32,7 +32,7 @@ import gregtech.api.util.GT_Utility; public class GT_EnergyArmor_Item extends ItemArmor implements ISpecialArmor { - public static Map jumpChargeMap = new ConcurrentHashMap(); + public static Map<EntityPlayer, Float> jumpChargeMap = new ConcurrentHashMap<>(); public int mCharge, mTransfer, mTier, mDamageEnergyCost, mSpecials; public boolean mChargeProvider; public double mArmorAbsorbtionPercentage; @@ -88,7 +88,7 @@ public class GT_EnergyArmor_Item extends ItemArmor implements ISpecialArmor { } @Override - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List<String> aList, boolean aF3_H) { aList.add("Tier: " + mTier); if ((mSpecials & 1) != 0) aList.add("Rebreather"); if ((mSpecials & 2) != 0) aList.add("Inertia Damper"); @@ -140,8 +140,7 @@ public class GT_EnergyArmor_Item extends ItemArmor implements ISpecialArmor { } if (!aPlayer.worldObj.isRemote && (mSpecials & 128) != 0) { - float jumpCharge = jumpChargeMap.containsKey(aPlayer) ? ((Float) jumpChargeMap.get(aPlayer)).floatValue() - : 1.0F; + float jumpCharge = jumpChargeMap.containsKey(aPlayer) ? (Float) jumpChargeMap.get(aPlayer) : 1.0F; if (GT_ModHandler.canUseElectricItem(aStack, 1000) && aPlayer.onGround && jumpCharge < 1.0F) { jumpCharge = 1.0F; @@ -162,7 +161,7 @@ public class GT_EnergyArmor_Item extends ItemArmor implements ISpecialArmor { } } - jumpChargeMap.put(aPlayer, Float.valueOf(jumpCharge)); + jumpChargeMap.put(aPlayer, jumpCharge); } if ((mSpecials & 256) != 0) { @@ -237,7 +236,7 @@ public class GT_EnergyArmor_Item extends ItemArmor implements ISpecialArmor { @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item aItem, CreativeTabs creativeTab, List outputSubItems) { + public void getSubItems(Item aItem, CreativeTabs creativeTab, List<ItemStack> outputSubItems) { ItemStack tCharged = new ItemStack(this, 1), tUncharged = new ItemStack(this, 1, getMaxDamage()); GT_ModHandler.chargeElectricItem(tCharged, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false); outputSubItems.add(tCharged); @@ -291,8 +290,7 @@ public class GT_EnergyArmor_Item extends ItemArmor implements ISpecialArmor { // TODO: @ForgeSubscribe public void onEntityLivingFallEvent(LivingFallEvent event) { - if (!event.entity.worldObj.isRemote && event.entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.entity; + if (!event.entity.worldObj.isRemote && event.entity instanceof EntityPlayer player) { for (int i = 0; i < 4; i++) { ItemStack armor = player.inventory.armorInventory[i]; if (armor != null && armor.getItem() == this && (mSpecials & 2) != 0) { @@ -350,17 +348,12 @@ public class GT_EnergyArmor_Item extends ItemArmor implements ISpecialArmor { private double getBaseAbsorptionRatio() { if (mArmorAbsorbtionPercentage <= 0) return 0.00; - switch (this.armorType) { - case 0: - return 0.15; - case 1: - return 0.40; - case 2: - return 0.30; - case 3: - return 0.15; - default: - return 0.00; - } + return switch (this.armorType) { + case 0 -> 0.15; + case 1 -> 0.40; + case 2 -> 0.30; + case 3 -> 0.15; + default -> 0.00; + }; } } diff --git a/src/main/java/gregtech/api/items/GT_Generic_Item.java b/src/main/java/gregtech/api/items/GT_Generic_Item.java index b8a348144c..03e42a1b41 100644 --- a/src/main/java/gregtech/api/items/GT_Generic_Item.java +++ b/src/main/java/gregtech/api/items/GT_Generic_Item.java @@ -96,7 +96,7 @@ public class GT_Generic_Item extends Item implements IProjectileItem { @SuppressWarnings("unchecked") @Override - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List<String> aList, boolean aF3_H) { if (getMaxDamage() > 0 && !getHasSubtypes()) aList.add((aStack.getMaxDamage() - getDamage(aStack)) + " / " + aStack.getMaxDamage()); if (mTooltip != null) aList.add(GT_LanguageManager.getTranslation(mTooltip)); diff --git a/src/main/java/gregtech/api/items/GT_MetaBase_Item.java b/src/main/java/gregtech/api/items/GT_MetaBase_Item.java index 532b500d8f..c829f563b1 100644 --- a/src/main/java/gregtech/api/items/GT_MetaBase_Item.java +++ b/src/main/java/gregtech/api/items/GT_MetaBase_Item.java @@ -37,7 +37,7 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpecialElectricItem, IElectricItemManager, IFluidContainerItem { /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ - private final ConcurrentHashMap<Short, ArrayList<IItemBehaviour<GT_MetaBase_Item>>> mItemBehaviors = new ConcurrentHashMap<Short, ArrayList<IItemBehaviour<GT_MetaBase_Item>>>(); + private final ConcurrentHashMap<Short, ArrayList<IItemBehaviour<GT_MetaBase_Item>>> mItemBehaviors = new ConcurrentHashMap<>(); /** * Creates the Item using these Parameters. @@ -197,9 +197,8 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item return aStack; } - @SuppressWarnings("unchecked") @Override - public final void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + public final void addInformation(ItemStack aStack, EntityPlayer aPlayer, List<String> aList, boolean aF3_H) { String tKey = getUnlocalizedName(aStack) + ".tooltip"; String[] tStrings = GT_LanguageManager.getTranslation(tKey) .split("/n "); @@ -224,7 +223,7 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item + EnumChatFormatting.GRAY); } else { aList.add( - String.valueOf(EnumChatFormatting.AQUA) + EnumChatFormatting.AQUA + String.format( transItem("011", "%s / %s EU - Voltage: %s"), formatNumbers(tCharge), diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item.java index 5f906d670d..7d70ae1c8e 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item.java @@ -65,7 +65,7 @@ public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item implements * <p/> * You can also use the unlocalized Name gotten from getUnlocalizedName() as Key if you want to get a specific Item. */ - public static final ConcurrentHashMap<String, GT_MetaGenerated_Item> sInstances = new ConcurrentHashMap<String, GT_MetaGenerated_Item>(); + public static final ConcurrentHashMap<String, GT_MetaGenerated_Item> sInstances = new ConcurrentHashMap<>(); /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ @@ -120,7 +120,7 @@ public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item implements mVisibleItems.set(aID); GT_LanguageManager.addStringLocalization(getUnlocalizedName(rStack) + ".name", aEnglish); GT_LanguageManager.addStringLocalization(getUnlocalizedName(rStack) + ".tooltip", aToolTip); - List<TC_AspectStack> tAspects = new ArrayList<TC_AspectStack>(); + List<TC_AspectStack> tAspects = new ArrayList<>(); // Important Stuff to do first for (Object tRandomData : aRandomData) if (tRandomData instanceof SubTag) { if (tRandomData == SubTag.INVISIBLE) { @@ -351,7 +351,7 @@ public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item implements @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item aItem, CreativeTabs aCreativeTab, List aList) { + public void getSubItems(Item aItem, CreativeTabs aCreativeTab, List<ItemStack> aList) { int j = mEnabledItems.length(); for (int i = 0; i < j; i++) if (mVisibleItems.get(i) || (D1 && mEnabledItems.get(i))) { Long[] tStats = mElectricStats.get((short) (mOffset + i)); diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X01.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X01.java index 6615c6177b..f32c326afa 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X01.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X01.java @@ -164,7 +164,7 @@ public abstract class GT_MetaGenerated_Item_X01 extends GT_MetaGenerated_Item { @Override @SideOnly(Side.CLIENT) - public final void getSubItems(Item aItem, CreativeTabs aCreativeTab, List aList) { + public final void getSubItems(Item aItem, CreativeTabs aCreativeTab, List<ItemStack> aList) { for (int i = 0; i < GregTech_API.sGeneratedMaterials.length; i++) if (mPrefix.doGenerateItem(GregTech_API.sGeneratedMaterials[i]) && doesShowInCreative( mPrefix, diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java index a3c5814dbf..58368ba05b 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java @@ -185,7 +185,7 @@ public abstract class GT_MetaGenerated_Item_X32 extends GT_MetaGenerated_Item { @Override @SideOnly(Side.CLIENT) - public final void getSubItems(Item aItem, CreativeTabs aCreativeTab, List aList) { + public final void getSubItems(Item aItem, CreativeTabs aCreativeTab, List<ItemStack> aList) { for (int i = 0; i < 32000; i++) { OrePrefixes aPrefix = mGeneratedPrefixList[i / 1000]; Materials aMaterial = GregTech_API.sGeneratedMaterials[i % 1000]; diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java index 592914a2ff..5243a7bb07 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java @@ -81,11 +81,11 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item * <p/> * You can also use the unlocalized Name gotten from getUnlocalizedName() as Key if you want to get a specific Item. */ - public static final ConcurrentHashMap<String, GT_MetaGenerated_Tool> sInstances = new ConcurrentHashMap<String, GT_MetaGenerated_Tool>(); + public static final ConcurrentHashMap<String, GT_MetaGenerated_Tool> sInstances = new ConcurrentHashMap<>(); /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ - public final ConcurrentHashMap<Short, IToolStats> mToolStats = new ConcurrentHashMap<Short, IToolStats>(); + public final ConcurrentHashMap<Short, IToolStats> mToolStats = new ConcurrentHashMap<>(); /** * Creates the Item using these Parameters. @@ -180,7 +180,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item mToolStats.put((short) (aID + 1), aToolStats); aToolStats.onStatsAddedToTool(this, aID); ItemStack rStack = new ItemStack(this, 1, aID); - List<TC_AspectStack> tAspects = new ArrayList<TC_AspectStack>(); + List<TC_AspectStack> tAspects = new ArrayList<>(); for (Object tOreDictNameOrAspect : aOreDictNamesAndAspects) { if (tOreDictNameOrAspect instanceof TC_AspectStack) ((TC_AspectStack) tOreDictNameOrAspect).addToAspectList(tAspects); @@ -271,8 +271,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item } IToolStats tStats = getToolStats(aStack); Block aBlock = aPlayer.worldObj.getBlock(aX, aY, aZ); - if (tStats.isChainsaw() && (aBlock instanceof IShearable)) { - IShearable target = (IShearable) aBlock; + if (tStats.isChainsaw() && (aBlock instanceof IShearable target)) { if ((target.isShearable(aStack, aPlayer.worldObj, aX, aY, aZ))) { ArrayList<ItemStack> drops = target.onSheared( aStack, @@ -385,7 +384,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item @Override @SideOnly(Side.CLIENT) - public final void getSubItems(Item aItem, CreativeTabs aCreativeTab, List aList) { + public final void getSubItems(Item aItem, CreativeTabs aCreativeTab, List<ItemStack> aList) { for (int i = 0; i < 32766; i += 2) { if (getToolStats(new ItemStack(this, 1, i)) != null) { ItemStack tStack = new ItemStack(this, 1, i); diff --git a/src/main/java/gregtech/api/items/GT_RadioactiveCellIC_Item.java b/src/main/java/gregtech/api/items/GT_RadioactiveCellIC_Item.java index da7a6bc984..617e02cfe6 100644 --- a/src/main/java/gregtech/api/items/GT_RadioactiveCellIC_Item.java +++ b/src/main/java/gregtech/api/items/GT_RadioactiveCellIC_Item.java @@ -101,11 +101,11 @@ public class GT_RadioactiveCellIC_Item extends GT_RadioactiveCell_Item implement int dheat = heat / heatAcceptors.size(); heat -= dheat; - dheat = ((IReactorComponent) ((ItemStackCoord) heatAcceptors.get(0)).stack.getItem()).alterHeat( + dheat = ((IReactorComponent) heatAcceptors.get(0).stack.getItem()).alterHeat( reactor, - ((ItemStackCoord) heatAcceptors.get(0)).stack, - ((ItemStackCoord) heatAcceptors.get(0)).x, - ((ItemStackCoord) heatAcceptors.get(0)).y, + heatAcceptors.get(0).stack, + heatAcceptors.get(0).x, + heatAcceptors.get(0).y, dheat); heat += dheat; heatAcceptors.remove(0); @@ -149,7 +149,7 @@ public class GT_RadioactiveCellIC_Item extends GT_RadioactiveCell_Item implement float ReaktorOutput = 1.5F * breedereffectiveness + 1.0F; reactor.addOutput(ReaktorOutput * this.sEnergy); } else { - reactor.addOutput((float) (1.0F * this.sEnergy)); + reactor.addOutput(1.0F * this.sEnergy); } } return true; @@ -182,15 +182,14 @@ public class GT_RadioactiveCellIC_Item extends GT_RadioactiveCell_Item implement @Override public void onUpdate(ItemStack stack, World world, Entity entity, int slotIndex, boolean isCurrentItem) { - if (this.sRadiation > 0 && (entity instanceof EntityLivingBase)) { - EntityLivingBase entityLiving = (EntityLivingBase) entity; + if (this.sRadiation > 0 && (entity instanceof EntityLivingBase entityLiving)) { if (!GregTech_API.mIC2Classic && !GT_Utility.isWearingFullRadioHazmat(entityLiving)) { IC2Potion.radiation.applyTo(entityLiving, sRadiation * 20, sRadiation * 10); } } } - private class ItemStackCoord { + private static class ItemStackCoord { public ItemStack stack; public int x; diff --git a/src/main/java/gregtech/api/items/GT_RadioactiveCell_Item.java b/src/main/java/gregtech/api/items/GT_RadioactiveCell_Item.java index 4ec9ce1990..34492b6220 100644 --- a/src/main/java/gregtech/api/items/GT_RadioactiveCell_Item.java +++ b/src/main/java/gregtech/api/items/GT_RadioactiveCell_Item.java @@ -138,21 +138,11 @@ public class GT_RadioactiveCell_Item extends GT_Generic_Item implements IBoxable super.addAdditionalToolTips(aList, aStack, aPlayer); // aList.add("Time left: " + (this.maxDelay - getDurabilityOfStack(aStack)) + " secs"); int rDmg = getDurabilityOfStack(aStack) * 6 / this.maxDmg; - EnumChatFormatting color2; - switch (rDmg) { - case 0: - case 1: - color2 = EnumChatFormatting.WHITE; - break; - case 2: - case 3: - case 4: - color2 = EnumChatFormatting.GRAY; - break; - default: - color2 = EnumChatFormatting.DARK_GRAY; - break; - } + EnumChatFormatting color2 = switch (rDmg) { + case 0, 1 -> EnumChatFormatting.WHITE; + case 2, 3, 4 -> EnumChatFormatting.GRAY; + default -> EnumChatFormatting.DARK_GRAY; + }; EnumChatFormatting color1 = this instanceof GT_DepletetCell_Item ? color2 = EnumChatFormatting.DARK_GRAY : EnumChatFormatting.WHITE; aList.add( diff --git a/src/main/java/gregtech/api/items/GT_SolderingTool_Item.java b/src/main/java/gregtech/api/items/GT_SolderingTool_Item.java index 41581b94f8..8d8db6a52a 100644 --- a/src/main/java/gregtech/api/items/GT_SolderingTool_Item.java +++ b/src/main/java/gregtech/api/items/GT_SolderingTool_Item.java @@ -50,9 +50,6 @@ public class GT_SolderingTool_Item extends GT_Tool_Item { public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { super.onItemUseFirst(aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ); - if (aWorld.isRemote) { - return false; - } return false; } } diff --git a/src/main/java/gregtech/api/items/GT_Spray_Foam_Item.java b/src/main/java/gregtech/api/items/GT_Spray_Foam_Item.java index aa64476105..fcd291fa01 100644 --- a/src/main/java/gregtech/api/items/GT_Spray_Foam_Item.java +++ b/src/main/java/gregtech/api/items/GT_Spray_Foam_Item.java @@ -96,31 +96,24 @@ public class GT_Spray_Foam_Item extends GT_Tool_Item { } else if (tRotationPitch <= -65) { tSide = 0; } else { - switch (MathHelper.floor_double((aPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) { - case 0: - tSide = 2; - break; - case 1: - tSide = 5; - break; - case 2: - tSide = 3; - break; - case 3: - tSide = 4; - break; - } + tSide = switch (MathHelper.floor_double((aPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) { + case 0 -> 2; + case 1 -> 5; + case 2 -> 3; + case 3 -> 4; + default -> tSide; + }; } switch (0) { - case 0: + case 0 -> { if (GT_Utility.isBlockAir(aWorld, aX, aY, aZ) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) { GT_Utility.sendSoundToPlayers(aWorld, SoundResource.IC2_TOOLS_PAINTER, 1.0F, -1, aX, aY, aZ); aWorld.setBlock(aX, aY, aZ, GT_Utility.getBlockFromStack(tStack), tStack.getItemDamage(), 3); return true; } - break; - case 1: + } + case 1 -> { for (byte i = 0; i < 4; i++) { if (GT_Utility.isBlockAir(aWorld, aX, aY, aZ) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) { @@ -148,15 +141,14 @@ public class GT_Spray_Foam_Item extends GT_Tool_Item { aZ -= ForgeDirection.getOrientation(tSide).offsetZ; } return true; - case 2: + } + case 2 -> { boolean temp = false, tXFactor = (ForgeDirection.getOrientation(tSide).offsetX == 0), tYFactor = (ForgeDirection.getOrientation(tSide).offsetY == 0), tZFactor = (ForgeDirection.getOrientation(tSide).offsetZ == 0); - aX -= (tXFactor ? 1 : 0); aY -= (tYFactor ? 1 : 0); aZ -= (tZFactor ? 1 : 0); - for (byte i = 0; i < 3; i++) for (byte j = 0; j < 3; j++) { if (GT_Utility.isBlockAir( aWorld, @@ -186,6 +178,7 @@ public class GT_Spray_Foam_Item extends GT_Tool_Item { } } return temp; + } } } return false; diff --git a/src/main/java/gregtech/api/items/GT_Spray_Pepper_Item.java b/src/main/java/gregtech/api/items/GT_Spray_Pepper_Item.java index 7d863c3e89..e4e03083f5 100644 --- a/src/main/java/gregtech/api/items/GT_Spray_Pepper_Item.java +++ b/src/main/java/gregtech/api/items/GT_Spray_Pepper_Item.java @@ -56,7 +56,6 @@ public class GT_Spray_Pepper_Item extends GT_Tool_Item { return false; } Block aBlock = aWorld.getBlock(aX, aY, aZ); - if (aBlock == null) return false; // byte aMeta = (byte)aWorld.getBlockMetadata(aX, aY, aZ); // TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index e1a83f5cc6..0bc1201827 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -346,36 +346,34 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity if (isClientSide()) { issueTextureUpdate(); switch (aEventID) { - case GregTechTileClientEvents.CHANGE_COMMON_DATA: - mConnections = (byte) aValue; - break; - case GregTechTileClientEvents.CHANGE_CUSTOM_DATA: + case GregTechTileClientEvents.CHANGE_COMMON_DATA -> mConnections = (byte) aValue; + case GregTechTileClientEvents.CHANGE_CUSTOM_DATA -> { if (hasValidMetaTileEntity()) mMetaTileEntity.onValueUpdate((byte) aValue); - break; - case GregTechTileClientEvents.CHANGE_COLOR: + } + case GregTechTileClientEvents.CHANGE_COLOR -> { if (aValue > 16 || aValue < 0) aValue = 0; mColor = (byte) aValue; - break; - case GregTechTileClientEvents.CHANGE_REDSTONE_OUTPUT: + } + case GregTechTileClientEvents.CHANGE_REDSTONE_OUTPUT -> { mSidedRedstone[0] = (byte) ((aValue & 1) == 1 ? 15 : 0); mSidedRedstone[1] = (byte) ((aValue & 2) == 2 ? 15 : 0); mSidedRedstone[2] = (byte) ((aValue & 4) == 4 ? 15 : 0); mSidedRedstone[3] = (byte) ((aValue & 8) == 8 ? 15 : 0); mSidedRedstone[4] = (byte) ((aValue & 16) == 16 ? 15 : 0); mSidedRedstone[5] = (byte) ((aValue & 32) == 32 ? 15 : 0); - break; - case GregTechTileClientEvents.DO_SOUND: + } + case GregTechTileClientEvents.DO_SOUND -> { if (hasValidMetaTileEntity() && mTickTimer > 20) mMetaTileEntity.doSound((byte) aValue, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); - break; - case GregTechTileClientEvents.START_SOUND_LOOP: + } + case GregTechTileClientEvents.START_SOUND_LOOP -> { if (hasValidMetaTileEntity() && mTickTimer > 20) mMetaTileEntity.startSoundLoop((byte) aValue, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); - break; - case GregTechTileClientEvents.STOP_SOUND_LOOP: + } + case GregTechTileClientEvents.STOP_SOUND_LOOP -> { if (hasValidMetaTileEntity() && mTickTimer > 20) mMetaTileEntity.stopSoundLoop((byte) aValue, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); - break; + } } } return true; diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 00e31ed9a0..0f908bdaa3 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -728,48 +728,46 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec if (isClientSide()) { issueTextureUpdate(); switch (aEventID) { - case GregTechTileClientEvents.CHANGE_COMMON_DATA: + case GregTechTileClientEvents.CHANGE_COMMON_DATA -> { mFacing = (byte) (aValue & 7); mActive = ((aValue & 8) != 0); mRedstone = ((aValue & 16) != 0); // mLockUpgrade = ((aValue&32) != 0); mWorks = ((aValue & 64) != 0); - break; - case GregTechTileClientEvents.CHANGE_CUSTOM_DATA: + } + case GregTechTileClientEvents.CHANGE_CUSTOM_DATA -> { if (hasValidMetaTileEntity()) { if ((aValue & 0x80) == 0) // Is texture index mMetaTileEntity.onValueUpdate((byte) (aValue & 0x7F)); else if (mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) // is texture page and hatch ((GT_MetaTileEntity_Hatch) mMetaTileEntity).onTexturePageUpdate((byte) (aValue & 0x7F)); } - break; - case GregTechTileClientEvents.CHANGE_COLOR: + } + case GregTechTileClientEvents.CHANGE_COLOR -> { if (aValue > 16 || aValue < 0) aValue = 0; mColor = (byte) aValue; - break; - case GregTechTileClientEvents.CHANGE_REDSTONE_OUTPUT: + } + case GregTechTileClientEvents.CHANGE_REDSTONE_OUTPUT -> { mSidedRedstone[0] = (byte) ((aValue & 1) == 1 ? 15 : 0); mSidedRedstone[1] = (byte) ((aValue & 2) == 2 ? 15 : 0); mSidedRedstone[2] = (byte) ((aValue & 4) == 4 ? 15 : 0); mSidedRedstone[3] = (byte) ((aValue & 8) == 8 ? 15 : 0); mSidedRedstone[4] = (byte) ((aValue & 16) == 16 ? 15 : 0); mSidedRedstone[5] = (byte) ((aValue & 32) == 32 ? 15 : 0); - break; - case GregTechTileClientEvents.DO_SOUND: + } + case GregTechTileClientEvents.DO_SOUND -> { if (hasValidMetaTileEntity() && mTickTimer > 20) mMetaTileEntity.doSound((byte) aValue, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); - break; - case GregTechTileClientEvents.START_SOUND_LOOP: + } + case GregTechTileClientEvents.START_SOUND_LOOP -> { if (hasValidMetaTileEntity() && mTickTimer > 20) mMetaTileEntity.startSoundLoop((byte) aValue, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); - break; - case GregTechTileClientEvents.STOP_SOUND_LOOP: + } + case GregTechTileClientEvents.STOP_SOUND_LOOP -> { if (hasValidMetaTileEntity() && mTickTimer > 20) mMetaTileEntity.stopSoundLoop((byte) aValue, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); - break; - case GregTechTileClientEvents.CHANGE_LIGHT: - mLightValue = (byte) aValue; - break; + } + case GregTechTileClientEvents.CHANGE_LIGHT -> mLightValue = (byte) aValue; } } return true; diff --git a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java index 238dc6ba30..3ef732b1c8 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java @@ -861,8 +861,7 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje final ItemStackHandler inventoryHandler = getInventoryHandler(); if (inventoryHandler == null) return; - if (!(this instanceof IInventory)) return; - final IInventory inv = (IInventory) this; + if (!(this instanceof IInventory inv)) return; final IConfigurationCircuitSupport ccs = getConfigurationCircuitSupport(); if (ccs == null) return; @@ -937,8 +936,7 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje final IConfigurationCircuitSupport ccs = getConfigurationCircuitSupport(); if (ccs == null) return; - if (!(this instanceof IInventory)) return; - final IInventory inv = (IInventory) this; + if (!(this instanceof IInventory inv)) return; final List<ItemStack> circuits = ccs.getConfigurationCircuits(); uiContext.openClientWindow( @@ -965,8 +963,7 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje final IConfigurationCircuitSupport ccs = getConfigurationCircuitSupport(); if (ccs == null) return; - if (!(this instanceof IInventory)) return; - final IInventory inv = (IInventory) this; + if (!(this instanceof IInventory inv)) return; GT_Values.NW.sendToServer(new GT_Packet_SetConfigurationCircuit(this, selected)); // we will not do any validation on client side diff --git a/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java b/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java index f2929e7e1e..4167bf1701 100644 --- a/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java @@ -702,18 +702,17 @@ public abstract class CoverableTileEntity extends BaseTileEntity implements ICov .setSize(COVER_TAB_WIDTH, COVER_TAB_HEIGHT)) .addChild( new ItemDrawable( - () -> { return getCoverItemAtSide(side); }) - .asWidget() - .setPos( - (COVER_TAB_WIDTH - - ICON_SIZE) - / 2 - + (flipHorizontally - ? -1 - : 1), - (COVER_TAB_HEIGHT - - ICON_SIZE) - / 2)) + () -> getCoverItemAtSide(side)).asWidget() + .setPos( + (COVER_TAB_WIDTH + - ICON_SIZE) + / 2 + + (flipHorizontally + ? -1 + : 1), + (COVER_TAB_HEIGHT + - ICON_SIZE) + / 2)) .setEnabled(widget -> getCoverItemAtSide(side) != null)); } } diff --git a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java index cf1cb5dc1b..a42525ae45 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java @@ -1,7 +1,6 @@ package gregtech.api.metatileentity; import static gregtech.api.enums.GT_Values.GT; -import static gregtech.api.enums.GT_Values.V; import java.io.File; import java.util.ArrayList; @@ -33,6 +32,7 @@ import gnu.trove.list.TIntList; import gnu.trove.list.array.TIntArrayList; import gregtech.api.GregTech_API; import gregtech.api.enums.Dyes; +import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.metatileentity.IConnectable; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IColoredTileEntity; @@ -115,7 +115,7 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { ItemStack tStack = new ItemStack(GregTech_API.sBlockMachines, 1, aID); tStack.getItem() - .addInformation(tStack, null, new ArrayList<String>(), true); + .addInformation(tStack, null, new ArrayList<>(), true); } /** @@ -754,36 +754,7 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { @Override public void doExplosion(long aExplosionPower) { - 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(aExplosionPower); int tX = getBaseMetaTileEntity().getXCoord(), tY = getBaseMetaTileEntity().getYCoord(), tZ = getBaseMetaTileEntity().getZCoord(); World tWorld = getBaseMetaTileEntity().getWorld(); diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java index a017fca2e0..c929bd5677 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java @@ -1,7 +1,5 @@ package gregtech.api.metatileentity; -import static gregtech.api.enums.GT_Values.V; - import java.io.File; import java.util.ArrayList; import java.util.List; @@ -45,6 +43,7 @@ import gnu.trove.list.TIntList; import gnu.trove.list.array.TIntArrayList; import gregtech.api.GregTech_API; import gregtech.api.enums.Dyes; +import gregtech.api.enums.GT_Values; import gregtech.api.enums.SoundResource; import gregtech.api.enums.SteamVariant; import gregtech.api.gui.GT_GUIColorOverride; @@ -846,8 +845,7 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac @Override public void setInventorySlotContents(int aIndex, ItemStack aStack) { markDirty(); - if (this instanceof IConfigurationCircuitSupport) { - IConfigurationCircuitSupport ccs = (IConfigurationCircuitSupport) this; + if (this instanceof IConfigurationCircuitSupport ccs) { if (ccs.allowSelectCircuit() && aIndex == ccs.getCircuitSlot() && aStack != null) { mInventory[aIndex] = GT_Utility.copyAmount(0, aStack); return; @@ -1090,28 +1088,7 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac @Override public void doExplosion(long aExplosionPower) { - // spotless:off - 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; - // spotless:on + float tStrength = GT_Values.getExplosionPowerForVoltage(aExplosionPower); final int tX = getBaseMetaTileEntity().getXCoord(); final int tY = getBaseMetaTileEntity().getYCoord(); final int tZ = getBaseMetaTileEntity().getZCoord(); @@ -1201,9 +1178,8 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac ForgeDirection.getOrientation(mBaseMetaTileEntity.getFrontFacing()) .name())); - if (this instanceof IPowerChannelState) { + if (this instanceof IPowerChannelState state) { // adapted from PowerStateWailaDataProvider - final IPowerChannelState state = (IPowerChannelState) this; NBTTagCompound tag = accessor.getNBTData(); final boolean isActive = tag.getBoolean("isActive"); final boolean isPowered = tag.getBoolean("isPowered"); @@ -1224,9 +1200,8 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac @Override public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y, int z) { - if (this instanceof IPowerChannelState) { + if (this instanceof IPowerChannelState state) { // adapted from PowerStateWailaDataProvider - final IPowerChannelState state = (IPowerChannelState) this; final boolean isActive = state.isActive(); final boolean isPowered = state.isPowered(); final boolean isBooting = state.isBooting(); diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java index 790d4d6c1f..2a1ec3c22c 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java @@ -223,8 +223,7 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile public long transferElectricity(byte aSide, long aVoltage, long aAmperage, HashSet<TileEntity> aAlreadyPassedSet) { if (!getBaseMetaTileEntity().isServerSide() || !isConnectedAtSide(aSide) && aSide != 6) return 0; final BaseMetaPipeEntity tBase = (BaseMetaPipeEntity) getBaseMetaTileEntity(); - if (!(tBase.getNode() instanceof PowerNode)) return 0; - final PowerNode tNode = (PowerNode) tBase.getNode(); + if (!(tBase.getNode() instanceof PowerNode tNode)) return 0; if (tNode != null) { int tPlace = 0; final Node[] tToPower = new Node[tNode.mConsumers.size()]; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java index a3e44640e8..b428d187d7 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java @@ -159,40 +159,24 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { } protected static ITexture getRestrictorTexture(byte aMask) { - switch (aMask) { - case 1: - return TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_UP); - case 2: - return TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_DOWN); - case 3: - return TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_UD); - case 4: - return TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_LEFT); - case 5: - return TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_UL); - case 6: - return TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_DL); - case 7: - return TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_NR); - case 8: - return TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_RIGHT); - case 9: - return TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_UR); - case 10: - return TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_DR); - case 11: - return TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_NL); - case 12: - return TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_LR); - case 13: - return TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_ND); - case 14: - return TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_NU); - case 15: - return TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR); - default: - return null; - } + return switch (aMask) { + case 1 -> TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_UP); + case 2 -> TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_DOWN); + case 3 -> TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_UD); + case 4 -> TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_LEFT); + case 5 -> TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_UL); + case 6 -> TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_DL); + case 7 -> TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_NR); + case 8 -> TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_RIGHT); + case 9 -> TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_UR); + case 10 -> TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_DR); + case 11 -> TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_NL); + case 12 -> TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_LR); + case 13 -> TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_ND); + case 14 -> TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_NU); + case 15 -> TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR); + default -> null; + }; } @Override @@ -349,22 +333,22 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { sendSound((byte) 9); if (tTemperature > 320) { try { - for (EntityLivingBase tLiving : (ArrayList<EntityLivingBase>) getBaseMetaTileEntity().getWorld() - .getEntitiesWithinAABB( - EntityLivingBase.class, - AxisAlignedBB.getBoundingBox( - getBaseMetaTileEntity().getXCoord() - - 2, - getBaseMetaTileEntity().getYCoord() - - 2, - getBaseMetaTileEntity().getZCoord() - - 2, - getBaseMetaTileEntity().getXCoord() - + 3, - getBaseMetaTileEntity().getYCoord() - + 3, - getBaseMetaTileEntity().getZCoord() - + 3))) { + for (EntityLivingBase tLiving : getBaseMetaTileEntity().getWorld() + .getEntitiesWithinAABB( + EntityLivingBase.class, + AxisAlignedBB.getBoundingBox( + getBaseMetaTileEntity().getXCoord() + - 2, + getBaseMetaTileEntity().getYCoord() + - 2, + getBaseMetaTileEntity().getZCoord() + - 2, + getBaseMetaTileEntity().getXCoord() + + 3, + getBaseMetaTileEntity().getYCoord() + + 3, + getBaseMetaTileEntity().getZCoord() + + 3))) { GT_Utility.applyHeatDamage(tLiving, (tTemperature - 300) / 25.0F); } } catch (Throwable e) { @@ -372,22 +356,22 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { } } else if (tTemperature < 260) { try { - for (EntityLivingBase tLiving : (ArrayList<EntityLivingBase>) getBaseMetaTileEntity().getWorld() - .getEntitiesWithinAABB( - EntityLivingBase.class, - AxisAlignedBB.getBoundingBox( - getBaseMetaTileEntity().getXCoord() - - 2, - getBaseMetaTileEntity().getYCoord() - - 2, - getBaseMetaTileEntity().getZCoord() - - 2, - getBaseMetaTileEntity().getXCoord() - + 3, - getBaseMetaTileEntity().getYCoord() - + 3, - getBaseMetaTileEntity().getZCoord() - + 3))) { + for (EntityLivingBase tLiving : getBaseMetaTileEntity().getWorld() + .getEntitiesWithinAABB( + EntityLivingBase.class, + AxisAlignedBB.getBoundingBox( + getBaseMetaTileEntity().getXCoord() + - 2, + getBaseMetaTileEntity().getYCoord() + - 2, + getBaseMetaTileEntity().getZCoord() + - 2, + getBaseMetaTileEntity().getXCoord() + + 3, + getBaseMetaTileEntity().getYCoord() + + 3, + getBaseMetaTileEntity().getZCoord() + + 3))) { GT_Utility.applyFrostDamage(tLiving, (270 - tTemperature) / 12.5F); } } catch (Throwable e) { diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java index 7b2a4fa232..bae070f6dd 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java @@ -382,70 +382,62 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier @Override public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { switch (mInventory.length) { - case 4: - builder.widget( - SlotGroup.ofItemHandler(inventoryHandler, 2) - .startFromSlot(0) - .endAtSlot(3) - .slotCreator(index -> new BaseSlot(inventoryHandler, index) { - - @Override - public int getSlotStackLimit() { - return 1; - } - }) - .background(getGUITextureSet().getItemSlot()) - .build() - .setPos(70, 25)); - break; - case 9: - builder.widget( - SlotGroup.ofItemHandler(inventoryHandler, 3) - .startFromSlot(0) - .endAtSlot(8) - .slotCreator(index -> new BaseSlot(inventoryHandler, index) { - - @Override - public int getSlotStackLimit() { - return 1; - } - }) - .background(getGUITextureSet().getItemSlot()) - .build() - .setPos(61, 16)); - break; - case 16: - builder.widget( - SlotGroup.ofItemHandler(inventoryHandler, 4) - .startFromSlot(0) - .endAtSlot(15) - .slotCreator(index -> new BaseSlot(inventoryHandler, index) { - - @Override - public int getSlotStackLimit() { - return 1; - } - }) - .background(getGUITextureSet().getItemSlot()) - .build() - .setPos(52, 7)); - break; - default: - builder.widget( - SlotGroup.ofItemHandler(inventoryHandler, 1) - .startFromSlot(0) - .endAtSlot(0) - .slotCreator(index -> new BaseSlot(inventoryHandler, index) { - - @Override - public int getSlotStackLimit() { - return 1; - } - }) - .background(getGUITextureSet().getItemSlot()) - .build() - .setPos(79, 34)); - break; + case 4 -> builder.widget( + SlotGroup.ofItemHandler(inventoryHandler, 2) + .startFromSlot(0) + .endAtSlot(3) + .slotCreator(index -> new BaseSlot(inventoryHandler, index) { + + @Override + public int getSlotStackLimit() { + return 1; + } + }) + .background(getGUITextureSet().getItemSlot()) + .build() + .setPos(70, 25)); + case 9 -> builder.widget( + SlotGroup.ofItemHandler(inventoryHandler, 3) + .startFromSlot(0) + .endAtSlot(8) + .slotCreator(index -> new BaseSlot(inventoryHandler, index) { + + @Override + public int getSlotStackLimit() { + return 1; + } + }) + .background(getGUITextureSet().getItemSlot()) + .build() + .setPos(61, 16)); + case 16 -> builder.widget( + SlotGroup.ofItemHandler(inventoryHandler, 4) + .startFromSlot(0) + .endAtSlot(15) + .slotCreator(index -> new BaseSlot(inventoryHandler, index) { + + @Override + public int getSlotStackLimit() { + return 1; + } + }) + .background(getGUITextureSet().getItemSlot()) + .build() + .setPos(52, 7)); + default -> builder.widget( + SlotGroup.ofItemHandler(inventoryHandler, 1) + .startFromSlot(0) + .endAtSlot(0) + .slotCreator(index -> new BaseSlot(inventoryHandler, index) { + + @Override + public int getSlotStackLimit() { + return 1; + } + }) + .background(getGUITextureSet().getItemSlot()) + .build() + .setPos(79, 34)); } } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java index a71b94b916..182b25fb92 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java @@ -302,8 +302,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity public long getFuelValue(FluidStack aLiquid, boolean aLong) { GT_Recipe_Map tRecipes = getRecipes(); - if (aLiquid == null || !(tRecipes instanceof GT_Recipe.GT_Recipe_Map_Fuel)) return 0; - GT_Recipe.GT_Recipe_Map_Fuel tFuels = (GT_Recipe.GT_Recipe_Map_Fuel) tRecipes; + if (aLiquid == null || !(tRecipes instanceof GT_Recipe.GT_Recipe_Map_Fuel tFuels)) return 0; GT_Recipe tFuel = tFuels.findFuel(aLiquid); if (tFuel == null) return 0; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java index 78fc68ee81..49b76b1579 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java @@ -237,14 +237,37 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return mTextures[mMainFacing < 2 - ? aSide == aFacing ? aActive ? 2 : 3 - : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1 - : aSide == mMainFacing ? aActive ? 2 : 3 - : (showPipeFacing() && aSide == aFacing) - ? aSide == 0 ? aActive ? 8 : 9 : aSide == 1 ? aActive ? 10 : 11 : aActive ? 12 : 13 - : aSide == 0 ? aActive ? 6 : 7 - : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1][aColorIndex + 1]; + final int textureIndex; + if (mMainFacing < 2) { + if (aSide == aFacing) { + textureIndex = aActive ? 2 : 3; + } else { + textureIndex = switch (aSide) { + case 0 -> aActive ? 6 : 7; + case 1 -> aActive ? 4 : 5; + default -> aActive ? 0 : 1; + }; + } + } else { + if (aSide == mMainFacing) { + textureIndex = aActive ? 2 : 3; + } else { + if (showPipeFacing() && aSide == aFacing) { + textureIndex = switch (aSide) { + case 0 -> aActive ? 8 : 9; + case 1 -> aActive ? 10 : 11; + default -> aActive ? 12 : 13; + }; + } else { + textureIndex = switch (aSide) { + case 0 -> aActive ? 6 : 7; + case 1 -> aActive ? 4 : 5; + default -> aActive ? 0 : 1; + }; + } + } + } + return mTextures[textureIndex][aColorIndex + 1]; } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java index 934554dfbc..d2433e04e6 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java @@ -4,8 +4,6 @@ import static gregtech.api.enums.GT_Values.D1; import static gregtech.api.enums.Textures.BlockIcons.*; import static gregtech.api.objects.XSTR.XSTR_INSTANCE; -import java.util.ArrayList; - import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; @@ -173,31 +171,28 @@ public abstract class GT_MetaTileEntity_BasicMachine_Bronze extends GT_MetaTileE sendSound((byte) 9); mNeedsSteamVenting = false; try { - for (EntityLivingBase tLiving : (ArrayList<EntityLivingBase>) getBaseMetaTileEntity().getWorld() - .getEntitiesWithinAABB( - EntityLivingBase.class, - AxisAlignedBB.getBoundingBox( - getBaseMetaTileEntity().getOffsetX( - getBaseMetaTileEntity().getFrontFacing(), - 1), - getBaseMetaTileEntity().getOffsetY( - getBaseMetaTileEntity().getFrontFacing(), - 1), - getBaseMetaTileEntity().getOffsetZ( - getBaseMetaTileEntity().getFrontFacing(), - 1), - getBaseMetaTileEntity().getOffsetX( - getBaseMetaTileEntity().getFrontFacing(), - 1) - + 1, - getBaseMetaTileEntity().getOffsetY( - getBaseMetaTileEntity().getFrontFacing(), - 1) - + 1, - getBaseMetaTileEntity().getOffsetZ( - getBaseMetaTileEntity().getFrontFacing(), - 1) - + 1))) { + for (EntityLivingBase tLiving : getBaseMetaTileEntity().getWorld() + .getEntitiesWithinAABB( + EntityLivingBase.class, + AxisAlignedBB.getBoundingBox( + getBaseMetaTileEntity().getOffsetX( + getBaseMetaTileEntity().getFrontFacing(), + 1), + getBaseMetaTileEntity().getOffsetY( + getBaseMetaTileEntity().getFrontFacing(), + 1), + getBaseMetaTileEntity().getOffsetZ( + getBaseMetaTileEntity().getFrontFacing(), + 1), + getBaseMetaTileEntity().getOffsetX( + getBaseMetaTileEntity().getFrontFacing(), + 1) + 1, + getBaseMetaTileEntity().getOffsetY( + getBaseMetaTileEntity().getFrontFacing(), + 1) + 1, + getBaseMetaTileEntity().getOffsetZ( + getBaseMetaTileEntity().getFrontFacing(), + 1) + 1))) { GT_Utility.applyHeatDamage(tLiving, getSteamDamage()); } } catch (Throwable e) { diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java index 5331f67dca..bc756fa6a5 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java @@ -40,7 +40,6 @@ import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gregtech.api.util.WorldSpawnedEventBuilder; import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder; import ic2.core.Ic2Items; @@ -231,673 +230,284 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PLATE) { switch (this.mTier) { - case 0: - case 1: - aRecipe[i] = OrePrefixes.plate.get(Materials.Steel); - break; - case 2: - aRecipe[i] = OrePrefixes.plate.get(Materials.Aluminium); - break; - case 3: - aRecipe[i] = OrePrefixes.plate.get(Materials.StainlessSteel); - break; - case 4: - aRecipe[i] = OrePrefixes.plate.get(Materials.Titanium); - break; - case 5: - aRecipe[i] = OrePrefixes.plate.get(Materials.TungstenSteel); - break; - case 6: - aRecipe[i] = OrePrefixes.plate.get(Materials.HSSG); - break; - case 7: - aRecipe[i] = OrePrefixes.plate.get(Materials.HSSE); - break; - default: - aRecipe[i] = OrePrefixes.plate.get(Materials.Neutronium); - break; + case 0, 1 -> aRecipe[i] = OrePrefixes.plate.get(Materials.Steel); + case 2 -> aRecipe[i] = OrePrefixes.plate.get(Materials.Aluminium); + case 3 -> aRecipe[i] = OrePrefixes.plate.get(Materials.StainlessSteel); + case 4 -> aRecipe[i] = OrePrefixes.plate.get(Materials.Titanium); + case 5 -> aRecipe[i] = OrePrefixes.plate.get(Materials.TungstenSteel); + case 6 -> aRecipe[i] = OrePrefixes.plate.get(Materials.HSSG); + case 7 -> aRecipe[i] = OrePrefixes.plate.get(Materials.HSSE); + default -> aRecipe[i] = OrePrefixes.plate.get(Materials.Neutronium); } continue; } if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PIPE) { switch (this.mTier) { - case 0: - case 1: - aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.Bronze); - break; - case 2: - aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.Steel); - break; - case 3: - aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.StainlessSteel); - break; - case 4: - aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.Titanium); - break; - case 5: - aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.TungstenSteel); - break; - case 6: - aRecipe[i] = OrePrefixes.pipeSmall.get(Materials.Ultimate); - break; - case 7: - aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.Ultimate); - break; - case 8: - aRecipe[i] = OrePrefixes.pipeLarge.get(Materials.Ultimate); - break; - default: - aRecipe[i] = OrePrefixes.pipeHuge.get(Materials.Ultimate); - break; + case 0, 1 -> aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.Bronze); + case 2 -> aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.Steel); + case 3 -> aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.StainlessSteel); + case 4 -> aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.Titanium); + case 5 -> aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.TungstenSteel); + case 6 -> aRecipe[i] = OrePrefixes.pipeSmall.get(Materials.Ultimate); + case 7 -> aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.Ultimate); + case 8 -> aRecipe[i] = OrePrefixes.pipeLarge.get(Materials.Ultimate); + default -> aRecipe[i] = OrePrefixes.pipeHuge.get(Materials.Ultimate); } continue; } if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.COIL_HEATING) { switch (this.mTier) { - case 0: - case 1: - aRecipe[i] = OrePrefixes.wireGt02.get(Materials.AnyCopper); - break; - case 2: - aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Cupronickel); - break; - case 3: - aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Kanthal); - break; - case 4: - aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Nichrome); - break; - case 5: - aRecipe[i] = OrePrefixes.wireGt02.get(Materials.TPV); - break; - case 6: - aRecipe[i] = OrePrefixes.wireGt02.get(Materials.HSSG); - break; - case 7: - aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Naquadah); - break; - case 8: - aRecipe[i] = OrePrefixes.wireGt02.get(Materials.NaquadahAlloy); - break; - case 9: - aRecipe[i] = OrePrefixes.wireGt04.get(Materials.NaquadahAlloy); - break; - default: - aRecipe[i] = OrePrefixes.wireGt08.get(Materials.NaquadahAlloy); - break; + case 0, 1 -> aRecipe[i] = OrePrefixes.wireGt02.get(Materials.AnyCopper); + case 2 -> aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Cupronickel); + case 3 -> aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Kanthal); + case 4 -> aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Nichrome); + case 5 -> aRecipe[i] = OrePrefixes.wireGt02.get(Materials.TPV); + case 6 -> aRecipe[i] = OrePrefixes.wireGt02.get(Materials.HSSG); + case 7 -> aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Naquadah); + case 8 -> aRecipe[i] = OrePrefixes.wireGt02.get(Materials.NaquadahAlloy); + case 9 -> aRecipe[i] = OrePrefixes.wireGt04.get(Materials.NaquadahAlloy); + default -> aRecipe[i] = OrePrefixes.wireGt08.get(Materials.NaquadahAlloy); } continue; } if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.COIL_HEATING_DOUBLE) { switch (this.mTier) { - case 0: - case 1: - aRecipe[i] = OrePrefixes.wireGt04.get(Materials.AnyCopper); - break; - case 2: - aRecipe[i] = OrePrefixes.wireGt04.get(Materials.Cupronickel); - break; - case 3: - aRecipe[i] = OrePrefixes.wireGt04.get(Materials.Kanthal); - break; - case 4: - aRecipe[i] = OrePrefixes.wireGt04.get(Materials.Nichrome); - break; - case 5: - aRecipe[i] = OrePrefixes.wireGt04.get(Materials.TPV); - break; - case 6: - aRecipe[i] = OrePrefixes.wireGt04.get(Materials.HSSG); - break; - case 7: - aRecipe[i] = OrePrefixes.wireGt04.get(Materials.Naquadah); - break; - case 8: - aRecipe[i] = OrePrefixes.wireGt04.get(Materials.NaquadahAlloy); - break; - case 9: - aRecipe[i] = OrePrefixes.wireGt08.get(Materials.NaquadahAlloy); - break; - default: - aRecipe[i] = OrePrefixes.wireGt16.get(Materials.NaquadahAlloy); - break; + case 0, 1 -> aRecipe[i] = OrePrefixes.wireGt04.get(Materials.AnyCopper); + case 2 -> aRecipe[i] = OrePrefixes.wireGt04.get(Materials.Cupronickel); + case 3 -> aRecipe[i] = OrePrefixes.wireGt04.get(Materials.Kanthal); + case 4 -> aRecipe[i] = OrePrefixes.wireGt04.get(Materials.Nichrome); + case 5 -> aRecipe[i] = OrePrefixes.wireGt04.get(Materials.TPV); + case 6 -> aRecipe[i] = OrePrefixes.wireGt04.get(Materials.HSSG); + case 7 -> aRecipe[i] = OrePrefixes.wireGt04.get(Materials.Naquadah); + case 8 -> aRecipe[i] = OrePrefixes.wireGt04.get(Materials.NaquadahAlloy); + case 9 -> aRecipe[i] = OrePrefixes.wireGt08.get(Materials.NaquadahAlloy); + default -> aRecipe[i] = OrePrefixes.wireGt16.get(Materials.NaquadahAlloy); } continue; } if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.STICK_DISTILLATION) { - switch (this.mTier) { - default: - aRecipe[i] = OrePrefixes.stick.get(Materials.Blaze); - break; - } + aRecipe[i] = OrePrefixes.stick.get(Materials.Blaze); continue; } if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.STICK_MAGNETIC) { switch (this.mTier) { - case 0: - case 1: - aRecipe[i] = OrePrefixes.stick.get(Materials.IronMagnetic); - break; - case 2: - case 3: - aRecipe[i] = OrePrefixes.stick.get(Materials.SteelMagnetic); - break; - case 4: - case 5: - aRecipe[i] = OrePrefixes.stick.get(Materials.NeodymiumMagnetic); - break; - case 6: - case 7: - aRecipe[i] = OrePrefixes.stick.get(Materials.SamariumMagnetic); - break; - default: - aRecipe[i] = OrePrefixes.stickLong.get(Materials.SamariumMagnetic); - break; + case 0, 1 -> aRecipe[i] = OrePrefixes.stick.get(Materials.IronMagnetic); + case 2, 3 -> aRecipe[i] = OrePrefixes.stick.get(Materials.SteelMagnetic); + case 4, 5 -> aRecipe[i] = OrePrefixes.stick.get(Materials.NeodymiumMagnetic); + case 6, 7 -> aRecipe[i] = OrePrefixes.stick.get(Materials.SamariumMagnetic); + default -> aRecipe[i] = OrePrefixes.stickLong.get(Materials.SamariumMagnetic); } continue; } if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.STICK_ELECTROMAGNETIC) { switch (this.mTier) { - case 0: - case 1: - aRecipe[i] = OrePrefixes.stick.get(Materials.AnyIron); - break; - case 2: - case 3: - aRecipe[i] = OrePrefixes.stick.get(Materials.Steel); - break; - case 4: - aRecipe[i] = OrePrefixes.stick.get(Materials.Neodymium); - break; - default: - aRecipe[i] = OrePrefixes.stick.get(Materials.VanadiumGallium); - break; + case 0, 1 -> aRecipe[i] = OrePrefixes.stick.get(Materials.AnyIron); + case 2, 3 -> aRecipe[i] = OrePrefixes.stick.get(Materials.Steel); + case 4 -> aRecipe[i] = OrePrefixes.stick.get(Materials.Neodymium); + default -> aRecipe[i] = OrePrefixes.stick.get(Materials.VanadiumGallium); } continue; } if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.COIL_ELECTRIC) { switch (this.mTier) { - case 0: - aRecipe[i] = OrePrefixes.wireGt01.get(Materials.Lead); - break; - case 1: - aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Tin); - break; - case 2: - aRecipe[i] = OrePrefixes.wireGt02.get(Materials.AnyCopper); - break; - case 3: - aRecipe[i] = OrePrefixes.wireGt04.get(Materials.AnyCopper); - break; - case 4: - aRecipe[i] = OrePrefixes.wireGt08.get(Materials.AnnealedCopper); - break; - case 5: - aRecipe[i] = OrePrefixes.wireGt16.get(Materials.AnnealedCopper); - break; - case 6: - aRecipe[i] = OrePrefixes.wireGt04.get(Materials.YttriumBariumCuprate); - break; - case 7: - aRecipe[i] = OrePrefixes.wireGt08.get(Materials.Iridium); - break; - default: - aRecipe[i] = OrePrefixes.wireGt16.get(Materials.Osmium); - break; + case 0 -> aRecipe[i] = OrePrefixes.wireGt01.get(Materials.Lead); + case 1 -> aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Tin); + case 2 -> aRecipe[i] = OrePrefixes.wireGt02.get(Materials.AnyCopper); + case 3 -> aRecipe[i] = OrePrefixes.wireGt04.get(Materials.AnyCopper); + case 4 -> aRecipe[i] = OrePrefixes.wireGt08.get(Materials.AnnealedCopper); + case 5 -> aRecipe[i] = OrePrefixes.wireGt16.get(Materials.AnnealedCopper); + case 6 -> aRecipe[i] = OrePrefixes.wireGt04.get(Materials.YttriumBariumCuprate); + case 7 -> aRecipe[i] = OrePrefixes.wireGt08.get(Materials.Iridium); + default -> aRecipe[i] = OrePrefixes.wireGt16.get(Materials.Osmium); } continue; } if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.ROBOT_ARM) { switch (this.mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Robot_Arm_LV; - break; - case 2: - aRecipe[i] = ItemList.Robot_Arm_MV; - break; - case 3: - aRecipe[i] = ItemList.Robot_Arm_HV; - break; - case 4: - aRecipe[i] = ItemList.Robot_Arm_EV; - break; - case 5: - aRecipe[i] = ItemList.Robot_Arm_IV; - break; - case 6: - aRecipe[i] = ItemList.Robot_Arm_LuV; - break; - case 7: - aRecipe[i] = ItemList.Robot_Arm_ZPM; - break; - case 8: - aRecipe[i] = ItemList.Robot_Arm_UV; - break; - case 9: - aRecipe[i] = ItemList.Robot_Arm_UHV; - break; - case 10: - aRecipe[i] = ItemList.Robot_Arm_UEV; - break; - case 11: - aRecipe[i] = ItemList.Robot_Arm_UIV; - break; - case 12: - aRecipe[i] = ItemList.Robot_Arm_UMV; - break; - case 13: - aRecipe[i] = ItemList.Robot_Arm_UXV; - break; - case 14: - aRecipe[i] = ItemList.Robot_Arm_MAX; - break; - default: - aRecipe[i] = ItemList.Robot_Arm_MAX; - break; + case 0, 1 -> aRecipe[i] = ItemList.Robot_Arm_LV; + case 2 -> aRecipe[i] = ItemList.Robot_Arm_MV; + case 3 -> aRecipe[i] = ItemList.Robot_Arm_HV; + case 4 -> aRecipe[i] = ItemList.Robot_Arm_EV; + case 5 -> aRecipe[i] = ItemList.Robot_Arm_IV; + case 6 -> aRecipe[i] = ItemList.Robot_Arm_LuV; + case 7 -> aRecipe[i] = ItemList.Robot_Arm_ZPM; + case 8 -> aRecipe[i] = ItemList.Robot_Arm_UV; + case 9 -> aRecipe[i] = ItemList.Robot_Arm_UHV; + case 10 -> aRecipe[i] = ItemList.Robot_Arm_UEV; + case 11 -> aRecipe[i] = ItemList.Robot_Arm_UIV; + case 12 -> aRecipe[i] = ItemList.Robot_Arm_UMV; + case 13 -> aRecipe[i] = ItemList.Robot_Arm_UXV; + case 14 -> aRecipe[i] = ItemList.Robot_Arm_MAX; + default -> aRecipe[i] = ItemList.Robot_Arm_MAX; } continue; } if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PUMP) { switch (this.mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Electric_Pump_LV; - break; - case 2: - aRecipe[i] = ItemList.Electric_Pump_MV; - break; - case 3: - aRecipe[i] = ItemList.Electric_Pump_HV; - break; - case 4: - aRecipe[i] = ItemList.Electric_Pump_EV; - break; - case 5: - aRecipe[i] = ItemList.Electric_Pump_IV; - break; - case 6: - aRecipe[i] = ItemList.Electric_Pump_LuV; - break; - case 7: - aRecipe[i] = ItemList.Electric_Pump_ZPM; - break; - case 8: - aRecipe[i] = ItemList.Electric_Pump_UV; - break; - case 9: - aRecipe[i] = ItemList.Electric_Pump_UHV; - break; - case 10: - aRecipe[i] = ItemList.Electric_Pump_UEV; - break; - case 11: - aRecipe[i] = ItemList.Electric_Pump_UIV; - break; - case 12: - aRecipe[i] = ItemList.Electric_Pump_UMV; - break; - case 13: - aRecipe[i] = ItemList.Electric_Pump_UXV; - break; - case 14: - aRecipe[i] = ItemList.Electric_Pump_MAX; - break; - default: - aRecipe[i] = ItemList.Electric_Pump_MAX; - break; + case 0, 1 -> aRecipe[i] = ItemList.Electric_Pump_LV; + case 2 -> aRecipe[i] = ItemList.Electric_Pump_MV; + case 3 -> aRecipe[i] = ItemList.Electric_Pump_HV; + case 4 -> aRecipe[i] = ItemList.Electric_Pump_EV; + case 5 -> aRecipe[i] = ItemList.Electric_Pump_IV; + case 6 -> aRecipe[i] = ItemList.Electric_Pump_LuV; + case 7 -> aRecipe[i] = ItemList.Electric_Pump_ZPM; + case 8 -> aRecipe[i] = ItemList.Electric_Pump_UV; + case 9 -> aRecipe[i] = ItemList.Electric_Pump_UHV; + case 10 -> aRecipe[i] = ItemList.Electric_Pump_UEV; + case 11 -> aRecipe[i] = ItemList.Electric_Pump_UIV; + case 12 -> aRecipe[i] = ItemList.Electric_Pump_UMV; + case 13 -> aRecipe[i] = ItemList.Electric_Pump_UXV; + case 14 -> aRecipe[i] = ItemList.Electric_Pump_MAX; + default -> aRecipe[i] = ItemList.Electric_Pump_MAX; } continue; } if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.ROTOR) { switch (this.mTier) { - case 0: - case 1: - aRecipe[i] = OrePrefixes.rotor.get(Materials.Tin); - break; - case 2: - aRecipe[i] = OrePrefixes.rotor.get(Materials.Bronze); - break; - case 3: - aRecipe[i] = OrePrefixes.rotor.get(Materials.Steel); - break; - case 4: - aRecipe[i] = OrePrefixes.rotor.get(Materials.StainlessSteel); - break; - case 5: - aRecipe[i] = OrePrefixes.rotor.get(Materials.TungstenSteel); - break; - case 6: - aRecipe[i] = OrePrefixes.rotor.get(Materials.Chrome); - break; - case 7: - aRecipe[i] = OrePrefixes.rotor.get(Materials.Iridium); - break; - default: - aRecipe[i] = OrePrefixes.rotor.get(Materials.Osmium); - break; + case 0, 1 -> aRecipe[i] = OrePrefixes.rotor.get(Materials.Tin); + case 2 -> aRecipe[i] = OrePrefixes.rotor.get(Materials.Bronze); + case 3 -> aRecipe[i] = OrePrefixes.rotor.get(Materials.Steel); + case 4 -> aRecipe[i] = OrePrefixes.rotor.get(Materials.StainlessSteel); + case 5 -> aRecipe[i] = OrePrefixes.rotor.get(Materials.TungstenSteel); + case 6 -> aRecipe[i] = OrePrefixes.rotor.get(Materials.Chrome); + case 7 -> aRecipe[i] = OrePrefixes.rotor.get(Materials.Iridium); + default -> aRecipe[i] = OrePrefixes.rotor.get(Materials.Osmium); } continue; } if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.MOTOR) { switch (this.mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Electric_Motor_LV; - break; - case 2: - aRecipe[i] = ItemList.Electric_Motor_MV; - break; - case 3: - aRecipe[i] = ItemList.Electric_Motor_HV; - break; - case 4: - aRecipe[i] = ItemList.Electric_Motor_EV; - break; - case 5: - aRecipe[i] = ItemList.Electric_Motor_IV; - break; - case 6: - aRecipe[i] = ItemList.Electric_Motor_LuV; - break; - case 7: - aRecipe[i] = ItemList.Electric_Motor_ZPM; - break; - case 8: - aRecipe[i] = ItemList.Electric_Motor_UV; - break; - case 9: - aRecipe[i] = ItemList.Electric_Motor_UHV; - break; - case 10: - aRecipe[i] = ItemList.Electric_Motor_UEV; - break; - case 11: - aRecipe[i] = ItemList.Electric_Motor_UIV; - break; - case 12: - aRecipe[i] = ItemList.Electric_Motor_UMV; - break; - case 13: - aRecipe[i] = ItemList.Electric_Motor_UXV; - break; - case 14: - aRecipe[i] = ItemList.Electric_Motor_MAX; - break; - default: - aRecipe[i] = ItemList.Electric_Motor_MAX; - break; + case 0, 1 -> aRecipe[i] = ItemList.Electric_Motor_LV; + case 2 -> aRecipe[i] = ItemList.Electric_Motor_MV; + case 3 -> aRecipe[i] = ItemList.Electric_Motor_HV; + case 4 -> aRecipe[i] = ItemList.Electric_Motor_EV; + case 5 -> aRecipe[i] = ItemList.Electric_Motor_IV; + case 6 -> aRecipe[i] = ItemList.Electric_Motor_LuV; + case 7 -> aRecipe[i] = ItemList.Electric_Motor_ZPM; + case 8 -> aRecipe[i] = ItemList.Electric_Motor_UV; + case 9 -> aRecipe[i] = ItemList.Electric_Motor_UHV; + case 10 -> aRecipe[i] = ItemList.Electric_Motor_UEV; + case 11 -> aRecipe[i] = ItemList.Electric_Motor_UIV; + case 12 -> aRecipe[i] = ItemList.Electric_Motor_UMV; + case 13 -> aRecipe[i] = ItemList.Electric_Motor_UXV; + case 14 -> aRecipe[i] = ItemList.Electric_Motor_MAX; + default -> aRecipe[i] = ItemList.Electric_Motor_MAX; } continue; } if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PISTON) { switch (this.mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Electric_Piston_LV; - break; - case 2: - aRecipe[i] = ItemList.Electric_Piston_MV; - break; - case 3: - aRecipe[i] = ItemList.Electric_Piston_HV; - break; - case 4: - aRecipe[i] = ItemList.Electric_Piston_EV; - break; - case 5: - aRecipe[i] = ItemList.Electric_Piston_IV; - break; - case 6: - aRecipe[i] = ItemList.Electric_Piston_LuV; - break; - case 7: - aRecipe[i] = ItemList.Electric_Piston_ZPM; - break; - case 8: - aRecipe[i] = ItemList.Electric_Piston_UV; - break; - case 9: - aRecipe[i] = ItemList.Electric_Piston_UHV; - break; - case 10: - aRecipe[i] = ItemList.Electric_Piston_UEV; - break; - case 11: - aRecipe[i] = ItemList.Electric_Piston_UIV; - break; - case 12: - aRecipe[i] = ItemList.Electric_Piston_UMV; - break; - case 13: - aRecipe[i] = ItemList.Electric_Piston_UXV; - break; - case 14: - aRecipe[i] = ItemList.Electric_Piston_MAX; - break; - default: - aRecipe[i] = ItemList.Electric_Piston_MAX; - break; + case 0, 1 -> aRecipe[i] = ItemList.Electric_Piston_LV; + case 2 -> aRecipe[i] = ItemList.Electric_Piston_MV; + case 3 -> aRecipe[i] = ItemList.Electric_Piston_HV; + case 4 -> aRecipe[i] = ItemList.Electric_Piston_EV; + case 5 -> aRecipe[i] = ItemList.Electric_Piston_IV; + case 6 -> aRecipe[i] = ItemList.Electric_Piston_LuV; + case 7 -> aRecipe[i] = ItemList.Electric_Piston_ZPM; + case 8 -> aRecipe[i] = ItemList.Electric_Piston_UV; + case 9 -> aRecipe[i] = ItemList.Electric_Piston_UHV; + case 10 -> aRecipe[i] = ItemList.Electric_Piston_UEV; + case 11 -> aRecipe[i] = ItemList.Electric_Piston_UIV; + case 12 -> aRecipe[i] = ItemList.Electric_Piston_UMV; + case 13 -> aRecipe[i] = ItemList.Electric_Piston_UXV; + case 14 -> aRecipe[i] = ItemList.Electric_Piston_MAX; + default -> aRecipe[i] = ItemList.Electric_Piston_MAX; } continue; } if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CONVEYOR) { switch (this.mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Conveyor_Module_LV; - break; - case 2: - aRecipe[i] = ItemList.Conveyor_Module_MV; - break; - case 3: - aRecipe[i] = ItemList.Conveyor_Module_HV; - break; - case 4: - aRecipe[i] = ItemList.Conveyor_Module_EV; - break; - case 5: - aRecipe[i] = ItemList.Conveyor_Module_IV; - break; - case 6: - aRecipe[i] = ItemList.Conveyor_Module_LuV; - break; - case 7: - aRecipe[i] = ItemList.Conveyor_Module_ZPM; - break; - case 8: - aRecipe[i] = ItemList.Conveyor_Module_UV; - break; - case 9: - aRecipe[i] = ItemList.Conveyor_Module_UHV; - break; - case 10: - aRecipe[i] = ItemList.Conveyor_Module_UEV; - break; - case 11: - aRecipe[i] = ItemList.Conveyor_Module_UIV; - break; - case 12: - aRecipe[i] = ItemList.Conveyor_Module_UMV; - break; - case 13: - aRecipe[i] = ItemList.Conveyor_Module_UXV; - break; - case 14: - aRecipe[i] = ItemList.Conveyor_Module_MAX; - break; - default: - aRecipe[i] = ItemList.Conveyor_Module_MAX; - break; + case 0, 1 -> aRecipe[i] = ItemList.Conveyor_Module_LV; + case 2 -> aRecipe[i] = ItemList.Conveyor_Module_MV; + case 3 -> aRecipe[i] = ItemList.Conveyor_Module_HV; + case 4 -> aRecipe[i] = ItemList.Conveyor_Module_EV; + case 5 -> aRecipe[i] = ItemList.Conveyor_Module_IV; + case 6 -> aRecipe[i] = ItemList.Conveyor_Module_LuV; + case 7 -> aRecipe[i] = ItemList.Conveyor_Module_ZPM; + case 8 -> aRecipe[i] = ItemList.Conveyor_Module_UV; + case 9 -> aRecipe[i] = ItemList.Conveyor_Module_UHV; + case 10 -> aRecipe[i] = ItemList.Conveyor_Module_UEV; + case 11 -> aRecipe[i] = ItemList.Conveyor_Module_UIV; + case 12 -> aRecipe[i] = ItemList.Conveyor_Module_UMV; + case 13 -> aRecipe[i] = ItemList.Conveyor_Module_UXV; + case 14 -> aRecipe[i] = ItemList.Conveyor_Module_MAX; + default -> aRecipe[i] = ItemList.Conveyor_Module_MAX; } continue; } if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.EMITTER) { switch (this.mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Emitter_LV; - break; - case 2: - aRecipe[i] = ItemList.Emitter_MV; - break; - case 3: - aRecipe[i] = ItemList.Emitter_HV; - break; - case 4: - aRecipe[i] = ItemList.Emitter_EV; - break; - case 5: - aRecipe[i] = ItemList.Emitter_IV; - break; - case 6: - aRecipe[i] = ItemList.Emitter_LuV; - break; - case 7: - aRecipe[i] = ItemList.Emitter_ZPM; - break; - case 8: - aRecipe[i] = ItemList.Emitter_UV; - break; - case 9: - aRecipe[i] = ItemList.Emitter_UHV; - break; - case 10: - aRecipe[i] = ItemList.Emitter_UEV; - break; - case 11: - aRecipe[i] = ItemList.Emitter_UIV; - break; - case 12: - aRecipe[i] = ItemList.Emitter_UMV; - break; - case 13: - aRecipe[i] = ItemList.Emitter_UXV; - break; - case 14: - aRecipe[i] = ItemList.Emitter_MAX; - break; - default: - aRecipe[i] = ItemList.Emitter_MAX; - break; + case 0, 1 -> aRecipe[i] = ItemList.Emitter_LV; + case 2 -> aRecipe[i] = ItemList.Emitter_MV; + case 3 -> aRecipe[i] = ItemList.Emitter_HV; + case 4 -> aRecipe[i] = ItemList.Emitter_EV; + case 5 -> aRecipe[i] = ItemList.Emitter_IV; + case 6 -> aRecipe[i] = ItemList.Emitter_LuV; + case 7 -> aRecipe[i] = ItemList.Emitter_ZPM; + case 8 -> aRecipe[i] = ItemList.Emitter_UV; + case 9 -> aRecipe[i] = ItemList.Emitter_UHV; + case 10 -> aRecipe[i] = ItemList.Emitter_UEV; + case 11 -> aRecipe[i] = ItemList.Emitter_UIV; + case 12 -> aRecipe[i] = ItemList.Emitter_UMV; + case 13 -> aRecipe[i] = ItemList.Emitter_UXV; + case 14 -> aRecipe[i] = ItemList.Emitter_MAX; + default -> aRecipe[i] = ItemList.Emitter_MAX; } continue; } if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.SENSOR) { switch (this.mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Sensor_LV; - break; - case 2: - aRecipe[i] = ItemList.Sensor_MV; - break; - case 3: - aRecipe[i] = ItemList.Sensor_HV; - break; - case 4: - aRecipe[i] = ItemList.Sensor_EV; - break; - case 5: - aRecipe[i] = ItemList.Sensor_IV; - break; - case 6: - aRecipe[i] = ItemList.Sensor_LuV; - break; - case 7: - aRecipe[i] = ItemList.Sensor_ZPM; - break; - case 8: - aRecipe[i] = ItemList.Sensor_UV; - break; - case 9: - aRecipe[i] = ItemList.Sensor_UHV; - break; - case 10: - aRecipe[i] = ItemList.Sensor_UEV; - break; - case 11: - aRecipe[i] = ItemList.Sensor_UIV; - break; - case 12: - aRecipe[i] = ItemList.Sensor_UMV; - break; - case 13: - aRecipe[i] = ItemList.Sensor_UXV; - break; - case 14: - aRecipe[i] = ItemList.Sensor_MAX; - break; - default: - aRecipe[i] = ItemList.Sensor_MAX; - break; + case 0, 1 -> aRecipe[i] = ItemList.Sensor_LV; + case 2 -> aRecipe[i] = ItemList.Sensor_MV; + case 3 -> aRecipe[i] = ItemList.Sensor_HV; + case 4 -> aRecipe[i] = ItemList.Sensor_EV; + case 5 -> aRecipe[i] = ItemList.Sensor_IV; + case 6 -> aRecipe[i] = ItemList.Sensor_LuV; + case 7 -> aRecipe[i] = ItemList.Sensor_ZPM; + case 8 -> aRecipe[i] = ItemList.Sensor_UV; + case 9 -> aRecipe[i] = ItemList.Sensor_UHV; + case 10 -> aRecipe[i] = ItemList.Sensor_UEV; + case 11 -> aRecipe[i] = ItemList.Sensor_UIV; + case 12 -> aRecipe[i] = ItemList.Sensor_UMV; + case 13 -> aRecipe[i] = ItemList.Sensor_UXV; + case 14 -> aRecipe[i] = ItemList.Sensor_MAX; + default -> aRecipe[i] = ItemList.Sensor_MAX; } continue; } if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.FIELD_GENERATOR) { switch (this.mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Field_Generator_LV; - break; - case 2: - aRecipe[i] = ItemList.Field_Generator_MV; - break; - case 3: - aRecipe[i] = ItemList.Field_Generator_HV; - break; - case 4: - aRecipe[i] = ItemList.Field_Generator_EV; - break; - case 5: - aRecipe[i] = ItemList.Field_Generator_IV; - break; - case 6: - aRecipe[i] = ItemList.Field_Generator_LuV; - break; - case 7: - aRecipe[i] = ItemList.Field_Generator_ZPM; - break; - case 8: - aRecipe[i] = ItemList.Field_Generator_UV; - break; - case 9: - aRecipe[i] = ItemList.Field_Generator_UHV; - break; - case 10: - aRecipe[i] = ItemList.Field_Generator_UEV; - break; - case 11: - aRecipe[i] = ItemList.Field_Generator_UIV; - break; - case 12: - aRecipe[i] = ItemList.Field_Generator_UMV; - break; - case 13: - aRecipe[i] = ItemList.Field_Generator_UXV; - break; - case 14: - aRecipe[i] = ItemList.Field_Generator_MAX; - break; - default: - aRecipe[i] = ItemList.Field_Generator_MAX; - break; + case 0, 1 -> aRecipe[i] = ItemList.Field_Generator_LV; + case 2 -> aRecipe[i] = ItemList.Field_Generator_MV; + case 3 -> aRecipe[i] = ItemList.Field_Generator_HV; + case 4 -> aRecipe[i] = ItemList.Field_Generator_EV; + case 5 -> aRecipe[i] = ItemList.Field_Generator_IV; + case 6 -> aRecipe[i] = ItemList.Field_Generator_LuV; + case 7 -> aRecipe[i] = ItemList.Field_Generator_ZPM; + case 8 -> aRecipe[i] = ItemList.Field_Generator_UV; + case 9 -> aRecipe[i] = ItemList.Field_Generator_UHV; + case 10 -> aRecipe[i] = ItemList.Field_Generator_UEV; + case 11 -> aRecipe[i] = ItemList.Field_Generator_UIV; + case 12 -> aRecipe[i] = ItemList.Field_Generator_UMV; + case 13 -> aRecipe[i] = ItemList.Field_Generator_UXV; + case 14 -> aRecipe[i] = ItemList.Field_Generator_MAX; + default -> aRecipe[i] = ItemList.Field_Generator_MAX; } continue; } @@ -1063,9 +673,10 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ ItemStack aStack) { if (!super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack)) return false; switch (this.mInputSlotCount) { - case 0: + case 0 -> { return false; - case 1: + } + case 1 -> { if (this.getFillableStack() == null) return !this.mRequiresFluidForFiltering && this.getRecipeList() .containsInput( aStack); @@ -1080,7 +691,8 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ this.getSpecialSlot(), appendSelectedCircuit(aStack)) != null; - case 2: + } + case 2 -> { return (!this.mRequiresFluidForFiltering || this.getFillableStack() != null) && (((this.getInputAt(0) != null && this.getInputAt(1) != null) || (this.getInputAt(0) == null && this.getInputAt(1) == null ? this.getRecipeList() @@ -1100,17 +712,18 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ ? appendSelectedCircuit(aStack, this.getInputAt(1)) : appendSelectedCircuit(this.getInputAt(0), aStack)) != null)))); - default: { + } + default -> { int tID = this.getBaseMetaTileEntity() .getMetaTileID(); if (tID >= 211 && tID <= 218 || tID >= 1180 && tID <= 1187 || tID >= 10780 && tID <= 10786) { // assembler - // lv-iv; - // circuit - // asseblers - // lv - - // uv; - // assemblers - // luv-uev + // lv-iv; + // circuit + // asseblers + // lv - + // uv; + // assemblers + // luv-uev if (GT_Utility.isStackValid(aStack)) for (int oreID : OreDictionary.getOreIDs(aStack)) { if (OreDictionary.getOreName(oreID) .startsWith("circuit")) @@ -1134,34 +747,26 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ if (aBaseMetaTileEntity.isClientSide() && aBaseMetaTileEntity.isActive()) { // noinspection SwitchStatementWithTooFewBranches switch (this.mSpecialEffect) { - case TOP_SMOKE: + case TOP_SMOKE -> { final byte topFacing = (byte) ForgeDirection.UP.ordinal(); - if (aBaseMetaTileEntity.getFrontFacing() != topFacing && aBaseMetaTileEntity.getCoverIDAtSide(topFacing) == 0 && !aBaseMetaTileEntity.getOpacityAtSide(topFacing)) { - new WorldSpawnedEventBuilder.ParticleEventBuilder().setMotion(0.0D, 0.0D, 0.0D) - .setIdentifier(ParticleFX.SMOKE) - .setPosition( - aBaseMetaTileEntity.getXCoord() - + 0.8F - - XSTR_INSTANCE.nextFloat() - * 0.6F, - aBaseMetaTileEntity.getYCoord() - + 0.9F - + XSTR_INSTANCE.nextFloat() - * 0.2F, - aBaseMetaTileEntity.getZCoord() - + 0.8F - - XSTR_INSTANCE.nextFloat() - * 0.6F) - .setWorld(aBaseMetaTileEntity.getWorld()) - .run(); + new ParticleEventBuilder().setMotion(0.0D, 0.0D, 0.0D) + .setIdentifier(ParticleFX.SMOKE) + .setPosition( + aBaseMetaTileEntity.getXCoord() + 0.8F + - XSTR_INSTANCE.nextFloat() * 0.6F, + aBaseMetaTileEntity.getYCoord() + 0.9F + + XSTR_INSTANCE.nextFloat() * 0.2F, + aBaseMetaTileEntity.getZCoord() + 0.8F + - XSTR_INSTANCE.nextFloat() * 0.6F) + .setWorld(aBaseMetaTileEntity.getWorld()) + .run(); } - break; - default: - break; + } + default -> {} } } } @@ -1177,7 +782,7 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ // noinspection SwitchStatementWithTooFewBranches switch (this.mSpecialEffect) { - case MAIN_RANDOM_SPARKS: + case MAIN_RANDOM_SPARKS -> { // Random Sparkles at main face if (aBaseMetaTileEntity.isActive() && XSTR_INSTANCE.nextInt(3) == 0) { @@ -1227,9 +832,8 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ .run(); } } - break; - default: - break; + } + default -> {} } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java index 1138b0a51d..1b451f3108 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java @@ -105,57 +105,63 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM if (side == facing) return mTextures[FRONT_INDEX][colorIndex]; if (ForgeDirection.OPPOSITES[aSide] == aFacing) return mTextures[OUTPUT_INDEX][colorIndex]; switch (facing) { - case DOWN: + case DOWN -> { return mTextures[ARROW_UP_INDEX][colorIndex]; // ARROW_UP - case UP: + } + case UP -> { return mTextures[ARROW_DOWN_INDEX][colorIndex]; // ARROW_DOWN - case NORTH: + } + case NORTH -> { switch (side) { - case DOWN: - case UP: + case DOWN, UP -> { return mTextures[ARROW_DOWN_INDEX][colorIndex]; // ARROW_DOWN - case WEST: + } + case WEST -> { return mTextures[ARROW_RIGHT_INDEX][colorIndex]; // ARROW_RIGHT - case EAST: + } + case EAST -> { return mTextures[ARROW_LEFT_INDEX][colorIndex]; // ARROW_LEFT - default: + } + default -> {} } - break; - case SOUTH: + } + case SOUTH -> { switch (side) { - case DOWN: - case UP: + case DOWN, UP -> { return mTextures[ARROW_UP_INDEX][colorIndex]; // ARROW_UP - case WEST: + } + case WEST -> { return mTextures[ARROW_LEFT_INDEX][colorIndex]; // ARROW_LEFT - case EAST: + } + case EAST -> { return mTextures[ARROW_RIGHT_INDEX][colorIndex]; // ARROW_RIGHT - default: + } + default -> {} } - break; - case WEST: + } + case WEST -> { switch (side) { - case UP: - case SOUTH: + case UP, SOUTH -> { return mTextures[ARROW_RIGHT_INDEX][colorIndex]; // ARROW_RIGHT - case DOWN: - case NORTH: + } + case DOWN, NORTH -> { return mTextures[ARROW_LEFT_INDEX][colorIndex]; // ARROW_LEFT - default: + } + default -> {} } - break; - case EAST: + } + case EAST -> { switch (side) { - case UP: - case SOUTH: + case UP, SOUTH -> { return mTextures[ARROW_LEFT_INDEX][colorIndex]; // ARROW_LEFT - case DOWN: - case NORTH: + } + case DOWN, NORTH -> { return mTextures[ARROW_RIGHT_INDEX][colorIndex]; // ARROW_RIGHT - default: + } + default -> {} } - break; - default: + } + default -> {} } return mTextures[FRONT_INDEX][colorIndex]; } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java index d9c32911b7..700732f033 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java @@ -39,7 +39,7 @@ public abstract class GT_MetaTileEntity_CubicMultiBlockBase<T extends GT_MetaTil extends GT_MetaTileEntity_EnhancedMultiBlockBase<T> implements ISurvivalConstructable { protected static final String STRUCTURE_PIECE_MAIN = "main"; - protected static final ClassValue<IStructureDefinition<GT_MetaTileEntity_CubicMultiBlockBase<?>>> STRUCTURE_DEFINITION = new ClassValue<IStructureDefinition<GT_MetaTileEntity_CubicMultiBlockBase<?>>>() { + protected static final ClassValue<IStructureDefinition<GT_MetaTileEntity_CubicMultiBlockBase<?>>> STRUCTURE_DEFINITION = new ClassValue<>() { @Override protected IStructureDefinition<GT_MetaTileEntity_CubicMultiBlockBase<?>> computeValue(Class<?> type) { diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ExtendedPowerMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ExtendedPowerMultiBlockBase.java index cfc1ce6558..99b5c6c550 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ExtendedPowerMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ExtendedPowerMultiBlockBase.java @@ -192,7 +192,7 @@ public abstract class GT_MetaTileEntity_ExtendedPowerMultiBlockBase<T extends GT + StatCollector.translateToLocal("GT5U.multiblock.efficiency") + ": " + EnumChatFormatting.YELLOW - + Float.toString(mEfficiency / 100.0F) + + mEfficiency / 100.0F + EnumChatFormatting.RESET + " %", /* 6 */ StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DataAccess.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DataAccess.java index fc6dce9e70..9adc250f73 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DataAccess.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DataAccess.java @@ -143,19 +143,16 @@ public class GT_MetaTileEntity_Hatch_DataAccess extends GT_MetaTileEntity_Hatch @Override public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { - switch (mTier) { - case 4: - getBaseMetaTileEntity().add2by2Slots( - builder, - getGUITextureSet().getItemSlot(), - GT_UITextures.OVERLAY_SLOT_CIRCUIT); - break; - default: - getBaseMetaTileEntity().add4by4Slots( - builder, - getGUITextureSet().getItemSlot(), - GT_UITextures.OVERLAY_SLOT_CIRCUIT); - break; + if (mTier == 4) { + getBaseMetaTileEntity().add2by2Slots( + builder, + getGUITextureSet().getItemSlot(), + GT_UITextures.OVERLAY_SLOT_CIRCUIT); + } else { + getBaseMetaTileEntity().add4by4Slots( + builder, + getGUITextureSet().getItemSlot(), + GT_UITextures.OVERLAY_SLOT_CIRCUIT); } } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java index 42abf4839b..a9235ba430 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java @@ -269,18 +269,10 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch @Override public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { switch (mTier) { - case 0: - getBaseMetaTileEntity().add1by1Slot(builder); - break; - case 1: - getBaseMetaTileEntity().add2by2Slots(builder); - break; - case 2: - getBaseMetaTileEntity().add3by3Slots(builder); - break; - default: - getBaseMetaTileEntity().add4by4Slots(builder); - break; + case 0 -> getBaseMetaTileEntity().add1by1Slot(builder); + case 1 -> getBaseMetaTileEntity().add2by2Slots(builder); + case 2 -> getBaseMetaTileEntity().add3by3Slots(builder); + default -> getBaseMetaTileEntity().add4by4Slots(builder); } } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java index d380baf8ed..a2d30a9d72 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java @@ -280,8 +280,7 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch getBaseMetaTileEntity().setActive(false); aStack.stackSize--; } - if (mSolderingTool && aPlayer instanceof EntityPlayerMP) { - EntityPlayerMP tPlayer = (EntityPlayerMP) aPlayer; + if (mSolderingTool && aPlayer instanceof EntityPlayerMP tPlayer) { try { GT_Mod.achievements.issueAchievement(tPlayer, "maintainance"); } catch (Exception ignored) {} diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java index 4a8e745a25..b55350a97e 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java @@ -252,39 +252,39 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch impl } final String inBrackets; switch (mMode) { - case 0: + case 0 -> { GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("108", "Outputs misc. Fluids, Steam and Items")); this.setLockedFluidName(null); - break; - case 1: + } + case 1 -> { GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("109", "Outputs Steam and Items")); this.setLockedFluidName(null); - break; - case 2: + } + case 2 -> { GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("110", "Outputs Steam and misc. Fluids")); this.setLockedFluidName(null); - break; - case 3: + } + case 3 -> { GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("111", "Outputs Steam")); this.setLockedFluidName(null); - break; - case 4: + } + case 4 -> { GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("112", "Outputs misc. Fluids and Items")); this.setLockedFluidName(null); - break; - case 5: + } + case 5 -> { GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("113", "Outputs only Items")); this.setLockedFluidName(null); - break; - case 6: + } + case 6 -> { GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("114", "Outputs only misc. Fluids")); this.setLockedFluidName(null); - break; - case 7: + } + case 7 -> { GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("115", "Outputs nothing")); this.setLockedFluidName(null); - break; - case 8: + } + case 8 -> { playerThatLockedfluid = new WeakReference<>(aPlayer); if (mFluid == null) { this.setLockedFluidName(null); @@ -305,8 +305,8 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch impl "%s (%s)", GT_Utility.trans("151.1", "Outputs items and 1 specific Fluid"), inBrackets)); - break; - case 9: + } + case 9 -> { playerThatLockedfluid = new WeakReference<>(aPlayer); if (mFluid == null) { this.setLockedFluidName(null); @@ -324,7 +324,7 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch impl GT_Utility.sendChatToPlayer( aPlayer, String.format("%s (%s)", GT_Utility.trans("151.2", "Outputs 1 specific Fluid"), inBrackets)); - break; + } } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java index c970b64cb9..633d82566c 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java @@ -113,7 +113,7 @@ public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch i /** * Attempt to store as many items as possible into the internal inventory of this output bus. If you need atomicity * you should use {@link gregtech.api.interfaces.tileentity.IHasInventory#addStackToSlot(int, ItemStack)} - * + * * @param aStack Assume valid. Will be mutated. Take over the ownership. Caller should not retain a reference to * this stack if the call returns true. * @return true if stack is fully accepted. false is stack is partially accepted or nothing is accepted @@ -193,18 +193,10 @@ public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch i @Override public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { switch (mTier) { - case 0: - getBaseMetaTileEntity().add1by1Slot(builder); - break; - case 1: - getBaseMetaTileEntity().add2by2Slots(builder); - break; - case 2: - getBaseMetaTileEntity().add3by3Slots(builder); - break; - default: - getBaseMetaTileEntity().add4by4Slots(builder); - break; + case 0 -> getBaseMetaTileEntity().add1by1Slot(builder); + case 1 -> getBaseMetaTileEntity().add2by2Slots(builder); + case 2 -> getBaseMetaTileEntity().add3by3Slots(builder); + default -> getBaseMetaTileEntity().add4by4Slots(builder); } } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index d2083fc87c..e26029b629 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -513,13 +513,17 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity public void doSound(byte aIndex, double aX, double aY, double aZ) { super.doSound(aIndex, aX, aY, aZ); switch (aIndex) { - case PROCESS_START_SOUND_INDEX: + case PROCESS_START_SOUND_INDEX -> { if (getProcessStartSound() != null) GT_Utility.doSoundAtClient(getProcessStartSound(), getTimeBetweenProcessSounds(), 1.0F, aX, aY, aZ); - break; - case INTERRUPT_SOUND_INDEX: - GT_Utility.doSoundAtClient(SoundResource.IC2_MACHINES_INTERRUPT_ONE, 100, 1.0F, aX, aY, aZ); - break; + } + case INTERRUPT_SOUND_INDEX -> GT_Utility.doSoundAtClient( + SoundResource.IC2_MACHINES_INTERRUPT_ONE, + 100, + 1.0F, + aX, + aY, + aZ); } } @@ -678,24 +682,12 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity mRuntime = 0; if (getBaseMetaTileEntity().getRandomNumber(6000) == 0) { switch (getBaseMetaTileEntity().getRandomNumber(6)) { - case 0: - mWrench = false; - break; - case 1: - mScrewdriver = false; - break; - case 2: - mSoftHammer = false; - break; - case 3: - mHardHammer = false; - break; - case 4: - mSolderingTool = false; - break; - case 5: - mCrowbar = false; - break; + case 0 -> mWrench = false; + case 1 -> mScrewdriver = false; + case 2 -> mSoftHammer = false; + case 3 -> mHardHammer = false; + case 4 -> mSolderingTool = false; + case 5 -> mCrowbar = false; } } if (mInventory[1] != null && getBaseMetaTileEntity().getRandomNumber(2) == 0 @@ -1184,9 +1176,8 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity if (aTileEntity == null) return false; IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch hatch && GT_ExoticEnergyInputHelper.isExoticEnergyInput(aMetaTileEntity)) { - GT_MetaTileEntity_Hatch hatch = (GT_MetaTileEntity_Hatch) aMetaTileEntity; hatch.updateTexture(aBaseCasingIndex); return mExoticEnergyHatches.add(hatch); } @@ -1333,7 +1324,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity + StatCollector.translateToLocal("GT5U.multiblock.efficiency") + ": " + EnumChatFormatting.YELLOW - + Float.toString(mEfficiency / 100.0F) + + mEfficiency / 100.0F + EnumChatFormatting.RESET + " %", /* 6 */ StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java index cb98e202ad..c7b9c66b70 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java @@ -179,7 +179,7 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)), 1, true) == 1) { - long tEU = (long) ((IEnergyProvider) tTileEntity).extractEnergy( + long tEU = ((IEnergyProvider) tTileEntity).extractEnergy( ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)), GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU), false); @@ -187,7 +187,7 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi aBaseMetaTileEntity.injectEnergyUnits((byte) 6, Math.min(tEU, maxEUInput()), 1); } else if (tTileEntity instanceof IEnergyStorage && ((IEnergyStorage) tTileEntity).extractEnergy(1, true) == 1) { - long tEU = (long) ((IEnergyStorage) tTileEntity).extractEnergy( + long tEU = ((IEnergyStorage) tTileEntity).extractEnergy( GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU), false); tEU = tEU * GregTech_API.mRFtoEU / 100; diff --git a/src/main/java/gregtech/api/multitileentity/MultiTileEntityBlock.java b/src/main/java/gregtech/api/multitileentity/MultiTileEntityBlock.java index 81997c1e76..2e6bdca647 100644 --- a/src/main/java/gregtech/api/multitileentity/MultiTileEntityBlock.java +++ b/src/main/java/gregtech/api/multitileentity/MultiTileEntityBlock.java @@ -243,8 +243,8 @@ public class MultiTileEntityBlock extends Block @Override @SuppressWarnings("unchecked") - public final void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB aAABB, List aList, - Entity aEntity) { + public final void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB aAABB, + List<AxisAlignedBB> aList, Entity aEntity) { final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (aTileEntity instanceof IMultiTileEntity) ((IMultiTileEntity) aTileEntity).addCollisionBoxesToList(aAABB, aList, aEntity); @@ -444,9 +444,8 @@ public class MultiTileEntityBlock extends Block @Override public Block getFacade(IBlockAccess aWorld, int aX, int aY, int aZ, int side) { final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof CoverableTileEntity) { + if (tTileEntity instanceof CoverableTileEntity tile) { final byte aSide = (byte) side; - final CoverableTileEntity tile = (CoverableTileEntity) tTileEntity; if (side != -1) { final Block facadeBlock = tile.getCoverInfoAtSide(aSide) .getFacadeBlock(); @@ -469,9 +468,8 @@ public class MultiTileEntityBlock extends Block @Override public int getFacadeMetadata(IBlockAccess aWorld, int aX, int aY, int aZ, int side) { final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof CoverableTileEntity) { + if (tTileEntity instanceof CoverableTileEntity tile) { final byte aSide = (byte) side; - final CoverableTileEntity tile = (CoverableTileEntity) tTileEntity; if (side != -1) { final CoverInfo coverInfo = tile.getCoverInfoAtSide(aSide); final Block facadeBlock = coverInfo.getFacadeBlock(); @@ -518,7 +516,7 @@ public class MultiTileEntityBlock extends Block } @Override - public final void getSubBlocks(Item aItem, CreativeTabs aCreativeTab, List aList) { + public final void getSubBlocks(Item aItem, CreativeTabs aCreativeTab, List<ItemStack> aList) { /**/ } diff --git a/src/main/java/gregtech/api/multitileentity/MultiTileEntityBlockInternal.java b/src/main/java/gregtech/api/multitileentity/MultiTileEntityBlockInternal.java index 690430b673..91855aae55 100644 --- a/src/main/java/gregtech/api/multitileentity/MultiTileEntityBlockInternal.java +++ b/src/main/java/gregtech/api/multitileentity/MultiTileEntityBlockInternal.java @@ -74,7 +74,7 @@ public class MultiTileEntityBlockInternal extends Block implements IRenderedBloc // TileEntity should not refresh yet! -Greg ((IMultiTileEntity) aMTEContainer.mTileEntity).setShouldRefresh(false); // Fake-Set the TileEntity first, bypassing a lot of checks. -Greg - setTileEntity(aWorld, aX, aY, aZ, (TileEntity) aMTEContainer.mTileEntity, false); + setTileEntity(aWorld, aX, aY, aZ, aMTEContainer.mTileEntity, false); // Now set the Block with the REAL MetaData. -Greg setTileEntity(aWorld, aX, aY, aZ, aMTEContainer.mBlock, aMTEContainer.mBlockMetaData, 0, false); // When the TileEntity is set now it SHOULD refresh! -Greg @@ -85,7 +85,7 @@ public class MultiTileEntityBlockInternal extends Block implements IRenderedBloc return false; } // And finally properly set the TileEntity for real! -Greg - setTileEntity(aWorld, aX, aY, aZ, (TileEntity) aMTEContainer.mTileEntity, aCauseBlockUpdates); + setTileEntity(aWorld, aX, aY, aZ, aMTEContainer.mTileEntity, aCauseBlockUpdates); // Yep, all this just to set one Block and its TileEntity properly... -Greg try { diff --git a/src/main/java/gregtech/api/multitileentity/MultiTileEntityItemInternal.java b/src/main/java/gregtech/api/multitileentity/MultiTileEntityItemInternal.java index 23ad00dabd..1f3c2dd5ca 100644 --- a/src/main/java/gregtech/api/multitileentity/MultiTileEntityItemInternal.java +++ b/src/main/java/gregtech/api/multitileentity/MultiTileEntityItemInternal.java @@ -49,7 +49,7 @@ public class MultiTileEntityItemInternal extends ItemBlock implements IFluidCont @Override @SuppressWarnings("unchecked") - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List<String> aList, boolean aF3_H) { final MultiTileEntityContainer tTileEntityContainer = mBlock.mMultiTileEntityRegistry.getNewTileEntityContainer( aStack); if (tTileEntityContainer == null) { @@ -71,7 +71,7 @@ public class MultiTileEntityItemInternal extends ItemBlock implements IFluidCont @Override @SideOnly(Side.CLIENT) @SuppressWarnings("unchecked") - public void getSubItems(Item aItem, CreativeTabs aTab, List aList) { + public void getSubItems(Item aItem, CreativeTabs aTab, List<ItemStack> aList) { for (MultiTileEntityClassContainer tClass : mBlock.mMultiTileEntityRegistry.mRegistrations) { if (!tClass.mHidden) { if (((IMultiTileEntity) tClass.mCanonicalTileEntity).getSubItems( diff --git a/src/main/java/gregtech/api/multitileentity/MultiTileEntityRegistry.java b/src/main/java/gregtech/api/multitileentity/MultiTileEntityRegistry.java index 56414dfb4e..1aeed1b3de 100644 --- a/src/main/java/gregtech/api/multitileentity/MultiTileEntityRegistry.java +++ b/src/main/java/gregtech/api/multitileentity/MultiTileEntityRegistry.java @@ -219,7 +219,7 @@ public class MultiTileEntityRegistry { public TileEntity getNewTileEntity(int aID) { final MultiTileEntityContainer tContainer = getNewTileEntityContainer(null, 0, 0, 0, aID, null); - return tContainer == null ? null : (TileEntity) tContainer.mTileEntity; + return tContainer == null ? null : tContainer.mTileEntity; } public MultiTileEntityContainer getNewTileEntityContainer(World aWorld, int aX, int aY, int aZ, int aID, diff --git a/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java b/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java index 8d96ff58f5..740496a8b6 100644 --- a/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java +++ b/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java @@ -451,7 +451,7 @@ public abstract class MultiTileBasicMachine extends TickableMultiTileEntity impl /** * Runs only on server side - * + * * @param tick The current tick of the machine */ protected void runMachine(long tick) { @@ -483,7 +483,7 @@ public abstract class MultiTileBasicMachine extends TickableMultiTileEntity impl /** * Runs only on server side - * + * * @param tick The current tick of the machine */ protected void runningTick(long tick) { @@ -569,13 +569,17 @@ public abstract class MultiTileBasicMachine extends TickableMultiTileEntity impl public void doSound(byte aIndex, double aX, double aY, double aZ) { switch (aIndex) { - case PROCESS_START_SOUND_INDEX: + case PROCESS_START_SOUND_INDEX -> { if (getProcessStartSound() != null) GT_Utility.doSoundAtClient(getProcessStartSound(), getTimeBetweenProcessSounds(), 1.0F, aX, aY, aZ); - break; - case INTERRUPT_SOUND_INDEX: - GT_Utility.doSoundAtClient(SoundResource.IC2_MACHINES_INTERRUPT_ONE, 100, 1.0F, aX, aY, aZ); - break; + } + case INTERRUPT_SOUND_INDEX -> GT_Utility.doSoundAtClient( + SoundResource.IC2_MACHINES_INTERRUPT_ONE, + 100, + 1.0F, + aX, + aY, + aZ); } } @@ -854,7 +858,7 @@ public abstract class MultiTileBasicMachine extends TickableMultiTileEntity impl this.soundEventValue = soundEventValue; if (isClientSide()) { switch (soundEventValue) { - case PROCESS_START_SOUND_INDEX: + case PROCESS_START_SOUND_INDEX -> { if (getProcessStartSound() != null) GT_Utility.doSoundAtClient( getProcessStartSound(), getTimeBetweenProcessSounds(), @@ -862,16 +866,14 @@ public abstract class MultiTileBasicMachine extends TickableMultiTileEntity impl getXCoord(), getYCoord(), getZCoord()); - break; - case INTERRUPT_SOUND_INDEX: - GT_Utility.doSoundAtClient( - SoundResource.IC2_MACHINES_INTERRUPT_ONE, - 100, - 1.0F, - getXCoord(), - getYCoord(), - getZCoord()); - break; + } + case INTERRUPT_SOUND_INDEX -> GT_Utility.doSoundAtClient( + SoundResource.IC2_MACHINES_INTERRUPT_ONE, + 100, + 1.0F, + getXCoord(), + getYCoord(), + getZCoord()); } } } diff --git a/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockController.java b/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockController.java index 72e766d54c..b76dc1b4bc 100644 --- a/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockController.java +++ b/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockController.java @@ -656,9 +656,8 @@ public abstract class MultiBlockController<T extends MultiBlockController<T>> ex @Override public boolean check(S t, World world, int x, int y, int z) { final TileEntity tileEntity = world.getTileEntity(x, y, z); - if (!(tileEntity instanceof MultiBlockPart)) return false; + if (!(tileEntity instanceof MultiBlockPart part)) return false; - final MultiBlockPart part = (MultiBlockPart) tileEntity; if (registryID != part.getMultiTileEntityRegistryID() || meta != part.getMultiTileEntityID()) return false; @@ -974,7 +973,7 @@ public abstract class MultiBlockController<T extends MultiBlockController<T>> ex if (tInv == null) return false; final int tSlot = tInv.getRight(); - final IItemHandlerModifiable inv = tInv.getLeft();; + final IItemHandlerModifiable inv = tInv.getLeft(); return inv.getStackInSlot(tSlot) == null || GT_Utility.areStacksEqual(aStack, inv.getStackInSlot(tSlot)); // && // allowPutStack(getBaseMetaTileEntity(), @@ -1441,7 +1440,7 @@ public abstract class MultiBlockController<T extends MultiBlockController<T>> ex buttons.setSize(16, 167) .setPos(7, 86); buttons.addChild(createPowerSwitchButton()) - .addChild(new FakeSyncWidget.BooleanSyncer(() -> isAllowedToWork(), val -> { + .addChild(new FakeSyncWidget.BooleanSyncer(this::isAllowedToWork, val -> { if (val) enableWorking(); else disableWorking(); })) diff --git a/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java b/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java index 0ea8cd77c8..953fc42f56 100644 --- a/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java +++ b/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java @@ -674,18 +674,16 @@ public abstract class MultiBlockPart extends NonTickableMultiTileEntity DropDownWidget dropDown = new DropDownWidget(); dropDown.addDropDownItemsSimple( controller.getInventoryNames(this), - (buttonWidget, index, label, setSelected) -> { - buttonWidget.setOnClick((clickData, widget) -> { - if (getNameOfInventoryFromIndex(controller, index).equals("all")) { - mLockedInventory = GT_Values.E; - mLockedInventoryIndex = 0; - } else { - mLockedInventory = getNameOfInventoryFromIndex(controller, index); - mLockedInventoryIndex = index; - } - setSelected.run(); - }); - }, + (buttonWidget, index, label, setSelected) -> buttonWidget.setOnClick((clickData, widget) -> { + if (getNameOfInventoryFromIndex(controller, index).equals("all")) { + mLockedInventory = GT_Values.E; + mLockedInventoryIndex = 0; + } else { + mLockedInventory = getNameOfInventoryFromIndex(controller, index); + mLockedInventoryIndex = index; + } + setSelected.run(); + }), true); builder.widget( dropDown.setSelected(mLockedInventoryIndex) diff --git a/src/main/java/gregtech/api/net/GT_Packet_GtTileEntityGuiRequest.java b/src/main/java/gregtech/api/net/GT_Packet_GtTileEntityGuiRequest.java index dbc72042a3..bf1a7e4af7 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_GtTileEntityGuiRequest.java +++ b/src/main/java/gregtech/api/net/GT_Packet_GtTileEntityGuiRequest.java @@ -88,9 +88,8 @@ public class GT_Packet_GtTileEntityGuiRequest extends GT_Packet_New { final World world = DimensionManager.getWorld(this.dimId); if (world == null) return; final TileEntity tile = world.getTileEntity(this.mX, this.mY, this.mZ); - if (!(tile instanceof BaseTileEntity) || ((BaseTileEntity) tile).isDead()) return; + if (!(tile instanceof BaseTileEntity baseTile) || ((BaseTileEntity) tile).isDead()) return; - final BaseTileEntity baseTile = ((BaseTileEntity) tile); final EntityPlayerMP player = (EntityPlayerMP) world.getEntityByID(playerId); final CoverableTileEntity coverableTile = (baseTile instanceof CoverableTileEntity) ? (CoverableTileEntity) baseTile diff --git a/src/main/java/gregtech/api/net/GT_Packet_MultiTileEntity.java b/src/main/java/gregtech/api/net/GT_Packet_MultiTileEntity.java index 98f6f11aec..b31355adad 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_MultiTileEntity.java +++ b/src/main/java/gregtech/api/net/GT_Packet_MultiTileEntity.java @@ -100,7 +100,7 @@ public class GT_Packet_MultiTileEntity extends GT_Packet_New { } /** - * + * * @param boolToSync each bit of the integer will be a boolean. */ public void setBooleans(int boolToSync) { @@ -213,11 +213,13 @@ public class GT_Packet_MultiTileEntity extends GT_Packet_New { } if ((packetFeatures & INVENTORY_NAME) == INVENTORY_NAME) { int tLength = aData.readInt(); - String tName = ""; + String tName; if (tLength > 0) { + StringBuilder tNameBuilder = new StringBuilder(); for (int i = 0; i < tLength; i++) { - tName += aData.readChar(); + tNameBuilder.append(aData.readChar()); } + tName = tNameBuilder.toString(); } else { tName = null; } @@ -241,8 +243,7 @@ public class GT_Packet_MultiTileEntity extends GT_Packet_New { final TileEntity tTileEntity = aWorld.getTileEntity(mX, mY, mZ); try { final Block tBlock = aWorld.getBlock(mX, mY, mZ); - if (tBlock instanceof MultiTileEntityBlock) { - final MultiTileEntityBlock mteBlock = (MultiTileEntityBlock) tBlock; + if (tBlock instanceof MultiTileEntityBlock mteBlock) { final IMultiTileEntity mte = mteBlock.receiveMultiTileEntityData(aWorld, mX, mY, mZ, mRID, mID); if (mte == null) return; mte.receiveClientEvent(GregTechTileClientEvents.CHANGE_COMMON_DATA, mCommonData); @@ -255,8 +256,7 @@ public class GT_Packet_MultiTileEntity extends GT_Packet_New { mte.receiveClientEvent(GregTechTileClientEvents.CHANGE_REDSTONE_OUTPUT, mRedstone); } - if ((features & MODES) == MODES && mte instanceof IMultiTileEntity.IMTE_HasModes) { - final IMultiTileEntity.IMTE_HasModes mteModes = (IMultiTileEntity.IMTE_HasModes) mte; + if ((features & MODES) == MODES && mte instanceof IMultiTileEntity.IMTE_HasModes mteModes) { mteModes.setMode(mMode); mteModes.setAllowedModes(mAllowedModes); } @@ -271,8 +271,7 @@ public class GT_Packet_MultiTileEntity extends GT_Packet_New { mtePart.setLockedInventoryIndex(mLockedInventoryIndex); } - if ((features & INVENTORY_NAME) == INVENTORY_NAME && mte instanceof InventoryUpgrade) { - final InventoryUpgrade invUpg = (InventoryUpgrade) mte; + if ((features & INVENTORY_NAME) == INVENTORY_NAME && mte instanceof InventoryUpgrade invUpg) { invUpg.setInventoryName(mInventoryName); } diff --git a/src/main/java/gregtech/api/net/GT_Packet_RequestCoverData.java b/src/main/java/gregtech/api/net/GT_Packet_RequestCoverData.java index e997c8feb9..e1ac057aa4 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_RequestCoverData.java +++ b/src/main/java/gregtech/api/net/GT_Packet_RequestCoverData.java @@ -102,8 +102,7 @@ public class GT_Packet_RequestCoverData extends GT_Packet_New { final World world = DimensionManager.getWorld(mPlayer.dimension); if (world != null) { final TileEntity tile = world.getTileEntity(mX, mY, mZ); - if (tile instanceof CoverableTileEntity) { - final CoverableTileEntity te = (CoverableTileEntity) tile; + if (tile instanceof CoverableTileEntity te) { if (!te.isDead() && te.getCoverIDAtSide(side) == coverID) { te.issueCoverUpdate(side); } diff --git a/src/main/java/gregtech/api/net/GT_Packet_SetLockedFluid.java b/src/main/java/gregtech/api/net/GT_Packet_SetLockedFluid.java index a96d33bda6..0252201ba3 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_SetLockedFluid.java +++ b/src/main/java/gregtech/api/net/GT_Packet_SetLockedFluid.java @@ -80,10 +80,9 @@ public class GT_Packet_SetLockedFluid extends GT_Packet_New { TileEntity tile = world.getTileEntity(mX, mY, mZ); if (!(tile instanceof IGregTechTileEntity) || ((IGregTechTileEntity) tile).isDead()) return; IMetaTileEntity mte = ((IGregTechTileEntity) tile).getMetaTileEntity(); - if (!(mte instanceof IFluidLockable)) return; + if (!(mte instanceof IFluidLockable mteToLock)) return; Fluid tFluid = FluidRegistry.getFluid(mFluidID); if (tFluid == null) return; - IFluidLockable mteToLock = (IFluidLockable) mte; if (!mteToLock.allowChangingLockedFluid(tFluid.getName())) return; mteToLock.lockFluid(true); diff --git a/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverGUI.java b/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverGUI.java index 86321f9287..25d4adf8e1 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverGUI.java +++ b/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverGUI.java @@ -191,8 +191,7 @@ public class GT_Packet_TileEntityCoverGUI extends GT_Packet_New { // Using EntityPlayer instead of EntityClientPlayerMP so both client and server can load this final EntityPlayer thePlayer = ((EntityPlayer) ((World) aWorld).getEntityByID(playerID)); final TileEntity tile = aWorld.getTileEntity(mX, mY, mZ); - if (tile instanceof IGregTechTileEntity && !((IGregTechTileEntity) tile).isDead()) { - final IGregTechTileEntity gtTile = ((IGregTechTileEntity) tile); + if (tile instanceof IGregTechTileEntity gtTile && !((IGregTechTileEntity) tile).isDead()) { gtTile.setCoverDataAtSide(side, coverData); // Set it client side to read later. GT_CoverBehaviorBase<?> cover = gtTile.getCoverBehaviorAtSideNew(side); diff --git a/src/main/java/gregtech/api/objects/AE2DigitalChestHandler.java b/src/main/java/gregtech/api/objects/AE2DigitalChestHandler.java index 06ab3788b3..6bbab251ba 100644 --- a/src/main/java/gregtech/api/objects/AE2DigitalChestHandler.java +++ b/src/main/java/gregtech/api/objects/AE2DigitalChestHandler.java @@ -16,7 +16,7 @@ public class AE2DigitalChestHandler implements appeng.api.storage.IExternalStora } @Override - public appeng.api.storage.IMEInventory getInventory(final TileEntity te, final ForgeDirection d, + public appeng.api.storage.IMEInventory<?> getInventory(final TileEntity te, final ForgeDirection d, final appeng.api.storage.StorageChannel chan, final appeng.api.networking.security.BaseActionSource src) { if (chan == appeng.api.storage.StorageChannel.ITEMS) { return ((GT_MetaTileEntity_DigitalChestBase) (((BaseMetaTileEntity) te).getMetaTileEntity())); diff --git a/src/main/java/gregtech/api/objects/GT_ArrayList.java b/src/main/java/gregtech/api/objects/GT_ArrayList.java index 50eb3ebcc1..9124ef8616 100644 --- a/src/main/java/gregtech/api/objects/GT_ArrayList.java +++ b/src/main/java/gregtech/api/objects/GT_ArrayList.java @@ -19,6 +19,7 @@ public class GT_ArrayList<E> extends ArrayList<E> { mAllowNulls = aAllowNulls; } + @SafeVarargs public GT_ArrayList(boolean aAllowNulls, E... aArray) { super(Arrays.asList(aArray)); mAllowNulls = aAllowNulls; diff --git a/src/main/java/gregtech/api/objects/GT_HashSet.java b/src/main/java/gregtech/api/objects/GT_HashSet.java index 1f12b669b3..64ff0f10b0 100644 --- a/src/main/java/gregtech/api/objects/GT_HashSet.java +++ b/src/main/java/gregtech/api/objects/GT_HashSet.java @@ -38,7 +38,7 @@ public class GT_HashSet<E extends GT_ItemStack> extends AbstractSet<E> { GregTech_API.sItemStackMappings.add(map); } - public HashMap getMap() { + public Map<GT_ItemStack, Object> getMap() { return map; } diff --git a/src/main/java/gregtech/api/objects/ItemData.java b/src/main/java/gregtech/api/objects/ItemData.java index 72d5cc5900..4fe0320ca7 100644 --- a/src/main/java/gregtech/api/objects/ItemData.java +++ b/src/main/java/gregtech/api/objects/ItemData.java @@ -11,7 +11,7 @@ public class ItemData { private static final MaterialStack[] EMPTY_MATERIALSTACK_ARRAY = new MaterialStack[0]; - public final List<Object> mExtraData = new GT_ArrayList<Object>(false, 1); + public final List<Object> mExtraData = new GT_ArrayList<>(false, 1); public final OrePrefixes mPrefix; public final MaterialStack mMaterial; public final MaterialStack[] mByProducts; @@ -41,10 +41,10 @@ public class ItemData { MaterialStack[] tByProducts = aByProducts.length < 1 ? EMPTY_MATERIALSTACK_ARRAY : new MaterialStack[aByProducts.length]; int j = 0; - for (int i = 0; i < aByProducts.length; i++) if (aByProducts[i] != null && aByProducts[i].mMaterial != null) - tByProducts[j++] = aByProducts[i].clone(); + for (MaterialStack aByProduct : aByProducts) + if (aByProduct != null && aByProduct.mMaterial != null) tByProducts[j++] = aByProduct.clone(); mByProducts = j > 0 ? new MaterialStack[j] : EMPTY_MATERIALSTACK_ARRAY; - for (int i = 0; i < mByProducts.length; i++) mByProducts[i] = tByProducts[i]; + System.arraycopy(tByProducts, 0, mByProducts, 0, mByProducts.length); } } @@ -60,7 +60,7 @@ public class ItemData { mPrefix = null; mBlackListed = true; - ArrayList<MaterialStack> aList = new ArrayList<MaterialStack>(), rList = new ArrayList<MaterialStack>(); + ArrayList<MaterialStack> aList = new ArrayList<>(), rList = new ArrayList<>(); for (ItemData tData : aData) if (tData != null) { if (tData.hasValidMaterialData() && tData.mMaterial.mAmount > 0) aList.add(tData.mMaterial.clone()); @@ -77,13 +77,7 @@ public class ItemData { if (temp) rList.add(aMaterial.clone()); } - Collections.sort(rList, new Comparator<MaterialStack>() { - - @Override - public int compare(MaterialStack a, MaterialStack b) { - return a.mAmount == b.mAmount ? 0 : a.mAmount > b.mAmount ? -1 : +1; - } - }); + rList.sort((a, b) -> Long.compare(b.mAmount, a.mAmount)); if (rList.isEmpty()) { mMaterial = null; @@ -92,7 +86,7 @@ public class ItemData { rList.remove(0); } - mByProducts = rList.toArray(new MaterialStack[rList.size()]); + mByProducts = rList.toArray(new MaterialStack[0]); } public final boolean hasValidPrefixMaterialData() { @@ -108,7 +102,7 @@ public class ItemData { } public final ArrayList<MaterialStack> getAllMaterialStacks() { - ArrayList<MaterialStack> rList = new ArrayList(); + ArrayList<MaterialStack> rList = new ArrayList<>(); if (hasValidMaterialData()) rList.add(mMaterial); rList.addAll(Arrays.asList(mByProducts)); return rList; 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); + }; } /** diff --git a/src/main/java/gregtech/api/world/GT_Worldgen.java b/src/main/java/gregtech/api/world/GT_Worldgen.java index 742651b02a..ae6fc930a4 100644 --- a/src/main/java/gregtech/api/world/GT_Worldgen.java +++ b/src/main/java/gregtech/api/world/GT_Worldgen.java @@ -14,8 +14,9 @@ public abstract class GT_Worldgen { public final String mWorldGenName; public final boolean mEnabled; - private final Map<String, Boolean> mDimensionMap = new ConcurrentHashMap<String, Boolean>(); + private final Map<String, Boolean> mDimensionMap = new ConcurrentHashMap<>(); + @SuppressWarnings({ "unchecked", "rawtypes" }) // The adding of "this" needs a List<this> which does not exist public GT_Worldgen(String aName, List aList, boolean aDefault) { mWorldGenName = aName; mEnabled = GregTech_API.sWorldgenFile.get("worldgen", mWorldGenName, aDefault); diff --git a/src/main/java/gregtech/api/world/GT_Worldgen_Ore.java b/src/main/java/gregtech/api/world/GT_Worldgen_Ore.java index d3aa6b0e10..c40b3dfe13 100644 --- a/src/main/java/gregtech/api/world/GT_Worldgen_Ore.java +++ b/src/main/java/gregtech/api/world/GT_Worldgen_Ore.java @@ -27,7 +27,7 @@ public abstract class GT_Worldgen_Ore extends GT_Worldgen { mSize = GregTech_API.sWorldgenFile.get(aTextWorldgen + mWorldGenName, "Size", aSize); mMinY = GregTech_API.sWorldgenFile.get(aTextWorldgen + mWorldGenName, "MinHeight", aMinY); mMaxY = GregTech_API.sWorldgenFile.get(aTextWorldgen + mWorldGenName, "MaxHeight", aMaxY); - if (aBiomeList == null) mBiomeList = new ArrayList<String>(); + if (aBiomeList == null) mBiomeList = new ArrayList<>(); else mBiomeList = aBiomeList; mAllowToGenerateinVoid = aAllowToGenerateinVoid; } |