aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/util
diff options
context:
space:
mode:
authorchill <chill.gtnh@outlook.com>2023-06-05 06:51:28 +0200
committerGitHub <noreply@github.com>2023-06-05 06:51:28 +0200
commitdb089891a20e5696096907864578e39586035e6e (patch)
treee56d68eb64c3b8025193930b68e731b23d0f60d9 /src/main/java/gregtech/api/util
parentdd9bbe334a00a0435502ac502d4155bfa12d123d (diff)
downloadGT5-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')
-rw-r--r--src/main/java/gregtech/api/util/ColorsMetadataSectionSerializer.java3
-rw-r--r--src/main/java/gregtech/api/util/GT_ApiaryUpgrade.java6
-rw-r--r--src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java3
-rw-r--r--src/main/java/gregtech/api/util/GT_Assemblyline_Server.java5
-rw-r--r--src/main/java/gregtech/api/util/GT_BaseCrop.java12
-rw-r--r--src/main/java/gregtech/api/util/GT_CLS_Compat.java4
-rw-r--r--src/main/java/gregtech/api/util/GT_CircuitryBehavior.java11
-rw-r--r--src/main/java/gregtech/api/util/GT_CoverBehaviorBase.java8
-rw-r--r--src/main/java/gregtech/api/util/GT_ExoticEnergyInputHelper.java2
-rw-r--r--src/main/java/gregtech/api/util/GT_HatchElementBuilder.java22
-rw-r--r--src/main/java/gregtech/api/util/GT_LanguageManager.java1
-rw-r--r--src/main/java/gregtech/api/util/GT_ModHandler.java37
-rw-r--r--src/main/java/gregtech/api/util/GT_OreDictUnificator.java9
-rw-r--r--src/main/java/gregtech/api/util/GT_OverclockCalculator.java46
-rw-r--r--src/main/java/gregtech/api/util/GT_Recipe.java94
-rw-r--r--src/main/java/gregtech/api/util/GT_RecipeBuilder.java3
-rw-r--r--src/main/java/gregtech/api/util/GT_RecipeMapUtil.java17
-rw-r--r--src/main/java/gregtech/api/util/GT_RecipeRegistrator.java54
-rw-r--r--src/main/java/gregtech/api/util/GT_Single_Recipe_Check.java1
-rw-r--r--src/main/java/gregtech/api/util/GT_StructureUtility.java13
-rw-r--r--src/main/java/gregtech/api/util/GT_Utility.java98
-rw-r--r--src/main/java/gregtech/api/util/GT_UtilityClient.java1
-rw-r--r--src/main/java/gregtech/api/util/ISerializableObject.java2
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 e