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 | |
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')
111 files changed, 744 insertions, 600 deletions
diff --git a/src/main/java/gregtech/api/GregTech_API.java b/src/main/java/gregtech/api/GregTech_API.java index 3e0f7fdabe..94eaefd67e 100644 --- a/src/main/java/gregtech/api/GregTech_API.java +++ b/src/main/java/gregtech/api/GregTech_API.java @@ -5,7 +5,17 @@ import static gregtech.api.enums.GT_Values.L; import static gregtech.api.enums.GT_Values.M; import static gregtech.api.enums.Mods.IndustrialCraft2; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; import java.util.function.BiFunction; import java.util.function.IntFunction; @@ -221,14 +231,14 @@ public class GregTech_API { @Deprecated public static IGT_RecipeAdder sRecipeAdder; /** - * Used to register Aspects to ThaumCraft, this Object might be null if ThaumCraft isn't installed + * Registers Aspects to Thaumcraft. This Object might be {@code null} if Thaumcraft isn't installed. */ public static IThaumcraftCompat sThaumcraftCompat; /** - * These Lists are getting executed at their respective timings. Useful if you have to do things right before/after - * I do them, without having to control the load order. Add your "Commands" in the Constructor or in a static Code - * Block of your Mods Main Class. These are not Threaded, I just use a native Java Interface for their execution. - * Implement just the Method run() and everything should work + * The Lists below are executed at their respective timings. Useful to do things at a particular moment in time. + * The Lists are not Threaded - a native Java interface is used for their execution. + * Add your "commands" in the constructor or in the static-code-block of your mod's Main class. + * Implement the method {@code run()}, and everything should work. */ public static List<Runnable> sBeforeGTPreload = new ArrayList<>(), sAfterGTPreload = new ArrayList<>(), sBeforeGTLoad = new ArrayList<>(), sAfterGTLoad = new ArrayList<>(), sBeforeGTPostload = new ArrayList<>(), @@ -426,17 +436,11 @@ public class GregTech_API { public static Item constructCoolantCellItem(String aUnlocalized, String aEnglish, int aMaxStore) { try { return new GT_CoolantCellIC_Item(aUnlocalized, aEnglish, aMaxStore); - // return - // (Item)Class.forName("gregtech.api.items.GT_CoolantCellIC_Item").getConstructors()[0].newInstance(aUnlocalized, - // aEnglish, aMaxStore); } catch (Throwable e) { /* Do nothing */ } try { return new GT_CoolantCell_Item(aUnlocalized, aEnglish, aMaxStore); - // return - // (Item)Class.forName("gregtech.api.items.GT_CoolantCell_Item").getConstructors()[0].newInstance(aUnlocalized, - // aEnglish, aMaxStore); } catch (Throwable e) { /* Do nothing */ } @@ -723,20 +727,20 @@ public class GregTech_API { } /** - * This gives you a new BaseMetaTileEntity. As some Interfaces are not always loaded (Buildcraft, Universal - * Electricity) I have to use Invocation at the Constructor of the BaseMetaTileEntity + * Provides a new BaseMetaTileEntity. Because some interfaces are not always loaded (Buildcraft, Universal + * Electricity) we have to use invocation at the constructor of the BaseMetaTileEntity. */ public static BaseMetaTileEntity constructBaseMetaTileEntity() { if (sBaseMetaTileEntityClass == null) { try { - return (sBaseMetaTileEntityClass = BaseMetaTileEntity.class).newInstance(); - } catch (Throwable e) { - /* Do nothing */ - } + return (sBaseMetaTileEntityClass = BaseMetaTileEntity.class).getDeclaredConstructor() + .newInstance(); + } catch (Throwable ignored) {} } try { - return sBaseMetaTileEntityClass.newInstance(); + return sBaseMetaTileEntityClass.getDeclaredConstructor() + .newInstance(); } catch (Throwable e) { GT_Log.err.println("GT_Mod: Fatal Error occurred while initializing TileEntities, crashing Minecraft."); e.printStackTrace(GT_Log.err); diff --git a/src/main/java/gregtech/api/damagesources/GT_DamageSources.java b/src/main/java/gregtech/api/damagesources/GT_DamageSources.java index b8d53f71fb..10fd6eb9b0 100644 --- a/src/main/java/gregtech/api/damagesources/GT_DamageSources.java +++ b/src/main/java/gregtech/api/damagesources/GT_DamageSources.java @@ -4,7 +4,11 @@ import javax.annotation.Nullable; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; -import net.minecraft.util.*; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EntityDamageSource; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; public class GT_DamageSources { diff --git a/src/main/java/gregtech/api/enums/Element.java b/src/main/java/gregtech/api/enums/Element.java index a769a94a4e..a0f8e6c0b1 100644 --- a/src/main/java/gregtech/api/enums/Element.java +++ b/src/main/java/gregtech/api/enums/Element.java @@ -277,7 +277,6 @@ public enum Element { $Nq(-130, -200, 0, -1, null, "Anti-Naquadah", false), $Nt(0, -10000, 0, -1, null, "Anti-Neutronium", false); - public static volatile int VERSION = 509; public final long mProtons, mNeutrons, mAdditionalMass, mHalfLifeSeconds; public final String mName, mDecayTo; public final boolean mIsIsotope; diff --git a/src/main/java/gregtech/api/enums/GT_Values.java b/src/main/java/gregtech/api/enums/GT_Values.java index d494c5b64c..1dcbc419f2 100644 --- a/src/main/java/gregtech/api/enums/GT_Values.java +++ b/src/main/java/gregtech/api/enums/GT_Values.java @@ -4,7 +4,11 @@ import static gregtech.api.enums.Mods.GregTech; import static gregtech.api.enums.Mods.IndustrialCraft2; import java.math.BigInteger; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; @@ -94,8 +98,6 @@ public class GT_Values { .divide(BigInteger.valueOf(32)) .longValueExact()) .toArray(); - // Why -7? Mystery of the universe. Something may break if you change this so please do not without extensive - // testing. // TODO:Adding that in coremod!!! // TODO:tier 14,15 wires and transformers only (not even cables !!!) // TODO:tier 12,13 the above + batteries, battery buffers, (maybe cables,12 also works for machines) diff --git a/src/main/java/gregtech/api/enums/Materials.java b/src/main/java/gregtech/api/enums/Materials.java index 63be0ddb24..fc13aff66b 100644 --- a/src/main/java/gregtech/api/enums/Materials.java +++ b/src/main/java/gregtech/api/enums/Materials.java @@ -5,7 +5,15 @@ import static gregtech.api.enums.GT_Values.M; import static gregtech.api.enums.Mods.NewHorizonsCoreMod; import static gregtech.api.enums.Mods.Thaumcraft; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -25,7 +33,11 @@ import gregtech.api.objects.GT_FluidStack; import gregtech.api.objects.MaterialStack; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; -import gregtech.common.render.items.*; +import gregtech.common.render.items.CosmicNeutroniumRenderer; +import gregtech.common.render.items.GT_GeneratedMaterial_Renderer; +import gregtech.common.render.items.GaiaSpiritRenderer; +import gregtech.common.render.items.InfinityRenderer; +import gregtech.common.render.items.TranscendentMetalRenderer; import gregtech.common.render.items.UniversiumRenderer; import gregtech.loaders.materialprocessing.ProcessingConfig; import gregtech.loaders.materialprocessing.ProcessingModSupport; @@ -38,7 +50,6 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { public static final Map<Fluid, Materials> FLUID_MAP = new LinkedHashMap<>(); - public static volatile int VERSION = 509; /** * This is for keeping compatibility with addons mods (Such as TinkersGregworks etc.) that looped over the old * materials enum diff --git a/src/main/java/gregtech/api/enums/MaterialsBotania.java b/src/main/java/gregtech/api/enums/MaterialsBotania.java index b82d810a19..7728351bbc 100644 --- a/src/main/java/gregtech/api/enums/MaterialsBotania.java +++ b/src/main/java/gregtech/api/enums/MaterialsBotania.java @@ -1,6 +1,11 @@ package gregtech.api.enums; -import static gregtech.api.enums.OrePrefixes.*; +import static gregtech.api.enums.OrePrefixes.gem; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.nugget; +import static gregtech.api.enums.OrePrefixes.plate; +import static gregtech.api.enums.OrePrefixes.rod; +import static gregtech.api.enums.OrePrefixes.rotor; import java.util.Arrays; diff --git a/src/main/java/gregtech/api/enums/MaterialsKevlar.java b/src/main/java/gregtech/api/enums/MaterialsKevlar.java index 647fe08ef4..b199acc59c 100644 --- a/src/main/java/gregtech/api/enums/MaterialsKevlar.java +++ b/src/main/java/gregtech/api/enums/MaterialsKevlar.java @@ -595,8 +595,8 @@ public class MaterialsKevlar { // H3RhCl6 /** - * called by Materials. Can be safely called multiple times. exists to allow Materials ensure this class is - * initialized + * This method is called by Materials. It can be safely called multiple times. + * It exists to allow Materials ensure this class is initialized. */ public static void init() { // no-op. all work is done by <clinit> diff --git a/src/main/java/gregtech/api/enums/OrePrefixes.java b/src/main/java/gregtech/api/enums/OrePrefixes.java index c029083a50..cfe30d97dd 100644 --- a/src/main/java/gregtech/api/enums/OrePrefixes.java +++ b/src/main/java/gregtech/api/enums/OrePrefixes.java @@ -1,8 +1,15 @@ package gregtech.api.enums; -import static gregtech.api.enums.GT_Values.*; +import static gregtech.api.enums.GT_Values.B; +import static gregtech.api.enums.GT_Values.D2; +import static gregtech.api.enums.GT_Values.M; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; import net.minecraft.item.ItemStack; @@ -667,8 +674,6 @@ public enum OrePrefixes { cellSteamCracked2, cellSteamCracked3); - public static volatile int VERSION = 509; - static { pulp.mPrefixInto = dust; oreGem.mPrefixInto = ore; @@ -731,9 +736,6 @@ public enum OrePrefixes { dust.mNotGeneratedItems.add(Materials.Gunpowder); dust.mNotGeneratedItems.add(Materials.Sugar); dust.mNotGeneratedItems.add(Materials.Blaze); - // dust.mNotGeneratedItems.add(Materials.Ichorium); - // dustSmall.mNotGeneratedItems.add(Materials.Ichorium); - // dustTiny.mNotGeneratedItems.add(Materials.Ichorium); stick.mNotGeneratedItems.add(Materials.Wood); stick.mNotGeneratedItems.add(Materials.Bone); stick.mNotGeneratedItems.add(Materials.Blaze); @@ -860,7 +862,6 @@ public enum OrePrefixes { crateGtIngot.mGeneratedItems.addAll(ingot.mGeneratedItems); crateGtGem.mGeneratedItems.addAll(gem.mGeneratedItems); crateGtPlate.mGeneratedItems.addAll(plate.mGeneratedItems); - itemCasing.mGeneratedItems.addAll(itemCasing.mGeneratedItems); // ----- toolHeadFile.mCondition = new ICondition.And<>( diff --git a/src/main/java/gregtech/api/enums/TextureSet.java b/src/main/java/gregtech/api/enums/TextureSet.java index 3fb15656e5..9bf690d423 100644 --- a/src/main/java/gregtech/api/enums/TextureSet.java +++ b/src/main/java/gregtech/api/enums/TextureSet.java @@ -97,7 +97,7 @@ public class TextureSet { /** * Construct a TextureSet that will delegate some of its textures to the origin TextureSet. - * + * <p> * This assumes you want to construct a custom texture set. */ private TextureSet(String aSetName, TextureSet origin, boolean overrideBlock, boolean overrideItem) { diff --git a/src/main/java/gregtech/api/enums/Textures.java b/src/main/java/gregtech/api/enums/Textures.java index a38a10ccce..80d7d1c8f0 100644 --- a/src/main/java/gregtech/api/enums/Textures.java +++ b/src/main/java/gregtech/api/enums/Textures.java @@ -1677,7 +1677,7 @@ public class Textures { setCasingTextureForId(ERROR_TEXTURE_INDEX, ERROR_RENDERING[0]); } - protected IIcon mIcon; + IIcon mIcon; BlockIcons() { GregTech_API.sGTBlockIconload.add(this); @@ -1822,7 +1822,7 @@ public class Textures { public static final ITexture[] ERROR_RENDERING = { TextureFactory.of(RENDERING_ERROR) }; - protected IIcon mIcon, mOverlay; + IIcon mIcon, mOverlay; ItemIcons() { GregTech_API.sGTItemIconload.add(this); diff --git a/src/main/java/gregtech/api/fluid/GT_FluidFactory.java b/src/main/java/gregtech/api/fluid/GT_FluidFactory.java index 7ffc824a79..7c65956c69 100644 --- a/src/main/java/gregtech/api/fluid/GT_FluidFactory.java +++ b/src/main/java/gregtech/api/fluid/GT_FluidFactory.java @@ -44,7 +44,7 @@ public class GT_FluidFactory { /** * Helper for quick fluid creation and registration - * + * * @param fluidName The name key of the {@link Fluid} to register in the {@link FluidRegistry} * @param localizedName The localized name of this {@link IGT_Fluid} * @param material The {@link Materials} of this {@link IGT_Fluid} @@ -63,7 +63,7 @@ public class GT_FluidFactory { /** * Helper for quick fluid creation and registration - * + * * @param fluidName The name key of the {@link Fluid} to register in the {@link FluidRegistry} * @param localizedName The localized name of this {@link IGT_Fluid} * @param state The {@link FluidState} of this {@link IGT_Fluid} @@ -80,7 +80,7 @@ public class GT_FluidFactory { /** * Gets an {@link IGT_Fluid} builder instance - * + * * @param fluidName The name key of the {@link Fluid} to register in the {@link FluidRegistry} * @return the {@link IGT_FluidBuilder} instance */ diff --git a/src/main/java/gregtech/api/graphs/consumers/ConsumerNode.java b/src/main/java/gregtech/api/graphs/consumers/ConsumerNode.java index 04d7ebbe5a..392fe74a32 100644 --- a/src/main/java/gregtech/api/graphs/consumers/ConsumerNode.java +++ b/src/main/java/gregtech/api/graphs/consumers/ConsumerNode.java @@ -7,7 +7,9 @@ import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.graphs.Node; -// node attached to a tile entity that can consume stuff from the network +/** + * A node attached to a {@code TileEntity} that can consume stuff from the network. + */ public class ConsumerNode extends Node { public ForgeDirection mSide; diff --git a/src/main/java/gregtech/api/graphs/consumers/NodeEnergyConnected.java b/src/main/java/gregtech/api/graphs/consumers/NodeEnergyConnected.java index 6daeae8c9c..fb0a8cf287 100644 --- a/src/main/java/gregtech/api/graphs/consumers/NodeEnergyConnected.java +++ b/src/main/java/gregtech/api/graphs/consumers/NodeEnergyConnected.java @@ -15,11 +15,6 @@ public class NodeEnergyConnected extends ConsumerNode { } @Override - public boolean needsEnergy() { - return super.needsEnergy(); - } - - @Override public int injectEnergy(long aVoltage, long aMaxAmps) { return (int) ((IEnergyConnected) mTileEntity).injectEnergyUnits(mSide, aVoltage, aMaxAmps); } diff --git a/src/main/java/gregtech/api/gui/GT_Container.java b/src/main/java/gregtech/api/gui/GT_Container.java index e2ef6fd658..851e1f6461 100644 --- a/src/main/java/gregtech/api/gui/GT_Container.java +++ b/src/main/java/gregtech/api/gui/GT_Container.java @@ -18,9 +18,9 @@ import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; /** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * <p/> - * Main Container-Class, used for all my GUIs + * The main Container class. It is used for all GregTech GUIs. + * <p> + * Never include this file in your mod - it will break your modpack. */ public class GT_Container extends Container { diff --git a/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java b/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java index af1393cbfb..a77f376e00 100644 --- a/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java +++ b/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java @@ -93,8 +93,7 @@ public class GT_ContainerMetaTile_Machine extends GT_Container { mActive = mTileEntity.isActive() ? 1 : 0; mTimer++; - for (ICrafting crafter : this.crafters) { - ICrafting player = crafter; + for (ICrafting player : this.crafters) { if (mTimer % 500 == 10 || oEnergy != mEnergy) { player.sendProgressBarUpdate(this, 0, mEnergy & 65535); player.sendProgressBarUpdate(this, 1, mEnergy >>> 16); diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java index 479c021d89..5d6c1c4126 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java @@ -251,8 +251,7 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { mItemTransfer = getMachine().mItemTransfer; mStuttering = getMachine().mStuttering; - for (ICrafting crafter : this.crafters) { - ICrafting player = crafter; + for (ICrafting player : this.crafters) { player.sendProgressBarUpdate(this, 102, mFluidTransfer ? 1 : 0); player.sendProgressBarUpdate(this, 103, mItemTransfer ? 1 : 0); player.sendProgressBarUpdate(this, 104, mStuttering ? 1 : 0); diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java index 08e8e6eb00..403de4bab5 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java @@ -77,8 +77,7 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine { } public void sendProgressBar() { - for (ICrafting crafter : this.crafters) { - ICrafting player = crafter; + for (ICrafting player : this.crafters) { if (mTimer % 500 == 0 || oContent != mContent) { player.sendProgressBarUpdate(this, 100, mContent & 65535); player.sendProgressBarUpdate(this, 101, mContent >>> 16); diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java b/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java index a72e9737ee..df395858a9 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java @@ -15,10 +15,14 @@ import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.Dyes; import gregtech.api.enums.GT_Values; -import gregtech.api.gui.widgets.*; +import gregtech.api.gui.widgets.GT_GuiCoverTabLine; +import gregtech.api.gui.widgets.GT_GuiIcon; +import gregtech.api.gui.widgets.GT_GuiSlotTooltip; import gregtech.api.gui.widgets.GT_GuiTabLine.DisplayStyle; import gregtech.api.gui.widgets.GT_GuiTabLine.GT_GuiTabIconSet; import gregtech.api.gui.widgets.GT_GuiTabLine.GT_ITabRenderer; +import gregtech.api.gui.widgets.GT_GuiTooltip; +import gregtech.api.gui.widgets.GT_GuiTooltipManager; import gregtech.api.gui.widgets.GT_GuiTooltipManager.GT_IToolTipRenderer; import gregtech.api.interfaces.IConfigurationCircuitSupport; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -38,8 +42,8 @@ public class GT_GUIContainerMetaTile_Machine extends GT_GUIContainer implements public final GT_ContainerMetaTile_Machine mContainer; - protected GT_GuiTooltipManager mTooltipManager = new GT_GuiTooltipManager(); - protected GT_TooltipDataCache mTooltipCache = new GT_TooltipDataCache(); + protected final GT_GuiTooltipManager mTooltipManager = new GT_GuiTooltipManager(); + protected final GT_TooltipDataCache mTooltipCache = new GT_TooltipDataCache(); private static final String GHOST_CIRCUIT_TOOLTIP = "GT5U.machines.select_circuit.tooltip"; private final int guiTint; diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java index f610f6cf14..8873152137 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java @@ -2,7 +2,7 @@ package gregtech.api.gui; import static gregtech.api.enums.Mods.GregTech; -import java.awt.*; +import java.awt.Rectangle; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.StatCollector; @@ -137,7 +137,7 @@ public class GT_GUIContainer_BasicMachine extends GT_GUIContainerMetaTile_Machin /** * Apply proper coloration to a machine's power tier short name * - * @param machineTier + * @param machineTier machine tier * @return colored power tier short name */ private String powerTierName(byte machineTier) { diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_MultiMachine.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_MultiMachine.java index 66c5156190..3d9515b19a 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_MultiMachine.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_MultiMachine.java @@ -20,7 +20,7 @@ import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeTurbin @Deprecated public class GT_GUIContainer_MultiMachine extends GT_GUIContainerMetaTile_Machine { - String mName; + final String mName; private final int textColor = this.getTextColorOrDefault("text", 0xFAFAFF), textColorTitle = this.getTextColorOrDefault("title", 0xFAFAFF); diff --git a/src/main/java/gregtech/api/gui/GT_GUICover.java b/src/main/java/gregtech/api/gui/GT_GUICover.java index 791bcc0c73..5729ada685 100644 --- a/src/main/java/gregtech/api/gui/GT_GUICover.java +++ b/src/main/java/gregtech/api/gui/GT_GUICover.java @@ -28,8 +28,8 @@ public abstract class GT_GUICover extends GT_GUIScreen { /** * The parent GUI to exit to. -1 is ignored. - * - * @param parentGuiId + * + * @param parentGuiId parent GUI ID */ public void setParentGuiId(int parentGuiId) { this.parentGuiId = parentGuiId; diff --git a/src/main/java/gregtech/api/gui/GT_GUIScreen.java b/src/main/java/gregtech/api/gui/GT_GUIScreen.java index 4f15e2e607..2ff2973792 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIScreen.java +++ b/src/main/java/gregtech/api/gui/GT_GUIScreen.java @@ -26,13 +26,13 @@ import gregtech.api.interfaces.IGuiScreen; @Deprecated public abstract class GT_GUIScreen extends GuiScreen implements GT_IToolTipRenderer, IGuiScreen { - protected GT_GuiTooltipManager ttManager = new GT_GuiTooltipManager(); + protected final GT_GuiTooltipManager ttManager = new GT_GuiTooltipManager(); protected int gui_width = 176; protected int gui_height = 107; protected int guiTop, guiLeft; - protected boolean drawButtons = true; - protected ResourceLocation mGUIbackgroundLocation; + protected final boolean drawButtons = true; + protected final ResourceLocation mGUIbackgroundLocation; private GuiButton selectedButton; private final GT_GUIColorOverride colorOverride; @@ -42,8 +42,8 @@ public abstract class GT_GUIScreen extends GuiScreen implements GT_IToolTipRende public String header; public GT_GuiFakeItemButton headerIcon; - protected List<IGuiElement> elements = new ArrayList<>(); - protected List<GT_GuiIntegerTextBox> textBoxes = new ArrayList<>(); + protected final List<IGuiElement> elements = new ArrayList<>(); + protected final List<GT_GuiIntegerTextBox> textBoxes = new ArrayList<>(); public GT_GUIScreen(int width, int height, String header) { this.gui_width = width; diff --git a/src/main/java/gregtech/api/gui/GT_Slot_Holo.java b/src/main/java/gregtech/api/gui/GT_Slot_Holo.java index 47bd5ceef3..9b7b75f0b2 100644 --- a/src/main/java/gregtech/api/gui/GT_Slot_Holo.java +++ b/src/main/java/gregtech/api/gui/GT_Slot_Holo.java @@ -51,9 +51,9 @@ public class GT_Slot_Holo extends Slot { } /** - * Whether this slot should be ignored in event processing, for example highlight the slot on mouseOver - * - * @param enabled + * Sets if this slot should be ignored in event-processing. For example, highlight the slot on mouseOver. + * + * @param enabled if the slot should be enabled */ public void setEnabled(boolean enabled) { mEnabled = enabled; diff --git a/src/main/java/gregtech/api/gui/modularui/IDataFollowerWidget.java b/src/main/java/gregtech/api/gui/modularui/IDataFollowerWidget.java index 87833da7b3..393b8431e2 100644 --- a/src/main/java/gregtech/api/gui/modularui/IDataFollowerWidget.java +++ b/src/main/java/gregtech/api/gui/modularui/IDataFollowerWidget.java @@ -15,7 +15,7 @@ import gregtech.common.gui.modularui.widget.DataControllerWidget; * recipe mode. <br> * No widgets implementing this interface should not sync; Instead, {@link DataControllerWidget} will sync data, either * when this widget triggers update on client or data update is detected on server. - * + * * @param <T> Data type stored in the parent widget * @param <U> State type stored in this widget * @see DataControllerWidget @@ -45,5 +45,6 @@ public interface IDataFollowerWidget<T, U> { /** * Called on {@link Widget#onPostInit}. */ + @SuppressWarnings("OverrideOnly") // So IntelliJ doesn't warn about the Widget#onPostInit link in the javadoc default void onPostInit() {} } diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java index d52b09b9d5..6f4eb0e2c2 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java @@ -103,8 +103,8 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine { /** * Add the cover on this side of the IGregTechTileEntity to the tabs * - * @param side - * @param cover + * @param side side to apply the cover to + * @param cover cover to add */ private void addCoverToTabs(ForgeDirection side, ItemStack cover) { final boolean enabled = this.tile.getCoverBehaviorAtSideNew(side) @@ -117,9 +117,9 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine { /** * Decorate the cover's tooltips according to the side it's on and on whether the tab is enabled or not * - * @param side - * @param cover - * @param enabled + * @param side side + * @param cover cover which tooltip to decorate + * @param enabled if the tab is enabled * @return This cover tab's tooltip */ private String[] getTooltipForCoverTab(ForgeDirection side, ItemStack cover, boolean enabled) { @@ -135,7 +135,7 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine { /** * Get the translated name for a side of the IGregTechTileEntity * - * @param side + * @param side side of the entity * @return translated name for a side of the IGregTechTileEntity */ private String getSideDescription(ForgeDirection side) { diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java index b534359cac..9f4287a65b 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java @@ -1,6 +1,6 @@ package gregtech.api.gui.widgets; -import java.awt.*; +import java.awt.Rectangle; import java.util.List; import net.minecraft.client.Minecraft; diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java index 46d213f0f6..66ab27356e 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java @@ -113,16 +113,16 @@ public enum GT_GuiIcon implements IGuiIcon { /** * This is intended to enable addon mods to register additional textures. They can then add to this enum using - * EnumHelper.addEnum or by creating your their enum that implements IGuiIcon (still requires adding a texture here) + * EnumHelper.addEnum or by creating their enum that implements IGuiIcon (still requires adding a texture here) * - * @param location + * @param location location of the texture to add */ public static void addTextures(ResourceLocation... location) { if (location == null || location.length == 0) return; int startIndex = TEXTURES.length; TEXTURES = Arrays.copyOf(TEXTURES, location.length); - System.arraycopy(location, 0, TEXTURES, startIndex + 0, location.length); + System.arraycopy(location, 0, TEXTURES, startIndex, location.length); } @Override diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java index 62d6648e73..d4bfe31404 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java @@ -17,7 +17,7 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen protected GT_GuiIcon icon; private final int x0; private final int y0; - protected IGuiScreen gui; + protected final IGuiScreen gui; private GT_GuiTooltip tooltip; diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java index ef5348cf77..2d3c7374bd 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java @@ -1,6 +1,6 @@ package gregtech.api.gui.widgets; -import java.awt.*; +import java.awt.Rectangle; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiTextField; diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiTab.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiTab.java index 151eba2936..d06c2bd2eb 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiTab.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiTab.java @@ -34,7 +34,7 @@ public class GT_GuiTab { * A tab to be attached to a tab line * * @param gui IGregTechTileEntity the tab line this tab belongs to is attached to - * @param id both the ID and position in the tab line of this tab + * @param id both the ID and position in the tab line of this tab. Not used, kept for compatibility. * @param bounds bounds of this tab * @param tabBackground set of background textures * @param item item to draw atop the background texture, not colored @@ -62,7 +62,7 @@ public class GT_GuiTab { /** * Set this tab's tooltip text * - * @param text + * @param text text to set * @return This tab for chaining */ public GT_GuiTab setTooltipText(String... text) { @@ -85,9 +85,9 @@ public class GT_GuiTab { /** * Draw the background texture for this tab * - * @param mouseX - * @param mouseY - * @param parTicks + * @param mouseX not used, likely kept for backward compatibility + * @param mouseY not used, likely kept for backward compatibility + * @param parTicks not used, likely kept for backward compatibility */ public void drawBackground(int mouseX, int mouseY, float parTicks) { if (this.visible) { @@ -106,9 +106,9 @@ public class GT_GuiTab { /** * Draw overlay textures and items atop the background texture * - * @param mouseX - * @param mouseY - * @param parTicks + * @param mouseX X mouse coordinate + * @param mouseY Y mouse coordinate + * @param parTicks not used, likely kept for backward compatibility */ public void drawOverlays(int mouseX, int mouseY, float parTicks) { this.mousedOver = bounds.contains(mouseX, mouseY); @@ -165,8 +165,8 @@ public class GT_GuiTab { /** * Reposition this tab on the screen * - * @param xPos - * @param yPos + * @param xPos X tab coordinate + * @param yPos Y tab coordinate */ public void setPosition(int xPos, int yPos) { this.bounds = new Rectangle(xPos, yPos, bounds.width, bounds.height); diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java index 74145463b3..950478cdfa 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java @@ -86,7 +86,8 @@ public class GT_GuiTabLine { private final DisplayStyle yDir; // Whether to display on the right side of the GT_ITabRenderer instead of left - protected boolean flipHorizontally, visible; + protected final boolean flipHorizontally; + protected final boolean visible; private final GT_GuiTabIconSet tabBackground; private final GT_ITabRenderer gui; @@ -128,10 +129,10 @@ public class GT_GuiTabLine { /** * Creates a new tab at the specified position with the given parameters. This class handles the positioning. * - * @param tabId - * @param item - * @param overlay - * @param text + * @param tabId tab ID + * @param item item to draw atop the background texture, not colored + * @param overlay texture to draw atop the background texture, not colored + * @param text tooltip of this tab */ public void setTab(int tabId, ItemStack item, IGuiIcon overlay, String[] text) { mTabs[tabId] = new GT_GuiTab( @@ -148,8 +149,8 @@ public class GT_GuiTabLine { /** * Get the bounds a given tab should occupy * - * @param tabId - * @return + * @param tabId tab ID + * @return tab bounds */ protected Rectangle getBoundsForTab(int tabId) { return new Rectangle(getTabX(tabId), getTabY(tabId), this.tabWidth, this.tabHeight); @@ -158,12 +159,12 @@ public class GT_GuiTabLine { /** * Enable or disable a tab. Disabled tabs have a dark background. * - * @param tabId - * @param value + * @param tabId tab ID + * @param enable true to enable, false to disable */ - public void setTabEnabled(int tabId, boolean value) { + public void setTabEnabled(int tabId, boolean enable) { if (mTabs[tabId] != null) { - mTabs[tabId].enabled = value; + mTabs[tabId].enabled = enable; } } @@ -172,8 +173,6 @@ public class GT_GuiTabLine { * drawScreen. * * @param parTicks - * @param mouseX - * @param mouseY */ public void drawTabs(float parTicks, int mouseX, int mouseY) { if (this.visible) { @@ -189,9 +188,9 @@ public class GT_GuiTabLine { /** * Draw the tab's backgrounds first * - * @param parTicks - * @param mouseX - * @param mouseY + * @param parTicks not used, likely kept for compatibility + * @param mouseX mouse X position + * @param mouseY mouse Y position */ protected void drawOverlays(float parTicks, int mouseX, int mouseY) { for (GT_GuiTab mTab : mTabs) { @@ -204,9 +203,9 @@ public class GT_GuiTabLine { /** * Draw anything that overlays the tab's background texture * - * @param parTicks - * @param mouseX - * @param mouseY + * @param parTicks not used, likely kept for compatibility + * @param mouseX mouse X position + * @param mouseY mouse Y position */ protected void drawBackground(float parTicks, int mouseX, int mouseY) { for (GT_GuiTab mTab : mTabs) { @@ -219,9 +218,9 @@ public class GT_GuiTabLine { /** * Call tabClick for every tab that was clicked. GT_ITabRenderer must call this method on mouseClicked. * - * @param mouseX - * @param mouseY - * @param mouseButton + * @param mouseX mouse X position + * @param mouseY mouse Y position + * @param mouseButton which mouse button was used to click */ public void onMouseClicked(int mouseX, int mouseY, int mouseButton) { for (int tabId = 0; tabId < mTabs.length; tabId++) { @@ -236,8 +235,8 @@ public class GT_GuiTabLine { /** * Act on a tab being clicked. * - * @param tabId - * @param mouseButton + * @param tabId tab ID + * @param mouseButton which mouse button was used to click */ protected void tabClicked(int tabId, int mouseButton) {} @@ -255,8 +254,8 @@ public class GT_GuiTabLine { /** * Get the proper X position for a given tab * - * @param tabId - * @return + * @param tabId tab ID + * @return X position of the tab */ private int getTabX(int tabId) { return this.gui.getGuiLeft() + (flipHorizontally ? (gui.getXSize() - tabLineLeft - tabWidth) : tabLineLeft) @@ -266,8 +265,8 @@ public class GT_GuiTabLine { /** * Get the proper Y position for a given tab * - * @param tabId - * @return + * @param tabId tab ID + * @return Y position of the tab */ private int getTabY(int tabId) { return this.gui.getGuiTop() + tabLineTop + (tabId * (tabHeight + tabSpacing) * yDir.getValue()); diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java index 326e744382..fe20b2b57a 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java @@ -11,7 +11,7 @@ import gregtech.api.util.GT_TooltipDataCache.TooltipData; public class GT_GuiTooltip { - protected Rectangle bounds; + protected final Rectangle bounds; protected TooltipData data; private List<String> displayedText; public boolean enabled = true; @@ -20,8 +20,8 @@ public class GT_GuiTooltip { * Used to create a tooltip that will appear over the specified bounds. This will initially be a "static" tooltip * that doesn't respect verbosity levels or respond to the shift key. * - * @param bounds - * @param text + * @param bounds tooltip bounds + * @param text tooltip text */ public GT_GuiTooltip(Rectangle bounds, String... text) { this.bounds = bounds; @@ -32,8 +32,8 @@ public class GT_GuiTooltip { * Used to create a tooltip that will appear over the specified bounds. This will initially be a "dynamic" tooltip * that respects verbosity levels and responds to the shift key. * - * @param bounds - * @param data + * @param bounds tooltip bounds + * @param data tooltip data */ public GT_GuiTooltip(Rectangle bounds, TooltipData data) { this.bounds = bounds; @@ -69,7 +69,7 @@ public class GT_GuiTooltip { /** * Used to set a "static" tooltip that doesn't respect verbosity levels or respond to the shift key * - * @param text + * @param text tooltip text */ public void setToolTipText(String... text) { this.data = formatTooltip(text); @@ -79,7 +79,7 @@ public class GT_GuiTooltip { /** * Used to set a "dynamic" tooltip that respects verbosity levels and responds to the shift key * - * @param data + * @param data tooltip data */ public void setToolTipText(TooltipData data) { // Trust that the tooltips have already been formatted and colored, just make sure it has no nulls @@ -89,7 +89,7 @@ public class GT_GuiTooltip { /** * Apply tooltip colors in case the text doesn't contain them and return as tooltip data * - * @param text + * @param text text to apply the colors to * @return colored tooltip lines as list */ protected TooltipData formatTooltip(String[] text) { diff --git a/src/main/java/gregtech/api/interfaces/IConfigurationCircuitSupport.java b/src/main/java/gregtech/api/interfaces/IConfigurationCircuitSupport.java index 6ec9f68a8b..8dde8163c8 100644 --- a/src/main/java/gregtech/api/interfaces/IConfigurationCircuitSupport.java +++ b/src/main/java/gregtech/api/interfaces/IConfigurationCircuitSupport.java @@ -20,7 +20,7 @@ public interface IConfigurationCircuitSupport { /** * Return a list of possible configuration circuit this machine expects. - * + * <p> * This list is unmodifiable. Its elements are not supposed to be modified in any way! */ default List<ItemStack> getConfigurationCircuits() { diff --git a/src/main/java/gregtech/api/interfaces/IGT_RecipeMap.java b/src/main/java/gregtech/api/interfaces/IGT_RecipeMap.java index bbc2fd4ada..2c5259882a 100644 --- a/src/main/java/gregtech/api/interfaces/IGT_RecipeMap.java +++ b/src/main/java/gregtech/api/interfaces/IGT_RecipeMap.java @@ -18,14 +18,14 @@ public interface IGT_RecipeMap { /** * Add a downstream recipe map that will get to handle the original builder. - * + * <p> * Downstream recipe maps got passed the recipe builder after parent recipe map is done with its business. Notice * at this time the original recipe builder might be modified by the parent recipe map in some form, but it will * remain as valid. - * + * <p> * A downstream will only be invoked if parent recipe map added something. * - * @param downstream + * @param downstream the downstream recipe map to add */ void addDownstream(IGT_RecipeMap downstream); @@ -38,7 +38,7 @@ public interface IGT_RecipeMap { /** * Return a variant of this recipe map that will perform a deep copy on input recipe builder before doing anything * to it. - * + * <p> * The returned recipe map will not have any downstreams, but can accept new downstreams. */ default IGT_RecipeMap deepCopyInput() { diff --git a/src/main/java/gregtech/api/interfaces/IGlobalWirelessEnergy.java b/src/main/java/gregtech/api/interfaces/IGlobalWirelessEnergy.java index 98fe106f24..9640cb38d1 100644 --- a/src/main/java/gregtech/api/interfaces/IGlobalWirelessEnergy.java +++ b/src/main/java/gregtech/api/interfaces/IGlobalWirelessEnergy.java @@ -1,6 +1,8 @@ package gregtech.api.interfaces; -import static gregtech.common.misc.GlobalVariableStorage.*; +import static gregtech.common.misc.GlobalVariableStorage.GlobalEnergy; +import static gregtech.common.misc.GlobalVariableStorage.GlobalEnergyName; +import static gregtech.common.misc.GlobalVariableStorage.GlobalEnergyTeam; import java.math.BigInteger; import java.util.UUID; diff --git a/src/main/java/gregtech/api/interfaces/INetworkUpdatableItem.java b/src/main/java/gregtech/api/interfaces/INetworkUpdatableItem.java index b7e7b0ce33..1dd36d9998 100644 --- a/src/main/java/gregtech/api/interfaces/INetworkUpdatableItem.java +++ b/src/main/java/gregtech/api/interfaces/INetworkUpdatableItem.java @@ -7,14 +7,14 @@ import net.minecraft.nbt.NBTTagCompound; /** * Together with {@link gregtech.api.net.GT_Packet_UpdateItem} you can request server side to update item in hand with a * NBT tag. - * + * <p> * Usual NBT tag size limit applies. */ public interface INetworkUpdatableItem { /** * Receive update from client. Runs on server thread. - * + * * @param stack Stack being updated * @param player player holding the stack * @param tag received data diff --git a/src/main/java/gregtech/api/interfaces/ITextureBuilder.java b/src/main/java/gregtech/api/interfaces/ITextureBuilder.java index 5cfcffaed9..7c9672d521 100644 --- a/src/main/java/gregtech/api/interfaces/ITextureBuilder.java +++ b/src/main/java/gregtech/api/interfaces/ITextureBuilder.java @@ -64,7 +64,7 @@ public interface ITextureBuilder { /** * Set alpha blending - * + * * @param allowAlpha to set * * @return {@link ITextureBuilder} for chaining diff --git a/src/main/java/gregtech/api/interfaces/internal/IGT_RecipeAdder.java b/src/main/java/gregtech/api/interfaces/internal/IGT_RecipeAdder.java index 71b555e2c0..361e391a9b 100644 --- a/src/main/java/gregtech/api/interfaces/internal/IGT_RecipeAdder.java +++ b/src/main/java/gregtech/api/interfaces/internal/IGT_RecipeAdder.java @@ -36,11 +36,11 @@ public interface IGT_RecipeAdder { /** * Adds a Fusion Reactor Recipe * - * @param FluidOutputArray : Array of input fluids. Up to 16. - * @param FluidOutputArray : Array of output fluids. Up to 16. - * @param aFusionDurationInTicks : How many ticks the Fusion lasts (must be > 0). - * @param aFusionEnergyPerTick : The EU consumed per tick to keep the reaction going. - * @param aEnergyNeededForStartingFusion : EU needed to initialize the fusion reaction. (must be >= 0). + * @param FluidInputArray Array of input fluids. Up to 16. + * @param FluidOutputArray Array of output fluids. Up to 16. + * @param aFusionDurationInTicks How many ticks the Fusion lasts (must be > 0). + * @param aFusionEnergyPerTick The EU consumed per tick to keep the reaction going. + * @param aEnergyNeededForStartingFusion EU needed to initialize the fusion reaction. (must be >= 0). * @return true if the recipe got added, otherwise false. */ @@ -91,7 +91,7 @@ public interface IGT_RecipeAdder { * @param aInput1 must be != null * @param aOutput1 must be != null * @param aDuration must be > 0 - * @return + * @return if the recipe was successfully added */ @Deprecated @@ -509,7 +509,7 @@ public interface IGT_RecipeAdder { * @param aOutput1 must be != null * @param aDuration must be > 0 * @param aEUt should be > 0 - * @return + * @return if the recipe was successfully added */ @Deprecated boolean addOreWasherRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, @@ -626,7 +626,7 @@ public interface IGT_RecipeAdder { * @param aOutput1 must be != null * @param aDuration must be > 0 * @param aEUt should be > 0 - * @return + * @return if the recipe was successfully added */ @Deprecated boolean addThermalCentrifugeRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, @@ -974,12 +974,15 @@ public interface IGT_RecipeAdder { /** * Adds Pyrolyse Recipe * - * @param aInput - * @param intCircuit - * @param aOutput - * @param aFluidOutput - * @param aDuration - * @param aEUt + * @param aInput input item stack + * @param aFluidInput fluid input + * @param intCircuit circuit index + * @param aOutput output item stack + * @param aFluidOutput fluid output + * @param aDuration recipe duration + * @param aEUt recipe EU/t expenditure + * + * @return if the recipe was successfully added */ @Deprecated boolean addPyrolyseRecipe(ItemStack aInput, FluidStack aFluidInput, int intCircuit, ItemStack aOutput, @@ -988,10 +991,10 @@ public interface IGT_RecipeAdder { /** * Adds Oil Cracking Recipe * - * @param aInput - * @param aOutput - * @param aDuration - * @param aEUt + * @param aInput input item stack + * @param aOutput output item stack + * @param aDuration recipe duration + * @param aEUt recipe EU/t expenditure */ @Deprecated boolean addCrackingRecipe(FluidStack aInput, FluidStack aOutput, int aDuration, int aEUt); @@ -1003,8 +1006,8 @@ public interface IGT_RecipeAdder { * @param aInput The fluid to be cracked * @param aInput2 The fluid to catalyze the cracking (typically Hydrogen or Steam) * @param aOutput The cracked fluid - * @param aDuration - * @param aEUt + * @param aDuration recipe duration + * @param aEUt recipe EU/t expenditure */ @Deprecated boolean addCrackingRecipe(int circuitConfig, FluidStack aInput, FluidStack aInput2, FluidStack aOutput, @@ -1029,14 +1032,14 @@ public interface IGT_RecipeAdder { * partly biological, partly metal nanites TIer 2 Nano Forge - Can make mostly metal nanites with some biological * aspects TIer 3 Nano Forge - Can make nanites entierly out of metal * - * @param aInputs = must not be null - * @param aFluidInputs = can be null - * @param aOutputs = must not be null, the nanite or other output - * @param aFluidOutputs = can be null - * @param aChances = can be null - * @param aDuration - * @param aEUt - * @param aSpecialValue = defines the tier of nano forge required. + * @param aInputs must not be null + * @param aFluidInputs can be null + * @param aOutputs must not be null, the nanite or other output + * @param aFluidOutputs can be null + * @param aChances can be null + * @param aDuration recipe duration + * @param aEUt recipe EU/t expenditure + * @param aSpecialValue defines the tier of nano forge required. * */ @Deprecated @@ -1047,12 +1050,12 @@ public interface IGT_RecipeAdder { * Add a Board Manufacturer Recipe. The Board Manufacturer's main use is to make the circuit boards needed to make * circuits. * - * @param aInputs = must not be null - * @param aFluidInputs = must not be null - * @param aOutputs = must not be null - * @param aDuration - * @param aEUt - * @param aSpecialValue = defines the tier of the board manufacturer required. + * @param aInputs must not be null + * @param aFluidInputs must not be null + * @param aOutputs must not be null + * @param aDuration recipe duration + * @param aEUt recipe EU/t expenditure + * @param aSpecialValue defines the tier of the board manufacturer required. */ @Deprecated boolean addPCBFactoryRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack[] aOutputs, int aDuration, diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java index fed9501067..9a60092121 100644 --- a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java @@ -185,7 +185,7 @@ public interface IMetaTileEntity extends ISidedInventory, IFluidTank, IFluidHand void onRemoval(); /** - * @param facing + * @param facing the facing direction to check * @return if aFacing would be a valid Facing for this Device. Used for wrenching. */ boolean isFacingValid(ForgeDirection facing); @@ -267,7 +267,7 @@ public interface IMetaTileEntity extends ISidedInventory, IFluidTank, IFluidHand /** * a Player right-clicks the Machine Sneaky right clicks are not getting passed to this! * - * @return + * @return mostly {@code false}. Probably is left for compatibility. */ boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, float aX, float aY, float aZ); @@ -323,9 +323,9 @@ public interface IMetaTileEntity extends ISidedInventory, IFluidTank, IFluidHand void sendLoopEnd(byte aIndex); /** - * Called when the Machine explodes, override Explosion Code here. + * Called when the Machine explodes. Override the Explosion code here. * - * @param aExplosionPower + * @param aExplosionPower explosion power */ void doExplosion(long aExplosionPower); @@ -457,7 +457,7 @@ public interface IMetaTileEntity extends ISidedInventory, IFluidTank, IFluidHand * The Machine Update, which is called when the Machine needs an Update of its Parts. I suggest to wait 1-5 seconds * before actually checking the Machine Parts. RP-Frames could for example cause Problems when you instacheck the * Machine Parts. - * + * <p> * just do stuff since we are already in meta tile... */ @Override diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java index 0c2c5ebf28..5daf895c20 100644 --- a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java +++ b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java @@ -49,7 +49,7 @@ public interface IMetaTileEntityItemPipe extends IMetaTileEntityPipe { class Util { /** - * @return a List of connected Item Pipes + * @return connected Item Pipes */ public static Map<IMetaTileEntityItemPipe, Long> scanPipes(IMetaTileEntityItemPipe aMetaTileEntity, Map<IMetaTileEntityItemPipe, Long> aMap, long aStep, boolean aSuckItems, boolean aIgnoreCapacity) { diff --git a/src/main/java/gregtech/api/interfaces/modularui/ControllerWithOptionalFeatures.java b/src/main/java/gregtech/api/interfaces/modularui/ControllerWithOptionalFeatures.java index 04b6b4e6a9..e6e3142196 100644 --- a/src/main/java/gregtech/api/interfaces/modularui/ControllerWithOptionalFeatures.java +++ b/src/main/java/gregtech/api/interfaces/modularui/ControllerWithOptionalFeatures.java @@ -1,6 +1,7 @@ package gregtech.api.interfaces.modularui; -import static gregtech.api.metatileentity.BaseTileEntity.*; +import static gregtech.api.metatileentity.BaseTileEntity.BUTTON_FORBIDDEN_TOOLTIP; +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/main/java/gregtech/api/interfaces/tileentity/ICoverable.java b/src/main/java/gregtech/api/interfaces/tileentity/ICoverable.java index 112a7035d7..8834678984 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/ICoverable.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/ICoverable.java @@ -80,7 +80,7 @@ public interface ICoverable extends IRedstoneTileEntity, IHasInventory, IBasicEn /** * Receiving a packet with cover data. * - * @param coverSide + * @param coverSide cover side * @param aPlayer the player who made the change */ default void receiveCoverData(ForgeDirection coverSide, int aCoverID, ISerializableObject aCoverData, diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IGearEnergyTileEntity.java b/src/main/java/gregtech/api/interfaces/tileentity/IGearEnergyTileEntity.java index eefcbcb5ac..7eeee90c8c 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IGearEnergyTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IGearEnergyTileEntity.java @@ -14,7 +14,7 @@ public interface IGearEnergyTileEntity { * Inject Energy Call for Rotational Energy. Rotation Energy can't be stored, this is just for things like internal * Dynamos, which convert it into Energy, or into Progress. * - * @param side + * @param side inject to this side * @param aSpeed Positive = Clockwise, Negative = Counterclockwise */ boolean injectRotationalEnergy(ForgeDirection side, long aSpeed, long aEnergy); diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java b/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java index 5062f0fce5..cccc594c76 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java @@ -62,7 +62,7 @@ public interface IGregTechTileEntity extends ITexturedTileEntity, IGearEnergyTil * one kind of MetaTileEntity so only use this if you are sure its the correct one or you will get a Class cast * Error. * - * @param aMetaTileEntity + * @param aMetaTileEntity a MetaTileEntity */ void setMetaTileEntity(IMetaTileEntity aMetaTileEntity); @@ -177,9 +177,7 @@ public interface IGregTechTileEntity extends ITexturedTileEntity, IGearEnergyTil && getMetaTileEntity().isMachineBlockUpdateRecursive(); } - default void setShutdownStatus(boolean newStatus) { - return; - } + default void setShutdownStatus(boolean newStatus) {} /** * A randomly called display update to be able to add particles or other items for display The event is proxied by diff --git a/src/main/java/gregtech/api/items/GT_CoolantCell_Item.java b/src/main/java/gregtech/api/items/GT_CoolantCell_Item.java index 352448b6b1..6ed7dae3b0 100644 --- a/src/main/java/gregtech/api/items/GT_CoolantCell_Item.java +++ b/src/main/java/gregtech/api/items/GT_CoolantCell_Item.java @@ -13,7 +13,7 @@ import ic2.core.util.StackUtil; public class GT_CoolantCell_Item extends GT_Generic_Item { - protected int heatStorage; + protected final int heatStorage; public GT_CoolantCell_Item(String aUnlocalized, String aEnglish, int aMaxStore) { super(aUnlocalized, aEnglish, null); diff --git a/src/main/java/gregtech/api/items/GT_EnergyArmor_Item.java b/src/main/java/gregtech/api/items/GT_EnergyArmor_Item.java index cec7a86240..9c7b7c173c 100644 --- a/src/main/java/gregtech/api/items/GT_EnergyArmor_Item.java +++ b/src/main/java/gregtech/api/items/GT_EnergyArmor_Item.java @@ -140,7 +140,7 @@ public class GT_EnergyArmor_Item extends ItemArmor implements ISpecialArmor { } if (!aPlayer.worldObj.isRemote && (mSpecials & 128) != 0) { - float jumpCharge = jumpChargeMap.containsKey(aPlayer) ? (Float) jumpChargeMap.get(aPlayer) : 1.0F; + float jumpCharge = jumpChargeMap.getOrDefault(aPlayer, 1.0F); if (GT_ModHandler.canUseElectricItem(aStack, 1000) && aPlayer.onGround && jumpCharge < 1.0F) { jumpCharge = 1.0F; @@ -180,9 +180,7 @@ public class GT_EnergyArmor_Item extends ItemArmor implements ISpecialArmor { } } - if (bonus > 0.0F) { - aPlayer.moveFlying(0.0F, 1.0F, bonus); - } + aPlayer.moveFlying(0.0F, 1.0F, bonus); } } @@ -333,10 +331,9 @@ public class GT_EnergyArmor_Item extends ItemArmor implements ISpecialArmor { private double getBaseAbsorptionRatio() { if (mArmorAbsorbtionPercentage <= 0) return 0.00; return switch (this.armorType) { - case 0 -> 0.15; + case 0, 3 -> 0.15; case 1 -> 0.40; case 2 -> 0.30; - case 3 -> 0.15; default -> 0.00; }; } diff --git a/src/main/java/gregtech/api/items/GT_Generic_Item.java b/src/main/java/gregtech/api/items/GT_Generic_Item.java index 26eafe5130..4410eccc26 100644 --- a/src/main/java/gregtech/api/items/GT_Generic_Item.java +++ b/src/main/java/gregtech/api/items/GT_Generic_Item.java @@ -91,7 +91,6 @@ public class GT_Generic_Item extends Item implements IProjectileItem { return 0; } - @SuppressWarnings("unchecked") @Override public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List<String> aList, boolean aF3_H) { if (getMaxDamage() > 0 && !getHasSubtypes()) diff --git a/src/main/java/gregtech/api/items/GT_MetaBase_Item.java b/src/main/java/gregtech/api/items/GT_MetaBase_Item.java index 4b3c713f22..8a65fbc841 100644 --- a/src/main/java/gregtech/api/items/GT_MetaBase_Item.java +++ b/src/main/java/gregtech/api/items/GT_MetaBase_Item.java @@ -297,10 +297,6 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item if (tStats == null || tStats[2] > aTier || !(tStats[3] == -1 || tStats[3] == -3 || (tStats[3] < 0 && aCharge == Integer.MAX_VALUE)) || aStack.stackSize != 1) return 0; - // REALLY?? THIS IS THE CULPRIT THAT CHARGES ITEMS AT INSTANT!!! - // long tChargeBefore = getRealCharge(aStack), tNewCharge = aCharge == Integer.MAX_VALUE ? Long.MAX_VALUE : - // Math.min(Math.abs(tStats[0]), tChargeBefore + (aIgnoreTransferLimit ? (long) aCharge : Math.min(tStats[1], - // (long) aCharge))); long tTransfer = aIgnoreTransferLimit ? (long) aCharge : Math.min(tStats[1], (long) aCharge); long tChargeBefore = getRealCharge(aStack), tNewCharge = Math.min( Math.abs(tStats[0]), diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item.java index 677ad639c7..14da8254ef 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item.java @@ -134,7 +134,6 @@ public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item implements } if (tRandomData == SubTag.NO_UNIFICATION) { GT_OreDictUnificator.addToBlacklist(rStack); - continue; } } // now check for the rest @@ -161,6 +160,8 @@ public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item implements tUseOreDict = false; } if (tRandomData instanceof IItemBehaviour) { + // The cast below from is not safe. If you know how to make it safe, please do. + // noinspection unchecked addItemBehavior(mOffset + aID, (IItemBehaviour<GT_MetaBase_Item>) tRandomData); tUseOreDict = false; } @@ -182,7 +183,6 @@ public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item implements } if (tUseOreDict) { GT_OreDictUnificator.registerOre(tRandomData, rStack); - continue; } } if (GregTech_API.sThaumcraftCompat != null) diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java index ac5af06ef4..a06a4a7a63 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java @@ -100,7 +100,7 @@ public abstract class GT_MetaGenerated_Item_X32 extends GT_MetaGenerated_Item { // You have to check for at least these Conditions in every Case! So add a super Call like the following for // this before executing your Code: // if (!super.doesMaterialAllowGeneration(aPrefix, aMaterial)) return false; - return aPrefix != null && aMaterial != null && aPrefix.doGenerateItem(aMaterial); + return aPrefix != null && aPrefix.doGenerateItem(aMaterial); } /* ---------- OVERRIDEABLE FUNCTIONS ---------- */ diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java index 9483d401db..ecbea37697 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java @@ -236,7 +236,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item IToolStats tStats = getToolStats(aStack); if (isItemStackUsable(aStack) && getDigSpeed(aStack, aBlock, aMetaData) > 0.0F) doDamage( aStack, - tStats + (long) tStats .convertBlockDrops(aDrops, aStack, aPlayer, aBlock, aX, aY, aZ, aMetaData, aFortune, aSilkTouch, aEvent) * tStats.getToolDamagePerDropConversion()); } @@ -404,6 +404,10 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item // EU/t -> toolCombatDamage, toolSpeed // Overflow Tier -> toolQuality float aBaseEff = (5f + getToolCombatDamage(aStack)) * 1000f; + + // It was noted by IntelliJ that replacing ((GT_MetaGenerated_Tool) aStack.getItem()) with + // GT_MetaGenerated_Tool can have side effects. This refactoring will need tests. + @SuppressWarnings("AccessStaticViaInstance") float aOptFlow = (Math.max( Float.MIN_NORMAL, ((GT_MetaGenerated_Tool) aStack.getItem()).getToolStats(aStack) @@ -615,7 +619,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item @Override public final boolean doDamageToItem(ItemStack aStack, int aVanillaDamage) { - return doDamage(aStack, aVanillaDamage * 100); + return doDamage(aStack, aVanillaDamage * 100L); } public final boolean doDamage(ItemStack aStack, long aAmount) { diff --git a/src/main/java/gregtech/api/items/GT_SolderingTool_Item.java b/src/main/java/gregtech/api/items/GT_SolderingTool_Item.java index 6ec06c91a5..6d84a64e0a 100644 --- a/src/main/java/gregtech/api/items/GT_SolderingTool_Item.java +++ b/src/main/java/gregtech/api/items/GT_SolderingTool_Item.java @@ -28,10 +28,6 @@ public class GT_SolderingTool_Item extends GT_Tool_Item { aDischargedGTID); GT_OreDictUnificator.registerOre(ToolDictNames.craftingToolSolderingIron, new ItemStack(this, 1, W)); GregTech_API.registerSolderingTool(new ItemStack(this, 1, W)); - // setCraftingSound(GregTech_API.sSoundList.get(103)); - // setBreakingSound(GregTech_API.sSoundList.get(103)); - // setEntityHitSound(GregTech_API.sSoundList.get(103)); - // setUsageAmounts(1, 1, 1); } @Override diff --git a/src/main/java/gregtech/api/items/GT_Spray_Pepper_Item.java b/src/main/java/gregtech/api/items/GT_Spray_Pepper_Item.java index 29f6348d82..81517daa0e 100644 --- a/src/main/java/gregtech/api/items/GT_Spray_Pepper_Item.java +++ b/src/main/java/gregtech/api/items/GT_Spray_Pepper_Item.java @@ -52,8 +52,6 @@ public class GT_Spray_Pepper_Item extends GT_Tool_Item { return false; } Block aBlock = aWorld.getBlock(aX, aY, aZ); - // byte aMeta = (byte)aWorld.getBlockMetadata(aX, aY, aZ); - // TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); return false; } diff --git a/src/main/java/gregtech/api/logic/ComplexParallelProcessingLogic.java b/src/main/java/gregtech/api/logic/ComplexParallelProcessingLogic.java index 4c49a88819..07c9f94101 100644 --- a/src/main/java/gregtech/api/logic/ComplexParallelProcessingLogic.java +++ b/src/main/java/gregtech/api/logic/ComplexParallelProcessingLogic.java @@ -23,8 +23,8 @@ public class ComplexParallelProcessingLogic { protected final long[] availableEut; protected final long[] eut; protected final long[] durations; - protected boolean[] isItemVoidProtected; - protected boolean[] isFluidVoidProtected; + protected final boolean[] isItemVoidProtected; + protected final boolean[] isFluidVoidProtected; public ComplexParallelProcessingLogic(int maxComplexParallels) { this(null, maxComplexParallels); diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index 579903db0b..4aa2464853 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -3,7 +3,11 @@ package gregtech.api.metatileentity; import static gregtech.GT_Mod.GT_FML_LOGGER; import static gregtech.api.enums.GT_Values.NW; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.UUID; import net.minecraft.block.Block; import net.minecraft.entity.Entity; @@ -519,11 +523,6 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity } @Override - public void onChunkUnload() { - super.onChunkUnload(); - } - - @Override public boolean hasCustomInventoryName() { return false; } @@ -851,10 +850,6 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity } if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sHardHammerList)) { - // if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { - // GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(1), 1.0F, -1, xCoord, yCoord, - // zCoord); - // } return true; } diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index c4e1ba8521..894eee729c 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -6,7 +6,11 @@ import static gregtech.api.enums.GT_Values.V; import static gregtech.api.objects.XSTR.XSTR_INSTANCE; import java.lang.reflect.Field; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.UUID; import javax.annotation.Nullable; @@ -64,7 +68,10 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachin import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.net.GT_Packet_TileEntity; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.*; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; import gregtech.common.GT_Pollution; import gregtech.common.covers.CoverInfo; import ic2.api.Direction; @@ -90,7 +97,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec protected long mStoredEnergy = 0, mStoredSteam = 0; protected int mAverageEUInputIndex = 0, mAverageEUOutputIndex = 0; protected boolean mReleaseEnergy = false; - protected long[] mAverageEUInput = new long[] { 0, 0, 0, 0, 0 }, mAverageEUOutput = new long[] { 0, 0, 0, 0, 0 }; + protected final long[] mAverageEUInput = new long[] { 0, 0, 0, 0, 0 }; + protected final long[] mAverageEUOutput = new long[] { 0, 0, 0, 0, 0 }; private boolean mHasEnoughEnergy = true, mRunningThroughTick = false, mInputDisabled = false, mOutputDisabled = false, mMuffler = false, mLockUpgrade = false; private boolean mActive = false, mWorkUpdate = false, mSteamConverter = false, mWorks = true; @@ -1375,7 +1383,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec tItemEntity.hurtResistantTime = 999999; tItemEntity.lifespan = 60000; try { - if (ENTITY_ITEM_HEALTH_FIELD != null) ENTITY_ITEM_HEALTH_FIELD.setInt(tItemEntity, 99999999); + ENTITY_ITEM_HEALTH_FIELD.setInt(tItemEntity, 99999999); } catch (Exception ignored) {} this.worldObj.spawnEntityInWorld(tItemEntity); tItem.stackSize = 0; diff --git a/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java b/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java index 4eac3b8158..04f8a457b1 100644 --- a/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java @@ -196,7 +196,7 @@ public abstract class CoverableTileEntity extends BaseTileEntity implements ICov } /** - * Returns false if the tile is no longer valid after ticking the cover + * @return {@code false} if the tile is no longer valid after ticking the cover */ public boolean tickCoverAtSide(ForgeDirection side, long aTickTimer) { final CoverInfo coverInfo = getCoverInfoAtSide(side); diff --git a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java index 011bf1527f..f548949807 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java @@ -87,14 +87,22 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { private IGregTechTileEntity mBaseMetaTileEntity; /** - * This registers your Machine at the List. Use only ID's larger than 2048, because i reserved these ones. See also - * the List in the API, as it has a Description containing all the reservations. + * This registers your Machine at the List. Use only ID's larger than 2048 - the ones lower are reserved by GT. + * See also the list in the API package - it has a description that contains all the reservations. + * <p> + * The constructor can be overloaded as follows: + * <blockquote> + * + * <pre> + * + * public GT_MetaTileEntity_EBench(int id, String name, String nameRegional) { + * super(id, name, nameRegional); + * } + * </pre> + * + * </blockquote> * - * @param aID the ID - * @example for Constructor overload. - * <p/> - * public GT_MetaTileEntity_EBench(int aID, String mName, String mNameRegional) { super(aID, mName, - * mNameRegional); } + * @param aID the machine ID */ public MetaPipeEntity(int aID, String aBasicName, String aRegionalName, int aInvSlotCount) { this(aID, aBasicName, aRegionalName, aInvSlotCount, true); @@ -332,7 +340,7 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { } /** - * a Player rightclicks the Machine Sneaky rightclicks are not getting passed to this! + * Called when a Player rightclicks the Machine. Sneaky rightclicks are not getting passed to this! */ @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java index a6c5497e8e..fc923927ae 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java @@ -109,14 +109,22 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac public long mSoundRequests = 0; /** - * This registers your Machine at the List. Use only ID's larger than 2048, because i reserved these ones. See also - * the List in the API, as it has a Description containing all the reservations. + * This registers your Machine at the List. Use only ID's larger than 2048 - the ones lower are reserved by GT. + * See also the list in the API package - it has a description that contains all the reservations. + * <p> + * The constructor can be overloaded as follows: + * <blockquote> + * + * <pre> + * + * public GT_MetaTileEntity_EBench(int id, String name, String nameRegional) { + * super(id, name, nameRegional); + * } + * </pre> + * + * </blockquote> * - * @param aID the ID - * @example for Constructor overload. - * <p/> - * public GT_MetaTileEntity_EBench(int aID, String mName, String mNameRegional) { super(aID, mName, - * mNameRegional); } + * @param aID the machine ID */ public MetaTileEntity(int aID, String aBasicName, String aRegionalName, int aInvSlotCount) { if (GregTech_API.sPostloadStarted || !GregTech_API.sPreloadStarted) diff --git a/src/main/java/gregtech/api/metatileentity/TileIC2EnergySink.java b/src/main/java/gregtech/api/metatileentity/TileIC2EnergySink.java index 7fb9bc4be6..6fecb840b4 100644 --- a/src/main/java/gregtech/api/metatileentity/TileIC2EnergySink.java +++ b/src/main/java/gregtech/api/metatileentity/TileIC2EnergySink.java @@ -35,34 +35,30 @@ public class TileIC2EnergySink extends TileEntity implements IEnergySink { */ /** - * Determine how much energy the sink accepts. - * - * Make sure that injectEnergy() does accepts energy if demandsEnergy() returns anything > 0. - * - * @note Modifying the energy net from this method is disallowed. + * Determine how much energy the sink accepts. Note that you cannot modify the energy net from this method. + * <p> + * Make sure that {@link TileIC2EnergySink#injectEnergy} accepts energy if this function returns anything positive. * * @return max accepted input in eu */ @Override public double getDemandedEnergy() { if (cableMeta != null) { - // We don't want everything to join the enet (treating the cable as a conductor) so we join it as a ink. We - // don't want to traverse all cables - // connected to this (like we would during distribution) to see if it actually needs any EU... so we just - // always say we want it all. If there - // are more than two things attached, and one of them is a GT cable that doesn't have anywhere to send it's - // energy, the distribution will be a bit - // weird. In that case only use one cable, or use a transformer. + /* + * We don't want everything to join the enet, treating the cable as a conductor, so we join it as a link. + * We don't want to traverse all cables connected to this, like we would during distribution, to see if it + * actually needs any EU, so we just always say we want it all. If there are more than two things attached + * and one of them is a GT cable that doesn't have anywhere to send its energy, the distribution will be a + * bit weird. In that case, use only one cable or a transformer. + */ return (cableMeta.mVoltage * cableMeta.mAmperage); } else return myMeta.getEUCapacity() - myMeta.getStoredEU(); } /** - * Determine the tier of this energy sink. 1 = LV, 2 = MV, 3 = HV, 4 = EV etc. - * - * @note Return Integer.MAX_VALUE to allow any voltage. + * Gets the tier of this energy sink. 1 = LV, 2 = MV, 3 = HV, 4 = EV etc. * - * @return tier of this energy sink + * @return tier of this energy sink or {@link Integer#MAX_VALUE} to allow any voltage */ @Override public int getSinkTier() { @@ -71,7 +67,7 @@ public class TileIC2EnergySink extends TileEntity implements IEnergySink { /** * Transfer energy to the sink. - * + * <p> * It's highly recommended to accept all energy by letting the internal buffer overflow to increase the performance * and accuracy of the distribution simulation. * @@ -105,7 +101,7 @@ public class TileIC2EnergySink extends TileEntity implements IEnergySink { /** * Determine if this acceptor can accept current from an adjacent emitter in a direction. - * + * <p> * The TileEntity in the emitter parameter is what was originally added to the energy net, which may be normal * in-world TileEntity, a delegate or an IMetaDelegate. * diff --git a/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java b/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java index 83c6174438..811a30d341 100644 --- a/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java +++ b/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java @@ -1,6 +1,21 @@ package gregtech.api.metatileentity.examples; -import static gregtech.api.enums.Textures.BlockIcons.*; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_BOTTOM_STEAM_FURNACE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_BOTTOM_STEAM_FURNACE_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_BOTTOM_STEAM_FURNACE_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_BOTTOM_STEAM_FURNACE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_STEAM_FURNACE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_STEAM_FURNACE_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_STEAM_FURNACE_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_STEAM_FURNACE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_SIDE_STEAM_FURNACE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_SIDE_STEAM_FURNACE_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_SIDE_STEAM_FURNACE_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_SIDE_STEAM_FURNACE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_TOP_STEAM_FURNACE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_TOP_STEAM_FURNACE_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_TOP_STEAM_FURNACE_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_TOP_STEAM_FURNACE_GLOW; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java index 59dc65f89a..9d51f6f37e 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java @@ -27,7 +27,10 @@ import net.minecraftforge.common.util.ForgeDirection; import cofh.api.energy.IEnergyReceiver; import gregtech.GT_Mod; import gregtech.api.GregTech_API; -import gregtech.api.enums.*; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TextureSet; +import gregtech.api.enums.Textures; import gregtech.api.graphs.Node; import gregtech.api.graphs.NodeList; import gregtech.api.graphs.PowerNode; @@ -45,7 +48,12 @@ import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.MetaPipeEntity; import gregtech.api.objects.GT_Cover_None; import gregtech.api.render.TextureFactory; -import gregtech.api.util.*; +import gregtech.api.util.GT_CoverBehavior; +import gregtech.api.util.GT_CoverBehaviorBase; +import gregtech.api.util.GT_GC_Compat; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.ISerializableObject; import gregtech.common.GT_Client; import gregtech.common.covers.CoverInfo; import gregtech.common.covers.GT_Cover_SolarPanel; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java index f0d8807e95..5c98724df6 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java @@ -308,7 +308,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE } if (tileEntity instanceof ISidedInventory) { final int[] tSlots = ((ISidedInventory) tileEntity).getAccessibleSlotsFromSide(oppositeSide.ordinal()); - if (tSlots == null || tSlots.length <= 0) return false; + if (tSlots == null || tSlots.length == 0) return false; connectable = true; } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java index 0a589d6919..0285ca932a 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java @@ -226,8 +226,6 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity long tFluidAmountToUse = Math.min( mFluid.amount / tConsumed, (maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); - // long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUOutput() * 20 + - // getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue);//TODO CHECK if (tFluidAmountToUse > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) { // divided by two because this is called every 10 ticks, not 20 diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java index fb8a4e6e21..649d47d89b 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java @@ -629,11 +629,6 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B endProcess(); } if (mProgresstime > 5) mStuttering = false; - // XSTR aXSTR = new XSTR(); - // if(GT_Mod.gregtechproxy.mAprilFool && - // aXSTR.nextInt(5000)==0)GT_Utility.sendSoundToPlayers(aBaseMetaTileEntity.getWorld(), - // GregTech_API.sSoundList.get(5), 10.0F, -1.0F, aBaseMetaTileEntity.getXCoord(), - // aBaseMetaTileEntity.getYCoord(),aBaseMetaTileEntity.getZCoord()); } else { if (!mStuttering) { stutterProcess(); @@ -684,13 +679,6 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B (byte) 64, (byte) 1, tMaxStacks); - // for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && - // aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) { - // tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, - // aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, - // (byte) 1, (byte) 64, (byte) 1); - // if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true); - // } } if (mOutputBlocked != 0) if (isOutputEmpty()) mOutputBlocked = 0; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java index 7d316476bd..c3cb9da636 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java @@ -1,7 +1,13 @@ package gregtech.api.metatileentity.implementations; import static gregtech.api.enums.GT_Values.D1; -import static gregtech.api.enums.Textures.BlockIcons.*; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_BRONZE_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_BRONZE_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_BRONZE_TOP; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_OUT; import static gregtech.api.objects.XSTR.XSTR_INSTANCE; import net.minecraft.entity.EntityLivingBase; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java index ffc51cbd01..4b45708370 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java @@ -28,9 +28,13 @@ import com.gtnewhorizons.modularui.common.widget.ProgressBar; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.enums.*; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.ParticleFX; +import gregtech.api.enums.SoundResource; import gregtech.api.enums.Textures.BlockIcons.CustomIcon; +import gregtech.api.enums.Tier; import gregtech.api.gui.GT_Container_BasicMachine; import gregtech.api.gui.GT_GUIContainer_BasicMachine; import gregtech.api.gui.modularui.GT_UITextures; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java index aaac590fe3..e73fcbe21f 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java @@ -26,7 +26,7 @@ import gregtech.common.gui.modularui.widget.FluidDisplaySlotWidget; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * + * <p> * This is the main construct for my generic Tanks. Filling and emptying behavior have to be implemented manually */ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_TieredMachineBlock diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java index cf1ba436e1..f88bdd0553 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java @@ -1,9 +1,21 @@ package gregtech.api.metatileentity.implementations; import static gregtech.api.enums.GT_Values.V; -import static gregtech.api.enums.Textures.BlockIcons.*; - -import java.util.*; +import static gregtech.api.enums.Textures.BlockIcons.ARROW_DOWN; +import static gregtech.api.enums.Textures.BlockIcons.ARROW_DOWN_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.ARROW_LEFT; +import static gregtech.api.enums.Textures.BlockIcons.ARROW_LEFT_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.ARROW_RIGHT; +import static gregtech.api.enums.Textures.BlockIcons.ARROW_RIGHT_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.ARROW_UP; +import static gregtech.api.enums.Textures.BlockIcons.ARROW_UP_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_OUT; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; import java.util.stream.IntStream; import net.minecraft.entity.player.EntityPlayer; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java index a4456e056c..efb91e3a26 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java @@ -4,7 +4,13 @@ import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.enums.GT_HatchElement.Energy; +import static gregtech.api.enums.GT_HatchElement.InputBus; +import static gregtech.api.enums.GT_HatchElement.InputHatch; +import static gregtech.api.enums.GT_HatchElement.Maintenance; +import static gregtech.api.enums.GT_HatchElement.Muffler; +import static gregtech.api.enums.GT_HatchElement.OutputBus; +import static gregtech.api.enums.GT_HatchElement.OutputHatch; import java.util.List; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ExtendedPowerMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ExtendedPowerMultiBlockBase.java index b5eb13b385..47dd69ba6c 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ExtendedPowerMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ExtendedPowerMultiBlockBase.java @@ -1,6 +1,6 @@ package gregtech.api.metatileentity.implementations; -import static gregtech.api.enums.GT_Values.*; +import static gregtech.api.enums.GT_Values.VN; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java index e659fd10a9..e6d8b13045 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java @@ -30,7 +30,7 @@ public class GT_MetaTileEntity_Hatch_Input extends GT_MetaTileEntity_Hatch { aTier, 3, new String[] { "Fluid Input for Multiblocks", - "Capacity: " + GT_Utility.formatNumbers(8000 * (1 << aTier)) + "L" }); + "Capacity: " + GT_Utility.formatNumbers(8000L * (1L << aTier)) + "L" }); } public GT_MetaTileEntity_Hatch_Input(int aID, int aSlot, String aName, String aNameRegional, int aTier) { @@ -41,7 +41,7 @@ public class GT_MetaTileEntity_Hatch_Input extends GT_MetaTileEntity_Hatch { aTier, aSlot, new String[] { "Fluid Input for Multiblocks", - "Capacity: " + GT_Utility.formatNumbers(8000 * (1 << aTier) / aSlot) + "L", + "Capacity: " + GT_Utility.formatNumbers(8000L * (1L << aTier) / aSlot) + "L", "Can hold " + aSlot + " types of fluid." }); } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java index 0a8144d620..858e87d43e 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java @@ -1,6 +1,7 @@ package gregtech.api.metatileentity.implementations; -import static gregtech.api.enums.Textures.BlockIcons.*; +import static gregtech.api.enums.Textures.BlockIcons.ITEM_IN_SIGN; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_IN; import java.util.ArrayList; import java.util.HashMap; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java index 3b56a2dbbf..d8449bd469 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java @@ -79,19 +79,19 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch @Override public String[] getDescription() { + String[] desc; if (mAuto) { - String[] desc = new String[mDescriptionArray.length + 3]; + desc = new String[mDescriptionArray.length + 3]; System.arraycopy(mDescriptionArray, 0, desc, 0, mDescriptionArray.length); desc[mDescriptionArray.length] = "4 Ducttape, 2 Lubricant Cells"; desc[mDescriptionArray.length + 1] = "4 Steel Screws, 2 HV Circuits"; desc[mDescriptionArray.length + 2] = "For each autorepair"; - return desc; } else { - String[] desc = new String[mDescriptionArray.length + 1]; + desc = new String[mDescriptionArray.length + 1]; System.arraycopy(mDescriptionArray, 0, desc, 0, mDescriptionArray.length); desc[mDescriptionArray.length] = "Cannot be shared between Multiblocks!"; - return desc; } + return desc; } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java index d488eaae3e..932447edbc 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java @@ -13,7 +13,12 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.*; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; +import net.minecraftforge.fluids.IFluidHandler; import com.gtnewhorizons.modularui.api.math.Alignment; import com.gtnewhorizons.modularui.api.screen.ModularWindow; @@ -51,7 +56,7 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch aTier, 4, new String[] { "Fluid Output for Multiblocks", - "Capacity: " + GT_Utility.formatNumbers(8000 * (1 << aTier)) + "L", + "Capacity: " + GT_Utility.formatNumbers(8000L * (1L << aTier)) + "L", "Right click with screwdriver to restrict output", "Can be restricted to put out Items and/or Steam/No Steam/1 specific Fluid", "Restricted Output Hatches are given priority for Multiblock Fluid output" }); diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java index e3915d4854..c30ce51e57 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java @@ -180,10 +180,6 @@ public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch i mInventory.length); for (int i = 0; i < mInventory.length; i++) if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; - // GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity, - // aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), - // null, false, (byte) 64, (byte) 1, (byte)( 64 * - // aBaseMetaTileEntity.getSizeInventory()), (byte) 1); } } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index 7884301e97..a6944449a5 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -1,6 +1,7 @@ package gregtech.api.metatileentity.implementations; -import static gregtech.api.enums.GT_Values.*; +import static gregtech.api.enums.GT_Values.V; +import static gregtech.api.enums.GT_Values.VN; import static mcp.mobius.waila.api.SpecialChars.GREEN; import static mcp.mobius.waila.api.SpecialChars.RED; import static mcp.mobius.waila.api.SpecialChars.RESET; @@ -35,7 +36,11 @@ import com.google.common.collect.Iterables; import com.gtnewhorizons.modularui.api.math.Pos2d; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; -import com.gtnewhorizons.modularui.common.widget.*; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.DynamicPositionedColumn; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -56,8 +61,16 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.*; +import gregtech.api.util.GT_ExoticEnergyInputHelper; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_ParallelHelper; +import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Single_Recipe_Check; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.GT_Waila; +import gregtech.api.util.VoidProtectionHelper; import gregtech.client.GT_SoundLoop; import gregtech.common.GT_Pollution; import gregtech.common.items.GT_MetaGenerated_Tool_01; @@ -89,10 +102,10 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity protected boolean inputSeparation = false; protected VoidingMode voidingMode = VoidingMode.VOID_ALL; protected boolean batchMode = false; - protected static String INPUT_SEPARATION_NBT_KEY = "inputSeparation"; - protected static String VOID_EXCESS_NBT_KEY = "voidExcess"; - protected static String VOIDING_MODE_NBT_KEY = "voidingMode"; - protected static String BATCH_MODE_NBT_KEY = "batchMode"; + protected static final String INPUT_SEPARATION_NBT_KEY = "inputSeparation"; + protected static final String VOID_EXCESS_NBT_KEY = "voidExcess"; + protected static final String VOIDING_MODE_NBT_KEY = "voidingMode"; + protected static final String BATCH_MODE_NBT_KEY = "batchMode"; public GT_Single_Recipe_Check mSingleRecipeCheck = null; public ArrayList<GT_MetaTileEntity_Hatch_Input> mInputHatches = new ArrayList<>(); @@ -721,6 +734,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity GT_Pollution.addPollution(getBaseMetaTileEntity(), GT_Mod.gregtechproxy.mPollutionOnExplosion); mInventory[1] = null; + // noinspection unchecked // In this case, the inspection only indicates that the array can be abused in runtime Iterable<MetaTileEntity> allHatches = Iterables.concat( mInputBusses, mOutputBusses, @@ -867,7 +881,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity mMaxProgresstime >>= ocTimeShift; // this is effect of overclocking if (mMaxProgresstime < 1) { if (oldTime == 1) break; - xEUt *= oldTime * (perfectOC ? 1 : 2); + xEUt *= (long) oldTime * (perfectOC ? 1 : 2); break; } else { xEUt <<= 2; @@ -1034,11 +1048,6 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity public ArrayList<ItemStack> getStoredOutputs() { ArrayList<ItemStack> rList = new ArrayList<>(); - // for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { - // if (isValidMetaTileEntity(tHatch)) { - // rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(1)); - // } - // } for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) { if (isValidMetaTileEntity(tHatch)) { for (int i = tHatch.getBaseMetaTileEntity() diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Dynamo.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Dynamo.java index d677b76248..821c02d10f 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Dynamo.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Dynamo.java @@ -1,6 +1,7 @@ package gregtech.api.metatileentity.implementations; -import static gregtech.api.enums.GT_Values.*; +import static gregtech.api.enums.GT_Values.AuthorColen; +import static gregtech.api.enums.GT_Values.V; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Hatch.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Hatch.java index 4c1c7b4cb9..9a4f8d6b56 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Hatch.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Hatch.java @@ -1,6 +1,7 @@ package gregtech.api.metatileentity.implementations; -import static gregtech.api.enums.GT_Values.*; +import static gregtech.api.enums.GT_Values.AuthorColen; +import static gregtech.api.enums.GT_Values.V; import java.math.BigInteger; diff --git a/src/main/java/gregtech/api/net/GT_Packet_Sound.java b/src/main/java/gregtech/api/net/GT_Packet_Sound.java index f742c39dba..fdaf5b3979 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_Sound.java +++ b/src/main/java/gregtech/api/net/GT_Packet_Sound.java @@ -1,6 +1,5 @@ package gregtech.api.net; -import java.io.DataOutput; import java.io.IOException; import net.minecraft.world.IBlockAccess; @@ -35,14 +34,13 @@ public class GT_Packet_Sound extends GT_Packet_New { @Override public void encode(ByteBuf aOut) { - DataOutput tOut = new ByteBufOutputStream(aOut); - try { - tOut.writeUTF(mSoundName); - tOut.writeFloat(mSoundStrength); - tOut.writeFloat(mSoundPitch); - tOut.writeInt(mX); - tOut.writeShort(mY); - tOut.writeInt(mZ); + try (ByteBufOutputStream byteOutputStream = new ByteBufOutputStream(aOut)) { + byteOutputStream.writeUTF(mSoundName); + byteOutputStream.writeFloat(mSoundStrength); + byteOutputStream.writeFloat(mSoundPitch); + byteOutputStream.writeInt(mX); + byteOutputStream.writeShort(mY); + byteOutputStream.writeInt(mZ); } catch (IOException e) { // this really shouldn't happen, but whatever e.printStackTrace(GT_Log.err); diff --git a/src/main/java/gregtech/api/objects/GT_ChunkManager.java b/src/main/java/gregtech/api/objects/GT_ChunkManager.java index dd87c8c72e..14baaddd3d 100644 --- a/src/main/java/gregtech/api/objects/GT_ChunkManager.java +++ b/src/main/java/gregtech/api/objects/GT_ChunkManager.java @@ -21,7 +21,9 @@ import gregtech.api.interfaces.IChunkLoader; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Log; -// This class handles re-initializing chunks after a server restart +/** + * Handles re-initialization of chunks after a server restart. + */ public class GT_ChunkManager implements ForgeChunkManager.OrderedLoadingCallback, ForgeChunkManager.PlayerOrderedLoadingCallback { @@ -30,17 +32,25 @@ public class GT_ChunkManager public static void init() { ForgeChunkManager.setForcedChunkLoadingCallback(GT_Mod.instance, instance); - // MinecraftForge.EVENT_BUS.register(instance); } @Override public void ticketsLoaded(List<Ticket> tickets, World world) {} - // Determine if tickets should be kept. Based on if the ticket is a machine or working chunk ticket. Working chunk - // tickets are tossed - // and re-created when the machine re-activates. Machine tickets are kept only if the config - // alwaysReloadChunkloaders is true. Otherwise - // machine chunks are tossed and re-created only when the machine re-activates, similar to a Passive Anchor. + /** + * Determines if tickets should be kept. Based on if the ticket is a machine or a working-chunk ticket. + * Working-chunk tickets are tossed and recreated when the machine reactivates. + * Machine tickets are kept only if the config {@code alwaysReloadChunkloaders} is true. + * Otherwise, machine chunks are tossed and recreated only when the machine reactivates, + * similarly to a Passive Anchor. + * + * @param tickets The tickets that you will want to select from. + * The list is immutable and cannot be manipulated directly. Copy it first. + * @param world The world + * @param maxTicketCount The maximum number of tickets that will be allowed. + * @return list of tickets + */ + @Override public List<Ticket> ticketsLoaded(List<Ticket> tickets, World world, int maxTicketCount) { List<Ticket> validTickets = new ArrayList<>(); @@ -54,8 +64,7 @@ public class GT_ChunkManager .getInteger("OwnerZ"); if (y > 0) { TileEntity tile = world.getTileEntity(x, y, z); - if (tile != null && tile instanceof IGregTechTileEntity - && ((IGregTechTileEntity) tile).isAllowedToWork()) { + if (tile instanceof IGregTechTileEntity && ((IGregTechTileEntity) tile).isAllowedToWork()) { ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(x >> 4, z >> 4)); if (!registeredTickets.containsKey(tile)) { registeredTickets.put(tile, ticket); @@ -72,19 +81,32 @@ public class GT_ChunkManager return validTickets; } - // Determine if player tickets should be kept. This is where a ticket list per player would be created and - // maintained. When - // a player join event occurs, their name/UUID/whatevs is compared against tickets on this list and those tickets - // reactivated. - // Since that info would be maintained/dealt with on a per-player startup, the list returned back to Forge is empty. + /** + * Determines if player tickets should be kept. This is where a ticket list per-player would be created and + * maintained. When a player joins, an event occurs, their name/UUID/etc is compared against tickets on this list + * and those tickets are reactivated. + * Since that info would be maintained/dealt with on a per-player startup, the list returned back to Forge is empty. + * + * @param tickets The tickets that you will want to select from. + * The list is immutable and cannot be manipulated directly. Copy it first. + * @param world The world + * @return the list of string-ticket paris + */ @Override public ListMultimap<String, Ticket> playerTicketsLoaded(ListMultimap<String, Ticket> tickets, World world) { // Not currently used, so just return an empty list. return ArrayListMultimap.create(); } - // Request a chunk to be loaded for this machine - // may pass null chunk to load just the machine itself, if "alwaysReloadChunkloaders" is enabled in config + /** + * Requests a chunk to be loaded for this machine. May pass a {@code null} chunk to load just the machine itself if + * {@code alwaysReloadChunkloaders} is enabled in config. + * + * @param owner owner of the TileEntity + * @param chunkXZ chunk coordinates + * @param player player + * @return if the chunk was loaded successfully + */ public static boolean requestPlayerChunkLoad(TileEntity owner, ChunkCoordIntPair chunkXZ, String player) { if (!GT_Values.enableChunkloaders) return false; if (!GT_Values.alwaysReloadChunkloaders && chunkXZ == null) return false; @@ -122,6 +144,7 @@ public class GT_ChunkManager return true; } + @SuppressWarnings("UnusedReturnValue") public static boolean requestChunkLoad(TileEntity owner, ChunkCoordIntPair chunkXZ) { return requestPlayerChunkLoad(owner, chunkXZ, ""); } diff --git a/src/main/java/gregtech/api/objects/GT_FluidStack.java b/src/main/java/gregtech/api/objects/GT_FluidStack.java index f0a6dae8e5..5a017fd590 100644 --- a/src/main/java/gregtech/api/objects/GT_FluidStack.java +++ b/src/main/java/gregtech/api/objects/GT_FluidStack.java @@ -2,16 +2,12 @@ package gregtech.api.objects; import java.util.Collection; import java.util.Collections; -import java.util.Map; import java.util.WeakHashMap; -import net.minecraftforge.common.ForgeVersion; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import gregtech.api.GregTech_API; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_Utility; /** * Because Forge fucked this one up royally. @@ -20,7 +16,6 @@ public class GT_FluidStack extends FluidStack { private static final Collection<GT_FluidStack> sAllFluidStacks = Collections .newSetFromMap(new WeakHashMap<>(10000)); - private static volatile boolean lock = false; private final Fluid mFluid; public GT_FluidStack(Fluid aFluid, int aAmount) { @@ -35,46 +30,8 @@ public class GT_FluidStack extends FluidStack { this(aFluid.getFluid(), aFluid.amount); } - public static final synchronized void fixAllThoseFuckingFluidIDs() { - if (ForgeVersion.getBuildVersion() < 1355 && ForgeVersion.getRevisionVersion() < 4) { - try { - while (lock) { - Thread.sleep(1); - } - } catch (InterruptedException e) {} - lock = true; - for (GT_FluidStack tFluid : sAllFluidStacks) tFluid.fixFluidIDForFucksSake(); - try { - for (Map<Fluid, ?> tMap : GregTech_API.sFluidMappings) GT_Utility.reMap(tMap); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - lock = false; - } - } - - public final void fixFluidIDForFucksSake() { - if (ForgeVersion.getBuildVersion() < 1355 && ForgeVersion.getRevisionVersion() < 4) { - int fluidID; - try { - fluidID = this.getFluid() - .getID(); - } catch (Throwable e) { - System.err.println(e); - } - try { - fluidID = mFluid.getID(); - } catch (Throwable e) { - fluidID = -1; - } - } - } - @Override public FluidStack copy() { - if (ForgeVersion.getBuildVersion() < 1355 && ForgeVersion.getRevisionVersion() < 4) { - fixFluidIDForFucksSake(); - } return new GT_FluidStack(this); } diff --git a/src/main/java/gregtech/api/objects/GT_HashSet.java b/src/main/java/gregtech/api/objects/GT_HashSet.java index 6442631035..d42f194e5d 100644 --- a/src/main/java/gregtech/api/objects/GT_HashSet.java +++ b/src/main/java/gregtech/api/objects/GT_HashSet.java @@ -1,6 +1,11 @@ package gregtech.api.objects; -import java.util.*; +import java.util.AbstractSet; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; import net.minecraft.item.ItemStack; @@ -42,6 +47,7 @@ public class GT_HashSet<E extends GT_ItemStack> extends AbstractSet<E> { return map; } + @SuppressWarnings("unchecked") // The downcasting below will throw ClassCastException unless E is GT_ItemStack. @Override public Iterator<E> iterator() { return (Iterator<E>) map.keySet() diff --git a/src/main/java/gregtech/api/objects/GT_ItemStack.java b/src/main/java/gregtech/api/objects/GT_ItemStack.java index 27e79a3e96..1273b7111d 100644 --- a/src/main/java/gregtech/api/objects/GT_ItemStack.java +++ b/src/main/java/gregtech/api/objects/GT_ItemStack.java @@ -7,6 +7,10 @@ import net.minecraft.item.ItemStack; import gregtech.api.enums.GT_Values; import gregtech.api.util.GT_Utility; +/** + * An optimization of {@link ItemStack} to have a better {@code hashcode} and {@code equals} in order to improve + * {@code HashMap} and {@code Set} performance + */ public class GT_ItemStack { public final Item mItem; diff --git a/src/main/java/gregtech/api/objects/ItemData.java b/src/main/java/gregtech/api/objects/ItemData.java index c6a04bbb7e..779e45ac8b 100644 --- a/src/main/java/gregtech/api/objects/ItemData.java +++ b/src/main/java/gregtech/api/objects/ItemData.java @@ -1,6 +1,8 @@ package gregtech.api.objects; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import net.minecraft.item.ItemStack; @@ -115,8 +117,6 @@ public class ItemData { @Override public String toString() { if (mPrefix == null || mMaterial == null || mMaterial.mMaterial == null) return ""; - return String.valueOf( - new StringBuilder().append(mPrefix.name()) - .append(mMaterial.mMaterial.mName)); + return String.valueOf(mPrefix.name() + mMaterial.mMaterial.mName); } } diff --git a/src/main/java/gregtech/api/objects/ObjMap.java b/src/main/java/gregtech/api/objects/ObjMap.java index bb15aab0d7..badc673464 100644 --- a/src/main/java/gregtech/api/objects/ObjMap.java +++ b/src/main/java/gregtech/api/objects/ObjMap.java @@ -191,7 +191,7 @@ public class ObjMap<K, V> { return key.hashCode() & m_mask; } - /** Taken from FastUtil implementation */ + /* Taken from FastUtil implementation */ /** * Return the least power of two greater than or equal to the specified value. diff --git a/src/main/java/gregtech/api/objects/XSTR.java b/src/main/java/gregtech/api/objects/XSTR.java index 1ce5273e7e..33823d3ebd 100644 --- a/src/main/java/gregtech/api/objects/XSTR.java +++ b/src/main/java/gregtech/api/objects/XSTR.java @@ -1,29 +1,33 @@ package gregtech.api.objects; +import java.util.Random; +import java.util.concurrent.atomic.AtomicLong; + +/* + * TODO: Check the validity of the algorithm. + * There is a claim that this particular implementation is not faithful to the articles it links, skewing the + * distribution. + */ /** + * XSTR - Xorshift ThermiteRandom Modified by Bogdan-G 03.06.2016 version 0.0.4 + * <p> * A subclass of java.util.random that implements the Xorshift random number generator - * + * <p> * - it is 30% faster than the generator from Java's library - it produces random sequences of higher quality than * java.util.Random - this class also provides a clone() function - * + * <p> * Usage: XSRandom rand = new XSRandom(); //Instantiation x = rand.nextInt(); //pull a random number - * + * <p> * To use the class in legacy code, you may also instantiate an XSRandom object and assign it to a java.util.Random * object: java.util.Random rand = new XSRandom(); - * + * <p> * for an explanation of the algorithm, see http://demesos.blogspot.com/2011/09/pseudo-random-number-generators.html * * @author Wilfried Elmenreich University of Klagenfurt/Lakeside Labs http://www.elmenreich.tk - * + * <p> * This code is released under the GNU Lesser General Public License Version 3 * http://www.gnu.org/licenses/lgpl-3.0.txt */ -import java.util.Random; -import java.util.concurrent.atomic.AtomicLong; - -/** - * XSTR - Xorshift ThermiteRandom Modified by Bogdan-G 03.06.2016 version 0.0.4 - */ public class XSTR extends Random { private static final long serialVersionUID = 6208727693524452904L; @@ -118,11 +122,12 @@ public class XSTR extends Random { } /** - * Implementation of George Marsaglia's elegant Xorshift random generator 30% faster and better quality than the - * built-in java.util.random see also see http://www.javamex.com/tutorials/random_numbers/xorshift.shtml + * Implementation of George Marsaglia's Xorshift random generator that is 30% faster and better quality than the + * built-in java.util.random. * - * @param nbits - * @return + * @param nbits number of bits to shift the result for + * @return a random integer + * @see <a href="https://www.javamex.com/tutorials/random_numbers/xorshift.shtml">the Xorshift article</a> */ @Override public int next(int nbits) { diff --git a/src/main/java/gregtech/api/render/TextureFactory.java b/src/main/java/gregtech/api/render/TextureFactory.java index 6a49165ad4..26142fd606 100644 --- a/src/main/java/gregtech/api/render/TextureFactory.java +++ b/src/main/java/gregtech/api/render/TextureFactory.java @@ -21,7 +21,7 @@ import gregtech.common.render.GT_TextureBuilder; * <p> * Example of the {@link #builder()}: * </p> - * + * * <pre> * {@code * // Texture that glows in the dark @@ -31,7 +31,7 @@ import gregtech.common.render.GT_TextureBuilder; * TextureFactory.builder().addIcon(GRANITE_RED_STONE).stdOrient().build(); * } * </pre> - * + * * See: the {@link ITextureBuilder} interface */ @SuppressWarnings("unused") 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 |