diff options
author | chill <chill.gtnh@outlook.com> | 2023-06-05 06:51:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-05 06:51:28 +0200 |
commit | db089891a20e5696096907864578e39586035e6e (patch) | |
tree | e56d68eb64c3b8025193930b68e731b23d0f60d9 /src/main/java/gregtech/api/util | |
parent | dd9bbe334a00a0435502ac502d4155bfa12d123d (diff) | |
download | GT5-Unofficial-db089891a20e5696096907864578e39586035e6e.tar.gz GT5-Unofficial-db089891a20e5696096907864578e39586035e6e.tar.bz2 GT5-Unofficial-db089891a20e5696096907864578e39586035e6e.zip |
Code cleanup (#2040)
* remove redundant suppressions
* prettify commented code
* improve comments
The integer comment contradicted the code, so I deleted it.
* delete commented-out code
* update bitwise int flip from XOR to the dedicated tilda operator
The flip was a 32-bit XOR, which is an int-flip.
That XOR was replaced with an equivalent tilda operator.
* convert a field to inline
This field was used only once, so put it straight to where it is used.
* remove fluid fix since no-one uses Forge version 1355 or earlier
* unwrap switches where fitting
In some places, we suppress IntelliJ's inspection
RedundantLabeledSwitchRuleCodeBlock - we don't want to unwrap some of
the suggested cases because we want to keep the consistency in a
switch statement for the sake of readability.
* fuse "collect" into Stream API
* fix javadocs
* remove unnecessary public modifiers from an interface
Members of an interface are public by default.
* move common parts outside of if
* suppress OverrideOnly warning in a javadoc
* remove unused lock
* suppress warnings about unchecked casts
These warnings require non-trivial fixes that are yet to arrive.
For now, let's suppress them to reduce the warning-bloat.
* remove outdated comment
* remove final modifier from private methods
Because they are private, it is hard to accidentally overwrite them.
Therefore, the final modifier is redundant in this case.
* refactor getIcon
The first 'if' doesn't cover only tMeta == 9 && mConnectedMachineTextures,
therefore the second if can be unrolled.
The last switch is redundant because all tMeta values are covered by
switches, but let's keep SOLID_STEEL as a fallback just in case.
* explain what the casings are and why block casings are split
* suppress switch-to-if suggestion
* remove unnecessary null check
The null is handled in doGenerateItem()
* address redundant local variables
* rename variables in onTick
* suppress warning about accessing static member via instance
* rephrase exception
* rephrase javadoc
* address field-can-be-final warnings
* remove empty methods
* enum cannot inherit, so protected is redundant
* remove redundant throws
* update imports to be not wildcard
* remove unnecessary try-catch
* update for loop
* remove redundant code in order to use the diamond operator
* update instanceof to use pattern variables
* replace blank lines with <p> in javadocs
* fix dangling javadocs
* suppress warning about unreachable methods in javadocs
* remove redundant operation
* add the descriptions of parameters in javadocs
Also fix javadocs along the way.
* relax returned type in javadoc
That was done in order to make the docs reflect the code more often.
Otherwise, people may forget to change the returned type again with
another change.
* make long conversion explicit
Integer multiplication can give a wrong result if one of the parts is
not explicitly cast to long. Let's cast one of the parts where
applicable.
* remove unary plus
* simplify unary minus
* use addAll instead of forEach,add
It was suggested by IntelliJ to replace the iteration with a bulk operation
to improve performance.
* replace .asList with .singletonList for consistency
* simplify toArray calls
Explanation from IntelliJ:
There are two styles to convert a collection to an array:
* A pre-sized array, for example, c.toArray(new String[c.size()])
* An empty array, for example, c.toArray(new String[0])
In older Java versions, using a pre-sized array was recommended, as the
reflection call necessary to create an array of proper size was quite slow.
However, since late updates of OpenJDK 6, this call was intrinsified, making
the performance of the empty array version the same, and sometimes even better,
compared to the pre-sized version. Also, passing a pre-sized array is dangerous
for a concurrent or synchronized collection as a data race is possible between
the size and toArray calls. This may result in extra nulls at the end of the
array if the collection was concurrently shrunk during the operation.
* split StringBuilder append
Explanation by IntelliJ:
Reports String concatenation used as the argument to appends.
Such calls may profitably be turned into chained append calls on the existing
StringBuilder saving the cost of an extra StringBuilder allocation. This
inspection ignores compile-time evaluated String concatenations,
in which case the conversion would only worsen performance.
* annotate overriding methods with @Nonnull where needed
The method that was overridden has @Nonnull so the method that is overriding
should also have @Nonnull.
* remove set adding itself to itself
* remove null check because findField either works or blows up
cpw.mods.fml.relauncher.ReflectionHelper::findField either returns a non-null
value or throws a RuntimeException, so no need to check of null.
* remove slot comparison with tInventory.length
slot max value is 127 when tInventory.length is set to 256, which results in
that the condition is always true and unnecessary.
* remove aOutput2 null check
As GT_Values.NI is null, there is no need to check aOutput2 for null again
* suppress the suggestion to delete tMeta < 13
mConnectedMachineTextures can change, so tMeta range is not guaranteed
* remove aCoverVariable % 3 < 2
the if above already limits the result of % 3 to "2", so the condition
"less than 2" is always false.
* unwrap "if" because bonus is unchanged
Unwrap if because even if the bonus is a variable, it hasn't been changed for
the past 8 years and is unlikely to be changed in the future.
* reformat javadoc
* improve ignoring an exception
Make them either more clear or concise
* fixup fix typo
* update deprecated calls of newInstance()
* remove testing BaseMetaTileEntity
GregTech_API.constructBaseMetaTileEntity() checks the creation by itself,
logging and throwing a runtime error if failed.
* unwrap hatch-fill for do_SolarSalt
To reach this branch, do_coolant needs to be false and we need to still be in
the function, which means that do_SolarSalt was set to true in the previous
top-tier "if".
* remove always-false input-bus checks of MTE PlasmaForge
size() is non-negative, and the values it is compared to are final and 0.
* length and size are non-negative
Therefore, there's no need to check their negativity
* aOutput is guaranteed to be positive
* tThereWasARecipe is always false when reached in its first occurrence
* convert an assert into if
Only tStack 2 is checked for null because if it isn't null then
tStack1 also isn't null based on the "if" above.
Also IntelliJ was sure that tStack is not null for some reason.
On a side note, assertions work only either with a specified flag
or in debug runs. Therefore, it is dangerous to rely on them.
* simplify stone-gravel-cobble if
tBlock != Blocks.stone because of the if at the start of the method.
for the last else-if, tBlock == Blocks.gravel because of the check slightly
above the change.
* interDimensional is always true because of the first if
* convert an example to javadoc
* remove always-false statements
* replace referential string equality with equals
If we compare strings by "==", we compare references to them, which is not
what we usually want. I wasn't sure if String Pool works here, so I played
it save with equals().
* use Automatic Resource Management for AutoCloseable ByteBufOutputStream
* add todo to swap from sleep to event bus
* null is checked by instanceof
* merge switch branches
* add a TODO to use clamp()
* new String declaration is redundant
* use getOrDefault for a map
* replace StringBuilder with concatenation where fitting
Using a StringBuilder to concatenate two string will not make the program
faster or more understandable, so I swapped it to concatenation.
* remove unnecessary continue
* flip if
* remove redundant returns
* unwrap ifs
It's checked at the top "if" that aType == IItemRenderer.ItemRenderType.INVENTORY,
so all aType.equals(IItemRenderer.ItemRenderType.INVENTORY below are always true.
* remove checking all GT VERSIONs except the API one
* remove version check from GT_Mod and delete respective VERSION fields
Aside from GregTech_API.VERSION, these fields are not used anywhere
in the project, so only GregTech_API.VERSION was kept.
The idea and the usage check were done by miozune.
Diffstat (limited to 'src/main/java/gregtech/api/util')
23 files changed, 260 insertions, 192 deletions
diff --git a/src/main/java/gregtech/api/util/ColorsMetadataSectionSerializer.java b/src/main/java/gregtech/api/util/ColorsMetadataSectionSerializer.java index f898049e46..389662d041 100644 --- a/src/main/java/gregtech/api/util/ColorsMetadataSectionSerializer.java +++ b/src/main/java/gregtech/api/util/ColorsMetadataSectionSerializer.java @@ -68,8 +68,7 @@ public class ColorsMetadataSectionSerializer extends BaseMetadataSectionSerializ } public JsonElement serialize(ColorsMetadataSection colorsMetaSection, Type type, JsonSerializationContext context) { - JsonObject jsonObject = new JsonObject(); - return jsonObject; + return new JsonObject(); } public String getSectionName() { diff --git a/src/main/java/gregtech/api/util/GT_ApiaryUpgrade.java b/src/main/java/gregtech/api/util/GT_ApiaryUpgrade.java index de46309a9f..a31038dd60 100644 --- a/src/main/java/gregtech/api/util/GT_ApiaryUpgrade.java +++ b/src/main/java/gregtech/api/util/GT_ApiaryUpgrade.java @@ -1,6 +1,10 @@ package gregtech.api.util; -import java.util.*; +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.HashSet; import java.util.function.BiConsumer; import java.util.function.Consumer; diff --git a/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java b/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java index 077964cb69..1eba5c843c 100644 --- a/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java +++ b/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java @@ -320,8 +320,7 @@ public class GT_AssemblyLineUtils { */ public static ItemStack getDataStickOutput(ItemStack aDataStick) { if (doesDataStickHaveOutput(aDataStick)) { - ItemStack aOutput = GT_Utility.loadItem(aDataStick.getTagCompound(), "output"); - return aOutput; + return GT_Utility.loadItem(aDataStick.getTagCompound(), "output"); } return null; } 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 e5889a6442..1881ab015a 100644 --- a/src/main/java/gregtech/api/util/GT_Assemblyline_Server.java +++ b/src/main/java/gregtech/api/util/GT_Assemblyline_Server.java @@ -23,9 +23,8 @@ public class GT_Assemblyline_Server { public static void fillMap(FMLPreInitializationEvent aEvent) { - String s = new String( - aEvent.getModConfigurationDirectory() - .getAbsolutePath()); + String s = aEvent.getModConfigurationDirectory() + .getAbsolutePath(); s = s.substring( 0, aEvent.getModConfigurationDirectory() diff --git a/src/main/java/gregtech/api/util/GT_BaseCrop.java b/src/main/java/gregtech/api/util/GT_BaseCrop.java index 456ba50ff1..90c1619472 100644 --- a/src/main/java/gregtech/api/util/GT_BaseCrop.java +++ b/src/main/java/gregtech/api/util/GT_BaseCrop.java @@ -253,18 +253,6 @@ public class GT_BaseCrop extends CropCard implements ICropCardInfo { return true; } } - // Block block = aCrop.getWorld().getBlock(aCrop.getLocation().posX, aCrop.getLocation().posY - i, - // aCrop.getLocation().posZ); - // if (block.isAir(aCrop.getWorld(), aCrop.getLocation().posX, aCrop.getLocation().posY - i, - // aCrop.getLocation().posZ)) { - // return false; - // } - // if (block == mBlock) { - // int tMeta = aCrop.getWorld().getBlockMetadata(aCrop.getLocation().posX, aCrop.getLocation().posY - - // i, aCrop.getLocation().posZ); - // if(mMeta < 0 || tMeta == mMeta){ - // return true;} - // } } return false; } 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 0d3864e26f..c560435e30 100644 --- a/src/main/java/gregtech/api/util/GT_CLS_Compat.java +++ b/src/main/java/gregtech/api/util/GT_CLS_Compat.java @@ -119,7 +119,7 @@ public class GT_CLS_Compat { } public static void stepMaterialsCLS(Collection<GT_Proxy.OreDictEventContainer> mEvents, - ProgressManager.ProgressBar progressBar) throws IllegalAccessException, InvocationTargetException { + ProgressManager.ProgressBar progressBar) throws IllegalAccessException { try { isRegisteringGTmaterials.set(null, true); } catch (IllegalArgumentException | IllegalAccessException e) { @@ -136,7 +136,7 @@ public class GT_CLS_Compat { } public static void doActualRegistrationCLS(ProgressManager.ProgressBar progressBar, - Set<Materials> replacedVanillaItemsSet) throws InvocationTargetException, IllegalAccessException { + Set<Materials> replacedVanillaItemsSet) { try { isReplacingVanillaMaterials.set(null, true); } catch (IllegalArgumentException | IllegalAccessException e) { diff --git a/src/main/java/gregtech/api/util/GT_CircuitryBehavior.java b/src/main/java/gregtech/api/util/GT_CircuitryBehavior.java index d5cd50049e..63fb7d1e70 100644 --- a/src/main/java/gregtech/api/util/GT_CircuitryBehavior.java +++ b/src/main/java/gregtech/api/util/GT_CircuitryBehavior.java @@ -107,9 +107,7 @@ public abstract class GT_CircuitryBehavior { return tRedstoneAmount; } - /***************** - * GUI Functions * - *****************/ + // region GUI Functions /** * returns the weakest incoming non-zero RS-Power @@ -167,9 +165,9 @@ public abstract class GT_CircuitryBehavior { */ public abstract void validateParameters(int[] aCircuitData, IRedstoneCircuitBlock aRedstoneCircuitBlock); - /**************************** - * Useful Utility Functions * - ****************************/ + // endregion + + // region Utility Functions /** * Called every tick if the Block has enough Energy and if the Block is Active @@ -210,4 +208,5 @@ public abstract class GT_CircuitryBehavior { public String getDataDisplay(int[] aCircuitData, int aCircuitDataIndex) { return null; } + // endregion } diff --git a/src/main/java/gregtech/api/util/GT_CoverBehaviorBase.java b/src/main/java/gregtech/api/util/GT_CoverBehaviorBase.java index e1a49b998f..fdb4cbe7a4 100644 --- a/src/main/java/gregtech/api/util/GT_CoverBehaviorBase.java +++ b/src/main/java/gregtech/api/util/GT_CoverBehaviorBase.java @@ -137,7 +137,7 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { /** * Return whether cover data needs to be synced to client upon tile entity creation or cover placement. - * + * <p> * Note if you want to sync the data afterwards you will have to manually do it by calling * {@link ICoverable#issueCoverUpdate(ForgeDirection)} This option only affects the initial sync. */ @@ -508,9 +508,9 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { return colorOverride.getTextColorOrDefault(textType, defaultColor); } - protected Supplier<Integer> COLOR_TITLE = () -> getTextColorOrDefault("title", 0x222222); - protected Supplier<Integer> COLOR_TEXT_GRAY = () -> getTextColorOrDefault("text_gray", 0x555555); - protected Supplier<Integer> COLOR_TEXT_WARN = () -> getTextColorOrDefault("text_warn", 0xff0000); + protected final Supplier<Integer> COLOR_TITLE = () -> getTextColorOrDefault("title", 0x222222); + protected final Supplier<Integer> COLOR_TEXT_GRAY = () -> getTextColorOrDefault("text_gray", 0x555555); + protected final Supplier<Integer> COLOR_TEXT_WARN = () -> getTextColorOrDefault("text_warn", 0xff0000); } // endregion diff --git a/src/main/java/gregtech/api/util/GT_ExoticEnergyInputHelper.java b/src/main/java/gregtech/api/util/GT_ExoticEnergyInputHelper.java index dbb14222c0..8e5301bd0b 100644 --- a/src/main/java/gregtech/api/util/GT_ExoticEnergyInputHelper.java +++ b/src/main/java/gregtech/api/util/GT_ExoticEnergyInputHelper.java @@ -79,7 +79,7 @@ public class GT_ExoticEnergyInputHelper { public static long getAverageInputVoltageMulti(Collection<? extends GT_MetaTileEntity_Hatch> hatches) { long rVoltage = 0; - if (hatches.size() <= 0) { + if (hatches.size() == 0) { return rVoltage; } for (GT_MetaTileEntity_Hatch tHatch : hatches) diff --git a/src/main/java/gregtech/api/util/GT_HatchElementBuilder.java b/src/main/java/gregtech/api/util/GT_HatchElementBuilder.java index 194a29f8a2..2087ad755c 100644 --- a/src/main/java/gregtech/api/util/GT_HatchElementBuilder.java +++ b/src/main/java/gregtech/api/util/GT_HatchElementBuilder.java @@ -2,8 +2,19 @@ package gregtech.api.util; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import java.util.*; -import java.util.function.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.EnumSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.function.BiFunction; +import java.util.function.BiPredicate; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.function.Supplier; import java.util.stream.Collectors; import net.minecraft.block.Block; @@ -16,7 +27,12 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import com.gtnewhorizon.structurelib.StructureLibAPI; -import com.gtnewhorizon.structurelib.structure.*; +import com.gtnewhorizon.structurelib.structure.AutoPlaceEnvironment; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureElement; +import com.gtnewhorizon.structurelib.structure.IStructureElementChain; +import com.gtnewhorizon.structurelib.structure.IStructureElementNoPlacement; +import com.gtnewhorizon.structurelib.structure.StructureUtility; import com.gtnewhorizon.structurelib.util.ItemStackPredicate; import gnu.trove.TIntCollection; diff --git a/src/main/java/gregtech/api/util/GT_LanguageManager.java b/src/main/java/gregtech/api/util/GT_LanguageManager.java index eeaa12a9ed..5bc2d0e9b1 100644 --- a/src/main/java/gregtech/api/util/GT_LanguageManager.java +++ b/src/main/java/gregtech/api/util/GT_LanguageManager.java @@ -26,6 +26,7 @@ public class GT_LanguageManager { public static boolean sUseEnglishFile = false; public static boolean i18nPlaceholder = true; + // TODO: convert to enum public static String FACE_ANY = "gt.lang.face.any", FACE_BOTTOM = "gt.lang.face.bottom", FACE_TOP = "gt.lang.face.top", FACE_LEFT = "gt.lang.face.left", FACE_FRONT = "gt.lang.face.front", FACE_RIGHT = "gt.lang.face.right", FACE_BACK = "gt.lang.face.back", FACE_NONE = "gt.lang.face.none"; diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java index 21675a58a4..f0add071fd 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -91,7 +91,6 @@ public class GT_ModHandler { private static final List<ItemStack> delayedRemovalByOutput = new ArrayList<>(); private static final List<InventoryCrafting> delayedRemovalByRecipe = new ArrayList<>(); - public static volatile int VERSION = 509; public static Collection<String> sNativeRecipeClasses = new HashSet<>(), sSpecialRecipeClasses = new HashSet<>(); public static GT_HashSet<GT_ItemStack> sNonReplaceableItems = new GT_HashSet<>(); public static Object sBoxableWrapper = new GT_IBoxableWrapper(); @@ -862,11 +861,11 @@ public class GT_ModHandler { */ @Deprecated public static boolean addThermalCentrifugeRecipe(ItemStack aInput, int[] aChances, int aHeat, Object... aOutput) { - if (aInput == null || aOutput == null || aOutput.length <= 0 || aOutput[0] == null) return false; + if (aInput == null || aOutput == null || aOutput.length == 0 || aOutput[0] == null) return false; if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.thermalcentrifuge, aInput, true)) return false; RA.addThermalCentrifugeRecipe( aInput, - aOutput.length >= 1 ? (ItemStack) aOutput[0] : null, + (ItemStack) aOutput[0], aOutput.length >= 2 ? (ItemStack) aOutput[1] : null, aOutput.length >= 3 ? (ItemStack) aOutput[2] : null, aChances, @@ -877,11 +876,11 @@ public class GT_ModHandler { @Deprecated public static boolean addThermalCentrifugeRecipe(ItemStack aInput, int aHeat, Object... aOutput) { - if (aInput == null || aOutput == null || aOutput.length <= 0 || aOutput[0] == null) return false; + if (aInput == null || aOutput == null || aOutput.length == 0 || aOutput[0] == null) return false; if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.thermalcentrifuge, aInput, true)) return false; RA.addThermalCentrifugeRecipe( aInput, - aOutput.length >= 1 ? (ItemStack) aOutput[0] : null, + (ItemStack) aOutput[0], aOutput.length >= 2 ? (ItemStack) aOutput[1] : null, aOutput.length >= 3 ? (ItemStack) aOutput[2] : null, 500, @@ -893,7 +892,7 @@ public class GT_ModHandler { * IC2-OreWasher Recipe. Overloads old Recipes automatically */ public static boolean addOreWasherRecipe(ItemStack aInput, int[] aChances, int aWaterAmount, Object... aOutput) { - if (aInput == null || aOutput == null || aOutput.length <= 0 || aOutput[0] == null) return false; + if (aInput == null || aOutput == null || aOutput.length == 0 || aOutput[0] == null) return false; if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.orewashing, aInput, true)) return false; RA.addOreWasherRecipe( aInput, @@ -917,7 +916,7 @@ public class GT_ModHandler { } public static boolean addOreWasherRecipe(ItemStack aInput, int aWaterAmount, Object... aOutput) { - if (aInput == null || aOutput == null || aOutput.length <= 0 || aOutput[0] == null) return false; + if (aInput == null || aOutput == null || aOutput.length == 0 || aOutput[0] == null) return false; if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.orewashing, aInput, true)) return false; RA.addOreWasherRecipe( aInput, @@ -1097,11 +1096,14 @@ public class GT_ModHandler { boolean aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT, boolean aRemoveAllOtherShapedsWithSameOutput, boolean aRemoveAllOtherNativeRecipes, boolean aCheckForCollisions, boolean aOnlyAddIfThereIsAnyRecipeOutputtingThis, boolean aOnlyAddIfResultIsNotNull, Object[] aRecipe) { + aResult = GT_OreDictUnificator.get(true, aResult); if (aOnlyAddIfResultIsNotNull && aResult == null) return false; if (aResult != null && Items.feather.getDamage(aResult) == W) Items.feather.setDamage(aResult, 0); - if (aRecipe == null || aRecipe.length <= 0) return false; + if (aRecipe == null || aRecipe.length == 0) return false; + // The renamed variable clarifies what's happening + // noinspection UnnecessaryLocalVariable boolean tDoWeCareIfThereWasARecipe = aOnlyAddIfThereIsAnyRecipeOutputtingThis; boolean tThereWasARecipe = false; @@ -1270,8 +1272,7 @@ public class GT_ModHandler { if (tRecipe[x] != null && Items.feather.getDamage(tRecipe[x]) == W) Items.feather.setDamage(tRecipe[x], 0); } - if (tDoWeCareIfThereWasARecipe || !aBuffered) - tThereWasARecipe = removeRecipe(tRecipe) != null || tThereWasARecipe; + if (tDoWeCareIfThereWasARecipe || !aBuffered) tThereWasARecipe = removeRecipe(tRecipe) != null; else removeRecipeDelayed(tRecipe); } } catch (Throwable e) { @@ -1385,7 +1386,7 @@ public class GT_ModHandler { int[] aEnchantmentLevelsAdded, boolean aBuffered, boolean aKeepNBT, boolean aDismantleable, boolean aRemovable, Object[] aRecipe) { aResult = GT_OreDictUnificator.get(true, aResult); - if (aRecipe == null || aRecipe.length <= 0) return false; + 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(); @@ -1542,7 +1543,6 @@ public class GT_ModHandler { delayedRemovalByRecipe.add(aCrafting); } - @SuppressWarnings("unchecked") public static void bulkRemoveByRecipe(List<InventoryCrafting> toRemove) { ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance() .getRecipeList(); @@ -1699,8 +1699,7 @@ public class GT_ModHandler { } } - if (tIndex == 2) { - assert tStack1 != null && tStack2 != null; + if (tIndex == 2 && tStack2 != null) { if (tStack1.getItem() == tStack2.getItem() && tStack1.stackSize == 1 && tStack2.stackSize == 1 && tStack1.getItem() @@ -1733,7 +1732,6 @@ public class GT_ModHandler { /** * Gives you a copy of the Output from a Crafting Recipe Used for Recipe Detection. */ - @SuppressWarnings("unchecked") public static ItemStack getRecipeOutput(boolean aUncopiedStack, boolean allowOreDict, ItemStack... aRecipe) { if (aRecipe == null || Arrays.stream(aRecipe) .noneMatch(Objects::nonNull)) return null; @@ -1993,7 +1991,7 @@ public class GT_ModHandler { */ public static ItemStack[] getMachineOutput(ItemStack aInput, Map<IRecipeInput, RecipeOutput> aRecipeList, boolean aRemoveInput, NBTTagCompound rRecipeMetaData, ItemStack... aOutputSlots) { - if (aOutputSlots == null || aOutputSlots.length <= 0) return new ItemStack[0]; + if (aOutputSlots == null || aOutputSlots.length == 0) return new ItemStack[0]; if (aInput == null) return new ItemStack[aOutputSlots.length]; try { for (Entry<IRecipeInput, RecipeOutput> tEntry : aRecipeList.entrySet()) { @@ -2136,8 +2134,6 @@ public class GT_ModHandler { aCharge, V[Math.max(0, Math.min(V.length - 1, tTier))] + B[Math.max(0, Math.min(V.length - 1, tTier))]); if (aCharge > 0) { - // int rCharge = Math.max(0, ic2.api.item.ElectricItem.manager.discharge(aStack, aCharge + - // (aCharge * 4 > aTier ? aTier : 0), tTier, T, aSimulate)); int rCharge = (int) Math.max( 0, ic2.api.item.ElectricItem.manager.discharge( @@ -2197,13 +2193,12 @@ public class GT_ModHandler { */ public static boolean damageOrDechargeItem(ItemStack aStack, int aDamage, int aDecharge, EntityLivingBase aPlayer) { if (GT_Utility.isStackInvalid(aStack) || (aStack.getMaxStackSize() <= 1 && aStack.stackSize > 1)) return false; - if (aPlayer != null && aPlayer instanceof EntityPlayer && ((EntityPlayer) aPlayer).capabilities.isCreativeMode) - return true; + if (aPlayer instanceof EntityPlayer && ((EntityPlayer) aPlayer).capabilities.isCreativeMode) return true; if (aStack.getItem() instanceof IDamagableItem) { return ((IDamagableItem) aStack.getItem()).doDamageToItem(aStack, aDamage); } else if (GT_ModHandler.isElectricItem(aStack)) { if (canUseElectricItem(aStack, aDecharge)) { - if (aPlayer != null && aPlayer instanceof EntityPlayer) { + if (aPlayer instanceof EntityPlayer) { return GT_ModHandler.useElectricItem(aStack, aDecharge, (EntityPlayer) aPlayer); } return GT_ModHandler.dischargeElectricItem(aStack, aDecharge, Integer.MAX_VALUE, true, false, true) diff --git a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java index 85e423b032..d6be321854 100644 --- a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java +++ b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java @@ -44,7 +44,6 @@ public class GT_OreDictUnificator { private static final Map<GT_ItemStack2, ItemData> sItemStack2DataMap = new HashMap<>(); private static final Map<GT_ItemStack2, List<ItemStack>> sUnificationTable = new HashMap<>(); private static final Set<GT_ItemStack2> sNoUnificationList = new HashSet<>(); - public static volatile int VERSION = 509; private static int isRegisteringOre = 0, isAddingOre = 0; private static boolean mRunThroughTheList = true; @@ -114,16 +113,12 @@ public class GT_OreDictUnificator { } public static ItemStack get(OrePrefixes aPrefix, Object aMaterial, ItemStack aReplacement, long aAmount) { - // if (Materials.mDefaultComponents.contains(aPrefix) && !aPrefix.mDynamicItems.contains((Materials)aMaterial)) - // aPrefix.mDynamicItems.add((Materials) aMaterial); if (OrePrefixes.mPreventableComponents.contains(aPrefix) && aPrefix.mDisabledItems.contains(aMaterial)) return aReplacement; return get(aPrefix.get(aMaterial), aReplacement, aAmount, false, true); } public static ItemStack get(OrePrefixes aPrefix, Object aMaterial, long aAmount, boolean aNoInvalidAmounts) { - // if (Materials.mDefaultComponents.contains(aPrefix) && !aPrefix.mDynamicItems.contains((Materials)aMaterial)) - // aPrefix.mDynamicItems.add((Materials) aMaterial); if (OrePrefixes.mPreventableComponents.contains(aPrefix) && aPrefix.mDisabledItems.contains(aMaterial)) return null; return get(aPrefix.get(aMaterial), null, aAmount, false, aNoInvalidAmounts); @@ -136,10 +131,6 @@ public class GT_OreDictUnificator { if (stackFromName != null) return GT_Utility.copyAmount(aAmount, stackFromName); if (aMentionPossibleTypos) { GT_Log.err.println("Unknown Key for Unification, Typo? " + aName); - // Debug callstack of entries not in sName2StackMap - // StackTraceElement[] cause = Thread.currentThread().getStackTrace(); - // GT_Log.err.println(Arrays.toString(cause)); - } final ItemStack stackFirstOre = getFirstOre(aName, aAmount); if (stackFirstOre != null) return GT_Utility.copyAmount(aAmount, stackFirstOre); diff --git a/src/main/java/gregtech/api/util/GT_OverclockCalculator.java b/src/main/java/gregtech/api/util/GT_OverclockCalculator.java index ab32772c78..ba90240f14 100644 --- a/src/main/java/gregtech/api/util/GT_OverclockCalculator.java +++ b/src/main/java/gregtech/api/util/GT_OverclockCalculator.java @@ -3,38 +3,38 @@ package gregtech.api.util; public class GT_OverclockCalculator { /** - * @mAmps - Amperage of the multiblock - * @mEUt - Voltage of the multiblock - * @mRecipeEUt - Voltage the recipe will run at - * @mRecipeAmps - The amount of amps the recipe needs + * mAmps - Amperage of the multiblock + * mEUt - Voltage of the multiblock + * mRecipeEUt - Voltage the recipe will run at + * mRecipeAmps - The amount of amps the recipe needs */ private long mAmps = 1, mEUt = 0, mRecipeEUt = 0, mRecipeAmps = 1; /** - * @mEUtDiscount - Discount for EUt at the beginning of calculating overclocks, like GT++ machines - * @mSpeedBoost - Speeding/Slowing up/down the duration of a recipe at the beginning of calculating overclocks, like - * GT++ machines - * @mHeatDiscountAmont - The value used for discount final eut per 900 heat + * mEUtDiscount - Discount for EUt at the beginning of calculating overclocks, like GT++ machines + * mSpeedBoost - Speeding/Slowing up/down the duration of a recipe at the beginning of calculating overclocks, like + * GT++ machines + * mHeatDiscountAmount - The value used for discount final eut per 900 heat */ private float mEUtDiscount = 1, mSpeedBoost = 1, mHeatDiscountAmount = 0.95f; /** - * @mEUtIncreasePerOC - How much the bits should be moved to the left when it is overclocking (Going up, 2 meaning - * it is multiplied with 4x) - * @mDurationDecreasePerOC - How much the bits should be moved to the right when its overclocking (Going down, 1 - * meaning it is halved) - * @mDuration - Duration of the recipe - * @mParallel - The parallel the multi has when trying to overclock - * @mRecipeHeat - The min heat required for the recipe - * @mMultiHeat - The heat the multi has when starting the recipe - * @mHeatPerfectOC - How much the bits should be moved to the right for each 1800 above recipe heat (Used for - * duration) + * mEUtIncreasePerOC - How much the bits should be moved to the left when it is overclocking (Going up, 2 meaning + * it is multiplied with 4x) + * mDurationDecreasePerOC - How much the bits should be moved to the right when its overclocking (Going down, 1 + * meaning it is halved) + * mDuration - Duration of the recipe + * mParallel - The parallel the multi has when trying to overclock + * mRecipeHeat - The min heat required for the recipe + * mMultiHeat - The heat the multi has when starting the recipe + * mHeatPerfectOC - How much the bits should be moved to the right for each 1800 above recipe heat (Used for + * duration) */ private int mEUtIncreasePerOC = 2, mDurationDecreasePerOC = 1, mDuration = 0, mParallel = 1, mRecipeHeat = 0, mMultiHeat = 0, mHeatPerfectOC = 2; /** - * @mHeatOC - Whether to enable overclocking with heat like the EBF every 1800 heat difference - * @mOneTickDiscount - Whether to give EUt Discount when the duration goes below one tick - * @calculates - variable to check whether the overclocks have been calculated - * @mHeatDiscount - Whether to enable heat discounts every 900 heat difference + * mHeatOC - Whether to enable overclocking with heat like the EBF every 1800 heat difference + * mOneTickDiscount - Whether to give EUt Discount when the duration goes below one tick + * calculates - variable to check whether the overclocks have been calculated + * mHeatDiscount - Whether to enable heat discounts every 900 heat difference */ private boolean mHeatOC, mOneTickDiscount, calculated, mHeatDiscount; @@ -261,7 +261,7 @@ public class GT_OverclockCalculator { if (mOneTickDiscount) { int voltageDifference = GT_Utility.getTier(mEUt) - GT_Utility.getTier(mRecipeEUt); - mRecipeEUt >>= voltageDifference * mDurationDecreasePerOC; + mRecipeEUt >>= (long) voltageDifference * mDurationDecreasePerOC; if (mRecipeEUt < 1) { mRecipeEUt = 1; } diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 43dfd0c5b2..4e8db694af 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -1,27 +1,50 @@ package gregtech.api.util; -import static gregtech.api.enums.GT_Values.*; +import static gregtech.api.enums.GT_Values.D1; +import static gregtech.api.enums.GT_Values.D2; +import static gregtech.api.enums.GT_Values.E; +import static gregtech.api.enums.GT_Values.L; +import static gregtech.api.enums.GT_Values.W; import static gregtech.api.enums.Mods.GTPlusPlus; import static gregtech.api.enums.Mods.GregTech; import static gregtech.api.enums.Mods.NEICustomDiagrams; import static gregtech.api.enums.Mods.Railcraft; import static gregtech.api.util.GT_RecipeBuilder.handleRecipeCollision; import static gregtech.api.util.GT_RecipeConstants.ADDITIVE_AMOUNT; -import static gregtech.api.util.GT_RecipeMapUtil.*; +import static gregtech.api.util.GT_RecipeMapUtil.FIRST_FLUIDSTACK_INPUT; +import static gregtech.api.util.GT_RecipeMapUtil.FIRST_FLUIDSTACK_OUTPUT; +import static gregtech.api.util.GT_RecipeMapUtil.FIRST_FLUID_OUTPUT; +import static gregtech.api.util.GT_RecipeMapUtil.FIRST_ITEM_INPUT; +import static gregtech.api.util.GT_RecipeMapUtil.FIRST_ITEM_OR_FLUID_INPUT; +import static gregtech.api.util.GT_RecipeMapUtil.FIRST_ITEM_OR_FLUID_OUTPUT; +import static gregtech.api.util.GT_RecipeMapUtil.FIRST_ITEM_OUTPUT; +import static gregtech.api.util.GT_RecipeMapUtil.GT_RecipeTemplate; +import static gregtech.api.util.GT_RecipeMapUtil.SPECIAL_VALUE_ALIASES; +import static gregtech.api.util.GT_RecipeMapUtil.asTemplate; +import static gregtech.api.util.GT_RecipeMapUtil.buildOrEmpty; import static gregtech.api.util.GT_Utility.formatNumbers; import static gregtech.api.util.GT_Utility.isArrayEmptyOrNull; import static gregtech.api.util.GT_Utility.isArrayOfLength; import static net.minecraft.util.EnumChatFormatting.GRAY; import static net.minecraft.util.StatCollector.translateToLocal; -import java.awt.*; -import java.util.*; +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import net.minecraft.client.Minecraft; @@ -67,8 +90,15 @@ import gnu.trove.map.TByteObjectMap; import gnu.trove.map.hash.TByteObjectHashMap; import gregtech.GT_Mod; import gregtech.api.GregTech_API; -import gregtech.api.enums.*; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Element; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.SteamVariant; +import gregtech.api.enums.SubTag; import gregtech.api.gui.GT_GUIColorOverride; import gregtech.api.gui.modularui.FallbackableSteamTexture; import gregtech.api.gui.modularui.GT_UITextures; @@ -111,7 +141,6 @@ import mods.railcraft.common.items.RailcraftToolItems; */ public class GT_Recipe implements Comparable<GT_Recipe> { - public static volatile int VERSION = 509; /** * If you want to change the Output, feel free to modify or even replace the whole ItemStack Array, for Inputs, * please add a new Recipe, because of the HashMaps. @@ -912,7 +941,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { /** * THIS CONSTRUCTOR DOES SET THE PERSISTENT HASH. - * + * <p> * if you set one yourself, it will give you one of the RunetimeExceptions! */ public GT_Recipe_AssemblyLine(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, @@ -941,7 +970,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { /** * THIS CONSTRUCTOR DOES <b>NOT</b> SET THE PERSISTENT HASH. - * + * <p> * if you don't set one yourself, it will break a lot of stuff! */ public GT_Recipe_AssemblyLine(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, @@ -1283,10 +1312,6 @@ public class GT_Recipe implements Comparable<GT_Recipe> { .setSlotOverlay(true, false, GT_UITextures.OVERLAY_SLOT_UUM) .setSlotOverlay(false, false, true, true, GT_UITextures.OVERLAY_SLOT_DATA_ORB) .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); - // public static final GT_Recipe_Map sAssemblylineFakeRecipes = new GT_Recipe_Map(new HashSet<>(30), - // "gt.recipe.scanner", "Scanner", null, Mods.GregTech.getResourcePath(BASIC_MACHINES, "Default"), 1, 1, 1, 0, - // 1, E, 1, E, true, - // true); public static final GT_Recipe_Map sAssemblylineVisualRecipes = new GT_Recipe_Map_AssemblyLineFake( new HashSet<>(110), "gt.recipe.fakeAssemblylineProcess", @@ -2251,6 +2276,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { int tExplosives = Math.min(b.getMetadata(ADDITIVE_AMOUNT), 64); int tGunpowder = tExplosives << 1; // Worst int tDynamite = Math.max(1, tExplosives >> 1); // good + @SuppressWarnings("UnnecessaryLocalVariable") int tTNT = tExplosives; // Slightly better int tITNT = Math.max(1, tExplosives >> 2); // the best if (tGunpowder < 65) coll.derive() @@ -3457,7 +3483,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { /** * Change how recipes are emitted by a particular recipe builder. Can emit multiple recipe per builder. - * + * <p> * Unlike {@link #setRecipeEmitter(Function)}, this one does not clear the existing recipe being emitted, if any */ public GT_Recipe_Map combineRecipeEmitter( @@ -3478,7 +3504,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { /** * Change how recipes are emitted by a particular recipe builder. Effectively add a new recipe per recipe added. * func must not return null. - * + * <p> * Unlike {@link #setRecipeEmitter(Function)}, this one does not clear the existing recipe being emitted, if any */ public GT_Recipe_Map combineRecipeEmitterSingle(Function<? super GT_RecipeBuilder, ? extends GT_Recipe> func) { @@ -3515,10 +3541,10 @@ public class GT_Recipe implements Comparable<GT_Recipe> { /** * Run a custom hook on all recipes added <b>via builder</b>. For more complicated behavior subclass this, then - * override {@link #doAdd(GT_RecipeBuilder)} - * + * override {@link #doAdd(GT_RecipeBuilder)}. + * <p> * Recipes added via one of the overloads of addRecipe will NOT be affected by this function. - * + * <p> * Unlike {@link #setRecipeSpecialHandler(Function)}, this one will not replace the existing special handler. * The supplied function will be given the output of existing handler when a recipe is added. */ @@ -3529,10 +3555,10 @@ public class GT_Recipe implements Comparable<GT_Recipe> { /** * Run a custom hook on all recipes added <b>via builder</b>. For more complicated behavior subclass this, then - * override {@link #doAdd(GT_RecipeBuilder)} - * + * override {@link #doAdd(GT_RecipeBuilder)}. + * <p> * Recipes added via one of the overloads of addRecipe will NOT be affected by this function. - * + * <p> * Unlike {@link #setRecipeSpecialHandler(Function)}, this one will not replace the existing special handler. * The supplied function will be given the output of existing handler when a recipe is added. */ @@ -3715,6 +3741,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { return addRecipe(aRecipe, aCheckForCollisions, true, hidden); } + @Nonnull @Override public Collection<GT_Recipe> doAdd(GT_RecipeBuilder builder) { Iterable<? extends GT_Recipe> recipes = recipeEmitter.apply(builder); @@ -3771,7 +3798,8 @@ public class GT_Recipe implements Comparable<GT_Recipe> { } String s = iStack.getDisplayName(); if (hasAnEntry) { - errorInfo.append("+" + s); + errorInfo.append("+") + .append(s); } else { errorInfo.append(s); } @@ -4831,7 +4859,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { @Override public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { - if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null; + if (aInputs == null || aInputs.length == 0 || aInputs[0] == null) return null; if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe; ItemStack tOutput = GT_ModHandler.getSmeltingOutput(aInputs[0], false, null); return tOutput == null ? null @@ -4884,7 +4912,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { @Override public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { - if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null; + if (aInputs == null || aInputs.length == 0 || aInputs[0] == null) return null; if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe; ItemStack tOutput = GT_ModHandler.getSmeltingOutput(aInputs[0], false, null); @@ -5016,7 +5044,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { @Override public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { - if (aInputs == null || aInputs.length <= 0 || !ItemList.IC2_Scrapbox.isStackEqual(aInputs[0], false, true)) + if (aInputs == null || aInputs.length == 0 || !ItemList.IC2_Scrapbox.isStackEqual(aInputs[0], false, true)) return super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs); ItemStack tOutput = GT_ModHandler.getRandomScrapboxDrop(); if (tOutput == null) @@ -5084,7 +5112,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { aFluids, aSpecialSlot, aInputs); - if (aInputs == null || aInputs.length <= 0 + if (aInputs == null || aInputs.length == 0 || aInputs[0] == null || rRecipe != null || !GregTech_API.sPostloadFinished) return rRecipe; @@ -5219,7 +5247,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { @Override public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { - if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null; + if (aInputs == null || aInputs.length == 0 || aInputs[0] == null) return null; if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe; ItemStack tComparedInput = GT_Utility.copyOrNull(aInputs[0]); ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput( @@ -5290,7 +5318,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { @Override public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { - if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null; + if (aInputs == null || aInputs.length == 0 || aInputs[0] == null) return null; if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe; ItemStack tComparedInput = GT_Utility.copyOrNull(aInputs[0]); ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput( @@ -5362,7 +5390,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { @Override public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { - if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null; + if (aInputs == null || aInputs.length == 0 || aInputs[0] == null) return null; if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe; ItemStack tComparedInput = GT_Utility.copyOrNull(aInputs[0]); ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput( @@ -5433,7 +5461,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { @Override public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { - if (aInputs == null || aInputs.length <= 0 + if (aInputs == null || aInputs.length == 0 || aInputs[0] == null || aFluids == null || aFluids.length < 1 @@ -5521,7 +5549,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { @Override public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { - if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null || !GregTech_API.sPostloadFinished) + if (aInputs == null || aInputs.length == 0 || aInputs[0] == null || !GregTech_API.sPostloadFinished) return super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs); aRecipe = super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs); if (aRecipe != null) return aRecipe; @@ -5634,7 +5662,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * aSpecialSlot,temp); if(rRecipe!= null){ break; } else { aInputs2.remove(IS); } } if(rRecipe!= null) * break; } } if(rRecipe!= null) break; }else aInputs2.add(aInput); if(rRecipe!= null) break; } } */ - if (aInputs == null || aInputs.length <= 0 + if (aInputs == null || aInputs.length == 0 || aInputs[0] == null || rRecipe == null || !GregTech_API.sPostloadFinished) return rRecipe; @@ -5784,10 +5812,10 @@ public class GT_Recipe implements Comparable<GT_Recipe> { aFluids, aSpecialSlot, aInputs); - if (aInputs == null || aInputs.length <= 0 + if (aInputs == null || aInputs.length == 0 || aInputs[0] == null || aFluids == null - || aFluids.length <= 0 + || aFluids.length == 0 || aFluids[0] == null || !GregTech_API.sPostloadFinished) return rRecipe; diff --git a/src/main/java/gregtech/api/util/GT_RecipeBuilder.java b/src/main/java/gregtech/api/util/GT_RecipeBuilder.java index e05798479e..d7cae76e65 100644 --- a/src/main/java/gregtech/api/util/GT_RecipeBuilder.java +++ b/src/main/java/gregtech/api/util/GT_RecipeBuilder.java @@ -392,7 +392,7 @@ public class GT_RecipeBuilder { /** * produce a deep copy of current values. anything unset will remain unset. IMPORTANT: If metadata contains mutable * value, they will not be cloned! - * + * <p> * checkout docs/RecipeBuilder.md for more info on whether to copy or not. */ public GT_RecipeBuilder copy() { @@ -754,6 +754,7 @@ public class GT_RecipeBuilder { public static <T> MetadataIdentifier<T> create(Class<T> clazz, String identifier) { MetadataIdentifier<T> key = new MetadataIdentifier<>(clazz, identifier); + // noinspection unchecked // The class uses type T to fill allIdentifiers return (MetadataIdentifier<T>) allIdentifiers.computeIfAbsent(key, Function.identity()); } diff --git a/src/main/java/gregtech/api/util/GT_RecipeMapUtil.java b/src/main/java/gregtech/api/util/GT_RecipeMapUtil.java index a534f8031d..bc8662ab03 100644 --- a/src/main/java/gregtech/api/util/GT_RecipeMapUtil.java +++ b/src/main/java/gregtech/api/util/GT_RecipeMapUtil.java @@ -4,7 +4,16 @@ import static gregtech.api.enums.Mods.GregTech; import static gregtech.api.util.GT_Config.getStackConfigName; import static gregtech.api.util.GT_Utility.isArrayEmptyOrNull; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.IdentityHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; import java.util.function.Consumer; import java.util.function.Function; @@ -141,10 +150,10 @@ public class GT_RecipeMapUtil { } /** - * Register a recipe map as part of your mod's public API under your modid and your given identifier. + * Register a recipe map as part of your mod's public API under your modID and your given identifier. * - * @param identifier - * @param recipeMap + * @param identifier map name + * @param recipeMap the map to register * @param dependencies fully qualified identifier of dependent recipe maps. scheduler will only add recipes to one * of the dependent recipe maps and this recipe map concurrently, guaranteeing thread safety. * Currently unused, but you are advised to fill them, so that when The Day (tm) comes we don't diff --git a/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java index 7367d79ec9..f44196eefe 100644 --- a/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java +++ b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java @@ -1,7 +1,23 @@ package gregtech.api.util; -import static gregtech.api.enums.GT_Values.*; -import static gregtech.api.enums.Materials.*; +import static gregtech.api.enums.GT_Values.L; +import static gregtech.api.enums.GT_Values.M; +import static gregtech.api.enums.GT_Values.RA; +import static gregtech.api.enums.Materials.Bronze; +import static gregtech.api.enums.Materials.Cobalt; +import static gregtech.api.enums.Materials.DarkSteel; +import static gregtech.api.enums.Materials.Diamond; +import static gregtech.api.enums.Materials.FierySteel; +import static gregtech.api.enums.Materials.Gold; +import static gregtech.api.enums.Materials.Iron; +import static gregtech.api.enums.Materials.IronWood; +import static gregtech.api.enums.Materials.Knightmetal; +import static gregtech.api.enums.Materials.Lead; +import static gregtech.api.enums.Materials.Ruby; +import static gregtech.api.enums.Materials.Sapphire; +import static gregtech.api.enums.Materials.Steel; +import static gregtech.api.enums.Materials.Steeleaf; +import static gregtech.api.enums.Materials.Thaumium; import static gregtech.api.enums.Materials.Void; import static gregtech.api.util.GT_Recipe.GT_Recipe_Map.sHammerRecipes; import static gregtech.api.util.GT_Recipe.GT_Recipe_Map.sMaceratorRecipes; @@ -12,7 +28,11 @@ import static gregtech.api.util.GT_RecipeConstants.UniversalArcFurnace; import static gregtech.api.util.GT_Utility.calculateRecipeEU; import java.lang.reflect.Field; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.IdentityHashMap; +import java.util.List; +import java.util.Map; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -32,7 +52,12 @@ import com.google.common.collect.SetMultimap; import cpw.mods.fml.relauncher.ReflectionHelper; import gregtech.GT_Mod; import gregtech.api.GregTech_API; -import gregtech.api.enums.*; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.enums.TierEU; import gregtech.api.objects.ItemData; import gregtech.api.objects.MaterialStack; import ic2.api.reactor.IReactorComponent; @@ -128,7 +153,6 @@ public class GT_RecipeRegistrator { { "Shears", s_H + s_P, s_P + s_F }, { "Shears", s_H + s_P, s_P + s_F }, { "Scythe", s_I + s_P + s_H, s_R + s_F + s_P, s_R + " " + " " }, { "Scythe", s_H + s_P + s_I, s_P + s_F + s_R, " " + " " + s_R } }; - public static volatile int VERSION = 509; static { // flush the cache on post load finish @@ -189,11 +213,6 @@ public class GT_RecipeRegistrator { || tData.mPrefix == OrePrefixes.block | tData.mPrefix == OrePrefixes.plate)) { tHide = true; } - // boolean tHide = (aMaterial != Materials.Iron && aMaterial!= - // Materials.Redstone)&&(GT_Mod.gregtechproxy.mHideRecyclingRecipes); - // if(tHide && tData!=null&&tData.hasValidPrefixData()&&tData.mPrefix==OrePrefixes.ingot){ - // tHide=false; - // } RA.addFluidSmelterRecipe( GT_Utility.copyAmount(1, aStack), aByproduct @@ -307,7 +326,7 @@ public class GT_RecipeRegistrator { tAmount += tMaterial.mAmount * tMaterial.mMaterial.getMass(); boolean tHide = !tIron && GT_Mod.gregtechproxy.mHideRecyclingRecipes; - ArrayList<ItemStack> outputs = new ArrayList<ItemStack>(); + ArrayList<ItemStack> outputs = new ArrayList<>(); if (GT_OreDictUnificator.getIngotOrDust(aData.mMaterial) != null) { outputs.add(GT_OreDictUnificator.getIngotOrDust(aData.mMaterial)); } @@ -317,7 +336,7 @@ public class GT_RecipeRegistrator { } } if (outputs.size() != 0) { - ItemStack[] outputsArray = outputs.toArray(new ItemStack[outputs.size()]); + ItemStack[] outputsArray = outputs.toArray(new ItemStack[0]); GT_RecipeBuilder recipeBuilder = GT_Values.RA.stdBuilder(); recipeBuilder.itemInputs(aStack) .itemOutputs(outputsArray) @@ -366,7 +385,7 @@ public class GT_RecipeRegistrator { { boolean tHide = (aData.mMaterial.mMaterial != Materials.Iron) && (GT_Mod.gregtechproxy.mHideRecyclingRecipes); - ArrayList<ItemStack> outputs = new ArrayList<ItemStack>(); + ArrayList<ItemStack> outputs = new ArrayList<>(); if (GT_OreDictUnificator.getDust(aData.mMaterial) != null) { outputs.add(GT_OreDictUnificator.getDust(aData.mMaterial)); } @@ -376,7 +395,7 @@ public class GT_RecipeRegistrator { } } if (outputs.size() != 0) { - ItemStack[] outputsArray = outputs.toArray(new ItemStack[outputs.size()]); + ItemStack[] outputsArray = outputs.toArray(new ItemStack[0]); GT_RecipeBuilder recipeBuilder = GT_Values.RA.stdBuilder(); recipeBuilder.itemInputs(aStack) .itemOutputs(outputsArray) @@ -484,7 +503,6 @@ public class GT_RecipeRegistrator { private static Map<RecipeShape, List<IRecipe>> createIndexedRecipeListCache() { Map<RecipeShape, List<IRecipe>> result = new IdentityHashMap<>(); - @SuppressWarnings("unchecked") ArrayList<IRecipe> allRecipeList = (ArrayList<IRecipe>) CraftingManager.getInstance() .getRecipeList(); // filter using the empty slots in the shape. @@ -509,8 +527,7 @@ public class GT_RecipeRegistrator { && !(tStack.getItem() instanceof IReactorComponent) && !GT_ModHandler.isElectricItem(tStack) && !GT_Utility.isStackInList(tStack, GT_ModHandler.sNonReplaceableItems)) { - if (tRecipe instanceof ShapedOreRecipe) { - ShapedOreRecipe tShapedRecipe = (ShapedOreRecipe) tRecipe; + if (tRecipe instanceof ShapedOreRecipe tShapedRecipe) { if (checkRecipeShape( buffer, tShapedRecipe.getInput(), @@ -521,8 +538,7 @@ public class GT_RecipeRegistrator { .add(tRecipe); } } - } else if (tRecipe instanceof ShapedRecipes) { - ShapedRecipes tShapedRecipe = (ShapedRecipes) tRecipe; + } else if (tRecipe instanceof ShapedRecipes tShapedRecipe) { if (checkRecipeShape( buffer, tShapedRecipe.recipeItems, diff --git a/src/main/java/gregtech/api/util/GT_Single_Recipe_Check.java b/src/main/java/gregtech/api/util/GT_Single_Recipe_Check.java index 4470139afa..733cca3b69 100644 --- a/src/main/java/gregtech/api/util/GT_Single_Recipe_Check.java +++ b/src/main/java/gregtech/api/util/GT_Single_Recipe_Check.java @@ -62,6 +62,7 @@ public class GT_Single_Recipe_Check { * {@link GT_MetaTileEntity_MultiBlockBase#getCompactedFluids()} both enforce this single-stack restriction, so any * multi-block that calls those can use this method. */ + @SuppressWarnings("JavadocReference") public boolean checkRecipeInputsSingleStack(boolean consumeInputs) { Map<GT_Utility.ItemId, ItemStack> itemMap = null; if (totalItemCost > 0) { diff --git a/src/main/java/gregtech/api/util/GT_StructureUtility.java b/src/main/java/gregtech/api/util/GT_StructureUtility.java index 2447bea63f..d3c4c10a0d 100644 --- a/src/main/java/gregtech/api/util/GT_StructureUtility.java +++ b/src/main/java/gregtech/api/util/GT_StructureUtility.java @@ -8,7 +8,12 @@ import static com.gtnewhorizon.structurelib.util.ItemStackPredicate.NBTMode.EXAC import java.util.Arrays; import java.util.List; -import java.util.function.*; +import java.util.function.BiConsumer; +import java.util.function.BiPredicate; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.function.ToIntFunction; import javax.annotation.Nonnull; @@ -25,7 +30,11 @@ import net.minecraft.util.IIcon; import net.minecraft.world.World; import com.gtnewhorizon.structurelib.StructureLibAPI; -import com.gtnewhorizon.structurelib.structure.*; +import com.gtnewhorizon.structurelib.structure.AutoPlaceEnvironment; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureElement; +import com.gtnewhorizon.structurelib.structure.IStructureElementNoPlacement; +import com.gtnewhorizon.structurelib.structure.StructureUtility; import com.gtnewhorizon.structurelib.util.ItemStackPredicate; import gregtech.api.GregTech_API; diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 7f423e0c19..dee22c9283 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -26,7 +26,22 @@ import java.math.BigInteger; import java.math.RoundingMode; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; -import java.util.*; +import java.util.AbstractCollection; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.UUID; import java.util.function.Function; import java.util.function.IntFunction; import java.util.function.Supplier; @@ -67,7 +82,12 @@ import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; -import net.minecraft.util.*; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraft.world.chunk.Chunk; @@ -108,7 +128,14 @@ import gregtech.api.damagesources.GT_DamageSources; import gregtech.api.damagesources.GT_DamageSources.DamageSourceHotItem; import gregtech.api.enchants.Enchantment_Hazmat; import gregtech.api.enchants.Enchantment_Radioactivity; -import gregtech.api.enums.*; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SoundResource; +import gregtech.api.enums.SubTag; +import gregtech.api.enums.Textures; +import gregtech.api.enums.ToolDictNames; import gregtech.api.events.BlockScanningEvent; import gregtech.api.interfaces.IBlockContainer; import gregtech.api.interfaces.IDebugableBlock; @@ -164,7 +191,6 @@ public class GT_Utility { private static final Map<OrePrefixes, Supplier<ItemStack>> sOreToCobble = new HashMap<>(); private static final Map<Integer, Boolean> sOreTable = new HashMap<>(); - public static volatile int VERSION = 509; public static boolean TE_CHECK = false, BC_CHECK = false, CHECK_ALL = true, RF_CHECK = false; public static Map<GT_PlayedSound, Integer> sPlayedSoundMap = new /* Concurrent */ HashMap<>(); private static int sBookCount = 0; @@ -589,8 +615,6 @@ public class GT_Utility { byte tMovedItemCount = (byte) (tStack.stackSize - (rStack == null ? 0 : rStack.stackSize)); if (tMovedItemCount >= 1 /* Math.max(aMinMoveAtOnce, aMinTargetStackSize) */) { - // ((cofh.api.transport.IItemConduit)aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), - // copyAmount(tMovedItemCount, tStack), F); fromInventory.decrStackSize(aGrabSlot, tMovedItemCount); fromInventory.markDirty(); return tMovedItemCount; @@ -1394,8 +1418,7 @@ public class GT_Utility { public static byte moveOneItemStackIntoSlot(Object fromTileEntity, Object toTileEntity, ForgeDirection fromSide, int putSlot, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) { - if (fromTileEntity == null || !(fromTileEntity instanceof IInventory fromInv) - || aMaxTargetStackSize <= 0 + if (!(fromTileEntity instanceof IInventory fromInv) || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize @@ -1695,7 +1718,7 @@ public class GT_Utility { /** * Treat both null list, or both null item stack at same list position as equal. - * + * <p> * Since ItemStack doesn't override equals and hashCode, you cannot just use Objects.equals */ public static boolean areStackListsEqual(List<ItemStack> lhs, List<ItemStack> rhs, boolean ignoreStackSize, @@ -1926,7 +1949,7 @@ public class GT_Utility { .hasContainerItem(aStack)) return aStack.getItem() .getContainerItem(aStack); - /** + /* * These are all special Cases, in which it is intended to have only GT Blocks outputting those Container Items */ if (ItemList.Cell_Empty.isStackEqual(aStack, false, true)) return null; @@ -2075,7 +2098,7 @@ public class GT_Utility { if (isStringInvalid(aMapping)) return null; ItemStack rStack = GregTech_API.sBookList.get(aMapping); if (rStack != null) return copyAmount(1, rStack); - if (isStringInvalid(aTitle) || isStringInvalid(aAuthor) || aPages.length <= 0) return null; + if (isStringInvalid(aTitle) || isStringInvalid(aAuthor) || aPages.length == 0) return null; sBookCount++; rStack = new ItemStack(Items.written_book, 1); NBTTagCompound tNBT = new NBTTagCompound(); @@ -2378,8 +2401,7 @@ public class GT_Utility { } public static boolean isStackInvalid(Object aStack) { - return aStack == null || !(aStack instanceof ItemStack) - || ((ItemStack) aStack).getItem() == null + return !(aStack instanceof ItemStack) || ((ItemStack) aStack).getItem() == null || ((ItemStack) aStack).stackSize < 0; } @@ -2454,7 +2476,7 @@ public class GT_Utility { /** * Initializes new empty texture page for casings page 0 is old CASING_BLOCKS - * + * <p> * Then casings should be registered like this: for (byte i = MIN_USED_META; i < MAX_USED_META; i = (byte) (i + 1)) * { Textures.BlockIcons.casingTexturePages[PAGE][i+START_INDEX] = new GT_CopiedBlockTexture(this, 6, i); } * @@ -3069,8 +3091,7 @@ public class GT_Utility { if (!interDimensional) return false; startWorld.updateEntityWithOptionalForce(entity, false); // added - if ((entity instanceof EntityPlayerMP) && interDimensional) { - EntityPlayerMP player = (EntityPlayerMP) entity; + if (entity instanceof EntityPlayerMP player) { player.closeScreen(); // added player.dimension = aDimension; player.playerNetServerHandler.sendPacket( @@ -3102,40 +3123,34 @@ public class GT_Utility { destinationWorld.theChunkProviderServer.loadChunk((int) aX >> 4, (int) aZ >> 4); destinationWorld.theProfiler.startSection("placing"); - if (interDimensional) { - if (!(entity instanceof EntityPlayer)) { - NBTTagCompound entityNBT = new NBTTagCompound(); - entity.isDead = false; - entityNBT.setString("id", EntityList.getEntityString(entity)); - entity.writeToNBT(entityNBT); - entity.isDead = true; - entity = EntityList.createEntityFromNBT(entityNBT, destinationWorld); - if (entity == null) { - return false; - } - entity.dimension = destinationWorld.provider.dimensionId; + if (!(entity instanceof EntityPlayer)) { + NBTTagCompound entityNBT = new NBTTagCompound(); + entity.isDead = false; + entityNBT.setString("id", EntityList.getEntityString(entity)); + entity.writeToNBT(entityNBT); + entity.isDead = true; + entity = EntityList.createEntityFromNBT(entityNBT, destinationWorld); + if (entity == null) { + return false; } - destinationWorld.spawnEntityInWorld(entity); - entity.setWorld(destinationWorld); + entity.dimension = destinationWorld.provider.dimensionId; } + destinationWorld.spawnEntityInWorld(entity); + entity.setWorld(destinationWorld); entity.setLocationAndAngles(aX, aY, aZ, entity.rotationYaw, entity.rotationPitch); destinationWorld.updateEntityWithOptionalForce(entity, false); entity.setLocationAndAngles(aX, aY, aZ, entity.rotationYaw, entity.rotationPitch); - if ((entity instanceof EntityPlayerMP)) { - EntityPlayerMP player = (EntityPlayerMP) entity; - if (interDimensional) { - player.mcServer.getConfigurationManager() - .func_72375_a(player, destinationWorld); - } + if ((entity instanceof EntityPlayerMP player)) { + player.mcServer.getConfigurationManager() + .func_72375_a(player, destinationWorld); player.playerNetServerHandler.setPlayerLocation(aX, aY, aZ, player.rotationYaw, player.rotationPitch); } destinationWorld.updateEntityWithOptionalForce(entity, false); - if (((entity instanceof EntityPlayerMP)) && interDimensional) { - EntityPlayerMP player = (EntityPlayerMP) entity; + if (entity instanceof EntityPlayerMP player) { player.theItemInWorldManager.setWorld(destinationWorld); player.mcServer.getConfigurationManager() .updateTimeAndWeatherForPlayer(player, destinationWorld); @@ -3667,6 +3682,7 @@ public class GT_Utility { * @return an Array containing the X and the Y Coordinate of the clicked Point, with the top left Corner as Origin, * like on the Texture Sheet. return values should always be between [0.0F and 0.99F]. */ + // TODO: use clamp() public static float[] getClickedFacingCoords(ForgeDirection side, float aX, float aY, float aZ) { return switch (side) { case DOWN -> new float[] { Math.min(0.99F, Math.max(0, 1 - aX)), Math.min(0.99F, Math.max(0, aZ)) }; @@ -4194,10 +4210,7 @@ public class GT_Utility { } private static void applyArrayOfBullshit(IBullshit aBullshitModifier, ItemStack[] aStacks) { - ItemStack[] aitemstack1 = aStacks; - int i = aStacks.length; - for (int j = 0; j < i; ++j) { - ItemStack itemstack = aitemstack1[j]; + for (ItemStack itemstack : aStacks) { applyBullshit(aBullshitModifier, itemstack); } } @@ -4634,6 +4647,7 @@ public class GT_Utility { size = sum; } + @Nonnull @Override public Iterator<E> iterator() { return colls.stream() diff --git a/src/main/java/gregtech/api/util/GT_UtilityClient.java b/src/main/java/gregtech/api/util/GT_UtilityClient.java index 3bdcbef9ca..398c1f6b41 100644 --- a/src/main/java/gregtech/api/util/GT_UtilityClient.java +++ b/src/main/java/gregtech/api/util/GT_UtilityClient.java @@ -27,7 +27,6 @@ public class GT_UtilityClient { } } - @SuppressWarnings("unchecked") public static List<String> getTooltip(ItemStack aStack, boolean aGuiStyle) { try { List<String> tooltip = aStack.getTooltip( diff --git a/src/main/java/gregtech/api/util/ISerializableObject.java b/src/main/java/gregtech/api/util/ISerializableObject.java index 51bee67b91..7f1626bac5 100644 --- a/src/main/java/gregtech/api/util/ISerializableObject.java +++ b/src/main/java/gregtech/api/util/ISerializableObject.java @@ -48,7 +48,7 @@ public interface ISerializableObject { /** * Read data from given parameter and return this. The data read this way is intended to be stored for short amount * of time over network. - * + * * @param aPlayer the player who is sending this packet to server. null if it's client reading data. */ // the NBT is an unfortunate piece of tech. everything uses it but its API is not as efficient as could be |