diff options
| author | Jason Mitchell <mitchej@gmail.com> | 2023-01-30 10:56:42 -0800 |
|---|---|---|
| committer | Jason Mitchell <mitchej@gmail.com> | 2023-01-30 10:56:42 -0800 |
| commit | 0d9aab72aa570f13dc3e32e0d32b3f3a95f95e0a (patch) | |
| tree | 1e2c649f3a6ce3f6b2babd0098a5f4819e9cd0b6 /src/main/java/gregtech/api/util | |
| parent | f8cc82edeb9810c45cba762d733a2c909a302faa (diff) | |
| download | GT5-Unofficial-0d9aab72aa570f13dc3e32e0d32b3f3a95f95e0a.tar.gz GT5-Unofficial-0d9aab72aa570f13dc3e32e0d32b3f3a95f95e0a.tar.bz2 GT5-Unofficial-0d9aab72aa570f13dc3e32e0d32b3f3a95f95e0a.zip | |
[ci skip] spotlessApply with the new settings
Diffstat (limited to 'src/main/java/gregtech/api/util')
53 files changed, 5387 insertions, 6461 deletions
diff --git a/src/main/java/gregtech/api/util/ColorsMetadataSection.java b/src/main/java/gregtech/api/util/ColorsMetadataSection.java index c7ec2c8aa3..d8ce59f42c 100644 --- a/src/main/java/gregtech/api/util/ColorsMetadataSection.java +++ b/src/main/java/gregtech/api/util/ColorsMetadataSection.java @@ -1,21 +1,24 @@ package gregtech.api.util; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.HashMap; import java.util.Map; + import net.minecraft.client.resources.data.IMetadataSection; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + @SideOnly(Side.CLIENT) public class ColorsMetadataSection implements IMetadataSection { + private final Map<String, Integer> textColors; private final Map<String, String> hexTextColors; private final Map<String, Integer> guiTints; private final Map<String, String> hexGuiTints; private final boolean guiTintEnabled; - public ColorsMetadataSection( - Map<String, String> hexTextColorMap, Map<String, String> hexGuiTintMap, boolean guiTintEnabled) { + public ColorsMetadataSection(Map<String, String> hexTextColorMap, Map<String, String> hexGuiTintMap, + boolean guiTintEnabled) { this.hexTextColors = hexTextColorMap; this.textColors = convertHexMapToIntMap(hexTextColorMap); diff --git a/src/main/java/gregtech/api/util/ColorsMetadataSectionSerializer.java b/src/main/java/gregtech/api/util/ColorsMetadataSectionSerializer.java index b58c00db88..cab41e0d3b 100644 --- a/src/main/java/gregtech/api/util/ColorsMetadataSectionSerializer.java +++ b/src/main/java/gregtech/api/util/ColorsMetadataSectionSerializer.java @@ -1,25 +1,29 @@ package gregtech.api.util; +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.client.resources.data.BaseMetadataSectionSerializer; +import net.minecraft.util.JsonUtils; + import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.Dyes; -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.Map; -import net.minecraft.client.resources.data.BaseMetadataSectionSerializer; -import net.minecraft.util.JsonUtils; @SideOnly(Side.CLIENT) public class ColorsMetadataSectionSerializer extends BaseMetadataSectionSerializer implements JsonSerializer { - public ColorsMetadataSection deserialize( - JsonElement metadataColors, Type type, JsonDeserializationContext context) { + + public ColorsMetadataSection deserialize(JsonElement metadataColors, Type type, + JsonDeserializationContext context) { // Default values boolean enableGuiTint = GregTech_API.sColoredGUI; Map<String, String> hexGuiTintMap = new HashMap<>(); @@ -39,8 +43,8 @@ public class ColorsMetadataSectionSerializer extends BaseMetadataSectionSerializ if (jsonObject.has("guiTint")) { JsonObject guiTints = JsonUtils.func_152754_s(jsonObject, "guiTint"); - enableGuiTint = - JsonUtils.getJsonObjectBooleanFieldValueOrDefault(guiTints, "enableGuiTintWhenPainted", true); + enableGuiTint = JsonUtils + .getJsonObjectBooleanFieldValueOrDefault(guiTints, "enableGuiTintWhenPainted", true); for (Dyes dye : Dyes.values()) { hexGuiTintMap.put(dye.mName, GT_Util.toHexString(dye.getRGBA())); diff --git a/src/main/java/gregtech/api/util/GT_ApiaryModifier.java b/src/main/java/gregtech/api/util/GT_ApiaryModifier.java index eee97a4458..bb5c760556 100644 --- a/src/main/java/gregtech/api/util/GT_ApiaryModifier.java +++ b/src/main/java/gregtech/api/util/GT_ApiaryModifier.java @@ -3,6 +3,7 @@ package gregtech.api.util; import net.minecraft.world.biome.BiomeGenBase; public class GT_ApiaryModifier { + public float territory = 1f; public float mutation = 1f; public float lifespan = 1f; diff --git a/src/main/java/gregtech/api/util/GT_ApiaryUpgrade.java b/src/main/java/gregtech/api/util/GT_ApiaryUpgrade.java index d4b00d99b2..b54697fdfc 100644 --- a/src/main/java/gregtech/api/util/GT_ApiaryUpgrade.java +++ b/src/main/java/gregtech/api/util/GT_ApiaryUpgrade.java @@ -1,14 +1,17 @@ package gregtech.api.util; -import gregtech.api.enums.OrePrefixes; -import gregtech.common.items.GT_MetaGenerated_Item_03; import java.util.*; import java.util.function.BiConsumer; import java.util.function.Consumer; + import net.minecraft.item.ItemStack; import net.minecraft.world.biome.BiomeGenBase; +import gregtech.api.enums.OrePrefixes; +import gregtech.common.items.GT_MetaGenerated_Item_03; + public enum GT_ApiaryUpgrade { + speed1(UNIQUE_INDEX.SPEED_UPGRADE, 32200, 1, (mods, n) -> mods.maxSpeed = 1), speed2(UNIQUE_INDEX.SPEED_UPGRADE, 32201, 1, (mods, n) -> mods.maxSpeed = 2), speed3(UNIQUE_INDEX.SPEED_UPGRADE, 32202, 1, (mods, n) -> mods.maxSpeed = 3), @@ -105,10 +108,10 @@ public enum GT_ApiaryUpgrade { sieve(UNIQUE_INDEX.SIEVE_UPGRADE, 32229, 1, (mods, n) -> { mods.isCollectingPollen = true; mods.energy *= 1.05f; - }), - ; + }),; private enum UNIQUE_INDEX { + SPEED_UPGRADE, PRODUCTION_UPGRADE, PLAINS_UPGRADE, @@ -130,16 +133,15 @@ public enum GT_ApiaryUpgrade { OCEAN_UPGRADE, SKY_UPGRADE, HEATER_UPGRADE, - SIEVE_UPGRADE, - ; + SIEVE_UPGRADE,; void apply(Consumer<GT_ApiaryUpgrade> fn) { UNIQUE_UPGRADE_LIST.get(this).forEach(fn); } } - private static final EnumMap<UNIQUE_INDEX, ArrayList<GT_ApiaryUpgrade>> UNIQUE_UPGRADE_LIST = - new EnumMap<>(UNIQUE_INDEX.class); + private static final EnumMap<UNIQUE_INDEX, ArrayList<GT_ApiaryUpgrade>> UNIQUE_UPGRADE_LIST = new EnumMap<>( + UNIQUE_INDEX.class); private int meta = 0; private int maxnumber = 1; @@ -150,8 +152,8 @@ public enum GT_ApiaryUpgrade { private final HashSet<GT_Utility.ItemId> blacklistedUpgrades = new HashSet<>(); - GT_ApiaryUpgrade( - UNIQUE_INDEX unique_index, int meta, int maxnumber, BiConsumer<GT_ApiaryModifier, Integer> applier) { + GT_ApiaryUpgrade(UNIQUE_INDEX unique_index, int meta, int maxnumber, + BiConsumer<GT_ApiaryModifier, Integer> applier) { this.unique_index = unique_index; this.meta = meta; this.maxnumber = maxnumber; @@ -162,11 +164,10 @@ public enum GT_ApiaryUpgrade { private void setup_static_variables() { quickLookup.put(this.meta, this); ArrayList<GT_ApiaryUpgrade> un = UNIQUE_UPGRADE_LIST.get(this.unique_index); - if (un != null) - un.forEach((u) -> { - u.blacklistedUpgrades.add(this.id); - this.blacklistedUpgrades.add(u.id); - }); + if (un != null) un.forEach((u) -> { + u.blacklistedUpgrades.add(this.id); + this.blacklistedUpgrades.add(u.id); + }); else { un = new ArrayList<>(1); UNIQUE_UPGRADE_LIST.put(this.unique_index, un); diff --git a/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java b/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java index f20a78d494..218e5bffdc 100644 --- a/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java +++ b/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java @@ -2,17 +2,14 @@ package gregtech.api.util; import static gregtech.GT_Mod.GT_FML_LOGGER; -import cpw.mods.fml.common.FMLCommonHandler; -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.ItemList; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.GT_Recipe.GT_Recipe_AssemblyLine; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Objects; + import javax.annotation.Nonnull; + import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -20,21 +17,26 @@ import net.minecraft.nbt.NBTTagString; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.fluids.FluidStack; +import cpw.mods.fml.common.FMLCommonHandler; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.util.GT_Recipe.GT_Recipe_AssemblyLine; + public class GT_AssemblyLineUtils { /** * A cache of Recipes using the Output as Key. */ - private static HashMap<GT_ItemStack, GT_Recipe_AssemblyLine> sRecipeCacheByOutput = - new HashMap<GT_ItemStack, GT_Recipe_AssemblyLine>(); + private static HashMap<GT_ItemStack, GT_Recipe_AssemblyLine> sRecipeCacheByOutput = new HashMap<GT_ItemStack, GT_Recipe_AssemblyLine>(); /** * A cache of Recipes using the Recipe Hash String as Key. */ - private static HashMap<String, GT_Recipe_AssemblyLine> sRecipeCacheByRecipeHash = - new HashMap<String, GT_Recipe_AssemblyLine>(); + private static HashMap<String, GT_Recipe_AssemblyLine> sRecipeCacheByRecipeHash = new HashMap<String, GT_Recipe_AssemblyLine>(); /** * Checks the DataStick for deprecated/invalid recipes, updating them as required. + * * @param aDataStick - The DataStick to process * @return Is this DataStick now valid with a current recipe? */ @@ -55,6 +57,7 @@ public class GT_AssemblyLineUtils { /** * Finds an Assembly Line recipe from a DataStick. + * * @param aDataStick - The DataStick to check. * @return The GT_Recipe_AssemblyLine recipe contained on the DataStick, if any. */ @@ -64,8 +67,10 @@ public class GT_AssemblyLineUtils { /** * Finds an Assembly Line recipe from a DataStick. - * @param aDataStick - The DataStick to check. - * @param aReturnBuiltRecipe - Do we return a GT_Recipe_AssemblyLine built from the data on the Data Stick instead of searching the Recipe Map? + * + * @param aDataStick - The DataStick to check. + * @param aReturnBuiltRecipe - Do we return a GT_Recipe_AssemblyLine built from the data on the Data Stick instead + * of searching the Recipe Map? * @return The GT_Recipe_AssemblyLine recipe contained on the DataStick, if any. */ @Nonnull @@ -131,8 +136,7 @@ public class GT_AssemblyLineUtils { GT_FML_LOGGER.info("Fluid " + i + " " + tLoaded.getUnlocalizedName()); } } - if (!aTag.hasKey("output") - || !aTag.hasKey("time") + if (!aTag.hasKey("output") || !aTag.hasKey("time") || aTag.getInteger("time") <= 0 || !aTag.hasKey("eu") || !GT_Utility.isStackValid(aOutput)) { @@ -147,14 +151,15 @@ public class GT_AssemblyLineUtils { // Try build a recipe instance if (aReturnBuiltRecipe) { - return LookupResultType.VALID_STACK_AND_VALID_HASH.getResult(new GT_Recipe_AssemblyLine( - null, - 0, - aInputs.toArray(new ItemStack[0]), - aFluidInputs.toArray(new FluidStack[0]), - aOutput, - aTime, - aEU)); + return LookupResultType.VALID_STACK_AND_VALID_HASH.getResult( + new GT_Recipe_AssemblyLine( + null, + 0, + aInputs.toArray(new ItemStack[0]), + aFluidInputs.toArray(new FluidStack[0]), + aOutput, + aTime, + aEU)); } for (GT_Recipe_AssemblyLine aRecipe : GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes) { @@ -186,13 +191,13 @@ public class GT_AssemblyLineUtils { } private static boolean areStacksEqual(ItemStack[] lhs, List<ItemStack> rhs) { - return lhs == null - ? rhs.isEmpty() + return lhs == null ? rhs.isEmpty() : !rhs.isEmpty() && GT_Utility.areStackListsEqual(Arrays.asList(lhs), rhs, false, true); } /** * Finds a GT_Recipe_AssemblyLine based on the expected output ItemStack. + * * @param aOutput - The Output of a GT_Recipe_AssemblyLine. * @return First found GT_Recipe_AssemblyLine with matching output. */ @@ -273,8 +278,7 @@ public class GT_AssemblyLineUtils { * @return Does this Data Stick have a valid output ItemStack? */ public static boolean doesDataStickHaveOutput(ItemStack aDataStick) { - if (isItemDataStick(aDataStick) - && aDataStick.hasTagCompound() + if (isItemDataStick(aDataStick) && aDataStick.hasTagCompound() && aDataStick.getTagCompound().hasKey("output")) { return true; } @@ -306,8 +310,7 @@ public class GT_AssemblyLineUtils { public static boolean doesDataStickHaveRecipeHash(ItemStack aDataStick) { if (isItemDataStick(aDataStick) && aDataStick.hasTagCompound()) { NBTTagCompound aNBT = aDataStick.getTagCompound(); - if (aNBT.hasKey("Data.Recipe.Hash") - && !aNBT.getString("Data.Recipe.Hash").equals("Hash.0")) { + if (aNBT.hasKey("Data.Recipe.Hash") && !aNBT.getString("Data.Recipe.Hash").equals("Hash.0")) { return true; } } @@ -316,6 +319,7 @@ public class GT_AssemblyLineUtils { /** * Get the Output ItemStack from a Data Stick. + * * @param aDataStick - The Data Stick to check. * @return Output ItemStack contained on the Data Stick. */ @@ -329,9 +333,11 @@ public class GT_AssemblyLineUtils { /** * @param aDataStick - The Data Stick to process. - * @return The stored Recipe Hash String on the Data Stick, will return an invalid Hash if one is not found. <p> - * The hash will be guaranteed to pass isValidHash(). <p> - * Will not return Null. + * @return The stored Recipe Hash String on the Data Stick, will return an invalid Hash if one is not found. + * <p> + * The hash will be guaranteed to pass isValidHash(). + * <p> + * Will not return Null. */ public static String getHashFromDataStack(ItemStack aDataStick) { if (isItemDataStick(aDataStick) && aDataStick.hasTagCompound()) { @@ -346,7 +352,7 @@ public class GT_AssemblyLineUtils { /** * - * @param aDataStick - The Data Stick to update. + * @param aDataStick - The Data Stick to update. * @param aRecipeHash - The Recipe Hash String to update with. * @return Did we update the Recipe Hash String on the Data Stick? */ @@ -379,8 +385,12 @@ public class GT_AssemblyLineUtils { String aHash = generateRecipeHash(aNewRecipe); if (GT_Values.D1) { GT_Recipe_AssemblyLine aOldRecipe = findAssemblyLineRecipeFromDataStick(aDataStick, true).recipe; - GT_FML_LOGGER.info("Updating data stick: " + aDataStick.getDisplayName() + " | Old Recipe Hash: " - + generateRecipeHash(aOldRecipe) + ", New Recipe Hash: " + aHash); + GT_FML_LOGGER.info( + "Updating data stick: " + aDataStick.getDisplayName() + + " | Old Recipe Hash: " + + generateRecipeHash(aOldRecipe) + + ", New Recipe Hash: " + + aHash); } String author = "Assembling Line Recipe Generator"; @@ -434,8 +444,15 @@ public class GT_AssemblyLineUtils { s = GT_Assemblyline_Server.lServerNames.get(aNewRecipe.mOutput.getDisplayName()); if (s == null) s = aNewRecipe.mOutput.getDisplayName(); } - tNBTList.appendTag(new NBTTagString("Construction plan for " + aNewRecipe.mOutput.stackSize + " " + s - + ". Needed EU/t: " + aNewRecipe.mEUt + " Production time: " + (aNewRecipe.mDuration / 20))); + tNBTList.appendTag( + new NBTTagString( + "Construction plan for " + aNewRecipe.mOutput.stackSize + + " " + + s + + ". Needed EU/t: " + + aNewRecipe.mEUt + + " Production time: " + + (aNewRecipe.mDuration / 20))); for (int i = 0; i < aNewRecipe.mInputs.length; i++) { if (aNewRecipe.mOreDictAlt[i] != null) { int count = 0; @@ -448,10 +465,7 @@ public class GT_AssemblyLineUtils { if (s == null) s = tStack.getDisplayName(); } - tBuilder.append(count == 0 ? "" : "\nOr ") - .append(tStack.stackSize) - .append(" ") - .append(s); + tBuilder.append(count == 0 ? "" : "\nOr ").append(tStack.stackSize).append(" ").append(s); count++; } } @@ -462,8 +476,9 @@ public class GT_AssemblyLineUtils { s = GT_Assemblyline_Server.lServerNames.get(aNewRecipe.mInputs[i].getDisplayName()); if (s == null) s = aNewRecipe.mInputs[i].getDisplayName(); } - tNBTList.appendTag(new NBTTagString( - "Input Bus " + (i + 1) + ": " + aNewRecipe.mInputs[i].stackSize + " " + s)); + tNBTList.appendTag( + new NBTTagString( + "Input Bus " + (i + 1) + ": " + aNewRecipe.mInputs[i].stackSize + " " + s)); } } for (int i = 0; i < aNewRecipe.mFluidInputs.length; i++) { @@ -473,8 +488,9 @@ public class GT_AssemblyLineUtils { s = GT_Assemblyline_Server.lServerNames.get(aNewRecipe.mFluidInputs[i].getLocalizedName()); if (s == null) s = aNewRecipe.mFluidInputs[i].getLocalizedName(); } - tNBTList.appendTag(new NBTTagString( - "Input Hatch " + (i + 1) + ": " + aNewRecipe.mFluidInputs[i].amount + "L " + s)); + tNBTList.appendTag( + new NBTTagString( + "Input Hatch " + (i + 1) + ": " + aNewRecipe.mFluidInputs[i].amount + "L " + s)); } } tNBT.setTag("pages", tNBTList); @@ -488,6 +504,7 @@ public class GT_AssemblyLineUtils { } public enum LookupResultType { + INVALID_STICK(true), VALID_STACK_BUT_INVALID_RECIPE(true), VALID_STACK_AND_VALID_RECIPE(false), @@ -514,6 +531,7 @@ public class GT_AssemblyLineUtils { } public static class LookupResult { + private final GT_Recipe_AssemblyLine recipe; private final LookupResultType type; 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 15d11cda63..a455fcf916 100644 --- a/src/main/java/gregtech/api/util/GT_Assemblyline_Server.java +++ b/src/main/java/gregtech/api/util/GT_Assemblyline_Server.java @@ -1,30 +1,30 @@ package gregtech.api.util; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Materials; -import gregtech.api.enums.MaterialsBotania; import java.io.File; import java.util.HashMap; import java.util.L |
