diff --git a/addon.gradle b/addon.gradle deleted file mode 100644 index cc0f5d57e..000000000 --- a/addon.gradle +++ /dev/null @@ -1,3 +0,0 @@ -compileJava { - options.encoding = "UTF-8" -} diff --git a/dependencies.gradle b/dependencies.gradle index 13d6112f9..4038924ff 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -11,5 +11,4 @@ dependencies { compileOnly("com.github.GTNewHorizons:TinkersGregworks:GTNH-1.0.24-pre:dev") {transitive = false} compileOnly("com.github.GTNewHorizons:OpenComputers:1.9.17-GTNH:api") {transitive = false} - } diff --git a/gradle.properties b/gradle.properties index 7b394d5ef..dbd43421d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,12 +15,27 @@ autoUpdateBuildScript = false minecraftVersion = 1.7.10 forgeVersion = 10.13.4.1614 +# Specify a MCP channel and mappings version for dependency deobfuscation and the deobfParams task. +channel = stable +mappingsVersion = 12 + +# Define other MCP mappings for dependency deobfuscation +remoteMappings = https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/ + # Select a username for testing your mod with breakpoints. You may leave this empty for a random username each time you # restart Minecraft in development. Choose this dependent on your mod: # Do you need consistent player progressing (for example Thaumcraft)? -> Select a name # Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty developmentEnvironmentUserName = Developer +# Enables using modern java syntax (up to version 17) via Jabel, while still targeting JVM 8. +# See https://github.com/bsideup/jabel for details on how this works. +enableModernJavaSyntax = true + +# Enables injecting missing generics into the decompiled source code for a better coding experience +# Turns most publicly visible List, Map, etc. into proper List, Map types +enableGenericInjection = true + # Generate a class with String fields for the mod id, name, version and group name named with the fields below generateGradleTokenClass = com.github.bartimaeusnek.bartworks.API.API_REFERENCE gradleTokenModId = @@ -40,12 +55,15 @@ replaceGradleTokenInFile = # Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api apiPackage = -# Specify the configuration file for Forge's access transformers here. I must be placed into /src/main/resources/META-INF/ -# Example value: mymodid_at.cfg +# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/ +# There can be multiple files in a comma-separated list. +# Example value: mymodid_at.cfg,nei_at.cfg accessTransformersFile = # Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled! usesMixins = false +# Adds some debug arguments like verbose output and export +usesMixinDebug = false # Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise. mixinPlugin = # Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail! @@ -61,6 +79,71 @@ containsMixinsAndOrCoreModOnly = false # Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins. forceEnableMixins = true -# If enabled, you may use 'shadowImplementation' for dependencies. They will be integrated in your jar. It is your +# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated in your jar. It is your # responsibility check the licence and request permission for distribution, if required. usesShadowedDependencies = false +# If disabled, won't remove unused classes from shaded dependencies. Some libraries use reflection to access +# their own classes, making the minimization unreliable. +minimizeShadowedDependencies = true +# If disabled, won't rename the shadowed classes. +relocateShadowedDependencies = true + +# Adds the GTNH maven, CurseMaven, IC2/Player maven, and some more well-known 1.7.10 repositories +includeWellKnownRepositories = true + +# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven. +# Authenticate with the MAVEN_USERNAME and MAVEN_PASSWORD environment variables. +# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle. +usesMavenPublishing = true +# mavenPublishUrl = http://jenkins.usrv.eu:8081/nexus/content/repositories/releases + +# Publishing to modrinth requires you to set the MODRINTH_TOKEN environment variable to your current modrinth API token. + +# The project's ID on Modrinth. Can be either the slug or the ID. +# Leave this empty if you don't want to publish on Modrinth. +modrinthProjectId = + +# The project's relations on Modrinth. You can use this to refer to other projects on Modrinth. +# Syntax: scope1-type1:name1;scope2-type2:name2;... +# Where scope can be one of [required, optional, incompatible, embedded], +# type can be one of [project, version], +# and the name is the Modrinth project or version slug/id of the other mod. +# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech +# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true +modrinthRelations = + + +# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens. + +# The project's numeric ID on CurseForge. You can find this in the About Project box. +# Leave this empty if you don't want to publish on CurseForge. +curseForgeProjectId = + +# The project's relations on CurseForge. You can use this to refer to other projects on CurseForge. +# Syntax: type1:name1;type2:name2;... +# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible], +# and the name is the CurseForge project slug of the other mod. +# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft +# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true +curseForgeRelations = + + +# Optional parameter to customize the produced artifacts. Use this to preserver artifact naming when migrating older +# projects. New projects should not use this parameter. +# customArchiveBaseName = + +# Optional parameter to prevent the source code from being published +# noPublishedSources = + +# Uncomment this to disable spotless checks +# This should only be uncommented to keep it easier to sync with upstream/other forks. +# That is, if there is no other active fork/upstream, NEVER change this. +# disableSpotless = true + +# Override the IDEA build type. Valid value is "" (leave blank, do not override), "idea" (force use native IDEA build), "gradle" +# (force use delegated build). +# This is meant to be set in $HOME/.gradle/gradle.properties. +# e.g. add "systemProp.org.gradle.project.ideaOverrideBuildType=idea" will override the build type to be always native build. +# WARNING: If you do use this option, it will overwrite whatever you have in your existing projects. This might not be what you want! +# Usually there is no need to uncomment this here as other developers do not necessarily use the same build type as you. +# ideaOverrideBuildType = idea diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectAdder.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectAdder.java index f13035b5c..fc09d943b 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectAdder.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectAdder.java @@ -17,7 +17,7 @@ import static gregtech.api.util.GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes; import static gregtech.api.util.GT_RecipeBuilder.SECONDS; -import java.awt.*; +import java.awt.Color; import net.minecraft.item.EnumRarity; import net.minecraftforge.fluids.FluidRegistry; @@ -28,13 +28,13 @@ import com.github.bartimaeusnek.bartworks.util.BioData; import com.github.bartimaeusnek.bartworks.util.BioPlasmid; +import gregtech.api.enums.FluidState; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; import gregtech.api.enums.TierEU; -import gregtech.api.objects.GT_Fluid; +import gregtech.api.fluid.GT_FluidFactory; import gregtech.api.util.GT_Utility; -@SuppressWarnings("ALL") public final class BioObjectAdder { /** @@ -50,7 +50,7 @@ public static BioCulture createAndRegisterBioCulture(Color color, String name, B EnumRarity rarity, boolean breedable) { if (BioCulture.BIO_CULTURE_ARRAY_LIST.size() > 1) return BioCulture.createAndRegisterBioCulture(color, name, plasmid, dna, rarity, breedable); - else new Exception( + new Exception( "Too Early to register a BioCulture! You MUST run this either after:bartworks OR in the init Phase!") .printStackTrace(); return null; @@ -70,7 +70,7 @@ public static BioCulture createAndRegisterBioCulture(Color color, String name, B boolean breedable) { if (BioCulture.BIO_CULTURE_ARRAY_LIST.size() > 1) return BioCulture.createAndRegisterBioCulture(color, name, plasmid, dna, breedable); - else new Exception( + new Exception( "Too Early to register a BioCulture! You MUST run this either after:bartworks OR in the init Phase!") .printStackTrace(); return null; @@ -168,15 +168,12 @@ public static void regenerateBioFluids() { for (BioCulture B : BioCulture.BIO_CULTURE_ARRAY_LIST) { if (B.getFluidNotSet()) { B.setFluid( - new GT_Fluid( - B.getName().replaceAll(" ", "").toLowerCase() + "fluid", - "molten.autogenerated", - new short[] { (short) B.getColor().getRed(), (short) B.getColor().getBlue(), - (short) B.getColor().getGreen() })); - - if (!FluidRegistry.registerFluid(B.getFluid())) { - new Exception("FAILED TO REGISTER FLUID FOR: " + B.getName()).printStackTrace(); - } + GT_FluidFactory.builder(B.getName().replace(" ", "").toLowerCase() + "fluid") + .withTextureName("molten.autogenerated") + .withColorRGBA( + new short[] { (short) B.getColor().getRed(), (short) B.getColor().getBlue(), + (short) B.getColor().getGreen() }) + .withStateAndTemperature(FluidState.LIQUID, 300).buildAndRegister().asFluid()); GT_Values.RA.stdBuilder().itemInputs(GT_Utility.getIntegratedCircuit(10)) .fluidInputs(new FluidStack(B.getFluid(), 1000)).fluidOutputs(dnaFluid).duration(25 * SECONDS) diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectGetter.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectGetter.java index 35c12e1ca..ba1308c42 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectGetter.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectGetter.java @@ -24,7 +24,6 @@ import com.github.bartimaeusnek.bartworks.util.BioData; import com.github.bartimaeusnek.bartworks.util.BioPlasmid; -@SuppressWarnings("ALL") public final class BioObjectGetter { public static BioCulture getBioCulture(String aName) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioRecipeAdder.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioRecipeAdder.java index b456f8d56..527b62bae 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioRecipeAdder.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioRecipeAdder.java @@ -24,7 +24,6 @@ import gregtech.api.enums.Materials; -@SuppressWarnings("ALL") public final class BioRecipeAdder { public static final int STANDART = 0; @@ -108,6 +107,7 @@ public static boolean addBacterialVatRecipe(ItemStack[] aInputs, @Nonnull BioCul * @param exactSv if the recipe needs EXACTLY the Sv or can use less... * @return */ + @Deprecated public static boolean addBacterialVatRecipe(ItemStack[] aInputs, @Nonnull BioCulture aCulture, @Nonnull FluidStack[] aFluidInputs, @Nonnull FluidStack[] aFluidOutputs, @Nonnegative int aDuration, @Nonnegative int aEUt, Materials material, @Nonnegative int glasTier, int aSpecialValue, boolean exactSv) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioVatLogicAdder.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioVatLogicAdder.java index fdfb02091..4084f485a 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioVatLogicAdder.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioVatLogicAdder.java @@ -34,7 +34,6 @@ import gregtech.api.enums.Materials; import gregtech.api.util.GT_ModHandler; -@SuppressWarnings("ALL") public final class BioVatLogicAdder { public static class RadioHatch { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileHasDifferentTextureSides.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileHasDifferentTextureSides.java index 4100b1776..698c28fbf 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileHasDifferentTextureSides.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileHasDifferentTextureSides.java @@ -31,7 +31,7 @@ default IIcon getTextureForSide(ForgeDirection side, int meta) { @SideOnly(Side.CLIENT) default IIcon getTextureForSide(int side, int meta) { - return getTextureForSide(ForgeDirection.values()[side], meta); + return this.getTextureForSide(ForgeDirection.values()[side], meta); } @SideOnly(Side.CLIENT) diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCore.java b/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCore.java index 60202e102..05877f42e 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCore.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCore.java @@ -38,7 +38,6 @@ import cpw.mods.fml.common.versioning.ArtifactVersion; import cpw.mods.fml.common.versioning.DefaultArtifactVersion; -@SuppressWarnings("ALL") public class BWCore extends DummyModContainer { public static final String BWCORE_NAME = "BartWorks ASM Core"; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreStaticReplacementMethodes.java b/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreStaticReplacementMethodes.java index 86480db53..8d3fe4876 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreStaticReplacementMethodes.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreStaticReplacementMethodes.java @@ -39,7 +39,6 @@ public static void clearRecentlyUsedRecipes() { RECENTLYUSEDRECIPES = ThreadLocal.withInitial(AccessPriorityList::new); } - @SuppressWarnings("ALL") public static ItemStack findCachedMatchingRecipe(InventoryCrafting inventoryCrafting, World world) { int i = 0; ItemStack itemstack = null; @@ -72,45 +71,40 @@ public static ItemStack findCachedMatchingRecipe(InventoryCrafting inventoryCraf return new ItemStack(itemstack.getItem(), 1, i1); - } else { - - IRecipe iPossibleRecipe = null; - AccessPriorityList cache = RECENTLYUSEDRECIPES.get(); - Iterator> it = cache.nodeIterator(); - - while (it.hasNext()) { - AccessPriorityListNode recipeNode = it.next(); - iPossibleRecipe = recipeNode.getELEMENT(); + } + IRecipe iPossibleRecipe = null; + AccessPriorityList cache = RECENTLYUSEDRECIPES.get(); + Iterator> it = cache.nodeIterator(); - if (!iPossibleRecipe.matches(inventoryCrafting, world)) continue; + while (it.hasNext()) { + AccessPriorityListNode recipeNode = it.next(); + iPossibleRecipe = recipeNode.getELEMENT(); - cache.addPrioToNode(recipeNode); - return iPossibleRecipe.getCraftingResult(inventoryCrafting); - } + if (!iPossibleRecipe.matches(inventoryCrafting, world)) continue; - ItemStack stack = null; + cache.addPrioToNode(recipeNode); + return iPossibleRecipe.getCraftingResult(inventoryCrafting); + } - HashSet recipeSet = new NonNullWrappedHashSet<>(); - List recipeList = CraftingManager.getInstance().getRecipeList(); + HashSet recipeSet = new NonNullWrappedHashSet<>(); + List recipeList = CraftingManager.getInstance().getRecipeList(); - for (int k = 0; k < recipeList.size(); k++) { - IRecipe r = (IRecipe) recipeList.get(k); - if (r.matches(inventoryCrafting, world)) recipeSet.add(r); - } + for (IRecipe r : recipeList) { + if (r.matches(inventoryCrafting, world)) recipeSet.add(r); + } - Object[] arr = recipeSet.toArray(); + Object[] arr = recipeSet.toArray(); - if (arr.length == 0) return null; + if (arr.length == 0) return null; - IRecipe recipe = (IRecipe) arr[0]; - stack = recipe.getCraftingResult(inventoryCrafting); + IRecipe recipe = (IRecipe) arr[0]; + ItemStack stack = recipe.getCraftingResult(inventoryCrafting); - if (arr.length != 1) return stack; + if (arr.length != 1) return stack; - if (stack != null) cache.addLast(recipe); + if (stack != null) cache.addLast(recipe); - return stack; - } + return stack; } private BWCoreStaticReplacementMethodes() {} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreTransformer.java b/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreTransformer.java index 160519257..794fd2881 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreTransformer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreTransformer.java @@ -85,7 +85,7 @@ private static MethodNode transformThaumcraftWandPedestal(MethodNode method) { nu.add(instruction); if (instruction.getOpcode() == INVOKEVIRTUAL) { MethodInsnNode invokevirtual = (MethodInsnNode) instruction; - if (invokevirtual.name.equals("addVis")) { + if ("addVis".equals(invokevirtual.name)) { AbstractInsnNode beginning = method.instructions.get(j - 7); LabelNode label = new LabelNode(); nu.insertBefore(beginning, new VarInsnNode(ALOAD, 0)); @@ -133,7 +133,6 @@ public static byte[] transform(int id, byte[] basicClass) { String name_deObfs = "canDoRainSnowIce"; String dsc_deObfs = "(Lnet/minecraft/world/chunk/Chunk;)Z"; - String dsc_Obfs = "(Lapx;)Z"; for (int i = 0; i < methods.size(); i++) { if (methods.get(i).name.equalsIgnoreCase(name_deObfs)) { BWCore.BWCORE_LOG.info("Found " + name_deObfs + "! Removing!"); @@ -142,12 +141,7 @@ public static byte[] transform(int id, byte[] basicClass) { } } BWCore.BWCORE_LOG.info("Creating new " + name_deObfs + "!"); - MethodNode nu = new MethodNode( - ACC_PUBLIC, - name_deObfs, - /* obfs ? dsc_Obfs : */ dsc_deObfs, - null, - new String[0]); + MethodNode nu = new MethodNode(ACC_PUBLIC, name_deObfs, dsc_deObfs, null, new String[0]); InsnList insnList = new InsnList(); insnList.add(new InsnNode(ICONST_0)); insnList.add(new InsnNode(IRETURN)); @@ -168,7 +162,7 @@ public static byte[] transform(int id, byte[] basicClass) { for (int i = 0; i < methods.size(); i++) { if (ASMUtils.isCorrectMethod(methods.get(i), name_deObfs, name_Obfs, name_src) && ASMUtils.isCorrectMethod(methods.get(i), dsc_deObfs, dsc_Obfs)) { - BWCore.BWCORE_LOG.info("Found " + (name_deObfs) + "! Patching!"); + BWCore.BWCORE_LOG.info("Found " + name_deObfs + "! Patching!"); MethodNode toPatch = methods.get(i); InsnList insnList = new InsnList(); insnList.add(new InsnNode(ACONST_NULL)); @@ -192,7 +186,7 @@ public static byte[] transform(int id, byte[] basicClass) { for (MethodNode toPatch : methods) { if (ASMUtils.isCorrectMethod(toPatch, name_deObfs, name_Obfs, name_src) && ASMUtils.isCorrectMethod(toPatch, dsc_universal)) { - BWCore.BWCORE_LOG.info("Found " + (name_deObfs) + "! Patching!"); + BWCore.BWCORE_LOG.info("Found " + name_deObfs + "! Patching!"); InsnList nu = new InsnList(); LabelNode[] LabelNodes = { new LabelNode(), new LabelNode() }; @@ -311,7 +305,7 @@ public static byte[] transform(int id, byte[] basicClass) { for (int i = 0; i < methods.size(); i++) { if (ASMUtils.isCorrectMethod(methods.get(i), name_deObfs, name_Obfs, name_src) && ASMUtils.isCorrectMethod(methods.get(i), dsc_universal, dsc_universal)) { - BWCore.BWCORE_LOG.info("Found " + (name_deObfs) + "! Patching!"); + BWCore.BWCORE_LOG.info("Found " + name_deObfs + "! Patching!"); methods.set(i, BWCoreTransformer.transformThaumcraftWandPedestal(methods.get(i))); break scase; } @@ -325,7 +319,7 @@ public static byte[] transform(int id, byte[] basicClass) { String name_deObfs = "getNewNoise"; for (MethodNode toPatch : methods) { if (ASMUtils.isCorrectMethod(toPatch, name_deObfs)) { - BWCore.BWCORE_LOG.info("Found " + (name_deObfs) + "! Patching!"); + BWCore.BWCORE_LOG.info("Found " + name_deObfs + "! Patching!"); LabelNode[] LabelNodes = { new LabelNode(), new LabelNode() }; InsnList nu = new InsnList(); // if (x < -28675) x %= -28675; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/GuiHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/GuiHandler.java index bb9a40934..c104d09f3 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/GuiHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/GuiHandler.java @@ -29,7 +29,7 @@ public Object getServerGuiElement(int ID, EntityPlayer player, World world, int @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - if (SideReference.Side.Client) {} else return getServerGuiElement(ID, player, world, x, y, z); + if (!SideReference.Side.Client) return this.getServerGuiElement(ID, player, world, x, y, z); return null; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java index cf88fe51b..e4a73d199 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java @@ -80,20 +80,17 @@ import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; -@SuppressWarnings("ALL") -@Mod( - modid = MainMod.MOD_ID, - name = MainMod.NAME, - version = API_REFERENCE.VERSION, - dependencies = "required-after:IC2; " + "required-after:gregtech; " - + "after:berriespp; " - + "after:tectech; " - + "after:GalacticraftMars; " - + "after:GalacticraftCore; " - + "after:Forestry; " - + "after:ProjRed|Illumination; " - + "after:RandomThings; " - + "before:miscutils; ") +@Mod(modid = MainMod.MOD_ID, name = MainMod.NAME, version = API_REFERENCE.VERSION, dependencies = """ + required-after:IC2;\ + required-after:gregtech;\ + after:berriespp;\ + after:tectech;\ + after:GalacticraftMars;\ + after:GalacticraftCore;\ + after:Forestry;\ + after:ProjRed|Illumination;\ + after:RandomThings;\ + before:miscutils;""") public final class MainMod { public static final String NAME = "BartWorks"; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipCache.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipCache.java index 4c59aa38e..a23020e78 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipCache.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipCache.java @@ -29,19 +29,16 @@ class TooltipCache { static boolean put(ItemStack itemStack, List tooltip) { Pair p = new Pair<>(Item.getIdFromItem(itemStack.getItem()), (short) itemStack.getItemDamage()); - if (TooltipCache.cache.containsKey(p)) return false; - - if (!tooltip.isEmpty()) { - StringBuilder sb = new StringBuilder(); - for (String s : tooltip) { - sb.append(s); - sb.append(System.lineSeparator()); - } - char[] rettype = sb.toString().toCharArray(); - return TooltipCache.cache.put(p, rettype) == rettype; - } else { + if (TooltipCache.cache.containsKey(p) || tooltip.isEmpty()) { return false; } + StringBuilder sb = new StringBuilder(); + for (String s : tooltip) { + sb.append(s); + sb.append(System.lineSeparator()); + } + char[] rettype = sb.toString().toCharArray(); + return TooltipCache.cache.put(p, rettype) == rettype; } static List getTooltip(ItemStack itemStack) { @@ -52,10 +49,4 @@ static List getTooltip(ItemStack itemStack) { } return Arrays.asList(new String(toTest).split(System.lineSeparator())); } - - private static void checkSize() { - if (TooltipCache.cache.size() > Short.MAX_VALUE * 2) { - TooltipCache.cache.clear(); - } - } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipEventHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipEventHandler.java index 1c004ec15..2b7e68681 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipEventHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipEventHandler.java @@ -67,8 +67,8 @@ public void getTooltip(ItemTooltipEvent event) { UI = GameRegistry.findUniqueIdentifierFor(Block.getBlockFromItem(tmp.getItem())); if (UI != null) { for (ModContainer modContainer : Loader.instance().getModList()) { - if (UI.modId.equals(MainMod.MOD_ID) || UI.modId.equals(BartWorksCrossmod.MOD_ID) - || UI.modId.equals("BWCore")) + if (MainMod.MOD_ID.equals(UI.modId) || BartWorksCrossmod.MOD_ID.equals(UI.modId) + || "BWCore".equals(UI.modId)) break; if (UI.modId.equals(modContainer.getModId())) { tooAdd.add( diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_RotorBlock.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_RotorBlock.java index ccacef6c3..188c0c9e6 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_RotorBlock.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_RotorBlock.java @@ -38,7 +38,8 @@ public BW_GUIContainer_RotorBlock(ContainerWindKineticGenerator container1) { this.name = StatCollector.translateToLocal("tile.BWRotorBlock.0.name"); } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { this.fontRendererObj .drawString(this.name, (this.xSize - this.fontRendererObj.getStringWidth(this.name)) / 2, 6, 2157374); if (this.container.base.checkrotor()) { @@ -58,8 +59,8 @@ protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) this.fontRendererObj.drawString(this.container.base.getRotorhealth() + " %", 46, 52, 2157374); if (this.container.base.guiisoverload()) { GuiTooltipHelper.drawAreaTooltip( - p_146979_1_ - this.guiLeft, - p_146979_2_ - this.guiTop, + mouseX - this.guiLeft, + mouseY - this.guiTop, StatCollector.translateToLocal("ic2.WindKineticGenerator.error.overload"), 44, 27, @@ -76,6 +77,7 @@ protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) } } + @Override protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { GL11.glColor3f(0.5f, 0.25f, 0.07f); this.mc.getTextureManager() diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_EICPistonVisualizer.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_EICPistonVisualizer.java index 4b5923fd2..bb48e4067 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_EICPistonVisualizer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_EICPistonVisualizer.java @@ -18,7 +18,7 @@ public class BW_EICPistonVisualizer extends EntityFX { public BW_EICPistonVisualizer(World world, int x, int y, int z, int age) { - super(world, (double) x, ((double) y), (double) z); + super(world, x, y, z); this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; @@ -43,9 +43,9 @@ public void renderParticle(Tessellator p_70539_1_, float p_70539_2_, float p_705 // Look at nearby block for correct tiered block to use Pair tieredBlock; if (this.worldObj != null) { - int nX = (int) posX; - int nY = (int) posY + 1; - int nZ = (int) posZ; + int nX = (int) this.posX; + int nY = (int) this.posY + 1; + int nZ = (int) this.posZ; Block neighborBlock = this.worldObj.getBlock(nX, nY, nZ); int neighborMeta = this.worldObj.getBlockMetadata(nX, nY, nZ); tieredBlock = Pair.of(neighborBlock, neighborMeta); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_GT_ItemRenderer.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_GT_ItemRenderer.java index 4a6561f9e..363de0eda 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_GT_ItemRenderer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_GT_ItemRenderer.java @@ -50,9 +50,8 @@ public boolean handleRenderType(ItemStack aStack, IItemRenderer.ItemRenderType a || aType == IItemRenderer.ItemRenderType.INVENTORY || aType == IItemRenderer.ItemRenderType.EQUIPPED || aType == IItemRenderer.ItemRenderType.ENTITY; - } else { - return false; } + return false; } @Override @@ -60,9 +59,8 @@ public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType aType, ItemSta IItemRenderer.ItemRendererHelper aHelper) { if (GT_Utility.isStackInvalid(aStack)) { return false; - } else { - return aType == IItemRenderer.ItemRenderType.ENTITY; } + return aType == IItemRenderer.ItemRenderType.ENTITY; } @Override @@ -85,7 +83,7 @@ public void renderItem(IItemRenderer.ItemRenderType type, ItemStack aStack, Obje Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); GL11.glBlendFunc(770, 771); - if (type.equals(IItemRenderer.ItemRenderType.INVENTORY)) { + if (IItemRenderer.ItemRenderType.INVENTORY.equals(type)) { if (aMetaData < CircuitImprintLoader.reverseIDs) GT_RenderUtil.renderItemIcon(tIcon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); else { @@ -102,24 +100,22 @@ public void renderItem(IItemRenderer.ItemRenderType type, ItemStack aStack, Obje -1.0F); } } - } else { - if (aMetaData < CircuitImprintLoader.reverseIDs) ItemRenderer.renderItemIn2D( - Tessellator.instance, - tIcon.getMaxU(), - tIcon.getMinV(), - tIcon.getMinU(), - tIcon.getMaxV(), - tIcon.getIconWidth(), - tIcon.getIconHeight(), - 0.0625F); - } + } else if (aMetaData < CircuitImprintLoader.reverseIDs) ItemRenderer.renderItemIn2D( + Tessellator.instance, + tIcon.getMaxU(), + tIcon.getMinV(), + tIcon.getMinU(), + tIcon.getMaxV(), + tIcon.getIconWidth(), + tIcon.getIconHeight(), + 0.0625F); IIcon tOverlay = (IIcon) BW_Util.get2DCoordFrom1DArray(aMetaData, 1, 2, aItem.mIconList); GL11.glColor3f(1.0F, 1.0F, 1.0F); if (tOverlay != null) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); GL11.glBlendFunc(770, 771); - if (type.equals(IItemRenderer.ItemRenderType.INVENTORY)) { + if (IItemRenderer.ItemRenderType.INVENTORY.equals(type)) { GT_RenderUtil.renderItemIcon(tOverlay, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); } else { ItemRenderer.renderItemIn2D( diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererSwitchingColorFluid.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererSwitchingColorFluid.java index 894d15cf4..6e1bffcd0 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererSwitchingColorFluid.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererSwitchingColorFluid.java @@ -76,9 +76,9 @@ private float getFluidHeightForRender(IBlockAccess world, int x, int y, int z, B return RendererSwitchingColorFluid.THREE_QUARTERS_FILLED; } } - return (!world.getBlock(x, y, z).getMaterial().isSolid() && world.getBlock(x, y + 1, z) == block) + return !world.getBlock(x, y, z).getMaterial().isSolid() && world.getBlock(x, y + 1, z) == block ? RendererSwitchingColorFluid.LIGHT_Y_POS - : (block.getQuantaPercentage(world, x, y, z) * RendererSwitchingColorFluid.THREE_QUARTERS_FILLED); + : block.getQuantaPercentage(world, x, y, z) * RendererSwitchingColorFluid.THREE_QUARTERS_FILLED; } public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {} @@ -86,7 +86,7 @@ public void renderInventoryBlock(Block block, int metadata, int modelID, RenderB @SideOnly(Side.CLIENT) public boolean renderWorldBlock(IBlockAccess iBlockAccess, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - if ((!(block instanceof BioFluidBlock))) return false; + if (!(block instanceof BioFluidBlock)) return false; Tessellator tessellator = Tessellator.instance; Coords blockat = new Coords(x, y, z, iBlockAccess.getTileEntity(x, y, z).getWorldObj().provider.dimensionId); Integer rgb = GT_TileEntity_BioVat.staticColorMap.get(blockat); @@ -94,15 +94,15 @@ public boolean renderWorldBlock(IBlockAccess iBlockAccess, int x, int y, int z, int r, g, b; if (rgb != null) { - r = (rgb >> 16) & 0xFF; - g = (rgb >> 8) & 0xFF; + r = rgb >> 16 & 0xFF; + g = rgb >> 8 & 0xFF; b = rgb & 0xFF; } else { r = 0; g = 0; b = 255; } - float red = ((float) r) / 255f, green = ((float) g) / 255f, blue = ((float) b) / 255f; + float red = r / 255f, green = g / 255f, blue = b / 255f; BlockFluidBase blockFluidBase = (BlockFluidBase) block; boolean renderTop = iBlockAccess.getBlock(x, y + 1, z) != blockFluidBase; @@ -237,35 +237,40 @@ public boolean renderWorldBlock(IBlockAccess iBlockAccess, int x, int y, int z, if (renderer.renderAllFaces || renderSides[side]) { rendered = true; double dHeight1, dHeight2, dXcoord1, dXcoord2, dZcoord1, dZcoord2; - if (side == 0) { - dHeight1 = heightNW; - dHeight2 = heightNE; - dXcoord1 = x; - dXcoord2 = x + 1; - dZcoord1 = z + RendererSwitchingColorFluid.RENDER_OFFSET; - dZcoord2 = z + RendererSwitchingColorFluid.RENDER_OFFSET; - } else if (side == 1) { - dHeight1 = heightSE; - dHeight2 = heightSW; - dXcoord1 = x + 1; - dXcoord2 = x; - dZcoord1 = z + 1 - RendererSwitchingColorFluid.RENDER_OFFSET; - dZcoord2 = z + 1 - RendererSwitchingColorFluid.RENDER_OFFSET; - } else if (side == 2) { - dHeight1 = heightSW; - dHeight2 = heightNW; - dXcoord1 = x + RendererSwitchingColorFluid.RENDER_OFFSET; - dXcoord2 = x + RendererSwitchingColorFluid.RENDER_OFFSET; - dZcoord1 = z + 1; - dZcoord2 = z; - } else { - dHeight1 = heightNE; - dHeight2 = heightSE; - dXcoord1 = x + 1 - RendererSwitchingColorFluid.RENDER_OFFSET; - dXcoord2 = x + 1 - RendererSwitchingColorFluid.RENDER_OFFSET; - dZcoord1 = z; - dZcoord2 = z + 1; - } + dZcoord2 = switch (side) { + case 0 -> { + dHeight1 = heightNW; + dHeight2 = heightNE; + dXcoord1 = x; + dXcoord2 = x + 1; + dZcoord1 = z + RendererSwitchingColorFluid.RENDER_OFFSET; + yield z + RendererSwitchingColorFluid.RENDER_OFFSET; + } + case 1 -> { + dHeight1 = heightSE; + dHeight2 = heightSW; + dXcoord1 = x + 1; + dXcoord2 = x; + dZcoord1 = z + 1 - RendererSwitchingColorFluid.RENDER_OFFSET; + yield z + 1 - RendererSwitchingColorFluid.RENDER_OFFSET; + } + case 2 -> { + dHeight1 = heightSW; + dHeight2 = heightNW; + dXcoord1 = x + RendererSwitchingColorFluid.RENDER_OFFSET; + dXcoord2 = x + RendererSwitchingColorFluid.RENDER_OFFSET; + dZcoord1 = z + 1; + yield z; + } + default -> { + dHeight1 = heightNE; + dHeight2 = heightSE; + dXcoord1 = x + 1 - RendererSwitchingColorFluid.RENDER_OFFSET; + dXcoord2 = x + 1 - RendererSwitchingColorFluid.RENDER_OFFSET; + dZcoord1 = z; + yield z + 1; + } + }; float u1Flow = iconFlow.getInterpolatedU(0.0); float u2Flow = iconFlow.getInterpolatedU(8.0); float v1Flow = iconFlow.getInterpolatedV((1.0 - dHeight1) * 16.0 * 0.5); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_Blocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_Blocks.java index 3dccd8847..1a00d16d8 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_Blocks.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_Blocks.java @@ -78,8 +78,7 @@ public int damageDropped(int meta) { @Override @SideOnly(Side.CLIENT) - @SuppressWarnings("unchecked") - public void getSubBlocks(Item item, CreativeTabs tab, List list) { + public void getSubBlocks(Item item, CreativeTabs tab, List list) { for (int i = 0; i < this.textureNames.length; i++) { list.add(new ItemStack(item, 1, i)); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks.java index 8bd57edaf..a2f5e520b 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks.java @@ -173,7 +173,7 @@ public int getRenderBlockPass() { @Override public int getRenderType() { if (!this.fake && SideReference.Side.Client) return RendererGlasBlock.RID; - else return 0; + return 0; } @Override diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks2.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks2.java index 16688fbc3..337db9032 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks2.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks2.java @@ -165,7 +165,7 @@ public int getRenderBlockPass() { @Override public int getRenderType() { if (!this.fake && SideReference.Side.Client) return RendererGlasBlock.RID; - else return 0; + return 0; } @Override diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java index 2cfc787a1..07db82fcb 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java @@ -60,8 +60,8 @@ public BW_TileEntityContainer(Material p_i45386_1_, Class } @Override - public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer player, int p_149727_6_, - float p_149727_7_, float p_149727_8_, float p_149727_9_) { + public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer player, int side, float subX, + float subY, float subZ) { if (worldObj.isRemote) { return false; } @@ -84,7 +84,8 @@ public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlaye if (!player.isSneaking()) { if (tile instanceof IHasGui) { return worldObj.isRemote || IC2.platform.launchGui(player, (IHasGui) tile); - } else if (tile instanceof ITileWithModularUI) { + } + if (tile instanceof ITileWithModularUI) { if (!worldObj.isRemote) { UIInfos.TILE_MODULAR_UI.open(player, worldObj, x, y, z); } @@ -94,10 +95,10 @@ public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlaye return false; } + @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) { TileEntity tile = world.getTileEntity(x, y, z); - if (tile instanceof IWrenchable && itemStack != null) { - IWrenchable tile2 = (IWrenchable) tile; + if (tile instanceof IWrenchable tile2 && itemStack != null) { int meta = itemStack.getItemDamage(); world.setBlockMetadataWithNotify(x, y, z, meta, 2); if (entity != null) { @@ -136,14 +137,14 @@ public void breakBlock(World world, int x, int y, int z, Block block, int meta) @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int meta) { - if (ITileHasDifferentTextureSides.class.isAssignableFrom(this.tileEntity)) { - try { - return ((ITileHasDifferentTextureSides) this.tileEntity.newInstance()).getTextureForSide(side, meta); - } catch (InstantiationException | IllegalAccessException e) { - e.printStackTrace(); - return super.getIcon(side, meta); - } - } else return super.getIcon(side, meta); + if (!ITileHasDifferentTextureSides.class.isAssignableFrom(this.tileEntity)) return super.getIcon(side, meta); + try { + return ((ITileHasDifferentTextureSides) this.tileEntity.getConstructor().newInstance()) + .getTextureForSide(side, meta); + } catch (Exception e) { + e.printStackTrace(); + return super.getIcon(side, meta); + } } @Override @@ -151,18 +152,19 @@ public IIcon getIcon(int side, int meta) { public void registerBlockIcons(IIconRegister par1IconRegister) { if (ITileHasDifferentTextureSides.class.isAssignableFrom(this.tileEntity)) { try { - ((ITileHasDifferentTextureSides) this.tileEntity.newInstance()).registerBlockIcons(par1IconRegister); - } catch (InstantiationException | IllegalAccessException e) { + ((ITileHasDifferentTextureSides) this.tileEntity.getConstructor().newInstance()) + .registerBlockIcons(par1IconRegister); + } catch (Exception e) { e.printStackTrace(); } } else super.registerBlockIcons(par1IconRegister); } @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + public TileEntity createNewTileEntity(World worldIn, int meta) { try { - return this.tileEntity.newInstance(); - } catch (InstantiationException | IllegalAccessException e) { + return this.tileEntity.getConstructor().newInstance(); + } catch (Exception e) { e.printStackTrace(); } return null; @@ -187,8 +189,8 @@ public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x public String[] getInfoData() { if (ITileAddsInformation.class.isAssignableFrom(this.tileEntity)) { try { - return ((ITileAddsInformation) this.tileEntity.newInstance()).getInfoData(); - } catch (InstantiationException | IllegalAccessException e) { + return ((ITileAddsInformation) this.tileEntity.getConstructor().newInstance()).getInfoData(); + } catch (Exception e) { e.printStackTrace(); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_Multiple.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_Multiple.java index 22b14db26..a7b39dcee 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_Multiple.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_Multiple.java @@ -64,8 +64,8 @@ public BW_TileEntityContainer_Multiple(Material p_i45386_1_, Class list) { for (int i = 0; i < this.textureNames.length; i++) { list.add(new ItemStack(item, 1, i)); } @@ -154,10 +152,10 @@ public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x } @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + public TileEntity createNewTileEntity(World worldIn, int meta) { try { - return this.tileEntityArray[p_149915_2_].newInstance(); - } catch (InstantiationException | IllegalAccessException e) { + return this.tileEntityArray[meta].getConstructor().newInstance(); + } catch (Exception e) { e.printStackTrace(); } return null; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BioFluidBlock.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BioFluidBlock.java index fa984b8ee..a5ad7625f 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BioFluidBlock.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BioFluidBlock.java @@ -38,9 +38,10 @@ public BioFluidBlock() { this.textureName = "gregtech:fluids/fluid.molten.autogenerated"; } + @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister p_149651_1_) { - FluidLoader.autogenIIcon = this.blockIcon = p_149651_1_.registerIcon(this.getTextureName()); + public void registerBlockIcons(IIconRegister reg) { + FluidLoader.autogenIIcon = this.blockIcon = reg.registerIcon(this.getTextureName()); } @Override @@ -58,6 +59,7 @@ public int getMaxRenderHeightMeta() { return 0; } + @Override public int getRenderType() { return FluidLoader.renderID; } @@ -74,18 +76,18 @@ public boolean canDrain(World world, int x, int y, int z) { @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess p_149673_1_, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_) { + public IIcon getIcon(IBlockAccess worldIn, int x, int y, int z, int side) { return FluidLoader.autogenIIcon; } @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int p_149691_2_) { + public IIcon getIcon(int side, int meta) { return FluidLoader.autogenIIcon; } @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + public TileEntity createNewTileEntity(World worldIn, int meta) { return new BWTileEntityDimIDBridge(); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ChangeConfig.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ChangeConfig.java index c294bcbab..0434a5d97 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ChangeConfig.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ChangeConfig.java @@ -29,44 +29,42 @@ public String getCommandName() { } @Override - public String getCommandUsage(ICommandSender p_71518_1_) { + public String getCommandUsage(ICommandSender sender) { return "bwcfg "; } @Override @SuppressWarnings("rawtypes") - public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) { + public void processCommand(ICommandSender sender, String[] args) { try { - Field f = ConfigHandler.class.getField(p_71515_2_[0]); + Field f = ConfigHandler.class.getField(args[0]); Class c = f.getType(); if (c.equals(int.class)) { int l; try { - l = Integer.parseInt(p_71515_2_[1]); + l = Integer.parseInt(args[1]); } catch (NumberFormatException e) { - p_71515_1_.addChatMessage(new ChatComponentText("you need to enter a number!")); + sender.addChatMessage(new ChatComponentText("you need to enter a number!")); return; } f.setInt(null, l); } else if (c.equals(long.class)) { long l; try { - l = Long.parseLong(p_71515_2_[1]); + l = Long.parseLong(args[1]); } catch (NumberFormatException e) { - p_71515_1_.addChatMessage(new ChatComponentText("you need to enter a number!")); + sender.addChatMessage(new ChatComponentText("you need to enter a number!")); return; } f.setLong(null, l); } else if (c.equals(boolean.class)) { - if (p_71515_2_[1].equalsIgnoreCase("true") || p_71515_2_[1].equalsIgnoreCase("1")) - f.setBoolean(null, true); - else if (p_71515_2_[1].equalsIgnoreCase("false") || p_71515_2_[1].equalsIgnoreCase("0")) - f.setBoolean(null, false); + if ("true".equalsIgnoreCase(args[1]) || "1".equalsIgnoreCase(args[1])) f.setBoolean(null, true); + else if ("false".equalsIgnoreCase(args[1]) || "0".equalsIgnoreCase(args[1])) f.setBoolean(null, false); else { - p_71515_1_.addChatMessage(new ChatComponentText("booleans need to be set to true or false")); + sender.addChatMessage(new ChatComponentText("booleans need to be set to true or false")); } } - p_71515_1_.addChatMessage(new ChatComponentText("Set " + p_71515_2_[0] + " to " + p_71515_2_[1])); + sender.addChatMessage(new ChatComponentText("Set " + args[0] + " to " + args[1])); } catch (Exception e) { e.printStackTrace(); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ClearCraftingCache.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ClearCraftingCache.java index 138542bd4..7afe07beb 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ClearCraftingCache.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ClearCraftingCache.java @@ -27,13 +27,13 @@ public String getCommandName() { } @Override - public String getCommandUsage(ICommandSender p_71518_1_) { + public String getCommandUsage(ICommandSender sender) { return "bwclr"; } @Override - public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) { + public void processCommand(ICommandSender sender, String[] args) { BWCoreStaticReplacementMethodes.clearRecentlyUsedRecipes(); - p_71515_1_.addChatMessage(new ChatComponentText("Recipe Cache cleared ")); + sender.addChatMessage(new ChatComponentText("Recipe Cache cleared ")); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/GetWorkingDirectory.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/GetWorkingDirectory.java index e3dd2d13c..341044c49 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/GetWorkingDirectory.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/GetWorkingDirectory.java @@ -26,12 +26,12 @@ public String getCommandName() { } @Override - public String getCommandUsage(ICommandSender p_71518_1_) { + public String getCommandUsage(ICommandSender sender) { return "bwgwd"; } @Override - public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) { - p_71515_1_.addChatMessage(new ChatComponentText(Minecraft.getMinecraft().mcDataDir.getAbsolutePath())); + public void processCommand(ICommandSender sender, String[] args) { + sender.addChatMessage(new ChatComponentText(Minecraft.getMinecraft().mcDataDir.getAbsolutePath())); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/PrintRecipeListToFile.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/PrintRecipeListToFile.java index 1646b8e75..28d840ac5 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/PrintRecipeListToFile.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/PrintRecipeListToFile.java @@ -21,7 +21,6 @@ import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; import net.minecraft.item.crafting.CraftingManager; -import net.minecraft.item.crafting.IRecipe; public class PrintRecipeListToFile extends CommandBase { @@ -31,20 +30,19 @@ public String getCommandName() { } @Override - public String getCommandUsage(ICommandSender p_71518_1_) { + public String getCommandUsage(ICommandSender sender) { return "prltf "; } @Override - @SuppressWarnings("unchecked") - public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) { - File file = new File(p_71515_2_[0]); + public void processCommand(ICommandSender sender, String[] args) { + File file = new File(args[0]); try { BufferedWriter fw = new BufferedWriter(new FileWriter(file)); CraftingManager.getInstance().getRecipeList().forEach(e -> { try { - fw.write(e.toString() + " = " + ((IRecipe) e).getRecipeOutput().getDisplayName() + "\n"); + fw.write(e.toString() + " = " + e.getRecipeOutput().getDisplayName() + "\n"); } catch (IOException ex) { ex.printStackTrace(); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/RunGC.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/RunGC.java index 35cdae5bb..4bbb71950 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/RunGC.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/RunGC.java @@ -25,13 +25,13 @@ public String getCommandName() { } @Override - public String getCommandUsage(ICommandSender p_71518_1_) { + public String getCommandUsage(ICommandSender sender) { return "bwgc"; } @Override - public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) { + public void processCommand(ICommandSender sender, String[] args) { Runtime.getRuntime().gc(); - p_71515_1_.addChatMessage(new ChatComponentText("Ran GC!")); + sender.addChatMessage(new ChatComponentText("Ran GC!")); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/SummonRuin.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/SummonRuin.java index ece470872..2def53c24 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/SummonRuin.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/SummonRuin.java @@ -26,19 +26,19 @@ public String getCommandName() { } @Override - public String getCommandUsage(ICommandSender p_71518_1_) { + public String getCommandUsage(ICommandSender sender) { return "SummonRuin "; } @Override - public void processCommand(ICommandSender iCommandSender, String[] p_71515_2_) { + public void processCommand(ICommandSender iCommandSender, String[] args) { try { new MapGenRuins.RuinsBase().generate( iCommandSender.getEntityWorld(), iCommandSender.getEntityWorld().rand, - Integer.parseInt(p_71515_2_[0]), + Integer.parseInt(args[0]), 256, - Integer.parseInt(p_71515_2_[1])); + Integer.parseInt(args[1])); } catch (Exception e) { e.printStackTrace(); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java index 46e63a89e..e710f15df 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java @@ -98,7 +98,7 @@ public class ConfigHandler { 615, 625, 635, 645, 655, 665, 675 }, }; private static int[][][] defaultMetasForTiers = { METAFORTIERS_ENERGY, METAFORTIERS_BUFFER, METAFORTIERS_CABLE, METAFORTIERS_MACHINE }; - private static final String[] VOLTAGE_NAMES = new String[] { "High Pressure Steam", "Low Voltage", "Medium Voltage", + private static final String[] VOLTAGE_NAMES = { "High Pressure Steam", "Low Voltage", "Medium Voltage", "High Voltage", "Extreme Voltage", "Insane Voltage", "Ludicrous Voltage", "ZPM Voltage", "Ultimate Voltage", "Ultimate High Voltage", "Ultimate Extreme Voltage", "Ultimate Insane Voltage", "Ultimate Mega Voltage", "Ultimate Extended Mega Voltage", "Overpowered Voltage", "Maximum Voltage" }; @@ -147,7 +147,7 @@ public ConfigHandler(Configuration C) { "This switch sets the lowest unnerfed Circuit Recipe Tier. -1 to disable it completely.", -1, VOLTAGE_NAMES.length).getInt(5); - ConfigHandler.cutoffTier = (ConfigHandler.cutoffTier == -1 ? VOLTAGE_NAMES.length : ConfigHandler.cutoffTier); + ConfigHandler.cutoffTier = ConfigHandler.cutoffTier == -1 ? VOLTAGE_NAMES.length : ConfigHandler.cutoffTier; ConfigHandler.disableExtraGassesForEBF = ConfigHandler.c .get( "System", diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java index 33876e557..b3791b51d 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java @@ -61,8 +61,7 @@ public String getUnlocalizedName(ItemStack aStack) { @Override @SideOnly(Side.CLIENT) - @SuppressWarnings("unchecked") - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { byte tier = BorosilicateGlass.getTier(this.field_150939_a, aStack.getItemDamage()); if (tier >= 0) { aList.add( diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_SimpleWindMeter.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_SimpleWindMeter.java index 8a3ec9507..62f8b0e66 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_SimpleWindMeter.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_SimpleWindMeter.java @@ -42,13 +42,12 @@ public BW_SimpleWindMeter() { @Override @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister p_94581_1_) { - this.itemIcon = p_94581_1_.registerIcon(MainMod.MOD_ID + ":BW_SimpleWindMeter"); + public void registerIcons(IIconRegister register) { + this.itemIcon = register.registerIcon(MainMod.MOD_ID + ":BW_SimpleWindMeter"); } @Override - @SuppressWarnings("unchecked") - public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean p_77624_4_) { + public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean p_77624_4_) { super.addInformation(itemStack, entityPlayer, list, p_77624_4_); list.add(StatCollector.translateToLocal("tooltip.windmeter.0.name")); list.add( diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_Stonage_Rotors.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_Stonage_Rotors.java index ce55f220b..fd875785a 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_Stonage_Rotors.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_Stonage_Rotors.java @@ -66,13 +66,14 @@ public BW_Stonage_Rotors(int diameter, float eff, int speed, float mRotor, int m this.itemTex = itemTex; } + @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { this.itemIcon = iconRegister.registerIcon(MainMod.MOD_ID + ":" + this.itemTex); } - @SuppressWarnings("unchecked") - public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean b) { + @Override + public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean b) { info.add( StatCollector .translateToLocalFormatted("ic2.itemrotor.wind.info", this.DiaMinMax[1], this.DiaMinMax[2])); @@ -85,14 +86,14 @@ public void addInformation(ItemStack itemStack, EntityPlayer player, List info, info.add(StatCollector.translateToLocal("tooltip.rotor.0.name") + " " + this.DiaMinMax[0]); info.add( StatCollector.translateToLocal("tooltip.rotor.1.name") + " " - + ((this.getMaxDamageEx() - this.getDamageOfStack(itemStack)) / 100) + + (this.getMaxDamageEx() - this.getDamageOfStack(itemStack)) / 100 + "/" - + (this.getMaxDamageEx() / 100)); + + this.getMaxDamageEx() / 100); info.add(StatCollector.translateToLocal("tooltip.rotor.2.name") + " " + this.eff); info.add(StatCollector.translateToLocal("tooltip.rotor.3.name") + " " + this.speed); info.add(StatCollector.translateToLocal("tooltip.rotor.4.name") + " " + this.mRotor); if (type != null) { - info.add(StatCollector.translateToLocal(("ic2.itemrotor.fitsin." + this.isAcceptedType(itemStack, type)))); + info.add(StatCollector.translateToLocal("ic2.itemrotor.fitsin." + this.isAcceptedType(itemStack, type))); } info.add(BW_Tooltip_Reference.ADDED_BY_BARTWORKS.get()); } @@ -128,11 +129,11 @@ public boolean isAcceptedType(ItemStack itemStack, IKineticRotor.GearboxType gea } public int getSpeed() { - return speed; + return this.speed; } public float getmRotor() { - return mRotor; + return this.mRotor; } public void setDamageForStack(ItemStack stack, int advDmg) { @@ -160,6 +161,6 @@ public int getMaxDamageEx() { } public void damageItemStack(ItemStack stack, int Dmg) { - setDamageForStack(stack, getDamageOfStack(stack) + Dmg); + this.setDamageForStack(stack, this.getDamageOfStack(stack) + Dmg); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/Circuit_Programmer.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/Circuit_Programmer.java index ebe2c0fa4..7eaea5c3a 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/Circuit_Programmer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/Circuit_Programmer.java @@ -73,8 +73,7 @@ public Circuit_Programmer() { } @Override - @SuppressWarnings("unchecked") - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { super.addInformation(aStack, aPlayer, aList, aF3_H); if (aStack != null && aStack.getTagCompound() != null) aList.add( StatCollector.translateToLocal("tooltip.cp.0.name") + " " @@ -94,8 +93,7 @@ public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer a @Override @SideOnly(Side.CLIENT) - @SuppressWarnings("unchecked") - public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List itemList) { + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List itemList) { ItemStack itemStack = new ItemStack(this, 1); if (this.getChargedItem(itemStack) == this) { ItemStack charged = new ItemStack(this, 1); @@ -163,10 +161,10 @@ public int getSlotLimit(int slot) { @Override public void putStack(ItemStack stack) { - if (isLVCircuit(stack)) { - stack = createRealCircuit(0); + if (Circuit_Programmer.this.isLVCircuit(stack)) { + stack = Circuit_Programmer.this.createRealCircuit(0); } - ((IItemHandlerModifiable) this.getItemHandler()).setStackInSlot(getSlotIndex(), stack); + ((IItemHandlerModifiable) this.getItemHandler()).setStackInSlot(this.getSlotIndex(), stack); this.onSlotChanged(); } }); @@ -174,7 +172,7 @@ public void putStack(ItemStack stack) { ItemStack initialStack = null; NBTTagCompound tag = heldStack.getTagCompound(); if (tag != null && tag.getBoolean(NBT_KEY_HAS_CHIP)) { - initialStack = createRealCircuit(tag.getByte(NBT_KEY_CHIP_CONFIG)); + initialStack = this.createRealCircuit(tag.getByte(NBT_KEY_CHIP_CONFIG)); } circuitSlotWidget.getMcSlot().putStack(initialStack); @@ -193,17 +191,17 @@ public void putStack(ItemStack stack) { tag2.setBoolean(NBT_KEY_HAS_CHIP, false); } heldItem.setTagCompound(tag2); - }).setFilter(stack -> isProgrammedCircuit(stack) || isLVCircuit(stack)) + }).setFilter(stack -> this.isProgrammedCircuit(stack) || this.isLVCircuit(stack)) .setBackground(ModularUITextures.ITEM_SLOT, GT_UITextures.OVERLAY_SLOT_INT_CIRCUIT).setPos(122, 60)); for (int i = 0; i < 24; i++) { final int index = i; builder.widget(new ButtonWidget().setOnClick((clickData, widget) -> { if (circuitSlotWidget.getMcSlot().getHasStack() - && isProgrammedCircuit(circuitSlotWidget.getMcSlot().getStack())) { - circuitSlotWidget.getMcSlot().putStack(createRealCircuit(index + 1)); + && this.isProgrammedCircuit(circuitSlotWidget.getMcSlot().getStack())) { + circuitSlotWidget.getMcSlot().putStack(this.createRealCircuit(index + 1)); } - }).setPos(32 + (i % 12) * 18, 21 + (i / 12) * 18).setSize(18, 18)); + }).setPos(32 + i % 12 * 18, 21 + i / 12 * 18).setSize(18, 18)); } return builder.build(); @@ -219,7 +217,7 @@ private boolean isProgrammedCircuit(ItemStack stack) { private boolean isLVCircuit(ItemStack stack) { return BW_Util.checkStackAndPrefix(stack) - && GT_OreDictUnificator.getAssociation(stack).mPrefix.equals(OrePrefixes.circuit) + && OrePrefixes.circuit.equals(GT_OreDictUnificator.getAssociation(stack).mPrefix) && GT_OreDictUnificator.getAssociation(stack).mMaterial.mMaterial.equals(Materials.Basic); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Destructopack_Item.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Destructopack_Item.java index 7d3327761..81b80f2ed 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Destructopack_Item.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Destructopack_Item.java @@ -49,8 +49,7 @@ public GT_Destructopack_Item() { } @Override - @SuppressWarnings("unchecked") - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { super.addInformation(aStack, aPlayer, aList, aF3_H); aList.add(BW_Tooltip_Reference.ADDED_BY_BARTWORKS.get()); } @@ -61,6 +60,7 @@ public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer a return aStack; } + @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister aIconRegister) { this.mIcon = aIconRegister.registerIcon("bartworks:gt.GT2Destructopack"); @@ -76,7 +76,7 @@ public ModularWindow createWindow(UIBuildContext buildContext, ItemStack heldSta @Override public void putStack(ItemStack stack) { - onSlotChanged(); + this.onSlotChanged(); } }).setBackground(ModularUITextures.ITEM_SLOT, BW_UITextures.OVERLAY_SLOT_CROSS).setPos(79, 16)).widget( new DrawableWidget().setDrawable(GT_UITextures.PICTURE_GT_LOGO_17x17_TRANSPARENT).setSize(17, 17) diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Rockcutter_Item.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Rockcutter_Item.java index 5207a345c..d099fa613 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Rockcutter_Item.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Rockcutter_Item.java @@ -59,7 +59,7 @@ public class GT_Rockcutter_Item extends ItemTool implements IElectricItem { public GT_Rockcutter_Item(int aTier) { super(2 * aTier, Item.ToolMaterial.EMERALD, GT_Rockcutter_Item.mineableBlocks); this.mTier = aTier; - this.multi = (int) Math.pow(10, (this.mTier - 1)); + this.multi = (int) Math.pow(10, this.mTier - 1); GT_Rockcutter_Item.mineableBlocks = new HashSet<>(); this.maxStackSize = 1; this.mCharge = 10000 * this.multi; @@ -71,13 +71,14 @@ public GT_Rockcutter_Item(int aTier) { this.setUnlocalizedName("GT_Rockcutter_Item_" + GT_Values.VN[this.mTier]); } - @SuppressWarnings("unchecked") - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { aList.add(StatCollector.translateToLocal("tooltip.bw.tier.name") + " " + GT_Values.VN[this.mTier]); aList.add(BW_Tooltip_Reference.ADDED_BY_BARTWORKS.get()); } - public void onUpdate(ItemStack aStack, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { + @Override + public void onUpdate(ItemStack aStack, World worldIn, Entity entityIn, int p_77663_4_, boolean p_77663_5_) { if (!ElectricItem.manager.canUse(aStack, 500 * this.multi)) { if (aStack.isItemEnchanted()) { aStack.getTagCompound().removeTag("ench"); @@ -87,12 +88,14 @@ public void onUpdate(ItemStack aStack, World p_77663_2_, Entity p_77663_3_, int } } + @Override public boolean onItemUse(ItemStack aStack, EntityPlayer aPlayer, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { ElectricItem.manager.use(aStack, 0, aPlayer); return false; } + @Override public boolean onBlockDestroyed(ItemStack var1, World var2, Block var3, int var4, int var5, int var6, EntityLivingBase var7) { ElectricItem.manager.use(var1, 0, var7); @@ -115,9 +118,9 @@ public boolean canHarvestBlock(Block par1Block, ItemStack itemStack) { || mineableBlocks.contains(par1Block); } + @Override @SideOnly(Side.CLIENT) - @SuppressWarnings("unchecked") - public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List itemList) { + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List itemList) { ItemStack itemStack = new ItemStack(this, 1); if (this.getChargedItem(itemStack) == this) { ItemStack charged = new ItemStack(this, 1); @@ -159,11 +162,13 @@ public double getTransferLimit(ItemStack itemStack) { return this.mTransfer; } + @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { this.icon = iconRegister.registerIcon("bartworks:GT_Rockcutter"); } + @Override @SideOnly(Side.CLIENT) public IIcon getIconFromDamage(int par1) { return this.icon; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Teslastaff_Item.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Teslastaff_Item.java index 0c0564299..bc0776250 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Teslastaff_Item.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Teslastaff_Item.java @@ -61,15 +61,14 @@ public GT_Teslastaff_Item() { } @Override - @SuppressWarnings("unchecked") - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { aList.add(StatCollector.translateToLocal("tooltip.teslastaff.0.name")); aList.add(BW_Tooltip_Reference.ADDED_BY_BARTWORKS.get()); } + @Override public boolean hitEntity(ItemStack aStack, EntityLivingBase aTarget, EntityLivingBase aPlayer) { - if (aTarget instanceof EntityLiving && ElectricItem.manager.canUse(aStack, 9000000)) { - EntityLiving tTarget = (EntityLiving) aTarget; + if (aTarget instanceof EntityLiving tTarget && ElectricItem.manager.canUse(aStack, 9000000)) { ElectricItem.manager.use(aStack, 9000000, aPlayer); for (int i = 1; i < 5; ++i) { if (tTarget.getEquipmentInSlot(i) != null @@ -81,9 +80,9 @@ public boolean hitEntity(ItemStack aStack, EntityLivingBase aTarget, EntityLivin return true; } + @Override @SideOnly(Side.CLIENT) - @SuppressWarnings("unchecked") - public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List itemList) { + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List itemList) { ItemStack itemStack = new ItemStack(this, 1); if (this.getChargedItem(itemStack) == this) { ItemStack charged = new ItemStack(this, 1); @@ -130,11 +129,13 @@ public double getTransferLimit(ItemStack itemStack) { return this.mTransfer; } + @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { this.icon = iconRegister.registerIcon("bartworks:GT_Teslastaff"); } + @Override @SideOnly(Side.CLIENT) public IIcon getIconFromDamage(int par1) { return this.icon; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabModule.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabModule.java index cc7977b5c..a4712dc36 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabModule.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabModule.java @@ -28,13 +28,13 @@ public LabModule(String[] tex) { this.setCreativeTab(MainMod.BIO_TAB); } - public String getUnlocalizedName(ItemStack p_77667_1_) { - return "labModule." + super.getUnlocalizedName(p_77667_1_); + @Override + public String getUnlocalizedName(ItemStack stack) { + return "labModule." + super.getUnlocalizedName(stack); } @Override - @SuppressWarnings("unchecked") - public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { aList.add(StatCollector.translateToLocal("tooltip.labmodule.0.name")); super.addInformation(p_77624_1_, p_77624_2_, aList, p_77624_4_); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabParts.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabParts.java index e8632c574..b18029411 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabParts.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabParts.java @@ -46,15 +46,11 @@ public EnumRarity getRarity(ItemStack itemStack) { if (itemStack == null || itemStack.getTagCompound() == null) return EnumRarity.common; - switch (itemStack.getItemDamage()) { - case 0: - return BW_Util.getRarityFromByte(itemStack.getTagCompound().getCompoundTag("DNA").getByte("Rarity")); - case 1: - case 2: - return BW_Util.getRarityFromByte(itemStack.getTagCompound().getByte("Rarity")); - default: - return EnumRarity.common; - } + return switch (itemStack.getItemDamage()) { + case 0 -> BW_Util.getRarityFromByte(itemStack.getTagCompound().getCompoundTag("DNA").getByte("Rarity")); + case 1, 2 -> BW_Util.getRarityFromByte(itemStack.getTagCompound().getByte("Rarity")); + default -> EnumRarity.common; + }; } @Override @@ -70,8 +66,7 @@ public int getColorFromItemStack(ItemStack stack, int p_82790_2_) { } @Override - @SuppressWarnings("unchecked") - public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean b) { + public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean b) { if (itemStack == null) return; if (itemStack.getTagCompound() == null) { @@ -129,17 +124,17 @@ public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List } @Override - @SuppressWarnings("unchecked") - public void getSubItems(Item item, CreativeTabs creativeTabs, List list) { + public void getSubItems(Item item, CreativeTabs creativeTabs, List list) { list.addAll(getAllPetriDishes()); list.addAll(getAllDNASampleFlasks()); list.addAll(getAllPlasmidCells()); super.getSubItems(item, creativeTabs, list); } + @Override public String getUnlocalizedName(ItemStack itemStack) { if (itemStack.getItemDamage() == 0 && itemStack.getTagCompound() != null) - return "filled.item." + this.tex[itemStack.getItemDamage()].replaceAll("/", "."); + return "filled.item." + this.tex[itemStack.getItemDamage()].replace('/', '.'); return super.getUnlocalizedName(itemStack); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleIconItem.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleIconItem.java index bd192efbe..e31e23d47 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleIconItem.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleIconItem.java @@ -27,6 +27,7 @@ public SimpleIconItem(String tex) { this.tex = tex; } + @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { this.itemIcon = iconRegister.registerIcon("bartworks:" + this.tex); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleSubItemClass.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleSubItemClass.java index 346f9e84c..8d5b239a7 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleSubItemClass.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleSubItemClass.java @@ -41,6 +41,7 @@ public SimpleSubItemClass(String... tex) { this.setCreativeTab(MainMod.BWT); } + @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { this.itemIcon = new IIcon[this.tex.length]; @@ -50,29 +51,28 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - @SuppressWarnings("unchecked") - public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { super.addInformation(p_77624_1_, p_77624_2_, aList, p_77624_4_); aList.add(BW_Tooltip_Reference.ADDED_BY_BARTWORKS.get()); } @Override - @SuppressWarnings("unchecked") - public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List p_150895_3_) { + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List p_150895_3_) { for (int i = 0; i < this.tex.length; i++) { p_150895_3_.add(new ItemStack(p_150895_1_, 1, i)); } } + @Override @SideOnly(Side.CLIENT) public IIcon getIconFromDamage(int p_77617_1_) { if (p_77617_1_ < this.tex.length) return this.itemIcon[p_77617_1_]; - else return this.itemIcon[0]; + return this.itemIcon[0]; } - public String getUnlocalizedName(ItemStack p_77667_1_) { - if (p_77667_1_.getItemDamage() < this.tex.length) - return "item." + this.tex[p_77667_1_.getItemDamage()].replaceAll("/", "."); - else return "WrongDamageItemDestroyIt"; + @Override + public String getUnlocalizedName(ItemStack stack) { + if (stack.getItemDamage() < this.tex.length) return "item." + this.tex[stack.getItemDamage()].replace('/', '.'); + return "WrongDamageItemDestroyIt"; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ElectricImplosionCompressorRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ElectricImplosionCompressorRecipes.java index f9f3ea3c6..e3804b8a5 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ElectricImplosionCompressorRecipes.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ElectricImplosionCompressorRecipes.java @@ -33,7 +33,7 @@ private static void addElectricImplosionRecipe(final ItemStack[] inputItems, fin 1); } - private static final ItemStack[] circuits = new ItemStack[] { ItemList.Circuit_ExoticProcessor.get(1), + private static final ItemStack[] circuits = { ItemList.Circuit_ExoticProcessor.get(1), ItemList.Circuit_OpticalAssembly.get(1), ItemList.Circuit_Biowaresupercomputer.get(1), ItemList.Circuit_Wetwaremainframe.get(1) }; @@ -129,30 +129,30 @@ public void run() { 20 * 4, (int) TierEU.RECIPE_MAX); - addMagnetohydrodynamicallyConstrainedStarMatterPartRecipes(); + this.addMagnetohydrodynamicallyConstrainedStarMatterPartRecipes(); } private void addMagnetohydrodynamicallyConstrainedStarMatterPartRecipes() { - addWhiteDwarfMagnetoEICRecipe(OrePrefixes.frameGt, 1, 1); - addWhiteDwarfMagnetoEICRecipe(OrePrefixes.nugget, 9, 1); - addWhiteDwarfMagnetoEICRecipe(OrePrefixes.ingot, 1, 1); - addWhiteDwarfMagnetoEICRecipe(OrePrefixes.plate, 1, 1); - addWhiteDwarfMagnetoEICRecipe(OrePrefixes.plateDense, 1, 3); - addWhiteDwarfMagnetoEICRecipe(OrePrefixes.stick, 2, 1); - addWhiteDwarfMagnetoEICRecipe(OrePrefixes.round, 8, 1); - addWhiteDwarfMagnetoEICRecipe(OrePrefixes.bolt, 8, 1); - addWhiteDwarfMagnetoEICRecipe(OrePrefixes.screw, 8, 1); - addWhiteDwarfMagnetoEICRecipe(OrePrefixes.ring, 4, 1); - addWhiteDwarfMagnetoEICRecipe(OrePrefixes.foil, 8, 1); - addWhiteDwarfMagnetoEICRecipe(OrePrefixes.itemCasing, 2, 1); - addWhiteDwarfMagnetoEICRecipe(OrePrefixes.gearGtSmall, 1, 1); - addWhiteDwarfMagnetoEICRecipe(OrePrefixes.rotor, 1, 2); - addWhiteDwarfMagnetoEICRecipe(OrePrefixes.stickLong, 1, 1); - addWhiteDwarfMagnetoEICRecipe(OrePrefixes.springSmall, 2, 1); - addWhiteDwarfMagnetoEICRecipe(OrePrefixes.spring, 1, 1); - addWhiteDwarfMagnetoEICRecipe(OrePrefixes.gearGt, 1, 2); - addWhiteDwarfMagnetoEICRecipe(OrePrefixes.wireFine, 8, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.frameGt, 1, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.nugget, 9, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.ingot, 1, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.plate, 1, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.plateDense, 1, 3); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.stick, 2, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.round, 8, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.bolt, 8, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.screw, 8, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.ring, 4, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.foil, 8, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.itemCasing, 2, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.gearGtSmall, 1, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.rotor, 1, 2); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.stickLong, 1, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.springSmall, 2, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.spring, 1, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.gearGt, 1, 2); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.wireFine, 8, 1); } private void addWhiteDwarfMagnetoEICRecipe(final OrePrefixes part, final int multiplier, diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java index 418a299f5..6f4b23747 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java @@ -14,11 +14,11 @@ package com.github.bartimaeusnek.bartworks.common.loaders; import static gregtech.api.enums.Mods.Gendustry; +import static gregtech.api.enums.Mods.GregTech; import static gregtech.api.util.GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes; import static gregtech.api.util.GT_RecipeBuilder.SECONDS; -import java.awt.*; -import java.util.Arrays; +import java.awt.Color; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; @@ -36,11 +36,12 @@ import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.GregTech_API; +import gregtech.api.enums.FluidState; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; import gregtech.api.enums.TierEU; -import gregtech.api.objects.GT_Fluid; -import gregtech.api.util.GT_LanguageManager; +import gregtech.api.fluid.GT_FluidFactory; import gregtech.api.util.GT_Utility; import gregtech.common.items.GT_MetaGenerated_Item_98; @@ -57,30 +58,27 @@ public class FluidLoader { public static Fluid fulvicAcid, heatedfulvicAcid, Kerogen; public static void run() { - FluidLoader.renderID = RenderingRegistry.getNextAvailableRenderId(); - short[] rgb = new short[3]; - Arrays.fill(rgb, (short) 255); - FluidLoader.ff = new GT_Fluid("BWfakeFluid", "molten.autogenerated", rgb); - FluidLoader.fulvicAcid = FluidLoader.createAndRegisterFluid("Fulvic Acid", new Color(20, 20, 20)); - FluidLoader.heatedfulvicAcid = FluidLoader - .createAndRegisterFluid("Heated Fulvic Acid", new Color(40, 20, 20), 720); - FluidLoader.Kerogen = FluidLoader.createAndRegisterFluid("Kerogen", new Color(85, 85, 85)); - FluidLoader.BioLabFluidMaterials = new Fluid[] { - new GT_Fluid("FluorecentdDNA", "molten.autogenerated", new short[] { 125, 50, 170, 0 }), - new GT_Fluid("EnzymesSollution", "molten.autogenerated", new short[] { 240, 200, 125, 0 }), - new GT_Fluid("Penicillin", "molten.autogenerated", new short[] { 255, 255, 255, 0 }), - new GT_Fluid("Polymerase", "molten.autogenerated", new short[] { 110, 180, 110, 0 }), }; - - FluidLoader.BioLabFluidCells = new ItemStack[FluidLoader.BioLabFluidMaterials.length]; - for (int i = 0; i < FluidLoader.BioLabFluidMaterials.length; i++) { - FluidRegistry.registerFluid(FluidLoader.BioLabFluidMaterials[i]); - } - - GT_MetaGenerated_Item_98.FluidCell[] fluidCells = new GT_MetaGenerated_Item_98.FluidCell[] { - GT_MetaGenerated_Item_98.FluidCell.FLUORESCENT_DNA, GT_MetaGenerated_Item_98.FluidCell.ENZYME_SOLUTION, - GT_MetaGenerated_Item_98.FluidCell.PENICILLIN, GT_MetaGenerated_Item_98.FluidCell.POLYMERASE, }; + renderID = RenderingRegistry.getNextAvailableRenderId(); + ff = new Fluid("BWfakeFluid"); + GregTech_API.sGTBlockIconload.add( + () -> ff.setIcons( + GregTech_API.sBlockIcons + .registerIcon(GregTech.getResourcePath("fluids", "fluid.molten.autogenerated")))); + fulvicAcid = createAndRegisterFluid("Fulvic Acid", new Color(20, 20, 20)); + heatedfulvicAcid = createAndRegisterFluid("Heated Fulvic Acid", new Color(40, 20, 20), 720); + Kerogen = createAndRegisterFluid("Kerogen", new Color(85, 85, 85)); + BioLabFluidMaterials = new Fluid[] { createAndRegisterFluid("FluorecentdDNA", new Color(125, 50, 170)), + createAndRegisterFluid("EnzymesSollution", new Color(240, 200, 125)), + createAndRegisterFluid("Penicillin", new Color(255, 255, 255)), + createAndRegisterFluid("Polymerase", new Color(110, 180, 110)) }; + + BioLabFluidCells = new ItemStack[BioLabFluidMaterials.length]; + + GT_MetaGenerated_Item_98.FluidCell[] fluidCells = { GT_MetaGenerated_Item_98.FluidCell.FLUORESCENT_DNA, + GT_MetaGenerated_Item_98.FluidCell.ENZYME_SOLUTION, GT_MetaGenerated_Item_98.FluidCell.PENICILLIN, + GT_MetaGenerated_Item_98.FluidCell.POLYMERASE, }; for (int i = 0; i < fluidCells.length; i++) { - FluidLoader.BioLabFluidCells[i] = fluidCells[i].get(); + BioLabFluidCells[i] = fluidCells[i].get(); } FluidStack dnaFluid = Gendustry.isModLoaded() ? FluidRegistry.getFluidStack("liquiddna", 100) @@ -88,24 +86,22 @@ public static void run() { for (BioCulture B : BioCulture.BIO_CULTURE_ARRAY_LIST) { if (B.isBreedable()) { B.setFluid( - new GT_Fluid( - B.getName().replaceAll(" ", "").toLowerCase() + "fluid", - "molten.autogenerated", - new short[] { (short) B.getColor().getRed(), (short) B.getColor().getBlue(), - (short) B.getColor().getGreen() })); - FluidRegistry.registerFluid(B.getFluid()); - GT_LanguageManager - .addStringLocalization(B.getFluid().getUnlocalizedName(), B.getLocalisedName() + " Fluid"); + GT_FluidFactory.builder(B.getName().replace(" ", "").toLowerCase() + "fluid") + .withTextureName("molten.autogenerated") + .withColorRGBA( + new short[] { (short) B.getColor().getRed(), (short) B.getColor().getBlue(), + (short) B.getColor().getGreen() }) + .withLocalizedName(B.getLocalisedName() + " Fluid") + .withStateAndTemperature(FluidState.LIQUID, 300).buildAndRegister().asFluid()); GT_Values.RA.stdBuilder().itemInputs(GT_Utility.getIntegratedCircuit(10)) .fluidInputs(new FluidStack(B.getFluid(), 1000)).fluidOutputs(dnaFluid).duration(25 * SECONDS) .eut(TierEU.RECIPE_MV).addTo(sCentrifugeRecipes); - } } - FluidLoader.bioFluidBlock = new BioFluidBlock(); - GameRegistry.registerBlock(FluidLoader.bioFluidBlock, "coloredFluidBlock"); + bioFluidBlock = new BioFluidBlock(); + GameRegistry.registerBlock(bioFluidBlock, "coloredFluidBlock"); GameRegistry.registerTileEntity(BWTileEntityDimIDBridge.class, "bwTEDimIDBridge"); if (SideReference.Side.Client) { RenderingRegistry.registerBlockHandler(RendererSwitchingColorFluid.instance); @@ -114,25 +110,18 @@ public static void run() { } public static Fluid createAndRegisterFluid(String Name, Color color) { - Fluid f = new GT_Fluid( - Name, - "molten.autogenerated", - new short[] { (short) color.getRed(), (short) color.getGreen(), (short) color.getBlue(), - (short) color.getAlpha() }); - GT_LanguageManager.addStringLocalization(f.getUnlocalizedName(), Name); - FluidRegistry.registerFluid(f); - return f; + return GT_FluidFactory.builder(Name).withTextureName("molten.autogenerated") + .withColorRGBA( + new short[] { (short) color.getRed(), (short) color.getGreen(), (short) color.getBlue(), + (short) color.getAlpha() }) + .withStateAndTemperature(FluidState.LIQUID, 300).buildAndRegister().asFluid(); } public static Fluid createAndRegisterFluid(String Name, Color color, int temperature) { - Fluid f = new GT_Fluid( - Name, - "molten.autogenerated", - new short[] { (short) color.getRed(), (short) color.getGreen(), (short) color.getBlue(), - (short) color.getAlpha() }); - GT_LanguageManager.addStringLocalization(f.getUnlocalizedName(), Name); - f.setTemperature(temperature); - FluidRegistry.registerFluid(f); - return f; + return GT_FluidFactory.builder(Name).withTextureName("molten.autogenerated") + .withColorRGBA( + new short[] { (short) color.getRed(), (short) color.getGreen(), (short) color.getBlue(), + (short) color.getAlpha() }) + .withStateAndTemperature(FluidState.LIQUID, temperature).buildAndRegister().asFluid(); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java index 48e178bc7..50f5fa6b7 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java @@ -283,15 +283,15 @@ public static void run() { "Electric Implosion Compressor").getStackForm(1L); // EIC depend on neutronium block to pass on structure updates - int bitmask = GregTech_API.sMachineIDs.getOrDefault(GregTech_API.sBlockMetal5, 0) | (1 << 2); + int bitmask = GregTech_API.sMachineIDs.getOrDefault(GregTech_API.sBlockMetal5, 0) | 1 << 2; GregTech_API.registerMachineBlock(GregTech_API.sBlockMetal5, bitmask); // Also spacetime, transcendent metal, and universium - bitmask = GregTech_API.sMachineIDs.getOrDefault(GregTech_API.sBlockMetal9, 0) | (1 << 3) | (1 << 4) | (1 << 8); + bitmask = GregTech_API.sMachineIDs.getOrDefault(GregTech_API.sBlockMetal9, 0) | 1 << 3 | 1 << 4 | 1 << 8; GregTech_API.registerMachineBlock(GregTech_API.sBlockMetal9, bitmask); // Also infinity - bitmask = GregTech_API.sMachineIDs.getOrDefault(LudicrousBlocks.resource_block, 0) | (1 << 1); + bitmask = GregTech_API.sMachineIDs.getOrDefault(LudicrousBlocks.resource_block, 0) | 1 << 1; GregTech_API.registerMachineBlock(LudicrousBlocks.resource_block, bitmask); ItemRegistry.THTR = new GT_TileEntity_THTR( @@ -422,31 +422,34 @@ public static void run() { for (int amps = 32; amps <= 128; amps += 32) { for (int tier = 4; tier < 8; tier++) { TecTechLaserAdditions[0][amps / 32 - 1][tier - 4] = new TT_MetaTileEntity_LowPowerLaserBox( - startID++, + startID, GT_Values.VN[tier] + "_LPLaser_Converter_" + amps, GT_Values.VN[tier] + " " + amps + "A/t" + " Low Power Laser Converter", tier, amps).getStackForm(1L); + startID++; } } for (int amps = 32; amps <= 128; amps += 32) { for (int tier = 4; tier < 8; tier++) { TecTechLaserAdditions[1][amps / 32 - 1][tier - 4] = new TT_MetaTileEntity_LowPowerLaserHatch( - startID++, + startID, GT_Values.VN[tier] + "_LPLaser_Hatch_" + amps, GT_Values.VN[tier] + " " + amps + "A/t" + " Low Power Laser Target Hatch", tier, amps).getStackForm(1L); + startID++; } } for (int amps = 32; amps <= 128; amps += 32) { for (int tier = 4; tier < 8; tier++) { TecTechLaserAdditions[2][amps / 32 - 1][tier - 4] = new TT_MetaTileEntity_LowPowerLaserDynamo( - startID++, + startID, GT_Values.VN[tier] + "_LPLaser_Dynamo_" + amps, GT_Values.VN[tier] + " " + amps + "A/t" + " Low Power Laser Source Hatch", tier, amps).getStackForm(1L); + startID++; } } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RadioHatchMaterialLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RadioHatchMaterialLoader.java index 41fc6c8a2..9a3ade059 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RadioHatchMaterialLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RadioHatchMaterialLoader.java @@ -42,9 +42,8 @@ public static void run() { } } - Materials[] spacialMaterial = new Materials[] { Materials.Naquadah, Materials.NaquadahEnriched, - Materials.Naquadria }; - int[] spacialValue = new int[] { 130, 140, 150 }; + Materials[] spacialMaterial = { Materials.Naquadah, Materials.NaquadahEnriched, Materials.Naquadria }; + int[] spacialValue = { 130, 140, 150 }; for (int i = 0; i < spacialMaterial.length; i++) { if (GT_OreDictUnificator.get(OrePrefixes.stick, spacialMaterial[i], 1) != null) diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/StaticRecipeChangeLoaders.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/StaticRecipeChangeLoaders.java index 3b145cad5..0cba76518 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/StaticRecipeChangeLoaders.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/StaticRecipeChangeLoaders.java @@ -30,7 +30,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.stream.Collectors; +import java.util.Set; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -45,7 +45,6 @@ import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; import com.github.bartimaeusnek.bartworks.util.BWRecipes; import com.github.bartimaeusnek.bartworks.util.BW_Util; -import com.github.bartimaeusnek.bartworks.util.Pair; import com.github.bartimaeusnek.bartworks.util.StreamUtils; import com.github.bartimaeusnek.bartworks.util.log.DebugLog; import com.github.bartimaeusnek.crossmod.BartWorksCrossmod; @@ -109,7 +108,7 @@ public static void addEBFGasRecipes() { public static void fixEnergyRequirements() { GT_Recipe.GT_Recipe_Map.sMappings.stream().filter(StreamUtils::filterVisualMaps) .forEach(gt_recipe_map -> gt_recipe_map.mRecipeList.parallelStream().forEach(gt_recipe -> { - for (int i = 0; i < (VN.length - 1); i++) { + for (int i = 0; i < VN.length - 1; i++) { if (gt_recipe.mEUt > BW_Util.getMachineVoltageFromTier(i) && gt_recipe.mEUt <= BW_Util.getTierVoltage(i)) { gt_recipe.mEUt = BW_Util.getMachineVoltageFromTier(i); @@ -217,15 +216,14 @@ public static void unificationRecipeEnforcer() { recipe.mOutputs[i] = GT_Utility .copyAmount(recipe.mOutputs[i].stackSize, replacement); } - if (recipe.mSpecialItems instanceof ItemStack) { - ItemStack specialItemStack = (ItemStack) recipe.mSpecialItems; + if (recipe.mSpecialItems instanceof ItemStack specialItemStack) { if (!GT_Utility.areStacksEqual(specialItemStack, toReplace)) continue; if (removal) { iterator.remove(); continue nextRecipe; } recipe.mSpecialItems = GT_Utility - .copyAmount((specialItemStack).stackSize, replacement); + .copyAmount(specialItemStack.stackSize, replacement); } } } @@ -235,7 +233,6 @@ public static void unificationRecipeEnforcer() { } } - @SuppressWarnings("ALL") private static void runMoltenUnificationEnfocement(Werkstoff werkstoff) { if (werkstoff.getGenerationFeatures().enforceUnification && werkstoff.hasItemType(OrePrefixes.cellMolten)) { try { @@ -245,52 +242,52 @@ private static void runMoltenUnificationEnfocement(Werkstoff werkstoff) { Materials.Empty.getCells(1)); Field f = GT_Utility.class.getDeclaredField("sFilledContainerToData"); f.setAccessible(true); + @SuppressWarnings("unchecked") Map sFilledContainerToData = (Map) f .get(null); - HashSet torem = new HashSet<>(); + Set> toremFilledContainerToData = new HashSet<>(); ItemStack toReplace = null; for (Map.Entry entry : sFilledContainerToData .entrySet()) { final String MODID = GameRegistry.findUniqueIdentifierFor(data.filledContainer.getItem()).modId; - if (MODID.equals(MainMod.MOD_ID) || MODID.equals(BartWorksCrossmod.MOD_ID)) continue; + if (MainMod.MOD_ID.equals(MODID) || BartWorksCrossmod.MOD_ID.equals(MODID)) continue; if (entry.getValue().fluid.equals(data.fluid) && !entry.getValue().filledContainer.equals(data.filledContainer)) { toReplace = entry.getValue().filledContainer; - torem.add(entry); + toremFilledContainerToData.add(entry); } } - sFilledContainerToData.entrySet().removeAll(torem); - torem.clear(); + sFilledContainerToData.entrySet().removeAll(toremFilledContainerToData); + Set toremRecipeList = new HashSet<>(); if (toReplace != null) { for (GT_Recipe.GT_Recipe_Map map : GT_Recipe.GT_Recipe_Map.sMappings) { - torem.clear(); + toremRecipeList.clear(); for (GT_Recipe recipe : map.mRecipeList) { - for (int i = 0; i < recipe.mInputs.length; i++) { - if (GT_Utility.areStacksEqual(recipe.mInputs[i], toReplace)) { - torem.add(recipe); + for (ItemStack mInput : recipe.mInputs) { + if (GT_Utility.areStacksEqual(mInput, toReplace)) { + toremRecipeList.add(recipe); // recipe.mInputs[i] = data.filledContainer; } } - for (int i = 0; i < recipe.mOutputs.length; i++) { - if (GT_Utility.areStacksEqual(recipe.mOutputs[i], toReplace)) { - torem.add(recipe); + for (ItemStack mOutput : recipe.mOutputs) { + if (GT_Utility.areStacksEqual(mOutput, toReplace)) { + toremRecipeList.add(recipe); // recipe.mOutputs[i] = data.filledContainer; if (map == GT_Recipe.GT_Recipe_Map.sFluidCannerRecipes - && GT_Utility.areStacksEqual(recipe.mOutputs[i], data.filledContainer) + && GT_Utility.areStacksEqual(mOutput, data.filledContainer) && !recipe.mFluidInputs[0].equals(data.fluid)) { - torem.add(recipe); + toremRecipeList.add(recipe); // recipe.mOutputs[i] = data.filledContainer; } } } - if (recipe.mSpecialItems instanceof ItemStack) { - if (GT_Utility.areStacksEqual((ItemStack) recipe.mSpecialItems, toReplace)) { - torem.add(recipe); - // recipe.mSpecialItems = data.filledContainer; - } + if (recipe.mSpecialItems instanceof ItemStack + && GT_Utility.areStacksEqual((ItemStack) recipe.mSpecialItems, toReplace)) { + toremRecipeList.add(recipe); + // recipe.mSpecialItems = data.filledContainer; } } - map.mRecipeList.removeAll(torem); + map.mRecipeList.removeAll(toremRecipeList); } } GT_Utility.addFluidContainerData(data); @@ -301,12 +298,11 @@ private static void runMoltenUnificationEnfocement(Werkstoff werkstoff) { } private static void runUnficationDeleter(Werkstoff werkstoff) { - if (werkstoff.getType() == Werkstoff.Types.ELEMENT) { - if (werkstoff.getBridgeMaterial() != null && Element.get(werkstoff.getToolTip()) != Element._NULL) { - werkstoff.getBridgeMaterial().mElement = Element.get(werkstoff.getToolTip()); - Element.get(werkstoff.getToolTip()).mLinkedMaterials = new ArrayList<>(); - Element.get(werkstoff.getToolTip()).mLinkedMaterials.add(werkstoff.getBridgeMaterial()); - } + if (werkstoff.getType() == Werkstoff.Types.ELEMENT && werkstoff.getBridgeMaterial() != null + && Element.get(werkstoff.getToolTip()) != Element._NULL) { + werkstoff.getBridgeMaterial().mElement = Element.get(werkstoff.getToolTip()); + Element.get(werkstoff.getToolTip()).mLinkedMaterials = new ArrayList<>(); + Element.get(werkstoff.getToolTip()).mLinkedMaterials.add(werkstoff.getBridgeMaterial()); } for (OrePrefixes prefixes : OrePrefixes.values()) if (werkstoff.hasItemType(prefixes)) { @@ -319,12 +315,11 @@ private static void runUnficationDeleter(Werkstoff werkstoff) { } private static void runMaterialLinker(Werkstoff werkstoff) { - if (werkstoff.getType() == Werkstoff.Types.ELEMENT) { - if (werkstoff.getBridgeMaterial() != null && Element.get(werkstoff.getToolTip()) != Element._NULL) { - werkstoff.getBridgeMaterial().mElement = Element.get(werkstoff.getToolTip()); - Element.get(werkstoff.getToolTip()).mLinkedMaterials = new ArrayList<>(); - Element.get(werkstoff.getToolTip()).mLinkedMaterials.add(werkstoff.getBridgeMaterial()); - } + if (werkstoff.getType() == Werkstoff.Types.ELEMENT && werkstoff.getBridgeMaterial() != null + && Element.get(werkstoff.getToolTip()) != Element._NULL) { + werkstoff.getBridgeMaterial().mElement = Element.get(werkstoff.getToolTip()); + Element.get(werkstoff.getToolTip()).mLinkedMaterials = new ArrayList<>(); + Element.get(werkstoff.getToolTip()).mLinkedMaterials.add(werkstoff.getBridgeMaterial()); } for (OrePrefixes prefixes : OrePrefixes.values()) @@ -379,14 +374,13 @@ private static HashSet getNoGasItems(ArrayListMultimap GT_Utility.areStacksEqual(s, tmpInput)) - || (BW_Util.checkStackAndPrefix(recipe.mInputs[i]) + || BW_Util.checkStackAndPrefix(recipe.mInputs[i]) && BW_Util.checkStackAndPrefix(baseRe.mInputs[i]) && GT_OreDictUnificator .getAssociation(recipe.mInputs[i]).mMaterial.mMaterial.equals( GT_OreDictUnificator.getAssociation( baseRe.mInputs[i]).mMaterial.mMaterial) - && GT_Utility - .areStacksEqual(recipe.mOutputs[0], baseRe.mOutputs[0])))) { + && GT_Utility.areStacksEqual(recipe.mOutputs[0], baseRe.mOutputs[0]))) { toAdd.add(recipe.mOutputs[0]); repToAdd.put(tag, recipe); continue recipeLoop; @@ -399,9 +393,8 @@ private static HashSet getNoGasItems(ArrayListMultimap= originalGasProtons ? 1.0D : 2.75D) - - (double) newGasProtons; - return Math.max(1, (int) ((double) originalDuration / 200D * Math.max(200D + protonTerm, 1D))); + double protonTerm = originalGasProtons * (newGasProtons >= originalGasProtons ? 1.0D : 2.75D) - newGasProtons; + return Math.max(1, (int) (originalDuration / 200D * Math.max(200D + protonTerm, 1D))); } private static int transformEBFGasRecipeTime(GT_Recipe recipe, Materials originalGas, Materials newGas) { @@ -409,9 +402,8 @@ private static int transformEBFGasRecipeTime(GT_Recipe recipe, Materials origina double originalEbfMul = gtEbfGasRecipeTimeMultipliers.get(originalGas); if (newEbfMul < 0.0D || originalEbfMul < 0.0D) { return transformEBFGasRecipeTime(recipe.mDuration, originalGas.getProtons(), newGas.getProtons()); - } else { - return Math.max(1, (int) ((double) recipe.mDuration * newEbfMul / originalEbfMul)); } + return Math.max(1, (int) (recipe.mDuration * newEbfMul / originalEbfMul)); } private static int transformEBFGasRecipeTime(GT_Recipe recipe, Materials originalGas, Werkstoff newGas) { @@ -422,9 +414,8 @@ private static int transformEBFGasRecipeTime(GT_Recipe recipe, Materials origina recipe.mDuration, originalGas.getProtons(), newGas.getStats().getProtons()); - } else { - return Math.max(1, (int) ((double) recipe.mDuration * newEbfMul / originalEbfMul)); } + return Math.max(1, (int) (recipe.mDuration * newEbfMul / originalEbfMul)); } private static int transformEBFNoGasRecipeTime(GT_Recipe recipe, Materials originalGas) { @@ -439,8 +430,7 @@ private static void editEBFMaterialRecipes(SubTag GasTag, GT_Recipe recipe, Mate int gasAmount = Math.max( 1, (int) Math.round( - (double) recipe.mFluidInputs[0].amount - * gtEbfGasRecipeConsumptionMultipliers.get(newGas))); + recipe.mFluidInputs[0].amount * gtEbfGasRecipeConsumptionMultipliers.get(newGas))); if (recipe.mFluidInputs != null && recipe.mFluidInputs.length == 1 && recipe.mFluidInputs[0].isFluidEqual(newGas.getGas(0))) { // preserve original recipe owner @@ -484,7 +474,7 @@ private static void editEBFWerkstoffRecipes(SubTag GasTag, GT_Recipe recipe, Mat int gasAmount = Math.max( 1, (int) Math.round( - (double) recipe.mFluidInputs[0].amount + recipe.mFluidInputs[0].amount * newGas.getStats().getEbfGasRecipeConsumedAmountMultiplier())); if (recipe.mFluidInputs != null && recipe.mFluidInputs.length == 1 && recipe.mFluidInputs[0] @@ -535,10 +525,12 @@ private static void editEBFNoGasRecipes(GT_Recipe recipe, Materials originalGas, && !GT_Utility.areStacksEqual(GT_Utility.getIntegratedCircuit(14), stack) && !GT_Utility.areStacksEqual(GT_Utility.getIntegratedCircuit(19), stack)) { if (BW_Util.checkStackAndPrefix(stack)) - circuitConfiguration = (byte) (GT_OreDictUnificator.getAssociation(stack).mPrefix - .equals(OrePrefixes.dustSmall) ? 4 - : GT_OreDictUnificator.getAssociation(stack).mPrefix - .equals(OrePrefixes.dustTiny) ? 9 : 1); + circuitConfiguration = (byte) (OrePrefixes.dustSmall + .equals(GT_OreDictUnificator.getAssociation(stack).mPrefix) + ? 4 + : OrePrefixes.dustTiny.equals( + GT_OreDictUnificator.getAssociation(stack).mPrefix) ? 9 + : 1); inputs.add(stack); } inputs.add(GT_Utility.getIntegratedCircuit(circuitConfiguration)); @@ -635,130 +627,9 @@ public static void addElectricImplosionCompressorRecipes() { } private static boolean checkForExplosives(ItemStack input) { - return (GT_Utility.areStacksEqual(input, new ItemStack(Blocks.tnt)) + return GT_Utility.areStacksEqual(input, new ItemStack(Blocks.tnt)) || GT_Utility.areStacksEqual(input, GT_ModHandler.getIC2Item("industrialTnt", 1L)) || GT_Utility.areStacksEqual(input, GT_ModHandler.getIC2Item("dynamite", 1L)) - || GT_Utility.areStacksEqual(input, ItemList.Block_Powderbarrel.get(1L))); - } - - private static int getBlastLogic(GT_Recipe recipe) { - int ret = 0; - - for (ItemStack stack : recipe.mInputs) { - if (stack != null) { - ret += Math.max(stack.stackSize, 1); - } - } - - while (ret > 14) { - ret /= 10; - } - - if (recipe.mFluidInputs.length != 0) ret += 10; - - return ret; - } - - private static int getLogicFuntion(GT_Recipe.GT_Recipe_Map gt_recipe_map, GT_Recipe recipe, - Pair counts) { - if (gt_recipe_map == GT_Recipe.GT_Recipe_Map.sMultiblockChemicalRecipes) - return getChemicalLogic(recipe, counts); - else if (gt_recipe_map == GT_Recipe.GT_Recipe_Map.sBlastRecipes) return getBlastLogic(recipe); - throw new NoSuchMethodError("Could not find a Supported Method for " + gt_recipe_map.mUnlocalizedName); - } - - private static int getChemicalLogic(GT_Recipe recipe, Pair counts) { - Pair toSet; - - if (counts.getKey() == 0 || counts.getValue() == 0) - toSet = new Pair<>(Math.max(recipe.mFluidOutputs.length, recipe.mOutputs.length), 0); - else if (counts.getValue() > 2) toSet = new Pair<>(counts.getKey() + counts.getValue(), 1); - else toSet = counts; - - return toSet.getValue() * 10 + toSet.getKey(); - } - - private static void transformCircuitRecipes(GT_Recipe.GT_Recipe_Map gtRecipeMap, - Map> mapGtRecipeCounts) { - mapGtRecipeCounts.forEach( - (recipe, counts) -> StaticRecipeChangeLoaders.rewriteForCorrectCircuit(gtRecipeMap, recipe, counts)); - - gtRecipeMap.mRecipeList.clear(); - gtRecipeMap.mRecipeList.addAll(mapGtRecipeCounts.keySet()); - - fixRecipeClashes(gtRecipeMap); - } - - private static void fixRecipeClashes(GT_Recipe.GT_Recipe_Map gtRecipeMap) { - boolean hasClashes; - do { - hasClashes = false; - gtRecipeMap.reInit(); - for (GT_Recipe re : gtRecipeMap.mRecipeList) { - if (gtRecipeMap.findRecipe(null, false, Long.MAX_VALUE, re.mFluidInputs, re.mInputs) != re) { - hasClashes = true; - fixRecipeCircuitClashes(re); - } - } - } while (hasClashes); - } - - private static void fixRecipeCircuitClashes(GT_Recipe recipe) { - for (int i = 0; i < recipe.mInputs.length; i++) { - if (GT_Utility.areStacksEqual(GT_Utility.getIntegratedCircuit(Short.MAX_VALUE), recipe.mInputs[i])) { - int nudmg = recipe.mInputs[i].getItemDamage() + 1 > 24 ? 1 : recipe.mInputs[i].getItemDamage() + 1; - recipe.mInputs[i].setItemDamage(nudmg); - } - } - } - - private static Map>> getRecipesByCircuitID( - GT_Recipe.GT_Recipe_Map[] ref) { - return Arrays.stream(ref).collect( - Collectors.toMap( - k -> k, - k -> getArrayListMultiMapFromRecipeList(gatherNoCircuitRecipes(new HashSet<>(k.mRecipeList))))); - } - - private static GT_Recipe rewriteForCorrectCircuit(GT_Recipe.GT_Recipe_Map gt_recipe_map, GT_Recipe recipe, - Pair counts) { - ItemStack[] old = BW_Util.copyAndRemoveNulls(recipe.mInputs, ItemStack.class); - ItemStack[] nu = Arrays.copyOf(old, old.length + 1); - - nu[old.length] = GT_Utility.getIntegratedCircuit( // Max 24, Min 1 - Math.min(Math.max(getLogicFuntion(gt_recipe_map, recipe, counts), 1), 24)); - recipe.mInputs = nu; - - return recipe; - } - - @SuppressWarnings("unchecked") - private static Collection gatherNoCircuitRecipes(Collection mRecipeList) { - Collection newColl; - try { - newColl = (Collection) mRecipeList.getClass().newInstance(); - } catch (InstantiationException | IllegalAccessException e) { - newColl = new HashSet<>(); - } - - recipeloop: for (GT_Recipe r : mRecipeList) { - for (int i = 0; i < r.mInputs.length; i++) - if (GT_Utility.areStacksEqual(GT_Utility.getIntegratedCircuit(Short.MAX_VALUE), r.mInputs[i])) { - continue recipeloop; - } - newColl.add(r); - } - - return newColl; - } - - private static Map> getArrayListMultiMapFromRecipeList( - Collection mRecipeList) { - return mRecipeList.stream().collect( - Collectors.toMap( - recipe -> recipe, - recipe -> new Pair<>( - (int) Arrays.stream(recipe.mInputs).filter(Objects::nonNull).count(), - (int) Arrays.stream(recipe.mFluidInputs).filter(Objects::nonNull).count()))); + || GT_Utility.areStacksEqual(input, ItemList.Block_Powderbarrel.get(1L)); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Assembler.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Assembler.java index 833c3c647..4b676367c 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Assembler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/Assembler.java @@ -173,7 +173,6 @@ public void run() { ItemList.TRANSFORMERS[4 + i].get(2 * (j + 1))).itemOutputs(converter) .fluidInputs(Materials.SolderingAlloy.getMolten(solderingAmount)) .duration((10 * (j + 1)) * SECONDS).eut(recipeConsumption).addTo(sAssemblerRecipes); - GT_Values.RA.stdBuilder() .itemInputs( new ItemStack( @@ -182,6 +181,21 @@ public void run() { ItemRegistry.TecTechPipeEnergyLowPower.getItemDamage()), WerkstoffLoader.CubicZirconia.get(OrePrefixes.lens), GT_OreDictUnificator.get(prefixes[j], cables[i + 4], 8), + emitters[i].get(2 * (j + 1)), + sensors[i].get(2 * (j + 1)), + ItemList.TRANSFORMERS[4 + i].get(2 * (j + 1))) + .itemOutputs(converter).fluidInputs(Materials.SolderingAlloy.getMolten(solderingAmount)) + .noFluidOutputs().duration((10 * (j + 1)) * SECONDS).eut(recipeConsumption) + .addTo(sAssemblerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack( + ItemRegistry.TecTechPipeEnergyLowPower.getItem(), + (j + 1) * 16, + ItemRegistry.TecTechPipeEnergyLowPower.getItemDamage()), + WerkstoffLoader.CubicZirconia.get(OrePrefixes.lens), + GT_OreDictUnificator.get(prefixes[j], cables[i + 4], 8), sensors[i].get(2 * (j + 1)), ItemList.HATCHES_ENERGY[4 + i].get(2 * (j + 1))) .itemOutputs(eInput).fluidInputs(Materials.SolderingAlloy.getMolten(solderingAmount)) @@ -191,7 +205,7 @@ public void run() { .itemInputs( new ItemStack( ItemRegistry.TecTechPipeEnergyLowPower.getItem(), - ((j + 1) * 16), + (j + 1) * 16, ItemRegistry.TecTechPipeEnergyLowPower.getItemDamage()), WerkstoffLoader.CubicZirconia.get(OrePrefixes.lens), GT_OreDictUnificator.get(prefixes[j], cables[i + 4], 8), diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/CraftingRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/CraftingRecipes.java index c36b0a612..3ee15f52d 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/CraftingRecipes.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/recipes/CraftingRecipes.java @@ -443,12 +443,12 @@ public void run() { for (int i = 3; i < GT_Values.VN.length - 1; i++) { // 12625 - BioLab2[(i - 3)] = new GT_MetaTileEntity_BioLab( + BioLab2[i - 3] = new GT_MetaTileEntity_BioLab( ConfigHandler.IDOffset + GT_Values.VN.length * 6 + i, "bw.biolab" + GT_Values.VN[i], GT_Values.VN[i] + " " + StatCollector.translateToLocal("tile.biolab.name"), i).getStackForm(1L); - RadioHatch2[(i - 3)] = new GT_MetaTileEntity_RadioHatch( + RadioHatch2[i - 3] = new GT_MetaTileEntity_RadioHatch( ConfigHandler.IDOffset + GT_Values.VN.length * 7 - 2 + i, "bw.radiohatch" + GT_Values.VN[i], GT_Values.VN[i] + " " + StatCollector.translateToLocal("tile.radiohatch.name"), @@ -456,21 +456,21 @@ public void run() { try { ItemStack machinehull = ItemList.MACHINE_HULLS[i].get(1L); GT_ModHandler.addCraftingRecipe( - BioLab2[(i - 3)], + BioLab2[i - 3], RecipeLoader.BITSD, new Object[] { "PFP", "WCW", "OGO", 'F', - GT_OreDictUnificator.get(OrePrefixes.frameGt, hulls2[(i - 3)], 1L), 'W', - GT_OreDictUnificator.get(OrePrefixes.wireGt01, wireMat2[(i - 3)], 1L), 'P', + GT_OreDictUnificator.get(OrePrefixes.frameGt, hulls2[i - 3], 1L), 'W', + GT_OreDictUnificator.get(OrePrefixes.wireGt01, wireMat2[i - 3], 1L), 'P', GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Polytetrafluoroethylene, 1L), 'O', GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Polystyrene, 1L), 'G', - "circuit" + circuits2[(i - 3)], 'C', machinehull }); + "circuit" + circuits2[i - 3], 'C', machinehull }); GT_ModHandler.addCraftingRecipe( - RadioHatch2[(i - 3)], + RadioHatch2[i - 3], RecipeLoader.BITSD, new Object[] { "DPD", "DCD", "DKD", 'D', GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Lead, 1L), 'C', machinehull, - 'K', GT_OreDictUnificator.get(OrePrefixes.cableGt08, cables2[(i - 3)], 1L), 'P', - Pistons2[(i - 3)] }); + 'K', GT_OreDictUnificator.get(OrePrefixes.cableGt08, cables2[i - 3], 1L), 'P', + Pistons2[i - 3] }); } catch (ArrayIndexOutOfBoundsException ignored) { } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/BW_Network.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/BW_Network.java index 14dcd3006..e5ae3c899 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/BW_Network.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/BW_Network.java @@ -34,6 +34,7 @@ import cpw.mods.fml.server.FMLServerHandler; import gregtech.api.enums.GT_Values; import gregtech.api.net.GT_Packet; +import gregtech.api.net.GT_Packet_New; import gregtech.api.net.IGT_NetworkHandler; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandler; @@ -44,73 +45,77 @@ /* * Original GT File slightly Modified */ -@SuppressWarnings("ALL") +@SuppressWarnings("deprecation") @ChannelHandler.Sharable -public class BW_Network extends MessageToMessageCodec implements IGT_NetworkHandler { +public class BW_Network extends MessageToMessageCodec implements IGT_NetworkHandler { private final EnumMap mChannel; - private final GT_Packet[] mSubChannels; + private final GT_Packet_New[] mSubChannels; public BW_Network() { this.mChannel = NetworkRegistry.INSTANCE.newChannel("BartWorks", this, new BW_Network.HandlerShared()); - this.mSubChannels = new GT_Packet[] { new RendererPacket(), new CircuitProgrammerPacket(), + this.mSubChannels = new GT_Packet_New[] { new RendererPacket(), new CircuitProgrammerPacket(), new MetaBlockPacket(), new OreDictCachePacket(), new ServerJoinedPackage(), new EICPacket() }; } - protected void encode(ChannelHandlerContext aContext, GT_Packet aPacket, List aOutput) throws Exception { + @Override + protected void encode(ChannelHandlerContext aContext, GT_Packet_New aPacket, List aOutput) + throws Exception { aOutput.add( new FMLProxyPacket( Unpooled.buffer().writeByte(aPacket.getPacketID()).writeBytes(aPacket.encode()).copy(), - (String) aContext.channel().attr(NetworkRegistry.FML_CHANNEL).get())); + aContext.channel().attr(NetworkRegistry.FML_CHANNEL).get())); } + @Override protected void decode(ChannelHandlerContext aContext, FMLProxyPacket aPacket, List aOutput) throws Exception { ByteArrayDataInput aData = ByteStreams.newDataInput(aPacket.payload().array()); aOutput.add(this.mSubChannels[aData.readByte()].decode(aData)); } + @Override public void sendToPlayer(@Nonnull GT_Packet aPacket, @Nonnull EntityPlayerMP aPlayer) { - ((FMLEmbeddedChannel) this.mChannel.get(Side.SERVER)).attr(FMLOutboundHandler.FML_MESSAGETARGET) + this.mChannel.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET) .set(FMLOutboundHandler.OutboundTarget.PLAYER); - ((FMLEmbeddedChannel) this.mChannel.get(Side.SERVER)).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS) - .set(aPlayer); - ((FMLEmbeddedChannel) this.mChannel.get(Side.SERVER)).writeAndFlush(aPacket); + this.mChannel.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(aPlayer); + this.mChannel.get(Side.SERVER).writeAndFlush(aPacket); } public void sendToAllPlayersinWorld(@Nonnull GT_Packet aPacket, World world) { for (String name : FMLServerHandler.instance().getServer().getAllUsernames()) { - ((FMLEmbeddedChannel) this.mChannel.get(Side.SERVER)).attr(FMLOutboundHandler.FML_MESSAGETARGET) + this.mChannel.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET) .set(FMLOutboundHandler.OutboundTarget.PLAYER); - ((FMLEmbeddedChannel) this.mChannel.get(Side.SERVER)).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS) + this.mChannel.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS) .set(world.getPlayerEntityByName(name)); - ((FMLEmbeddedChannel) this.mChannel.get(Side.SERVER)).writeAndFlush(aPacket); + this.mChannel.get(Side.SERVER).writeAndFlush(aPacket); } } + @Override public void sendToAllAround(@Nonnull GT_Packet aPacket, NetworkRegistry.TargetPoint aPosition) { - ((FMLEmbeddedChannel) this.mChannel.get(Side.SERVER)).attr(FMLOutboundHandler.FML_MESSAGETARGET) + this.mChannel.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET) .set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT); - ((FMLEmbeddedChannel) this.mChannel.get(Side.SERVER)).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS) - .set(aPosition); - ((FMLEmbeddedChannel) this.mChannel.get(Side.SERVER)).writeAndFlush(aPacket); + this.mChannel.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(aPosition); + this.mChannel.get(Side.SERVER).writeAndFlush(aPacket); } + @Override public void sendToServer(@Nonnull GT_Packet aPacket) { - ((FMLEmbeddedChannel) this.mChannel.get(Side.CLIENT)).attr(FMLOutboundHandler.FML_MESSAGETARGET) + this.mChannel.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET) .set(FMLOutboundHandler.OutboundTarget.TOSERVER); - ((FMLEmbeddedChannel) this.mChannel.get(Side.CLIENT)).writeAndFlush(aPacket); + this.mChannel.get(Side.CLIENT).writeAndFlush(aPacket); } + @Override public void sendPacketToAllPlayersInRange(World aWorld, @Nonnull GT_Packet aPacket, int aX, int aZ) { if (!aWorld.isRemote) { for (Object tObject : aWorld.playerEntities) { - if (!(tObject instanceof EntityPlayerMP)) { + if (!(tObject instanceof EntityPlayerMP tPlayer)) { break; } - EntityPlayerMP tPlayer = (EntityPlayerMP) tObject; Chunk tChunk = aWorld.getChunkFromBlockCoords(aX, aZ); if (tPlayer.getServerForPlayer().getPlayerManager() .isPlayerWatchingChunk(tPlayer, tChunk.xPosition, tChunk.zPosition)) { @@ -121,11 +126,12 @@ public void sendPacketToAllPlayersInRange(World aWorld, @Nonnull GT_Packet aPack } @Sharable - static final class HandlerShared extends SimpleChannelInboundHandler { + static final class HandlerShared extends SimpleChannelInboundHandler { HandlerShared() {} - protected void channelRead0(ChannelHandlerContext ctx, GT_Packet aPacket) throws Exception { + @Override + protected void channelRead0(ChannelHandlerContext ctx, GT_Packet_New aPacket) throws Exception { EntityPlayer aPlayer = GT_Values.GT.getThePlayer(); aPacket.process(aPlayer == null ? null : GT_Values.GT.getThePlayer().worldObj); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/CircuitProgrammerPacket.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/CircuitProgrammerPacket.java index a53cd1128..0ab6e42e9 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/CircuitProgrammerPacket.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/CircuitProgrammerPacket.java @@ -13,8 +13,6 @@ package com.github.bartimaeusnek.bartworks.common.net; -import java.nio.ByteBuffer; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -26,9 +24,10 @@ import com.github.bartimaeusnek.bartworks.common.items.Circuit_Programmer; import com.google.common.io.ByteArrayDataInput; -import gregtech.api.net.GT_Packet; +import gregtech.api.net.GT_Packet_New; +import io.netty.buffer.ByteBuf; -public class CircuitProgrammerPacket extends GT_Packet { +public class CircuitProgrammerPacket extends GT_Packet_New { private int dimID, playerID; private byte chipCfg; @@ -52,20 +51,17 @@ public byte getPacketID() { } @Override - public byte[] encode() { - return ByteBuffer.allocate(9).putInt(0, this.dimID).putInt(4, this.playerID) - .put(8, (this.hasChip ? this.chipCfg : -1)).array(); + public void encode(ByteBuf aOut) { + aOut.writeInt(this.dimID).writeInt(this.playerID).writeByte(this.hasChip ? this.chipCfg : -1); } @Override - public GT_Packet decode(ByteArrayDataInput byteArrayDataInput) { - byte[] ret = new byte[9]; - byteArrayDataInput.readFully(ret); + public GT_Packet_New decode(ByteArrayDataInput byteArrayDataInput) { return new CircuitProgrammerPacket( - ByteBuffer.wrap(ret).getInt(0), - ByteBuffer.wrap(ret).getInt(4), - ByteBuffer.wrap(ret).get(8) > -1, - ByteBuffer.wrap(ret).get(8)); + byteArrayDataInput.readInt(), + byteArrayDataInput.readInt(), + byteArrayDataInput.readByte() > -1, + byteArrayDataInput.readByte()); } @Override @@ -73,7 +69,7 @@ public void process(IBlockAccess iBlockAccess) { World w = DimensionManager.getWorld(this.dimID); if (w != null && w.getEntityByID(this.playerID) instanceof EntityPlayer) { ItemStack stack = ((EntityPlayer) w.getEntityByID(this.playerID)).getHeldItem(); - if ((stack != null) && (stack.stackSize > 0)) { + if (stack != null && stack.stackSize > 0) { Item item = stack.getItem(); if (item instanceof Circuit_Programmer) { NBTTagCompound nbt = stack.getTagCompound(); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/EICPacket.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/EICPacket.java index 95a79e934..621cc3fe4 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/EICPacket.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/EICPacket.java @@ -35,10 +35,10 @@ public byte getPacketID() { @Override public void encode(ByteBuf aOut) { - aOut.writeInt(coords.x); - aOut.writeInt(coords.y); - aOut.writeInt(coords.z); - aOut.writeBoolean(bool); + aOut.writeInt(this.coords.x); + aOut.writeInt(this.coords.y); + aOut.writeInt(this.coords.z); + aOut.writeBoolean(this.bool); } @Override @@ -49,11 +49,12 @@ public GT_Packet_New decode(ByteArrayDataInput aData) { @Override public void process(IBlockAccess aWorld) { if (SideReference.Side.Client) { - TileEntity te = aWorld.getTileEntity(coords.x, coords.y, coords.z); + TileEntity te = aWorld.getTileEntity(this.coords.x, this.coords.y, this.coords.z); if (!(te instanceof IGregTechTileEntity)) return; IMetaTileEntity mte = ((IGregTechTileEntity) te).getMetaTileEntity(); if (!(mte instanceof GT_TileEntity_ElectricImplosionCompressor)) return; - if (bool && !((IGregTechTileEntity) te).hasMufflerUpgrade()) ((IGregTechTileEntity) te).addMufflerUpgrade(); + if (this.bool && !((IGregTechTileEntity) te).hasMufflerUpgrade()) + ((IGregTechTileEntity) te).addMufflerUpgrade(); } } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/MetaBlockPacket.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/MetaBlockPacket.java index 38fdf5ee9..631021a29 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/MetaBlockPacket.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/MetaBlockPacket.java @@ -24,9 +24,10 @@ import com.github.bartimaeusnek.bartworks.util.MurmurHash3; import com.google.common.io.ByteArrayDataInput; -import gregtech.api.net.GT_Packet; +import gregtech.api.net.GT_Packet_New; +import io.netty.buffer.ByteBuf; -public class MetaBlockPacket extends GT_Packet { +public class MetaBlockPacket extends GT_Packet_New { int x; short y; @@ -51,27 +52,23 @@ public byte getPacketID() { } @Override - public byte[] encode() { + public void encode(ByteBuf aOut) { int hash = MurmurHash3.murmurhash3_x86_32( ByteBuffer.allocate(12).putInt(this.x).putInt(this.z).putShort(this.y).putShort(this.meta).array(), 0, 12, 31); - return ByteBuffer.allocate(16).putInt(this.x).putInt(this.z).putShort(this.y).putShort(this.meta).putInt(hash) - .array(); + aOut.writeInt(this.x).writeInt(this.z).writeShort(this.y).writeShort(this.meta).writeInt(hash); } @Override - public GT_Packet decode(ByteArrayDataInput byteArrayDataInput) { - byte[] tmp = new byte[16]; - byteArrayDataInput.readFully(tmp); - ByteBuffer buff = ByteBuffer.wrap(tmp); - this.x = buff.getInt(); - this.z = buff.getInt(); - this.y = buff.getShort(); - this.meta = buff.getShort(); + public GT_Packet_New decode(ByteArrayDataInput byteArrayDataInput) { + this.x = byteArrayDataInput.readInt(); + this.z = byteArrayDataInput.readInt(); + this.y = byteArrayDataInput.readShort(); + this.meta = byteArrayDataInput.readShort(); MetaBlockPacket todecode = new MetaBlockPacket(this.x, this.y, this.z, this.meta); - if (buff.getInt() != MurmurHash3.murmurhash3_x86_32( + if (byteArrayDataInput.readInt() != MurmurHash3.murmurhash3_x86_32( ByteBuffer.allocate(12).putInt(this.x).putInt(this.z).putShort(this.y).putShort(this.meta).array(), 0, 12, @@ -86,10 +83,10 @@ public GT_Packet decode(ByteArrayDataInput byteArrayDataInput) { public void process(IBlockAccess iBlockAccess) { if (iBlockAccess != null) { TileEntity tTileEntity = iBlockAccess.getTileEntity(this.x, this.y, this.z); - if ((tTileEntity instanceof BW_MetaGenerated_Block_TE)) { + if (tTileEntity instanceof BW_MetaGenerated_Block_TE) { ((BW_MetaGenerated_Block_TE) tTileEntity).mMetaData = this.meta; } - if (((iBlockAccess instanceof World)) && (((World) iBlockAccess).isRemote)) { + if (iBlockAccess instanceof World && ((World) iBlockAccess).isRemote) { ((World) iBlockAccess).markBlockForUpdate(this.x, this.y, this.z); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/OreDictCachePacket.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/OreDictCachePacket.java index 5e03bf53d..3ae70af18 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/OreDictCachePacket.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/OreDictCachePacket.java @@ -13,7 +13,6 @@ package com.github.bartimaeusnek.bartworks.common.net; -import java.nio.ByteBuffer; import java.util.HashSet; import net.minecraft.world.IBlockAccess; @@ -22,9 +21,10 @@ import com.github.bartimaeusnek.bartworks.util.Pair; import com.google.common.io.ByteArrayDataInput; -import gregtech.api.net.GT_Packet; +import gregtech.api.net.GT_Packet_New; +import io.netty.buffer.ByteBuf; -public class OreDictCachePacket extends GT_Packet { +public class OreDictCachePacket extends GT_Packet_New { private HashSet> hashSet = new HashSet<>(); @@ -43,15 +43,16 @@ public byte getPacketID() { } @Override - public byte[] encode() { + public void encode(ByteBuf aOut) { int size = this.hashSet.size(); - ByteBuffer buff = ByteBuffer.allocate(4 + size * 4 + size * 2).putInt(size); - for (Pair p : this.hashSet) buff.putInt(p.getKey()).putShort(p.getValue()); - return buff.array(); + aOut.writeInt(size); + for (Pair p : this.hashSet) { + aOut.writeInt(p.getKey()).writeShort(p.getValue()); + } } @Override - public GT_Packet decode(ByteArrayDataInput byteArrayDataInput) { + public GT_Packet_New decode(ByteArrayDataInput byteArrayDataInput) { int size = byteArrayDataInput.readInt(); for (int i = 0; i < size; i++) { this.hashSet.add(new Pair<>(byteArrayDataInput.readInt(), byteArrayDataInput.readShort())); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/RendererPacket.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/RendererPacket.java index c1dce7590..952a3eeeb 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/RendererPacket.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/RendererPacket.java @@ -13,8 +13,6 @@ package com.github.bartimaeusnek.bartworks.common.net; -import java.nio.ByteBuffer; - import net.minecraft.world.IBlockAccess; import com.github.bartimaeusnek.bartworks.API.SideReference; @@ -24,9 +22,10 @@ import com.github.bartimaeusnek.bartworks.util.Coords; import com.google.common.io.ByteArrayDataInput; -import gregtech.api.net.GT_Packet; +import gregtech.api.net.GT_Packet_New; +import io.netty.buffer.ByteBuf; -public class RendererPacket extends GT_Packet { +public class RendererPacket extends GT_Packet_New { private Coords coords; private int integer; @@ -49,36 +48,26 @@ public byte getPacketID() { } @Override - public byte[] encode() { + public void encode(ByteBuf aOut) { - byte r = (byte) (((this.integer >> 16) & 0xFF) + Byte.MIN_VALUE); - byte g = (byte) (((this.integer >> 8) & 0xFF) + Byte.MIN_VALUE); - byte b = (byte) (((this.integer) & 0xFF) + Byte.MIN_VALUE); + byte r = (byte) ((this.integer >> 16 & 0xFF) + Byte.MIN_VALUE); + byte g = (byte) ((this.integer >> 8 & 0xFF) + Byte.MIN_VALUE); + byte b = (byte) ((this.integer & 0xFF) + Byte.MIN_VALUE); byte checksum = (byte) (this.coords.x % 25 + this.coords.y % 25 + this.coords.z % 25 + this.coords.wID % 25 + this.integer % 25 + this.removal); - return ByteBuffer.allocate(19).putInt(0, this.coords.x).putShort(4, this.coords.y).putInt(6, this.coords.z) - .putInt(10, this.coords.wID).put(14, r).put(15, g).put(16, b).put(17, this.removal).put(18, checksum) - .array(); + aOut.writeInt(this.coords.x).writeShort(this.coords.y).writeInt(this.coords.z).writeInt(this.coords.wID) + .writeByte(r).writeByte(g).writeByte(b).writeByte(this.removal).writeByte(checksum); } @Override - public GT_Packet decode(ByteArrayDataInput dataInput) { - - byte[] buffer = new byte[19]; - dataInput.readFully(buffer); - - this.coords = new Coords( - ByteBuffer.wrap(buffer).getInt(0), - ByteBuffer.wrap(buffer).getShort(4), - ByteBuffer.wrap(buffer).getInt(6), - ByteBuffer.wrap(buffer).getInt(10)); - int[] rgb = { ByteBuffer.wrap(buffer).get(14) - Byte.MIN_VALUE, - ByteBuffer.wrap(buffer).get(15) - Byte.MIN_VALUE, ByteBuffer.wrap(buffer).get(16) - Byte.MIN_VALUE }; - this.integer = BW_ColorUtil.getColorFromRGBArray(rgb); - this.removal = ByteBuffer.wrap(buffer).get(17); + public GT_Packet_New decode(ByteArrayDataInput dataInput) { + this.coords = new Coords(dataInput.readInt(), dataInput.readShort(), dataInput.readInt(), dataInput.readInt()); + this.integer = BW_ColorUtil.getColorFromRGBArray( + new int[] { dataInput.readUnsignedByte(), dataInput.readUnsignedByte(), dataInput.readUnsignedByte() }); + this.removal = dataInput.readByte(); byte checksum = (byte) (this.coords.x % 25 + this.coords.y % 25 + this.coords.z % 25 @@ -86,7 +75,7 @@ public GT_Packet decode(ByteArrayDataInput dataInput) { + this.integer % 25 + this.removal); - if (checksum != ByteBuffer.wrap(buffer).get(18)) { + if (checksum != dataInput.readByte()) { MainMod.LOGGER.error("BW Packet was corrupted or modified!"); return null; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/ServerJoinedPackage.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/ServerJoinedPackage.java index 84c3ba893..3a6734d56 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/ServerJoinedPackage.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/ServerJoinedPackage.java @@ -19,9 +19,10 @@ import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; import com.google.common.io.ByteArrayDataInput; -import gregtech.api.net.GT_Packet; +import gregtech.api.net.GT_Packet_New; +import io.netty.buffer.ByteBuf; -public class ServerJoinedPackage extends GT_Packet { +public class ServerJoinedPackage extends GT_Packet_New { private byte config; @@ -41,12 +42,12 @@ public byte getPacketID() { } @Override - public byte[] encode() { - return new byte[] { this.config }; + public void encode(ByteBuf aOut) { + aOut.writeByte(this.config); } @Override - public GT_Packet decode(ByteArrayDataInput byteArrayDataInput) { + public GT_Packet_New decode(ByteArrayDataInput byteArrayDataInput) { this.config = byteArrayDataInput.readByte(); return this; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_RotorBlock.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_RotorBlock.java index a437dc828..5db8989d0 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_RotorBlock.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_RotorBlock.java @@ -29,6 +29,7 @@ public int getGrindPower() { return super.getKuOutput(); } + @Override public int getKuOutput() { return 0; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_ExperimentalFloodGate.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_ExperimentalFloodGate.java index a04d70f6a..9d6c03be7 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_ExperimentalFloodGate.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_ExperimentalFloodGate.java @@ -33,7 +33,7 @@ public class BW_TileEntity_ExperimentalFloodGate extends TileFluidHandler implements ITileAddsInformation { - private static final ForgeDirection[] allowed_directions = new ForgeDirection[] { DOWN, WEST, EAST, SOUTH, NORTH }; + private static final ForgeDirection[] allowed_directions = { DOWN, WEST, EAST, SOUTH, NORTH }; private PriorityQueue breadthFirstQueue = new PriorityQueue<>(Comparator.comparingInt(x -> x.y)); private boolean wasInited = false; @@ -47,26 +47,26 @@ public boolean canFill(ForgeDirection from, Fluid fluid) { } public void initEntity() { - if (wasInited) return; - breadthFirstQueue.add(new Coords(this.xCoord, this.yCoord, this.zCoord)); - wasInited = true; + if (this.wasInited) return; + this.breadthFirstQueue.add(new Coords(this.xCoord, this.yCoord, this.zCoord)); + this.wasInited = true; } @Override public void updateEntity() { - initEntity(); - Coords current = breadthFirstQueue.poll(); + this.initEntity(); + Coords current = this.breadthFirstQueue.poll(); if (current == null) return; - setFluidBlock(current); + this.setFluidBlock(current); for (ForgeDirection allowed_direction : allowed_directions) { - addBlockToQueue(current, allowed_direction); + this.addBlockToQueue(current, allowed_direction); } } @Override public void writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); - tag.setBoolean("init", wasInited); + tag.setBoolean("init", this.wasInited); int[] x = new int[this.breadthFirstQueue.size()]; int[] y = new int[this.breadthFirstQueue.size()]; @@ -97,15 +97,16 @@ public void readFromNBT(NBTTagCompound tag) { } private void setFluidBlock(Coords current) { - if (!checkForAir(current)) return; - if (this.tank.drain(1000, false) == null || this.tank.drain(1000, false).amount != 1000) return; + if (!this.checkForAir(current) || this.tank.drain(1000, false) == null + || this.tank.drain(1000, false).amount != 1000) + return; FluidStack stack = this.tank.drain(1000, true); - worldObj.setBlock(current.x, current.y, current.z, stack.getFluid().getBlock(), 0, 2); + this.worldObj.setBlock(current.x, current.y, current.z, stack.getFluid().getBlock(), 0, 2); } private void addBlockToQueue(Coords current, ForgeDirection allowed_direction) { Coords side = current.getCoordsFromSide(allowed_direction); - if (checkForAir(side)) breadthFirstQueue.add(side); + if (this.checkForAir(side)) this.breadthFirstQueue.add(side); } private boolean checkForAir(Coords coords) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java index c977453f6..98932b8d7 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java @@ -64,30 +64,30 @@ public class BW_TileEntity_HeatedWaterPump extends TileEntity implements ITileDr public ItemStack fakestack = new ItemStack(Blocks.water); @Override - public void writeToNBT(NBTTagCompound p_145841_1_) { + public void writeToNBT(NBTTagCompound compound) { NBTTagCompound subItemStack = new NBTTagCompound(); if (this.fuelstack != null) { this.fuelstack.writeToNBT(subItemStack); } - p_145841_1_.setTag("ItemStack", subItemStack); + compound.setTag("ItemStack", subItemStack); NBTTagCompound subFluidStack = new NBTTagCompound(); this.outputstack.writeToNBT(subFluidStack); - p_145841_1_.setTag("FluidStack", subFluidStack); - p_145841_1_.setInteger("fuel", this.fuel); - p_145841_1_.setInteger("maxfuel", this.maxfuel); - p_145841_1_.setByte("tick", this.tick); - super.writeToNBT(p_145841_1_); + compound.setTag("FluidStack", subFluidStack); + compound.setInteger("fuel", this.fuel); + compound.setInteger("maxfuel", this.maxfuel); + compound.setByte("tick", this.tick); + super.writeToNBT(compound); } @Override - public void readFromNBT(NBTTagCompound p_145839_1_) { - this.tick = p_145839_1_.getByte("tick"); - this.fuel = p_145839_1_.getInteger("fuel"); - this.maxfuel = p_145839_1_.getInteger("maxfuel"); - this.outputstack = FluidStack.loadFluidStackFromNBT(p_145839_1_.getCompoundTag("FluidStack")); - if (!p_145839_1_.getCompoundTag("ItemStack").equals(new NBTTagCompound())) - this.fuelstack = ItemStack.loadItemStackFromNBT(p_145839_1_.getCompoundTag("ItemStack")); - super.readFromNBT(p_145839_1_); + public void readFromNBT(NBTTagCompound compound) { + this.tick = compound.getByte("tick"); + this.fuel = compound.getInteger("fuel"); + this.maxfuel = compound.getInteger("maxfuel"); + this.outputstack = FluidStack.loadFluidStackFromNBT(compound.getCompoundTag("FluidStack")); + if (!compound.getCompoundTag("ItemStack").equals(new NBTTagCompound())) + this.fuelstack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("ItemStack")); + super.readFromNBT(compound); } private boolean checkPreUpdate() { @@ -111,7 +111,7 @@ private void handleWaterGeneration() { ++this.tick; --this.fuel; if (this.tick % 20 == 0) { - if (this.outputstack.amount <= (8000 - ConfigHandler.mbWaterperSec)) + if (this.outputstack.amount <= 8000 - ConfigHandler.mbWaterperSec) this.outputstack.amount += ConfigHandler.mbWaterperSec; this.tick = 0; } @@ -122,14 +122,14 @@ private void handleWaterGeneration() { public void updateEntity() { if (this.worldObj.isRemote) return; - pushWaterToAdjacentTiles(); - fakestack.setStackDisplayName(outputstack.amount + "L Water"); - if (checkPreUpdate()) return; + this.pushWaterToAdjacentTiles(); + this.fakestack.setStackDisplayName(this.outputstack.amount + "L Water"); + if (this.checkPreUpdate()) return; - fixUnderlflow(); - handleRefuel(); - handleWaterGeneration(); - causePollution(); + this.fixUnderlflow(); + this.handleRefuel(); + this.handleWaterGeneration(); + this.causePollution(); } private void pushWaterToAdjacentTiles() { @@ -141,20 +141,17 @@ private void pushWaterToAdjacentTiles() { this.yCoord + direction.offsetY, this.zCoord + direction.offsetZ)) .ifPresent(te -> { - if (te instanceof IFluidHandler) { - IFluidHandler tank = (IFluidHandler) te; + if (te instanceof IFluidHandler tank) { if (tank.canFill(direction.getOpposite(), this.outputstack.getFluid())) { - int drainage; - if ((drainage = tank.fill(direction.getOpposite(), this.outputstack, false)) - > 0) { + int drainage = tank.fill(direction.getOpposite(), this.outputstack, false); + if (drainage > 0) { tank.fill(direction.getOpposite(), this.outputstack, true); this.drain(drainage, true); } } - } else if (te instanceof IFluidTank) { - IFluidTank tank = (IFluidTank) te; - int drainage; - if ((drainage = tank.fill(this.outputstack, false)) > 0) { + } else if (te instanceof IFluidTank tank) { + int drainage = tank.fill(this.outputstack, false); + if (drainage > 0) { tank.fill(this.outputstack, true); this.drain(drainage, true); } @@ -192,9 +189,9 @@ public int getSizeInventory() { } @Override - public ItemStack getStackInSlot(int p_70301_1_) { - if (p_70301_1_ == 0) return this.fuelstack; - else return this.fakestack; + public ItemStack getStackInSlot(int slotIn) { + if (slotIn == 0) return this.fuelstack; + return this.fakestack; } @Override @@ -207,14 +204,14 @@ public ItemStack decrStackSize(int slot, int ammount) { } @Override - public ItemStack getStackInSlotOnClosing(int p_70304_1_) { + public ItemStack getStackInSlotOnClosing(int index) { return null; } @Override - public void setInventorySlotContents(int slot, ItemStack p_70299_2_) { - if (slot == BW_TileEntity_HeatedWaterPump.FUELSLOT) this.fuelstack = p_70299_2_; - else this.fakestack = p_70299_2_; + public void setInventorySlotContents(int slot, ItemStack stack) { + if (slot == BW_TileEntity_HeatedWaterPump.FUELSLOT) this.fuelstack = stack; + else this.fakestack = stack; } @Override @@ -233,7 +230,7 @@ public int getInventoryStackLimit() { } @Override - public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { + public boolean isUseableByPlayer(EntityPlayer player) { return true; } @@ -244,9 +241,8 @@ public void openInventory() {} public void closeInventory() {} @Override - public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { - return TileEntityFurnace.getItemBurnTime(p_94041_2_) > 0 - && p_94041_1_ == BW_TileEntity_HeatedWaterPump.FUELSLOT; + public boolean isItemValidForSlot(int index, ItemStack stack) { + return TileEntityFurnace.getItemBurnTime(stack) > 0 && index == BW_TileEntity_HeatedWaterPump.FUELSLOT; } @Override @@ -362,7 +358,7 @@ public ModularWindow createWindow(UIBuildContext buildContext) { new SlotWidget(invWrapper, 0).setFilter(stack -> TileEntityFurnace.getItemBurnTime(stack) > 0) .setPos(55, 52)) .widget(SlotWidget.phantom(invWrapper, 1).disableInteraction().setPos(85, 32)).widget( - new ProgressBar().setProgress(() -> (float) fuel / maxfuel) + new ProgressBar().setProgress(() -> (float) this.fuel / this.maxfuel) .setTexture(BW_UITextures.PROGRESSBAR_FUEL, 14).setDirection(ProgressBar.Direction.UP) .setPos(56, 36).setSize(14, 14)); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_InfinityTank.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_InfinityTank.java index 32f214a94..d91b79059 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_InfinityTank.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_InfinityTank.java @@ -85,8 +85,8 @@ public int getFluidAmount() { } @Override - public void writeToNBT(NBTTagCompound p_145841_1_) { - super.writeToNBT(p_145841_1_); + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); NBTTagList lInternalTank = new NBTTagList(); @@ -99,7 +99,7 @@ public void writeToNBT(NBTTagCompound p_145841_1_) { lInternalTank.appendTag(entry); } } - p_145841_1_.setTag("InternalTank", lInternalTank); + compound.setTag("InternalTank", lInternalTank); } @Override diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java index 2203b89aa..3433464b4 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java @@ -151,7 +151,7 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() { tt.addMachineType("Bacterial Vat").addInfo("Controller block for the Bacterial Vat") .addInfo("For maximum efficiency boost keep the Output Hatch always half filled!").addSeparator() .beginStructureBlock(5, 4, 5, false).addController("Front bottom center") - .addCasingInfo("Clean Stainless Steel Casings", 19) + .addCasingInfoMin("Clean Stainless Steel Casings", 19, false) .addOtherStructurePart("Glass", "Hollow two middle layers", 2) .addStructureInfo("The glass can be any glass, i.e. Tinkers Construct Clear Glass") .addStructureInfo("Some Recipes need more advanced Glass Types").addMaintenanceHatch("Any casing", 1) @@ -218,9 +218,9 @@ private int getExpectedMultiplier(@Nullable FluidStack recipeFluidOutput, boolea } private int calcMod(double x) { - double y = (((double) this.getOutputCapacity()) / 2D), z = ConfigHandler.bioVatMaxParallelBonus; + double y = this.getOutputCapacity() / 2D, z = ConfigHandler.bioVatMaxParallelBonus; - int ret = MathUtils.ceilInt(((-1D / y * Math.pow((x - y), 2D) + y) / y * z)); + int ret = MathUtils.ceilInt((-1D / y * Math.pow(x - y, 2D) + y) / y * z); return MathUtils.clamp(1, ret, ConfigHandler.bioVatMaxParallelBonus); } @@ -231,23 +231,23 @@ protected ProcessingLogic createProcessingLogic() { @NotNull @Override protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { - if (!BW_Util.areStacksEqualOrNull((ItemStack) recipe.mSpecialItems, getControllerSlot())) + if (!BW_Util.areStacksEqualOrNull( + (ItemStack) recipe.mSpecialItems, + GT_TileEntity_BioVat.this.getControllerSlot())) return CheckRecipeResultRegistry.NO_RECIPE; int[] conditions = GT_TileEntity_BioVat.specialValueUnpack(recipe.mSpecialValue); - mNeededSievert = conditions[3]; + GT_TileEntity_BioVat.this.mNeededSievert = conditions[3]; - if (mGlassTier < conditions[0]) { + if (GT_TileEntity_BioVat.this.mGlassTier < conditions[0]) { return CheckRecipeResultRegistry.insufficientMachineTier(conditions[0]); } if (conditions[2] == 0) { - if (mSievert < mNeededSievert) { - return ResultWrongSievert.insufficientSievert(mNeededSievert); - } - } else { - if (mSievert != conditions[3]) { - return ResultWrongSievert.wrongSievert(conditions[3]); + if (GT_TileEntity_BioVat.this.mSievert < GT_TileEntity_BioVat.this.mNeededSievert) { + return ResultWrongSievert.insufficientSievert(GT_TileEntity_BioVat.this.mNeededSievert); } + } else if (GT_TileEntity_BioVat.this.mSievert != conditions[3]) { + return ResultWrongSievert.wrongSievert(conditions[3]); } return CheckRecipeResultRegistry.SUCCESSFUL; @@ -261,14 +261,15 @@ public CheckRecipeResult process() { return result; } // We already made sure the recipe runs. Now the vat looks for as many "parallels" as it can do - mExpectedMultiplier = getExpectedMultiplier(lastRecipe.getFluidOutput(0), true); - mTimes = 1; - for (int i = 1; i < mExpectedMultiplier; i++) { - if (depleteInput(lastRecipe.mFluidInputs[0])) { - mTimes++; + GT_TileEntity_BioVat.this.mExpectedMultiplier = GT_TileEntity_BioVat.this + .getExpectedMultiplier(this.lastRecipe.getFluidOutput(0), true); + GT_TileEntity_BioVat.this.mTimes = 1; + for (int i = 1; i < GT_TileEntity_BioVat.this.mExpectedMultiplier; i++) { + if (GT_TileEntity_BioVat.this.depleteInput(this.lastRecipe.mFluidInputs[0])) { + GT_TileEntity_BioVat.this.mTimes++; } } - this.outputFluids[0].amount *= mTimes; + this.outputFluids[0].amount *= GT_TileEntity_BioVat.this.mTimes; return result; } }; @@ -277,7 +278,7 @@ public CheckRecipeResult process() { @Override protected void setupProcessingLogic(ProcessingLogic logic) { super.setupProcessingLogic(logic); - logic.setSpecialSlotItem(getControllerSlot()); + logic.setSpecialSlotItem(this.getControllerSlot()); } public FluidStack getStoredFluidOutputs() { @@ -289,16 +290,13 @@ public FluidStack getStoredFluidOutputs() { private boolean addRadiationInputToMachineList(IGregTechTileEntity aTileEntity, int CasingIndex) { if (aTileEntity == null) { return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null || !(aMetaTileEntity instanceof GT_MetaTileEntity_RadioHatch)) { + return false; } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return false; - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_RadioHatch) { - ((GT_MetaTileEntity_RadioHatch) aMetaTileEntity).updateTexture(CasingIndex); - return this.mRadHatches.add((GT_MetaTileEntity_RadioHatch) aMetaTileEntity); - } else { - return false; - } + ((GT_MetaTileEntity_RadioHatch) aMetaTileEntity).updateTexture(CasingIndex); + return this.mRadHatches.add((GT_MetaTileEntity_RadioHatch) aMetaTileEntity); } } @@ -308,7 +306,7 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack i this.mGlassTier = 0; this.mCasing = 0; - if (!checkPiece(STRUCTURE_PIECE_MAIN, 2, 3, 0)) return false; + if (!this.checkPiece(STRUCTURE_PIECE_MAIN, 2, 3, 0)) return false; return this.mCasing >= 19 && this.mRadHatches.size() <= 1 && this.mOutputHatches.size() == 1 @@ -341,8 +339,8 @@ private void sendAllRequiredRendererPackets() { } private void sendPackagesOrRenewRenderer(int x, int y, int z, BioCulture lCulture) { - int xDir = getXDir(); - int zDir = getZDir(); + int xDir = this.getXDir(); + int zDir = this.getZDir(); GT_TileEntity_BioVat.staticColorMap.remove( new Coords( @@ -392,10 +390,9 @@ private void check_Chunk() { if (!aWorld.isRemote) { for (Object tObject : aWorld.playerEntities) { - if (!(tObject instanceof EntityPlayerMP)) { + if (!(tObject instanceof EntityPlayerMP tPlayer)) { break; } - EntityPlayerMP tPlayer = (EntityPlayerMP) tObject; Chunk tChunk = aWorld.getChunkFromBlockCoords( this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getZCoord()); @@ -413,9 +410,9 @@ private void check_Chunk() { } private void placeFluid() { - isVisibleFluid = true; - int xDir = getXDir(); - int zDir = getZDir(); + this.isVisibleFluid = true; + int xDir = this.getXDir(); + int zDir = this.getZDir(); this.height = this.reCalculateHeight(); if (this.mFluid != null && this.height > 1 && this.reCalculateFluidAmmount() > 0) for (int x = -1; x < 2; x++) { for (int y = 0; y < this.height; y++) { @@ -437,7 +434,7 @@ private void placeFluid() { } private void removeFluid(int xDir, int zDir) { - isVisibleFluid = false; + this.isVisibleFluid = false; for (int x = -1; x < 2; x++) { for (int y = 1; y < 3; y++) { @@ -468,9 +465,9 @@ private int reCalculateFluidAmmount() { } private int reCalculateHeight() { - return (this.reCalculateFluidAmmount() > ((this.getCapacity() / 4) - 1) - ? (this.reCalculateFluidAmmount() >= this.getCapacity() / 2 ? 3 : 2) - : 1); + return this.reCalculateFluidAmmount() > this.getCapacity() / 4 - 1 + ? this.reCalculateFluidAmmount() >= this.getCapacity() / 2 ? 3 : 2 + : 1; } public void doAllVisualThings() { @@ -478,8 +475,8 @@ public void doAllVisualThings() { if (this.mMachine) { ItemStack aStack = this.mInventory[1]; BioCulture lCulture = null; - int xDir = getXDir(); - int zDir = getZDir(); + int xDir = this.getXDir(); + int zDir = this.getZDir(); if (this.getBaseMetaTileEntity().getTimer() % 200 == 0) { this.check_Chunk(); @@ -496,8 +493,8 @@ public void doAllVisualThings() { this.height = this.reCalculateHeight(); if (this.mFluid != null && this.height > 1 && this.reCalculateFluidAmmount() > 0) { - if ((!(BW_Util.areStacksEqualOrNull(aStack, this.mStack))) || (this.needsVisualUpdate - && this.getBaseMetaTileEntity().getTimer() % GT_TileEntity_BioVat.TIMERDIVIDER == 1)) { + if (!BW_Util.areStacksEqualOrNull(aStack, this.mStack) || this.needsVisualUpdate + && this.getBaseMetaTileEntity().getTimer() % GT_TileEntity_BioVat.TIMERDIVIDER == 1) { for (int x = -1; x < 2; x++) { for (int y = 1; y < this.height; y++) { for (int z = -1; z < 2; z++) { @@ -541,11 +538,9 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (this.getBaseMetaTileEntity().isActive() && this.mNeededSievert > this.mSievert) this.mOutputFluids = null; } - if (aBaseMetaTileEntity.isServerSide()) { - if (this.mMaxProgresstime <= 0) { - this.mTimes = 0; - this.mMaxProgresstime = 0; - } + if (aBaseMetaTileEntity.isServerSide() && this.mMaxProgresstime <= 0) { + this.mTimes = 0; + this.mMaxProgresstime = 0; } } @@ -567,13 +562,13 @@ else if ((this.mCulture == null || this.mCulture.getName().isEmpty()) @Override public void onRemoval() { - if (isVisibleFluid) { - int xDir = getXDir(); - int zDir = getZDir(); - removeFluid(xDir, zDir); - sendRenderPackets(xDir, zDir); + if (this.isVisibleFluid) { + int xDir = this.getXDir(); + int zDir = this.getZDir(); + this.removeFluid(xDir, zDir); + this.sendRenderPackets(xDir, zDir); } else if (this.getBaseMetaTileEntity().getWorld().getWorldTime() % 20 == 7) { - sendRenderPackets(); + this.sendRenderPackets(); } super.onRemoval(); @@ -588,9 +583,9 @@ private int getZDir() { } private void sendRenderPackets() { - int xDir = getXDir(); - int zDir = getZDir(); - sendRenderPackets(xDir, zDir); + int xDir = this.getXDir(); + int zDir = this.getZDir(); + this.sendRenderPackets(xDir, zDir); } private void sendRenderPackets(int xDir, int zDir) { @@ -656,7 +651,7 @@ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirec @Override public void construct(ItemStack itemStack, boolean b) { - buildPiece(STRUCTURE_PIECE_MAIN, itemStack, b, 2, 3, 0); + this.buildPiece(STRUCTURE_PIECE_MAIN, itemStack, b, 2, 3, 0); } @Override @@ -668,13 +663,15 @@ public String[] getInfoData() { // here we must check the machine is well-formed as otherwise getExpectedMultiplier might error out! infoData[infoData.length - 2] = StatCollector.translateToLocal("BW.infoData.BioVat.expectedProduction") + ": " + EnumChatFormatting.GREEN - + (mMachine ? (mMaxProgresstime <= 0 ? getExpectedMultiplier(null, false) : mExpectedMultiplier) * 100 + + (this.mMachine + ? (this.mMaxProgresstime <= 0 ? this.getExpectedMultiplier(null, false) + : this.mExpectedMultiplier) * 100 : -1) + EnumChatFormatting.RESET + " %"; infoData[infoData.length - 1] = StatCollector.translateToLocal("BW.infoData.BioVat.production") + ": " + EnumChatFormatting.GREEN - + (mMaxProgresstime <= 0 ? 0 : mTimes) * 100 + + (this.mMaxProgresstime <= 0 ? 0 : this.mTimes) * 100 + EnumChatFormatting.RESET + " %"; return infoData; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java index 28cc85941..e3543a533 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java @@ -117,6 +117,7 @@ public IStructureDefinition getStructureDefin return STRUCTURE_DEFINITION; } + @Override protected GT_Multiblock_Tooltip_Builder createTooltip() { GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Circuit Assembler").addInfo("Controller block for the Circuit Assembly Line") @@ -191,7 +192,8 @@ public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { @Override public void loadNBTData(NBTTagCompound aNBT) { this.type = aNBT.getCompoundTag("Type"); - imprintedItemName = GT_LanguageManager.getTranslateableItemStackName(ItemStack.loadItemStackFromNBT(this.type)); + this.imprintedItemName = GT_LanguageManager + .getTranslateableItemStackName(ItemStack.loadItemStackFromNBT(this.type)); super.loadNBTData(aNBT); } @@ -220,12 +222,12 @@ protected ProcessingLogic createProcessingLogic() { @NotNull @Override public CheckRecipeResult checkProcessing() { - if (this.type.equals(new NBTTagCompound()) && !this.imprintMachine(getControllerSlot())) + if (this.type.equals(new NBTTagCompound()) && !this.imprintMachine(this.getControllerSlot())) return SimpleCheckRecipeResult.ofFailure("no_imprint"); - if (imprintedItemName == null || imprintedStack == null) { - imprintedStack = new ItemStack(BW_Meta_Items.getNEWCIRCUITS(), 1, 0); - imprintedStack.setTagCompound(type); - imprintedItemName = GT_LanguageManager.getTranslateableItemStackName(imprintedStack); + if (this.imprintedItemName == null || this.imprintedStack == null) { + this.imprintedStack = new ItemStack(BW_Meta_Items.getNEWCIRCUITS(), 1, 0); + this.imprintedStack.setTagCompound(this.type); + this.imprintedItemName = GT_LanguageManager.getTranslateableItemStackName(this.imprintedStack); } return super.checkProcessing(); } @@ -233,7 +235,7 @@ public CheckRecipeResult checkProcessing() { @Override protected void setupProcessingLogic(ProcessingLogic logic) { super.setupProcessingLogic(logic); - logic.setSpecialSlotItem(imprintedStack); + logic.setSpecialSlotItem(this.imprintedStack); } @Override @@ -244,8 +246,8 @@ protected SoundResource getProcessStartSound() { @Override public ArrayList getStoredInputs() { ArrayList rList = new ArrayList<>(); - for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses) { - tHatch.mRecipeMap = getRecipeMap(); + for (GT_MetaTileEntity_Hatch_InputBus tHatch : this.mInputBusses) { + tHatch.mRecipeMap = this.getRecipeMap(); if (isValidMetaTileEntity(tHatch)) { for (int i = 0; i < tHatch.getBaseMetaTileEntity().getSizeInventory(); i++) { if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null) { @@ -262,19 +264,18 @@ public ArrayList getStoredInputs() { public boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { if (aTileEntity == null) { return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = this.getRecipeMap(); + return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = this.getRecipeMap(); + return this.mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = this.getRecipeMap(); - return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = this.getRecipeMap(); - return this.mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); - } else { - return false; - } + return false; } } @@ -282,17 +283,14 @@ public boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseC public boolean addInputHatchToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { if (aTileEntity == null) { return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null || !(aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input)) { + return false; } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return false; - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = this.getRecipeMap(); - return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); - } else { - return false; - } + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = this.getRecipeMap(); + return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); } } @@ -325,15 +323,15 @@ public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { @Override public String[] getInfoData() { - if (infoDataBuffer != null) return infoDataBuffer; + if (this.infoDataBuffer != null) return this.infoDataBuffer; String[] oldInfo = super.getInfoData(); - infoDataBuffer = new String[oldInfo.length + 1]; - System.arraycopy(oldInfo, 0, infoDataBuffer, 0, oldInfo.length); - infoDataBuffer[oldInfo.length] = StatCollector.translateToLocal("tooltip.cal.imprintedWith") + " " + this.infoDataBuffer = new String[oldInfo.length + 1]; + System.arraycopy(oldInfo, 0, this.infoDataBuffer, 0, oldInfo.length); + this.infoDataBuffer[oldInfo.length] = StatCollector.translateToLocal("tooltip.cal.imprintedWith") + " " + EnumChatFormatting.YELLOW - + getTypeForDisplay(); - return infoDataBuffer; + + this.getTypeForDisplay(); + return this.infoDataBuffer; } @Override @@ -351,12 +349,12 @@ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirec return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX) }; } + @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { if (!this.checkPiece(STRUCTURE_PIECE_FIRST, 0, 0, 0)) { return false; - } else { - return this.checkMachine(true) || this.checkMachine(false); } + return this.checkMachine(true) || this.checkMachine(false); } private boolean checkMachine(boolean leftToRight) { @@ -384,14 +382,15 @@ public void construct(ItemStack stackSize, boolean hintsOnly) { @Override public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; + if (this.mMachine) return -1; int built; - built = survivialBuildPiece(STRUCTURE_PIECE_FIRST, stackSize, 0, 0, 0, elementBudget, env, false, true); + built = this.survivialBuildPiece(STRUCTURE_PIECE_FIRST, stackSize, 0, 0, 0, elementBudget, env, false, true); if (built >= 0) return built; int tLength = Math.min(stackSize.stackSize + 1, 7); for (int i = 1; i < tLength; ++i) { - built = survivialBuildPiece(STRUCTURE_PIECE_NEXT, stackSize, -i, 0, 0, elementBudget, env, false, true); + built = this + .survivialBuildPiece(STRUCTURE_PIECE_NEXT, stackSize, -i, 0, 0, elementBudget, env, false, true); if (built >= 0) return built; } return -1; @@ -413,7 +412,8 @@ public void addAdditionalTooltipInformation(ItemStack stack, List toolti @Override public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { super.addUIWidgets(builder, buildContext); - builder.widget(new FakeSyncWidget.StringSyncer(() -> imprintedItemName, val -> imprintedItemName = val)); + builder.widget( + new FakeSyncWidget.StringSyncer(() -> this.imprintedItemName, val -> this.imprintedItemName = val)); } @Override @@ -428,7 +428,7 @@ public boolean supportsBatchMode() { @Override public boolean isRecipeLockingEnabled() { - return imprintedItemName != null && !imprintedItemName.equals(""); + return this.imprintedItemName != null && !"".equals(this.imprintedItemName); } @Override @@ -447,7 +447,7 @@ public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDat public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y, int z) { super.getWailaNBTData(player, tile, tag, world, x, y, z); - String imprintedWith = getTypeForDisplay(); + String imprintedWith = this.getTypeForDisplay(); if (!imprintedWith.isEmpty()) tag.setString("ImprintedWith", imprintedWith); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_DEHP.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_DEHP.java index 532a3af1f..c125d4150 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_DEHP.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_DEHP.java @@ -94,7 +94,7 @@ public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { @Override protected GT_Multiblock_Tooltip_Builder createTooltip() { GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - String casings = getCasingBlockItem().get(0).getDisplayName(); + String casings = this.getCasingBlockItem().get(0).getDisplayName(); tt.addMachineType("Geothermal Heat Pump").addInfo("Consumes " + GT_Values.V[this.mTier + 2] + "EU/t") .addInfo("Has 4 Modes, use the Screwdriver to change them:"); if (ConfigHandler.DEHPDirectSteam) { @@ -110,14 +110,16 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() { } else { tt.addInfo("0 Idle, 1 & 2 Coolant Heating Mode (no Difference between them), 3 Retract") .addInfo("Explodes when it runs out of Coolant").addInfo( - "Heats up " + (long) (this.mTier * 24 * ((double) GT_TileEntity_DEHP.nulearHeatMod)) * 20 + "Heats up " + (long) (this.mTier * 24 * (double) GT_TileEntity_DEHP.nulearHeatMod) * 20 + "L/s Coolant(minus 10% per Maintenance Problem)"); } tt.addSeparator().beginStructureBlock(3, 7, 3, false).addController("Front bottom") .addOtherStructurePart(casings, "form the 3x1x3 Base") .addOtherStructurePart(casings, "1x3x1 pillar above the center of the base (2 minimum total)") - .addOtherStructurePart(getFrameMaterial().mName + " Frame Boxes", "Each pillar's side and 1x3x1 on top") - .addEnergyHatch(VN[getMinTier()] + "+, Any base casing").addMaintenanceHatch("Any base casing") + .addOtherStructurePart( + this.getFrameMaterial().mName + " Frame Boxes", + "Each pillar's side and 1x3x1 on top") + .addEnergyHatch(VN[this.getMinTier()] + "+, Any base casing").addMaintenanceHatch("Any base casing") .addInputBus("Mining Pipes, optional, any base casing").addInputHatch("Any base casing") .addOutputHatch("Any base casing").toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS); return tt; @@ -191,6 +193,7 @@ public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, f super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); } + @Override protected boolean workingDownward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead) { if (this.mMode == 3) { @@ -202,53 +205,51 @@ protected boolean workingDownward(ItemStack aStack, int xDrill, int yDrill, int return true; } - if (tryLowerPipeState(false) != 0) { - if (this.waitForPipes()) { - return false; - } else { - if (this.mMode == 0) this.mMode = 1; - if (ConfigHandler.DEHPDirectSteam) { - if (this.mMode == 1) { - long steamProduced = (this.mTier * 600 * 2L * this.mEfficiency / 10000L); - long waterConsume = ((steamProduced + 160) / 160); - - if (this.getWaterFromHatches(false) - waterConsume > 0) { - this.consumeFluid(FluidRegistry.WATER, waterConsume); - this.addOutput(GT_ModHandler.getSteam(steamProduced)); - } else { - this.explodeMultiblock(); - return false; - } - } else if (this.mMode == 2) { - long steamProduced = (this.mTier * 300 * 2L * this.mEfficiency / 10000L); - long waterConsume = ((steamProduced + 160) / 160); - - if (this.getWaterFromHatches(true) - waterConsume > 0) { - this.consumeFluid(GT_ModHandler.getDistilledWater(1).getFluid(), waterConsume); - this.addOutput(FluidRegistry.getFluidStack("ic2superheatedsteam", (int) steamProduced)); - } else { - this.explodeMultiblock(); - return false; - } - } + if (this.tryLowerPipeState(false) == 0) { + return true; + } + if (this.waitForPipes()) { + return false; + } + if (this.mMode == 0) { + this.mMode = 1; + } + if (ConfigHandler.DEHPDirectSteam) { + if (this.mMode == 1) { + long steamProduced = this.mTier * 600 * 2L * this.mEfficiency / 10000L; + long waterConsume = (steamProduced + 160) / 160; + + if (this.getWaterFromHatches(false) - waterConsume > 0) { + this.consumeFluid(FluidRegistry.WATER, waterConsume); + this.addOutput(GT_ModHandler.getSteam(steamProduced)); } else { - if (this.mMode == 1 || this.mMode == 2) { - long coolantConverted = (long) (this.mTier * 24 - * ((double) GT_TileEntity_DEHP.nulearHeatMod) - * this.mEfficiency - / 10000L); - if (this.getFluidFromHatches(FluidRegistry.getFluid("ic2coolant")) - coolantConverted > 0) { - this.consumeFluid(FluidRegistry.getFluid("ic2coolant"), coolantConverted); - this.addOutput(FluidRegistry.getFluidStack("ic2hotcoolant", (int) coolantConverted)); - } else { - this.explodeMultiblock(); - return false; - } - } + this.explodeMultiblock(); + return false; + } + } else if (this.mMode == 2) { + long steamProduced = this.mTier * 300 * 2L * this.mEfficiency / 10000L; + long waterConsume = (steamProduced + 160) / 160; + + if (this.getWaterFromHatches(true) - waterConsume > 0) { + this.consumeFluid(GT_ModHandler.getDistilledWater(1).getFluid(), waterConsume); + this.addOutput(FluidRegistry.getFluidStack("ic2superheatedsteam", (int) steamProduced)); + } else { + this.explodeMultiblock(); + return false; } } - } else { - return true; + } else if (this.mMode == 1 || this.mMode == 2) { + long coolantConverted = (long) (this.mTier * 24 + * (double) GT_TileEntity_DEHP.nulearHeatMod + * this.mEfficiency + / 10000L); + if (this.getFluidFromHatches(FluidRegistry.getFluid("ic2coolant")) - coolantConverted > 0) { + this.consumeFluid(FluidRegistry.getFluid("ic2coolant"), coolantConverted); + this.addOutput(FluidRegistry.getFluidStack("ic2hotcoolant", (int) coolantConverted)); + } else { + this.explodeMultiblock(); + return false; + } } return true; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java index cd76fc747..51683d237 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java @@ -81,7 +81,6 @@ public class GT_TileEntity_ElectricImplosionCompressor private final ArrayList chunkCoordinates = new ArrayList<>(5); private int mBlockTier = 0; private int mCasing; - private int mMaxHatchTier = 0; public GT_TileEntity_ElectricImplosionCompressor(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -141,13 +140,13 @@ public boolean check(GT_TileEntity_ElectricImplosionCompressor te, World world, } private Pair getTier(ItemStack trigger) { - return tiers.get(Math.min(Math.max(trigger.stackSize, 1), tiers.size()) - 1); + return this.tiers.get(Math.min(Math.max(trigger.stackSize, 1), this.tiers.size()) - 1); } @Override public boolean spawnHint(GT_TileEntity_ElectricImplosionCompressor te, World world, int x, int y, int z, ItemStack itemStack) { - Pair tier = getTier(itemStack); + Pair tier = this.getTier(itemStack); if (te.piston) StructureLibAPI.hintParticle(world, x, y, z, tier.getKey(), tier.getValue()); return true; } @@ -155,7 +154,7 @@ public boolean spawnHint(GT_TileEntity_ElectricImplosionCompressor te, World wor @Override public boolean placeBlock(GT_TileEntity_ElectricImplosionCompressor te, World world, int x, int y, int z, ItemStack itemStack) { - Pair tier = getTier(itemStack); + Pair tier = this.getTier(itemStack); if (te.piston) world.setBlock(x, y, z, tier.getKey(), tier.getValue(), 3); else world.setBlockToAir(x, y, z); return true; @@ -175,14 +174,16 @@ public PlaceResult survivalPlaceBlock(GT_TileEntity_ElectricImplosionCompressor }).build(); public static List> getAllBlockTiers() { - return new ArrayList>() { + return new ArrayList<>() { + + private static final long serialVersionUID = 8171991663102417651L; { - add(Pair.of(GregTech_API.sBlockMetal5, 2)); - add(Pair.of(LudicrousBlocks.resource_block, 1)); - add(Pair.of(GregTech_API.sBlockMetal9, 4)); - add(Pair.of(GregTech_API.sBlockMetal9, 3)); - add(Pair.of(GregTech_API.sBlockMetal9, 8)); + this.add(Pair.of(GregTech_API.sBlockMetal5, 2)); + this.add(Pair.of(LudicrousBlocks.resource_block, 1)); + this.add(Pair.of(GregTech_API.sBlockMetal9, 4)); + this.add(Pair.of(GregTech_API.sBlockMetal9, 3)); + this.add(Pair.of(GregTech_API.sBlockMetal9, 8)); } }; @@ -198,28 +199,27 @@ private static int getTierOfBlock(Block block, int meta) { } if (block == GregTech_API.sBlockMetal5 && meta == 2) { return 1; // Neutronium - } else if (block == LudicrousBlocks.resource_block && meta == 1) { + } + if (block == LudicrousBlocks.resource_block && meta == 1) { return 2; // Infinity - } else if (block == GregTech_API.sBlockMetal9) { - switch (meta) { - case 4: // Transcendent Metal - return 3; - case 3: // SpaceTime - return 4; - case 8: // Universium - return 5; - } } - + if (block == GregTech_API.sBlockMetal9) { + return switch (meta) { + case 4 -> 3; // Transcendent Metal + case 3 -> 4; // SpaceTime + case 8 -> 5; // Universium + default -> -1; + }; + } return -1; } private void setBlockTier(int tier) { - mBlockTier = tier; + this.mBlockTier = tier; } private int getBlockTier() { - return mBlockTier; + return this.mBlockTier; } @Override @@ -242,7 +242,7 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() { .addInfo("Valid blocks: Neutronium, Infinity, Transcendent Metal, Spacetime, Universium") .addInfo("Minimum allowed energy hatch tier is one below recipe tier") .addInfo("Supports " + TT + " energy hatches").addSeparator().beginStructureBlock(3, 9, 3, false) - .addController("Front 3rd layer center").addCasingInfo("Solid Steel Machine Casing", 8) + .addController("Front 3rd layer center").addCasingInfoMin("Solid Steel Machine Casing", 8, false) .addStructureInfo("Casings can be replaced with Explosion Warning Signs") .addOtherStructurePart("Transformer-Winding Blocks", "Outer layer 2,3,7,8") .addOtherStructurePart("Nickel-Zinc-Ferrite Blocks", "Inner layer 2,3,7,8") @@ -266,32 +266,33 @@ protected ProcessingLogic createProcessingLogic() { @Override protected GT_OverclockCalculator createOverclockCalculator(@NotNull GT_Recipe recipe) { // For overclocking we'll allow all power to be used - return super.createOverclockCalculator(recipe).setEUt(getMaxInputEu()).setAmperage(1); + return super.createOverclockCalculator(recipe) + .setEUt(GT_TileEntity_ElectricImplosionCompressor.this.getMaxInputEu()).setAmperage(1); } - }.setMaxParallelSupplier(() -> (int) Math.pow(4, Math.max(mBlockTier - 1, 0))); + }.setMaxParallelSupplier(() -> (int) Math.pow(4, Math.max(this.mBlockTier - 1, 0))); } @Override protected void setProcessingLogicPower(ProcessingLogic logic) { - long amperage = getMaxInputAmps(); - long voltage = getAverageInputVoltage(); + long amperage = this.getMaxInputAmps(); + long voltage = this.getAverageInputVoltage(); // We allow one OC, if there is enough amperage, no matter which type of hatch is used logic.setAvailableVoltage(amperage >= 4 ? voltage * 4 : voltage); logic.setAvailableAmperage(amperage >= 4 ? amperage / 4 : amperage); } private void updateChunkCoordinates() { - chunkCoordinates.clear(); + this.chunkCoordinates.clear(); for (int x = -1; x <= 1; x++) for (int z = -1; z <= 1; z++) { - if (!(Math.abs(x) == 1 && Math.abs(z) == 1)) { - int[] abc = new int[] { x, -2, z + 1 }; - int[] xyz = new int[] { 0, 0, 0 }; + if (Math.abs(x) != 1 || Math.abs(z) != 1) { + int[] abc = { x, -2, z + 1 }; + int[] xyz = { 0, 0, 0 }; this.getExtendedFacing().getWorldOffset(abc, xyz); xyz[0] += this.getBaseMetaTileEntity().getXCoord(); xyz[1] += this.getBaseMetaTileEntity().getYCoord(); xyz[2] += this.getBaseMetaTileEntity().getZCoord(); - chunkCoordinates.add(new ChunkCoordinates(xyz[0], xyz[1], xyz[2])); + this.chunkCoordinates.add(new ChunkCoordinates(xyz[0], xyz[1], xyz[2])); } } } @@ -299,7 +300,7 @@ private void updateChunkCoordinates() { @Override public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { super.onFirstTick(aBaseMetaTileEntity); - updateChunkCoordinates(); + this.updateChunkCoordinates(); } @Override @@ -307,7 +308,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); if (pistonEnabled && aBaseMetaTileEntity.isActive() && aTick % 20 == 0) { - if (aBaseMetaTileEntity.isClientSide()) animatePiston(aBaseMetaTileEntity); + if (aBaseMetaTileEntity.isClientSide()) this.animatePiston(aBaseMetaTileEntity); else if (aBaseMetaTileEntity.hasMufflerUpgrade()) MainMod.BW_Network_instance.sendPacketToAllPlayersInRange( aBaseMetaTileEntity.getWorld(), new EICPacket( @@ -325,7 +326,7 @@ else if (aBaseMetaTileEntity.hasMufflerUpgrade()) MainMod.BW_Network_instance.se public void setExtendedFacing(ExtendedFacing newExtendedFacing) { super.setExtendedFacing(newExtendedFacing); // Will call stopMachine - updateChunkCoordinates(); + this.updateChunkCoordinates(); } @Override @@ -333,6 +334,7 @@ public boolean isCorrectMachinePart(ItemStack itemStack) { return true; } + @Override public void stopMachine() { this.resetPiston(); super.stopMachine(); @@ -344,8 +346,8 @@ private void resetPiston() { if (!aBaseMetaTileEntity.isServerSide()) return; if (!this.piston) { List> tiers = getAllBlockTiers(); - Pair tieredBlock = tiers.get(Math.min(mBlockTier, tiers.size()) - 1); - chunkCoordinates.forEach(c -> { + Pair tieredBlock = tiers.get(Math.min(this.mBlockTier, tiers.size()) - 1); + this.chunkCoordinates.forEach(c -> { // Don't replace real blocks in case user has placed something (e.g. tier upgrade) if (aBaseMetaTileEntity.getWorld().isAirBlock(c.posX, c.posY, c.posZ)) { aBaseMetaTileEntity.getWorld() @@ -361,7 +363,7 @@ private void activatePiston() { IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); if (!aBaseMetaTileEntity.isServerSide()) return; if (this.piston) { - chunkCoordinates.forEach(c -> aBaseMetaTileEntity.getWorld().setBlockToAir(c.posX, c.posY, c.posZ)); + this.chunkCoordinates.forEach(c -> aBaseMetaTileEntity.getWorld().setBlockToAir(c.posX, c.posY, c.posZ)); this.piston = !this.piston; } } @@ -369,19 +371,19 @@ private void activatePiston() { private void animatePiston(IGregTechTileEntity aBaseMetaTileEntity) { if (!aBaseMetaTileEntity.getWorld().isRemote) return; - if (!getBaseMetaTileEntity().hasMufflerUpgrade()) GT_Utility.doSoundAtClient( + if (!this.getBaseMetaTileEntity().hasMufflerUpgrade()) GT_Utility.doSoundAtClient( sound, 10, 1f, 1f, - chunkCoordinates.get(0).posX, - chunkCoordinates.get(0).posY, - chunkCoordinates.get(0).posZ); - spawnVisualPistonBlocks( + this.chunkCoordinates.get(0).posX, + this.chunkCoordinates.get(0).posY, + this.chunkCoordinates.get(0).posZ); + this.spawnVisualPistonBlocks( aBaseMetaTileEntity.getWorld(), - chunkCoordinates.get(2).posX, - chunkCoordinates.get(2).posY, - chunkCoordinates.get(2).posZ, + this.chunkCoordinates.get(2).posX, + this.chunkCoordinates.get(2).posY, + this.chunkCoordinates.get(2).posZ, 10); } @@ -406,23 +408,22 @@ public void loadNBTData(NBTTagCompound aNBT) { @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { this.mCasing = 0; - this.mMaxHatchTier = 0; - setBlockTier(0); - boolean isOK = checkPiece(STRUCTURE_PIECE_MAIN, 1, 6, 0); + int mMaxHatchTier = 0; + this.setBlockTier(0); + boolean isOK = this.checkPiece(STRUCTURE_PIECE_MAIN, 1, 6, 0); - List energyHatches = getExoticAndNormalEnergyHatchList(); + List energyHatches = this.getExoticAndNormalEnergyHatchList(); for (GT_MetaTileEntity_Hatch hatch : energyHatches) { mMaxHatchTier = Math.max(mMaxHatchTier, hatch.mTier); } isOK = isOK && this.mMaintenanceHatches.size() == 1 && energyHatches.size() >= 1; if (isOK) { - activatePiston(); + this.activatePiston(); return true; - } else { - resetPiston(); - return false; } + this.resetPiston(); + return false; } @Override @@ -468,13 +469,13 @@ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirec @Override public void construct(ItemStack itemStack, boolean b) { - buildPiece(STRUCTURE_PIECE_MAIN, itemStack, b, 1, 6, 0); + this.buildPiece(STRUCTURE_PIECE_MAIN, itemStack, b, 1, 6, 0); } @Override public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 1, 6, 0, elementBudget, env, false, true); + if (this.mMachine) return -1; + return this.survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 1, 6, 0, elementBudget, env, false, true); } @Override diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_HTGR.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_HTGR.java index bc825fbdb..8e6bcc85d 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_HTGR.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_HTGR.java @@ -181,7 +181,7 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() { "Reactor will take 4 000L/s of coolant multiplied by efficiency and by fuel coolant value (check tooltips)") .addInfo("Uses " + GT_Utility.formatNumbers(powerUsage) + " EU/t").addInfo("One Operation takes 1 hour") .addSeparator().beginStructureBlock(11, 12, 11, true).addController("Front bottom center") - .addCasingInfo("Europium Reinforced Radiation Proof Casings", 500) + .addCasingInfoMin("Europium Reinforced Radiation Proof Casings", 500, false) .addStructureInfo("Corners and the 2 touching blocks are air (cylindric)") .addInputBus("Any top layer casing", 2).addInputHatch("Any top layer casing", 2) .addOutputBus("Any bottom layer casing", 1).addOutputHatch("Any bottom layer casing", 1) @@ -197,19 +197,19 @@ protected IAlignmentLimits getInitialAlignmentLimits() { @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece("main", stackSize, hintsOnly, 5, 11, 0); + this.buildPiece("main", stackSize, hintsOnly, 5, 11, 0); } @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { this.mCasing = 0; - return (checkPiece("main", 5, 11, 0) && this.mCasing >= 500 + return this.checkPiece("main", 5, 11, 0) && this.mCasing >= 500 && this.mMaintenanceHatches.size() == 1 && this.mInputHatches.size() > 0 && this.mOutputHatches.size() > 0 && this.mInputBusses.size() > 0 && this.mOutputBusses.size() > 0 - && this.mEnergyHatches.size() > 0); + && this.mEnergyHatches.size() > 0; } @Override @@ -248,13 +248,12 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { } } if (this.fuelsupply < maxcapacity) { - startRecipeProcessing(); + this.startRecipeProcessing(); for (ItemStack itemStack : this.getStoredInputs()) { int type = -1; - if (itemStack == null) continue; - if (itemStack.getItem() != HTGRMaterials.aHTGR_Materials) continue; + if (itemStack == null || itemStack.getItem() != HTGRMaterials.aHTGR_Materials) continue; int damage = HTGRMaterials.aHTGR_Materials.getDamage(itemStack); - if (!((damage + 1) % HTGRMaterials.MATERIALS_PER_FUEL == HTGRMaterials.USABLE_FUEL_INDEX + 1)) + if ((damage + 1) % HTGRMaterials.MATERIALS_PER_FUEL != HTGRMaterials.USABLE_FUEL_INDEX + 1) continue; // is fuel type = damage / HTGRMaterials.MATERIALS_PER_FUEL; if (this.fueltype == -1) this.fueltype = type; @@ -264,7 +263,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { itemStack.stackSize -= toget; updateneeded = true; } - endRecipeProcessing(); + this.endRecipeProcessing(); } if (updateneeded) this.updateSlots(); } @@ -281,36 +280,36 @@ public boolean checkRecipe(ItemStack controllerStack) { } return false; } - if (!(this.HeliumSupply >= GT_TileEntity_HTGR.HELIUM_NEEDED && this.fuelsupply >= mincapacity)) return false; + if (this.HeliumSupply < GT_TileEntity_HTGR.HELIUM_NEEDED || this.fuelsupply < mincapacity) return false; double eff = Math.min(Math.pow((double) this.fuelsupply / (double) mincapacity, 2D), 100D) / 100D - - ((double) (getIdealStatus() - getRepairStatus()) / 10D); + - (this.getIdealStatus() - this.getRepairStatus()) / 10D; if (eff <= 0) return false; - int toReduce = MathUtils.floorInt((double) this.fuelsupply * 0.025D * eff); + int toReduce = MathUtils.floorInt(this.fuelsupply * 0.025D * eff); final int originalToReduce = toReduce; int burnedballs = toReduce / 64; if (burnedballs > 0) toReduce -= burnedballs * 64; - int meta = (this.fueltype * HTGRMaterials.MATERIALS_PER_FUEL) + HTGRMaterials.BURNED_OUT_FUEL_INDEX; + int meta = this.fueltype * HTGRMaterials.MATERIALS_PER_FUEL + HTGRMaterials.BURNED_OUT_FUEL_INDEX; - ItemStack[] toOutput = new ItemStack[] { new ItemStack(HTGRMaterials.aHTGR_Materials, burnedballs, meta), + ItemStack[] toOutput = { new ItemStack(HTGRMaterials.aHTGR_Materials, burnedballs, meta), new ItemStack(HTGRMaterials.aHTGR_Materials, toReduce, meta + 1) }; - if (!canOutputAll(toOutput)) return false; + if (!this.canOutputAll(toOutput)) return false; this.fuelsupply -= originalToReduce; this.mOutputItems = toOutput; // this.updateSlots(); // not needed ? - this.coolanttaking = (int) (4000D * (((this.fueltype * 0.5D) + 1)) * eff); + this.coolanttaking = (int) (4000D * (this.fueltype * 0.5D + 1) * eff); this.mEfficiency = (int) (eff * 10000D); this.mEfficiencyIncrease = 0; this.mEUt = -powerUsage; - this.mMaxProgresstime = (int) (72000 * (1d - (eff / 2d))); + this.mMaxProgresstime = (int) (72000 * (1d - eff / 2d)); return true; } @@ -318,11 +317,11 @@ public boolean checkRecipe(ItemStack controllerStack) { @Override public boolean onRunningTick(ItemStack aStack) { - runningtick++; + this.runningtick++; if (this.empty) { - if (emptyticksnodiff > 20 && emptyticksnodiff % 20 != 0) { - emptyticksnodiff++; + if (this.emptyticksnodiff > 20 && this.emptyticksnodiff % 20 != 0) { + this.emptyticksnodiff++; return true; } if (this.HeliumSupply > 0) { @@ -333,7 +332,7 @@ public boolean onRunningTick(ItemStack aStack) { ItemStack iStack = new ItemStack( HTGRMaterials.aHTGR_Materials, this.fuelsupply, - (HTGRMaterials.MATERIALS_PER_FUEL * this.fueltype) + HTGRMaterials.USABLE_FUEL_INDEX); + HTGRMaterials.MATERIALS_PER_FUEL * this.fueltype + HTGRMaterials.USABLE_FUEL_INDEX); boolean storedAll = false; for (GT_MetaTileEntity_Hatch_OutputBus tHatch : this.mOutputBusses) { if (!isValidMetaTileEntity(tHatch)) continue; @@ -343,10 +342,10 @@ public boolean onRunningTick(ItemStack aStack) { } } if (!storedAll) { - if (this.fuelsupply == iStack.stackSize) emptyticksnodiff++; + if (this.fuelsupply == iStack.stackSize) this.emptyticksnodiff++; else { this.fuelsupply = iStack.stackSize; - emptyticksnodiff = 0; + this.emptyticksnodiff = 0; } } else { this.fuelsupply = 0; @@ -357,13 +356,13 @@ public boolean onRunningTick(ItemStack aStack) { return true; } // USE DA POWAH - if (!drainEnergyInput(-mEUt)) { - criticalStopMachine(); + if (!this.drainEnergyInput(-this.mEUt)) { + this.criticalStopMachine(); return false; } - if (runningtick % 20 == 0) { - int takecoolant = coolanttaking; + if (this.runningtick % 20 == 0) { + int takecoolant = this.coolanttaking; int drainedamount = 0; for (GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { @@ -378,7 +377,7 @@ public boolean onRunningTick(ItemStack aStack) { } } - if (drainedamount > 0) addOutput(FluidRegistry.getFluidStack("ic2hotcoolant", drainedamount)); + if (drainedamount > 0) this.addOutput(FluidRegistry.getFluidStack("ic2hotcoolant", drainedamount)); this.updateSlots(); @@ -420,12 +419,12 @@ public String[] getInfoData() { + GT_Utility.formatNumbers(this.mMaxProgresstime / 20) + "s", "Fuel type:", - (this.fueltype == -1 ? "NONE" : ("TRISO (" + HTGRMaterials.sHTGR_Fuel[this.fueltype].sEnglish) + ")"), + this.fueltype == -1 ? "NONE" : "TRISO (" + HTGRMaterials.sHTGR_Fuel[this.fueltype].sEnglish + ")", "Fuel amount:", GT_Utility.formatNumbers(this.fuelsupply) + " pcs.", "Helium-Level:", GT_Utility.formatNumbers(this.HeliumSupply) + "L / " + GT_Utility.formatNumbers(GT_TileEntity_HTGR.HELIUM_NEEDED) + "L", - "Coolant:", GT_Utility.formatNumbers(coolanttaking) + "L/s", "Problems:", + "Coolant:", GT_Utility.formatNumbers(this.coolanttaking) + "L/s", "Problems:", String.valueOf(this.getIdealStatus() - this.getRepairStatus()) }; } @@ -479,7 +478,8 @@ public CustomHTGRSimpleSubItemClass(HashMap tooltip, String... @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { - if (tooltip.containsKey(getDamage(p_77624_1_))) aList.add(tooltip.get(getDamage(p_77624_1_))); + if (this.tooltip.containsKey(this.getDamage(p_77624_1_))) + aList.add(this.tooltip.get(this.getDamage(p_77624_1_))); aList.add("Material for High Temperature Gas-cooled Reactor"); super.addInformation(p_77624_1_, p_77624_2_, aList, p_77624_4_); } @@ -532,7 +532,7 @@ public LangEntry_(String a, String b) { } } - public static final Base_[] sHTGR_Bases = new Base_[] { new Base_("HTGRFuelMixture", "HTGR fuel mixture"), + public static final Base_[] sHTGR_Bases = { new Base_("HTGRFuelMixture", "HTGR fuel mixture"), new Base_("BISOPebbleCompound", "BISO pebble compound"), new Base_("TRISOPebbleCompound", "TRISO pebble compound"), new Base_("TRISOBall", "TRISO ball"), new Base_("TRISOPebble", "TRISO pebble"), new Base_("BurnedOutTRISOBall", "Burned out TRISO Ball"), @@ -540,7 +540,7 @@ public LangEntry_(String a, String b) { public static final int MATERIALS_PER_FUEL = sHTGR_Bases.length; static final int USABLE_FUEL_INDEX = 4; static final int BURNED_OUT_FUEL_INDEX = 5; - public static final Fuel_[] sHTGR_Fuel = new Fuel_[] { + public static final Fuel_[] sHTGR_Fuel = { new Fuel_( "Thorium", "Thorium", @@ -586,7 +586,7 @@ public LangEntry_(String a, String b) { new LangEntry_( "item." + sHTGR_Materials[i] + ".name", base.sEnglish + " (" + fuel.sEnglish + ")")); - if (((i + 1) % MATERIALS_PER_FUEL == (USABLE_FUEL_INDEX + 1)) && fuel.tooltip != null + if ((i + 1) % MATERIALS_PER_FUEL == USABLE_FUEL_INDEX + 1 && fuel.tooltip != null && !fuel.tooltip.isEmpty()) tooltip.put(i, fuel.tooltip); i++; @@ -603,7 +603,8 @@ public static void registeraTHR_Materials() { public static void register_fake_THR_Recipes() { int i = 0; - for (Fuel_ fuel : sHTGR_Fuel) { + for (@SuppressWarnings("unused") + Fuel_ fuel : sHTGR_Fuel) { fakeRecipeMap.addFakeRecipe( false, diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_LESU.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_LESU.java index 04eb969a8..113a9023a 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_LESU.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_LESU.java @@ -70,7 +70,7 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { private static final ITexture[][] iTextures = new ITexture[4][1]; public ConnectedBlocksChecker connectedcells; public final ItemStack[] circuits = new ItemStack[5]; - private final ItemStackHandler circuitsInventoryHandler = new ItemStackHandler(circuits) { + private final ItemStackHandler circuitsInventoryHandler = new ItemStackHandler(this.circuits) { @Override public int getSlotLimit(int slot) { @@ -100,7 +100,7 @@ public boolean isEnetInput() { @Override public long maxEUStore() { - return (this.mStorage >= Long.MAX_VALUE - 1 || this.mStorage < 0) ? Long.MAX_VALUE - 1 : this.mStorage; + return this.mStorage >= Long.MAX_VALUE - 1 || this.mStorage < 0 ? Long.MAX_VALUE - 1 : this.mStorage; } @Override @@ -179,6 +179,7 @@ public String[] getDescription() { return e.toArray(new String[0]); } + @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister aBlockIconRegister) { @@ -216,7 +217,7 @@ public boolean isClientSide() { public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, int aColorIndex, boolean aActive, boolean aRedstone) { - ITexture[] ret = new ITexture[0]; + ITexture[] ret = {}; if (this.isClientSide()) { @@ -251,15 +252,15 @@ public int getSizeInventory() { } @Override - public ItemStack getStackInSlot(int p_70301_1_) { - if (p_70301_1_ > 1) return this.circuits[(p_70301_1_ - 2)]; - return this.mInventory[p_70301_1_]; + public ItemStack getStackInSlot(int slotIn) { + if (slotIn > 1) return this.circuits[slotIn - 2]; + return this.mInventory[slotIn]; } @Override - public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { - if (p_70299_1_ < 2) this.mInventory[p_70299_1_] = p_70299_2_; - else this.circuits[(p_70299_1_ - 2)] = p_70299_2_; + public void setInventorySlotContents(int index, ItemStack stack) { + if (index < 2) this.mInventory[index] = stack; + else this.circuits[index - 2] = stack; } @Override @@ -278,20 +279,17 @@ public int getInventoryStackLimit() { } @Override - public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { + public boolean isUseableByPlayer(EntityPlayer player) { return true; } @Override - public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { + public boolean isItemValidForSlot(int index, ItemStack stack) { - switch (p_94041_1_) { - case 0: - case 1: - return true; - default: - return p_94041_2_ != null && p_94041_2_.getItem().equals(GT_Utility.getIntegratedCircuit(0).getItem()); - } + return switch (index) { + case 0, 1 -> true; + default -> stack != null && stack.getItem().equals(GT_Utility.getIntegratedCircuit(0).getItem()); + }; } @Override @@ -386,8 +384,8 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack i } this.mEfficiency = this.getMaxEfficiency(null); - this.mStorage = (ConfigHandler.energyPerCell * this.connectedcells.hashset.size() >= Long.MAX_VALUE - 1 - || ConfigHandler.energyPerCell * this.connectedcells.hashset.size() < 0) ? Long.MAX_VALUE - 1 + this.mStorage = ConfigHandler.energyPerCell * this.connectedcells.hashset.size() >= Long.MAX_VALUE - 1 + || ConfigHandler.energyPerCell * this.connectedcells.hashset.size() < 0 ? Long.MAX_VALUE - 1 : ConfigHandler.energyPerCell * this.connectedcells.hashset.size(); this.mMaxProgresstime = 1; this.mProgresstime = 0; @@ -407,7 +405,7 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack i if (finishedTime - startingTime > 5000000) MainMod.LOGGER.warn( "LESU LookUp took longer than 5ms!(" + (finishedTime - startingTime) + "ns / " - + ((finishedTime - startingTime) / 1000000) + + (finishedTime - startingTime) / 1000000 + "ms) Owner:" + this.getBaseMetaTileEntity().getOwnerName() + " Check at x:" @@ -456,29 +454,30 @@ public void addGregTechLogo(ModularWindow.Builder builder) { public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { builder.widget( new DrawableWidget().setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK).setPos(7, 4).setSize(118, 67)) - .widget(new SlotWidget(new BaseSlot(inventoryHandler, 1) { + .widget(new SlotWidget(new BaseSlot(this.inventoryHandler, 1) { @Override public int getSlotStackLimit() { return 1; } - }).setBackground(getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_IN).setPos(127, 13)) - .widget(new SlotWidget(new BaseSlot(inventoryHandler, 0) { + }).setBackground(this.getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_IN).setPos(127, 13)) + .widget(new SlotWidget(new BaseSlot(this.inventoryHandler, 0) { @Override public int getSlotStackLimit() { return 1; } - }).setBackground(getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_CHARGER).setPos(127, 49)); + }).setBackground(this.getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_CHARGER) + .setPos(127, 49)); for (int i = 0; i < 4; i++) { builder.widget( - new SlotWidget(circuitsInventoryHandler, i) - .setBackground(getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_INT_CIRCUIT) - .setPos(151, 4 + i * 18)); + new SlotWidget(this.circuitsInventoryHandler, i).setBackground( + this.getGUITextureSet().getItemSlot(), + GT_UITextures.OVERLAY_SLOT_INT_CIRCUIT).setPos(151, 4 + i * 18)); } final DynamicPositionedColumn screenElements = new DynamicPositionedColumn(); - drawTexts(screenElements); + this.drawTexts(screenElements); builder.widget(screenElements); builder.widget( @@ -486,8 +485,8 @@ public int getSlotStackLimit() { .widget( new ProgressBar() .setProgress( - () -> (float) getBaseMetaTileEntity().getStoredEU() - / getBaseMetaTileEntity().getEUCapacity()) + () -> (float) this.getBaseMetaTileEntity().getStoredEU() + / this.getBaseMetaTileEntity().getEUCapacity()) .setDirection(ProgressBar.Direction.RIGHT) .setTexture(BW_UITextures.PROGRESSBAR_STORED_EU_116, 116).setPos(8, 73) .setSize(116, 5)); @@ -498,40 +497,39 @@ private void drawTexts(DynamicPositionedColumn screenElements) { screenElements .widget( - TextWidget - .dynamicString( - () -> "EU: " + GT_Utility.formatNumbers(getBaseMetaTileEntity().getStoredEU())) - .setDefaultColor(COLOR_TEXT_WHITE.get())) + TextWidget.dynamicString( + () -> "EU: " + GT_Utility.formatNumbers(this.getBaseMetaTileEntity().getStoredEU())) + .setDefaultColor(this.COLOR_TEXT_WHITE.get())) .widget( TextWidget.dynamicString( - () -> "MAX: " + (getBaseMetaTileEntity().isActive() - ? GT_Utility.formatNumbers(getBaseMetaTileEntity().getOutputVoltage()) + () -> "MAX: " + (this.getBaseMetaTileEntity().isActive() + ? GT_Utility.formatNumbers(this.getBaseMetaTileEntity().getOutputVoltage()) + String.valueOf(ConfigHandler.energyPerCell).substring(1) : Integer.toString(0))) - .setDefaultColor(COLOR_TEXT_WHITE.get())) + .setDefaultColor(this.COLOR_TEXT_WHITE.get())) .widget( TextWidget .dynamicString( - () -> "MAX EU/t IN: " - + GT_Utility.formatNumbers(getBaseMetaTileEntity().getInputVoltage())) - .setDefaultColor(COLOR_TEXT_WHITE.get())) + () -> "MAX EU/t IN: " + GT_Utility + .formatNumbers(this.getBaseMetaTileEntity().getInputVoltage())) + .setDefaultColor(this.COLOR_TEXT_WHITE.get())) .widget( TextWidget .dynamicString( - () -> "EU/t OUT: " - + GT_Utility.formatNumbers(getBaseMetaTileEntity().getOutputVoltage())) - .setDefaultColor(COLOR_TEXT_WHITE.get())) + () -> "EU/t OUT: " + GT_Utility + .formatNumbers(this.getBaseMetaTileEntity().getOutputVoltage())) + .setDefaultColor(this.COLOR_TEXT_WHITE.get())) .widget( TextWidget .dynamicString( - () -> "AMP/t IN/OUT: " - + GT_Utility.formatNumbers(getBaseMetaTileEntity().getInputAmperage())) - .setDefaultColor(COLOR_TEXT_WHITE.get())) + () -> "AMP/t IN/OUT: " + GT_Utility + .formatNumbers(this.getBaseMetaTileEntity().getInputAmperage())) + .setDefaultColor(this.COLOR_TEXT_WHITE.get())) .widget( new TextWidget(Text.localised("tooltip.LESU.0.name")).setDefaultColor(Color.YELLOW.getRGB()) - .setEnabled(widget -> maxEUStore() >= Long.MAX_VALUE - 1)) + .setEnabled(widget -> this.maxEUStore() >= Long.MAX_VALUE - 1)) .widget( new TextWidget(Text.localised("tooltip.LESU.1.name")).setDefaultColor(Color.RED.getRGB()) - .setEnabled(widget -> !getBaseMetaTileEntity().isActive())); + .setEnabled(widget -> !this.getBaseMetaTileEntity().isActive())); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ManualTrafo.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ManualTrafo.java index 49e175a13..6c8f5e8b7 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ManualTrafo.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ManualTrafo.java @@ -98,8 +98,7 @@ public GT_TileEntity_ManualTrafo(String aName) { public boolean check(GT_TileEntity_ManualTrafo te, World world, int x, int y, int z) { if (world.isAirBlock(x, y, z)) return true; TileEntity tileEntity = world.getTileEntity(x, y, z); - if (tileEntity == null) return true; - if (!(tileEntity instanceof IGregTechTileEntity)) return true; + if (tileEntity == null || !(tileEntity instanceof IGregTechTileEntity)) return true; IMetaTileEntity mte = ((IGregTechTileEntity) tileEntity).getMetaTileEntity(); if (mte instanceof GT_MetaTileEntity_Hatch_Dynamo || mte instanceof GT_MetaTileEntity_Hatch_Energy) { @@ -108,7 +107,8 @@ public boolean check(GT_TileEntity_ManualTrafo te, World world, int x, int y, in == intier + (te.upstep ? te.mTiers : -te.mTiers)) { te.addToMachineList((IGregTechTileEntity) tileEntity, CASING_INDEX); return true; - } else return false; + } + return false; } return true; } @@ -135,7 +135,7 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() { .addInfo("Mode 3: Circuit 2 in controller: Tapped-Upstep (currently disabled)") .addInfo("Mode 4: Circuit 2 in controller: Tapped-Downstep (currently disabled)").addSeparator() .beginVariableStructureBlock(3, 3, 3, 10, 3, 3, false).addController("Front bottom center") - .addCasingInfo("MV Machine Casing", 0) + .addCasingInfoMin("MV Machine Casing", 0, false) .addOtherStructurePart("Transformer-Winding Blocks", "1 Layer for each tier transformed") .addOtherStructurePart("Nickel-Zinc-Ferrite Blocks", "Middle of Transformer-Winding Blocks") .addMaintenanceHatch("Any bottom layer casing", 1).addEnergyHatch("Any bottom layer casing", 1) @@ -177,10 +177,7 @@ public boolean onRunningTick(ItemStack aStack) { } return this.drainEnergyInput(this.getInputTier() * 2 * this.mEnergyHatches.size()) && this.addEnergyOutput( - this.getInputTier() * 2 - * this.mEnergyHatches.size() - * (long) this.mEfficiency - / this.getMaxEfficiency(null)); + this.getInputTier() * 2 * this.mEnergyHatches.size() * this.mEfficiency / this.getMaxEfficiency(null)); } public boolean onRunningTickTabbedMode() { @@ -188,11 +185,11 @@ public boolean onRunningTickTabbedMode() { for (GT_MetaTileEntity_Hatch_Dynamo E : this.mDynamoHatches) { for (GT_MetaTileEntity_Hatch_Energy I : this.mEnergyHatches) { - long vtt = I.getEUVar() >= (V[E.mTier] / 2) && E.getEUVar() < E.maxEUStore() ? I.getEUVar() : 0; + long vtt = I.getEUVar() >= V[E.mTier] / 2 && E.getEUVar() < E.maxEUStore() ? I.getEUVar() : 0; if (vtt == 0) continue; - long vtp = E.getEUVar() + (vtt); + long vtp = E.getEUVar() + vtt; long avt = Math.min(vtp, E.maxEUStore()); E.setEUVar(avt); I.setEUVar(I.getEUVar() - vtt); @@ -202,16 +199,18 @@ public boolean onRunningTickTabbedMode() { return ret; } + @Override public long getInputTier() { if (this.mEnergyHatches.size() > 0) return GT_Utility.getTier(this.mEnergyHatches.get(0).getBaseMetaTileEntity().getInputVoltage()); - else return 0L; + return 0L; } + @Override public long getOutputTier() { if (this.mDynamoHatches.size() > 0) return GT_Utility.getTier(this.mDynamoHatches.get(0).getBaseMetaTileEntity().getOutputVoltage()); - else return 0L; + return 0L; } @Override @@ -240,9 +239,7 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack i this.upstep = this.mode % 2 == 0; boolean tapmode = this.mode > 1; - if (!checkPiece(STRUCTURE_PIECE_BASE, 1, 0, 0)) return false; - - if (this.mEnergyHatches.size() == 0) return false; + if (!this.checkPiece(STRUCTURE_PIECE_BASE, 1, 0, 0) || this.mEnergyHatches.size() == 0) return false; byte intier = this.mEnergyHatches.get(0).mTier; for (GT_MetaTileEntity_Hatch_Energy in : this.mEnergyHatches) if (in.mTier != intier) return false; @@ -251,13 +248,13 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack i for (mHeight = 1; mHeight <= 8; mHeight++) { if (tapmode) { this.mTiers = mHeight; - if (!checkPiece(STRUCTURE_PIECE_TAP_LAYER, 2, mHeight, 1)) break; - } else if (!checkPiece(STRUCTURE_PIECE_LAYER, 1, mHeight, 0)) break; + if (!this.checkPiece(STRUCTURE_PIECE_TAP_LAYER, 2, mHeight, 1)) break; + } else if (!this.checkPiece(STRUCTURE_PIECE_LAYER, 1, mHeight, 0)) break; } - if (!checkPiece(STRUCTURE_PIECE_TOP, 1, mHeight, 0)) return false; + if (!this.checkPiece(STRUCTURE_PIECE_TOP, 1, mHeight, 0)) return false; this.mTiers = mHeight - 1; - if (this.mDynamoHatches.size() == 0 || mMaintenanceHatches.size() != 1 || this.mTiers == 0) return false; + if (this.mDynamoHatches.size() == 0 || this.mMaintenanceHatches.size() != 1 || this.mTiers == 0) return false; byte outtier = this.mDynamoHatches.get(0).mTier; for (GT_MetaTileEntity_Hatch_Dynamo out : this.mDynamoHatches) { @@ -331,11 +328,11 @@ public void construct(ItemStack itemStack, boolean b) { else this.mode = (byte) Math.min(3, this.mInventory[1].getItemDamage()); int mHeight = Math.min(itemStack.stackSize, 8); boolean tapmode = this.mode > 1; - buildPiece(STRUCTURE_PIECE_BASE, itemStack, b, 1, 0, 0); + this.buildPiece(STRUCTURE_PIECE_BASE, itemStack, b, 1, 0, 0); for (int i = 0; i < mHeight; i++) { - if (tapmode) buildPiece(STRUCTURE_PIECE_TAP_LAYER, itemStack, b, 2, i + 1, 1); - else buildPiece(STRUCTURE_PIECE_LAYER, itemStack, b, 1, i + 1, 0); + if (tapmode) this.buildPiece(STRUCTURE_PIECE_TAP_LAYER, itemStack, b, 2, i + 1, 1); + else this.buildPiece(STRUCTURE_PIECE_LAYER, itemStack, b, 1, i + 1, 0); } - buildPiece(STRUCTURE_PIECE_TOP, itemStack, b, 1, mHeight + 1, 0); + this.buildPiece(STRUCTURE_PIECE_TOP, itemStack, b, 1, mHeight + 1, 0); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java index 0bec36aca..89f27cf41 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java @@ -152,7 +152,7 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() { .addInfo("Reactor will take 4 800L/t of coolant multiplied by efficiency") .addInfo("Uses " + GT_Utility.formatNumbers(powerUsage) + " EU/t") .addInfo("One Operation takes 9 hours").addSeparator().beginStructureBlock(11, 12, 11, true) - .addController("Front bottom center").addCasingInfo("Radiation Proof Casings", 500) + .addController("Front bottom center").addCasingInfoMin("Radiation Proof Casings", 500, false) .addStructureInfo("Corners and the 2 touching blocks are air (cylindric)") .addInputBus("Any top layer casing", 2).addInputHatch("Any top layer casing", 2) .addOutputBus("Any bottom layer casing", 1).addOutputHatch("Any bottom layer casing", 1) @@ -168,19 +168,19 @@ protected IAlignmentLimits getInitialAlignmentLimits() { @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 5, 11, 0); + this.buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 5, 11, 0); } @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { this.mCasing = 0; - return (checkPiece(STRUCTURE_PIECE_MAIN, 5, 11, 0) && this.mCasing >= 500 + return this.checkPiece(STRUCTURE_PIECE_MAIN, 5, 11, 0) && this.mCasing >= 500 && this.mMaintenanceHatches.size() == 1 && this.mInputHatches.size() > 0 && this.mOutputHatches.size() > 0 && this.mInputBusses.size() > 0 && this.mOutputBusses.size() > 0 - && this.mEnergyHatches.size() > 0); + && this.mEnergyHatches.size() > 0; } @Override @@ -217,7 +217,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { } } if (this.fuelsupply < maxcapacity) { - startRecipeProcessing(); + this.startRecipeProcessing(); for (ItemStack itemStack : this.getStoredInputs()) { if (GT_Utility.areStacksEqual( itemStack, @@ -228,7 +228,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { this.fuelsupply += toget; } } - endRecipeProcessing(); + this.endRecipeProcessing(); this.updateSlots(); } } @@ -245,14 +245,14 @@ public boolean checkRecipe(ItemStack controllerStack) { } return false; } - if (!(this.HeliumSupply >= GT_TileEntity_THTR.HELIUM_NEEDED && this.fuelsupply >= mincapacity)) return false; + if (this.HeliumSupply < GT_TileEntity_THTR.HELIUM_NEEDED || this.fuelsupply < mincapacity) return false; - double eff = Math.min( - Math.pow((double) (this.fuelsupply - mincapacity) / ((maxcapacity - mincapacity) / 10D), 2D) + 1, - 100D) / 100D - ((double) (getIdealStatus() - getRepairStatus()) / 10D); + double eff = Math + .min(Math.pow((this.fuelsupply - mincapacity) / ((maxcapacity - mincapacity) / 10D), 2D) + 1, 100D) + / 100D - (this.getIdealStatus() - this.getRepairStatus()) / 10D; if (eff <= 0D) return false; - int toReduce = MathUtils.floorInt((double) this.fuelsupply * 0.005D * eff); + int toReduce = MathUtils.floorInt(this.fuelsupply * 0.005D * eff); final int originalToReduce = toReduce; int burnedballs = toReduce / 64; @@ -260,9 +260,9 @@ public boolean checkRecipe(ItemStack controllerStack) { int meta = THTRMaterials.MATERIAL_USED_FUEL_INDEX; - ItemStack[] toOutput = new ItemStack[] { new ItemStack(THTRMaterials.aTHTR_Materials, burnedballs, meta), + ItemStack[] toOutput = { new ItemStack(THTRMaterials.aTHTR_Materials, burnedballs, meta), new ItemStack(THTRMaterials.aTHTR_Materials, toReduce, meta + 1) }; - if (!canOutputAll(toOutput)) return false; + if (!this.canOutputAll(toOutput)) return false; this.fuelsupply -= originalToReduce; this.mOutputItems = toOutput; @@ -291,7 +291,7 @@ public boolean onRunningTick(ItemStack aStack) { if (!super.onRunningTick(aStack)) return false; - int takecoolant = coolanttaking; + int takecoolant = this.coolanttaking; int drainedamount = 0; for (GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { @@ -306,7 +306,7 @@ public boolean onRunningTick(ItemStack aStack) { } } - if (drainedamount > 0) addOutput(FluidRegistry.getFluidStack("ic2hotcoolant", drainedamount)); + if (drainedamount > 0) this.addOutput(FluidRegistry.getFluidStack("ic2hotcoolant", drainedamount)); this.updateSlots(); @@ -352,7 +352,7 @@ public String[] getInfoData() { GT_Utility.formatNumbers(this.HeliumSupply) + "L / " + GT_Utility.formatNumbers(GT_TileEntity_THTR.HELIUM_NEEDED) + "L", - "Coolant/t:", GT_Utility.formatNumbers(this.mProgresstime == 0 ? 0 : coolanttaking) + "L/t", + "Coolant/t:", GT_Utility.formatNumbers(this.mProgresstime == 0 ? 0 : this.coolanttaking) + "L/t", "Problems:", String.valueOf(this.getIdealStatus() - this.getRepairStatus()) }; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_Windmill.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_Windmill.java index 3137d91e4..26d7ed3d0 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_Windmill.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_Windmill.java @@ -32,6 +32,7 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.init.Blocks; import net.minecraft.init.Items; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityDispenser; @@ -74,7 +75,7 @@ import gregtech.api.interfaces.modularui.IGetTitleColor; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; -import gregtech.api.objects.XSTR; +import gregtech.api.objects.ItemData; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_OreDictUnificator; @@ -89,7 +90,6 @@ public class GT_TileEntity_Windmill extends GT_MetaTileEntity_EnhancedMultiBlock private static final IIconContainer[] iIconContainers = new IIconContainer[2]; private static final ITexture[] iTextures = new ITexture[3]; - private static final XSTR localRandomInstance = new XSTR(); private BW_RotorBlock rotorBlock; private int mDoor = 0; private int mHardenedClay = 0; @@ -137,13 +137,13 @@ private GT_TileEntity_Windmill(String aName) { @Override public boolean check(GT_TileEntity_Windmill gt_tileEntity_windmill, World world, int x, int y, int z) { - return delegate.check(gt_tileEntity_windmill, world, x, y, z); + return this.delegate.check(gt_tileEntity_windmill, world, x, y, z); } @Override public boolean spawnHint(GT_TileEntity_Windmill gt_tileEntity_windmill, World world, int x, int y, int z, ItemStack trigger) { - return delegate.spawnHint(gt_tileEntity_windmill, world, x, y, z, trigger); + return this.delegate.spawnHint(gt_tileEntity_windmill, world, x, y, z, trigger); } }))) .addElement('b', ofBlock(Blocks.brick_block, 0)) @@ -195,7 +195,8 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() { .addInfo("The structure is too complex!") .addInfo("Follow the StructureLib hologram projector to build the main structure.").addSeparator() .beginStructureBlock(7, 12, 7, false).addController("Front bottom center") - .addCasingInfo("Hardened Clay block", 40).addOtherStructurePart("Dispenser", "Any Hardened Clay block") + .addCasingInfoMin("Hardened Clay block", 40, false) + .addOtherStructurePart("Dispenser", "Any Hardened Clay block") .addOtherStructurePart("0-1 Wooden door", "Any Hardened Clay block") .addStructureHint("Primitive Kinetic Shaftbox", 1).toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTWORKS); return tt; @@ -211,7 +212,7 @@ public boolean isCorrectMachinePart(ItemStack itemStack) { @Override public boolean onRunningTick(ItemStack aStack) { if (this.mMaxProgresstime > 0) this.mProgresstime += this.rotorBlock.getGrindPower(); - if (!rotorBlock.rotorSlot.isEmpty()) this.setRotorDamage(rotorBlock, this.rotorBlock.getGrindPower()); + if (!this.rotorBlock.rotorSlot.isEmpty()) this.setRotorDamage(this.rotorBlock, this.rotorBlock.getGrindPower()); return this.rotorBlock.getGrindPower() > 0; } @@ -228,47 +229,51 @@ public boolean doRandomMaintenanceDamage() { private float[] multiplierRecipe(ItemStack itemStack) { // will return max and min value of the multiplier, the average of these is used to calculate the multiplier. - if (itemStack.getItem().equals(Items.wheat)) return new float[] { 1.13f, 1.5f }; - else if (itemStack.getItem().equals(Items.bone) - || Block.getBlockFromItem(itemStack.getItem()).equals(Blocks.glowstone) - || Block.getBlockFromItem(itemStack.getItem()).equals(Blocks.pumpkin)) + final Item item = itemStack.getItem(); + if (item == Items.wheat) { + return new float[] { 1.13f, 1.5f }; + } + final Block block = Block.getBlockFromItem(item); + if (item == Items.bone || block == Blocks.glowstone || block == Blocks.pumpkin) { return new float[] { 0.8f, 1f }; - else if (Block.getBlockFromItem(itemStack.getItem()).equals(Blocks.gravel) - || Block.getBlockFromItem(itemStack.getItem()).equals(Blocks.cobblestone) - || Block.getBlockFromItem(itemStack.getItem()).equals(Blocks.stone) - || Block.getBlockFromItem(itemStack.getItem()).equals(Blocks.sandstone) - || Block.getBlockFromItem(itemStack.getItem()).equals(Blocks.clay) - || Block.getBlockFromItem(itemStack.getItem()).equals(Blocks.hardened_clay) - || Block.getBlockFromItem(itemStack.getItem()).equals(Blocks.stained_hardened_clay) - || Block.getBlockFromItem(itemStack.getItem()).equals(Blocks.wool) - || Block.getBlockFromItem(itemStack.getItem()).equals(Blocks.netherrack) - || Block.getBlockFromItem(itemStack.getItem()).equals(Blocks.log) - || Block.getBlockFromItem(itemStack.getItem()).equals(Blocks.log2)) + } + if (block == Blocks.gravel || block == Blocks.cobblestone + || block == Blocks.stone + || block == Blocks.sandstone + || block == Blocks.clay + || block == Blocks.hardened_clay + || block == Blocks.stained_hardened_clay + || block == Blocks.wool + || block == Blocks.netherrack + || block == Blocks.log + || block == Blocks.log2) { return new float[] { 1f, 1.5f }; - else if (GT_OreDictUnificator.getAssociation(itemStack) == null - || GT_OreDictUnificator.getAssociation(itemStack).mPrefix == null - || GT_OreDictUnificator.getAssociation(itemStack).mMaterial == null - || GT_OreDictUnificator.getAssociation(itemStack).mMaterial.mMaterial == null - || GT_OreDictUnificator.getAssociation(itemStack).mMaterial.mMaterial.getDust(1) == null) + } + final ItemData association = GT_OreDictUnificator.getAssociation(itemStack); + final OrePrefixes prefix = association == null ? null : association.mPrefix; + if (prefix == null || association.mMaterial == null + || association.mMaterial.mMaterial == null + || association.mMaterial.mMaterial.getDust(1) == null) { return new float[] { 1f, 1f }; - else if (OrePrefixes.ore.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix) - || OrePrefixes.oreNetherrack.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix) - || OrePrefixes.oreEndstone.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix) - || OrePrefixes.oreBlackgranite.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix) - || OrePrefixes.oreRedgranite.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix) - || OrePrefixes.oreMarble.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix) - || OrePrefixes.oreBasalt.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)) + } + if (OrePrefixes.ore == prefix || OrePrefixes.oreNetherrack == prefix + || OrePrefixes.oreEndstone == prefix + || OrePrefixes.oreBlackgranite == prefix + || OrePrefixes.oreRedgranite == prefix + || OrePrefixes.oreMarble == prefix + || OrePrefixes.oreBasalt == prefix) { return new float[] { 0.5f, 1f }; - else if (OrePrefixes.stone.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix) - || OrePrefixes.stoneBricks.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix) - || OrePrefixes.stoneChiseled.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix) - || OrePrefixes.stoneCobble.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix) - || OrePrefixes.stoneCracked.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix) - || OrePrefixes.stoneMossy.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix) - || OrePrefixes.stoneMossyBricks.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix) - || OrePrefixes.stoneSmooth.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix) - || OrePrefixes.cobblestone.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)) + } + if (OrePrefixes.stone == prefix || OrePrefixes.stoneBricks == prefix + || OrePrefixes.stoneChiseled == prefix + || OrePrefixes.stoneCobble == prefix + || OrePrefixes.stoneCracked == prefix + || OrePrefixes.stoneMossy == prefix + || OrePrefixes.stoneMossyBricks == prefix + || OrePrefixes.stoneSmooth == prefix + || OrePrefixes.cobblestone == prefix) { return new float[] { 1f, 1.5f }; + } return new float[] { 1f, 1f }; } @@ -294,13 +299,13 @@ public boolean checkRecipe(ItemStack itemStack) { } this.updateSlots(); this.mOutputItems[0] = tRecipe.getOutput(0); - float[] mRecipe = multiplierRecipe(itemStack); + float[] mRecipe = this.multiplierRecipe(itemStack); float multiper = Math.min( mRecipe[1], Math.max( mRecipe[0], - 2f * ((float) Math.sqrt((float) 1 / (this.rotorBlock.getWindStrength() + 1))) - * OutputMultiplier(rotorBlock) + 2f * (float) Math.sqrt((float) 1 / (this.rotorBlock.getWindStrength() + 1)) + * this.OutputMultiplier(this.rotorBlock) * (mRecipe[0] + mRecipe[1]))); int amount = (int) Math.floor(multiper * (this.mOutputItems[0].stackSize * this.mMulti)); @@ -315,16 +320,16 @@ public boolean checkRecipe(ItemStack itemStack) { ItemStack tmp = this.mOutputItems[0].copy(); tmp.stackSize = amount; splitStacks.add(tmp); - mOutputItems = splitStacks.toArray(new ItemStack[splitStacks.size()]); + this.mOutputItems = splitStacks.toArray(new ItemStack[splitStacks.size()]); } - this.mMaxProgresstime = (tRecipe.mDuration * 2 * 100 * this.mMulti) / getSpeed(rotorBlock); + this.mMaxProgresstime = tRecipe.mDuration * 2 * 100 * this.mMulti / this.getSpeed(this.rotorBlock); this.mMulti = 16; return true; } @Override public void stopMachine() { - getBaseMetaTileEntity().disableWorking(); + this.getBaseMetaTileEntity().disableWorking(); } public boolean addDispenserToOutputSet(TileEntity aTileEntity) { @@ -343,7 +348,6 @@ public boolean setRotorBlock(TileEntity aTileEntity) { return false; } - @SuppressWarnings("ALL") @Override public boolean addOutput(ItemStack aStack) { if (GT_Utility.isStackInvalid(aStack)) return false; @@ -363,11 +367,10 @@ public boolean addOutput(ItemStack aStack) { if (GT_Utility.areStacksEqual(tHatch.getStackInSlot(i), aStack)) { aStack = null; return true; - } else { - tHatch.setInventorySlotContents(i, null); - aStack = null; - return false; } + tHatch.setInventorySlotContents(i, null); + aStack = null; + return false; } } } @@ -381,9 +384,10 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack i this.mDoor = 0; this.mHardenedClay = 0; - if (!checkPiece(STRUCTURE_PIECE_MAIN, 3, 11, 0)) return false; - - if (this.tileEntityDispensers.isEmpty() || this.mDoor > 2 || this.mHardenedClay < 40) return false; + if (!this.checkPiece(STRUCTURE_PIECE_MAIN, 3, 11, 0) || this.tileEntityDispensers.isEmpty() + || this.mDoor > 2 + || this.mHardenedClay < 40) + return false; this.mWrench = true; this.mScrewdriver = true; @@ -512,13 +516,13 @@ public boolean isClientSide() { @Override public void construct(ItemStack itemStack, boolean b) { - buildPiece(STRUCTURE_PIECE_MAIN, itemStack, b, 3, 11, 0); + this.buildPiece(STRUCTURE_PIECE_MAIN, itemStack, b, 3, 11, 0); } @Override public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 3, 11, 0, elementBudget, env, false, true); + if (this.mMachine) return -1; + return this.survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 3, 11, 0, elementBudget, env, false, true); } public float OutputMultiplier(BW_RotorBlock rotorBlock) { @@ -563,13 +567,14 @@ public void addGregTechLogo(ModularWindow.Builder builder) { @Override public int getTitleColor() { - return COLOR_TITLE_WHITE.get(); + return this.COLOR_TITLE_WHITE.get(); } @Override public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { builder.widget( - new SlotWidget(inventoryHandler, 1).setBackground(getGUITextureSet().getItemSlot()).setPos(59, 35)) + new SlotWidget(this.inventoryHandler, 1).setBackground(this.getGUITextureSet().getItemSlot()) + .setPos(59, 35)) .widget(new DrawableWidget() { private static final int DIVIDER = 125; @@ -577,24 +582,27 @@ public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildCont @Override public void onScreenUpdate() { super.onScreenUpdate(); - if (mMaxProgresstime > 0) { + if (GT_TileEntity_Windmill.this.mMaxProgresstime > 0) { if (System.currentTimeMillis() / DIVIDER % 40 == 30) - setDrawable(BW_UITextures.PICTURE_WINDMILL_ROTATING[3]); + this.setDrawable(BW_UITextures.PICTURE_WINDMILL_ROTATING[3]); else if (System.currentTimeMillis() / DIVIDER % 40 == 20) - setDrawable(BW_UITextures.PICTURE_WINDMILL_ROTATING[2]); + this.setDrawable(BW_UITextures.PICTURE_WINDMILL_ROTATING[2]); else if (System.currentTimeMillis() / DIVIDER % 40 == 10) - setDrawable(BW_UITextures.PICTURE_WINDMILL_ROTATING[1]); + this.setDrawable(BW_UITextures.PICTURE_WINDMILL_ROTATING[1]); else if (System.currentTimeMillis() / DIVIDER % 40 == 0) - setDrawable(BW_UITextures.PICTURE_WINDMILL_ROTATING[0]); + this.setDrawable(BW_UITextures.PICTURE_WINDMILL_ROTATING[0]); } else { - setDrawable(BW_UITextures.PICTURE_WINDMILL_EMPTY); + this.setDrawable(BW_UITextures.PICTURE_WINDMILL_EMPTY); } } }.setDrawable(BW_UITextures.PICTURE_WINDMILL_EMPTY).setPos(85, 27).setSize(32, 32)) - .widget(new FakeSyncWidget.IntegerSyncer(() -> mMaxProgresstime, val -> mMaxProgresstime = val)) + .widget( + new FakeSyncWidget.IntegerSyncer( + () -> this.mMaxProgresstime, + val -> this.mMaxProgresstime = val)) .widget( new ItemDrawable( - () -> mMachine && !getBaseMetaTileEntity().isActive() + () -> this.mMachine && !this.getBaseMetaTileEntity().isActive() ? GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( GT_MetaGenerated_Tool_01.SOFTMALLET, 1, @@ -604,12 +612,12 @@ else if (System.currentTimeMillis() / DIVIDER % 40 == 0) : null).asWidget().setPos(66, 66)) .widget( new FakeSyncWidget.BooleanSyncer( - () -> getBaseMetaTileEntity().isActive(), - val -> getBaseMetaTileEntity().setActive(val))) + () -> this.getBaseMetaTileEntity().isActive(), + val -> this.getBaseMetaTileEntity().setActive(val))) .widget( new TextWidget(GT_Utility.trans("138", "Incomplete Structure.")) - .setDefaultColor(COLOR_TEXT_WHITE.get()).setMaxWidth(150) - .setEnabled(widget -> !mMachine).setPos(92, 22)) - .widget(new FakeSyncWidget.BooleanSyncer(() -> mMachine, val -> mMachine = val)); + .setDefaultColor(this.COLOR_TEXT_WHITE.get()).setMaxWidth(150) + .setEnabled(widget -> !this.mMachine).setPos(92, 22)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> this.mMachine, val -> this.mMachine = val)); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java index 5178a3f75..bf80c80a1 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java @@ -174,8 +174,9 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() { .addInfo( "For each perfect overclock the EBF will reduce recipe time 4 times (instead of 2) (100% efficiency)") .addInfo("Additionally gives +100K for every tier past MV") - .addPollutionAmount(20 * getPollutionPerTick(null)).addSeparator().beginStructureBlock(15, 20, 15, true) - .addController("3rd layer center").addCasingInfoRange("Heat Proof Machine Casing", 0, 279, false) + .addPollutionAmount(20 * this.getPollutionPerTick(null)).addSeparator() + .beginStructureBlock(15, 20, 15, true).addController("3rd layer center") + .addCasingInfoRange("Heat Proof Machine Casing", 0, 279, false) .addOtherStructurePart("864x Heating Coils", "Inner 13x18x13 (Hollow)") .addOtherStructurePart("1007x Borosilicate Glass", "Outer 15x18x15") .addStructureInfo("The glass tier limits the Energy Input tier") @@ -195,31 +196,30 @@ public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); this.glassTier = aNBT.getByte("glasTier"); if (!aNBT.hasKey(INPUT_SEPARATION_NBT_KEY)) { - inputSeparation = aNBT.getBoolean("isBussesSeparate"); + this.inputSeparation = aNBT.getBoolean("isBussesSeparate"); } if (!aNBT.hasKey(BATCH_MODE_NBT_KEY)) { - batchMode = aNBT.getBoolean("mUseMultiparallelMode"); + this.batchMode = aNBT.getBoolean("mUseMultiparallelMode"); } } @Override public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aPlayer.isSneaking()) { - batchMode = !batchMode; - if (batchMode) { - GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); - } else { - GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); - } - return true; - } else { - inputSeparation = !inputSeparation; + if (!aPlayer.isSneaking()) { + this.inputSeparation = !this.inputSeparation; GT_Utility.sendChatToPlayer( aPlayer, - StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + inputSeparation); + StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + this.inputSeparation); return true; } + this.batchMode = !this.batchMode; + if (this.batchMode) { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); + } else { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); + } + return true; } @Override @@ -241,7 +241,7 @@ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirec @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); - aNBT.setByte("glasTier", glassTier); + aNBT.setByte("glasTier", this.glassTier); } @Override @@ -255,7 +255,7 @@ public boolean addOutputHatchToTopList(IGregTechTileEntity aTileEntity, int aBas if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return mPollutionOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); + return this.mPollutionOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); } return false; } @@ -264,7 +264,7 @@ public boolean addOutputHatchToTopList(IGregTechTileEntity aTileEntity, int aBas protected String[] getExtendedInfoData() { return new String[] { StatCollector.translateToLocal("GT5U.EBF.heat") + ": " + EnumChatFormatting.GREEN - + GT_Utility.formatNumbers(mHeatingCapacity) + + GT_Utility.formatNumbers(this.mHeatingCapacity) + EnumChatFormatting.RESET + " K" }; } @@ -277,12 +277,14 @@ protected ProcessingLogic createProcessingLogic() { @Override protected GT_OverclockCalculator createOverclockCalculator(@Nonnull GT_Recipe recipe) { return super.createOverclockCalculator(recipe).setRecipeHeat(recipe.mSpecialValue) - .setMultiHeat(mHeatingCapacity).setHeatOC(true).setHeatDiscount(true); + .setMultiHeat(GT_TileEntity_MegaBlastFurnace.this.mHeatingCapacity).setHeatOC(true) + .setHeatDiscount(true); } @Override protected @Nonnull CheckRecipeResult validateRecipe(@Nonnull GT_Recipe recipe) { - return recipe.mSpecialValue <= mHeatingCapacity ? CheckRecipeResultRegistry.SUCCESSFUL + return recipe.mSpecialValue <= GT_TileEntity_MegaBlastFurnace.this.mHeatingCapacity + ? CheckRecipeResultRegistry.SUCCESSFUL : CheckRecipeResultRegistry.insufficientHeat(recipe.mSpecialValue); } }.setMaxParallel(ConfigHandler.megaMachinesMax); @@ -300,24 +302,24 @@ public IStructureDefinition getStructureDefiniti @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece("main", stackSize, hintsOnly, 7, 17, 0); + this.buildPiece("main", stackSize, hintsOnly, 7, 17, 0); } @Override public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; + if (this.mMachine) return -1; int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 5); - glassTier = 0; - setCoilLevel(HeatingCoilLevel.None); - return survivialBuildPiece("main", stackSize, 7, 17, 0, realBudget, source, actor, false, true); + this.glassTier = 0; + this.setCoilLevel(HeatingCoilLevel.None); + return this.survivialBuildPiece("main", stackSize, 7, 17, 0, realBudget, source, actor, false, true); } public void setCoilLevel(HeatingCoilLevel aCoilLevel) { - mCoilLevel = aCoilLevel; + this.mCoilLevel = aCoilLevel; } public HeatingCoilLevel getCoilLevel() { - return mCoilLevel; + return this.mCoilLevel; } @Override @@ -325,7 +327,7 @@ public boolean addOutput(FluidStack aLiquid) { if (aLiquid == null) return false; FluidStack tLiquid = aLiquid.copy(); boolean isOutputPollution = false; - for (FluidStack pollutionFluidStack : pollutionFluidStacks) { + for (FluidStack pollutionFluidStack : this.pollutionFluidStacks) { if (!tLiquid.isFluidEqual(pollutionFluidStack)) continue; isOutputPollution = true; @@ -335,7 +337,7 @@ public boolean addOutput(FluidStack aLiquid) { if (isOutputPollution) { tOutputHatches = this.mPollutionOutputHatches; int pollutionReduction = 0; - for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { + for (GT_MetaTileEntity_Hatch_Muffler tHatch : this.mMufflerHatches) { if (!isValidMetaTileEntity(tHatch)) continue; pollutionReduction = 100 - tHatch.calculatePollutionReduction(100); break; @@ -350,30 +352,28 @@ public boolean addOutput(FluidStack aLiquid) { @Override public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { this.mHeatingCapacity = 0; - glassTier = 0; + this.glassTier = 0; - setCoilLevel(HeatingCoilLevel.None); + this.setCoilLevel(HeatingCoilLevel.None); this.mPollutionOutputHatches.clear(); - if (!checkPiece("main", 7, 17, 0)) return false; - - if (getCoilLevel() == HeatingCoilLevel.None) return false; - - if (mMaintenanceHatches.size() != 1) return false; + if (!this.checkPiece("main", 7, 17, 0) || this.getCoilLevel() == HeatingCoilLevel.None + || this.mMaintenanceHatches.size() != 1) + return false; - if (glassTier < 8) { - for (GT_MetaTileEntity_Hatch hatch : mExoticEnergyHatches) { + if (this.glassTier < 8) { + for (GT_MetaTileEntity_Hatch hatch : this.mExoticEnergyHatches) { if (hatch.getConnectionType() == GT_MetaTileEntity_Hatch.ConnectionType.LASER) { return false; } - if (glassTier < hatch.mTier) { + if (this.glassTier < hatch.mTier) { return false; } } } - this.mHeatingCapacity = (int) getCoilLevel().getHeat() + 100 * (BW_Util.getTier(getMaxInputEu()) - 2); + this.mHeatingCapacity = (int) this.getCoilLevel().getHeat() + 100 * (BW_Util.getTier(this.getMaxInputEu()) - 2); return true; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java index 52f5d55f2..68c8a7804 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java @@ -116,7 +116,7 @@ public GT_Recipe.GT_Recipe_Map getRecipeMap() { public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); if (!aNBT.hasKey(BATCH_MODE_NBT_KEY)) { - batchMode = aNBT.getBoolean("mUseMultiparallelMode"); + this.batchMode = aNBT.getBoolean("mUseMultiparallelMode"); } } @@ -124,8 +124,8 @@ public void loadNBTData(NBTTagCompound aNBT) { public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aPlayer.isSneaking()) { - batchMode = !batchMode; - if (batchMode) { + this.batchMode = !this.batchMode; + if (this.batchMode) { GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); } else { GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); @@ -142,31 +142,30 @@ protected ProcessingLogic createProcessingLogic() { @Override public void construct(ItemStack aStack, boolean aHintsOnly) { - buildPiece(STRUCTURE_PIECE_MAIN, aStack, aHintsOnly, 2, 2, 0); + this.buildPiece(STRUCTURE_PIECE_MAIN, aStack, aHintsOnly, 2, 2, 0); } @Override public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; + if (this.mMachine) return -1; int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 5); - return survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 2, 2, 0, realBudget, source, actor, false, true); + return this + .survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 2, 2, 0, realBudget, source, actor, false, true); } // -------------- TEC TECH COMPAT ---------------- @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - glassTier = 0; + this.glassTier = 0; - if (!checkPiece(STRUCTURE_PIECE_MAIN, 2, 2, 0)) return false; + if (!this.checkPiece(STRUCTURE_PIECE_MAIN, 2, 2, 0) || this.mMaintenanceHatches.size() != 1) return false; - if (mMaintenanceHatches.size() != 1) return false; - - if (glassTier < 8) { - for (GT_MetaTileEntity_Hatch hatch : mExoticEnergyHatches) { + if (this.glassTier < 8) { + for (GT_MetaTileEntity_Hatch hatch : this.mExoticEnergyHatches) { if (hatch.getConnectionType() == GT_MetaTileEntity_Hatch.ConnectionType.LASER) { return false; } - if (glassTier < hatch.mTier) { + if (this.glassTier < hatch.mTier) { return false; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaDistillTower.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaDistillTower.java index 913d706c5..343a06cec 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaDistillTower.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaDistillTower.java @@ -168,21 +168,18 @@ public class GT_TileEntity_MegaDistillTower extends GT_TileEntity_MegaMultiBlock t.mTopState = 1; // hatch adder TileEntity tileEntity = world.getTileEntity(x, y, z); - if (tileEntity instanceof IGregTechTileEntity) { - IGregTechTileEntity entity = (IGregTechTileEntity) tileEntity; - if (t.addLayerOutputHatch(entity, CASING_INDEX)) { - t.onTopLayerFound(false); - return true; - } + if (tileEntity instanceof IGregTechTileEntity entity + && t.addLayerOutputHatch(entity, CASING_INDEX)) { + t.onTopLayerFound(false); + return true; } // block adder if (world.getBlock(x, y, z) == GregTech_API.sBlockCasings4 && world.getBlockMetadata(x, y, z) == 1) { t.onTopLayerFound(true); return true; - } else { - return false; } + return false; }).build(); } @@ -208,27 +205,27 @@ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { } protected void onCasingFound() { - mCasing++; + this.mCasing++; } protected int getCurrentLayerOutputHatchCount() { - return mOutputHatchesByLayer.size() < mHeight || mHeight <= 0 ? 0 - : mOutputHatchesByLayer.get(mHeight - 1).size(); + return this.mOutputHatchesByLayer.size() < this.mHeight || this.mHeight <= 0 ? 0 + : this.mOutputHatchesByLayer.get(this.mHeight - 1).size(); } protected boolean addLayerOutputHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { if (aTileEntity == null || aTileEntity.isDead() || !(aTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Output)) return false; - while (mOutputHatchesByLayer.size() < mHeight) mOutputHatchesByLayer.add(new ArrayList<>()); + while (this.mOutputHatchesByLayer.size() < this.mHeight) this.mOutputHatchesByLayer.add(new ArrayList<>()); GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) aTileEntity.getMetaTileEntity(); tHatch.updateTexture(aBaseCasingIndex); - return mOutputHatchesByLayer.get(mHeight - 1).add(tHatch); + return this.mOutputHatchesByLayer.get(this.mHeight - 1).add(tHatch); } protected void onTopLayerFound(boolean aIsCasing) { - mTopLayerFound = true; - if (aIsCasing) onCasingFound(); + this.mTopLayerFound = true; + if (aIsCasing) this.onCasingFound(); } @Override @@ -277,63 +274,58 @@ public IStructureDefinition getStructureDefiniti @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { // reset - mOutputHatchesByLayer.forEach(List::clear); - mHeight = 1; - mTopLayerFound = false; - mTopState = -1; + this.mOutputHatchesByLayer.forEach(List::clear); + this.mHeight = 1; + this.mTopLayerFound = false; + this.mTopState = -1; // check base - if (!checkPiece(STRUCTURE_PIECE_BASE, 7, 0, 0)) return false; + if (!this.checkPiece(STRUCTURE_PIECE_BASE, 7, 0, 0)) return false; // check each layer - while (mHeight < 12 && checkPiece(STRUCTURE_PIECE_LAYER, 7, mHeight * 5, 0) && !mTopLayerFound) { - if (mOutputHatchesByLayer.size() < mHeight || mOutputHatchesByLayer.get(mHeight - 1).isEmpty()) + while (this.mHeight < 12 && this.checkPiece(STRUCTURE_PIECE_LAYER, 7, this.mHeight * 5, 0) + && !this.mTopLayerFound) { + if (this.mOutputHatchesByLayer.size() < this.mHeight + || this.mOutputHatchesByLayer.get(this.mHeight - 1).isEmpty()) // layer without output hatch return false; - mTopState = -1; + this.mTopState = -1; // not top - mHeight++; + this.mHeight++; } // validate final invariants... - return mCasing >= 75 * mHeight + 10 && mHeight >= 2 && mTopLayerFound && mMaintenanceHatches.size() == 1; + return this.mCasing >= 75 * this.mHeight + 10 && this.mHeight >= 2 + && this.mTopLayerFound + && this.mMaintenanceHatches.size() == 1; } @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(STRUCTURE_PIECE_BASE, stackSize, hintsOnly, 7, 0, 0); + this.buildPiece(STRUCTURE_PIECE_BASE, stackSize, hintsOnly, 7, 0, 0); int tTotalHeight = Math.min(12, stackSize.stackSize + 2); // min 2 output layer, so at least 1 + 2 height for (int i = 1; i < tTotalHeight - 1; i++) { - buildPiece(STRUCTURE_PIECE_LAYER, stackSize, hintsOnly, 7, 5 * i, 0); + this.buildPiece(STRUCTURE_PIECE_LAYER, stackSize, hintsOnly, 7, 5 * i, 0); } - buildPiece(STRUCTURE_PIECE_TOP_HINT, stackSize, hintsOnly, 7, 5 * (tTotalHeight - 1), 0); + this.buildPiece(STRUCTURE_PIECE_TOP_HINT, stackSize, hintsOnly, 7, 5 * (tTotalHeight - 1), 0); } @Override public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; + if (this.mMachine) return -1; int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 5); - mHeight = 0; - int built = survivialBuildPiece( - STRUCTURE_PIECE_BASE, - stackSize, - 7, - 0, - 0, - realBudget, - source, - actor, - false, - true); + this.mHeight = 0; + int built = this + .survivialBuildPiece(STRUCTURE_PIECE_BASE, stackSize, 7, 0, 0, realBudget, source, actor, false, true); if (built >= 0) return built; int tTotalHeight = Math.min(12, stackSize.stackSize + 2); // min 2 output layer, so at least 1 + 2 height for (int i = 1; i < tTotalHeight - 1; i++) { - mHeight = i; - built = survivialBuildPiece( + this.mHeight = i; + built = this.survivialBuildPiece( STRUCTURE_PIECE_LAYER, stackSize, 7, - 5 * mHeight, + 5 * this.mHeight, 0, realBudget, source, @@ -342,12 +334,12 @@ public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource true); if (built >= 0) return built; } - mHeight = tTotalHeight - 1; - return survivialBuildPiece( + this.mHeight = tTotalHeight - 1; + return this.survivialBuildPiece( STRUCTURE_PIECE_TOP_HINT, stackSize, 7, - 5 * mHeight, + 5 * this.mHeight, 0, realBudget, source, @@ -360,7 +352,7 @@ public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); if (!aNBT.hasKey(BATCH_MODE_NBT_KEY)) { - batchMode = aNBT.getBoolean("mUseMultiparallelMode"); + this.batchMode = aNBT.getBoolean("mUseMultiparallelMode"); } } @@ -368,8 +360,8 @@ public void loadNBTData(NBTTagCompound aNBT) { public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aPlayer.isSneaking()) { - batchMode = !batchMode; - if (batchMode) { + this.batchMode = !this.batchMode; + if (this.batchMode) { GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); } else { GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); @@ -386,16 +378,16 @@ protected ProcessingLogic createProcessingLogic() { @Override protected void addFluidOutputs(FluidStack[] mOutputFluids2) { - for (int i = 0; i < mOutputFluids2.length && i < mOutputHatchesByLayer.size(); i++) { + for (int i = 0; i < mOutputFluids2.length && i < this.mOutputHatchesByLayer.size(); i++) { FluidStack tStack = mOutputFluids2[i].copy(); - if (!dumpFluid(mOutputHatchesByLayer.get(i), tStack, true)) - dumpFluid(mOutputHatchesByLayer.get(i), tStack, false); + if (!dumpFluid(this.mOutputHatchesByLayer.get(i), tStack, true)) + dumpFluid(this.mOutputHatchesByLayer.get(i), tStack, false); } } @Override public List getFluidOutputSlots(FluidStack[] toOutput) { - return this.getFluidOutputSlotsByLayer(toOutput, mOutputHatchesByLayer); + return this.getFluidOutputSlotsByLayer(toOutput, this.mOutputHatchesByLayer); } @Override diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaMultiBlockBase.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaMultiBlockBase.java index 8850df1d3..e66604783 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaMultiBlockBase.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaMultiBlockBase.java @@ -49,7 +49,7 @@ protected String[] getExtendedInfoData() { protected long[] getCurrentInfoData() { long storedEnergy = 0, maxEnergy = 0; - for (GT_MetaTileEntity_Hatch hatch : getExoticAndNormalEnergyHatchList()) { + for (GT_MetaTileEntity_Hatch hatch : this.getExoticAndNormalEnergyHatchList()) { if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) { storedEnergy += hatch.getBaseMetaTileEntity().getStoredEU(); maxEnergy += hatch.getBaseMetaTileEntity().getEUCapacity(); @@ -68,7 +68,7 @@ public String[] getInfoData() { } } - long[] ttHatches = getCurrentInfoData(); + long[] ttHatches = this.getCurrentInfoData(); long storedEnergy = ttHatches[0]; long maxEnergy = ttHatches[1]; @@ -79,13 +79,13 @@ public String[] getInfoData() { } } - long nominalV = getMaxInputEu(); + long nominalV = this.getMaxInputEu(); String tName = BW_Util.getTierNameFromVoltage(nominalV); - if (tName.equals("MAX+")) tName = EnumChatFormatting.OBFUSCATED + "MAX+"; + if ("MAX+".equals(tName)) tName = EnumChatFormatting.OBFUSCATED + "MAX+"; - String[] extendedInfo = getExtendedInfoData(); + String[] extendedInfo = this.getExtendedInfoData(); - String[] baseInfo = new String[] { + String[] baseInfo = { StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(this.mProgresstime / 20) @@ -114,7 +114,7 @@ public String[] getInfoData() { + GT_Utility.formatNumbers(this.getMaxInputVoltage()) + EnumChatFormatting.RESET + " EU/t(*" - + GT_Utility.formatNumbers(getMaxInputAmps()) + + GT_Utility.formatNumbers(this.getMaxInputAmps()) + "A) = " + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(nominalV) @@ -131,7 +131,7 @@ public String[] getInfoData() { + StatCollector.translateToLocal("GT5U.multiblock.efficiency") + ": " + EnumChatFormatting.YELLOW - + (float) this.mEfficiency / 100.0F + + this.mEfficiency / 100.0F + EnumChatFormatting.RESET + " %", StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " @@ -171,7 +171,7 @@ public int getMaxEfficiency(ItemStack itemStack) { @Override protected void setProcessingLogicPower(ProcessingLogic logic) { - logic.setAvailableVoltage(getMaxInputEu()); + logic.setAvailableVoltage(this.getMaxInputEu()); logic.setAvailableAmperage(1); } @@ -220,7 +220,7 @@ public BlocksToPlace getBlocksToPlace(T t, World world, int x, int y, int z, Ite @Override public PlaceResult survivalPlaceBlock(T o, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) { - if (check(o, world, x, y, z)) return PlaceResult.SKIP; + if (this.check(o, world, x, y, z)) return PlaceResult.SKIP; if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, env.getActor())) return PlaceResult.REJECT; world.setBlock(x, y, z, Blocks.air, 0, 2); return PlaceResult.ACCEPT; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaOilCracker.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaOilCracker.java index 01f351014..e31b3563f 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaOilCracker.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaOilCracker.java @@ -189,52 +189,53 @@ public GT_Recipe.GT_Recipe_Map getRecipeMap() { protected ProcessingLogic createProcessingLogic() { return new ProcessingLogic() { + @Override @Nonnull public CheckRecipeResult process() { - setEuModifier(1.0F - Math.min(0.1F * (heatLevel.getTier() + 1), 0.5F)); + this.setEuModifier( + 1.0F - Math.min(0.1F * (GT_TileEntity_MegaOilCracker.this.heatLevel.getTier() + 1), 0.5F)); return super.process(); } }.setMaxParallel(ConfigHandler.megaMachinesMax); } public HeatingCoilLevel getCoilLevel() { - return heatLevel; + return this.heatLevel; } public void setCoilLevel(HeatingCoilLevel aCoilLevel) { - heatLevel = aCoilLevel; + this.heatLevel = aCoilLevel; } @Override public void construct(ItemStack aStack, boolean aHintsOnly) { - buildPiece(STRUCTURE_PIECE_MAIN, aStack, aHintsOnly, 6, 6, 0); + this.buildPiece(STRUCTURE_PIECE_MAIN, aStack, aHintsOnly, 6, 6, 0); } @Override public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; + if (this.mMachine) return -1; int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 5); - return survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 6, 6, 0, realBudget, source, actor, false, true); + return this + .survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 6, 6, 0, realBudget, source, actor, false, true); } // -------------- TEC TECH COMPAT ---------------- @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - glassTier = 0; - mInputOnSide = -1; - mOutputOnSide = -1; - mMiddleInputHatches.clear(); + this.glassTier = 0; + this.mInputOnSide = -1; + this.mOutputOnSide = -1; + this.mMiddleInputHatches.clear(); - if (!checkPiece(STRUCTURE_PIECE_MAIN, 6, 6, 0)) return false; + if (!this.checkPiece(STRUCTURE_PIECE_MAIN, 6, 6, 0) || this.mMaintenanceHatches.size() != 1) return false; - if (mMaintenanceHatches.size() != 1) return false; - - if (glassTier < 8) { - for (GT_MetaTileEntity_Hatch hatch : mExoticEnergyHatches) { + if (this.glassTier < 8) { + for (GT_MetaTileEntity_Hatch hatch : this.mExoticEnergyHatches) { if (hatch.getConnectionType() == GT_MetaTileEntity_Hatch.ConnectionType.LASER) { return false; } - if (glassTier < hatch.mTier) { + if (this.glassTier < hatch.mTier) { return false; } } @@ -252,25 +253,25 @@ private boolean addLeftHatchToMachineList(IGregTechTileEntity aTileEntity, int a return false; } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - if (mInputOnSide == 1) { + if (this.mInputOnSide == 1) { return false; } - mInputOnSide = 0; - mOutputOnSide = 1; + this.mInputOnSide = 0; + this.mOutputOnSide = 1; GT_MetaTileEntity_Hatch_Input tHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity; tHatch.updateTexture(aBaseCasingIndex); - tHatch.mRecipeMap = getRecipeMap(); - return mInputHatches.add(tHatch); + tHatch.mRecipeMap = this.getRecipeMap(); + return this.mInputHatches.add(tHatch); } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { - if (mOutputOnSide == 1) { + if (this.mOutputOnSide == 1) { return false; } - mInputOnSide = 1; - mOutputOnSide = 0; + this.mInputOnSide = 1; + this.mOutputOnSide = 0; GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) aMetaTileEntity; tHatch.updateTexture(aBaseCasingIndex); - return mOutputHatches.add(tHatch); + return this.mOutputHatches.add(tHatch); } return false; } @@ -284,25 +285,25 @@ private boolean addRightHatchToMachineList(IGregTechTileEntity aTileEntity, int return false; } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - if (mInputOnSide == 0) { + if (this.mInputOnSide == 0) { return false; } - mInputOnSide = 1; - mOutputOnSide = 0; + this.mInputOnSide = 1; + this.mOutputOnSide = 0; GT_MetaTileEntity_Hatch_Input tHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity; tHatch.updateTexture(aBaseCasingIndex); - tHatch.mRecipeMap = getRecipeMap(); - return mInputHatches.add(tHatch); + tHatch.mRecipeMap = this.getRecipeMap(); + return this.mInputHatches.add(tHatch); } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { - if (mOutputOnSide == 0) { + if (this.mOutputOnSide == 0) { return false; } - mInputOnSide = 0; - mOutputOnSide = 1; + this.mInputOnSide = 0; + this.mOutputOnSide = 1; GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) aMetaTileEntity; tHatch.updateTexture(aBaseCasingIndex); - return mOutputHatches.add(tHatch); + return this.mOutputHatches.add(tHatch); } return false; } @@ -315,11 +316,10 @@ private boolean addMiddleInputToMachineList(IGregTechTileEntity aTileEntity, int if (aMetaTileEntity == null) { return false; } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - GT_MetaTileEntity_Hatch_Input tHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input tHatch) { tHatch.updateTexture(aBaseCasingIndex); - tHatch.mRecipeMap = getRecipeMap(); - return mMiddleInputHatches.add(tHatch); + tHatch.mRecipeMap = this.getRecipeMap(); + return this.mMiddleInputHatches.add(tHatch); } return false; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java index 40d42f659..1243bae84 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java @@ -149,7 +149,7 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() { GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Vacuum Freezer").addInfo("Controller Block for the Mega Vacuum Freezer") .addInfo("Cools hot ingots and cells").addSeparator().beginStructureBlock(15, 15, 15, true) - .addController("Front center").addCasingInfo("Frost Proof Machine Casing", 900) + .addController("Front center").addCasingInfoMin("Frost Proof Machine Casing", 900, false) .addEnergyHatch("Any casing", 1).addMaintenanceHatch("Any casing", 1).addInputHatch("Any casing", 1) .addOutputHatch("Any casing", 1).addInputBus("Any casing", 1).addOutputBus("Any casing", 1) .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTWORKS); @@ -163,14 +163,15 @@ public IStructureDefinition getStructureDefinit @Override public void construct(ItemStack aStack, boolean aHintsOnly) { - buildPiece(STRUCTURE_PIECE_MAIN, aStack, aHintsOnly, 7, 7, 0); + this.buildPiece(STRUCTURE_PIECE_MAIN, aStack, aHintsOnly, 7, 7, 0); } @Override public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { - if (mMachine) return -1; + if (this.mMachine) return -1; int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 5); - return survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 7, 7, 0, realBudget, source, actor, false, true); + return this + .survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 7, 7, 0, realBudget, source, actor, false, true); } @Override @@ -182,7 +183,7 @@ public GT_Recipe.GT_Recipe_Map getRecipeMap() { public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); if (!aNBT.hasKey(BATCH_MODE_NBT_KEY)) { - batchMode = aNBT.getBoolean("mUseMultiparallelMode"); + this.batchMode = aNBT.getBoolean("mUseMultiparallelMode"); } } @@ -190,8 +191,8 @@ public void loadNBTData(NBTTagCompound aNBT) { public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aPlayer.isSneaking()) { - batchMode = !batchMode; - if (batchMode) { + this.batchMode = !this.batchMode; + if (this.batchMode) { GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); } else { GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); @@ -211,7 +212,7 @@ protected ProcessingLogic createProcessingLogic() { @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { this.mCasing = 0; - if (!checkPiece(STRUCTURE_PIECE_MAIN, 7, 7, 0)) return false; + if (!this.checkPiece(STRUCTURE_PIECE_MAIN, 7, 7, 0)) return false; return this.mMaintenanceHatches.size() == 1 && this.mCasing >= 900; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_AcidGenerator.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_AcidGenerator.java index daccb55d6..3686f5924 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_AcidGenerator.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_AcidGenerator.java @@ -60,22 +60,26 @@ public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { return new GT_MetaTileEntity_AcidGenerator(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); } + @Override public ITexture[] getFront(byte aColor) { return new ITexture[] { super.getFront(aColor)[0], TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL), Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] }; } + @Override public ITexture[] getBack(byte aColor) { return new ITexture[] { super.getBack(aColor)[0], TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_ACIDHAZARD) }; } + @Override public ITexture[] getBottom(byte aColor) { return new ITexture[] { super.getBottom(aColor)[0], TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_ACIDHAZARD) }; } + @Override public ITexture[] getTop(byte aColor) { return new ITexture[] { super.getTop(aColor)[0], TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL), @@ -86,27 +90,32 @@ public ITexture[] getTop(byte aColor) { .glow().build() }; } + @Override public ITexture[] getSides(byte aColor) { return new ITexture[] { super.getSides(aColor)[0], TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_ACIDHAZARD) }; } + @Override public ITexture[] getFrontActive(byte aColor) { return new ITexture[] { super.getFrontActive(aColor)[0], TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL), Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] }; } + @Override public ITexture[] getBackActive(byte aColor) { return new ITexture[] { super.getBackActive(aColor)[0], TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_ACIDHAZARD) }; } + @Override public ITexture[] getBottomActive(byte aColor) { return new ITexture[] { super.getBottomActive(aColor)[0], TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_ACIDHAZARD) }; } + @Override public ITexture[] getTopActive(byte aColor) { return new ITexture[] { super.getTopActive(aColor)[0], TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL), @@ -117,15 +126,18 @@ public ITexture[] getTopActive(byte aColor) { .glow().build() }; } + @Override public ITexture[] getSidesActive(byte aColor) { return new ITexture[] { super.getSidesActive(aColor)[0], TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_ACIDHAZARD) }; } + @Override public boolean isOutputFacing(ForgeDirection side) { return side == this.getBaseMetaTileEntity().getFrontFacing(); } + @Override public String[] getDescription() { return new String[] { StatCollector.translateToLocal("tooltip.tile.acidgen.0.name"), StatCollector.translateToLocal("tooltip.tile.acidgen.1.name"), diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_BioLab.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_BioLab.java index 6830042f8..4e01fca2a 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_BioLab.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_BioLab.java @@ -160,29 +160,30 @@ public int checkRecipe(boolean skipOC) { int damage = this.getSpecialSlot().getItemDamage(); switch (damage) { case DNA_EXTRACTION_MODULE: - if (GT_Utility.isStackValid(this.mInventory[getInputSlot()]) - && this.mInventory[getInputSlot()].getItem() instanceof LabParts - && this.mInventory[getInputSlot()].getItemDamage() == 0 - && this.mInventory[getInputSlot()].getTagCompound() != null + if (GT_Utility.isStackValid(this.mInventory[this.getInputSlot()]) + && this.mInventory[this.getInputSlot()].getItem() instanceof LabParts + && this.mInventory[this.getInputSlot()].getItemDamage() == 0 + && this.mInventory[this.getInputSlot()].getTagCompound() != null && // checks if it is a Culture - GT_Utility.isStackValid(this.mInventory[getInputSlot() + 1]) - && this.mInventory[getInputSlot() + 1].getItem() instanceof LabParts - && this.mInventory[getInputSlot() + 1].getItemDamage() == 1 - && this.mInventory[getInputSlot() + 1].getTagCompound() == null - && GT_Utility.isStackValid(this.mInventory[getInputSlot() + 2]) - && this.mInventory[getInputSlot() + 2].getItem() instanceof LabParts - && this.mInventory[getInputSlot() + 2].getItemDamage() == 3 - && GT_Utility - .areStacksEqual(this.mInventory[getInputSlot() + 3], Materials.Ethanol.getCells(1)) + GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 1]) + && this.mInventory[this.getInputSlot() + 1].getItem() instanceof LabParts + && this.mInventory[this.getInputSlot() + 1].getItemDamage() == 1 + && this.mInventory[this.getInputSlot() + 1].getTagCompound() == null + && GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 2]) + && this.mInventory[this.getInputSlot() + 2].getItem() instanceof LabParts + && this.mInventory[this.getInputSlot() + 2].getItemDamage() == 3 + && GT_Utility.areStacksEqual( + this.mInventory[this.getInputSlot() + 3], + Materials.Ethanol.getCells(1)) && this.mFluid != null && this.mFluid.isFluidEqual(FluidRegistry.getFluidStack("ic2distilledwater", 1000)) && this.mFluid.amount >= 1000) { - NBTTagCompound DNABioDataTag = this.mInventory[getInputSlot()].getTagCompound() + NBTTagCompound DNABioDataTag = this.mInventory[this.getInputSlot()].getTagCompound() .getCompoundTag("DNA"); if (DNABioDataTag == null) return super.checkRecipe(skipOC); BioData cultureDNABioData = BioData.getBioDataFromName( - this.mInventory[getInputSlot()].getTagCompound().getCompoundTag("DNA") + this.mInventory[this.getInputSlot()].getTagCompound().getCompoundTag("DNA") .getString("Name")); if (cultureDNABioData == null) return super.checkRecipe(skipOC); @@ -190,8 +191,8 @@ public int checkRecipe(boolean skipOC) { return GT_MetaTileEntity_BasicMachine.FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; for (int i = 0; i < 4; i++) { - if (this.mInventory[getInputSlot() + i] != null) - this.mInventory[getInputSlot() + i].stackSize--; + if (this.mInventory[this.getInputSlot() + i] != null) + this.mInventory[this.getInputSlot() + i].stackSize--; } this.mFluid.amount -= 1000; @@ -209,26 +210,27 @@ public int checkRecipe(boolean skipOC) { } break; case PCR_THERMOCYCLE_MODULE: { - if (GT_Utility.isStackValid(this.mInventory[getInputSlot()]) - && this.mInventory[getInputSlot()].getItem() instanceof LabParts - && this.mInventory[getInputSlot()].getItemDamage() == 1 - && this.mInventory[getInputSlot()].getTagCompound() != null + if (GT_Utility.isStackValid(this.mInventory[this.getInputSlot()]) + && this.mInventory[this.getInputSlot()].getItem() instanceof LabParts + && this.mInventory[this.getInputSlot()].getItemDamage() == 1 + && this.mInventory[this.getInputSlot()].getTagCompound() != null && // checks if it is a Culture - GT_Utility.isStackValid(this.mInventory[getInputSlot() + 3]) - && GT_Utility - .areStacksEqual(this.mInventory[getInputSlot() + 3], ItemList.Tool_DataOrb.get(1L)) - && GT_Utility.isStackValid(this.mInventory[getInputSlot() + 1]) + GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 3]) && GT_Utility.areStacksEqual( - this.mInventory[getInputSlot() + 1], + this.mInventory[this.getInputSlot() + 3], + ItemList.Tool_DataOrb.get(1L)) + && GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 1]) + && GT_Utility.areStacksEqual( + this.mInventory[this.getInputSlot() + 1], FluidLoader.BioLabFluidCells[0]) - && GT_Utility.isStackValid(this.mInventory[getInputSlot() + 2]) + && GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 2]) && GT_Utility.areStacksEqual( - this.mInventory[getInputSlot() + 2], + this.mInventory[this.getInputSlot() + 2], FluidLoader.BioLabFluidCells[3]) && this.mFluid != null && this.mFluid.isFluidEqual(dnaFluid) && this.mFluid.amount >= 1000) { - NBTTagCompound DNABioDataTag = this.mInventory[getInputSlot()].getTagCompound(); + NBTTagCompound DNABioDataTag = this.mInventory[this.getInputSlot()].getTagCompound(); if (DNABioDataTag == null) return super.checkRecipe(skipOC); BioData cultureDNABioData = BioData.getBioDataFromName(DNABioDataTag.getString("Name")); if (cultureDNABioData == null) return super.checkRecipe(skipOC); @@ -237,8 +239,8 @@ public int checkRecipe(boolean skipOC) { return GT_MetaTileEntity_BasicMachine.FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; for (int i = 0; i < 4; i++) { - if (this.mInventory[getInputSlot() + i] != null) - this.mInventory[getInputSlot() + i].stackSize--; + if (this.mInventory[this.getInputSlot() + i] != null) + this.mInventory[this.getInputSlot() + i].stackSize--; } this.mFluid.amount -= 1000; @@ -264,34 +266,38 @@ public int checkRecipe(boolean skipOC) { ItemStack inp2 = ItemList.Tool_DataOrb.get(1L); Behaviour_DataOrb.setDataTitle(inp2, "DNA Sample"); Behaviour_DataOrb.setDataName(inp2, BioCultureLoader.BIO_DATA_BETA_LACMATASE.getName()); - if (GT_Utility.isStackValid(this.mInventory[getInputSlot()]) - && GT_Utility - .areStacksEqual(FluidLoader.BioLabFluidCells[1], this.mInventory[getInputSlot()]) - && // checks if it is a Culture - GT_Utility.isStackValid(this.mInventory[getInputSlot() + 1]) + if (GT_Utility.isStackValid(this.mInventory[this.getInputSlot()]) && GT_Utility + .areStacksEqual(FluidLoader.BioLabFluidCells[1], this.mInventory[this.getInputSlot()]) && // checks + // if + // it + // is + // a + // Culture + GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 1]) && GT_Utility.areStacksEqual( - this.mInventory[getInputSlot() + 1], + this.mInventory[this.getInputSlot() + 1], BioItemList.getPlasmidCell(null)) - && GT_Utility.isStackValid(this.mInventory[getInputSlot() + 2]) + && GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 2]) && GT_Utility.areStacksEqual( - this.mInventory[getInputSlot() + 2], + this.mInventory[this.getInputSlot() + 2], ItemList.Tool_DataOrb.get(1L), true) - && Behaviour_DataOrb.getDataTitle(this.mInventory[getInputSlot() + 2]).equals("DNA Sample") - && (!(Behaviour_DataOrb.getDataName(this.mInventory[getInputSlot() + 2]).isEmpty())) - && GT_Utility.isStackValid(this.mInventory[getInputSlot() + 3]) - && GT_Utility.areStacksEqual(this.mInventory[getInputSlot() + 3], inp2) + && "DNA Sample" + .equals(Behaviour_DataOrb.getDataTitle(this.mInventory[this.getInputSlot() + 2])) + && !Behaviour_DataOrb.getDataName(this.mInventory[this.getInputSlot() + 2]).isEmpty() + && GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 3]) + && GT_Utility.areStacksEqual(this.mInventory[this.getInputSlot() + 3], inp2) && this.mFluid != null && this.mFluid.isFluidEqual(dnaFluid) - && (this.mFluid.amount >= 1000)) { - BioData cultureDNABioData = BioData - .getBioDataFromName(Behaviour_DataOrb.getDataName(this.mInventory[getInputSlot() + 2])); + && this.mFluid.amount >= 1000) { + BioData cultureDNABioData = BioData.getBioDataFromName( + Behaviour_DataOrb.getDataName(this.mInventory[this.getInputSlot() + 2])); if (cultureDNABioData == null) return super.checkRecipe(skipOC); if (this.mTier < 1 + rTier + cultureDNABioData.getTier()) return GT_MetaTileEntity_BasicMachine.FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; for (int i = 0; i < 2; i++) { - if (this.mInventory[getInputSlot() + i] != null) - this.mInventory[getInputSlot() + i].stackSize--; + if (this.mInventory[this.getInputSlot() + i] != null) + this.mInventory[this.getInputSlot() + i].stackSize--; } this.mFluid.amount -= 1000; if (cultureDNABioData.getChance() > new XSTR().nextInt(10000)) { @@ -307,32 +313,32 @@ public int checkRecipe(boolean skipOC) { } break; case TRANSFORMATION_MODULE: { - if (GT_Utility.isStackValid(this.mInventory[getInputSlot()]) && GT_Utility - .areStacksEqual(this.mInventory[getInputSlot()], BioItemList.getPetriDish(null), true) - && this.mInventory[getInputSlot()].getTagCompound() != null - && GT_Utility.isStackValid(this.mInventory[getInputSlot() + 1]) + if (GT_Utility.isStackValid(this.mInventory[this.getInputSlot()]) && GT_Utility + .areStacksEqual(this.mInventory[this.getInputSlot()], BioItemList.getPetriDish(null), true) + && this.mInventory[this.getInputSlot()].getTagCompound() != null + && GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 1]) && GT_Utility.areStacksEqual( - this.mInventory[getInputSlot() + 1], + this.mInventory[this.getInputSlot() + 1], BioItemList.getPlasmidCell(null), true) - && this.mInventory[getInputSlot() + 1].getTagCompound() != null - && GT_Utility.isStackValid(this.mInventory[getInputSlot() + 2]) + && this.mInventory[this.getInputSlot() + 1].getTagCompound() != null + && GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 2]) && GT_Utility.areStacksEqual( - this.mInventory[getInputSlot() + 2], + this.mInventory[this.getInputSlot() + 2], FluidLoader.BioLabFluidCells[2]) && this.mFluid != null && this.mFluid.isFluidEqual(FluidRegistry.getFluidStack("ic2distilledwater", 1000)) && this.mFluid.amount >= 1000) { BioData cultureDNABioData = BioData - .getBioDataFromNBTTag(this.mInventory[getInputSlot() + 1].getTagCompound()); + .getBioDataFromNBTTag(this.mInventory[this.getInputSlot() + 1].getTagCompound()); BioCulture bioCulture = BioCulture - .getBioCultureFromNBTTag(this.mInventory[getInputSlot()].getTagCompound()); + .getBioCultureFromNBTTag(this.mInventory[this.getInputSlot()].getTagCompound()); if (cultureDNABioData == null || bioCulture == null) return super.checkRecipe(skipOC); if (this.mTier < 3 + rTier + cultureDNABioData.getTier()) return GT_MetaTileEntity_BasicMachine.FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; for (int i = 0; i < 3; i++) { - if (this.mInventory[getInputSlot() + i] != null) - this.mInventory[getInputSlot() + i].stackSize--; + if (this.mInventory[this.getInputSlot() + i] != null) + this.mInventory[this.getInputSlot() + i].stackSize--; } this.mFluid.amount -= 1000; bioCulture = bioCulture.setPlasmid(BioPlasmid.convertDataToPlasmid(cultureDNABioData)); @@ -351,32 +357,33 @@ public int checkRecipe(boolean skipOC) { ItemStack Outp = ItemList.Tool_DataOrb.get(1L); Behaviour_DataOrb.setDataTitle(Outp, "DNA Sample"); - if (GT_Utility.isStackValid(this.mInventory[getInputSlot()]) + if (GT_Utility.isStackValid(this.mInventory[this.getInputSlot()]) && GT_Utility + .areStacksEqual(this.mInventory[this.getInputSlot()], BioItemList.getPetriDish(null)) + && GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 1]) && GT_Utility - .areStacksEqual(this.mInventory[getInputSlot()], BioItemList.getPetriDish(null)) - && GT_Utility.isStackValid(this.mInventory[getInputSlot() + 1]) - && GT_Utility.areStacksEqual(this.mInventory[getInputSlot() + 1], BioItemList.getOther(4)) - && GT_Utility.isStackValid(this.mInventory[getInputSlot() + 2]) + .areStacksEqual(this.mInventory[this.getInputSlot() + 1], BioItemList.getOther(4)) + && GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 2]) && GT_Utility.areStacksEqual( - this.mInventory[getInputSlot() + 2], + this.mInventory[this.getInputSlot() + 2], ItemList.Circuit_Chip_Stemcell.get(2L)) - && GT_Utility.isStackValid(this.mInventory[getInputSlot() + 3]) + && GT_Utility.isStackValid(this.mInventory[this.getInputSlot() + 3]) && GT_Utility.areStacksEqual( - this.mInventory[getInputSlot() + 3], + this.mInventory[this.getInputSlot() + 3], ItemList.Tool_DataOrb.get(1L), true) - && Behaviour_DataOrb.getDataTitle(this.mInventory[getInputSlot() + 3]).equals("DNA Sample") + && "DNA Sample" + .equals(Behaviour_DataOrb.getDataTitle(this.mInventory[this.getInputSlot() + 3])) && this.mFluid.isFluidEqual(dnaFluid) - && (this.mFluid.amount >= 8000)) { + && this.mFluid.amount >= 8000) { - BioData cultureDNABioData = BioData - .getBioDataFromName(Behaviour_DataOrb.getDataName(this.mInventory[getInputSlot() + 3])); + BioData cultureDNABioData = BioData.getBioDataFromName( + Behaviour_DataOrb.getDataName(this.mInventory[this.getInputSlot() + 3])); if (cultureDNABioData == null) return super.checkRecipe(skipOC); if (this.mTier < 3 + rTier + cultureDNABioData.getTier()) return GT_MetaTileEntity_BasicMachine.FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; for (int i = 0; i < 3; i++) { - if (this.mInventory[getInputSlot() + i] != null) - this.mInventory[getInputSlot() + i].stackSize--; + if (this.mInventory[this.getInputSlot() + i] != null) + this.mInventory[this.getInputSlot() + i].stackSize--; } this.mFluid.amount -= 8000; if (cultureDNABioData.getChance() > new XSTR().nextInt(10000)) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Diode.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Diode.java index 2f4811270..059799915 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Diode.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Diode.java @@ -63,12 +63,11 @@ public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, f if (!aPlayer.isSneaking()) { --this.aAmps; if (this.aAmps < 0) this.aAmps = this.maxAmps; - GT_Utility.sendChatToPlayer(aPlayer, "Max Amps: " + this.aAmps); } else { ++this.aAmps; if (this.aAmps > this.maxAmps) this.aAmps = 0; - GT_Utility.sendChatToPlayer(aPlayer, "Max Amps: " + this.aAmps); } + GT_Utility.sendChatToPlayer(aPlayer, "Max Amps: " + this.aAmps); } @Override @@ -104,7 +103,7 @@ private long getAmpsfromMeta(int meta) { if (meta > ConfigHandler.IDOffset + GT_Values.VN.length && meta <= ConfigHandler.IDOffset + GT_Values.VN.length * 2) return 2L; - else if (meta > ConfigHandler.IDOffset + GT_Values.VN.length * 2 + if (meta > ConfigHandler.IDOffset + GT_Values.VN.length * 2 && meta <= ConfigHandler.IDOffset + GT_Values.VN.length * 3) return 4L; else if (meta > ConfigHandler.IDOffset + GT_Values.VN.length * 3 @@ -119,6 +118,8 @@ else if (meta > ConfigHandler.IDOffset + GT_Values.VN.length * 5 else return 0L; } + @Override + @SuppressWarnings("deprecation") public String[] getDescription() { return ArrayUtils.addAll( this.mDescriptionArray, diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_EnergyDistributor.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_EnergyDistributor.java index f2345fce0..167a3a475 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_EnergyDistributor.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_EnergyDistributor.java @@ -40,31 +40,37 @@ public GT_MetaTileEntity_EnergyDistributor(String aName, int aTier, String[] aDe super(aName, aTier, aDescription, aTextures); } + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_EnergyDistributor(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); } + @Override public long maxEUInput() { return GT_Values.V[this.mTier]; } + @Override public long maxEUOutput() { return GT_Values.V[this.mTier]; } + @Override public long maxAmperesOut() { return 320; } + @Override public long maxAmperesIn() { return 320; } @Override public long maxEUStore() { - return 512L + (GT_Values.V[this.mTier] * 320L); + return 512L + GT_Values.V[this.mTier] * 320L; } + @Override public String[] getDescription() { return new String[] { StatCollector.translateToLocal("tooltip.tile.energydistributor.0.name"), StatCollector.translateToLocal("tooltip.tile.tiereddsc.0.name") + " " diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java index f709ece0b..33589f45f 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java @@ -90,7 +90,7 @@ public GT_MetaTileEntity_RadioHatch(int aID, String aName, String aNameRegional, StatCollector.translateToLocal("tooltip.tile.tiereddsc.3.name") + " " + (aTier - 2) + " " - + ((aTier - 2) >= 2 ? StatCollector.translateToLocal("tooltip.bw.kg.1.name") + + (aTier - 2 >= 2 ? StatCollector.translateToLocal("tooltip.bw.kg.1.name") : StatCollector.translateToLocal("tooltip.bw.kg.0.name")), StatCollector.translateToLocal("tooltip.tile.radhatch.1.name"), BW_Tooltip_Reference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get() }); @@ -108,12 +108,12 @@ public GT_MetaTileEntity_RadioHatch(String aName, int aTier, String[] aDescripti } public int getSievert() { - return this.sievert - MathUtils.ceilInt((float) this.sievert / 100f * (float) this.coverage); + return this.sievert - MathUtils.ceilInt(this.sievert / 100f * this.coverage); } public short[] getColorForGUI() { if (this.colorForGUI != null) return this.colorForGUI; - return colorForGUI = new short[] { 0xFA, 0xFA, 0xFF }; + return this.colorForGUI = new short[] { 0xFA, 0xFA, 0xFF }; } public byte getMass() { @@ -159,29 +159,26 @@ public void updateSlots() { @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - BaseMetaTileEntity myMetaTileEntity = ((BaseMetaTileEntity) this.getBaseMetaTileEntity()); + BaseMetaTileEntity myMetaTileEntity = (BaseMetaTileEntity) this.getBaseMetaTileEntity(); if (myMetaTileEntity.isServerSide()) { if (this.mass > 0) { ++this.timer; } - if (this.mass > 0) { - if (this.decayTime == 0 || (this.decayTime > 0 && this.timer % this.decayTime == 0)) { - this.mass--; - if (this.mass == 0) { - this.material = StatCollector.translateToLocal("tooltip.bw.empty.name"); - this.sievert = 0; - } - this.timer = 1; + if (this.mass > 0 && (this.decayTime == 0 || this.decayTime > 0 && this.timer % this.decayTime == 0)) { + this.mass--; + if (this.mass == 0) { + this.material = StatCollector.translateToLocal("tooltip.bw.empty.name"); + this.sievert = 0; } + this.timer = 1; } - if (myMetaTileEntity.mTickTimer > (myMetaTileEntity.mLastSoundTick + ticksBetweenSounds)) { - if (this.sievert > 0) { - sendLoopStart((byte) 1); - myMetaTileEntity.mLastSoundTick = myMetaTileEntity.mTickTimer; - } + if (myMetaTileEntity.mTickTimer > myMetaTileEntity.mLastSoundTick + ticksBetweenSounds + && this.sievert > 0) { + this.sendLoopStart((byte) 1); + myMetaTileEntity.mLastSoundTick = myMetaTileEntity.mTickTimer; } if (this.mass == 0) { @@ -190,14 +187,13 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { if (lStack == null) { this.colorForGUI = new short[] { 0x37, 0x37, 0x37 }; return; + } + ItemData itemData = GT_OreDictUnificator.getAssociation(lStack); + if (itemData != null) { + Materials mat = itemData.mMaterial.mMaterial; + this.colorForGUI = new short[] { mat.getRGBA()[0], mat.getRGBA()[1], mat.getRGBA()[2] }; } else { - ItemData itemData = GT_OreDictUnificator.getAssociation(lStack); - if (itemData != null) { - Materials mat = itemData.mMaterial.mMaterial; - this.colorForGUI = new short[] { mat.getRGBA()[0], mat.getRGBA()[1], mat.getRGBA()[2] }; - } else { - this.colorForGUI = new short[] { 0x37, 0x37, 0x37 }; - } + this.colorForGUI = new short[] { 0x37, 0x37, 0x37 }; } if (this.lastFail && GT_Utility.areStacksEqual(this.lastUsedItem, lStack, true)) { @@ -211,7 +207,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { this.sievert = this.lastRecipe.mEUt; this.material = this.lastUsedItem.getDisplayName(); lStack.stackSize--; - updateSlots(); + this.updateSlots(); } else { this.lastRecipe = null; } @@ -223,7 +219,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { false, Integer.MAX_VALUE - 7, null, - mInventory[0]); + this.mInventory[0]); if (this.lastRecipe == null) { this.lastFail = true; this.lastUsedItem = this.mInventory[0] == null ? null : this.mInventory[0].copy(); @@ -240,7 +236,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { this.sievert = this.lastRecipe.mEUt; this.material = lStack.getDisplayName(); lStack.stackSize--; - updateSlots(); + this.updateSlots(); } } } @@ -271,7 +267,7 @@ public String[] getInfoData() { + "/" + (this.decayTime - this.timer % this.decayTime) / 20 / 60 / 60 + StatCollector.translateToLocal("tooltip.tile.radhatch.9.name") }; - else return new String[] { + return new String[] { StatCollector.translateToLocal("tooltip.tile.radhatch.2.name") + " " + StatCollector.translateToLocal("tooltip.bw.empty.name"), StatCollector.translateToLocal("tooltip.tile.radhatch.3.name") + " " + "0", @@ -283,6 +279,7 @@ public boolean isSimpleMachine() { return true; } + @Override public boolean isFacingValid(ForgeDirection facing) { return true; } @@ -349,12 +346,12 @@ public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { buildContext.addSyncedWindow(RADIATION_SHUTTER_WINDOW_ID, this::createShutterWindow); - getBaseMetaTileEntity().add1by1Slot(builder); + this.getBaseMetaTileEntity().add1by1Slot(builder); builder.widget( new DrawableWidget().setBackground(BW_UITextures.PICTURE_SIEVERT_CONTAINER).setPos(61, 9) .setSize(56, 24)) .widget( - new ProgressBar().setProgress(() -> getSievert() / 148f).setDirection(Direction.RIGHT) + new ProgressBar().setProgress(() -> this.getSievert() / 148f).setDirection(Direction.RIGHT) .setTexture(BW_UITextures.PROGRESSBAR_SIEVERT, 24).setPos(65, 13).setSize(48, 16)) .widget( new DrawableWidget().setBackground(BW_UITextures.PICTURE_DECAY_TIME_INSIDE).setPos(124, 18) @@ -363,9 +360,19 @@ public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildCont @Override public void draw(float partialTicks) { - if (decayTime > 0) { - int height = MathUtils.ceilInt(48 * ((decayTime - timer % decayTime) / (float) decayTime)); - new Rectangle().setColor(Color.argb(colorForGUI[0], colorForGUI[1], colorForGUI[2], 255)) + if (GT_MetaTileEntity_RadioHatch.this.decayTime > 0) { + int height = MathUtils.ceilInt( + 48 * ((GT_MetaTileEntity_RadioHatch.this.decayTime + - GT_MetaTileEntity_RadioHatch.this.timer + % GT_MetaTileEntity_RadioHatch.this.decayTime) + / (float) GT_MetaTileEntity_RadioHatch.this.decayTime)); + new Rectangle() + .setColor( + Color.argb( + GT_MetaTileEntity_RadioHatch.this.colorForGUI[0], + GT_MetaTileEntity_RadioHatch.this.colorForGUI[1], + GT_MetaTileEntity_RadioHatch.this.colorForGUI[2], + 255)) .draw(new Pos2d(0, 48 - height), new Size(16, height), partialTicks); } } @@ -373,32 +380,31 @@ public void draw(float partialTicks) { () -> Collections.singletonList( StatCollector.translateToLocalFormatted( "tooltip.tile.radhatch.10.name", - timer <= 1 ? 0 : (decayTime - timer) / 20, - timer <= 1 ? 0 : decayTime / 20))) + this.timer <= 1 ? 0 : (this.decayTime - this.timer) / 20, + this.timer <= 1 ? 0 : this.decayTime / 20))) .setPos(124, 18).setSize(16, 48) .attachSyncer( - new FakeSyncWidget.LongSyncer(() -> decayTime, val -> decayTime = val), + new FakeSyncWidget.LongSyncer(() -> this.decayTime, val -> this.decayTime = val), builder, (widget, val) -> widget.notifyTooltipChange()) .attachSyncer( - new FakeSyncWidget.LongSyncer(() -> timer, val -> timer = val), + new FakeSyncWidget.LongSyncer(() -> this.timer, val -> this.timer = val), builder, (widget, val) -> widget.notifyTooltipChange())) - .widget(new FakeSyncWidget.ShortSyncer(() -> colorForGUI[0], val -> colorForGUI[0] = val)) - .widget(new FakeSyncWidget.ShortSyncer(() -> colorForGUI[1], val -> colorForGUI[1] = val)) - .widget(new FakeSyncWidget.ShortSyncer(() -> colorForGUI[2], val -> colorForGUI[2] = val)) + .widget(new FakeSyncWidget.ShortSyncer(() -> this.colorForGUI[0], val -> this.colorForGUI[0] = val)) + .widget(new FakeSyncWidget.ShortSyncer(() -> this.colorForGUI[1], val -> this.colorForGUI[1] = val)) + .widget(new FakeSyncWidget.ShortSyncer(() -> this.colorForGUI[2], val -> this.colorForGUI[2] = val)) .widget( new DrawableWidget().setBackground(BW_UITextures.PICTURE_DECAY_TIME_CONTAINER).setPos(120, 14) .setSize(24, 56)) .widget( TextWidget.dynamicString( - () -> StatCollector.translateToLocalFormatted("BW.NEI.display.radhatch.1", mass)) + () -> StatCollector.translateToLocalFormatted("BW.NEI.display.radhatch.1", this.mass)) .setTextAlignment(Alignment.Center).setPos(65, 62)) .widget( - TextWidget - .dynamicString( - () -> StatCollector - .translateToLocalFormatted("BW.NEI.display.radhatch.0", getSievert())) + TextWidget.dynamicString( + () -> StatCollector + .translateToLocalFormatted("BW.NEI.display.radhatch.0", this.getSievert())) .setTextAlignment(Alignment.Center).setPos(60, 72)) .widget(new ButtonWidget().setOnClick((clickData, widget) -> { if (!widget.isClient()) { @@ -416,25 +422,26 @@ public void draw(float partialTicks) { private ModularWindow createShutterWindow(EntityPlayer player) { ModularWindow.Builder builder = ModularWindow.builder(176, 107); builder.setBackground(ModularUITextures.VANILLA_BACKGROUND); - builder.setGuiTint(getGUIColorization()); + builder.setGuiTint(this.getGUIColorization()); - builder.widget(new TextWidget("Radiation Shutter Control").setDefaultColor(COLOR_TITLE.get()).setPos(10, 9)) + builder.widget( + new TextWidget("Radiation Shutter Control").setDefaultColor(this.COLOR_TITLE.get()).setPos(10, 9)) .widget( new DrawableWidget().setDrawable(BW_UITextures.PICTURE_RADIATION_SHUTTER_FRAME).setPos(14, 27) .setSize(55, 54)) .widget( - new DrawableWidget() - .setDrawable( - () -> coverage < 100 ? BW_UITextures.PICTURE_RADIATION_SHUTTER_INSIDE : null) + new DrawableWidget().setDrawable( + () -> this.coverage < 100 ? BW_UITextures.PICTURE_RADIATION_SHUTTER_INSIDE : null) .setPos(16, 29).setSize(51, 50).attachSyncer( new FakeSyncWidget.ByteSyncer(this::getCoverage, this::setCoverage), builder, - (widget, val) -> widget.setPos(16, 29 + coverage / 2) - .setSize(51, 50 - coverage / 2))) + (widget, val) -> widget.setPos(16, 29 + this.coverage / 2) + .setSize(51, 50 - this.coverage / 2))) .widget( - new TextFieldWidget().setSetterInt(val -> coverage = val.byteValue()) - .setGetterInt(() -> (int) coverage).setNumbers(0, 100).setTextColor(Color.WHITE.dark(1)) - .setOnScrollNumbers(1, 5, 50).setTextAlignment(Alignment.CenterLeft) + new TextFieldWidget().setSetterInt(val -> this.coverage = val.byteValue()) + .setGetterInt(() -> (int) this.coverage).setNumbers(0, 100) + .setTextColor(Color.WHITE.dark(1)).setOnScrollNumbers(1, 5, 50) + .setTextAlignment(Alignment.CenterLeft) .setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD.withOffset(-1, -1, 2, 2)) .setPos(86, 27).setSize(30, 12)) .widget(ButtonWidget.closeWindowButton(true).setPos(176 - 15, 3)); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Transistor.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Transistor.java index dc41d12cf..51a73c153 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Transistor.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Transistor.java @@ -90,21 +90,18 @@ public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { @Override public void saveNBTData(NBTTagCompound nbtTagCompound) {} + @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()) { final ForgeDirection side = ForgeDirection.EAST; if (aBaseMetaTileEntity.inputEnergyFrom(side)) { TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(side); - if (!(tTileEntity instanceof IBasicEnergyContainer)) { - this.powered = false; - return; - } - IBasicEnergyContainer tileAtSide = (IBasicEnergyContainer) tTileEntity; - if (!tileAtSide.outputsEnergyTo(ForgeDirection.WEST) || !tileAtSide.isUniversalEnergyStored(4L)) { + if (!(tTileEntity instanceof IBasicEnergyContainer tileAtSide)) { this.powered = false; return; } - if (!tileAtSide.decreaseStoredEnergyUnits(4, false)) { + if (!tileAtSide.outputsEnergyTo(ForgeDirection.WEST) || !tileAtSide.isUniversalEnergyStored(4L) + || !tileAtSide.decreaseStoredEnergyUnits(4, false)) { this.powered = false; return; } @@ -117,6 +114,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { } } + @Override public long maxEUInput() { return GT_Values.V[this.mTier]; } @@ -131,6 +129,7 @@ public long maxAmperesOut() { return this.powered ? 1L : 0; } + @Override public long maxEUOutput() { return this.powered ? GT_Values.V[this.mTier] : 0; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioLabHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioLabHandler.java index 3113991fd..bcac09fde 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioLabHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioLabHandler.java @@ -40,16 +40,18 @@ public BW_NEI_BioLabHandler(GT_Recipe.GT_Recipe_Map aRecipeMap) { } } + @Override public TemplateRecipeHandler newInstance() { return new BW_NEI_BioLabHandler(this.mRecipeMap); } + @Override public void loadCraftingRecipes(ItemStack aResult) { if (aResult != null && aResult.getItem() instanceof LabParts && aResult.getItemDamage() < 3 && aResult.getTagCompound() != null) { - for (CachedDefaultRecipe recipe : getCache()) - if (NEI_BW_Config.checkRecipe(aResult, recipe.mOutputs)) arecipes.add(recipe); + for (CachedDefaultRecipe recipe : this.getCache()) + if (NEI_BW_Config.checkRecipe(aResult, recipe.mOutputs)) this.arecipes.add(recipe); } else { super.loadCraftingRecipes(aResult); } @@ -60,8 +62,8 @@ public void loadUsageRecipes(ItemStack aResult) { if (aResult != null && aResult.getItem() instanceof LabParts && aResult.getItemDamage() < 3 && aResult.getTagCompound() != null) { - for (CachedDefaultRecipe recipe : getCache()) - if (NEI_BW_Config.checkRecipe(aResult, recipe.mInputs)) arecipes.add(recipe); + for (CachedDefaultRecipe recipe : this.getCache()) + if (NEI_BW_Config.checkRecipe(aResult, recipe.mInputs)) this.arecipes.add(recipe); } else { super.loadUsageRecipes(aResult); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioVatHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioVatHandler.java index e377a5d91..a7b170961 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioVatHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioVatHandler.java @@ -49,13 +49,13 @@ public TemplateRecipeHandler newInstance() { } private void loadLabPartRecipes(ItemStack aResult) { - for (CachedDefaultRecipe recipe : getCache()) { + for (CachedDefaultRecipe recipe : this.getCache()) { // dirty way of finding the special slot item // see constructor of CachedDefaultRecipe on why relx==120 and rely==52 means special slot for (PositionedStack stack : recipe.mInputs) { - if (stack.relx == 120 && stack.rely == 52) { - if (NEI_BW_Config.checkRecipe(aResult, Collections.singletonList(stack))) arecipes.add(recipe); - } + if (stack.relx == 120 && stack.rely == 52 + && NEI_BW_Config.checkRecipe(aResult, Collections.singletonList(stack))) + this.arecipes.add(recipe); } } } @@ -65,7 +65,7 @@ public void loadUsageRecipes(ItemStack aResult) { if (aResult != null && aResult.getItem() instanceof LabParts && aResult.getItemDamage() < 3 && aResult.getTagCompound() != null) { - loadLabPartRecipes(aResult); + this.loadLabPartRecipes(aResult); } else { super.loadUsageRecipes(aResult); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java index ad99e5062..703074d07 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java @@ -69,7 +69,7 @@ public int recipiesPerPage() { @Override public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equalsIgnoreCase("quickanddirtyneihandler")) { + if ("quickanddirtyneihandler".equalsIgnoreCase(outputId)) { HashSet result = new HashSet<>(); Werkstoff.werkstoffHashSet.stream().filter(w -> w.hasGenerationFeature(OrePrefixes.ore)) .forEach(w -> result.add(w.get(OrePrefixes.ore))); @@ -83,7 +83,7 @@ public void loadCraftingRecipes(String outputId, Object... results) { this.arecipes.clear(); this.arecipes.addAll(hashSet); } - if (outputId.equals("item")) { + if ("item".equals(outputId)) { this.loadCraftingRecipes((ItemStack) results[0]); HashSet hashSet = new HashSet<>(this.arecipes); this.arecipes.clear(); @@ -93,7 +93,7 @@ public void loadCraftingRecipes(String outputId, Object... results) { @Override public void drawExtras(int recipe) { - if ((recipe < this.arecipes.size()) && (this.arecipes.get(recipe) instanceof CachedOreRecipe)) { + if (recipe < this.arecipes.size() && this.arecipes.get(recipe) instanceof CachedOreRecipe) { CachedOreRecipe cachedOreRecipe = (CachedOreRecipe) this.arecipes.get(recipe); if (cachedOreRecipe == null || cachedOreRecipe.getOtherStacks() == null @@ -131,11 +131,9 @@ public void drawExtras(int recipe) { GuiDraw.drawString(cachedOreRecipe.getOtherStacks().get(2).item.getDisplayName(), 0, 100, 0, false); GuiDraw.drawString(ChatColorHelper.BOLD + "Sporadic:", 0, 110, 0, false); GuiDraw.drawString(cachedOreRecipe.getOtherStacks().get(3).item.getDisplayName(), 0, 120, 0, false); - } else { - if (cachedOreRecipe.worldGen != null) { - GuiDraw.drawString(ChatColorHelper.BOLD + "Amount per Chunk:", 0, 70, 0, false); - GuiDraw.drawString(cachedOreRecipe.worldGen.mDensity + "", 0, 80, 0, false); - } + } else if (cachedOreRecipe.worldGen != null) { + GuiDraw.drawString(ChatColorHelper.BOLD + "Amount per Chunk:", 0, 70, 0, false); + GuiDraw.drawString(cachedOreRecipe.worldGen.mDensity + "", 0, 80, 0, false); } } super.drawExtras(recipe); @@ -145,11 +143,9 @@ public void drawExtras(int recipe) { public void loadCraftingRecipes(ItemStack result) { Block ore = Block.getBlockFromItem(result.getItem()); if (ore instanceof BW_MetaGenerated_Ores) { - BW_OreLayer.NEIMAP.get((short) result.getItemDamage()).stream() - .filter( - l -> !(ore instanceof BW_MetaGenerated_SmallOres) - || !(l.getClass().equals(BW_WorldGenRoss128b.class) - || l.getClass().equals(BW_WorldGenRoss128ba.class))) + BW_OreLayer.NEIMAP.get((short) result.getItemDamage()).stream().filter( + l -> !(ore instanceof BW_MetaGenerated_SmallOres) || !l.getClass().equals(BW_WorldGenRoss128b.class) + && !l.getClass().equals(BW_WorldGenRoss128ba.class)) .forEach( l -> this.arecipes .add(new CachedOreRecipe(l, result, ore instanceof BW_MetaGenerated_SmallOres))); @@ -187,9 +183,9 @@ public PositionedStack getResult() { public List getOtherStacks() { List ret = new ArrayList<>(); int x = 0; - for (int i = 0; i < (small ? 1 : 4); i++) { + for (int i = 0; i < (this.small ? 1 : 4); i++) { x += 20; - ret.add(new PositionedStack(worldGen.getStacks().get(i), x, 12)); + ret.add(new PositionedStack(this.worldGen.getStacks().get(i), x, 12)); } return ret; } @@ -197,14 +193,13 @@ public List getOtherStacks() { @Override public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof CachedOreRecipe)) return false; - CachedOreRecipe that = (CachedOreRecipe) o; - return Objects.equals(worldGen, that.worldGen); + if (!(o instanceof CachedOreRecipe that)) return false; + return Objects.equals(this.worldGen, that.worldGen); } @Override public int hashCode() { - return worldGen.hashCode(); + return this.worldGen.hashCode(); } } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/server/EventHandler/ServerEventHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/server/EventHandler/ServerEventHandler.java index 723199551..744594682 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/server/EventHandler/ServerEventHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/server/EventHandler/ServerEventHandler.java @@ -45,9 +45,9 @@ public void EntityJoinWorldEvent(EntityJoinWorldEvent event) { // FMLCommonHandler.instance().bus() @SubscribeEvent(priority = EventPriority.HIGHEST) public void onPlayerTickEventServer(TickEvent.PlayerTickEvent event) { - if (event == null || !(event.player instanceof EntityPlayerMP)) return; - - if (event.player.worldObj.getTotalWorldTime() % 20 != 0) return; + if (event == null || !(event.player instanceof EntityPlayerMP) + || event.player.worldObj.getTotalWorldTime() % 20 != 0) + return; boolean replace = false; ItemStack toReplace = null; @@ -70,17 +70,16 @@ public void onPlayerTickEventServer(TickEvent.PlayerTickEvent event) { } toReplace = GT_OreDictUnificator.get(prefixes, e.getVarName(), stack.stackSize); break loop; - } else { - for (String s : e.getADDITIONAL_OREDICT()) { - if (oreDictName.contains(s)) { - String prefix = oreDictName.replace(s, ""); - OrePrefixes prefixes = OrePrefixes.getPrefix(prefix); - if (prefixes == null) { - continue; - } - toReplace = GT_OreDictUnificator.get(prefixes, e.getVarName(), stack.stackSize); - break loop; + } + for (String s : e.getADDITIONAL_OREDICT()) { + if (oreDictName.contains(s)) { + String prefix = oreDictName.replace(s, ""); + OrePrefixes prefixes = OrePrefixes.getPrefix(prefix); + if (prefixes == null) { + continue; } + toReplace = GT_OreDictUnificator.get(prefixes, e.getVarName(), stack.stackSize); + break loop; } } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlock_Item.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlock_Item.java index 651bf9804..24402ac36 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlock_Item.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlock_Item.java @@ -37,38 +37,37 @@ public BW_MetaGeneratedBlock_Item(Block par1) { super(par1); } + @Override public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { return false; } + @Override public String getUnlocalizedName(ItemStack aStack) { return this.field_150939_a.getUnlocalizedName() + "." + this.getDamage(aStack); } + @Override public String getItemStackDisplayName(ItemStack aStack) { Block block = Block.getBlockFromItem(aStack.getItem()); - if (block != null) { - if (block instanceof BW_MetaGenerated_Blocks) { - int aMetaData = aStack.getItemDamage(); - Werkstoff werkstoff = werkstoffHashMap.get((short) aMetaData); - if (werkstoff == null) werkstoff = Werkstoff.default_null_Werkstoff; - return ((BW_MetaGenerated_Blocks) block).blockTypeLocalizedName - .replace("%material", werkstoff.getLocalizedName()); - } + if (block instanceof BW_MetaGenerated_Blocks metaBlock) { + int aMetaData = aStack.getItemDamage(); + Werkstoff werkstoff = werkstoffHashMap.get((short) aMetaData); + if (werkstoff == null) werkstoff = Werkstoff.default_null_Werkstoff; + return metaBlock.blockTypeLocalizedName.replace("%material", werkstoff.getLocalizedName()); } - return GT_LanguageManager.getTranslation(getUnlocalizedName(aStack) + ".name"); + return GT_LanguageManager.getTranslation(this.getUnlocalizedName(aStack) + ".name"); } @Override @SideOnly(Side.CLIENT) - @SuppressWarnings("unchecked") - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { if (!GT_Utility.isStackValid(aStack) || aPlayer == null || aStack.getItemDamage() <= 0) { return; } if (aList == null) { - aList = new ArrayList(); + aList = new ArrayList<>(); } Werkstoff werkstoff = Werkstoff.werkstoffHashMap.get((short) aStack.getItemDamage()); if (werkstoff != null) { @@ -88,6 +87,7 @@ public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, b } } + @Override public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side, float hitX, float hitY, float hitZ, int aMeta) { short tDamage = (short) this.getDamage(aStack); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_Casing.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_Casing.java index ca8b06151..fef152ec4 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_Casing.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_Casing.java @@ -83,18 +83,17 @@ protected void doRegistrationStuff(Werkstoff tMaterial) { @Override public String getUnlocalizedName() { - if (_prefixes == OrePrefixes.blockCasing) return "bw.werkstoffblockscasing.01"; - else if (_prefixes == OrePrefixes.blockCasingAdvanced) return "bw.werkstoffblockscasingadvanced.01"; + if (this._prefixes == OrePrefixes.blockCasing) return "bw.werkstoffblockscasing.01"; + if (this._prefixes == OrePrefixes.blockCasingAdvanced) return "bw.werkstoffblockscasingadvanced.01"; return ""; } @Override @SideOnly(Side.CLIENT) - @SuppressWarnings("unchecked") - public void getSubBlocks(Item aItem, CreativeTabs aTab, List aList) { + public void getSubBlocks(Item aItem, CreativeTabs aTab, List aList) { Werkstoff.werkstoffHashSet.stream() .filter( - pMaterial -> pMaterial.getType().equals(Werkstoff.Types.BIOLOGICAL) + pMaterial -> Werkstoff.Types.BIOLOGICAL.equals(pMaterial.getType()) && pMaterial.hasGenerationFeature(OrePrefixes.blockCasing) || pMaterial.doesOreDictedItemExists(OrePrefixes.plate) && pMaterial.doesOreDictedItemExists(OrePrefixes.screw) diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_CasingAdvanced_TE.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_CasingAdvanced_TE.java index b53bd71e4..9f1b197b8 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_CasingAdvanced_TE.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_CasingAdvanced_TE.java @@ -36,7 +36,7 @@ protected Block GetProperBlock() { public ITexture[] getTexture(Block aBlock, ForgeDirection side) { if (SideReference.Side.Client) { Werkstoff aMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData); - if ((aMaterial != null)) { + if (aMaterial != null) { TextureSet set = aMaterial.getTexSet(); ITexture aIconSet = TextureFactory.of( PrefixTextureLinker.texMapBlocks.get(OrePrefixes.blockCasingAdvanced) diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_Casing_TE.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_Casing_TE.java index fda24e869..f23fc3a91 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_Casing_TE.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlocks_Casing_TE.java @@ -36,7 +36,7 @@ protected Block GetProperBlock() { public ITexture[] getTexture(Block aBlock, ForgeDirection side) { if (SideReference.Side.Client) { Werkstoff aMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData); - if ((aMaterial != null)) { + if (aMaterial != null) { TextureSet set = aMaterial.getTexSet(); ITexture aIconSet = TextureFactory.of( PrefixTextureLinker.texMapBlocks.get(OrePrefixes.blockCasing) diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedFrames.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedFrames.java index cb876af9b..ee322c563 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedFrames.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedFrames.java @@ -40,13 +40,13 @@ public class BW_MetaGeneratedFrames extends MetaPipeEntity { public BW_MetaGeneratedFrames(int aID, String aName, String aNameRegional, Werkstoff aMaterial) { super(aID, aName, aNameRegional, 0); - mMaterial = aMaterial; + this.mMaterial = aMaterial; - GT_OreDictUnificator.registerOre(OrePrefixes.frameGt, aMaterial, getStackForm(1)); + GT_OreDictUnificator.registerOre(OrePrefixes.frameGt, aMaterial, this.getStackForm(1)); GT_ModHandler.addCraftingRecipe( - getStackForm(2), + this.getStackForm(2), RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.BUFFERED, - new Object[] { "SSS", "SwS", "SSS", 'S', mMaterial.get(OrePrefixes.stick) }); + new Object[] { "SSS", "SwS", "SSS", 'S', this.mMaterial.get(OrePrefixes.stick) }); RA.stdBuilder() .itemInputs( @@ -57,7 +57,7 @@ public BW_MetaGeneratedFrames(int aID, String aName, String aNameRegional, Werks private BW_MetaGeneratedFrames(String aName, Werkstoff aMaterial) { super(aName, 0); - mMaterial = aMaterial; + this.mMaterial = aMaterial; } @Override @@ -129,10 +129,12 @@ public final boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int return false; } + @Override public int connect(ForgeDirection side) { return 0; } + @Override public void disconnect(ForgeDirection side) { /* Do nothing */ } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java index 7383b41b5..f4bf46dbe 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java @@ -26,7 +26,7 @@ public class BW_MetaGeneratedOreTE extends BW_MetaGenerated_Block_TE { @Override public ITexture[] getTexture(Block aBlock, ForgeDirection side) { Werkstoff aMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData); - if ((aMaterial != null)) { + if (aMaterial != null) { ITexture aIconSet = TextureFactory .of(aMaterial.getTexSet().mTextures[OrePrefixes.ore.mTextureIndex], aMaterial.getRGBA()); return new ITexture[] { TextureFactory.of(Blocks.stone), aIconSet }; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedSmallOreTE.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedSmallOreTE.java index ed3285eaa..de4dbb1cb 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedSmallOreTE.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedSmallOreTE.java @@ -31,6 +31,7 @@ public class BW_MetaGeneratedSmallOreTE extends BW_MetaGeneratedOreTE { + @Override public ArrayList getDrops(int aFortune) { ArrayList rList = new ArrayList<>(); Materials aMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData).getBridgeMaterial(); @@ -100,7 +101,7 @@ public ArrayList getDrops(int aFortune) { if (tSelector.size() > 0) { int i = 0; - for (int j = Math.max(1, (aFortune > 0 ? tRandom.nextInt(1 + aFortune) : 0)); i < j; ++i) { + for (int j = Math.max(1, aFortune > 0 ? tRandom.nextInt(1 + aFortune) : 0); i < j; ++i) { rList.add(GT_Utility.copyAmount(1L, tSelector.get(tRandom.nextInt(tSelector.size())))); } } @@ -118,7 +119,7 @@ public ArrayList getDrops(int aFortune) { @Override public ITexture[] getTexture(Block aBlock, ForgeDirection side) { Werkstoff aMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData); - if ((aMaterial != null)) { + if (aMaterial != null) { ITexture aIconSet = TextureFactory .of(aMaterial.getTexSet().mTextures[OrePrefixes.oreSmall.mTextureIndex], aMaterial.getRGBA()); return new ITexture[] { TextureFactory.of(Blocks.stone), aIconSet }; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Block_TE.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Block_TE.java index 7492512e7..5aba6c84a 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Block_TE.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Block_TE.java @@ -32,15 +32,18 @@ public abstract class BW_MetaGenerated_Block_TE extends TileEntity implements IT public short mMetaData; + @Override public boolean canUpdate() { return false; } + @Override public void readFromNBT(NBTTagCompound aNBT) { super.readFromNBT(aNBT); this.mMetaData = aNBT.getShort("m"); } + @Override public void writeToNBT(NBTTagCompound aNBT) { aNBT.setShort("m", this.mMetaData); super.writeToNBT(aNBT); @@ -64,7 +67,7 @@ public ArrayList getDrops(int aFortune) { rList.add(new ItemStack(Blocks.cobblestone, 1, 0)); return rList; } - rList.add(new ItemStack(GetProperBlock(), 1, this.mMetaData)); + rList.add(new ItemStack(this.GetProperBlock(), 1, this.mMetaData)); return rList; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Blocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Blocks.java index ad850c2c5..c9dd83db6 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Blocks.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Blocks.java @@ -50,11 +50,11 @@ public BW_MetaGenerated_Blocks(Material p_i45386_1_, Class this.setResistance(5.0F); this.setBlockTextureName("stone"); this.setCreativeTab(metaTab); - _prefixes = types; - if (_prefixes != null) { + this._prefixes = types; + if (this._prefixes != null) { this.blockTypeLocalizedName = GT_LanguageManager.addStringLocalization( - "bw.blocktype." + _prefixes, - _prefixes.mLocalizedMaterialPre + "%material" + _prefixes.mLocalizedMaterialPost); + "bw.blocktype." + this._prefixes, + this._prefixes.mLocalizedMaterialPre + "%material" + this._prefixes.mLocalizedMaterialPost); } Werkstoff.werkstoffHashSet.forEach(this::doRegistrationStuff); } @@ -69,7 +69,7 @@ public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { @SideOnly(Side.CLIENT) public final BW_MetaGenerated_Block_TE getProperTileEntityForRendering() { - return (BW_MetaGenerated_Block_TE) createNewTileEntity(null, 0); + return (BW_MetaGenerated_Block_TE) this.createNewTileEntity(null, 0); } protected abstract void doRegistrationStuff(Werkstoff w); @@ -79,19 +79,22 @@ public String getHarvestTool(int metadata) { return "pickaxe"; } + @Override protected boolean canSilkHarvest() { return false; } + @Override public int getRenderType() { if (BW_Renderer_Block_Ores.INSTANCE == null) return super.getRenderType(); return BW_Renderer_Block_Ores.INSTANCE.mRenderID; } + @Override public int getDamageValue(World aWorld, int aX, int aY, int aZ) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof BW_MetaGenerated_Block_TE))) { - return ((BW_MetaGenerated_Block_TE) tTileEntity).mMetaData; + if (tTileEntity instanceof BW_MetaGenerated_Block_TE metaTE) { + return metaTE.mMetaData; } return 0; } @@ -106,18 +109,20 @@ public boolean hasTileEntity(int metadata) { return true; } + @Override public void breakBlock(World world, int x, int y, int z, Block block, int meta) { TileEntity tTileEntity = world.getTileEntity(x, y, z); - if ((tTileEntity instanceof BW_MetaGenerated_Block_TE)) { - mTemporaryTileEntity.set((BW_MetaGenerated_Block_TE) tTileEntity); + if (tTileEntity instanceof BW_MetaGenerated_Block_TE metaTE) { + mTemporaryTileEntity.set(metaTE); } super.breakBlock(world, x, y, z, block, meta); } + @Override public ArrayList getDrops(World aWorld, int aX, int aY, int aZ, int aMeta, int aFortune) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof BW_MetaGenerated_Block_TE)) { - return ((BW_MetaGenerated_Block_TE) tTileEntity).getDrops(aFortune); + if (tTileEntity instanceof BW_MetaGenerated_Block_TE metaTE) { + return metaTE.getDrops(aFortune); } return mTemporaryTileEntity.get() == null ? new ArrayList<>() : mTemporaryTileEntity.get().getDrops(aFortune); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java index fde9c8e9e..7f9a3196d 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java @@ -84,20 +84,21 @@ public BW_MetaGenerated_Items(OrePrefixes orePrefixes) { } } + @Override public boolean onEntityItemUpdate(EntityItem aItemEntity) { if (this.orePrefixes == OrePrefixes.dustImpure || this.orePrefixes == OrePrefixes.dustPure || this.orePrefixes == OrePrefixes.crushed) { int aDamage = aItemEntity.getEntityItem().getItemDamage(); - if ((aDamage >= 0) && (!aItemEntity.worldObj.isRemote)) { + if (aDamage >= 0 && !aItemEntity.worldObj.isRemote) { Werkstoff aMaterial = werkstoffHashMap.get((short) aDamage); - if ((aMaterial != null) && (aMaterial != Werkstoff.default_null_Werkstoff)) { + if (aMaterial != null && aMaterial != Werkstoff.default_null_Werkstoff) { int tX = MathHelper.floor_double(aItemEntity.posX); int tY = MathHelper.floor_double(aItemEntity.posY); int tZ = MathHelper.floor_double(aItemEntity.posZ); Block tBlock = aItemEntity.worldObj.getBlock(tX, tY, tZ); byte tMetaData = (byte) aItemEntity.worldObj.getBlockMetadata(tX, tY, tZ); - if ((this.orePrefixes == OrePrefixes.dustImpure) || (this.orePrefixes == OrePrefixes.dustPure)) { - if ((tBlock == Blocks.cauldron) && (tMetaData > 0)) { + if (tBlock == Blocks.cauldron && tMetaData > 0) { + if (this.orePrefixes == OrePrefixes.dustImpure || this.orePrefixes == OrePrefixes.dustPure) { aItemEntity.setEntityItemStack( WerkstoffLoader.getCorrespondingItemStack( OrePrefixes.dust, @@ -105,9 +106,7 @@ public boolean onEntityItemUpdate(EntityItem aItemEntity) { aItemEntity.getEntityItem().stackSize)); aItemEntity.worldObj.setBlockMetadataWithNotify(tX, tY, tZ, tMetaData - 1, 3); return true; - } - } else { - if ((tBlock == Blocks.cauldron) && (tMetaData > 0)) { + } else { aItemEntity.setEntityItemStack( WerkstoffLoader.getCorrespondingItemStack( OrePrefixes.crushedPurified, @@ -124,8 +123,7 @@ public boolean onEntityItemUpdate(EntityItem aItemEntity) { } @Override - @SuppressWarnings("unchecked") - protected void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer aPlayer) { + protected void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer aPlayer) { if (this.orePrefixes == OrePrefixes.dustImpure || this.orePrefixes == OrePrefixes.dustPure) { aList.add(GT_LanguageManager.getTranslation("metaitem.01.tooltip.purify")); } @@ -159,13 +157,13 @@ public String getItemStackDisplayName(ItemStack aStack) { int aMetaData = aStack.getItemDamage(); Werkstoff werkstoff = werkstoffHashMap.get((short) aMetaData); if (werkstoff == null) werkstoff = Werkstoff.default_null_Werkstoff; - return itemTypeLocalizedName.replace("%material", werkstoff.getLocalizedName()); + return this.itemTypeLocalizedName.replace("%material", werkstoff.getLocalizedName()); } @Override public IIconContainer getIconContainer(int aMetaData) { if (werkstoffHashMap.get((short) aMetaData) == null) return null; - if (this.orePrefixes.mTextureIndex == -1) return getIconContainerBartWorks(aMetaData); + if (this.orePrefixes.mTextureIndex == -1) return this.getIconContainerBartWorks(aMetaData); return werkstoffHashMap.get((short) aMetaData).getTexSet().mTextures[this.orePrefixes.mTextureIndex]; } @@ -177,8 +175,7 @@ protected IIconContainer getIconContainerBartWorks(int aMetaData) { @Override @SideOnly(Side.CLIENT) - @SuppressWarnings("unchecked") - public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { + public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { for (Werkstoff werkstoff : werkstoffHashSet) { if (werkstoff != null && werkstoff.hasItemType(this.orePrefixes)) { ItemStack tStack = new ItemStack(this, 1, werkstoff.getmID()); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java index 36d7eb46f..08251573b 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java @@ -42,9 +42,10 @@ public BW_MetaGenerated_Ores(Material p_i45386_1_, Class t OrePrefixes.ore.mLocalizedMaterialPre + "%material" + OrePrefixes.ore.mLocalizedMaterialPost); } + @Override protected void doRegistrationStuff(Werkstoff w) { if (w != null) { - if (!w.hasItemType(OrePrefixes.ore) || ((w.getGenerationFeatures().blacklist & 0b1000) != 0)) return; + if (!w.hasItemType(OrePrefixes.ore) || (w.getGenerationFeatures().blacklist & 0b1000) != 0) return; GT_ModHandler.addValuableOre(this, w.getmID(), 1); } } @@ -57,26 +58,22 @@ public static boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMet Block tBlock = aWorld.getBlock(aX, aY, aZ); Block tOreBlock = WerkstoffLoader.BWOres; - if (aMetaData < 0 || tBlock == Blocks.air && !air) { + if (aMetaData < 0 || tBlock == Blocks.air && !air + || Block.getIdFromBlock(tBlock) != Block.getIdFromBlock(block)) { return false; - } else { - - if (Block.getIdFromBlock(tBlock) != Block.getIdFromBlock(block)) { - return false; - } - final int aaY = aY; - if (Arrays.stream(aBlockMeta).noneMatch(e -> e == aWorld.getBlockMetadata(aX, aaY, aZ))) { - return false; - } - - aWorld.setBlock(aX, aY, aZ, tOreBlock, aMetaData, 0); - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof BW_MetaGeneratedOreTE) { - ((BW_MetaGeneratedOreTE) tTileEntity).mMetaData = (short) aMetaData; - } + } + final int aaY = aY; + if (Arrays.stream(aBlockMeta).noneMatch(e -> e == aWorld.getBlockMetadata(aX, aaY, aZ))) { + return false; + } - return true; + aWorld.setBlock(aX, aY, aZ, tOreBlock, aMetaData, 0); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof BW_MetaGeneratedOreTE metaTE) { + metaTE.mMetaData = (short) aMetaData; } + + return true; } @Override @@ -85,10 +82,11 @@ public IIcon getIcon(int side, int meta) { } @Override - public IIcon getIcon(IBlockAccess p_149673_1_, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_) { + public IIcon getIcon(IBlockAccess worldIn, int x, int y, int z, int side) { return Blocks.stone.getIcon(0, 0); } + @Override public int getHarvestLevel(int metadata) { return 3; } @@ -99,26 +97,12 @@ public String getUnlocalizedName() { } @Override - @SuppressWarnings("unchecked") - public void getSubBlocks(Item aItem, CreativeTabs aTab, List aList) { + public void getSubBlocks(Item aItem, CreativeTabs aTab, List aList) { for (Werkstoff tMaterial : Werkstoff.werkstoffHashSet) { - if ((tMaterial != null) && tMaterial.hasItemType(OrePrefixes.ore) - && ((tMaterial.getGenerationFeatures().blacklist & 0x8) == 0)) { + if (tMaterial != null && tMaterial.hasItemType(OrePrefixes.ore) + && (tMaterial.getGenerationFeatures().blacklist & 0x8) == 0) { aList.add(new ItemStack(aItem, 1, tMaterial.getmID())); } } } - - @SuppressWarnings("unused") - private boolean checkForAir(IBlockAccess aWorld, int aX, int aY, int aZ) { - for (int x = -1; x <= 1; x++) { - for (int y = -1; y <= 1; y++) { - for (int z = -1; z <= 1; z++) { - if (x == 0 && y == 0 && z == 0) continue; - if (aWorld.getBlock(aX + x, aY + y, aZ + z).isAir(aWorld, aX + x, aY + y, aZ + z)) return true; - } - } - } - return false; - } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_SmallOres.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_SmallOres.java index 54825526d..fc6b75736 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_SmallOres.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_SmallOres.java @@ -37,7 +37,7 @@ public BW_MetaGenerated_SmallOres(Material p_i45386_1_, Class e == aWorld.getBlockMetadata(aX, aaY, aZ))) { - return false; - } - - aWorld.setBlock(aX, aY, aZ, tOreBlock, aMetaData, 0); - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof BW_MetaGeneratedOreTE) { - ((BW_MetaGeneratedOreTE) tTileEntity).mMetaData = (short) aMetaData; - } + } + final int aaY = aY; + if (Arrays.stream(aBlockMeta).noneMatch(e -> e == aWorld.getBlockMetadata(aX, aaY, aZ))) { + return false; + } - return true; + aWorld.setBlock(aX, aY, aZ, tOreBlock, aMetaData, 0); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof BW_MetaGeneratedOreTE metaTE) { + metaTE.mMetaData = (short) aMetaData; } + + return true; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_WerkstoffBlock_TE.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_WerkstoffBlock_TE.java index bfcfbc0e8..f82b90863 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_WerkstoffBlock_TE.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_WerkstoffBlock_TE.java @@ -31,7 +31,7 @@ public class BW_MetaGenerated_WerkstoffBlock_TE extends BW_MetaGenerated_Block_T public ITexture[] getTexture(Block aBlock, ForgeDirection side) { if (SideReference.Side.Client) { Werkstoff aMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData); - if ((aMaterial != null)) { + if (aMaterial != null) { TextureSet set = aMaterial.getTexSet(); ITexture aIconSet = TextureFactory.of( set.mTextures[PrefixTextureLinker.blockTexMap diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_WerkstoffBlocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_WerkstoffBlocks.java index 9c7d25168..8e149391c 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_WerkstoffBlocks.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_WerkstoffBlocks.java @@ -51,13 +51,12 @@ public IIcon getIcon(int side, int meta) { } @Override - public IIcon getIcon(IBlockAccess p_149673_1_, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_) { + public IIcon getIcon(IBlockAccess worldIn, int x, int y, int z, int side) { return Blocks.iron_block.getIcon(0, 0); } @Override - @SuppressWarnings("unchecked") - public void getSubBlocks(Item aItem, CreativeTabs p_149666_2_, List aList) { + public void getSubBlocks(Item aItem, CreativeTabs tab, List aList) { Werkstoff.werkstoffHashSet.stream() .filter(tMaterial -> tMaterial.hasItemType(OrePrefixes.gem) || tMaterial.hasItemType(OrePrefixes.ingot)) .map(tMaterial -> new ItemStack(aItem, 1, tMaterial.getmID())).forEach(aList::add); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_NonMeta_MaterialItems.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_NonMeta_MaterialItems.java index 67bfa6c0a..3315bfea4 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_NonMeta_MaterialItems.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_NonMeta_MaterialItems.java @@ -40,86 +40,88 @@ public enum BW_NonMeta_MaterialItems implements IItemContainer { @Override public IItemContainer set(Item aItem) { - mHasNotBeenSet = false; + this.mHasNotBeenSet = false; if (aItem == null) return this; ItemStack aStack = new ItemStack(aItem, 1, 0); - mStack = GT_Utility.copyAmount(1, aStack); + this.mStack = GT_Utility.copyAmount(1, aStack); return this; } @Override public IItemContainer set(ItemStack aStack) { - mHasNotBeenSet = false; - mStack = GT_Utility.copyAmount(1, aStack); + this.mHasNotBeenSet = false; + this.mStack = GT_Utility.copyAmount(1, aStack); return this; } @Override public Item getItem() { - if (mHasNotBeenSet) - throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); - if (GT_Utility.isStackInvalid(mStack)) return null; - return mStack.getItem(); + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + if (GT_Utility.isStackInvalid(this.mStack)) return null; + return this.mStack.getItem(); } @Override public Block getBlock() { - if (mHasNotBeenSet) - throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); - return GT_Utility.getBlockFromItem(getItem()); + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + return GT_Utility.getBlockFromItem(this.getItem()); } @Override public final boolean hasBeenSet() { - return !mHasNotBeenSet; + return !this.mHasNotBeenSet; } @Override public boolean isStackEqual(Object aStack) { - return isStackEqual(aStack, false, false); + return this.isStackEqual(aStack, false, false); } @Override public boolean isStackEqual(Object aStack, boolean aWildcard, boolean aIgnoreNBT) { if (GT_Utility.isStackInvalid(aStack)) return false; - return GT_Utility.areUnificationsEqual((ItemStack) aStack, aWildcard ? getWildcard(1) : get(1), aIgnoreNBT); + return GT_Utility + .areUnificationsEqual((ItemStack) aStack, aWildcard ? this.getWildcard(1) : this.get(1), aIgnoreNBT); } @Override public ItemStack get(long aAmount, Object... aReplacements) { - if (mHasNotBeenSet) - throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); - if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); - return GT_Utility.copyAmount(aAmount, GT_OreDictUnificator.get(mStack)); + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + if (GT_Utility.isStackInvalid(this.mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); + return GT_Utility.copyAmount(aAmount, GT_OreDictUnificator.get(this.mStack)); } @Override public ItemStack getWildcard(long aAmount, Object... aReplacements) { - if (mHasNotBeenSet) - throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); - if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); - return GT_Utility.copyAmountAndMetaData(aAmount, W, GT_OreDictUnificator.get(mStack)); + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + if (GT_Utility.isStackInvalid(this.mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); + return GT_Utility.copyAmountAndMetaData(aAmount, W, GT_OreDictUnificator.get(this.mStack)); } @Override public ItemStack getUndamaged(long aAmount, Object... aReplacements) { - if (mHasNotBeenSet) - throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); - if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); - return GT_Utility.copyAmountAndMetaData(aAmount, 0, GT_OreDictUnificator.get(mStack)); + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + if (GT_Utility.isStackInvalid(this.mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); + return GT_Utility.copyAmountAndMetaData(aAmount, 0, GT_OreDictUnificator.get(this.mStack)); } @Override public ItemStack getAlmostBroken(long aAmount, Object... aReplacements) { - if (mHasNotBeenSet) - throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); - if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); - return GT_Utility.copyAmountAndMetaData(aAmount, mStack.getMaxDamage() - 1, GT_OreDictUnificator.get(mStack)); + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + if (GT_Utility.isStackInvalid(this.mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); + return GT_Utility + .copyAmountAndMetaData(aAmount, this.mStack.getMaxDamage() - 1, GT_OreDictUnificator.get(this.mStack)); } @Override public ItemStack getWithName(long aAmount, String aDisplayName, Object... aReplacements) { - ItemStack rStack = get(1, aReplacements); + ItemStack rStack = this.get(1, aReplacements); if (GT_Utility.isStackInvalid(rStack)) return null; rStack.setStackDisplayName(aDisplayName); return GT_Utility.copyAmount(aAmount, rStack); @@ -127,7 +129,7 @@ public ItemStack getWithName(long aAmount, String aDisplayName, Object... aRepla @Override public ItemStack getWithCharge(long aAmount, int aEnergy, Object... aReplacements) { - ItemStack rStack = get(1, aReplacements); + ItemStack rStack = this.get(1, aReplacements); if (GT_Utility.isStackInvalid(rStack)) return null; GT_ModHandler.chargeElectricItem(rStack, aEnergy, Integer.MAX_VALUE, true, false); return GT_Utility.copyAmount(aAmount, rStack); @@ -135,25 +137,25 @@ public ItemStack getWithCharge(long aAmount, int aEnergy, Object... aReplacement @Override public ItemStack getWithDamage(long aAmount, long aMetaValue, Object... aReplacements) { - if (mHasNotBeenSet) - throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); - if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); - return GT_Utility.copyAmountAndMetaData(aAmount, aMetaValue, GT_OreDictUnificator.get(mStack)); + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + if (GT_Utility.isStackInvalid(this.mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); + return GT_Utility.copyAmountAndMetaData(aAmount, aMetaValue, GT_OreDictUnificator.get(this.mStack)); } @Override public IItemContainer registerOre(Object... aOreNames) { - if (mHasNotBeenSet) - throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); - for (Object tOreName : aOreNames) GT_OreDictUnificator.registerOre(tOreName, get(1)); + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + for (Object tOreName : aOreNames) GT_OreDictUnificator.registerOre(tOreName, this.get(1)); return this; } @Override public IItemContainer registerWildcardAsOre(Object... aOreNames) { - if (mHasNotBeenSet) - throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); - for (Object tOreName : aOreNames) GT_OreDictUnificator.registerOre(tOreName, getWildcard(1)); + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + for (Object tOreName : aOreNames) GT_OreDictUnificator.registerOre(tOreName, this.getWildcard(1)); return this; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_Meta_Items.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_Meta_Items.java index 69c66b947..11200e95c 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_Meta_Items.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_Meta_Items.java @@ -92,7 +92,6 @@ public static BW_Meta_Items.BW_GT_MetaGenCircuits getNEWCIRCUITS() { BW_Util.CLEANROOM)); } - @SuppressWarnings("deprecation") public void addNewCircuit(int aTier, int aID, String aName) { String additionalOreDictData = ""; @@ -147,7 +146,7 @@ public void addNewCircuit(int aTier, int aID, String aName) { ItemStack tStack = BW_Meta_Items.NEWCIRCUITS.addCircuit(aID, aName, tooltip, aTier); - GT_OreDictUnificator.registerOre((aOreDictPrefix + additionalOreDictData).replaceAll(" ", ""), tStack); + GT_OreDictUnificator.registerOre((aOreDictPrefix + additionalOreDictData).replace(" ", ""), tStack); } public static class BW_GT_MetaGenCircuits extends BW_Meta_Items.BW_GT_MetaGen_Item_Hook { @@ -159,7 +158,7 @@ public BW_GT_MetaGenCircuits() { public final ItemStack addCircuit(int aID, String aEnglish, String aToolTip, int tier) { CircuitImprintLoader.bwCircuitTagMap.put( new CircuitData( - BW_Util.getMachineVoltageFromTier(Math.min(1, (tier - 2))), + BW_Util.getMachineVoltageFromTier(Math.min(1, tier - 2)), tier > 2 ? BW_Util.CLEANROOM : 0, (byte) tier), new ItemStack(BW_Meta_Items.NEWCIRCUITS, 1, aID)); @@ -185,8 +184,7 @@ public final ItemStack getStackWithNBT(NBTTagCompound tag, int... meta_amount) { } @Override - @SuppressWarnings("unchecked") - public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { + public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { if (aCreativeTab == this.getCreativeTab()) for (NBTTagCompound tag : CircuitImprintLoader.recipeTagMap.keySet()) { ItemStack stack = new ItemStack(BW_Meta_Items.NEWCIRCUITS, 1, 0); @@ -196,6 +194,7 @@ public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { super.getSubItems(var1, aCreativeTab, aList); } + @Override @SideOnly(Side.CLIENT) public final void registerIcons(IIconRegister aIconRegister) { @@ -230,8 +229,7 @@ public final void registerIcons(IIconRegister aIconRegister) { } @Override - @SuppressWarnings("unchecked") - protected void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer aPlayer) { + protected void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer aPlayer) { if (aStack.getItemDamage() == 0) if (aStack.getTagCompound() != null && CircuitImprintLoader.getStackFromTag(aStack.getTagCompound()) != null) aList.add( @@ -303,10 +301,8 @@ public final ItemStack addItem(int aID, String aEnglish, String aToolTip, Object Object tRandomData; for (var9 = 0; var9 < var8; ++var9) { tRandomData = var7[var9]; - if (tRandomData instanceof SubTag) { - if (tRandomData == SubTag.NO_UNIFICATION) { - GT_OreDictUnificator.addToBlacklist(rStack); - } + if (tRandomData instanceof SubTag && tRandomData == SubTag.NO_UNIFICATION) { + GT_OreDictUnificator.addToBlacklist(rStack); } } @@ -351,9 +347,9 @@ public final ItemStack addItem(int aID, String aEnglish, String aToolTip, Object return rStack; } + @Override @SideOnly(Side.CLIENT) - @SuppressWarnings("unchecked") - public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { + public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { int j = this.mEnabledItems.length(); for (int i = 0; i < j; ++i) { @@ -366,8 +362,7 @@ public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { } @Override - @SuppressWarnings("unchecked") - protected void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer aPlayer) { + protected void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer aPlayer) { super.addAdditionalToolTips(aList, aStack, aPlayer); aList.add(BW_Tooltip_Reference.ADDED_BY_BARTWORKS.get()); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitData.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitData.java index da0225001..49fba31ec 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitData.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitData.java @@ -32,10 +32,8 @@ public CircuitData(long aVoltage, int aSpecial, byte aTier) { @Override public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof CircuitData)) return false; - CircuitData that = (CircuitData) o; - if (this.getaVoltage() != that.getaVoltage()) return false; - if (this.getaSpecial() != that.getaSpecial()) return false; + if (!(o instanceof CircuitData that)) return false; + if (this.getaVoltage() != that.getaVoltage() || this.getaSpecial() != that.getaSpecial()) return false; return this.getaTier() == that.getaTier(); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java index 91ac70820..9d8675406 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java @@ -60,7 +60,6 @@ public class CircuitImprintLoader { private static final HashSet ORIGINAL_CAL_RECIPES = new HashSet<>(); private static final HashSet MODIFIED_CAL_RECIPES = new HashSet<>(); - @SuppressWarnings({ "unused", "RedundantSuppression" }) public static void run() { HashSet toRem = new HashSet<>(); HashSet toAdd = new HashSet<>(); @@ -112,24 +111,13 @@ private static void handleCircuitRecipeRebuilding(GT_Recipe circuitRecipe, HashS if (newRecipe != null) BWRecipes.instance.getMappingsFor(BWRecipes.CIRCUITASSEMBLYLINE).addRecipe(newRecipe); addCutoffRecipeToSets(toRem, toAdd, circuitRecipe); - } else { - if (circuitRecipe.mEUt > BW_Util.getTierVoltage(ConfigHandler.cutoffTier)) toRem.add(circuitRecipe); - } + } else if (circuitRecipe.mEUt > BW_Util.getTierVoltage(ConfigHandler.cutoffTier)) toRem.add(circuitRecipe); } } - @Deprecated - private static String getTypeFromOreDict(ItemStack[] outputs) { - int[] oreIDS = OreDictionary.getOreIDs(outputs[0]); - - if (oreIDS.length < 1) return ""; - - return OreDictionary.getOreName(oreIDS[0]); - } - private static boolean isCircuitOreDict(ItemStack item) { return BW_Util.isTieredCircuit(item) - || BW_Util.getOreNames(item).stream().anyMatch(s -> s.equals("circuitPrimitiveArray")); + || BW_Util.getOreNames(item).stream().anyMatch(s -> "circuitPrimitiveArray".equals(s)); } private static void exchangeRecipesInList(HashSet toRem, HashSet toAdd) { @@ -310,8 +298,8 @@ private static void makeAndAddSlicingRecipe(NBTTagCompound tag) { BW_Util.getMachineVoltageFromTier( BW_Util.getCircuitTierFromOreDictName( OreDictionary.getOreName( - (OreDictionary.getOreIDs(stack) != null - && OreDictionary.getOreIDs(stack).length > 0) + OreDictionary.getOreIDs(stack) != null + && OreDictionary.getOreIDs(stack).length > 0 ? OreDictionary.getOreIDs(stack)[0] : -1)))); GT_Recipe slicingRecipe = new BWRecipes.DynamicGTRecipe( diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java index 7babb0d3c..5da0462d8 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java @@ -148,7 +148,7 @@ public static void makeCircuitParts() { ArrayList toolTip = new ArrayList<>(); if (FMLCommonHandler.instance().getEffectiveSide().isClient()) single.getItem().addInformation(single.get(1).copy(), null, toolTip, true); - String tt = (toolTip.size() > 0 ? toolTip.get(0) : ""); + String tt = toolTip.size() > 0 ? toolTip.get(0) : ""; // tt += "Internal Name = "+single; String localised = GT_LanguageManager .getTranslation(GT_LanguageManager.getTranslateableItemStackName(itemStack)); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/BWGTMetaItems.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/BWGTMetaItems.java index 0de9abaa4..08b396825 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/BWGTMetaItems.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/BWGTMetaItems.java @@ -57,37 +57,36 @@ public BWGTMetaItems(OrePrefixes orePrefixes, List noSubIDMaterials) for (int i = 0; i < Materials.values().length; i++) { ItemStack tStack = new ItemStack(this, 1, i); Materials material = Materials.values()[i]; - if (((material.getMolten(1) == null && orePrefixes == OrePrefixes.capsuleMolten) - || ((material.getFluid(1) == null && material.getGas(1) == null) - && (orePrefixes == OrePrefixes.capsule || orePrefixes == OrePrefixes.bottle)))) + if (material.getMolten(1) == null && orePrefixes == OrePrefixes.capsuleMolten + || material.getFluid(1) == null && material.getGas(1) == null + && (orePrefixes == OrePrefixes.capsule || orePrefixes == OrePrefixes.bottle)) continue; - if (OreDictionary - .doesOreNameExist(this.orePrefixes.name() + material.mDefaultLocalName.replaceAll(" ", ""))) { - hiddenThings.add(i); + if (OreDictionary.doesOreNameExist(this.orePrefixes.name() + material.mDefaultLocalName.replace(" ", ""))) { + this.hiddenThings.add(i); continue; } GT_OreDictUnificator - .registerOre(this.orePrefixes.name() + material.mDefaultLocalName.replaceAll(" ", ""), tStack); + .registerOre(this.orePrefixes.name() + material.mDefaultLocalName.replace(" ", ""), tStack); } if (noSubIDMaterials != null) { - hasList = true; + this.hasList = true; // materialloop: for (int i = 0; i < noSubIDMaterials.size(); i++) { ItemStack tStack = new ItemStack(this, 1, i + 1001); Materials w = noSubIDMaterials.get(i); - if (((w.getMolten(1) == null && orePrefixes == OrePrefixes.capsuleMolten) - || ((w.getFluid(1) == null && w.getGas(1) == null) - && (orePrefixes == OrePrefixes.capsule || orePrefixes == OrePrefixes.bottle)))) + if (w.getMolten(1) == null && orePrefixes == OrePrefixes.capsuleMolten + || w.getFluid(1) == null && w.getGas(1) == null + && (orePrefixes == OrePrefixes.capsule || orePrefixes == OrePrefixes.bottle)) continue; - if (OreDictionary.doesOreNameExist(this.orePrefixes.name() + w.mDefaultLocalName.replaceAll(" ", ""))) { - hiddenThings.add(i); + if (OreDictionary.doesOreNameExist(this.orePrefixes.name() + w.mDefaultLocalName.replace(" ", ""))) { + this.hiddenThings.add(i); continue; } GT_OreDictUnificator - .registerOre(this.orePrefixes.name() + w.mDefaultLocalName.replaceAll(" ", ""), tStack); + .registerOre(this.orePrefixes.name() + w.mDefaultLocalName.replace(" ", ""), tStack); } } } @@ -95,20 +94,19 @@ public BWGTMetaItems(OrePrefixes orePrefixes, List noSubIDMaterials) private Materials getMaterial(ItemStack is) { if (is == null || is.getItem() != this) return null; final int meta = is.getItemDamage(); - return getMaterialFromMeta(meta); + return this.getMaterialFromMeta(meta); } @Override public String getItemStackDisplayName(ItemStack aStack) { - Materials material = getMaterial(aStack); + Materials material = this.getMaterial(aStack); if (material == null) material = Materials._NULL; - return material.getLocalizedNameForItem(itemTypeLocalizedName); + return material.getLocalizedNameForItem(this.itemTypeLocalizedName); } - @SuppressWarnings("unchecked") @Override - protected void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer aPlayer) { - Materials material = getMaterial(aStack); + protected void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer aPlayer) { + Materials material = this.getMaterial(aStack); if (material != null) { String tooltip = material.getToolTip(); if (tooltip != null && !tooltip.isEmpty()) { @@ -120,13 +118,12 @@ protected void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer @Override public IIconContainer getIconContainer(int aMetaData) { - if (this.orePrefixes.mTextureIndex == -1) return getIconContainerBartWorks(aMetaData); - Materials material = getMaterialFromMeta(aMetaData); + if (this.orePrefixes.mTextureIndex == -1) return this.getIconContainerBartWorks(aMetaData); + Materials material = this.getMaterialFromMeta(aMetaData); if (material != null) { return material.mIconSet.mTextures[this.orePrefixes.mTextureIndex]; - } else { - return null; } + return null; } @Override @@ -137,7 +134,7 @@ protected IIconContainer getIconContainerBartWorks(int aMetaData) { if (iconLink == null) return null; - Materials material = getMaterialFromMeta(aMetaData); + Materials material = this.getMaterialFromMeta(aMetaData); if (material == null || material.mIconSet == null) return null; @@ -146,63 +143,61 @@ protected IIconContainer getIconContainerBartWorks(int aMetaData) { @Override public IIcon getIconFromDamage(int aMetaData) { - return getIcon(aMetaData, 0); + return this.getIcon(aMetaData, 0); } @Override public GT_GeneratedMaterial_Renderer getMaterialRenderer(int aMetaData) { - return getMaterialFromMeta(aMetaData).renderer; + return this.getMaterialFromMeta(aMetaData).renderer; } public Materials getMaterialFromMeta(int aMetaData) { - if (aMetaData > 1000 && hasList) { + if (aMetaData > 1000 && this.hasList) { return NoMetaValue.get(aMetaData - 1001); - } else { - if (aMetaData < 0 || aMetaData >= Materials.values().length) { - return null; - } - return Materials.values()[aMetaData]; } + if (aMetaData < 0 || aMetaData >= Materials.values().length) { + return null; + } + return Materials.values()[aMetaData]; } @Override @SideOnly(Side.CLIENT) - @SuppressWarnings("unchecked") - public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { + public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { for (int i = 0; i < Materials.values().length; i++) { Materials w = Materials.values()[i]; - if ((w == null) || (w.mTypes & Werkstoff.GenerationFeatures.getPrefixDataRaw(this.orePrefixes)) == 0 + if (w == null || (w.mTypes & Werkstoff.GenerationFeatures.getPrefixDataRaw(this.orePrefixes)) == 0 && Werkstoff.GenerationFeatures.getPrefixDataRaw(this.orePrefixes) != 0) continue; - else if (((w.getMolten(1) == null && orePrefixes == OrePrefixes.capsuleMolten) - || ((w.getFluid(1) == null && w.getGas(1) == null) - && (orePrefixes == OrePrefixes.capsule || orePrefixes == OrePrefixes.bottle)))) + if (w.getMolten(1) == null && this.orePrefixes == OrePrefixes.capsuleMolten + || w.getFluid(1) == null && w.getGas(1) == null + && (this.orePrefixes == OrePrefixes.capsule || this.orePrefixes == OrePrefixes.bottle)) continue; - else if (hiddenThings.contains(i)) continue; + else if (this.hiddenThings.contains(i)) continue; aList.add(new ItemStack(this, 1, i)); } - if (hasList) for (int i = 0; i < NoMetaValue.size(); i++) { + if (this.hasList) for (int i = 0; i < NoMetaValue.size(); i++) { Materials w = NoMetaValue.get(i); - if ((w == null) || (w.mTypes & Werkstoff.GenerationFeatures.getPrefixDataRaw(this.orePrefixes)) == 0 + if (w == null || (w.mTypes & Werkstoff.GenerationFeatures.getPrefixDataRaw(this.orePrefixes)) == 0 && Werkstoff.GenerationFeatures.getPrefixDataRaw(this.orePrefixes) != 0) continue; - else if (((w.getMolten(1) == null && orePrefixes == OrePrefixes.capsuleMolten) - || ((w.getFluid(1) == null && w.getGas(1) == null) - && (orePrefixes == OrePrefixes.capsule || orePrefixes == OrePrefixes.bottle)))) + if (w.getMolten(1) == null && this.orePrefixes == OrePrefixes.capsuleMolten + || w.getFluid(1) == null && w.getGas(1) == null + && (this.orePrefixes == OrePrefixes.capsule || this.orePrefixes == OrePrefixes.bottle)) continue; - else if (hiddenThings.contains(i)) continue; + else if (this.hiddenThings.contains(i)) continue; aList.add(new ItemStack(this, 1, i + 1001)); } } @Override public short[] getColorForGUI(ItemStack aStack) { - return getMaterial(aStack).mRGBa; + return this.getMaterial(aStack).mRGBa; } @Override public String getNameForGUI(ItemStack aStack) { - return getMaterial(aStack).mDefaultLocalName; + return this.getMaterial(aStack).mDefaultLocalName; } @Override @@ -210,9 +205,10 @@ public void onUpdate(ItemStack aStack, World aWorld, Entity aPlayer, int aTimer, @Override public short[] getRGBa(ItemStack aStack) { - return getMaterial(aStack).mRGBa; + return this.getMaterial(aStack).mRGBa; } + @Override public boolean onEntityItemUpdate(EntityItem aItemEntity) { return false; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/GTMetaItemEnhancer.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/GTMetaItemEnhancer.java index 0cfc062fb..c4838905e 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/GTMetaItemEnhancer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/GTMetaItemEnhancer.java @@ -69,15 +69,15 @@ public static void init() { .duration(2 * TICKS).eut(2).addTo(sFluidCannerRecipes); } - if (m.getFluid(1) == null && m.getGas(1) == null) continue; - if (OreDictionary.doesOreNameExist("capsule" + m.mName)) continue; + if (m.getFluid(1) == null && m.getGas(1) == null || OreDictionary.doesOreNameExist("capsule" + m.mName)) + continue; addFluidData(m, GT_ModHandler.getModItem(Forestry.ID, "waxCapsule", 1), capsuls, 1000, i, true); // addFluidData(m, new ItemStack(Items.glass_bottle), bottles, 250, i, false); } for (int i = 0, valuesLength = NoMetaValue.size(); i < valuesLength; i++) { Materials m = NoMetaValue.get(i); - if (m.getFluid(1) == null && m.getGas(1) == null) continue; - if (OreDictionary.doesOreNameExist("capsule" + m.mName)) continue; + if (m.getFluid(1) == null && m.getGas(1) == null || OreDictionary.doesOreNameExist("capsule" + m.mName)) + continue; addFluidData(m, GT_ModHandler.getModItem(Forestry.ID, "waxCapsule", 1), capsuls, 1000, i + 1001, true); // addFluidData(m, new ItemStack(Items.glass_bottle), bottles, 250, i + 1001, false); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/PlatinumSludgeOverHaul.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/PlatinumSludgeOverHaul.java index 8883e72e6..f0da014b0 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/PlatinumSludgeOverHaul.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/PlatinumSludgeOverHaul.java @@ -554,7 +554,7 @@ public static void replacePureElements() { if (GT_Utility.isStackValid(realEntry.getKey()) && BW_Util.checkStackAndPrefix((ItemStack) realEntry.getKey())) { ItemData association = GT_OreDictUnificator.getAssociation((ItemStack) realEntry.getKey()); - if ((!association.mPrefix.equals(dust) && !association.mPrefix.equals(dustTiny)) + if (!dust.equals(association.mPrefix) && !dustTiny.equals(association.mPrefix) || !association.mMaterial.mMaterial.equals(Materials.Platinum)) if (GT_Utility.isStackValid(realEntry.getValue()) && BW_Util.checkStackAndPrefix((ItemStack) realEntry.getValue())) { @@ -587,8 +587,8 @@ else if (ass.mMaterial.mMaterial.equals(Materials.Palladium)) maploop: for (GT_Recipe.GT_Recipe_Map map : GT_Recipe.GT_Recipe_Map.sMappings) { if (map == GT_Recipe.GT_Recipe_Map.sFusionRecipes || map == GT_Recipe.GT_Recipe_Map.sUnboxinatorRecipes || map == GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes - || map.mUnlocalizedName.equals("gt.recipe.eyeofharmony") - || map.mUnlocalizedName.equals("gtpp.recipe.quantumforcesmelter")) + || "gt.recipe.eyeofharmony".equals(map.mUnlocalizedName) + || "gtpp.recipe.quantumforcesmelter".equals(map.mUnlocalizedName)) continue; HashSet toDel = new HashSet<>(); recipeloop: for (GT_Recipe recipe : map.mRecipeList) { @@ -596,112 +596,97 @@ else if (ass.mMaterial.mMaterial.equals(Materials.Palladium)) for (int i = 0; i < recipe.mFluidOutputs.length; i++) { if (map.equals(GT_Recipe.GT_Recipe_Map.sFluidExtractionRecipes)) continue maploop; - else if (map.equals(GT_Recipe.GT_Recipe_Map.sMultiblockChemicalRecipes) + if (map.equals(GT_Recipe.GT_Recipe_Map.sMultiblockChemicalRecipes) || map.equals(GT_Recipe.GT_Recipe_Map.sChemicalRecipes)) { - if (GT_Utility.areFluidsEqual(Ruthenium.getMolten(1), recipe.mFluidOutputs[i])) - toDel.add(recipe); - else if (GT_Utility.areFluidsEqual(Rhodium.getMolten(1), recipe.mFluidOutputs[i])) - toDel.add(recipe); - else if (GT_Utility - .areFluidsEqual(Materials.Iridium.getMolten(1), recipe.mFluidOutputs[i])) { - recipe.mFluidOutputs[i] = AcidicIridiumSolution.getFluidOrGas(1000); - recipe.reloadOwner(); - } else - if (GT_Utility - .areFluidsEqual(Materials.Platinum.getMolten(1), recipe.mFluidOutputs[i])) { - recipe.mFluidOutputs[i] = PTConcentrate.getFluidOrGas(1000); - recipe.reloadOwner(); - } else - if (GT_Utility.areFluidsEqual( - Materials.Osmium.getMolten(1), - recipe.mFluidOutputs[i])) { - recipe.mFluidOutputs[i] = AcidicOsmiumSolution.getFluidOrGas(1000); - recipe.reloadOwner(); - } - } else { - if (GT_Utility.areFluidsEqual(Ruthenium.getMolten(1), recipe.mFluidOutputs[i])) - toDel.add(recipe); - else if (GT_Utility.areFluidsEqual(Rhodium.getMolten(1), recipe.mFluidOutputs[i])) - toDel.add(recipe); - else if (GT_Utility - .areFluidsEqual(Materials.Iridium.getMolten(1), recipe.mFluidOutputs[i])) - toDel.add(recipe); - else if (GT_Utility - .areFluidsEqual(Materials.Platinum.getMolten(1), recipe.mFluidOutputs[i])) - toDel.add(recipe); - else if (GT_Utility - .areFluidsEqual(Materials.Osmium.getMolten(1), recipe.mFluidOutputs[i])) - toDel.add(recipe); - } + if (GT_Utility.areFluidsEqual(Ruthenium.getMolten(1), recipe.mFluidOutputs[i]) + || GT_Utility.areFluidsEqual(Rhodium.getMolten(1), recipe.mFluidOutputs[i])) + toDel.add(recipe); + else if (GT_Utility.areFluidsEqual(Materials.Iridium.getMolten(1), recipe.mFluidOutputs[i])) { + recipe.mFluidOutputs[i] = AcidicIridiumSolution.getFluidOrGas(1000); + recipe.reloadOwner(); + } else + if (GT_Utility.areFluidsEqual(Materials.Platinum.getMolten(1), recipe.mFluidOutputs[i])) { + recipe.mFluidOutputs[i] = PTConcentrate.getFluidOrGas(1000); + recipe.reloadOwner(); + } else + if (GT_Utility.areFluidsEqual(Materials.Osmium.getMolten(1), recipe.mFluidOutputs[i])) { + recipe.mFluidOutputs[i] = AcidicOsmiumSolution.getFluidOrGas(1000); + recipe.reloadOwner(); + } + } else if (GT_Utility.areFluidsEqual(Ruthenium.getMolten(1), recipe.mFluidOutputs[i]) + || GT_Utility.areFluidsEqual(Rhodium.getMolten(1), recipe.mFluidOutputs[i]) + || GT_Utility.areFluidsEqual(Materials.Iridium.getMolten(1), recipe.mFluidOutputs[i]) + || GT_Utility.areFluidsEqual(Materials.Platinum.getMolten(1), recipe.mFluidOutputs[i])) + toDel.add(recipe); + else if (GT_Utility.areFluidsEqual(Materials.Osmium.getMolten(1), recipe.mFluidOutputs[i])) + toDel.add(recipe); } for (int i = 0; i < recipe.mOutputs.length; i++) { if (!GT_Utility.isStackValid(recipe.mOutputs[i])) continue; - if (BW_Util.areStacksEqualOrNull(Ruthenium.get(dust), recipe.mOutputs[i]) + if ((BW_Util.areStacksEqualOrNull(Ruthenium.get(dust), recipe.mOutputs[i]) || BW_Util.areStacksEqualOrNull(Ruthenium.get(dustImpure), recipe.mOutputs[i]) - || BW_Util.areStacksEqualOrNull(Ruthenium.get(dustPure), recipe.mOutputs[i])) { - if (!BW_Util.areStacksEqualOrNull(Ruthenium.get(ingot), recipe.mInputs[0])) { - for (int j = 0; j < recipe.mInputs.length; j++) - if (PlatinumSludgeOverHaul.isInBlackList(recipe.mInputs[j])) continue recipeloop; - int amount = recipe.mOutputs[i].stackSize * 2; - recipe.mOutputs[i] = LeachResidue.get(dust, amount); - recipe.reloadOwner(); - } + || BW_Util.areStacksEqualOrNull(Ruthenium.get(dustPure), recipe.mOutputs[i])) + && !BW_Util.areStacksEqualOrNull(Ruthenium.get(ingot), recipe.mInputs[0])) { + for (ItemStack mInput : recipe.mInputs) + if (PlatinumSludgeOverHaul.isInBlackList(mInput)) continue recipeloop; + int amount = recipe.mOutputs[i].stackSize * 2; + recipe.mOutputs[i] = LeachResidue.get(dust, amount); + recipe.reloadOwner(); } - if (BW_Util.areStacksEqualOrNull(Rhodium.get(dust), recipe.mOutputs[i]) + if ((BW_Util.areStacksEqualOrNull(Rhodium.get(dust), recipe.mOutputs[i]) || BW_Util.areStacksEqualOrNull(Rhodium.get(dustImpure), recipe.mOutputs[i]) - || BW_Util.areStacksEqualOrNull(Rhodium.get(dustPure), recipe.mOutputs[i])) { - if (!BW_Util.areStacksEqualOrNull(Rhodium.get(ingot), recipe.mInputs[0])) { - for (int j = 0; j < recipe.mInputs.length; j++) - if (PlatinumSludgeOverHaul.isInBlackList(recipe.mInputs[j])) continue recipeloop; - int amount = recipe.mOutputs[i].stackSize * 2; - recipe.mOutputs[i] = CrudeRhMetall.get(dust, amount); - recipe.reloadOwner(); - } + || BW_Util.areStacksEqualOrNull(Rhodium.get(dustPure), recipe.mOutputs[i])) + && !BW_Util.areStacksEqualOrNull(Rhodium.get(ingot), recipe.mInputs[0])) { + for (ItemStack mInput : recipe.mInputs) + if (PlatinumSludgeOverHaul.isInBlackList(mInput)) continue recipeloop; + int amount = recipe.mOutputs[i].stackSize * 2; + recipe.mOutputs[i] = CrudeRhMetall.get(dust, amount); + recipe.reloadOwner(); } if (!BW_Util.checkStackAndPrefix(recipe.mOutputs[i])) continue; // Pt if (GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mMaterial.mMaterial .equals(Materials.Platinum)) { - for (int j = 0; j < recipe.mInputs.length; j++) { - if (PlatinumSludgeOverHaul.isInBlackList(recipe.mInputs[j])) continue recipeloop; + for (ItemStack mInput : recipe.mInputs) { + if (PlatinumSludgeOverHaul.isInBlackList(mInput)) continue recipeloop; } - if (GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix.equals(dust) - || GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix.equals(dustImpure) - || GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix.equals(dustPure)) { + if (dust.equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustImpure.equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustPure.equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { int amount = recipe.mOutputs[i].stackSize; recipe.mOutputs[i] = BW_Util.setStackSize(PTMetallicPowder.get(dust), amount * 2); recipe.reloadOwner(); - } else if (GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix.equals(dustSmall)) { + } else if (dustSmall.equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { int amount = recipe.mOutputs[i].stackSize; recipe.mOutputs[i] = BW_Util.setStackSize(PTMetallicPowder.get(dustSmall), amount * 2); recipe.reloadOwner(); - } else if (GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix.equals(dustTiny)) { + } else if (dustTiny.equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { int amount = recipe.mOutputs[i].stackSize; recipe.mOutputs[i] = BW_Util.setStackSize(PTMetallicPowder.get(dustTiny), amount * 2); recipe.reloadOwner(); } } else if (GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mMaterial.mMaterial .equals(Materials.Palladium)) { - for (int j = 0; j < recipe.mInputs.length; j++) { - if (PlatinumSludgeOverHaul.isInBlackList(recipe.mInputs[j])) continue recipeloop; + for (ItemStack mInput : recipe.mInputs) { + if (PlatinumSludgeOverHaul.isInBlackList(mInput)) continue recipeloop; } - if (GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix.equals(dust) - || GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix - .equals(dustImpure) - || GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix - .equals(dustPure)) { + if (dust.equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustImpure + .equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustPure.equals( + GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { int amount = recipe.mOutputs[i].stackSize; recipe.mOutputs[i] = BW_Util.setStackSize(PDMetallicPowder.get(dust), amount * 4); recipe.reloadOwner(); - } else if (GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix - .equals(dustSmall)) { + } else if (dustSmall + .equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { int amount = recipe.mOutputs[i].stackSize; recipe.mOutputs[i] = BW_Util .setStackSize(PDMetallicPowder.get(dustSmall), amount * 4); recipe.reloadOwner(); } else - if (GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix - .equals(dustTiny)) { + if (dustTiny + .equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { int amount = recipe.mOutputs[i].stackSize; recipe.mOutputs[i] = BW_Util .setStackSize(PDMetallicPowder.get(dustTiny), amount * 4); @@ -710,27 +695,26 @@ else if (GT_Utility } else if (GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mMaterial.mMaterial .equals(Materials.Osmium)) { - for (int j = 0; j < recipe.mInputs.length; j++) { - if (PlatinumSludgeOverHaul.isInBlackList(recipe.mInputs[j])) - continue recipeloop; + for (ItemStack mInput : recipe.mInputs) { + if (PlatinumSludgeOverHaul.isInBlackList(mInput)) continue recipeloop; } - if (GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix.equals(dust) - || GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix - .equals(dustImpure) - || GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix - .equals(dustPure)) { + if (dust.equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustImpure.equals( + GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustPure.equals( + GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { int amount = recipe.mOutputs[i].stackSize; recipe.mOutputs[i] = BW_Util.setStackSize(IrOsLeachResidue.get(dust), amount); recipe.reloadOwner(); - } else if (GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix - .equals(dustSmall)) { + } else if (dustSmall + .equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { int amount = recipe.mOutputs[i].stackSize; recipe.mOutputs[i] = BW_Util .setStackSize(IrOsLeachResidue.get(dustSmall), amount); recipe.reloadOwner(); } else - if (GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix - .equals(dustTiny)) { + if (dustTiny.equals( + GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { int amount = recipe.mOutputs[i].stackSize; recipe.mOutputs[i] = BW_Util .setStackSize(IrOsLeachResidue.get(dustTiny), amount); @@ -739,27 +723,27 @@ else if (GT_Utility } else if (GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mMaterial.mMaterial .equals(Materials.Iridium)) { - for (int j = 0; j < recipe.mInputs.length; j++) { - if (PlatinumSludgeOverHaul.isInBlackList(recipe.mInputs[j])) - continue recipeloop; + for (ItemStack mInput : recipe.mInputs) { + if (PlatinumSludgeOverHaul.isInBlackList(mInput)) continue recipeloop; } - if (GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix.equals(dust) - || GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix - .equals(dustImpure) - || GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix - .equals(dustPure)) { + if (dust.equals(GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustImpure.equals( + GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustPure.equals( + GT_OreDictUnificator + .getAssociation(recipe.mOutputs[i]).mPrefix)) { int amount = recipe.mOutputs[i].stackSize; recipe.mOutputs[i] = BW_Util.setStackSize(IrLeachResidue.get(dust), amount); recipe.reloadOwner(); - } else if (GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix - .equals(dustSmall)) { + } else if (dustSmall.equals( + GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { int amount = recipe.mOutputs[i].stackSize; recipe.mOutputs[i] = BW_Util .setStackSize(IrLeachResidue.get(dustSmall), amount); recipe.reloadOwner(); } else - if (GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix - .equals(dustTiny)) { + if (dustTiny.equals( + GT_OreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { int amount = recipe.mOutputs[i].stackSize; recipe.mOutputs[i] = BW_Util .setStackSize(IrLeachResidue.get(dustTiny), amount); @@ -808,8 +792,8 @@ private static void replaceHVCircuitMaterials() { private static void setnewMaterialInRecipe(Object obj) { String inputName = "output"; String inputItemName = "input"; - if (!(obj instanceof ShapedOreRecipe || obj instanceof ShapelessOreRecipe)) { - if (obj instanceof ShapedRecipes || (obj instanceof ShapelessRecipes)) { + if (!(obj instanceof ShapedOreRecipe) && !(obj instanceof ShapelessOreRecipe)) { + if (obj instanceof ShapedRecipes || obj instanceof ShapelessRecipes) { inputName = "recipeOutput"; inputItemName = "recipeItems"; } else if (GTPlusPlus.isModLoaded()) { @@ -892,21 +876,19 @@ private static boolean checkRecipe(Object input, Materials mat) { } for (Object stack : stacks) { - if (stack instanceof ItemStack) { - if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(crateGtDust, mat, 1), (ItemStack) stack)) - return true; - } + if (stack instanceof ItemStack + && GT_Utility.areStacksEqual(GT_OreDictUnificator.get(crateGtDust, mat, 1), (ItemStack) stack)) + return true; } boolean allSame = false; for (Object stack : stacks) { - if (stack instanceof ItemStack) { - allSame = BW_Util.checkStackAndPrefix((ItemStack) stack) - && GT_OreDictUnificator.getAssociation((ItemStack) stack).mMaterial.mMaterial.equals(mat); - } else { + if (!(stack instanceof ItemStack)) { allSame = false; break; } + allSame = BW_Util.checkStackAndPrefix((ItemStack) stack) + && GT_OreDictUnificator.getAssociation((ItemStack) stack).mMaterial.mMaterial.equals(mat); if (!allSame) break; } return allSame; @@ -915,13 +897,10 @@ private static boolean checkRecipe(Object input, Materials mat) { } private static boolean isInBlackList(ItemStack stack) { - if (stack == null) return true; - - if (stack.getItem() instanceof BW_MetaGenerated_Items) return true; - - if (GameRegistry.findUniqueIdentifierFor(stack.getItem()).modId.equals(MainMod.MOD_ID)) return true; - - if (GameRegistry.findUniqueIdentifierFor(stack.getItem()).modId.equals(BartWorksCrossmod.MOD_ID)) return true; + if (stack == null || stack.getItem() instanceof BW_MetaGenerated_Items + || MainMod.MOD_ID.equals(GameRegistry.findUniqueIdentifierFor(stack.getItem()).modId) + || BartWorksCrossmod.MOD_ID.equals(GameRegistry.findUniqueIdentifierFor(stack.getItem()).modId)) + return true; if (GameRegistry.findUniqueIdentifierFor(stack.getItem()).modId.equals(NewHorizonsCoreMod.ID) && !stack.getUnlocalizedName().contains("dust") @@ -938,8 +917,8 @@ private static boolean isInBlackList(ItemStack stack) { if (stack.getItem() instanceof GT_Generic_Item) { if (!BW_Util.checkStackAndPrefix(stack)) return false; - return (!Arrays.asList(PlatinumSludgeOverHaul.OPBLACKLIST) - .contains(GT_OreDictUnificator.getAssociation(stack).mPrefix)) + return !Arrays.asList(PlatinumSludgeOverHaul.OPBLACKLIST) + .contains(GT_OreDictUnificator.getAssociation(stack).mPrefix) || Arrays.asList(PlatinumSludgeOverHaul.BLACKLIST) .contains(GT_OreDictUnificator.getAssociation(stack).mMaterial.mMaterial); } @@ -947,9 +926,8 @@ private static boolean isInBlackList(ItemStack stack) { if (GTPlusPlus.isModLoaded()) { try { if (Class.forName("gtPlusPlus.core.item.base.BaseItemComponent") - .isAssignableFrom(stack.getItem().getClass()) - && !(stack.getUnlocalizedName().contains("dust") - || stack.getUnlocalizedName().contains("Dust"))) + .isAssignableFrom(stack.getItem().getClass()) && !stack.getUnlocalizedName().contains("dust") + && !stack.getUnlocalizedName().contains("Dust")) return true; if (Class.forName("gtPlusPlus.core.block.base.BlockBaseModular") .isAssignableFrom(Block.getBlockFromItem(stack.getItem()).getClass())) diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java index a71bfe8b9..5d6e82a92 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java @@ -60,17 +60,18 @@ import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_OreDictUnificator; -@SuppressWarnings("ALL") public class Werkstoff implements IColorModulationContainer, ISubTagContainer { public static final LinkedHashSet werkstoffHashSet = new LinkedHashSet<>(); public static final LinkedHashMap werkstoffHashMap = new LinkedHashMap<>(); public static final LinkedHashMap werkstoffNameHashMap = new LinkedHashMap<>(); - public static final Map modNameOverrides = new HashMap() { + public static final Map modNameOverrides = new HashMap<>() { + + private static final long serialVersionUID = 6399917619058898648L; { - put(GalaxySpace.ID, DARK_PURPLE + "GalaxySpace"); + this.put(GalaxySpace.ID, DARK_PURPLE + "GalaxySpace"); } }; @@ -139,7 +140,7 @@ public Werkstoff(Materials materials, Werkstoff.GenerationFeatures generationFea materials.mIconSet, (List) materials.mOreByProducts, new Pair<>(materials, 1)); - if (!(mID > 31_766 && mID <= 32_767)) throw new IllegalArgumentException(); + if (mID <= 31_766 || mID > 32_767) throw new IllegalArgumentException(); this.stats.mass = materials.getMass(); this.stats.protons = materials.getProtons(); this.stats.meltingPoint = materials.mMeltingPoint; @@ -160,6 +161,7 @@ public Werkstoff(Materials materials, Werkstoff.GenerationFeatures generationFea } } + @SafeVarargs public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, int meltingpoint, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, Pair... contents) { @@ -174,6 +176,7 @@ public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, int mel contents); } + @SafeVarargs public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, Pair... contents) { @@ -188,6 +191,7 @@ public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, contents); } + @SafeVarargs public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, int meltingpoint, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, List oreByProduct, Pair... contents) { @@ -203,6 +207,7 @@ public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, int mel contents); } + @SafeVarargs public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, List oreByProduct, Pair... contents) { @@ -218,6 +223,7 @@ public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, contents); } + @SafeVarargs public Werkstoff(short[] rgba, String toolTip, String defaultName, Werkstoff.Types type, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, List oreByProduct, Pair... contents) { @@ -234,6 +240,7 @@ public Werkstoff(short[] rgba, String toolTip, String defaultName, Werkstoff.Typ contents); } + @SafeVarargs public Werkstoff(short[] rgba, String defaultName, Werkstoff.Stats stats, Werkstoff.Types type, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, List oreByProduct, Pair... contents) { @@ -242,12 +249,14 @@ public Werkstoff(short[] rgba, String defaultName, Werkstoff.Stats stats, Werkst this.mOreByProducts.addAll(oreByProduct); } + @SafeVarargs public Werkstoff(short[] rgba, String defaultName, Werkstoff.Stats stats, Werkstoff.Types type, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, Pair... contents) { this(rgba, defaultName, "", stats, type, generationFeatures, mID, texSet, contents); } + @SafeVarargs public Werkstoff(short[] rgba, String defaultName, String toolTip, Werkstoff.Stats stats, Werkstoff.Types type, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, List oreByProduct, Pair... contents) { @@ -256,6 +265,7 @@ public Werkstoff(short[] rgba, String defaultName, String toolTip, Werkstoff.Sta this.mOreByProducts.addAll(oreByProduct); } + @SafeVarargs public Werkstoff(short[] rgba, String defaultName, String toolTip, Werkstoff.Stats stats, Werkstoff.Types type, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, Pair... contents) { @@ -282,7 +292,7 @@ public Werkstoff(short[] rgba, String defaultName, String toolTip, Werkstoff.Sta if (((Materials) p.getKey()).mMaterialList.size() > 1 && p.getValue() > 1) this.toolTip += "(" + getFormula((Materials) p.getKey()) + ")" - + (BW_Util.subscriptNumber(p.getValue())); + + BW_Util.subscriptNumber(p.getValue()); else this.toolTip += getFormula((Materials) p.getKey()) + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); } @@ -290,17 +300,15 @@ public Werkstoff(short[] rgba, String defaultName, String toolTip, Werkstoff.Sta if (((Werkstoff) p.getKey()).CONTENTS.size() > 1 && p.getValue() > 1) this.toolTip += "(" + getFormula((Werkstoff) p.getKey()) + ")" - + (BW_Util.subscriptNumber(p.getValue())); + + BW_Util.subscriptNumber(p.getValue()); else this.toolTip += getFormula((Werkstoff) p.getKey()) + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); } - } else { - if (p.getKey() instanceof Materials) { - this.toolTip += getFormula((Materials) p.getKey()) - + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); - } else if (p.getKey() instanceof Werkstoff) this.toolTip += getFormula((Werkstoff) p.getKey()) + } else if (p.getKey() instanceof Materials) { + this.toolTip += getFormula((Materials) p.getKey()) + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); - } + } else if (p.getKey() instanceof Werkstoff) this.toolTip += getFormula((Werkstoff) p.getKey()) + + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); } } else this.toolTip = toolTip; @@ -368,7 +376,7 @@ public Werkstoff(short[] rgba, String defaultName, String toolTip, Werkstoff.Sta Werkstoff.werkstoffHashMap.put(this.mID, this); Werkstoff.werkstoffNameHashMap.put(this.defaultName, this); - this.owner = getMaterialOwner(); + this.owner = this.getMaterialOwner(); } private static String getFormula(Materials material) { @@ -380,23 +388,24 @@ private static String getFormula(Werkstoff material) { } public Werkstoff addAdditionalOreDict(String s) { - ADDITIONAL_OREDICT.add(s); + this.ADDITIONAL_OREDICT.add(s); return this; } public HashSet getADDITIONAL_OREDICT() { - return ADDITIONAL_OREDICT; + return this.ADDITIONAL_OREDICT; } public void setTCAspects(Pair... pAspectsArr) { this.stats.mTC_Aspects = pAspectsArr; } + @SuppressWarnings("unchecked") public Pair[] getTCAspects(int ratio) { if (this.stats.mTC_Aspects == null) { HashSet tc_aspectStacks = new HashSet<>(); HashSet> set = new HashSet<>(); - for (Pair p : this.getContents().getValue()) { + for (Pair p : this.getContents().getValue()) { if (p.getKey() instanceof Materials) tc_aspectStacks.addAll(((Materials) p.getKey()).mAspects); if (p.getKey() instanceof Werkstoff) set.addAll(Arrays.asList(((Werkstoff) p.getKey()).getTCAspects())); } @@ -414,7 +423,7 @@ public Pair[] getTCAspects(int ratio) { public List getGTWrappedTCAspects() { final List ret = new ArrayList<>(); - Arrays.stream(getTCAspects()).forEach(objectIntegerPair -> { + Arrays.stream(this.getTCAspects()).forEach(objectIntegerPair -> { try { new TC_Aspects.TC_AspectStack( TC_Aspects.valueOf( @@ -448,7 +457,7 @@ public Pair>> getContents case MIXTURE: case BIOLOGICAL: { for (int i = 0; i < this.CONTENTS.toArray().length; i++) { - ret += ((Pair) this.CONTENTS.toArray()[i]).getValue(); + ret += (int) this.CONTENTS.toArray(new Pair[0])[i].getValue(); } break; } @@ -491,12 +500,12 @@ public String getDefaultName() { public String getLocalizedName() { return GT_LanguageManager.addStringLocalization( String.format("bw.werkstoff.%05d.name", this.mID), - defaultName, + this.defaultName, !GregTech_API.sPostloadFinished); } public String getVarName() { - return this.defaultName.replaceAll(" ", ""); + return this.defaultName.replace(" ", ""); } public String getToolTip() { @@ -506,7 +515,7 @@ public String getToolTip() { public String getLocalizedToolTip() { return GT_LanguageManager.addStringLocalization( String.format("bw.werkstoff.%05d.tooltip", this.mID), - toolTip, + this.toolTip, !GregTech_API.sPostloadFinished); } @@ -579,31 +588,28 @@ public ItemStack get(OrePrefixes prefixes, int amount) { } public byte getToolQuality() { - return this.stats - .getQualityOverride() > 0 - ? this.stats.getQualityOverride() - : (byte) ((15f * (((float) this.getStats().getProtons() / 188f) - + (float) this.getStats().getMeltingPoint() / 10801f)) - / (float) this.getContents().getKey()); + return this.stats.getQualityOverride() > 0 ? this.stats.getQualityOverride() + : (byte) (15f * (this.getStats().getProtons() / 188f + this.getStats().getMeltingPoint() / 10801f) + / (float) this.getContents().getKey()); } public float getToolSpeed() { return this.stats.getSpeedOverride() > 0f ? this.stats.getSpeedOverride() : Math.max( 1f, - 2f * ((float) -this.getStats().getMass() + 0.1f * (float) this.getStats().getMeltingPoint() - + (float) this.getStats().getProtons()) + 2f * (-this.getStats().getMass() + 0.1f * this.getStats().getMeltingPoint() + + this.getStats().getProtons()) * 0.1f / (float) this.getContents().getKey() * 0.1f - * (float) this.getToolQuality()); + * this.getToolQuality()); } public int getDurability() { return this.stats.getDurOverride() > 0 ? this.stats.getDurOverride() - : (int) (this.stats.durMod - * ((0.01f * (float) this.getStats().getMeltingPoint() * (float) this.getStats().getMass()) - / (float) this.getContents().getKey())); + : (int) (this.stats.durMod * (0.01f * this.getStats().getMeltingPoint() + * this.getStats().getMass() + / (float) this.getContents().getKey())); } /** @@ -631,7 +637,7 @@ public boolean doesOreDictedItemExists(OrePrefixes prefixes) { } public String getOwner() { - return owner; + return this.owner; } private String getMaterialOwner() { @@ -656,15 +662,11 @@ public enum Types { UNDEFINED; public static Werkstoff.Stats getDefaultStatForType(Werkstoff.Types T) { - switch (T) { - case COMPOUND: - case BIOLOGICAL: - return new Werkstoff.Stats().setElektrolysis(true); - case MIXTURE: - return new Werkstoff.Stats().setCentrifuge(true); - default: - return new Werkstoff.Stats(); - } + return switch (T) { + case COMPOUND, BIOLOGICAL -> new Werkstoff.Stats().setElektrolysis(true); + case MIXTURE -> new Werkstoff.Stats().setCentrifuge(true); + default -> new Werkstoff.Stats(); + }; } } @@ -750,7 +752,7 @@ public static void initPrefixLogic() { } public void setExtension() { - isExtension = !isExtension; + this.isExtension = !this.isExtension; } public static int getPrefixDataRaw(OrePrefixes prefixes) { @@ -759,7 +761,7 @@ public static int getPrefixDataRaw(OrePrefixes prefixes) { } public boolean isExtension() { - return isExtension; + return this.isExtension; } // public byte toGenerateSecondary = 0b0000000; @@ -809,19 +811,19 @@ public Werkstoff.GenerationFeatures enforceUnification() { @Deprecated public Werkstoff.GenerationFeatures removeGems() { - if (this.hasGems()) this.toGenerate = (long) (this.toGenerate ^ 0b100); + if (this.hasGems()) this.toGenerate = this.toGenerate ^ 0b100; return this; } @Deprecated public Werkstoff.GenerationFeatures removeDusts() { - if (this.hasDusts()) this.toGenerate = (long) (this.toGenerate ^ 0b1); + if (this.hasDusts()) this.toGenerate = this.toGenerate ^ 0b1; return this; } @Deprecated public Werkstoff.GenerationFeatures removeOres() { - if (this.hasOres()) this.toGenerate = (long) (this.toGenerate ^ 0b1000); + if (this.hasOres()) this.toGenerate = this.toGenerate ^ 0b1000; return this; } @@ -886,7 +888,7 @@ public boolean hasSifterRecipes() { } public Werkstoff.GenerationFeatures onlyDust() { - this.toGenerate = (long) (0b1); + this.toGenerate = 0b1; return this; } @@ -894,17 +896,17 @@ public Werkstoff.GenerationFeatures onlyDust() { * Automatically adds Simple Metal Working Items */ public Werkstoff.GenerationFeatures addMetalItems() { - this.toGenerate = (long) (this.addSimpleMetalWorkingItems().toGenerate | 0b10); + this.toGenerate = this.addSimpleMetalWorkingItems().toGenerate | 0b10; return this; } public Werkstoff.GenerationFeatures disable() { - this.toGenerate = (long) (0); + this.toGenerate = 0; return this; } public Werkstoff.GenerationFeatures addCells() { - this.toGenerate = (long) (this.toGenerate | 0b10000); + this.toGenerate = this.toGenerate | 0b10000; return this; } @@ -919,7 +921,7 @@ public boolean hasMolten() { } public Werkstoff.GenerationFeatures addMolten() { - this.toGenerate = (long) (this.toGenerate | 0b1000000); + this.toGenerate = this.toGenerate | 0b1000000; return this; } @@ -927,17 +929,17 @@ public Werkstoff.GenerationFeatures addMolten() { * Automatically adds Simple Metal Working Items */ public Werkstoff.GenerationFeatures addGems() { - this.toGenerate = (long) (this.addSimpleMetalWorkingItems().toGenerate | 0x4); + this.toGenerate = this.addSimpleMetalWorkingItems().toGenerate | 0x4; return this; } public Werkstoff.GenerationFeatures addSimpleMetalWorkingItems() { - this.toGenerate = (long) (this.toGenerate | 0b10000000); + this.toGenerate = this.toGenerate | 0b10000000; return this; } public Werkstoff.GenerationFeatures addCasings() { - this.toGenerate = (long) (this.toGenerate | 0x382); + this.toGenerate = this.toGenerate | 0x382; return this; } @@ -947,22 +949,22 @@ public boolean hasSimpleMetalWorkingItems() { } public Werkstoff.GenerationFeatures addCraftingMetalWorkingItems() { - this.toGenerate = (long) (this.toGenerate | 0x100); + this.toGenerate = this.toGenerate | 0x100; return this; } public Werkstoff.GenerationFeatures addMultipleIngotMetalWorkingItems() { - this.toGenerate = (long) (this.toGenerate | 0x200); + this.toGenerate = this.toGenerate | 0x200; return this; } public Werkstoff.GenerationFeatures addPrefix(OrePrefixes prefixes) { - this.toGenerate = (long) (this.toGenerate | this.getPrefixDataRaw(prefixes)); + this.toGenerate = this.toGenerate | getPrefixDataRaw(prefixes); return this; } public Werkstoff.GenerationFeatures removePrefix(OrePrefixes prefixes) { - this.toGenerate = (long) (this.toGenerate ^ this.getPrefixDataRaw(prefixes)); + this.toGenerate = this.toGenerate ^ getPrefixDataRaw(prefixes); return this; } } @@ -1027,7 +1029,7 @@ public Werkstoff.Stats setEbfGasRecipeConsumedAmountMultiplier(double amountMult } public int getDurOverride() { - return durOverride; + return this.durOverride; } public Werkstoff.Stats setDurOverride(int durOverride) { @@ -1036,7 +1038,7 @@ public Werkstoff.Stats setDurOverride(int durOverride) { } public float getSpeedOverride() { - return speedOverride; + return this.speedOverride; } public Werkstoff.Stats setSpeedOverride(float speedOverride) { @@ -1045,7 +1047,7 @@ public Werkstoff.Stats setSpeedOverride(float speedOverride) { } public byte getQualityOverride() { - return qualityOverride; + return this.qualityOverride; } public Werkstoff.Stats setQualityOverride(byte qualityOverride) { @@ -1068,7 +1070,7 @@ public Werkstoff.Stats setQualityOverride(byte qualityOverride) { float durMod = 1f; public float getDurMod() { - return durMod; + return this.durMod; } public void setDurMod(float durMod) { @@ -1097,14 +1099,12 @@ Pair[] getmTC_Aspects() { @Override public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof Werkstoff.Stats)) return false; + if (!(o instanceof Werkstoff.Stats that)) return false; - Werkstoff.Stats that = (Werkstoff.Stats) o; - - if (this.boilingPoint != that.boilingPoint) return false; - if (this.meltingPoint != that.meltingPoint) return false; - if (this.mass != that.mass) return false; - if (this.protons != that.protons) return false; + if (this.boilingPoint != that.boilingPoint || this.meltingPoint != that.meltingPoint + || this.mass != that.mass + || this.protons != that.protons) + return false; if (this.neutrons != that.neutrons) return false; if (this.electrons != that.electrons) return false; if (Math.abs(this.ebfGasRecipeTimeMultiplier - that.ebfGasRecipeTimeMultiplier) > 1.0e-6D) return false; @@ -1159,7 +1159,7 @@ public Werkstoff.Stats setToxic(boolean toxic) { byte enchantmentlvl = 3; public byte getEnchantmentlvl() { - return enchantmentlvl; + return this.enchantmentlvl; } public Werkstoff.Stats setEnchantmentlvl(byte enchantmentlvl) { @@ -1193,7 +1193,7 @@ public Werkstoff.Stats setMeltingVoltage(int meltingVoltage) { } public int getMeltingVoltage() { - return meltingVoltage; + return this.meltingVoltage; } public boolean isElektrolysis() { @@ -1223,9 +1223,8 @@ public boolean isGas() { public FluidState getFluidState() { if ((this.quality & 0x40) != 0) { return FluidState.GAS; - } else { - return FluidState.LIQUID; } + return FluidState.LIQUID; } public Werkstoff.Stats setGas(boolean gas) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java index 23c0331b9..b9855ab1a 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java @@ -139,7 +139,7 @@ import ic2.api.recipe.RecipeOutput; import ic2.api.recipe.Recipes; -@SuppressWarnings({ "unchecked", "deprecation" }) +@SuppressWarnings("deprecation") public class WerkstoffLoader { private WerkstoffLoader() {} @@ -169,7 +169,7 @@ public static void setUp() { } catch (NullPointerException | IllegalArgumentException ignored) {} // add tiberium - Element t = EnumUtils.createNewElement("Tr", 123L, 203L, 0L, -1L, null, "Tiberium", false); + EnumUtils.createNewElement("Tr", 123L, 203L, 0L, -1L, null, "Tiberium", false); bottle.mDefaultStackSize = 1; Werkstoff.GenerationFeatures.initPrefixLogic(); @@ -1440,7 +1440,7 @@ public static ItemStack getCorrespondingItemStackUnsafe(OrePrefixes orePrefixes, if (ret != null) return ret; } if (orePrefixes == ore) return new ItemStack(WerkstoffLoader.BWOres, amount, werkstoff.getmID()); - else if (orePrefixes == oreSmall) return new ItemStack(WerkstoffLoader.BWSmallOres, amount, werkstoff.getmID()); + if (orePrefixes == oreSmall) return new ItemStack(WerkstoffLoader.BWSmallOres, amount, werkstoff.getmID()); else if (orePrefixes == block) return new ItemStack(WerkstoffLoader.BWBlocks, amount, werkstoff.getmID()); else if (orePrefixes == OrePrefixes.blockCasing) return new ItemStack(WerkstoffLoader.BWBlockCasings, amount, werkstoff.getmID()); @@ -1453,7 +1453,7 @@ else if (orePrefixes == OrePrefixes.blockCasingAdvanced) public static ItemStack getCorrespondingItemStack(OrePrefixes orePrefixes, Werkstoff werkstoff, int amount) { ItemStack stack = getCorrespondingItemStackUnsafe(orePrefixes, werkstoff, amount); if (stack != null) return stack; - else MainMod.LOGGER.catching( + MainMod.LOGGER.catching( Level.ERROR, new Exception( "NO SUCH ITEM! " + orePrefixes @@ -1478,9 +1478,9 @@ public static void runInit() { MainMod.LOGGER.info( "Making Meta Items for BW Materials took " + (timepost - timepre) + "ns/" - + ((timepost - timepre) / 1000000) + + (timepost - timepre) / 1000000 + "ms/" - + ((timepost - timepre) / 1000000000) + + (timepost - timepre) / 1000000000 + "s!"); } @@ -1491,12 +1491,12 @@ public static void run() { ProgressManager.ProgressBar progressBar = ProgressManager .push("Register BW Materials", Werkstoff.werkstoffHashSet.size() + 1); DebugLog.log("Loading Recipes" + (System.nanoTime() - timepre)); - Integer[] clsArr = new Integer[0]; + Integer[] clsArr = {}; int size = 0; if (BetterLoadingScreen.isModLoaded()) clsArr = CLSCompat.initCls(); - IWerkstoffRunnable[] werkstoffRunnables = new IWerkstoffRunnable[] { new ToolLoader(), new DustLoader(), - new GemLoader(), new SimpleMetalLoader(), new CasingLoader(), new AspectLoader(), new OreLoader(), + IWerkstoffRunnable[] werkstoffRunnables = { new ToolLoader(), new DustLoader(), new GemLoader(), + new SimpleMetalLoader(), new CasingLoader(), new AspectLoader(), new OreLoader(), new CrushedLoader(), new CraftingMaterialLoader(), new CellLoader(), new MoltenCellLoader(), new MultipleMetalLoader(), new MetalLoader(), new BlockLoader() }; @@ -1536,14 +1536,15 @@ public static void run() { MainMod.LOGGER.info( "Loading Processing Recipes for BW Materials took " + (timepost - timepre) + "ns/" - + ((timepost - timepre) / 1000000) + + (timepost - timepre) / 1000000 + "ms/" - + ((timepost - timepre) / 1000000000) + + (timepost - timepre) / 1000000000 + "s!"); registered = true; } } + @SuppressWarnings("unchecked") private static void addSubTags() { WerkstoffLoader.CubicZirconia.getStats().setDurOverride(Materials.Diamond.mDurability); WerkstoffLoader.HDCS.getStats().setSpeedOverride(Materials.HSSS.mToolSpeed); @@ -1590,7 +1591,8 @@ private static void addSubTags() { if (pair.getKey() instanceof Materials && pair.getKey() == Materials.Neodymium) { W.add(SubTag.ELECTROMAGNETIC_SEPERATION_NEODYMIUM); break; - } else if (pair.getKey() instanceof Materials && pair.getKey() == Materials.Iron) { + } + if (pair.getKey() instanceof Materials && pair.getKey() == Materials.Iron) { W.add(SubTag.ELECTROMAGNETIC_SEPERATION_IRON); break; } else if (pair.getKey() instanceof Materials && pair.getKey() == Materials.Gold) { @@ -1649,12 +1651,13 @@ private static void addItemsForGeneration() { && (werkstoff.getGenerationFeatures().toGenerate & p.mMaterialGenerationBits) != 0 && OreDictHandler.getItemStack(werkstoff.getDefaultName(), p, 1) != null) { DebugLog.log( - "Found: " + (p + werkstoff.getVarName()) + "Found: " + p + + werkstoff.getVarName() + " in GT material system, disable and reroute my Items to that, also add a Tooltip."); werkstoff.getGenerationFeatures().setBlacklist(p); } - WerkstoffLoader.toGenerateGlobal = (WerkstoffLoader.toGenerateGlobal - | werkstoff.getGenerationFeatures().toGenerate); + WerkstoffLoader.toGenerateGlobal = WerkstoffLoader.toGenerateGlobal + | werkstoff.getGenerationFeatures().toGenerate; } DebugLog.log("GlobalGeneration: " + WerkstoffLoader.toGenerateGlobal); if ((WerkstoffLoader.toGenerateGlobal & 0b1) != 0) { @@ -1781,8 +1784,8 @@ static void gameRegistryHandler() { } private static void runGTItemDataRegistrator() { - IWerkstoffRunnable[] registrations = new IWerkstoffRunnable[] { new BridgeMaterialsLoader(), - new AssociationLoader(), new CasingRegistrator() }; + IWerkstoffRunnable[] registrations = { new BridgeMaterialsLoader(), new AssociationLoader(), + new CasingRegistrator() }; for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) { for (IWerkstoffRunnable registration : registrations) { registration.run(werkstoff); @@ -1821,6 +1824,7 @@ public static void addVanillaCasingsToGTOreDictUnificator() { * used for the miners mostly removing this hacky material from the materials map instantly. we only need the item * data. */ + @SuppressWarnings("unchecked") private static void addFakeItemDataToInWorldBlocksAndCleanUpFakeData() { Map MATERIALS_MAP = null; @@ -1855,7 +1859,7 @@ public static void removeIC2Recipes() { Set> remset = new HashSet<>(); for (Map.Entry curr : Recipes.macerator.getRecipes().entrySet()) { if (curr.getKey() instanceof RecipeInputOreDict) { - if (((RecipeInputOreDict) curr.getKey()).input.equalsIgnoreCase("oreNULL")) { + if ("oreNULL".equalsIgnoreCase(((RecipeInputOreDict) curr.getKey()).input)) { remset.add(curr); } for (ItemStack stack : curr.getValue().items) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AdditionalRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AdditionalRecipes.java index 0d3fdc2f5..b7387653b 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AdditionalRecipes.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AdditionalRecipes.java @@ -79,10 +79,10 @@ public class AdditionalRecipes { - private static BWRecipes.BW_Recipe_Map_LiquidFuel sAcidGenFuels = ((BWRecipes.BW_Recipe_Map_LiquidFuel) BWRecipes.instance - .getMappingsFor((byte) 2)); - private static BWRecipes.BacteriaVatRecipeMap sBacteriaVat = ((BWRecipes.BacteriaVatRecipeMap) BWRecipes.instance - .getMappingsFor((byte) 1)); + private static BWRecipes.BW_Recipe_Map_LiquidFuel sAcidGenFuels = (BWRecipes.BW_Recipe_Map_LiquidFuel) BWRecipes.instance + .getMappingsFor((byte) 2); + private static BWRecipes.BacteriaVatRecipeMap sBacteriaVat = (BWRecipes.BacteriaVatRecipeMap) BWRecipes.instance + .getMappingsFor((byte) 1); private static GT_Recipe.GT_Recipe_Map sBiolab = BWRecipes.instance.getMappingsFor((byte) 0); private static void runBWRecipes() { @@ -458,7 +458,7 @@ public static void run() { new FluidStack[] { Materials.SolderingAlloy.getMolten((i + 1) * 36) }, null, (i + 1) * 750, - BW_Util.getMachineVoltageFromTier((i + 1)), + BW_Util.getMachineVoltageFromTier(i + 1), CLEANROOM)); } // IV-LuV @@ -478,7 +478,7 @@ public static void run() { new FluidStack[] { new FluidStack(solderIndalloy, (i + 1) * 36) }, null, (i + 1) * 750, - BW_Util.getMachineVoltageFromTier((i + 1)), + BW_Util.getMachineVoltageFromTier(i + 1), CLEANROOM)); } // ZPM @@ -486,7 +486,7 @@ public static void run() { new BWRecipes.DynamicGTRecipe( false, new ItemStack[] { BW_Meta_Items.getNEWCIRCUITS().getStack(3), - WerkstoffLoader.MagnetoResonaticDust.get(gemExquisite, (1)), + WerkstoffLoader.MagnetoResonaticDust.get(gemExquisite, 1), BW_Meta_Items.getNEWCIRCUITS().getStack(7 + 3), ItemList.Circuit_Parts_DiodeASMD.get((7 + 6) * 4), ItemList.Circuit_Parts_CapacitorASMD.get((7 + 6) * 4), @@ -504,7 +504,7 @@ public static void run() { new BWRecipes.DynamicGTRecipe( false, new ItemStack[] { BW_Meta_Items.getNEWCIRCUITS().getStack(3), - WerkstoffLoader.MagnetoResonaticDust.get(gemExquisite, (1)), + WerkstoffLoader.MagnetoResonaticDust.get(gemExquisite, 1), BW_Meta_Items.getNEWCIRCUITS().getStack(8 + 3), ItemList.Circuit_Parts_DiodeASMD.get((8 + 6) * 4), ItemList.Circuit_Parts_CapacitorASMD.get((8 + 6) * 4), @@ -523,7 +523,7 @@ public static void run() { new BWRecipes.DynamicGTRecipe( false, new ItemStack[] { BW_Meta_Items.getNEWCIRCUITS().getStack(3), - WerkstoffLoader.MagnetoResonaticDust.get(gemExquisite, (1)), + WerkstoffLoader.MagnetoResonaticDust.get(gemExquisite, 1), BW_Meta_Items.getNEWCIRCUITS().getStack(i + 3), ItemList.Circuit_Parts_DiodeXSMD.get((i + 6) * 4), ItemList.Circuit_Parts_CapacitorXSMD.get((i + 6) * 4), @@ -648,7 +648,7 @@ private static void oldGThelperMethod() { Materials werkstoffBridgeMaterial = null; boolean aElementSet = false; for (Element e : Element.values()) { - if (e.toString().equals("Uuo")) { + if ("Uuo".equals(e.toString())) { werkstoffBridgeMaterial = werkstoff.getBridgeMaterial() != null ? werkstoff.getBridgeMaterial() : new Materials( -1, diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/AspectLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/AspectLoader.java index f31945f15..03b9315c1 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/AspectLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/AspectLoader.java @@ -48,13 +48,11 @@ public void run(Werkstoff werkstoff) { werkstoff.getTCAspects( enabledOrePrefixes == OrePrefixes.ore ? 1 : (int) (enabledOrePrefixes.mMaterialAmount / 3628800L))); - } else if (enabledOrePrefixes.mMaterialAmount >= 0L) { - if (Objects.nonNull(WerkstoffLoader.items.get(enabledOrePrefixes))) - // noinspection unchecked - ThaumcraftHandler.AspectAdder.addAspectViaBW( - werkstoff.get(enabledOrePrefixes), - new Pair<>(TC_Aspects.PERDITIO.mAspect, 1)); - } + } else if (enabledOrePrefixes.mMaterialAmount >= 0L + && Objects.nonNull(WerkstoffLoader.items.get(enabledOrePrefixes))) + ThaumcraftHandler.AspectAdder.addAspectViaBW( + werkstoff.get(enabledOrePrefixes), + new Pair<>(TC_Aspects.PERDITIO.mAspect, 1)); } } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CasingLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CasingLoader.java index cb8ce95b4..794255493 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CasingLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CasingLoader.java @@ -40,11 +40,11 @@ public void run(Werkstoff werkstoff) { if (werkstoff == BW_GT_MaterialReference.Wood /* || werkstoff == BW_GT_MaterialReference.WoodSealed */) { addCasingRecipes(werkstoff, plank); } else { - if (!(werkstoff.hasGenerationFeature(blockCasing) && werkstoff.doesOreDictedItemExists(plate) - && werkstoff.doesOreDictedItemExists(screw) - && werkstoff.doesOreDictedItemExists(gearGtSmall) - && werkstoff.doesOreDictedItemExists(gearGt) - && werkstoff.doesOreDictedItemExists(plateDouble))) + if (!werkstoff.hasGenerationFeature(blockCasing) || !werkstoff.doesOreDictedItemExists(plate) + || !werkstoff.doesOreDictedItemExists(screw) + || !werkstoff.doesOreDictedItemExists(gearGtSmall) + || !werkstoff.doesOreDictedItemExists(gearGt) + || !werkstoff.doesOreDictedItemExists(plateDouble)) return; addCasingRecipes(werkstoff, plateDouble); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CellLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CellLoader.java index 1d8f8678a..338269770 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CellLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CellLoader.java @@ -127,7 +127,7 @@ public void run(Werkstoff werkstoff) { stOutputs.add( ((Werkstoff) container.getKey()).get( dust, - (tracker.get(container.getKey()).getKey() + container.getValue()))); + tracker.get(container.getKey()).getKey() + container.getValue())); stOutputs.remove(tracker.get(container.getKey()).getValue() + 1); } } @@ -218,7 +218,7 @@ public void run(Werkstoff werkstoff) { } - if (werkstoff.getType().equals(Werkstoff.Types.ELEMENT)) { + if (Werkstoff.Types.ELEMENT.equals(werkstoff.getType())) { Materials werkstoffBridgeMaterial = null; boolean ElementSet = false; for (Element e : Element.values()) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CrushedLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CrushedLoader.java index 490946101..23a1576eb 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CrushedLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/CrushedLoader.java @@ -50,7 +50,7 @@ public void run(Werkstoff werkstoff) { if (!werkstoff.hasItemType(ore) || !werkstoff.hasItemType(dust)) return; if (werkstoff.hasItemType(ingot) && !werkstoff.getStats().isBlastFurnace()) { - if (werkstoff.getType().equals(Werkstoff.Types.ELEMENT)) { + if (Werkstoff.Types.ELEMENT.equals(werkstoff.getType())) { GT_ModHandler.addSmeltingRecipe(werkstoff.get(crushed), werkstoff.get(nugget, 10)); GT_ModHandler.addSmeltingRecipe(werkstoff.get(crushedPurified), werkstoff.get(nugget, 10)); GT_ModHandler.addSmeltingRecipe(werkstoff.get(crushedCentrifuged), werkstoff.get(nugget, 10)); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/DustLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/DustLoader.java index 48d37851e..74a2d7841 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/DustLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/DustLoader.java @@ -70,104 +70,80 @@ public void run(Werkstoff werkstoff) { || werkstoff.getGenerationFeatures().hasChemicalRecipes()) { for (Pair container : werkstoff.getContents().getValue() .toArray(new Pair[0])) { - if (container.getKey() instanceof Materials) { - if ((((Materials) container.getKey()).getGas(0) != null - || ((Materials) container.getKey()).getFluid(0) != null - || ((Materials) container.getKey()).mIconSet == TextureSet.SET_FLUID) - && ((Materials) container.getKey()).getDust(0) == null) { - FluidStack tmpFl = ((Materials) container.getKey()).getGas(1000L * container.getValue()); + final ISubTagContainer key = container.getKey(); + final int value = container.getValue(); + if (key instanceof Materials materialKey) { + if ((materialKey.getGas(0) != null || materialKey.getFluid(0) != null + || materialKey.mIconSet == TextureSet.SET_FLUID) && materialKey.getDust(0) == null) { + FluidStack tmpFl = materialKey.getGas(1000L * value); if (tmpFl == null || tmpFl.getFluid() == null) { - tmpFl = ((Materials) container.getKey()).getFluid(1000L * container.getValue()); + tmpFl = materialKey.getFluid(1000L * value); } flOutputs.add(tmpFl); if (flOutputs.size() > 1) { - if (!tracker.containsKey(container.getKey())) { - stOutputs.add(((Materials) container.getKey()).getCells(container.getValue())); - tracker.put( - container.getKey(), - new Pair<>(container.getValue(), stOutputs.size() - 1)); + if (!tracker.containsKey(key)) { + stOutputs.add(materialKey.getCells(value)); + tracker.put(key, new Pair<>(value, stOutputs.size() - 1)); } else { - stOutputs.add( - ((Materials) container.getKey()).getCells( - tracker.get(container.getKey()).getKey() + container.getValue())); - stOutputs.remove(tracker.get(container.getKey()).getValue() + 1); + stOutputs.add(materialKey.getCells(tracker.get(key).getKey() + value)); + stOutputs.remove(tracker.get(key).getValue() + 1); } - cells += container.getValue(); + cells += value; } } else { - if (((Materials) container.getKey()).getDust(container.getValue()) == null) { - if (((Materials) container.getKey()).getCells(container.getValue()) != null - && (((Materials) container.getKey()).getMolten(0) != null - || ((Materials) container.getKey()).getSolid(0) != null)) { - FluidStack tmpFl = ((Materials) container.getKey()) - .getMolten(1000L * container.getValue()); - if (tmpFl == null || tmpFl.getFluid() == null) { - tmpFl = ((Materials) container.getKey()).getSolid(1000L * container.getValue()); - } - flOutputs.add(tmpFl); - if (flOutputs.size() > 1) { - if (!tracker.containsKey(container.getKey())) { - stOutputs.add( - ((Materials) container.getKey()).getCells(container.getValue())); - tracker.put( - container.getKey(), - new Pair<>(container.getValue(), stOutputs.size() - 1)); - } else { - stOutputs.add( - ((Materials) container.getKey()).getCells( - tracker.get(container.getKey()).getKey() - + container.getValue())); - stOutputs.remove(tracker.get(container.getKey()).getValue() + 1); - } - cells += container.getValue(); + if (materialKey.getDust(value) == null) { + if (materialKey.getCells(value) == null + || materialKey.getMolten(0) == null && materialKey.getSolid(0) == null) + continue; + FluidStack tmpFl = materialKey.getMolten(1000L * value); + if (tmpFl == null || tmpFl.getFluid() == null) { + tmpFl = materialKey.getSolid(1000L * value); + } + flOutputs.add(tmpFl); + if (flOutputs.size() > 1) { + if (!tracker.containsKey(key)) { + stOutputs.add(materialKey.getCells(value)); + tracker.put(key, new Pair<>(value, stOutputs.size() - 1)); + } else { + stOutputs.add(materialKey.getCells(tracker.get(key).getKey() + value)); + stOutputs.remove(tracker.get(key).getValue() + 1); } - } else continue; + cells += value; + } } - if (!tracker.containsKey(container.getKey())) { - stOutputs.add(((Materials) container.getKey()).getDust(container.getValue())); - tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); + if (!tracker.containsKey(key)) { + stOutputs.add(materialKey.getDust(value)); + tracker.put(key, new Pair<>(value, stOutputs.size() - 1)); } else { - stOutputs.add( - ((Materials) container.getKey()).getDust( - tracker.get(container.getKey()).getKey() + container.getValue())); - stOutputs.remove(tracker.get(container.getKey()).getValue() + 1); + stOutputs.add(materialKey.getDust(tracker.get(key).getKey() + value)); + stOutputs.remove(tracker.get(key).getValue() + 1); } } - } else if (container.getKey() instanceof Werkstoff) { - if (((Werkstoff) container.getKey()).getStats().isGas() - || ((Werkstoff) container.getKey()).hasItemType(cell)) { - FluidStack tmpFl = ((Werkstoff) container.getKey()) - .getFluidOrGas(1000 * container.getValue()); + } else if (key instanceof Werkstoff werkstoffKey) { + if (werkstoffKey.getStats().isGas() || werkstoffKey.hasItemType(cell)) { + FluidStack tmpFl = werkstoffKey.getFluidOrGas(1000 * value); if (tmpFl == null || tmpFl.getFluid() == null) { - tmpFl = ((Werkstoff) container.getKey()).getFluidOrGas(1000 * container.getValue()); + tmpFl = werkstoffKey.getFluidOrGas(1000 * value); } flOutputs.add(tmpFl); if (flOutputs.size() > 1) { - if (!tracker.containsKey(container.getKey())) { - stOutputs.add(((Werkstoff) container.getKey()).get(cell, container.getValue())); - tracker.put( - container.getKey(), - new Pair<>(container.getValue(), stOutputs.size() - 1)); + if (!tracker.containsKey(key)) { + stOutputs.add(werkstoffKey.get(cell, value)); + tracker.put(key, new Pair<>(value, stOutputs.size() - 1)); } else { - stOutputs.add( - ((Werkstoff) container.getKey()).get( - cell, - tracker.get(container.getKey()).getKey() + container.getValue())); - stOutputs.remove(tracker.get(container.getKey()).getValue() + 1); + stOutputs.add(werkstoffKey.get(cell, tracker.get(key).getKey() + value)); + stOutputs.remove(tracker.get(key).getValue() + 1); } - cells += container.getValue(); + cells += value; } } else { - if (!((Werkstoff) container.getKey()).hasItemType(dust)) continue; - if (!tracker.containsKey(container.getKey())) { - stOutputs.add(((Werkstoff) container.getKey()).get(dust, container.getValue())); - tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); + if (!werkstoffKey.hasItemType(dust)) continue; + if (!tracker.containsKey(key)) { + stOutputs.add(werkstoffKey.get(dust, value)); + tracker.put(key, new Pair<>(value, stOutputs.size() - 1)); } else { - stOutputs.add( - ((Werkstoff) container.getKey()).get( - dust, - (tracker.get(container.getKey()).getKey() + container.getValue()))); - stOutputs.remove(tracker.get(container.getKey()).getValue() + 1); + stOutputs.add(werkstoffKey.get(dust, tracker.get(key).getKey() + value)); + stOutputs.remove(tracker.get(key).getValue() + 1); } } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/GemLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/GemLoader.java index 912452d49..d57ee89da 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/GemLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/GemLoader.java @@ -51,6 +51,7 @@ import gregtech.api.enums.Materials; import gregtech.api.enums.Textures; import gregtech.api.enums.TierEU; +import gregtech.api.interfaces.ITexture; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; @@ -61,7 +62,7 @@ public class GemLoader implements IWerkstoffRunnable { public void run(Werkstoff werkstoff) { if (werkstoff.hasItemType(gem)) { if (werkstoff.getGenerationFeatures().hasSifterRecipes() - || (werkstoff.hasItemType(ore) && werkstoff.hasItemType(dust))) { + || werkstoff.hasItemType(ore) && werkstoff.hasItemType(dust)) { GT_Values.RA.stdBuilder().itemInputs(werkstoff.get(gem, 9)).itemOutputs(werkstoff.get(block)) .duration(15 * SECONDS).eut(2).addTo(sCompressorRecipes); @@ -172,12 +173,15 @@ public void run(Werkstoff werkstoff) { .itemOutputs(werkstoff.get(lens), werkstoff.get(dust, 2)).duration(2 * MINUTES) .eut(TierEU.RECIPE_LV).addTo(sLatheRecipes); + final ITexture texture = TextureFactory.of( + Textures.BlockIcons.MACHINE_CASINGS[2][0], + TextureFactory.of(Textures.BlockIcons.OVERLAY_LENS, werkstoff.getRGBA(), false)); GregTech_API.registerCover( werkstoff.get(lens), - TextureFactory.of( - Textures.BlockIcons.MACHINE_CASINGS[2][0], - TextureFactory.of(Textures.BlockIcons.OVERLAY_LENS, werkstoff.getRGBA(), false)), - new gregtech.common.covers.GT_Cover_Lens(BW_ColorUtil.getDyeFromColor(werkstoff.getRGBA()).mIndex)); + texture, + new gregtech.common.covers.GT_Cover_Lens( + BW_ColorUtil.getDyeFromColor(werkstoff.getRGBA()).mIndex, + texture)); GT_Values.RA.stdBuilder().itemInputs(werkstoff.get(lens)).itemOutputs(werkstoff.get(dustSmall, 3)) .duration(20 * SECONDS).eut(2).addTo(sMaceratorRecipes); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/MoltenCellLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/MoltenCellLoader.java index 4fb6adc37..8e1aa3bd5 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/MoltenCellLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/MoltenCellLoader.java @@ -107,7 +107,6 @@ public void run(Werkstoff werkstoff) { GT_Values.RA.stdBuilder().itemInputs(werkstoff.get(stick)).fluidOutputs(werkstoff.getMolten(72)) .duration(15 * SECONDS).eut(2).addTo(sFluidExtractionRecipes); - } if (werkstoff.getGenerationFeatures().hasMetalCraftingSolidifierRecipes()) { @@ -175,11 +174,10 @@ public void run(Werkstoff werkstoff) { } - if (werkstoff.getGenerationFeatures().hasMultipleMetalSolidifierRecipes()) { - if (!werkstoff.hasItemType(plateDouble)) { - return; - } + if (werkstoff.getGenerationFeatures().hasMultipleMetalSolidifierRecipes() + && !werkstoff.hasItemType(plateDouble)) { // No multiple plate molds + return; } // Tank "Recipe" diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/registration/BridgeMaterialsLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/registration/BridgeMaterialsLoader.java index 46f546319..79d74219a 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/registration/BridgeMaterialsLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/registration/BridgeMaterialsLoader.java @@ -73,75 +73,74 @@ public void run(Werkstoff werkstoff) { 1, null); for (OrePrefixes prefixes : values()) { - if (!(prefixes == cell && werkstoff.getType().equals(Werkstoff.Types.ELEMENT))) { - if (prefixes == dust && werkstoff.getType().equals(Werkstoff.Types.ELEMENT)) { - if (werkstoff.getType().equals(Werkstoff.Types.ELEMENT)) { - boolean ElementSet = false; - for (Element e : Element.values()) { - if (e.toString().equals(werkstoff.getToolTip())) { - if (e.mLinkedMaterials.size() > 0) break; - werkstoffBridgeMaterial = werkstoff.getBridgeMaterial() != null - ? werkstoff.getBridgeMaterial() - : Materials.get(werkstoff.getVarName()) != Materials._NULL - ? Materials.get(werkstoff.getVarName()) - : new Materials( - -1, - werkstoff.getTexSet(), - werkstoff.getToolSpeed(), - werkstoff.getDurability(), - werkstoff.getToolQuality(), - 0, - werkstoff.getRGBA()[0], - werkstoff.getRGBA()[1], - werkstoff.getRGBA()[2], - werkstoff.getRGBA()[3], - werkstoff.getVarName(), - werkstoff.getDefaultName(), - 0, - 0, - werkstoff.getStats().getMeltingPoint(), - werkstoff.getStats().getMeltingPoint(), - werkstoff.getStats().isBlastFurnace(), - false, - 0, - 1, - 1, - null); - werkstoffBridgeMaterial.mElement = e; - e.mLinkedMaterials = new ArrayList<>(); - e.mLinkedMaterials.add(werkstoffBridgeMaterial); - if (werkstoff.hasItemType(dust)) { - GT_OreDictUnificator - .addAssociation(dust, werkstoffBridgeMaterial, werkstoff.get(dust), false); - GT_OreDictUnificator - .set(dust, werkstoffBridgeMaterial, werkstoff.get(dust), true, true); - } - ElementSet = true; - break; + if (prefixes != cell || !Werkstoff.Types.ELEMENT.equals(werkstoff.getType())) { + if (prefixes == dust && Werkstoff.Types.ELEMENT.equals(werkstoff.getType()) + && Werkstoff.Types.ELEMENT.equals(werkstoff.getType())) { + boolean ElementSet = false; + for (Element e : Element.values()) { + if (e.toString().equals(werkstoff.getToolTip())) { + if (e.mLinkedMaterials.size() > 0) break; + werkstoffBridgeMaterial = werkstoff.getBridgeMaterial() != null + ? werkstoff.getBridgeMaterial() + : Materials.get(werkstoff.getVarName()) != Materials._NULL + ? Materials.get(werkstoff.getVarName()) + : new Materials( + -1, + werkstoff.getTexSet(), + werkstoff.getToolSpeed(), + werkstoff.getDurability(), + werkstoff.getToolQuality(), + 0, + werkstoff.getRGBA()[0], + werkstoff.getRGBA()[1], + werkstoff.getRGBA()[2], + werkstoff.getRGBA()[3], + werkstoff.getVarName(), + werkstoff.getDefaultName(), + 0, + 0, + werkstoff.getStats().getMeltingPoint(), + werkstoff.getStats().getMeltingPoint(), + werkstoff.getStats().isBlastFurnace(), + false, + 0, + 1, + 1, + null); + werkstoffBridgeMaterial.mElement = e; + e.mLinkedMaterials = new ArrayList<>(); + e.mLinkedMaterials.add(werkstoffBridgeMaterial); + if (werkstoff.hasItemType(dust)) { + GT_OreDictUnificator + .addAssociation(dust, werkstoffBridgeMaterial, werkstoff.get(dust), false); + GT_OreDictUnificator + .set(dust, werkstoffBridgeMaterial, werkstoff.get(dust), true, true); } + ElementSet = true; + break; } - if (!ElementSet) { - continue; - } + } + if (!ElementSet) { + continue; + } - if (werkstoff.hasItemType(dust)) { - ItemStack scannerOutput = ItemList.Tool_DataOrb.get(1L); - Behaviour_DataOrb.setDataTitle(scannerOutput, "Elemental-Scan"); - Behaviour_DataOrb.setDataName(scannerOutput, werkstoff.getToolTip()); - GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe( - false, - new BWRecipes.DynamicGTRecipe( - false, - new ItemStack[] { werkstoff.get(prefixes) }, - new ItemStack[] { scannerOutput }, - ItemList.Tool_DataOrb.get(1L), - null, - null, - null, - (int) (werkstoffBridgeMaterial.getMass() * 8192L), - 30, - 0)); - } + if (werkstoff.hasItemType(dust)) { + ItemStack scannerOutput = ItemList.Tool_DataOrb.get(1L); + Behaviour_DataOrb.setDataTitle(scannerOutput, "Elemental-Scan"); + Behaviour_DataOrb.setDataName(scannerOutput, werkstoff.getToolTip()); + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe( + false, + new BWRecipes.DynamicGTRecipe( + false, + new ItemStack[] { werkstoff.get(prefixes) }, + new ItemStack[] { scannerOutput }, + ItemList.Tool_DataOrb.get(1L), + null, + null, + null, + (int) (werkstoffBridgeMaterial.getMass() * 8192L), + 30, + 0)); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/oredict/OreDictHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/oredict/OreDictHandler.java index 6bb0da930..bd3b30a95 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/oredict/OreDictHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/oredict/OreDictHandler.java @@ -60,8 +60,8 @@ public static void adaptCacheForWorld() { (short) tmp.getItemDamage()); GameRegistry.UniqueIdentifier UI = GameRegistry.findUniqueIdentifierFor(tmp.getItem()); if (UI == null) UI = GameRegistry.findUniqueIdentifierFor(Block.getBlockFromItem(tmp.getItem())); - if (!UI.modId.equals(MainMod.MOD_ID) && !UI.modId.equals(BartWorksCrossmod.MOD_ID) - && !UI.modId.equals("BWCore")) { + if (!MainMod.MOD_ID.equals(UI.modId) && !BartWorksCrossmod.MOD_ID.equals(UI.modId) + && !"BWCore".equals(UI.modId)) { OreDictHandler.cacheNonBW.add(p2); } } @@ -70,14 +70,15 @@ public static void adaptCacheForWorld() { } public static ItemStack getItemStack(String elementName, OrePrefixes prefixes, int amount) { - if (OreDictHandler.cache.get(prefixes + elementName.replaceAll(" ", "")) != null) { - Pair p = OreDictHandler.cache.get(prefixes + elementName.replaceAll(" ", "")); + if (OreDictHandler.cache.get(prefixes + elementName.replace(" ", "")) != null) { + Pair p = OreDictHandler.cache.get(prefixes + elementName.replace(" ", "")); return new ItemStack(Item.getItemById(p.getKey()), amount, p.getValue()); - } else if (!OreDictionary.getOres(prefixes + elementName.replaceAll(" ", "")).isEmpty()) { + } + if (!OreDictionary.getOres(prefixes + elementName.replace(" ", "")).isEmpty()) { ItemStack tmp = GT_OreDictUnificator - .get(OreDictionary.getOres(prefixes + elementName.replaceAll(" ", "")).get(0).copy()).copy(); + .get(OreDictionary.getOres(prefixes + elementName.replace(" ", "")).get(0).copy()).copy(); OreDictHandler.cache.put( - prefixes + elementName.replaceAll(" ", ""), + prefixes + elementName.replace(" ", ""), new Pair<>(Item.getIdFromItem(tmp.getItem()), (short) tmp.getItemDamage())); tmp.stackSize = amount; return tmp; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_OreLayer.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_OreLayer.java index 1efa707f2..0590b522c 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_OreLayer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_OreLayer.java @@ -138,26 +138,26 @@ public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int int i; if (this.mSecondaryMeta > 0) { for (i = tMinY - 1; i < tMinY + 2; ++i) { - if (shouldPlace(aRandom, cX, eX, tX, cZ, eZ, tZ)) { + if (this.shouldPlace(aRandom, cX, eX, tX, cZ, eZ, tZ)) { wasPlaced = this.setOreBlock(aWorld, tX, i, tZ, this.mSecondaryMeta, false); } } } - if (this.mBetweenMeta > 0 && shouldPlace(aRandom, cX, eX, tX, cZ, eZ, tZ)) { + if (this.mBetweenMeta > 0 && this.shouldPlace(aRandom, cX, eX, tX, cZ, eZ, tZ)) { wasPlaced = this .setOreBlock(aWorld, tX, tMinY + 2 + aRandom.nextInt(2), tZ, this.mBetweenMeta, false); } if (this.mPrimaryMeta > 0) { for (i = tMinY + 3; i < tMinY + 6; ++i) { - if (shouldPlace(aRandom, cX, eX, tX, cZ, eZ, tZ)) { + if (this.shouldPlace(aRandom, cX, eX, tX, cZ, eZ, tZ)) { wasPlaced = this.setOreBlock(aWorld, tX, i, tZ, this.mPrimaryMeta, false); } } } - if (this.mSporadicMeta > 0 && (shouldPlace(aRandom, cX, eX, tX, cZ, eZ, tZ))) { + if (this.mSporadicMeta > 0 && this.shouldPlace(aRandom, cX, eX, tX, cZ, eZ, tZ)) { wasPlaced = this .setOreBlock(aWorld, tX, tMinY - 1 + aRandom.nextInt(7), tZ, this.mSporadicMeta, false); } @@ -174,10 +174,10 @@ public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int private boolean shouldPlace(Random aRandom, int cX, int eX, int tX, int cZ, int eZ, int tZ) { if (aRandom.nextInt( - Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0) - return true; - if (aRandom.nextInt( - Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0) + Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0 + || aRandom.nextInt( + Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) + == 0) return true; return false; } @@ -187,10 +187,10 @@ public boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, TileEntity te = aWorld.getTileEntity(aX, aY, aZ); if (te instanceof BW_MetaGeneratedOreTE || te instanceof GT_TileEntity_Ores) return true; - if ((aMetaData == this.mSporadicMeta && (this.bwOres & 0b0001) != 0) - || (aMetaData == this.mBetweenMeta && (this.bwOres & 0b0010) != 0) - || (aMetaData == this.mPrimaryMeta && (this.bwOres & 0b1000) != 0) - || (aMetaData == this.mSecondaryMeta && (this.bwOres & 0b0100) != 0)) { + if (aMetaData == this.mSporadicMeta && (this.bwOres & 0b0001) != 0 + || aMetaData == this.mBetweenMeta && (this.bwOres & 0b0010) != 0 + || aMetaData == this.mPrimaryMeta && (this.bwOres & 0b1000) != 0 + || aMetaData == this.mSecondaryMeta && (this.bwOres & 0b0100) != 0) { return isSmallOre ? BW_MetaGenerated_SmallOres.setOreBlock( aWorld, @@ -216,52 +216,49 @@ public boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, } public boolean setGTOreBlockSpace(World aWorld, int aX, int aY, int aZ, int aMetaData, Block block) { - if (!GT_TileEntity_Ores.setOreBlock(aWorld, aX, aY, aZ, aMetaData, false, false)) { - aY = Math.min(aWorld.getActualHeight(), Math.max(aY, 1)); - Block tBlock = aWorld.getBlock(aX, aY, aZ); - Block tOreBlock = GregTech_API.sBlockOres1; - if (aMetaData < 0 || tBlock == Blocks.air) { + if (GT_TileEntity_Ores.setOreBlock(aWorld, aX, aY, aZ, aMetaData, false, false)) return true; + aY = Math.min(aWorld.getActualHeight(), Math.max(aY, 1)); + Block tBlock = aWorld.getBlock(aX, aY, aZ); + Block tOreBlock = GregTech_API.sBlockOres1; + if (aMetaData < 0 || tBlock == Blocks.air) { + return false; + } else { + if (!tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, block)) { return false; - } else { - if (!tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, block)) { - return false; - } - aMetaData += 5000; - aWorld.setBlock(aX, aY, aZ, tOreBlock, aMetaData, 0); - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof GT_TileEntity_Ores) { - ((GT_TileEntity_Ores) tTileEntity).mMetaData = (short) aMetaData; - } - return true; } - } else return true; + aMetaData += 5000; + aWorld.setBlock(aX, aY, aZ, tOreBlock, aMetaData, 0); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof GT_TileEntity_Ores ore) { + ore.mMetaData = (short) aMetaData; + } + return true; + } } @Override public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof BW_OreLayer)) return false; - - BW_OreLayer that = (BW_OreLayer) o; - - if (bwOres != that.bwOres) return false; - if (mMinY != that.mMinY) return false; - if (mWeight != that.mWeight) return false; - if (mDensity != that.mDensity) return false; - if (mSize != that.mSize) return false; - if (mMaxY != that.mMaxY) return false; - if (mPrimaryMeta != that.mPrimaryMeta) return false; - if (mSecondaryMeta != that.mSecondaryMeta) return false; - if (mBetweenMeta != that.mBetweenMeta) return false; - return mSporadicMeta == that.mSporadicMeta; + if (!(o instanceof BW_OreLayer that)) return false; + + if (this.bwOres != that.bwOres || this.mMinY != that.mMinY + || this.mWeight != that.mWeight + || this.mDensity != that.mDensity) + return false; + if (this.mSize != that.mSize) return false; + if (this.mMaxY != that.mMaxY) return false; + if (this.mPrimaryMeta != that.mPrimaryMeta) return false; + if (this.mSecondaryMeta != that.mSecondaryMeta) return false; + if (this.mBetweenMeta != that.mBetweenMeta) return false; + return this.mSporadicMeta == that.mSporadicMeta; } @Override public int hashCode() { return MurmurHash3.murmurhash3_x86_32( - ByteBuffer.allocate(37).put(bwOres).putInt(mMinY).putInt(mWeight).putInt(mDensity).putInt(mSize) - .putInt(mMaxY).putInt(mPrimaryMeta).putInt(mSecondaryMeta).putInt(mBetweenMeta) - .putInt(mSporadicMeta).array(), + ByteBuffer.allocate(37).put(this.bwOres).putInt(this.mMinY).putInt(this.mWeight).putInt(this.mDensity) + .putInt(this.mSize).putInt(this.mMaxY).putInt(this.mPrimaryMeta).putInt(this.mSecondaryMeta) + .putInt(this.mBetweenMeta).putInt(this.mSporadicMeta).array(), 0, 37, 31); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WordGenerator.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WordGenerator.java index ac4f909e5..983a3b653 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WordGenerator.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WordGenerator.java @@ -81,7 +81,7 @@ public XSTR getRandom(int xChunk, int zChunk) { XSTR fmlRandom = new XSTR(worldSeed); long xSeed = fmlRandom.nextLong() >> 2 + 1L; long zSeed = fmlRandom.nextLong() >> 2 + 1L; - long chunkSeed = (xSeed * xChunk + zSeed * zChunk) ^ worldSeed; + long chunkSeed = xSeed * xChunk + zSeed * zChunk ^ worldSeed; fmlRandom.setSeed(chunkSeed); return new XSTR(fmlRandom.nextInt()); } @@ -96,10 +96,10 @@ public void run() { if (!BW_WordGenerator.WorldGenContainer.mGenerated.contains(centerChunk) && this.surroundingChunksLoaded(xCenter, zCenter)) { BW_WordGenerator.WorldGenContainer.mGenerated.add(centerChunk); - if ((BW_OreLayer.sWeight > 0) && (BW_OreLayer.sList.size() > 0)) { + if (BW_OreLayer.sWeight > 0 && BW_OreLayer.sList.size() > 0) { boolean temp = true; int tRandomWeight; - for (int i = 0; (i < 256) && (temp); i++) { + for (int i = 0; i < 256 && temp; i++) { tRandomWeight = random.nextInt(BW_OreLayer.sWeight); for (BW_OreLayer tWorldGen : BW_OreLayer.sList) { if (!tWorldGen.isGenerationAllowed(this.mWorld, this.mDimensionType, this.mDimensionType)) @@ -120,7 +120,7 @@ public void run() { this.mChunkGenerator, this.mChunkProvider); ++attempts; - } while ((!placed) && attempts < 25); + } while (!placed && attempts < 25); temp = false; break; } catch (Throwable e) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WorldGenRoss128b.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WorldGenRoss128b.java index 27ece0dee..f043be21b 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WorldGenRoss128b.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WorldGenRoss128b.java @@ -60,6 +60,7 @@ public class BW_WorldGenRoss128b extends BW_OreLayer { + @Override public Block getDefaultBlockToReplace() { return Blocks.stone; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/worldgen/MapGenRuins.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/worldgen/MapGenRuins.java index fb806ccf1..e94e7b6e7 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/worldgen/MapGenRuins.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/worldgen/MapGenRuins.java @@ -39,9 +39,9 @@ import gregtech.api.objects.XSTR; import gregtech.api.threads.GT_Runnable_MachineBlockUpdate; -@SuppressWarnings({ "ALL" }) public abstract class MapGenRuins extends WorldGenerator { + @SuppressWarnings("unchecked") protected Pair[][] ToBuildWith = new Pair[4][0]; @Override @@ -49,6 +49,7 @@ public boolean generate(World p_76484_1_, Random p_76484_2_, int p_76484_3_, int return false; } + @SuppressWarnings("unchecked") protected void setFloorBlocks(int[] metas, Block... blocks) { this.ToBuildWith[0] = new Pair[metas.length]; for (int i = 0; i < metas.length; i++) { @@ -56,6 +57,7 @@ protected void setFloorBlocks(int[] metas, Block... blocks) { } } + @SuppressWarnings("unchecked") protected void setWallBlocks(int[] metas, Block... blocks) { this.ToBuildWith[1] = new Pair[metas.length]; for (int i = 0; i < metas.length; i++) { @@ -63,6 +65,7 @@ protected void setWallBlocks(int[] metas, Block... blocks) { } } + @SuppressWarnings("unchecked") protected void setRoofBlocks(int[] metas, Block... blocks) { this.ToBuildWith[2] = new Pair[metas.length]; for (int i = 0; i < metas.length; i++) { @@ -70,6 +73,7 @@ protected void setRoofBlocks(int[] metas, Block... blocks) { } } + @SuppressWarnings("unchecked") protected void setMiscBlocks(int[] metas, Block... blocks) { this.ToBuildWith[3] = new Pair[metas.length]; for (int i = 0; i < metas.length; i++) { @@ -123,7 +127,7 @@ private TileEntity setGTMachineBlock(World worldObj, int x, int y, int z, int me protected TileEntity reSetGTTileEntity(IGregTechTileEntity bte, World worldObj, int x, int y, int z, int meta) { worldObj.removeTileEntity(x, y, z); this.setBlock(worldObj, x, y, z, Blocks.air, 0); - return setGTMachineBlock(worldObj, x, y, z, meta); + return this.setGTMachineBlock(worldObj, x, y, z, meta); } protected void setGTMachineBlockWChance(World worldObj, int x, int y, int z, Random rand, int airchance, int meta) { @@ -143,12 +147,12 @@ protected void setGTMachine(World worldObj, int x, int y, int z, int meta, Strin try { GT_Runnable_MachineBlockUpdate.setDisabled(); } catch (Throwable ignored) {} - setGTMachineBlock(worldObj, x, y, z, meta); + this.setGTMachineBlock(worldObj, x, y, z, meta); BaseMetaTileEntity BTE = (BaseMetaTileEntity) worldObj.getTileEntity(x, y, z); BTE.setOwnerName(ownerName); BTE.setFrontFacing(facing); BTE = (BaseMetaTileEntity) worldObj.getTileEntity(x, y, z); - checkTile(BTE, worldObj, x, y, z, meta, ownerName, facing, 0); + this.checkTile(BTE, worldObj, x, y, z, meta, ownerName, facing, 0); try { GT_Runnable_MachineBlockUpdate.setEnabled(); } catch (Throwable ignored) {} @@ -158,8 +162,9 @@ private void checkTile(BaseMetaTileEntity BTE, World worldObj, int x, int y, int ForgeDirection facing, int depth) { if (depth < 25) { if (BTE.getMetaTileID() != meta || worldObj.getTileEntity(x, y, z) != BTE || BTE.isInvalid()) { - redoTile(BTE, worldObj, x, y, z, meta, ownerName, facing); - checkTile(BTE, worldObj, x, y, z, meta, ownerName, facing, depth++); + this.redoTile(BTE, worldObj, x, y, z, meta, ownerName, facing); + this.checkTile(BTE, worldObj, x, y, z, meta, ownerName, facing, depth); + depth++; } } else { worldObj.removeTileEntity(x, y, z); @@ -169,7 +174,7 @@ private void checkTile(BaseMetaTileEntity BTE, World worldObj, int x, int y, int private void redoTile(BaseMetaTileEntity BTE, World worldObj, int x, int y, int z, int meta, String ownerName, ForgeDirection facing) { - reSetGTTileEntity(BTE, worldObj, x, y, z, meta); + this.reSetGTTileEntity(BTE, worldObj, x, y, z, meta); BTE = (BaseMetaTileEntity) worldObj.getTileEntity(x, y, z); BTE.setOwnerName(ownerName); BTE.setFrontFacing(facing); @@ -179,10 +184,10 @@ protected void setGTCable(World worldObj, int x, int y, int z, int meta) { try { GT_Runnable_MachineBlockUpdate.setDisabled(); } catch (Throwable ignored) {} - BaseMetaPipeEntity BTE = (BaseMetaPipeEntity) setGTMachineBlock(worldObj, x, y, z, meta); + BaseMetaPipeEntity BTE = (BaseMetaPipeEntity) this.setGTMachineBlock(worldObj, x, y, z, meta); MetaPipeEntity MPE = (MetaPipeEntity) BTE.getMetaTileEntity(); BTE.mConnections |= (byte) (1 << (byte) 4); - BTE.mConnections |= (byte) (1 << (ForgeDirection.getOrientation(4).getOpposite().ordinal())); + BTE.mConnections |= (byte) (1 << ForgeDirection.getOrientation(4).getOpposite().ordinal()); BaseMetaTileEntity BPE = (BaseMetaTileEntity) worldObj.getTileEntity(x, y, z - 1); if (BPE != null) { BTE.mConnections |= (byte) (1 << (byte) 2); @@ -243,9 +248,13 @@ public boolean generate(World worldObj, Random rand1, int x, int y, int z) { rand, 5, this.ToBuildWith[3][0]); - } else if ((dx == 0) && dz == -5 && (dy == 1 || dy == 2)) { - if (dy == 1) this.setBlock(worldObj, x + dx, y + 1, z + -5, Blocks.iron_door, 1); - if (dy == 2) this.setBlock(worldObj, x + dx, y + 2, z + dz, Blocks.iron_door, 8); + } else if (dx == 0 && dz == -5 && (dy == 1 || dy == 2)) { + if (dy == 1) { + this.setBlock(worldObj, x + dx, y + 1, z + -5, Blocks.iron_door, 1); + } + if (dy == 2) { + this.setBlock(worldObj, x + dx, y + 2, z + dz, Blocks.iron_door, 8); + } } else if (Math.abs(dx) == 5 && Math.abs(dz) < 5 || Math.abs(dz) == 5 && Math.abs(dx) < 5) { this.setRandomBlockWAirChance( worldObj, @@ -255,16 +264,19 @@ public boolean generate(World worldObj, Random rand1, int x, int y, int z) { rand, 25, this.ToBuildWith[1]); - if (dy == 2) { - if (rand.nextInt(100) < 12) if (useColor) this.setRandomBlockWAirChance( - worldObj, - x + dx, - y + 2, - z + dz, - rand, - 25, - new Pair<>(Blocks.stained_glass_pane, colored)); - else this.setRandomBlockWAirChance( + if (dy == 2 && rand.nextInt(100) < 12) { + if (useColor) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + 2, + z + dz, + rand, + 25, + new Pair<>(Blocks.stained_glass_pane, colored)); + } + } else { + this.setRandomBlockWAirChance( worldObj, x + dx, y + dy, @@ -349,83 +361,113 @@ public boolean generate(World worldObj, Random rand1, int x, int y, int z) { } } } - } else if (dy == 4) { - if (Math.abs(dx) == 5) this.setRandomBlockWAirChance( - worldObj, - x + dx, - y + 4, - z + dz, - rand, - 25, - this.ToBuildWith[2]); - else if (Math.abs(dz) == 5 && Math.abs(dx) < 5) this.setRandomBlockWAirChance( - worldObj, - x + dx, - y + dy, - z + dz, - rand, - 25, - this.ToBuildWith[1]); - } else if (dy == 5) { - if (Math.abs(dx) == 4) this.setRandomBlockWAirChance( - worldObj, - x + dx, - y + 5, - z + dz, - rand, - 25, - this.ToBuildWith[2]); - else if (Math.abs(dz) == 5 && Math.abs(dx) < 4) this.setRandomBlockWAirChance( - worldObj, - x + dx, - y + dy, - z + dz, - rand, - 25, - this.ToBuildWith[1]); - } else if (dy == 6) { - if (Math.abs(dx) == 3) this.setRandomBlockWAirChance( - worldObj, - x + dx, - y + 6, - z + dz, - rand, - 25, - this.ToBuildWith[2]); - else if (Math.abs(dz) == 5 && Math.abs(dx) < 3) this.setRandomBlockWAirChance( - worldObj, - x + dx, - y + dy, - z + dz, - rand, - 25, - this.ToBuildWith[1]); - } else if (dy == 7) { - if (Math.abs(dx) == 2) this.setRandomBlockWAirChance( - worldObj, - x + dx, - y + 7, - z + dz, - rand, - 25, - this.ToBuildWith[2]); - else if (Math.abs(dz) == 5 && Math.abs(dx) < 2) this.setRandomBlockWAirChance( - worldObj, - x + dx, - y + dy, - z + dz, - rand, - 25, - this.ToBuildWith[1]); - } else if (dy == 8) { - if (Math.abs(dx) == 1 || Math.abs(dx) == 0) this.setRandomBlockWAirChance( - worldObj, - x + dx, - y + 8, - z + dz, - rand, - 25, - this.ToBuildWith[2]); + } else switch (dy) { + case 4: + if (Math.abs(dx) == 5) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + 4, + z + dz, + rand, + 25, + this.ToBuildWith[2]); + break; + } + if (Math.abs(dz) == 5 && Math.abs(dx) < 5) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + dy, + z + dz, + rand, + 25, + this.ToBuildWith[1]); + } + break; + case 5: + if (Math.abs(dx) == 4) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + 5, + z + dz, + rand, + 25, + this.ToBuildWith[2]); + break; + } + if (Math.abs(dz) == 5 && Math.abs(dx) < 4) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + dy, + z + dz, + rand, + 25, + this.ToBuildWith[1]); + } + break; + case 6: + if (Math.abs(dx) == 3) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + 6, + z + dz, + rand, + 25, + this.ToBuildWith[2]); + break; + } + if (Math.abs(dz) == 5 && Math.abs(dx) < 3) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + dy, + z + dz, + rand, + 25, + this.ToBuildWith[1]); + } + break; + case 7: + if (Math.abs(dx) == 2) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + 7, + z + dz, + rand, + 25, + this.ToBuildWith[2]); + break; + } + if (Math.abs(dz) == 5 && Math.abs(dx) < 2) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + dy, + z + dz, + rand, + 25, + this.ToBuildWith[1]); + } + break; + case 8: + if (Math.abs(dx) == 1 || Math.abs(dx) == 0) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + 8, + z + dz, + rand, + 25, + this.ToBuildWith[2]); + } + break; + default: + break; } } } @@ -434,19 +476,22 @@ else if (Math.abs(dz) == 5 && Math.abs(dx) < 2) this.setRandomBlockWAirChance( int dy = 1; int dz = 3; for (int dx = 2; dx > -5; dx--) { - if (set < toSet) { - if (!lastset || treeinaRow > 2 && worldObj.getTileEntity(x + dx, y + dy, z + dz) == null) { - short meta = GT_WorldgenUtil.getMachine(secureRandom, tier); - this.setGTMachine(worldObj, x + dx, y + dy, z + dz, meta, owner, ForgeDirection.UP); - - set++; - treeinaRow = 0; - lastset = true; - } else { - lastset = rand.nextBoolean(); - if (lastset) treeinaRow++; + if (set >= toSet) { + break tosetloop; + } + if (!lastset || treeinaRow > 2 && worldObj.getTileEntity(x + dx, y + dy, z + dz) == null) { + short meta = GT_WorldgenUtil.getMachine(secureRandom, tier); + this.setGTMachine(worldObj, x + dx, y + dy, z + dz, meta, owner, ForgeDirection.UP); + + set++; + treeinaRow = 0; + lastset = true; + } else { + lastset = rand.nextBoolean(); + if (lastset) { + treeinaRow++; } - } else break tosetloop; + } } } return true; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java index a2ed19b77..a628c1ffb 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java @@ -234,20 +234,14 @@ protected void drawNEIDurationInfo(NEIRecipeInfo recipeInfo) {} * @param machine 0 = biolab; 1 = BacterialVat; 2 = sAcidGenFuels; 3 = circuitAssemblyLine */ public GT_Recipe.GT_Recipe_Map getMappingsFor(byte machine) { - switch (machine) { - case 0: - return sBiolab; - case 1: - return sBacteriaVat; - case 2: - return sAcidGenFuels; - case 3: - return sCircuitAssemblyLineMap; - case 4: - return sRadHatch; - default: - return null; - } + return switch (machine) { + case 0 -> this.sBiolab; + case 1 -> this.sBacteriaVat; + case 2 -> this.sAcidGenFuels; + case 3 -> this.sCircuitAssemblyLineMap; + case 4 -> this.sRadHatch; + default -> null; + }; } public static long calcDecayTicks(int x) { @@ -255,12 +249,12 @@ public static long calcDecayTicks(int x) { if (x == 43) ret = 5000; else if (x == 61) ret = 4500; else if (x <= 100) ret = MathUtils.ceilLong((8000D * Math.tanh(-x / 20D) + 8000D) * 1000D); - else ret = MathUtils.ceilLong(((8000D * Math.tanh(-x / 65D) + 8000D))); + else ret = MathUtils.ceilLong(8000D * Math.tanh(-x / 65D) + 8000D); return ret; } public boolean addRadHatch(ItemStack item, int radioLevel, int amount, short[] rgba) { - return sRadHatch.addRecipe( + return this.sRadHatch.addRecipe( new DynamicGTRecipe( false, new ItemStack[] { item }, @@ -276,7 +270,7 @@ public boolean addRadHatch(ItemStack item, int radioLevel, int amount, short[] r } public boolean addRadHatch(ItemStack item, int radioLevel, int amount, int time, short[] rgba) { - return sRadHatch.addRecipe( + return this.sRadHatch.addRecipe( new DynamicGTRecipe( false, new ItemStack[] { item }, @@ -293,7 +287,7 @@ public boolean addRadHatch(ItemStack item, int radioLevel, int amount, int time, public boolean addBioLabRecipe(ItemStack[] aInputs, ItemStack aOutput, ItemStack aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - return sBiolab.addRecipe( + return this.sBiolab.addRecipe( new DynamicGTRecipe( true, aInputs, @@ -310,7 +304,7 @@ public boolean addBioLabRecipe(ItemStack[] aInputs, ItemStack aOutput, ItemStack public boolean addBioLabRecipeIncubation(ItemStack aInput, BioCulture aOutput, int[] aChances, FluidStack[] aFluidInputs, int aDuration, int aEUt, int aSpecialValue) { - return sBiolab.addRecipe( + return this.sBiolab.addRecipe( new DynamicGTRecipe( true, new ItemStack[] { BioItemList.getPetriDish(null), aInput }, @@ -327,7 +321,7 @@ public boolean addBioLabRecipeIncubation(ItemStack aInput, BioCulture aOutput, i public boolean addBioLabRecipeIncubation(ItemStack aInput, BioCulture aOutput, int[] aChances, FluidStack aFluidInputs, int aDuration, int aEUt, int aSpecialValue) { - return sBiolab.addRecipe( + return this.sBiolab.addRecipe( new DynamicGTRecipe( true, new ItemStack[] { BioItemList.getPetriDish(null), aInput }, @@ -345,7 +339,7 @@ public boolean addBioLabRecipeIncubation(ItemStack aInput, BioCulture aOutput, i @Deprecated public boolean addBioLabRecipeDNAExtraction(ItemStack[] aInputs, ItemStack aOutput, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - return sBiolab.addRecipe( + return this.sBiolab.addRecipe( new DynamicGTRecipe( true, aInputs, @@ -363,7 +357,7 @@ public boolean addBioLabRecipeDNAExtraction(ItemStack[] aInputs, ItemStack aOutp @Deprecated public boolean addBioLabRecipePCRThermoclycling(ItemStack[] aInputs, ItemStack aOutput, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - return sBiolab.addRecipe( + return this.sBiolab.addRecipe( new DynamicGTRecipe( true, aInputs, @@ -381,7 +375,7 @@ public boolean addBioLabRecipePCRThermoclycling(ItemStack[] aInputs, ItemStack a @Deprecated public boolean addBioLabRecipePlasmidSynthesis(ItemStack[] aInputs, ItemStack aOutput, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - return sBiolab.addRecipe( + return this.sBiolab.addRecipe( new DynamicGTRecipe( true, aInputs, @@ -399,7 +393,7 @@ public boolean addBioLabRecipePlasmidSynthesis(ItemStack[] aInputs, ItemStack aO @Deprecated public boolean addBioLabRecipeTransformation(ItemStack[] aInputs, ItemStack aOutput, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - return sBiolab.addRecipe( + return this.sBiolab.addRecipe( new DynamicGTRecipe( true, aInputs, @@ -417,7 +411,7 @@ public boolean addBioLabRecipeTransformation(ItemStack[] aInputs, ItemStack aOut @Deprecated public boolean addBioLabRecipeClonalCellularSynthesis(ItemStack[] aInputs, ItemStack aOutput, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - return sBiolab.addRecipe( + return this.sBiolab.addRecipe( new DynamicGTRecipe( true, aInputs, @@ -440,7 +434,7 @@ public boolean addBacterialVatRecipe(ItemStack[] aInputs, ItemStack[] aOutputs, aSievert += calculateSv(material); aSievert = aSievert << 6; aSievert = aSievert | glasTier; - return sBacteriaVat.addRecipe( + return this.sBacteriaVat.addRecipe( new BacteriaVatRecipe( false, aInputs, @@ -458,7 +452,6 @@ public boolean addBacterialVatRecipe(ItemStack[] aInputs, ItemStack[] aOutputs, public boolean addBacterialVatRecipe(ItemStack[] aInputs, BioCulture aCulture, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, @Nonnegative int aDuration, @Nonnegative int aEUt, @Nonnegative int aSv, @Nonnegative int glasTier, int aSpecialValue, boolean exactSv) { - byte gTier = (byte) glasTier; int aSievert = 0; if (aSv >= 83 || aSv == 61 || aSv == 43) aSievert += aSv; aSievert = aSievert << 1; @@ -466,8 +459,8 @@ public boolean addBacterialVatRecipe(ItemStack[] aInputs, BioCulture aCulture, F aSievert = aSievert << 2; aSievert = aSievert | specialToByte(aSpecialValue); aSievert = aSievert << 4; - aSievert = aSievert | gTier; - return sBacteriaVat.addRecipe( + aSievert = aSievert | glasTier; + return this.sBacteriaVat.addRecipe( new BacteriaVatRecipe( false, aInputs, @@ -496,7 +489,7 @@ public boolean addBacterialVatRecipe(ItemStack[] aInputs, BioCulture aCulture, F aSievert = aSievert | specialToByte(aSpecialValue); aSievert = aSievert << 4; aSievert = aSievert | gTier; - return sBacteriaVat.addRecipe( + return this.sBacteriaVat.addRecipe( new BacteriaVatRecipe( false, aInputs, @@ -520,7 +513,7 @@ public boolean addBacterialVatRecipe(ItemStack[] aInputs, ItemStack[] aOutputs, aSievert = aSievert << 1; aSievert = aSievert | (exactSv ? 1 : 0); aSievert = aSievert << 6; - return sBacteriaVat.addRecipe( + return this.sBacteriaVat.addRecipe( new BacteriaVatRecipe( false, aInputs, @@ -547,7 +540,7 @@ public boolean addBacterialVatRecipe(ItemStack[] aInputs, BioCulture culture, Fl aSievert = aSievert << 2; aSievert = aSievert | specialToByte(aSpecialValue); aSievert = aSievert << 4; - return sBacteriaVat.addRecipe( + return this.sBacteriaVat.addRecipe( new BacteriaVatRecipe( false, aInputs, @@ -569,7 +562,7 @@ public boolean addBacterialVatRecipe(ItemStack[] aInputs, BioCulture culture, Fl FluidStack[] aFluidOutputs, int aDuration, int aEUt, byte glasTier) { int aSievert = 0; aSievert = aSievert | glasTier; - return sBacteriaVat.addRecipe( + return this.sBacteriaVat.addRecipe( new BacteriaVatRecipe( false, aInputs, @@ -589,7 +582,7 @@ public boolean addBacterialVatRecipe(ItemStack[] aInputs, BioCulture culture, Fl */ public boolean addBacterialVatRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, BioCulture culture, FluidStack[] aFluidOutputs, int aDuration, int aEUt) { - return sBacteriaVat.addRecipe( + return this.sBacteriaVat.addRecipe( new BacteriaVatRecipe( false, aInputs, @@ -617,7 +610,7 @@ public boolean addTrimmedBacterialVatRecipe(ItemStack[] aInputs, BioCulture aCul aSievert = aSievert | specialToByte(aSpecialValue); aSievert = aSievert << 4; aSievert = aSievert | gTier; - return sBacteriaVat.addRecipe( + return this.sBacteriaVat.addRecipe( new BacteriaVatRecipe( true, aInputs, @@ -758,6 +751,7 @@ public BacteriaVatRecipeMap(Collection aRecipeList, String aUnlocaliz aNEIAllowed); } + @Override protected GT_Recipe addRecipe(GT_Recipe aRecipe, boolean aCheckForCollisions, boolean aFakeRecipe, boolean aHidden) { aRecipe.mHidden = aHidden; @@ -768,30 +762,29 @@ protected GT_Recipe addRecipe(GT_Recipe aRecipe, boolean aCheckForCollisions, bo if (aRecipe.mFluidInputs.length < this.mMinimalInputFluids && aRecipe.mInputs.length < this.mMinimalInputItems) { return null; - } else { - return aCheckForCollisions && isthere != null - && BW_Util.areStacksEqualOrNull( - (ItemStack) isthere.mSpecialItems, - (ItemStack) aRecipe.mSpecialItems) ? null : this.add(aRecipe); } + return aCheckForCollisions && isthere != null + && BW_Util + .areStacksEqualOrNull((ItemStack) isthere.mSpecialItems, (ItemStack) aRecipe.mSpecialItems) + ? null + : this.add(aRecipe); } public GT_Recipe addRecipe(GT_Recipe aRecipe, boolean VanillaGT) { - if (VanillaGT) return addRecipe(aRecipe, true, false, false); - else return addRecipe(aRecipe); + if (VanillaGT) return this.addRecipe(aRecipe, true, false, false); + return this.addRecipe(aRecipe); } + @Override public GT_Recipe addRecipe(GT_Recipe aRecipe) { if (aRecipe.mInputs.length > 0 && GT_Utility.areStacksEqual( aRecipe.mInputs[aRecipe.mInputs.length - 1], GT_Utility.getIntegratedCircuit(32767))) return aRecipe; - else { - ItemStack[] nu1 = Arrays.copyOf(aRecipe.mInputs, aRecipe.mInputs.length + 1); - nu1[nu1.length - 1] = GT_Utility.getIntegratedCircuit(9 + nu1.length); - aRecipe.mInputs = nu1; - } + ItemStack[] nu1 = Arrays.copyOf(aRecipe.mInputs, aRecipe.mInputs.length + 1); + nu1[nu1.length - 1] = GT_Utility.getIntegratedCircuit(9 + nu1.length); + aRecipe.mInputs = nu1; if (this.findRecipe(null, false, 9223372036854775807L, aRecipe.mFluidInputs, aRecipe.mInputs) != null) { ItemStack[] nu = Arrays.copyOf(aRecipe.mInputs, aRecipe.mInputs.length + 1); int i = 9 + nu.length; @@ -875,7 +868,7 @@ public SpecialObjectSensitiveMap(Collection aRecipeList, String aUnlo aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); - setSpecialSlotSensitive(true); + this.setSpecialSlotSensitive(true); } } @@ -899,12 +892,10 @@ public BWNBTDependantCraftingRecipe(ItemStack result, Object... recipe) { @Override public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof BWRecipes.BWNBTDependantCraftingRecipe)) return false; - - BWRecipes.BWNBTDependantCraftingRecipe that = (BWRecipes.BWNBTDependantCraftingRecipe) o; + if (!(o instanceof BWRecipes.BWNBTDependantCraftingRecipe that)) return false; - if (!Objects.equals(this.result, that.result)) return false; - if (!Objects.equals(this.charToStackMap, that.charToStackMap)) return false; + if (!Objects.equals(this.result, that.result) || !Objects.equals(this.charToStackMap, that.charToStackMap)) + return false; // Probably incorrect - comparing Object[] arrays with Arrays.equals return Arrays.equals(this.shape, that.shape); } @@ -913,8 +904,7 @@ public boolean equals(Object o) { public int hashCode() { int result1 = this.result != null ? this.result.hashCode() : 0; result1 = 31 * result1 + (this.charToStackMap != null ? this.charToStackMap.hashCode() : 0); - result1 = 31 * result1 + Arrays.hashCode(this.shape); - return result1; + return 31 * result1 + Arrays.hashCode(this.shape); } @Override diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_ColorUtil.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_ColorUtil.java index 580f6f779..5989c1b6d 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_ColorUtil.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_ColorUtil.java @@ -26,7 +26,7 @@ private BW_ColorUtil() {} public static byte getDarknessFromColor(short[] rgba, int index) { int g = rgba[index]; if (g >= 0 && g < 64) return 0; - else if (g >= 64 && g < 160) return 1; + if (g >= 64 && g < 160) return 1; else if (g >= 160 && g < 223) return 2; else if (g >= 233 && g <= 255) return 3; return 4; @@ -81,7 +81,8 @@ else if (rgba[0] > rgba[1] + rgba[1] / 10 && rgba[0] > rgba[2] + rgba[2] / 10 return Dyes._NULL; } return Dyes.dyePink; - } else if (isGrenScale(tmp)) { + } + if (isGrenScale(tmp)) { if (isCyanScale(tmp)) { if (rgba[2] + 40 < rgba[1]) switch (getDarknessFromColor(rgba, 0)) { case 0: @@ -151,17 +152,17 @@ public static boolean isYellowScale(short[] rgba) { public static boolean isBlueScale(short[] rgba) { rgba = correctCorlorArray(rgba); - return (rgba[2] * 2) >= (rgba[1] + rgba[0]); + return rgba[2] * 2 >= rgba[1] + rgba[0]; } public static boolean isGrenScale(short[] rgba) { rgba = correctCorlorArray(rgba); - return (rgba[1] * 2) >= (rgba[0] + rgba[2]); + return rgba[1] * 2 >= rgba[0] + rgba[2]; } public static boolean isRedScale(short[] rgba) { rgba = correctCorlorArray(rgba); - return (rgba[0] * 2) >= (rgba[1] + rgba[2]); + return rgba[0] * 2 >= rgba[1] + rgba[2]; } public static boolean isGrayScale(short[] rgba, int magin) { @@ -203,15 +204,15 @@ public static short[] correctCorlorArray(short[] rgba) { } public static short[] splitColorToRBGArray(int rgb) { - return new short[] { (short) ((rgb >> 16) & 0xFF), (short) ((rgb >> 8) & 0xFF), (short) (rgb & 0xFF) }; + return new short[] { (short) (rgb >> 16 & 0xFF), (short) (rgb >> 8 & 0xFF), (short) (rgb & 0xFF) }; } public static int getColorFromRGBArray(short[] color) { - return ((color[0] & 0x0ff) << 16) | ((color[1] & 0x0ff) << 8) | (color[2] & 0x0ff); + return (color[0] & 0x0ff) << 16 | (color[1] & 0x0ff) << 8 | color[2] & 0x0ff; } public static int getColorFromRGBArray(int[] color) { - return ((color[0] & 0x0ff) << 16) | ((color[1] & 0x0ff) << 8) | (color[2] & 0x0ff); + return (color[0] & 0x0ff) << 16 | (color[1] & 0x0ff) << 8 | color[2] & 0x0ff; } public static String getColorForTier(int tier) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java index 1db1293f2..69438bff9 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java @@ -78,7 +78,6 @@ import gregtech.api.util.GT_Shaped_Recipe; import gregtech.api.util.GT_Utility; -@SuppressWarnings({ "unused", "RedundantSuppression" }) public class BW_Util { public static final int STANDART = 0; @@ -110,10 +109,10 @@ public static GT_Recipe copyAndSetTierToNewRecipe(GT_Recipe recipe, byte tier) { int newTime = recipe.mDuration; int newVoltage = recipe.mEUt; if (tier < oldTier) { - newTime <<= (oldTier - tier); + newTime <<= oldTier - tier; newVoltage >>= 2 * (oldTier - tier); } else { - newTime >>= (tier - oldTier); + newTime >>= tier - oldTier; newVoltage <<= 2 * (tier - oldTier); } recipe.mEUt = newVoltage; @@ -125,40 +124,19 @@ public static String subscriptNumbers(String b) { char[] chars = b.toCharArray(); char[] nu = new char[chars.length]; for (int i = 0; i < chars.length; i++) { - switch (chars[i]) { - case '0': - nu[i] = '₀'; - continue; - case '1': - nu[i] = '₁'; - continue; - case '2': - nu[i] = '₂'; - continue; - case '3': - nu[i] = '₃'; - continue; - case '4': - nu[i] = '₄'; - continue; - case '5': - nu[i] = '₅'; - continue; - case '6': - nu[i] = '₆'; - continue; - case '7': - nu[i] = '₇'; - continue; - case '8': - nu[i] = '₈'; - continue; - case '9': - nu[i] = '₉'; - continue; - default: - nu[i] = chars[i]; - } + nu[i] = switch (chars[i]) { + case '0' -> '\u2080'; + case '1' -> '\u2081'; + case '2' -> '\u2082'; + case '3' -> '\u2083'; + case '4' -> '\u2084'; + case '5' -> '\u2085'; + case '6' -> '\u2086'; + case '7' -> '\u2087'; + case '8' -> '\u2088'; + case '9' -> '\u2089'; + default -> chars[i]; + }; } return new String(nu); } @@ -167,37 +145,19 @@ public static String subscriptNumber(Number b) { char[] chars = Long.toString(b.longValue()).toCharArray(); char[] nu = new char[chars.length]; for (int i = 0; i < chars.length; i++) { - switch (chars[i]) { - case '0': - nu[i] = '₀'; - continue; - case '1': - nu[i] = '₁'; - continue; - case '2': - nu[i] = '₂'; - continue; - case '3': - nu[i] = '₃'; - continue; - case '4': - nu[i] = '₄'; - continue; - case '5': - nu[i] = '₅'; - continue; - case '6': - nu[i] = '₆'; - continue; - case '7': - nu[i] = '₇'; - continue; - case '8': - nu[i] = '₈'; - continue; - case '9': - nu[i] = '₉'; - } + nu[i] = switch (chars[i]) { + case '0' -> '\u2080'; + case '1' -> '\u2081'; + case '2' -> '\u2082'; + case '3' -> '\u2083'; + case '4' -> '\u2084'; + case '5' -> '\u2085'; + case '6' -> '\u2086'; + case '7' -> '\u2087'; + case '8' -> '\u2088'; + case '9' -> '\u2089'; + default -> chars[i]; + }; } return new String(nu); } @@ -206,40 +166,19 @@ public static String superscriptNumbers(String b) { char[] chars = b.toCharArray(); char[] nu = new char[chars.length]; for (int i = 0; i < chars.length; i++) { - switch (chars[i]) { - case '0': - nu[i] = '⁰'; - continue; - case '1': - nu[i] = '¹'; - continue; - case '2': - nu[i] = '²'; - continue; - case '3': - nu[i] = '³'; - continue; - case '4': - nu[i] = '⁴'; - continue; - case '5': - nu[i] = '⁵'; - continue; - case '6': - nu[i] = '⁶'; - continue; - case '7': - nu[i] = '⁷'; - continue; - case '8': - nu[i] = '⁸'; - continue; - case '9': - nu[i] = '⁹'; - continue; - default: - nu[i] = chars[i]; - } + nu[i] = switch (chars[i]) { + case '0' -> '\u2070'; + case '1' -> '\u2071'; + case '2' -> '\u00B2'; + case '3' -> '\u00B3'; + case '4' -> '\u2074'; + case '5' -> '\u2075'; + case '6' -> '\u2076'; + case '7' -> '\u2077'; + case '8' -> '\u2078'; + case '9' -> '\u2079'; + default -> chars[i]; + }; } return new String(nu); } @@ -248,46 +187,38 @@ public static String superscriptNumber(Number b) { char[] chars = Long.toString(b.longValue()).toCharArray(); char[] nu = new char[chars.length]; for (int i = 0; i < chars.length; i++) { - switch (chars[i]) { - case '0': - nu[i] = '⁰'; - continue; - case '1': - nu[i] = '¹'; - continue; - case '2': - nu[i] = '²'; - continue; - case '3': - nu[i] = '³'; - continue; - case '4': - nu[i] = '⁴'; - continue; - case '5': - nu[i] = '⁵'; - continue; - case '6': - nu[i] = '⁶'; - continue; - case '7': - nu[i] = '⁷'; - continue; - case '8': - nu[i] = '⁸'; - continue; - case '9': - nu[i] = '⁹'; - } + nu[i] = switch (chars[i]) { + case '0' -> '\u2070'; + case '1' -> '\u2071'; + case '2' -> '\u00B2'; + case '3' -> '\u00B3'; + case '4' -> '\u2074'; + case '5' -> '\u2075'; + case '6' -> '\u2076'; + case '7' -> '\u2077'; + case '8' -> '\u2078'; + case '9' -> '\u2079'; + default -> chars[i]; + }; } return new String(nu); } public static byte specialToByte(int aSpecialValue) { byte special = 0; - if (aSpecialValue == (LOWGRAVITY)) special = 1; - else if (aSpecialValue == (CLEANROOM)) special = 2; - else if (aSpecialValue == (LOWGRAVITY | CLEANROOM)) special = 3; + switch (aSpecialValue) { + case LOWGRAVITY: + special = 1; + break; + case CLEANROOM: + special = 2; + break; + case LOWGRAVITY | CLEANROOM: + special = 3; + break; + default: + break; + } return special; } @@ -316,8 +247,8 @@ public static int calculateSv(Materials materials) { if (pair.getMaterials().equals(materials)) return pair.getSievert(); } return (int) (materials.getProtons() == 43L - ? (materials.equals(Materials.NaquadahEnriched) ? 140 - : materials.equals(Materials.Naquadria) ? 150 : materials.equals(Materials.Naquadah) ? 130 : 43) + ? materials.equals(Materials.NaquadahEnriched) ? 140 + : materials.equals(Materials.Naquadria) ? 150 : materials.equals(Materials.Naquadah) ? 130 : 43 : materials.getProtons()); } @@ -397,7 +328,7 @@ public static T[] copyAndRemoveNulls(T[] input, Class clazz) { @Deprecated public static int getMachineVoltageFromTier(int tier) { - return (int) (30 * Math.pow(4, (tier - 1))); + return (int) (30 * Math.pow(4, tier - 1)); } public static long getTierVoltage(int tier) { @@ -405,7 +336,7 @@ public static long getTierVoltage(int tier) { } public static long getTierVoltage(byte tier) { - return 8L << (2 * tier); + return 8L << 2 * tier; } public static byte getTier(long voltage) { @@ -420,7 +351,7 @@ public static byte getTier(long voltage) { public static String getTierName(byte tier) { if (VN.length - 1 <= tier) return "MAX+"; - else return VN[tier]; + return VN[tier]; } public static String getTierNameFromVoltage(long voltage) { @@ -428,7 +359,7 @@ public static String getTierNameFromVoltage(long voltage) { } public static boolean areStacksEqualOrNull(ItemStack aStack1, ItemStack aStack2) { - return (aStack1 == null && aStack2 == null) || GT_Utility.areStacksEqual(aStack1, aStack2); + return aStack1 == null && aStack2 == null || GT_Utility.areStacksEqual(aStack1, aStack2); } public static boolean areStacksEqualOrEachNull(ItemStack aStack1, ItemStack aStack2) { @@ -436,9 +367,9 @@ public static boolean areStacksEqualOrEachNull(ItemStack aStack1, ItemStack aSta } public static byte getByteFromRarity(EnumRarity rarity) { - if (rarity.equals(EnumRarity.uncommon)) return 1; - else if (rarity.equals(EnumRarity.epic)) return 2; - else if (rarity.equals(EnumRarity.rare)) return 3; + if (EnumRarity.uncommon.equals(rarity)) return 1; + if (EnumRarity.epic.equals(rarity)) return 2; + else if (EnumRarity.rare.equals(rarity)) return 3; return 0; } @@ -447,34 +378,16 @@ public static byte getByteFromRarity(EnumRarity rarity) { */ @Deprecated public static byte getTierFromGlasMeta(int meta) { - byte ret; - switch (meta) { - case 1: - ret = 4; - break; - case 2: - case 12: - ret = 5; - break; - case 3: - ret = 6; - break; - case 4: - ret = 7; - break; - case 5: - ret = 8; - break; - case 13: - ret = 9; - break; - case 14: - ret = 10; - break; - default: - ret = 3; - } - return ret; + return switch (meta) { + case 1 -> 4; + case 2, 12 -> 5; + case 3 -> 6; + case 4 -> 7; + case 5 -> 8; + case 13 -> 9; + case 14 -> 10; + default -> 3; + }; } /** @@ -502,7 +415,7 @@ private static void calculateOverclockednessMultiInternal(@Nonnegative int aEUt, byte mTier = (byte) Math.max(0, GT_Utility.getTier(maxInputVoltage)); if (mTier == 0) { // Long time calculation - long xMaxProgresstime = ((long) aDuration) << 1; + long xMaxProgresstime = (long) aDuration << 1; if (xMaxProgresstime > Integer.MAX_VALUE - 1) { // make impossible if too long base.mEUt = Integer.MAX_VALUE - 1; @@ -580,215 +493,12 @@ public static ItemStack[] getItemsFromInputBusses(GT_MetaTileEntity_MultiBlockBa } public static EnumRarity getRarityFromByte(byte b) { - switch (b) { - case 1: - return EnumRarity.uncommon; - case 2: - return EnumRarity.rare; - case 3: - return EnumRarity.epic; - default: - return EnumRarity.common; - } - } - - public static boolean check_layer(IGregTechTileEntity aBaseMetaTileEntity, int radius, int yLevel, int height, - Block block, int dmg, int offset, boolean insideCheck, Block inside, int dmginside, int aBaseCasingIndex) { - return BW_Util.check_layer( - aBaseMetaTileEntity, - radius, - yLevel, - height, - block, - dmg, - offset, - false, - insideCheck, - inside, - dmginside, - aBaseCasingIndex); - } - - public static boolean check_layer(IGregTechTileEntity aBaseMetaTileEntity, int radius, int yLevel, int height, - Block block, int dmg, int offset, int aBaseCasingIndex) { - return BW_Util - .check_layer(aBaseMetaTileEntity, radius, yLevel, height, block, dmg, offset, false, aBaseCasingIndex); - } - - public static boolean check_layer(IGregTechTileEntity aBaseMetaTileEntity, int radius, int yLevel, int height, - Block block, int dmg, int offset, boolean controllerLayer, int aBaseCasingIndex) { - return BW_Util.check_layer( - aBaseMetaTileEntity, - radius, - yLevel, - height, - block, - dmg, - offset, - controllerLayer, - false, - aBaseCasingIndex); - } - - public static boolean check_layer(IGregTechTileEntity aBaseMetaTileEntity, int radius, int yLevel, int height, - Block block, int dmg, int offset, boolean controllerLayer, boolean freeCorners, int aBaseCasingIndex) { - return BW_Util.check_layer( - aBaseMetaTileEntity, - radius, - yLevel, - height, - block, - dmg, - offset, - controllerLayer, - freeCorners, - false, - block, - dmg, - true, - aBaseCasingIndex); - } - - public static boolean check_layer(IGregTechTileEntity aBaseMetaTileEntity, int radius, int yLevel, int height, - Block block, int dmg, int offset, boolean controllerLayer, boolean insideCheck, Block inside, int dmginside, - int aBaseCasingIndex) { - return BW_Util.check_layer( - aBaseMetaTileEntity, - radius, - yLevel, - height, - block, - dmg, - offset, - controllerLayer, - false, - insideCheck, - inside, - dmginside, - true, - aBaseCasingIndex); - } - - /** - * @param aBaseMetaTileEntity the Multiblock controller, usually a parameter - * @param radius the radius of the layer - * @param yLevel the starting y level of the Layer, referenced to the Multiblock - * @param height the height of the Layers, referenced to the Multiblock - * @param block the block for the walls - * @param offset the offset in most cases should be the same as the radius - * @param controllerLayer if the layer contains the controller - * @param freeCorners if the corners should be checked - * @param insideCheck if the inside should be empty/filled - * @param inside which block should be inside - * @param allowHatches if hatches are allowed in this Layer - * @param aBaseCasingIndex the Index for the hatches texture - * @return if the layer check was completed - */ - public static boolean check_layer(IGregTechTileEntity aBaseMetaTileEntity, int radius, int yLevel, int height, - Block block, int dmg, int offset, boolean controllerLayer, boolean freeCorners, boolean insideCheck, - Block inside, int dmginside, boolean allowHatches, int aBaseCasingIndex) { - int xDir = aBaseMetaTileEntity.getBackFacing().offsetX * offset; - int zDir = aBaseMetaTileEntity.getBackFacing().offsetZ * offset; - for (int x = -radius; x <= radius; x++) { - for (int y = yLevel; y < height; y++) { - for (int z = -radius; z <= radius; z++) { - if (freeCorners && (((Math.abs(x) == radius && Math.abs(z) == radius)))) continue; - if (controllerLayer && (xDir + x == 0 && zDir + z == 0)) continue; - boolean b = Math.abs(x) < radius && Math.abs(z) != radius; - if (insideCheck && b) { - if (!(inside.equals(Blocks.air) ? aBaseMetaTileEntity.getAirOffset(xDir + x, y, zDir + z) - : aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z).equals(inside)) - && (aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z) != dmginside - || dmginside > (-1))) { - if (!(allowHatches - && (((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity.getMetaTileEntity()) - .addDynamoToMachineList( - aBaseMetaTileEntity - .getIGregTechTileEntityOffset(xDir + x, y, zDir + z), - aBaseCasingIndex) - || ((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity - .getMetaTileEntity()) - .addEnergyInputToMachineList( - aBaseMetaTileEntity.getIGregTechTileEntityOffset( - xDir + x, - y, - zDir + z), - aBaseCasingIndex) - || ((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity - .getMetaTileEntity()) - .addMaintenanceToMachineList( - aBaseMetaTileEntity.getIGregTechTileEntityOffset( - xDir + x, - y, - zDir + z), - aBaseCasingIndex) - || ((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity - .getMetaTileEntity()) - .addMufflerToMachineList( - aBaseMetaTileEntity.getIGregTechTileEntityOffset( - xDir + x, - y, - zDir + z), - aBaseCasingIndex) - || ((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity - .getMetaTileEntity()) - .addInputToMachineList( - aBaseMetaTileEntity.getIGregTechTileEntityOffset( - xDir + x, - y, - zDir + z), - aBaseCasingIndex) - || ((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity - .getMetaTileEntity()) - .addOutputToMachineList( - aBaseMetaTileEntity.getIGregTechTileEntityOffset( - xDir + x, - y, - zDir + z), - aBaseCasingIndex)))) { - return false; - } - } - } - if (!b && !aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z).equals(block) - && (aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z) != dmg || dmg > (-1))) { - if (!(allowHatches - && (((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity.getMetaTileEntity()) - .addDynamoToMachineList( - aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z), - aBaseCasingIndex) - || ((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity.getMetaTileEntity()) - .addEnergyInputToMachineList( - aBaseMetaTileEntity - .getIGregTechTileEntityOffset(xDir + x, y, zDir + z), - aBaseCasingIndex) - || ((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity.getMetaTileEntity()) - .addMaintenanceToMachineList( - aBaseMetaTileEntity - .getIGregTechTileEntityOffset(xDir + x, y, zDir + z), - aBaseCasingIndex) - || ((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity.getMetaTileEntity()) - .addMufflerToMachineList( - aBaseMetaTileEntity - .getIGregTechTileEntityOffset(xDir + x, y, zDir + z), - aBaseCasingIndex) - || ((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity.getMetaTileEntity()) - .addInputToMachineList( - aBaseMetaTileEntity - .getIGregTechTileEntityOffset(xDir + x, y, zDir + z), - aBaseCasingIndex) - || ((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity.getMetaTileEntity()) - .addOutputToMachineList( - aBaseMetaTileEntity - .getIGregTechTileEntityOffset(xDir + x, y, zDir + z), - aBaseCasingIndex)))) { - return false; - } - } - } - } - } - return true; + return switch (b) { + case 1 -> EnumRarity.uncommon; + case 2 -> EnumRarity.rare; + case 3 -> EnumRarity.epic; + default -> EnumRarity.common; + }; } public static List getMetasFromLayer(IGregTechTileEntity aBaseMetaTileEntity, int radius, int yLevel, @@ -799,8 +509,8 @@ public static List getMetasFromLayer(IGregTechTileEntity aBaseMetaTileEnti for (int x = -radius; x <= radius; x++) { for (int y = yLevel; y < height; y++) { for (int z = -radius; z <= radius; z++) { - if (freeCorners && (((Math.abs(x) == radius && Math.abs(z) == radius)))) continue; - if (controllerLayer && (xDir + x == 0 && zDir + z == 0)) continue; + if (freeCorners && Math.abs(x) == radius && Math.abs(z) == radius) continue; + if (controllerLayer && xDir + x == 0 && zDir + z == 0) continue; final boolean inside = Math.abs(x) < radius && Math.abs(z) != radius; if (insideCheck && inside) ret.add(aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)); if (!inside) { @@ -813,43 +523,24 @@ public static List getMetasFromLayer(IGregTechTileEntity aBaseMetaTileEnti } public static byte getCircuitTierFromOreDictName(String name) { - switch (name) { - case "circuitPrimitive": - return 0; - case "circuitBasic": - return 1; - case "circuitGood": - return 2; - case "circuitAdvanced": - return 3; - case "circuitData": - return 4; - case "circuitElite": - return 5; - case "circuitMaster": - return 6; - case "circuitUltimate": - return 7; - case "circuitSuperconductor": - return 8; - case "circuitInfinite": - return 9; - case "circuitBio": - return 10; - case "circuitNano": - case "circuitOptical": - return 11; - case "circuitPiko": - case "circuitExotic": - return 12; - case "circuitQuantum": - case "circuitCosmic": - return 13; - case "circuitTranscendent": - return 14; - default: - return -1; - } + return switch (name) { + case "circuitPrimitive" -> 0; + case "circuitBasic" -> 1; + case "circuitGood" -> 2; + case "circuitAdvanced" -> 3; + case "circuitData" -> 4; + case "circuitElite" -> 5; + case "circuitMaster" -> 6; + case "circuitUltimate" -> 7; + case "circuitSuperconductor" -> 8; + case "circuitInfinite" -> 9; + case "circuitBio" -> 10; + case "circuitNano", "circuitOptical" -> 11; + case "circuitPiko", "circuitExotic" -> 12; + case "circuitQuantum", "circuitCosmic" -> 13; + case "circuitTranscendent" -> 14; + default -> -1; + }; } public static byte getCircuitTierFromItemStack(ItemStack stack) { @@ -874,14 +565,12 @@ public static List getOreNames(ItemStack stack) { return ret; } - private static Block bw_realglasRef; - public static byte calculateGlassTier(@Nonnull Block block, @Nonnegative byte meta) { byte boroTier = BorosilicateGlass.getTier(block, meta); if (boroTier != -1) return boroTier; - if (block.getUnlocalizedName().equals("blockAlloyGlass")) return 4; + if ("blockAlloyGlass".equals(block.getUnlocalizedName())) return 4; if (block.equals(Blocks.glass)) return 3; @@ -896,7 +585,7 @@ public static byte calculateGlassTier(@Nonnull Block block, @Nonnegative byte me public static IStructureElement ofGlassTiered(byte mintier, byte maxtier, byte notset, BiConsumer setter, Function getter, int aDots) { - return new IStructureElement() { + return new IStructureElement<>() { private final IStructureElement placementDelegate = BorosilicateGlass .ofBoroGlass(notset, mintier, maxtier, setter, getter); @@ -906,10 +595,8 @@ public boolean check(T te, World world, int x, int y, int z) { if (world.isAirBlock(x, y, z)) return false; byte glasstier = BW_Util .calculateGlassTier(world.getBlock(x, y, z), (byte) world.getBlockMetadata(x, y, z)); - if (glasstier == 0) return false; // is not a glass ? - if (glasstier == notset) return false; - if (glasstier < mintier) return false; - if (glasstier > maxtier) return false; + // is not a glass ? + if (glasstier == 0 || glasstier == notset || glasstier < mintier || glasstier > maxtier) return false; if (getter.apply(te) == notset) setter.accept(te, glasstier); return getter.apply(te) == glasstier; } @@ -922,22 +609,22 @@ public boolean spawnHint(T te, World world, int x, int y, int z, ItemStack itemS @Override public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - return placementDelegate.placeBlock(t, world, x, y, z, trigger); + return this.placementDelegate.placeBlock(t, world, x, y, z, trigger); } @Override public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) { - return placementDelegate.survivalPlaceBlock(t, world, x, y, z, trigger, env); + return this.placementDelegate.survivalPlaceBlock(t, world, x, y, z, trigger, env); } }; } public static IStructureElement ofGlassTieredMixed(byte mintier, byte maxtier, int aDots) { - return new IStructureElement() { + return new IStructureElement<>() { private final IStructureElement placementDelegate = BorosilicateGlass - .ofBoroGlass((byte) 0, mintier, maxtier, (v1, v2) -> {}, (v1) -> (byte) 0); + .ofBoroGlass((byte) 0, mintier, maxtier, (v1, v2) -> {}, v1 -> (byte) 0); @Override public boolean check(T te, World world, int x, int y, int z) { @@ -956,13 +643,13 @@ public boolean spawnHint(T te, World world, int x, int y, int z, ItemStack itemS @Override public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - return placementDelegate.placeBlock(t, world, x, y, z, trigger); + return this.placementDelegate.placeBlock(t, world, x, y, z, trigger); } @Override public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) { - return placementDelegate.survivalPlaceBlock(t, world, x, y, z, trigger, env); + return this.placementDelegate.survivalPlaceBlock(t, world, x, y, z, trigger, env); } }; } @@ -1002,7 +689,6 @@ public static ShapedOreRecipe createGTCraftingRecipe(ItemStack aResult, long aBi aRecipe); } - @SuppressWarnings({ "rawtypes", "unchecked" }) public static ShapedOreRecipe createGTCraftingRecipe(ItemStack aResult, Enchantment[] aEnchantmentsAdded, int[] aEnchantmentLevelsAdded, boolean aMirrored, boolean aBuffered, boolean aKeepNBT, boolean aDismantleable, boolean aRemovable, boolean aReversible, boolean aRemoveAllOthersWithSameOutput, @@ -1017,13 +703,20 @@ public static ShapedOreRecipe createGTCraftingRecipe(ItemStack aResult, Enchantm boolean tThereWasARecipe = false; for (byte i = 0; i < aRecipe.length; i++) { - if (aRecipe[i] instanceof IItemContainer) aRecipe[i] = ((IItemContainer) aRecipe[i]).get(1); - else if (aRecipe[i] instanceof Enum) aRecipe[i] = ((Enum) aRecipe[i]).name(); - else if (!(aRecipe[i] == null || aRecipe[i] instanceof ItemStack - || aRecipe[i] instanceof ItemData - || aRecipe[i] instanceof String - || aRecipe[i] instanceof Character)) + if (aRecipe[i] instanceof IItemContainer itemContainer) { + aRecipe[i] = itemContainer.get(1); + continue; + } + if (aRecipe[i] instanceof Enumenum_) { + aRecipe[i] = enum_.name(); + continue; + } + if (aRecipe[i] != null && !(aRecipe[i] instanceof ItemStack) + && !(aRecipe[i] instanceof ItemData) + && !(aRecipe[i] instanceof String) + && !(aRecipe[i] instanceof Character)) { aRecipe[i] = aRecipe[i].toString(); + } } try { @@ -1035,8 +728,9 @@ else if (!(aRecipe[i] == null || aRecipe[i] instanceof ItemStack ArrayList tRecipeList = new ArrayList<>(Arrays.asList(aRecipe)); - while (aRecipe[idx] instanceof String) { - StringBuilder s = new StringBuilder((String) aRecipe[idx++]); + while (aRecipe[idx] instanceof String string) { + StringBuilder s = new StringBuilder(string); + idx++; shape.append(s); while (s.length() < 3) s.append(" "); if (s.length() > 3) throw new IllegalArgumentException(); @@ -1176,7 +870,10 @@ else if (in.equals(OreDictNames.craftingAnvil.toString())) if (aReversible && aResult != null) { ItemData[] tData = new ItemData[9]; int x = -1; - for (char chr : shape.toString().toCharArray()) tData[++x] = tItemDataMap.get(chr); + for (char chr : shape.toString().toCharArray()) { + x++; + tData[x] = tItemDataMap.get(chr); + } if (GT_Utility.arrayContainsNonNull(tData)) GT_OreDictUnificator.addItemData(aResult, new ItemData(tData)); } @@ -1185,7 +882,8 @@ else if (in.equals(OreDictNames.craftingAnvil.toString())) ItemStack[] tRecipe = new ItemStack[9]; int x = -1; for (char chr : shape.toString().toCharArray()) { - tRecipe[++x] = tItemStackMap.get(chr); + x++; + tRecipe[x] = tItemStackMap.get(chr); if (tRecipe[x] != null && Items.feather.getDamage(tRecipe[x]) == W) Items.feather.setDamage(tRecipe[x], 0); } @@ -1213,7 +911,8 @@ else if (in.equals(OreDictNames.craftingAnvil.toString())) IRecipe tRecipe = tList.get(i); if (GT_ModHandler.sSpecialRecipeClasses.contains(tRecipe.getClass().getName())) continue; if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(tRecipe.getRecipeOutput()), aResult, true)) { - tList.remove(i--); + tList.remove(i); + i--; tList_sS = tList.size(); tThereWasARecipe = true; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioCulture.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioCulture.java index c260b6d68..3a9edb71f 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioCulture.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioCulture.java @@ -170,7 +170,7 @@ public BioPlasmid getPlasmid() { } public BioCulture setPlasmid(BioPlasmid plasmid) { - return checkForExisting( + return this.checkForExisting( new BioCulture(this.color, this.name, this.ID, plasmid, this.dDNA, this.rarity, this.bBreedable)); } @@ -191,7 +191,7 @@ public BioDNA getdDNA() { } public BioCulture setdDNA(BioDNA dDNA) { - return checkForExisting( + return this.checkForExisting( new BioCulture(this.color, this.name, this.ID, this.plasmid, dDNA, this.rarity, this.bBreedable)); } @@ -203,8 +203,7 @@ public BioCulture setdDNAUnsafe(BioDNA dDNA) { @Override public boolean equals(Object o) { if (this == o) return true; - if (o == null || this.getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; + if (o == null || this.getClass() != o.getClass() || !super.equals(o)) return false; BioCulture culture = (BioCulture) o; return this.isBreedable() == culture.isBreedable() && Objects.equals(this.getColor(), culture.getColor()) && Objects.equals(this.getPlasmid(), culture.getPlasmid()) @@ -218,7 +217,7 @@ public int hashCode() { ByteBuffer.allocate(17) .putInt(MurmurHash3.murmurhash3_x86_32(this.getName(), 0, this.getName().length(), 31)) .putInt(this.getColorRGB()).putInt(this.getPlasmid().ID).putInt(this.getdDNA().ID) - .put((byte) (isBreedable() ? 1 : 0)).array(), + .put((byte) (this.isBreedable() ? 1 : 0)).array(), 0, 17, 31); @@ -226,7 +225,7 @@ public int hashCode() { @Override public short[] getRGBA() { - return new short[] { (short) getColor().getRed(), (short) getColor().getGreen(), (short) getColor().getBlue(), - (short) getColor().getAlpha() }; + return new short[] { (short) this.getColor().getRed(), (short) this.getColor().getGreen(), + (short) this.getColor().getBlue(), (short) this.getColor().getAlpha() }; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioDNA.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioDNA.java index c1c6431da..22edd6017 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioDNA.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioDNA.java @@ -46,6 +46,6 @@ public static BioDNA createAndRegisterBioDNA(String aName, EnumRarity rarity, in @Override public String toString() { - return "BioDNA{" + "name='" + name + '\'' + ", ID=" + ID + '}'; + return "BioDNA{" + "name='" + this.name + '\'' + ", ID=" + this.ID + '}'; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioData.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioData.java index 854bc4afb..d88ffc3aa 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioData.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioData.java @@ -100,9 +100,9 @@ public boolean equals(Object o) { if (o == null || this.getClass() != o.getClass()) return false; BioData bioData = (BioData) o; return this.getID() == bioData.getID() - || (this.getChance() == bioData.getChance() && this.getTier() == bioData.getTier() + || this.getChance() == bioData.getChance() && this.getTier() == bioData.getTier() && Objects.equals(this.getName(), bioData.getName()) - && this.getRarity() == bioData.getRarity()); + && this.getRarity() == bioData.getRarity(); } @Override @@ -127,7 +127,7 @@ public void setTier(int tier) { @Override public String toString() { - return "BioData{" + "name='" + name + '\'' + ", ID=" + ID + '}'; + return "BioData{" + "name='" + this.name + '\'' + ", ID=" + this.ID + '}'; } public EnumRarity getRarity() { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioPlasmid.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioPlasmid.java index 47f94bb38..0d40d9dec 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioPlasmid.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioPlasmid.java @@ -46,6 +46,6 @@ public static BioPlasmid createAndRegisterBioPlasmid(String aName, EnumRarity ra @Override public String toString() { - return "BioPlasmid{" + "name='" + name + '\'' + ", ID=" + ID + '}'; + return "BioPlasmid{" + "name='" + this.name + '\'' + ", ID=" + this.ID + '}'; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksChecker.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksChecker.java index 48aaf70b6..d35489a15 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksChecker.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksChecker.java @@ -16,7 +16,6 @@ import java.util.HashSet; import net.minecraft.block.Block; -import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; @@ -51,36 +50,36 @@ public int get_connected(World w, int x, int y, int z, Block b) { int wID = w.provider.dimensionId; - byte sides = check_sourroundings(w, x, y, z, b); + byte sides = this.check_sourroundings(w, x, y, z, b); - if (((sides | 0b111011) == 0b111111) && !hashset.contains(new Coords(x + 1, y, z, wID))) { + if ((sides | 0b111011) == 0b111111 && !this.hashset.contains(new Coords(x + 1, y, z, wID))) { ret++; - ret += get_connected(w, x + 1, y, z, b); + ret += this.get_connected(w, x + 1, y, z, b); } - if (((sides | 0b110111) == 0b111111) && !hashset.contains(new Coords(x - 1, y, z, wID))) { + if ((sides | 0b110111) == 0b111111 && !this.hashset.contains(new Coords(x - 1, y, z, wID))) { ret++; - ret += get_connected(w, x - 1, y, z, b); + ret += this.get_connected(w, x - 1, y, z, b); } - if (((sides | 0b101111) == 0b111111) && !hashset.contains(new Coords(x, y, z + 1, wID))) { + if ((sides | 0b101111) == 0b111111 && !this.hashset.contains(new Coords(x, y, z + 1, wID))) { ret++; - ret += get_connected(w, x, y, z + 1, b); + ret += this.get_connected(w, x, y, z + 1, b); } - if (((sides | 0b011111) == 0b111111) && !hashset.contains(new Coords(x, y, z - 1, wID))) { + if ((sides | 0b011111) == 0b111111 && !this.hashset.contains(new Coords(x, y, z - 1, wID))) { ret++; - ret += get_connected(w, x, y, z - 1, b); + ret += this.get_connected(w, x, y, z - 1, b); } - if (((sides | 0b111110) == 0b111111) && !hashset.contains(new Coords(x, y + 1, z, wID))) { + if ((sides | 0b111110) == 0b111111 && !this.hashset.contains(new Coords(x, y + 1, z, wID))) { ret++; - ret += get_connected(w, x, y + 1, z, b); + ret += this.get_connected(w, x, y + 1, z, b); } - if (((sides | 0b111101) == 0b111111) && !hashset.contains(new Coords(x, y - 1, z, wID))) { + if ((sides | 0b111101) == 0b111111 && !this.hashset.contains(new Coords(x, y - 1, z, wID))) { ret++; - ret += get_connected(w, x, y - 1, z, b); + ret += this.get_connected(w, x, y - 1, z, b); } return ret; @@ -91,9 +90,9 @@ public byte check_sourroundings(World w, int x, int y, int z, Block b) { byte ret = 0; int wID = w.provider.dimensionId; - if (hashset.contains(new Coords(x, y, z, wID))) return ret; + if (this.hashset.contains(new Coords(x, y, z, wID))) return ret; - hashset.add(new Coords(x, y, z, wID)); + this.hashset.add(new Coords(x, y, z, wID)); if (w.getBlock(x + 1, y, z).equals(b)) ret = (byte) (ret | 0b000100); @@ -115,58 +114,60 @@ public boolean get_meta_of_sideblocks(World w, int n, int[] xyz, boolean GT) { int wID = w.provider.dimensionId; Coords Controller = new Coords(xyz[0], xyz[1], xyz[2], wID); - for (Coords C : hashset) { + for (Coords C : this.hashset) { if (GT) { - TileEntity t; - t = w.getTileEntity(C.x, C.y + 1, C.z); - if (t != null && !new Coords(C.x, C.y + 1, C.z, wID).equals(Controller)) { - if (t instanceof IGregTechTileEntity) - if (((IGregTechTileEntity) t).getMetaTileID() == n) return true; + if (!new Coords(C.x, C.y + 1, C.z, wID).equals(Controller) + && w.getTileEntity(C.x, C.y + 1, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; } - t = w.getTileEntity(C.x, C.y - 1, C.z); - if (t != null && !new Coords(C.x, C.y - 1, C.z, wID).equals(Controller)) { - if (t instanceof IGregTechTileEntity) - if (((IGregTechTileEntity) t).getMetaTileID() == n) return true; + if (!new Coords(C.x, C.y - 1, C.z, wID).equals(Controller) + && w.getTileEntity(C.x, C.y - 1, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; } - t = w.getTileEntity(C.x + 1, C.y, C.z); - if (t != null && !new Coords(C.x + 1, C.y, C.z, wID).equals(Controller)) { - if (t instanceof IGregTechTileEntity) - if (((IGregTechTileEntity) t).getMetaTileID() == n) return true; + if (!new Coords(C.x + 1, C.y, C.z, wID).equals(Controller) + && w.getTileEntity(C.x + 1, C.y, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; } - t = w.getTileEntity(C.x - 1, C.y, C.z); - if (t != null && !new Coords(C.x - 1, C.y, C.z, wID).equals(Controller)) { - if (t instanceof IGregTechTileEntity) - if (((IGregTechTileEntity) t).getMetaTileID() == n) return true; + if (!new Coords(C.x - 1, C.y, C.z, wID).equals(Controller) + && w.getTileEntity(C.x - 1, C.y, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; } - t = w.getTileEntity(C.x, C.y, C.z + 1); - if (t != null && !new Coords(C.x, C.y, C.z + 1, wID).equals(Controller)) { - if (t instanceof IGregTechTileEntity) - if (((IGregTechTileEntity) t).getMetaTileID() == n) return true; + if (!new Coords(C.x, C.y, C.z + 1, wID).equals(Controller) + && w.getTileEntity(C.x, C.y, C.z + 1) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; } - t = w.getTileEntity(C.x, C.y, C.z - 1); - if (t != null && !new Coords(C.x, C.y, C.z - 1, wID).equals(Controller)) { - if (t instanceof IGregTechTileEntity) - if (((IGregTechTileEntity) t).getMetaTileID() == n) return true; + if (!new Coords(C.x, C.y, C.z - 1, wID).equals(Controller) + && w.getTileEntity(C.x, C.y, C.z - 1) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; } } else { - if (n == w.getBlockMetadata(C.x, C.y + 1, C.z) - && !new Coords(C.x, C.y + 1, C.z, wID).equals(Controller)) - return true; - if (n == w.getBlockMetadata(C.x, C.y - 1, C.z) - && !new Coords(C.x, C.y - 1, C.z, wID).equals(Controller)) + if (n == w.getBlockMetadata(C.x, C.y + 1, C.z) && !new Coords(C.x, C.y + 1, C.z, wID).equals(Controller) + || n == w.getBlockMetadata(C.x, C.y - 1, C.z) + && !new Coords(C.x, C.y - 1, C.z, wID).equals(Controller)) { return true; + } if (n == w.getBlockMetadata(C.x + 1, C.y, C.z) - && !new Coords(C.x + 1, C.y, C.z, wID).equals(Controller)) + && !new Coords(C.x + 1, C.y, C.z, wID).equals(Controller)) { return true; + } if (n == w.getBlockMetadata(C.x - 1, C.y, C.z) - && !new Coords(C.x - 1, C.y, C.z, wID).equals(Controller)) + && !new Coords(C.x - 1, C.y, C.z, wID).equals(Controller)) { return true; + } if (n == w.getBlockMetadata(C.x, C.y, C.z + 1) - && !new Coords(C.x, C.y, C.z + 1, wID).equals(Controller)) + && !new Coords(C.x, C.y, C.z + 1, wID).equals(Controller)) { return true; + } if (n == w.getBlockMetadata(C.x, C.y, C.z - 1) - && !new Coords(C.x, C.y, C.z - 1, wID).equals(Controller)) + && !new Coords(C.x, C.y, C.z - 1, wID).equals(Controller)) { return true; + } } } return false; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksCheckerIteration.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksCheckerIteration.java index eb5dd0b17..7dee6f3f9 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksCheckerIteration.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksCheckerIteration.java @@ -18,7 +18,6 @@ import java.util.Queue; import net.minecraft.block.Block; -import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -34,45 +33,45 @@ public class ConnectedBlocksCheckerIteration { private final Queue kwoe = new LinkedList<>(); public long get_connected(World w, int x, int y, int z, Block b) { - kwoe.add(new Coords(x, y, z, w.provider.dimensionId)); - hashset.add(new Coords(x, y, z, w.provider.dimensionId)); - while (!kwoe.isEmpty()) { - Coords tocheck = kwoe.poll(); + this.kwoe.add(new Coords(x, y, z, w.provider.dimensionId)); + this.hashset.add(new Coords(x, y, z, w.provider.dimensionId)); + while (!this.kwoe.isEmpty()) { + Coords tocheck = this.kwoe.poll(); int wID = w.provider.dimensionId; - checked.add(tocheck); + this.checked.add(tocheck); Coords c; - if (!checked.contains(c = new Coords(tocheck.x + 1, tocheck.y, tocheck.z, wID)) + if (!this.checked.contains(c = new Coords(tocheck.x + 1, tocheck.y, tocheck.z, wID)) && w.getBlock(tocheck.x + 1, tocheck.y, tocheck.z).equals(b)) { - kwoe.add(c); - hashset.add(c); + this.kwoe.add(c); + this.hashset.add(c); } - if (!checked.contains(c = new Coords(tocheck.x - 1, tocheck.y, tocheck.z, wID)) + if (!this.checked.contains(c = new Coords(tocheck.x - 1, tocheck.y, tocheck.z, wID)) && w.getBlock(tocheck.x - 1, tocheck.y, tocheck.z).equals(b)) { - kwoe.add(c); - hashset.add(c); + this.kwoe.add(c); + this.hashset.add(c); } - if (!checked.contains(c = new Coords(tocheck.x, tocheck.y, tocheck.z + 1, wID)) + if (!this.checked.contains(c = new Coords(tocheck.x, tocheck.y, tocheck.z + 1, wID)) && w.getBlock(tocheck.x, tocheck.y, tocheck.z + 1).equals(b)) { - kwoe.add(c); - hashset.add(c); + this.kwoe.add(c); + this.hashset.add(c); } - if (!checked.contains(c = new Coords(tocheck.x, tocheck.y, tocheck.z - 1, wID)) + if (!this.checked.contains(c = new Coords(tocheck.x, tocheck.y, tocheck.z - 1, wID)) && w.getBlock(tocheck.x, tocheck.y, tocheck.z - 1).equals(b)) { - kwoe.add(c); - hashset.add(c); + this.kwoe.add(c); + this.hashset.add(c); } - if (!checked.contains(c = new Coords(tocheck.x, tocheck.y + 1, tocheck.z, wID)) + if (!this.checked.contains(c = new Coords(tocheck.x, tocheck.y + 1, tocheck.z, wID)) && w.getBlock(tocheck.x, tocheck.y + 1, tocheck.z).equals(b)) { - kwoe.add(c); - hashset.add(c); + this.kwoe.add(c); + this.hashset.add(c); } - if (!checked.contains(c = new Coords(tocheck.x, tocheck.y - 1, tocheck.z, wID)) + if (!this.checked.contains(c = new Coords(tocheck.x, tocheck.y - 1, tocheck.z, wID)) && w.getBlock(tocheck.x, tocheck.y - 1, tocheck.z).equals(b)) { - kwoe.add(c); - hashset.add(c); + this.kwoe.add(c); + this.hashset.add(c); } } - return hashset.size(); + return this.hashset.size(); } public boolean get_meta_of_sideblocks(World w, int n, int[] xyz, boolean GT) { @@ -80,58 +79,60 @@ public boolean get_meta_of_sideblocks(World w, int n, int[] xyz, boolean GT) { int wID = w.provider.dimensionId; Coords Controller = new Coords(xyz[0], xyz[1], xyz[2], wID); - for (Coords C : hashset) { + for (Coords C : this.hashset) { if (GT) { - TileEntity t; - t = w.getTileEntity(C.x, C.y + 1, C.z); - if (t != null && !new Coords(C.x, C.y + 1, C.z, wID).equals(Controller)) { - if (t instanceof IGregTechTileEntity) - if (((IGregTechTileEntity) t).getMetaTileID() == n) return true; + if (!new Coords(C.x, C.y + 1, C.z, wID).equals(Controller) + && w.getTileEntity(C.x, C.y + 1, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; } - t = w.getTileEntity(C.x, C.y - 1, C.z); - if (t != null && !new Coords(C.x, C.y - 1, C.z, wID).equals(Controller)) { - if (t instanceof IGregTechTileEntity) - if (((IGregTechTileEntity) t).getMetaTileID() == n) return true; + if (!new Coords(C.x, C.y - 1, C.z, wID).equals(Controller) + && w.getTileEntity(C.x, C.y - 1, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; } - t = w.getTileEntity(C.x + 1, C.y, C.z); - if (t != null && !new Coords(C.x + 1, C.y, C.z, wID).equals(Controller)) { - if (t instanceof IGregTechTileEntity) - if (((IGregTechTileEntity) t).getMetaTileID() == n) return true; + if (!new Coords(C.x + 1, C.y, C.z, wID).equals(Controller) + && w.getTileEntity(C.x + 1, C.y, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; } - t = w.getTileEntity(C.x - 1, C.y, C.z); - if (t != null && !new Coords(C.x - 1, C.y, C.z, wID).equals(Controller)) { - if (t instanceof IGregTechTileEntity) - if (((IGregTechTileEntity) t).getMetaTileID() == n) return true; + if (!new Coords(C.x - 1, C.y, C.z, wID).equals(Controller) + && w.getTileEntity(C.x - 1, C.y, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; } - t = w.getTileEntity(C.x, C.y, C.z + 1); - if (t != null && !new Coords(C.x, C.y, C.z + 1, wID).equals(Controller)) { - if (t instanceof IGregTechTileEntity) - if (((IGregTechTileEntity) t).getMetaTileID() == n) return true; + if (!new Coords(C.x, C.y, C.z + 1, wID).equals(Controller) + && w.getTileEntity(C.x, C.y, C.z + 1) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; } - t = w.getTileEntity(C.x, C.y, C.z - 1); - if (t != null && !new Coords(C.x, C.y, C.z - 1, wID).equals(Controller)) { - if (t instanceof IGregTechTileEntity) - if (((IGregTechTileEntity) t).getMetaTileID() == n) return true; + if (!new Coords(C.x, C.y, C.z - 1, wID).equals(Controller) + && w.getTileEntity(C.x, C.y, C.z - 1) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; } } else { - if (n == w.getBlockMetadata(C.x, C.y + 1, C.z) - && !new Coords(C.x, C.y + 1, C.z, wID).equals(Controller)) - return true; - if (n == w.getBlockMetadata(C.x, C.y - 1, C.z) - && !new Coords(C.x, C.y - 1, C.z, wID).equals(Controller)) + if (n == w.getBlockMetadata(C.x, C.y + 1, C.z) && !new Coords(C.x, C.y + 1, C.z, wID).equals(Controller) + || n == w.getBlockMetadata(C.x, C.y - 1, C.z) + && !new Coords(C.x, C.y - 1, C.z, wID).equals(Controller)) { return true; + } if (n == w.getBlockMetadata(C.x + 1, C.y, C.z) - && !new Coords(C.x + 1, C.y, C.z, wID).equals(Controller)) + && !new Coords(C.x + 1, C.y, C.z, wID).equals(Controller)) { return true; + } if (n == w.getBlockMetadata(C.x - 1, C.y, C.z) - && !new Coords(C.x - 1, C.y, C.z, wID).equals(Controller)) + && !new Coords(C.x - 1, C.y, C.z, wID).equals(Controller)) { return true; + } if (n == w.getBlockMetadata(C.x, C.y, C.z + 1) - && !new Coords(C.x, C.y, C.z + 1, wID).equals(Controller)) + && !new Coords(C.x, C.y, C.z + 1, wID).equals(Controller)) { return true; + } if (n == w.getBlockMetadata(C.x, C.y, C.z - 1) - && !new Coords(C.x, C.y, C.z - 1, wID).equals(Controller)) + && !new Coords(C.x, C.y, C.z - 1, wID).equals(Controller)) { return true; + } } } return false; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/Coords.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/Coords.java index b1ece2651..f8c33dd8e 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/Coords.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/Coords.java @@ -33,22 +33,15 @@ public Coords(int x, int y, int z) { } public Coords getCoordsFromSide(ForgeDirection direction) { - switch (direction) { - case UP: - return new Coords(this.x, this.y + 1, this.z, this.wID); - case DOWN: - return new Coords(this.x, this.y - 1, this.z, this.wID); - case WEST: - return new Coords(this.x - 1, this.y, this.z, this.wID); - case EAST: - return new Coords(this.x + 1, this.y, this.z, this.wID); - case NORTH: - return new Coords(this.x, this.y, this.z - 1, this.wID); - case SOUTH: - return new Coords(this.x, this.y, this.z + 1, this.wID); - default: - throw new UnsupportedOperationException("This is impossible."); - } + return switch (direction) { + case UP -> new Coords(this.x, this.y + 1, this.z, this.wID); + case DOWN -> new Coords(this.x, this.y - 1, this.z, this.wID); + case WEST -> new Coords(this.x - 1, this.y, this.z, this.wID); + case EAST -> new Coords(this.x + 1, this.y, this.z, this.wID); + case NORTH -> new Coords(this.x, this.y, this.z - 1, this.wID); + case SOUTH -> new Coords(this.x, this.y, this.z + 1, this.wID); + default -> throw new UnsupportedOperationException("This is impossible."); + }; } @Override @@ -81,6 +74,6 @@ public int hashCode() { @Override public String toString() { - return x + "," + y + "," + z + "," + wID; + return this.x + "," + this.y + "," + this.z + "," + this.wID; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/MathUtils.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/MathUtils.java index b3cbc9351..e8f4330ed 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/MathUtils.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/MathUtils.java @@ -62,13 +62,13 @@ public static double ceil(double x) { } public static byte clamp(byte amount, byte min, byte max) { - byte inner = (amount <= max) ? amount : max; - return (min >= inner) ? min : inner; + byte inner = amount <= max ? amount : max; + return min >= inner ? min : inner; } public static short clamp(short amount, short min, short max) { - short inner = (amount <= max) ? amount : max; - return (min >= inner) ? min : inner; + short inner = amount <= max ? amount : max; + return min >= inner ? min : inner; } public static int clamp(int amount, int min, int max) { @@ -88,23 +88,23 @@ public static double clamp(double amount, double min, double max) { } public static > T clamp(T val, T min, T max) { - return (val.compareTo(min) < 0) ? min : (val.compareTo(max) > 0) ? max : val; + return val.compareTo(min) < 0 ? min : val.compareTo(max) > 0 ? max : val; } public static int wrap(int input, int bound) { - return (((input % bound) + bound) % bound); + return (input % bound + bound) % bound; } public static long wrap(long input, long bound) { - return (((input % bound) + bound) % bound); + return (input % bound + bound) % bound; } public static double wrap(double input, double bound) { - return (((input % bound) + bound) % bound); + return (input % bound + bound) % bound; } public static float wrap(float input, float bound) { - return (((input % bound) + bound) % bound); + return (input % bound + bound) % bound; } public static float tanh(float x) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/MurmurHash3.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/MurmurHash3.java index 30b7ff76a..e230d4341 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/MurmurHash3.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/MurmurHash3.java @@ -13,7 +13,7 @@ public final class MurmurHash3 { - public static final int fmix32(int h) { + public static int fmix32(int h) { h ^= h >>> 16; h *= 0x85ebca6b; h ^= h >>> 13; @@ -22,7 +22,7 @@ public static final int fmix32(int h) { return h; } - public static final long fmix64(long k) { + public static long fmix64(long k) { k ^= k >>> 33; k *= 0xff51afd7ed558ccdL; k ^= k >>> 33; @@ -34,15 +34,15 @@ public static final long fmix64(long k) { /** * Gets a long from a byte buffer in little endian byte order. */ - public static final long getLongLittleEndian(byte[] buf, int offset) { - return ((long) buf[offset + 7] << 56) // no mask needed - | ((buf[offset + 6] & 0xffL) << 48) - | ((buf[offset + 5] & 0xffL) << 40) - | ((buf[offset + 4] & 0xffL) << 32) - | ((buf[offset + 3] & 0xffL) << 24) - | ((buf[offset + 2] & 0xffL) << 16) - | ((buf[offset + 1] & 0xffL) << 8) - | ((buf[offset] & 0xffL)); // no shift needed + public static long getLongLittleEndian(byte[] buf, int offset) { + return (long) buf[offset + 7] << 56 // no mask needed + | (buf[offset + 6] & 0xffL) << 48 + | (buf[offset + 5] & 0xffL) << 40 + | (buf[offset + 4] & 0xffL) << 32 + | (buf[offset + 3] & 0xffL) << 24 + | (buf[offset + 2] & 0xffL) << 16 + | (buf[offset + 1] & 0xffL) << 8 + | buf[offset] & 0xffL; // no shift needed } /** @@ -58,15 +58,13 @@ public static int murmurhash3_x86_32(byte[] data, int offset, int len, int seed) for (int i = offset; i < roundedEnd; i += 4) { // little endian load order - int k1 = (data[i] & 0xff) | ((data[i + 1] & 0xff) << 8) - | ((data[i + 2] & 0xff) << 16) - | (data[i + 3] << 24); + int k1 = data[i] & 0xff | (data[i + 1] & 0xff) << 8 | (data[i + 2] & 0xff) << 16 | data[i + 3] << 24; k1 *= c1; - k1 = (k1 << 15) | (k1 >>> 17); // ROTL32(k1,15); + k1 = k1 << 15 | k1 >>> 17; // ROTL32(k1,15); k1 *= c2; h1 ^= k1; - h1 = (h1 << 13) | (h1 >>> 19); // ROTL32(h1,13); + h1 = h1 << 13 | h1 >>> 19; // ROTL32(h1,13); h1 = h1 * 5 + 0xe6546b64; } @@ -81,9 +79,9 @@ public static int murmurhash3_x86_32(byte[] data, int offset, int len, int seed) k1 |= (data[roundedEnd + 1] & 0xff) << 8; // fallthrough case 1: - k1 |= (data[roundedEnd] & 0xff); + k1 |= data[roundedEnd] & 0xff; k1 *= c1; - k1 = (k1 << 15) | (k1 >>> 17); // ROTL32(k1,15); + k1 = k1 << 15 | k1 >>> 17; // ROTL32(k1,15); k1 *= c2; h1 ^= k1; } @@ -121,7 +119,8 @@ public static int murmurhash3_x86_32(CharSequence data, int offset, int len, int int nBytes = 0; // length in UTF8 bytes while (pos < end) { - int code = data.charAt(pos++); + int code = data.charAt(pos); + pos++; if (code < 0x80) { k2 = code; bits = 8; @@ -137,20 +136,20 @@ public static int murmurhash3_x86_32(CharSequence data, int offset, int len, int * shift = 0; nBytes += 4; k1 = 0; } else { k1 |= code << shift; shift += 8; } continue; ***/ } else if (code < 0x800) { - k2 = (0xC0 | (code >> 6)) | ((0x80 | (code & 0x3F)) << 8); + k2 = 0xC0 | code >> 6 | (0x80 | code & 0x3F) << 8; bits = 16; } else if (code < 0xD800 || code > 0xDFFF || pos >= end) { // we check for pos>=end to encode an unpaired surrogate as 3 bytes. - k2 = (0xE0 | (code >> 12)) | ((0x80 | ((code >> 6) & 0x3F)) << 8) | ((0x80 | (code & 0x3F)) << 16); + k2 = 0xE0 | code >> 12 | (0x80 | code >> 6 & 0x3F) << 8 | (0x80 | code & 0x3F) << 16; bits = 24; } else { // surrogate pair // int utf32 = pos < end ? (int) data.charAt(pos++) : 0; - int utf32 = (int) data.charAt(pos++); - utf32 = ((code - 0xD7C0) << 10) + (utf32 & 0x3FF); - k2 = (0xff & (0xF0 | (utf32 >> 18))) | ((0x80 | ((utf32 >> 12) & 0x3F))) << 8 - | ((0x80 | ((utf32 >> 6) & 0x3F))) << 16 - | (0x80 | (utf32 & 0x3F)) << 24; + int utf32 = data.charAt(pos++); + utf32 = (code - 0xD7C0 << 10) + (utf32 & 0x3FF); + k2 = 0xff & (0xF0 | utf32 >> 18) | (0x80 | utf32 >> 12 & 0x3F) << 8 + | (0x80 | utf32 >> 6 & 0x3F) << 16 + | (0x80 | utf32 & 0x3F) << 24; bits = 32; } @@ -164,17 +163,17 @@ public static int murmurhash3_x86_32(CharSequence data, int offset, int len, int // mix after we have a complete word k1 *= c1; - k1 = (k1 << 15) | (k1 >>> 17); // ROTL32(k1,15); + k1 = k1 << 15 | k1 >>> 17; // ROTL32(k1,15); k1 *= c2; h1 ^= k1; - h1 = (h1 << 13) | (h1 >>> 19); // ROTL32(h1,13); + h1 = h1 << 13 | h1 >>> 19; // ROTL32(h1,13); h1 = h1 * 5 + 0xe6546b64; shift -= 32; // unfortunately, java won't let you shift 32 bits off, so we need to check for 0 if (shift != 0) { - k1 = k2 >>> (bits - shift); // bits used == bits - newshift + k1 = k2 >>> bits - shift; // bits used == bits - newshift } else { k1 = 0; } @@ -186,7 +185,7 @@ public static int murmurhash3_x86_32(CharSequence data, int offset, int len, int if (shift > 0) { nBytes += shift >> 3; k1 *= c1; - k1 = (k1 << 15) | (k1 >>> 17); // ROTL32(k1,15); + k1 = k1 << 15 | k1 >>> 17; // ROTL32(k1,15); k1 *= c2; h1 ^= k1; } @@ -253,13 +252,13 @@ public static void murmurhash3_x64_128(byte[] key, int offset, int len, int seed case 10: k2 |= (key[roundedEnd + 9] & 0xffL) << 8; case 9: - k2 |= (key[roundedEnd + 8] & 0xffL); + k2 |= key[roundedEnd + 8] & 0xffL; k2 *= c2; k2 = Long.rotateLeft(k2, 33); k2 *= c1; h2 ^= k2; case 8: - k1 = ((long) key[roundedEnd + 7]) << 56; + k1 = (long) key[roundedEnd + 7] << 56; case 7: k1 |= (key[roundedEnd + 6] & 0xffL) << 48; case 6: @@ -273,7 +272,7 @@ public static void murmurhash3_x64_128(byte[] key, int offset, int len, int seed case 2: k1 |= (key[roundedEnd + 1] & 0xffL) << 8; case 1: - k1 |= (key[roundedEnd] & 0xffL); + k1 |= key[roundedEnd] & 0xffL; k1 *= c1; k1 = Long.rotateLeft(k1, 31); k1 *= c2; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/SimplexNoise.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/SimplexNoise.java index 3d0edb9bc..8e2e69c49 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/SimplexNoise.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/SimplexNoise.java @@ -161,52 +161,49 @@ public static double noise(double xin, double yin, double zin) { j2 = 1; k2 = 0; } // X Y Z order - else if (x0 >= z0) { - i1 = 1; - j1 = 0; - k1 = 0; - i2 = 1; - j2 = 0; - k2 = 1; - } // X Z Y order else { - i1 = 0; - j1 = 0; - k1 = 1; + if (x0 >= z0) { + i1 = 1; + j1 = 0; + k1 = 0; + } // X Z Y order + else { + i1 = 0; + j1 = 0; + k1 = 1; + } i2 = 1; j2 = 0; k2 = 1; } // Z X Y order - } else { // x0 extends HashMap { + private static final long serialVersionUID = 46345163103910175L; private V defaultValue; public NonNullWrappedHashMap(int initialCapacity, float loadFactor, V defaultValue) { @@ -43,7 +44,7 @@ public NonNullWrappedHashMap(Map m, V defaultValue) { @Override public V get(Object key) { - return getOrDefault(key, defaultValue); + return this.getOrDefault(key, this.defaultValue); } @Override diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/NonNullWrappedHashSet.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/NonNullWrappedHashSet.java index 1a96a3fd7..5490c4bda 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/NonNullWrappedHashSet.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/NonNullWrappedHashSet.java @@ -18,12 +18,11 @@ public class NonNullWrappedHashSet extends HashSet { - public NonNullWrappedHashSet() { - super(); - } + private static final long serialVersionUID = 8377161849188229010L; + + public NonNullWrappedHashSet() {} public NonNullWrappedHashSet(Collection c) { - super(); this.addAll(c); } @@ -35,11 +34,13 @@ public NonNullWrappedHashSet(int initialCapacity) { super(initialCapacity); } + @Override public boolean add(E e) { if (e != null) return super.add(e); return false; } + @Override public boolean addAll(Collection c) { boolean wasChanged = false; for (E element : c) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/Pair.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/Pair.java index 8f34837f9..5f7104f95 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/Pair.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/Pair.java @@ -45,7 +45,7 @@ public boolean equals(Object o) { @Override public int hashCode() { return MurmurHash3.murmurhash3_x86_32( - ByteBuffer.allocate(8).putInt(pair[0].hashCode()).putInt(pair[1].hashCode()).array(), + ByteBuffer.allocate(8).putInt(this.pair[0].hashCode()).putInt(this.pair[1].hashCode()).array(), 0, 8, 31); @@ -53,18 +53,18 @@ public int hashCode() { @Override public A getKey() { - return (A) pair[0]; + return (A) this.pair[0]; } @Override public B getValue() { - return (B) pair[1]; + return (B) this.pair[1]; } @Override public B setValue(Object value) { - pair[1] = value; - return (B) pair[1]; + this.pair[1] = value; + return (B) this.pair[1]; } public Pair copyWithNewValue(B value) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/RecipeFinderForParallel.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/RecipeFinderForParallel.java index 9f3df5d17..dc6863b56 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/RecipeFinderForParallel.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/RecipeFinderForParallel.java @@ -101,10 +101,9 @@ public static int handleParallelRecipe(GT_Recipe aRecipe, FluidStack[] aFluidInp tInputItem.stackSize -= tCompressedItemRecipe.get(tItem); i.remove(); break; - } else { - tCompressedItemRecipe.put(tItem, tCompressedItemRecipe.get(tItem) - tInputItem.stackSize); - tInputItem.stackSize = 0; } + tCompressedItemRecipe.put(tItem, tCompressedItemRecipe.get(tItem) - tInputItem.stackSize); + tInputItem.stackSize = 0; } } } else { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/ResultWrongSievert.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/ResultWrongSievert.java index 6acd41784..7d3af3eb3 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/ResultWrongSievert.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/ResultWrongSievert.java @@ -32,17 +32,14 @@ public boolean wasSuccessful() { @Override public String getDisplayString() { - switch (type) { - case EXACTLY: - return StatCollector.translateToLocalFormatted( - "GT5U.gui.text.wrong_sievert_exactly", - GT_Utility.formatNumbers(required)); - case MINIMUM: - return StatCollector.translateToLocalFormatted( - "GT5U.gui.text.wrong_sievert_min", - GT_Utility.formatNumbers(required)); - } - return ""; + return switch (this.type) { + case EXACTLY -> StatCollector.translateToLocalFormatted( + "GT5U.gui.text.wrong_sievert_exactly", + GT_Utility.formatNumbers(this.required)); + case MINIMUM -> StatCollector.translateToLocalFormatted( + "GT5U.gui.text.wrong_sievert_min", + GT_Utility.formatNumbers(this.required)); + }; } @Override @@ -52,22 +49,22 @@ public CheckRecipeResult newInstance() { @Override public void encode(PacketBuffer buffer) { - buffer.writeVarIntToBuffer(required); - buffer.writeVarIntToBuffer(type.ordinal()); + buffer.writeVarIntToBuffer(this.required); + buffer.writeVarIntToBuffer(this.type.ordinal()); } @Override public void decode(PacketBuffer buffer) { - required = buffer.readVarIntFromBuffer(); - type = NeededSievertType.values()[buffer.readVarIntFromBuffer()]; + this.required = buffer.readVarIntFromBuffer(); + this.type = NeededSievertType.values()[buffer.readVarIntFromBuffer()]; } @Override public boolean equals(Object o) { if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false; ResultWrongSievert that = (ResultWrongSievert) o; - return required == that.required; + return this.required == that.required; } /** diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityList.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityList.java index 25da35d02..6cbd1793e 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityList.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityList.java @@ -23,37 +23,36 @@ import org.apache.commons.lang3.NotImplementedException; -@SuppressWarnings("ALL") public class AccessPriorityList implements List, Deque, Set { transient int size = 0; transient AccessPriorityListNode head; transient AccessPriorityListNode tail; - public static AccessPriorityList create() { - return new AccessPriorityList(); + public static AccessPriorityList create() { + return new AccessPriorityList<>(); } public AccessPriorityList() {} @Override public void addFirst(E t) { - final AccessPriorityListNode first = head; + final AccessPriorityListNode first = this.head; final AccessPriorityListNode newNode = new AccessPriorityListNode<>(null, t, first); - head = newNode; - if (first == null) tail = newNode; + this.head = newNode; + if (first == null) this.tail = newNode; else first.setBefore(newNode); - size++; + this.size++; } @Override public void addLast(E t) { - final AccessPriorityListNode last = tail; + final AccessPriorityListNode last = this.tail; final AccessPriorityListNode newNode = new AccessPriorityListNode<>(last, t, null); - tail = newNode; - if (last == null) head = newNode; + this.tail = newNode; + if (last == null) this.head = newNode; else last.setNext(newNode); - size++; + this.size++; } @Override @@ -68,10 +67,10 @@ public boolean offerLast(E e) { @Override public E removeFirst() { - E first = head.getELEMENT(); - AccessPriorityListNode node = head; - head = node.getNext(); - head.setBefore(null); + E first = this.head.getELEMENT(); + AccessPriorityListNode node = this.head; + this.head = node.getNext(); + this.head.setBefore(null); node.destroy(); node = null; this.size--; @@ -80,10 +79,10 @@ public E removeFirst() { @Override public E removeLast() { - E last = tail.getELEMENT(); - AccessPriorityListNode node = tail; - tail = node.getBefore(); - tail.setNext(null); + E last = this.tail.getELEMENT(); + AccessPriorityListNode node = this.tail; + this.tail = node.getBefore(); + this.tail.setNext(null); node.destroy(); node = null; this.size--; @@ -102,22 +101,22 @@ public E pollLast() { @Override public E getFirst() { - return peekFirst(); + return this.peekFirst(); } @Override public E getLast() { - return peekLast(); + return this.peekLast(); } @Override public E peekFirst() { - return head != null ? head.getELEMENT() : null; + return this.head != null ? this.head.getELEMENT() : null; } @Override public E peekLast() { - return tail != null ? tail.getELEMENT() : null; + return this.tail != null ? this.tail.getELEMENT() : null; } @Override @@ -132,12 +131,12 @@ public boolean removeLastOccurrence(Object o) { @Override public int size() { - return size; + return this.size; } @Override public boolean isEmpty() { - return size == 0; + return this.size == 0; } @Override @@ -147,42 +146,42 @@ public boolean contains(Object o) { @Override public Iterator iterator() { - return new AccessPriorityListIterators.AccessPriorityListIterator<>(head); + return new AccessPriorityListIterators.AccessPriorityListIterator<>(this.head); } public Iterator> nodeIterator() { - return new AccessPriorityListIterators.AccessPriorityListNodeIterator<>(head); + return new AccessPriorityListIterators.AccessPriorityListNodeIterator<>(this.head); } @Override public Iterator descendingIterator() { - return new AccessPriorityListIterators.AccessPriorityListReverseIterator<>(tail); + return new AccessPriorityListIterators.AccessPriorityListReverseIterator<>(this.tail); } @Override public Object[] toArray() { - Object[] ret = new Object[size]; + Object[] ret = new Object[this.size]; int index = 0; - for (Iterator it = iterator(); it.hasNext(); index++) ret[index] = it.next(); + for (Iterator it = this.iterator(); it.hasNext(); index++) ret[index] = it.next(); return ret; } @Override public T[] toArray(T[] a) { - T[] ret = (T[]) new Object[size]; + T[] ret = (T[]) new Object[this.size]; int index = 0; - for (Iterator it = (Iterator) iterator(); it.hasNext(); index++) ret[index] = it.next(); + for (Iterator it = (Iterator) this.iterator(); it.hasNext(); index++) ret[index] = it.next(); return ret; } @Override public boolean add(E e) { - addLast(e); + this.addLast(e); return true; } private void moveNodeUp(AccessPriorityListNode node) { - if (node == head || node.getBefore() == null) return; + if (node == this.head || node.getBefore() == null) return; final AccessPriorityListNode before = node.getBefore(); final AccessPriorityListNode beforeBefore = before.getBefore(); final AccessPriorityListNode next = node.getNext(); @@ -193,7 +192,7 @@ private void moveNodeUp(AccessPriorityListNode node) { // <0,1,2> <1,2,3> N<0,3,4> <3,4,5> if (beforeBefore != null) beforeBefore.setNext(node); - else head = node; + else this.head = node; // <0,1,3> <1,2,3> N<0,3,4> <3,4,5> before.setBefore(node); @@ -203,7 +202,7 @@ private void moveNodeUp(AccessPriorityListNode node) { // <0,1,3> <3,2,4> N<0,3,4> <3,4,5> if (next != null) next.setBefore(before); - else tail = before; + else this.tail = before; // <0,1,3> N<0,3,4> <3,2,4> <2,4,5> node.setNext(before); @@ -211,15 +210,14 @@ private void moveNodeUp(AccessPriorityListNode node) { } AccessPriorityListNode getNode(int index) { - if (index <= (size / 2)) { - AccessPriorityListNode x = head; + if (index <= this.size / 2) { + AccessPriorityListNode x = this.head; for (int i = 0; i < index; i++) x = x.getNext(); return x; - } else { - AccessPriorityListNode x = tail; - for (int i = size - 1; i > index; i--) x = x.getBefore(); - return x; } + AccessPriorityListNode x = this.tail; + for (int i = this.size - 1; i > index; i--) x = x.getBefore(); + return x; } @Override @@ -228,7 +226,7 @@ public boolean offer(E e) { } private boolean isValidIndex(int index) { - if (index >= 0 && index < size) return true; + if (index >= 0 && index < this.size) return true; throw new ArrayIndexOutOfBoundsException("NOT A VAILD INDEX!"); } @@ -239,7 +237,7 @@ public E remove() { @Override public E poll() { - return removeFirst(); + return this.removeFirst(); } @Override @@ -249,17 +247,17 @@ public E element() { @Override public E peek() { - return getFirst(); + return this.getFirst(); } @Override public void push(E e) { - addFirst(e); + this.addFirst(e); } @Override public E pop() { - return removeFirst(); + return this.removeFirst(); } @Override @@ -300,8 +298,8 @@ public boolean retainAll(Collection c) { @Override public void clear() { - if (tail != null) { - AccessPriorityListNode node = tail; + if (this.tail != null) { + AccessPriorityListNode node = this.tail; while (node.getBefore() != null) { node.setNext(null); node.setPriority(0L); @@ -315,33 +313,33 @@ public void clear() { } public void addPrioToNode(AccessPriorityListNode node) { - addPrioToNode(node, 1L); + this.addPrioToNode(node, 1L); } public void addPrioToNode(AccessPriorityListNode node, long prio) { long current = node.getPriority(); - if (current == Long.MAX_VALUE || (current > 0 && prio > 0 && prio + current < 0)) + if (current == Long.MAX_VALUE || current > 0 && prio > 0 && prio + current < 0) node.setPriority(Long.MAX_VALUE); else node.setPriority(current + prio); while (node.getBefore() != null && node.getPriority() >= node.getBefore().getPriority()) { - moveNodeUp(node); + this.moveNodeUp(node); } } public void addPrioToNode(int index, long prio) { - if (!isValidIndex(index)) return; - AccessPriorityListNode node = getNode(index); - addPrioToNode(node, prio); + if (!this.isValidIndex(index)) return; + AccessPriorityListNode node = this.getNode(index); + this.addPrioToNode(node, prio); } public void addPrioToNode(int index) { - addPrioToNode(index, 1L); + this.addPrioToNode(index, 1L); } @Override public E get(int index) { - if (!isValidIndex(index)) return null; - AccessPriorityListNode node = getNode(index); + if (!this.isValidIndex(index)) return null; + AccessPriorityListNode node = this.getNode(index); return node.getELEMENT(); } @@ -372,7 +370,7 @@ public int lastIndexOf(Object o) { @Override public ListIterator listIterator() { - return new AccessPriorityListIterators.AccessPriorityListListIterator<>(head, tail, false); + return new AccessPriorityListIterators.AccessPriorityListListIterator<>(this.head, this.tail, false); } @Override diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityListIterators.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityListIterators.java index dc826caa6..bf3883e69 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityListIterators.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityListIterators.java @@ -32,51 +32,51 @@ public AccessPriorityListListIterator(AccessPriorityListNode head, AccessPrio boolean reverse) { this.head = head; this.tail = tail; - current = reverse ? tail : head; + this.current = reverse ? tail : head; this.reverse = reverse; } public AccessPriorityListListIterator(AccessPriorityList list, int index) { this.head = list.head; this.tail = list.tail; - current = list.getNode(index); - counter = index; + this.current = list.getNode(index); + this.counter = index; } @Override public boolean hasNext() { - return reverse ? head != current : tail != current; + return this.reverse ? this.head != this.current : this.tail != this.current; } @Override public E next() { - counter++; - E ret = current.getELEMENT(); - current = current.getNext(); + this.counter++; + E ret = this.current.getELEMENT(); + this.current = this.current.getNext(); return ret; } @Override public boolean hasPrevious() { - return !reverse ? head != current : tail != current; + return !this.reverse ? this.head != this.current : this.tail != this.current; } @Override public E previous() { - counter--; - E ret = current.getELEMENT(); - current = current.getBefore(); + this.counter--; + E ret = this.current.getELEMENT(); + this.current = this.current.getBefore(); return ret; } @Override public int nextIndex() { - return counter + 1; + return this.counter + 1; } @Override public int previousIndex() { - return counter - 1; + return this.counter - 1; } @Override @@ -106,13 +106,13 @@ public AccessPriorityListIterator(AccessPriorityListNode head) { @Override public boolean hasNext() { - return current != null; + return this.current != null; } @Override public E next() { - E ret = current.getELEMENT(); - current = current.getNext(); + E ret = this.current.getELEMENT(); + this.current = this.current.getNext(); return ret; } } @@ -128,13 +128,13 @@ public AccessPriorityListReverseIterator(AccessPriorityListNode tail) { @Override public boolean hasNext() { - return current != null; + return this.current != null; } @Override public E next() { - E ret = current.getELEMENT(); - current = current.getBefore(); + E ret = this.current.getELEMENT(); + this.current = this.current.getBefore(); return ret; } } @@ -150,13 +150,13 @@ public AccessPriorityListNodeIterator(AccessPriorityListNode head) { @Override public boolean hasNext() { - return current != null; + return this.current != null; } @Override public AccessPriorityListNode next() { - AccessPriorityListNode ret = current; - current = current.getNext(); + AccessPriorityListNode ret = this.current; + this.current = this.current.getNext(); return ret; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityListNode.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityListNode.java index 94bf309ef..72b266917 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityListNode.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityListNode.java @@ -15,7 +15,7 @@ public class AccessPriorityListNode { - public static final AccessPriorityListNode EMPTY_NODE = new AccessPriorityListNode(null); + public static final AccessPriorityListNode EMPTY_NODE = new AccessPriorityListNode<>(null); private final E ELEMENT; private long priority = Long.MIN_VALUE; @@ -23,12 +23,12 @@ public class AccessPriorityListNode { private AccessPriorityListNode before; public AccessPriorityListNode(E element) { - ELEMENT = element; + this.ELEMENT = element; } public AccessPriorityListNode(AccessPriorityListNode before, E element, AccessPriorityListNode next) { this.ELEMENT = element; - connect(next, before); + this.connect(next, before); } public void connect(AccessPriorityListNode next, AccessPriorityListNode before) { @@ -37,11 +37,11 @@ public void connect(AccessPriorityListNode next, AccessPriorityListNode be } public E getELEMENT() { - return ELEMENT; + return this.ELEMENT; } public long getPriority() { - return priority; + return this.priority; } public void setPriority(long priority) { @@ -49,7 +49,7 @@ public void setPriority(long priority) { } public AccessPriorityListNode getNext() { - return next; + return this.next; } public void setNext(AccessPriorityListNode next) { @@ -57,7 +57,7 @@ public void setNext(AccessPriorityListNode next) { } public AccessPriorityListNode getBefore() { - return before; + return this.before; } public void setBefore(AccessPriorityListNode before) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/flowerset/FlowerSet.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/flowerset/FlowerSet.java index d331b95e1..d797e68d8 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/flowerset/FlowerSet.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/flowerset/FlowerSet.java @@ -20,20 +20,20 @@ public class FlowerSet implements Set { - public FlowerSet(int petals, Function comparerison) { + public FlowerSet(int petals, Function, Integer> comparerison) { this.petals = petals; this.comparerison = comparerison; } final int petals; - final Function comparerison; + final Function, Integer> comparerison; - public static FlowerSet createBase64(Function comparerison) { - return new FlowerSet(64, comparerison); + public static FlowerSet createBase64(Function, Integer> comparerison) { + return new FlowerSet<>(64, comparerison); } - public static FlowerSet createHexflower(Function comparerison) { - return new FlowerSet(16, comparerison); + public static FlowerSet createHexflower(Function, Integer> comparerison) { + return new FlowerSet<>(16, comparerison); } @Override @@ -103,39 +103,43 @@ static class FlowerNode { private final FlowerSet map; final V value; - final FlowerNode[] links; + final FlowerNode[] links; + @SuppressWarnings("unchecked") public FlowerNode(V value, FlowerSet map) { this.value = value; this.map = map; - links = new FlowerNode[map.petals]; + this.links = new FlowerNode[map.petals]; } private static final int DEPTH = 20480; - public void TryToSetSingleNode(FlowerNode node, FlowerNode toset, int place, int depth) { + public void TryToSetSingleNode(FlowerNode node, FlowerNode toset, int place, int depth) { if (depth > DEPTH) throw new IllegalStateException("Recursive Call went too deep."); if (node.links[place] == null) node.links[place] = toset; - else TryToSetSingleNode(node.links[place], toset, place, depth++); + else { + this.TryToSetSingleNode(node.links[place], toset, place, depth); + depth++; + } } - public void TryToSetSingleNode(FlowerNode node, FlowerNode toset, int place) { + public void TryToSetSingleNode(FlowerNode node, FlowerNode toset, int place) { if (node.links[place] == null) node.links[place] = toset; - else TryToSetSingleNode(node.links[place], toset, place, 0); + else this.TryToSetSingleNode(node.links[place], toset, place, 0); } @SafeVarargs public final void SetUpLinks(FlowerNode... links) { for (FlowerNode node : links) { - int place = map.comparerison.apply(node); - TryToSetSingleNode(this, node, place); + int place = this.map.comparerison.apply(node); + this.TryToSetSingleNode(this, node, place); } } } static class Functions { - public static Function HashBasedFunction() { + public static Function, Integer> HashBasedFunction() { return function -> function.hashCode() % function.map.petals; } } diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java b/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java index 7f3239a7e..3aaea2201 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java @@ -40,14 +40,16 @@ modid = BartWorksCrossmod.MOD_ID, name = BartWorksCrossmod.NAME, version = BartWorksCrossmod.VERSION, - dependencies = "required-after:IC2; " + "required-after:gregtech; " - + "required-after:bartworks;" - + "after:GalacticraftMars; " - + "after:GalacticraftCore; " - + "after:Micdoodlecore; " - + "after:miscutils; " - + "after:EMT; " - + "after:tectech; ") + dependencies = """ + required-after:IC2;\ + required-after:gregtech;\ + required-after:bartworks;\ + after:GalacticraftMars;\ + after:GalacticraftCore;\ + after:Micdoodlecore;\ + after:miscutils;\ + after:EMT;\ + after:tectech;""") public class BartWorksCrossmod { public static final String NAME = "BartWorks Mod Additions"; diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/GTpp/loader/RadioHatchCompat.java b/src/main/java/com/github/bartimaeusnek/crossmod/GTpp/loader/RadioHatchCompat.java index 9ead53307..a5f4dfa07 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/GTpp/loader/RadioHatchCompat.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/GTpp/loader/RadioHatchCompat.java @@ -42,13 +42,12 @@ import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.common.registry.GameRegistry; -@SuppressWarnings({ "unchecked", "rawtypes", "unused" }) public class RadioHatchCompat { - private static Class intf; - private static Class materialClass; - private static Class enu; - private static Class materialStackClass; + private static Class intf; + private static Class materialClass; + private static Class enu; + private static Class materialStackClass; private static Field isRadioactive; private static Field f; @@ -96,8 +95,8 @@ public class RadioHatchCompat { Object[] arr = RadioHatchCompat.enu.getEnumConstants(); for (Object o : arr) { if (RadioHatchCompat.rod != null && RadioHatchCompat.longRod != null) break; - else if (o.toString().equalsIgnoreCase("ROD")) RadioHatchCompat.rod = o; - else if (o.toString().equalsIgnoreCase("RODLONG")) RadioHatchCompat.longRod = o; + if ("ROD".equalsIgnoreCase(o.toString())) RadioHatchCompat.rod = o; + else if ("RODLONG".equalsIgnoreCase(o.toString())) RadioHatchCompat.longRod = o; } } catch (NoSuchFieldException | ClassNotFoundException e) { @@ -105,11 +104,14 @@ public class RadioHatchCompat { } } + @SuppressWarnings("unchecked") public static void run() { DebugLog.log("Starting Generation of missing GT++ rods/longrods"); try { - Class rodclass = Class.forName("gtPlusPlus.core.item.base.rods.BaseItemRod"); - Class longrodclass = Class.forName("gtPlusPlus.core.item.base.rods.BaseItemRodLong"); + Class rodclass = (Class) Class + .forName("gtPlusPlus.core.item.base.rods.BaseItemRod"); + Class longrodclass = (Class) Class + .forName("gtPlusPlus.core.item.base.rods.BaseItemRodLong"); Constructor c1 = rodclass.getConstructor(RadioHatchCompat.materialClass); Constructor c2 = longrodclass.getConstructor(RadioHatchCompat.materialClass); Field cOwners = GameData.class.getDeclaredField("customOwners"); @@ -125,11 +127,11 @@ public static void run() { for (ModContainer container : Loader.instance().getModList()) { if (gtpp != null && bartworks != null) break; - else if (container.getModId().equalsIgnoreCase(BartWorksCrossmod.MOD_ID)) bartworks = container; + if (BartWorksCrossmod.MOD_ID.equalsIgnoreCase(container.getModId())) bartworks = container; else if (container.getModId().equalsIgnoreCase(GTPlusPlus.ID)) gtpp = container; } - for (Object mats : (Set) RadioHatchCompat.materialClass.getField("mMaterialMap").get(null)) { + for (Object mats : (Set) RadioHatchCompat.materialClass.getField("mMaterialMap").get(null)) { if (RadioHatchCompat.isRadioactive.getBoolean(mats)) { if (OreDictionary.getOres("stick" + RadioHatchCompat.unlocalizedName.get(mats)).isEmpty()) { @@ -194,19 +196,19 @@ static class GTPPRadAdapter implements IRadMaterial { byte amount; final Object m; - private static ArrayList getMaterialInput(Object GTPPMaterial) throws IllegalAccessException { + private static ArrayList getMaterialInput(Object GTPPMaterial) throws IllegalAccessException { Object ret = RadioHatchCompat.vMaterialInput.get(GTPPMaterial); - return ret instanceof ArrayList ? (ArrayList) ret : new ArrayList(); + return ret instanceof ArrayList ? (ArrayList) ret : new ArrayList<>(); } private static boolean isElement(Object GTPPMaterial) throws IllegalAccessException { return RadioHatchCompat.GTPPRadAdapter.getMaterialInput(GTPPMaterial).isEmpty(); } - private static List getElemets(Object GTPPMaterial) throws IllegalAccessException { - ArrayList elements = new ArrayList(); - Queue toCheck = new LinkedList(); - ArrayList materialInputs = RadioHatchCompat.GTPPRadAdapter.getMaterialInput(GTPPMaterial); + private static List getElemets(Object GTPPMaterial) throws IllegalAccessException { + ArrayList elements = new ArrayList<>(); + Queue toCheck = new LinkedList<>(); + ArrayList materialInputs = RadioHatchCompat.GTPPRadAdapter.getMaterialInput(GTPPMaterial); if (materialInputs.isEmpty()) return Collections.singletonList(GTPPMaterial); for (Object materialStack : materialInputs) { if (!RadioHatchCompat.GTPPRadAdapter.isElement(RadioHatchCompat.stackMaterial.get(materialStack))) @@ -222,10 +224,10 @@ private static List getElemets(Object GTPPMaterial) throws IllegalAccessExceptio private static Integer calulateRad(Object m) { int ret = 0; try { - List pureElements = RadioHatchCompat.GTPPRadAdapter.getElemets(m); + List pureElements = RadioHatchCompat.GTPPRadAdapter.getElemets(m); for (Object materialObj : pureElements) if (RadioHatchCompat.isRadioactive.getBoolean(materialObj)) - ret += ((int) RadioHatchCompat.radlevel.getByte(m) + RadioHatchCompat.GTPPRadAdapter - .clampToZero(RadioHatchCompat.protons.getLong(materialObj))); + ret += RadioHatchCompat.radlevel.getByte(m) + RadioHatchCompat.GTPPRadAdapter + .clampToZero(RadioHatchCompat.protons.getLong(materialObj)); else ret += RadioHatchCompat.radlevel.getByte(m); } catch (IllegalAccessException e) { e.printStackTrace(); diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/cls/CLSCompat.java b/src/main/java/com/github/bartimaeusnek/crossmod/cls/CLSCompat.java index 3d1a265b8..1b55aee24 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/cls/CLSCompat.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/cls/CLSCompat.java @@ -79,7 +79,7 @@ public static int invokeStepSize(Werkstoff werkstoff, Integer[] steps, int size) long time = System.currentTimeMillis(); if (time - lastUpdate >= MINIMAL_UPDATE_INTERVAL) { try { - displayProgress.invoke(null, werkstoff.getDefaultName(), ((float) size) / 10000); + displayProgress.invoke(null, werkstoff.getDefaultName(), (float) size / 10000); } catch (IllegalAccessException | InvocationTargetException e) { e.printStackTrace(); } diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticgreg/GT_TileEntity_VoidMiner_Base.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticgreg/GT_TileEntity_VoidMiner_Base.java index c6b465695..b56d33a5d 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticgreg/GT_TileEntity_VoidMiner_Base.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticgreg/GT_TileEntity_VoidMiner_Base.java @@ -26,7 +26,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.Set; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -66,16 +65,15 @@ import gregtech.common.GT_Worldgen_GT_Ore_SmallPieces; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_DrillerBase; -@SuppressWarnings("ALL") public abstract class GT_TileEntity_VoidMiner_Base extends GT_MetaTileEntity_DrillerBase { private static ArrayListMultimap, Float>> extraDropsDimMap = ArrayListMultimap .create(); - private static FluidStack[] NOBLE_GASSES = new FluidStack[] { WerkstoffLoader.Neon.getFluidOrGas(1), + private static FluidStack[] NOBLE_GASSES = { WerkstoffLoader.Neon.getFluidOrGas(1), WerkstoffLoader.Krypton.getFluidOrGas(1), WerkstoffLoader.Xenon.getFluidOrGas(1), WerkstoffLoader.Oganesson.getFluidOrGas(1) }; - private HashMap, Float> dropmap = null; + private Map, Float> dropmap = null; private float totalWeight; private int multiplier = 1; @@ -106,24 +104,24 @@ else if (Material instanceof Werkstoff) getExtraDropsDimMap() public GT_TileEntity_VoidMiner_Base(int aID, String aName, String aNameRegional, int tier) { super(aID, aName, aNameRegional); - TIER_MULTIPLIER = (byte) Math.max(tier, 1); + this.TIER_MULTIPLIER = (byte) Math.max(tier, 1); } @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); - aNBT.setBoolean("mBlacklist", mBlacklist); + aNBT.setBoolean("mBlacklist", this.mBlacklist); } @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - mBlacklist = aNBT.getBoolean("mBlacklist"); + this.mBlacklist = aNBT.getBoolean("mBlacklist"); } public GT_TileEntity_VoidMiner_Base(String aName, int tier) { super(aName); - TIER_MULTIPLIER = (byte) tier; + this.TIER_MULTIPLIER = (byte) tier; } @Override @@ -156,21 +154,20 @@ protected void setElectricityStats() { protected boolean workingAtBottom(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead) { // if the dropmap has never been initialised or if the dropmap is empty - if (dropmap == null || totalWeight == 0) calculateDropMap(); + if (this.dropmap == null || this.totalWeight == 0) this.calculateDropMap(); - if (totalWeight != 0.f) { - handleFluidConsumption(); - handleOutputs(); + if (this.totalWeight != 0.f) { + this.handleFluidConsumption(); + this.handleOutputs(); return true; - } else { - stopMachine(); - return false; } + this.stopMachine(); + return false; } @Override protected GT_Multiblock_Tooltip_Builder createTooltip() { - String casings = getCasingBlockItem().get(0).getDisplayName(); + String casings = this.getCasingBlockItem().get(0).getDisplayName(); final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Miner").addInfo("Controller Block for the Void Miner " + GT_Values.VN[this.getMinTier()]) @@ -178,7 +175,7 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() { .addInfo( "Can be supplied with 2L/s of Neon(x4), Krypton(x8), Xenon(x16) or Oganesson(x64) for higher outputs.") .addInfo( - "Will output " + (2 * TIER_MULTIPLIER) + "Will output " + 2 * this.TIER_MULTIPLIER + " Ores per Second depending on the Dimension it is build in") .addInfo("Put the Ore into the input bus to set the Whitelist/Blacklist") .addInfo("Use a screwdriver to toggle Whitelist/Blacklist") @@ -186,8 +183,10 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() { .beginStructureBlock(3, 7, 3, false).addController("Front bottom") .addOtherStructurePart(casings, "form the 3x1x3 Base") .addOtherStructurePart(casings, "1x3x1 pillar above the center of the base (2 minimum total)") - .addOtherStructurePart(getFrameMaterial().mName + " Frame Boxes", "Each pillar's side and 1x3x1 on top") - .addEnergyHatch(VN[getMinTier()] + "+, Any base casing").addMaintenanceHatch("Any base casing") + .addOtherStructurePart( + this.getFrameMaterial().mName + " Frame Boxes", + "Each pillar's side and 1x3x1 on top") + .addEnergyHatch(VN[this.getMinTier()] + "+, Any base casing").addMaintenanceHatch("Any base casing") .addInputBus("Mining Pipes or Ores, optional, any base casing") .addInputHatch("Optional noble gas, any base casing").addOutputBus("Any base casing") .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS); @@ -215,23 +214,17 @@ public static ArrayListMultimap, Float>> ge */ private Predicate makeOreLayerPredicate() { World world = this.getBaseMetaTileEntity().getWorld(); - switch (world.provider.dimensionId) { - case -1: - return gt_worldgen -> gt_worldgen.mNether; - case 0: - return gt_worldgen -> gt_worldgen.mOverworld; - case 1: - return gt_worldgen -> gt_worldgen.mEnd || gt_worldgen.mEndAsteroid; - case 7: - /* - * explicitely giving different dim numbers so it default to false in the config, keeping compat with - * the current worldgen config - */ - - return gt_worldgen -> gt_worldgen.isGenerationAllowed(world, 0, 7); - default: - throw new IllegalStateException(); - } + return switch (world.provider.dimensionId) { + case -1 -> gt_worldgen -> gt_worldgen.mNether; + case 0 -> gt_worldgen -> gt_worldgen.mOverworld; + case 1 -> gt_worldgen -> gt_worldgen.mEnd || gt_worldgen.mEndAsteroid; + /* + * explicitely giving different dim numbers so it default to false in the config, keeping compat with the + * current worldgen config + */ + case 7 -> gt_worldgen -> gt_worldgen.isGenerationAllowed(world, 0, 7); + default -> throw new IllegalStateException(); + }; } /** @@ -241,22 +234,17 @@ private Predicate makeOreLayerPredicate() { */ private Predicate makeSmallOresPredicate() { World world = this.getBaseMetaTileEntity().getWorld(); - switch (world.provider.dimensionId) { - case -1: - return gt_worldgen -> gt_worldgen.mNether; - case 0: - return gt_worldgen -> gt_worldgen.mOverworld; - case 1: - return gt_worldgen -> gt_worldgen.mEnd; - case 7: - /* - * explicitely giving different dim numbers so it default to false in the config, keeping compat with - * the current worldgen config - */ - return gt_worldgen -> gt_worldgen.isGenerationAllowed(world, 0, 7); - default: - throw new IllegalStateException(); - } + return switch (world.provider.dimensionId) { + case -1 -> gt_worldgen -> gt_worldgen.mNether; + case 0 -> gt_worldgen -> gt_worldgen.mOverworld; + case 1 -> gt_worldgen -> gt_worldgen.mEnd; + /* + * explicitely giving different dim numbers so it default to false in the config, keeping compat with the + * current worldgen config + */ + case 7 -> gt_worldgen -> gt_worldgen.isGenerationAllowed(world, 0, 7); + default -> throw new IllegalStateException(); + }; } /** @@ -267,15 +255,15 @@ private Predicate makeSmallOresPredicate() { * @param value the non normalised weight */ private void addDrop(Pair key, float value) { - final ItemStack ore = getOreItemStack(key); + final ItemStack ore = this.getOreItemStack(key); if (ConfigHandler.voidMinerBlacklist.contains( String.format( "%s:%d", GameRegistry.findUniqueIdentifierFor(ore.getItem()).toString(), ore.getItemDamage()))) return; - if (!dropmap.containsKey(key)) dropmap.put(key, value); - else dropmap.put(key, dropmap.get(key) + value); + if (!this.dropmap.containsKey(key)) this.dropmap.put(key, value); + else this.dropmap.put(key, this.dropmap.get(key) + value); } /** @@ -286,10 +274,10 @@ private void addDrop(Pair key, float value) { private void getDropsVanillaVeins(Predicate oreLayerPredicate) { GT_Worldgen_GT_Ore_Layer.sList.stream() .filter(gt_worldgen -> gt_worldgen.mEnabled && oreLayerPredicate.test(gt_worldgen)).forEach(element -> { - addDrop(new Pair<>((int) element.mPrimaryMeta, false), (float) element.mWeight); - addDrop(new Pair<>((int) element.mSecondaryMeta, false), (float) element.mWeight); - addDrop(new Pair<>((int) element.mSporadicMeta, false), (element.mWeight / 8f)); - addDrop(new Pair<>((int) element.mBetweenMeta, false), (element.mWeight / 8f)); + this.addDrop(new Pair<>((int) element.mPrimaryMeta, false), element.mWeight); + this.addDrop(new Pair<>((int) element.mSecondaryMeta, false), element.mWeight); + this.addDrop(new Pair<>((int) element.mSporadicMeta, false), element.mWeight / 8f); + this.addDrop(new Pair<>((int) element.mBetweenMeta, false), element.mWeight / 8f); }); } @@ -301,7 +289,7 @@ private void getDropsVanillaVeins(Predicate oreLayerPr private void getDropsVanillaSmallOres(Predicate smallOresPredicate) { GT_Worldgen_GT_Ore_SmallPieces.sList.stream() .filter(gt_worldgen -> gt_worldgen.mEnabled && smallOresPredicate.test(gt_worldgen)) - .forEach(element -> addDrop(new Pair<>((int) element.mMeta, false), (float) element.mAmount)); + .forEach(element -> this.addDrop(new Pair<>((int) element.mMeta, false), element.mAmount)); } /** @@ -310,26 +298,17 @@ private void getDropsVanillaSmallOres(Predicate * @param finalDef ModDimensionDef corresponding to the target dim */ private void getDropsOreVeinsSpace(ModDimensionDef finalDef) { - Set space = GalacticGreg.oreVeinWorldgenList.stream() + GalacticGreg.oreVeinWorldgenList.stream() .filter( - gt_worldgen -> gt_worldgen.mEnabled && gt_worldgen instanceof GT_Worldgen_GT_Ore_Layer_Space - && ((GT_Worldgen_GT_Ore_Layer_Space) gt_worldgen).isEnabledForDim(finalDef)) - .collect(Collectors.toSet()); - - space.forEach(element -> { - addDrop( - new Pair<>((int) ((GT_Worldgen_GT_Ore_Layer_Space) element).mPrimaryMeta, false), - (float) ((GT_Worldgen_GT_Ore_Layer_Space) element).mWeight); - addDrop( - new Pair<>((int) ((GT_Worldgen_GT_Ore_Layer_Space) element).mSecondaryMeta, false), - (float) ((GT_Worldgen_GT_Ore_Layer_Space) element).mWeight); - addDrop( - new Pair<>((int) ((GT_Worldgen_GT_Ore_Layer_Space) element).mSporadicMeta, false), - (((GT_Worldgen_GT_Ore_Layer_Space) element).mWeight / 8f)); - addDrop( - new Pair<>((int) ((GT_Worldgen_GT_Ore_Layer_Space) element).mBetweenMeta, false), - (((GT_Worldgen_GT_Ore_Layer_Space) element).mWeight / 8f)); - }); + gt_worldgen -> gt_worldgen.mEnabled + && gt_worldgen instanceof GT_Worldgen_GT_Ore_Layer_Space oreLayerSpace + && oreLayerSpace.isEnabledForDim(finalDef)) + .map(gt_worldgen -> (GT_Worldgen_GT_Ore_Layer_Space) gt_worldgen).forEach(element -> { + this.addDrop(new Pair<>((int) element.mPrimaryMeta, false), element.mWeight); + this.addDrop(new Pair<>((int) element.mSecondaryMeta, false), element.mWeight); + this.addDrop(new Pair<>((int) element.mSporadicMeta, false), element.mWeight / 8f); + this.addDrop(new Pair<>((int) element.mBetweenMeta, false), element.mWeight / 8f); + }); } /** @@ -338,15 +317,13 @@ private void getDropsOreVeinsSpace(ModDimensionDef finalDef) { * @param finalDef ModDimensionDef corresponding to the target dim */ private void getDropsSmallOreSpace(ModDimensionDef finalDef) { - Set space = GalacticGreg.smallOreWorldgenList.stream().filter( - gt_worldgen -> gt_worldgen.mEnabled && gt_worldgen instanceof GT_Worldgen_GT_Ore_SmallPieces_Space - && ((GT_Worldgen_GT_Ore_SmallPieces_Space) gt_worldgen).isEnabledForDim(finalDef)) - .collect(Collectors.toSet()); - - space.forEach( - element -> addDrop( - new Pair<>((int) ((GT_Worldgen_GT_Ore_SmallPieces_Space) element).mMeta, false), - (float) ((GT_Worldgen_GT_Ore_SmallPieces_Space) element).mAmount)); + GalacticGreg.smallOreWorldgenList.stream() + .filter( + gt_worldgen -> gt_worldgen.mEnabled + && gt_worldgen instanceof GT_Worldgen_GT_Ore_SmallPieces_Space oreSmallPiecesSpace + && oreSmallPiecesSpace.isEnabledForDim(finalDef)) + .map(gt_worldgen -> (GT_Worldgen_GT_Ore_SmallPieces_Space) gt_worldgen) + .forEach(element -> this.addDrop(new Pair<>((int) element.mMeta, false), element.mAmount)); } /** @@ -357,8 +334,8 @@ private void getDropsSmallOreSpace(ModDimensionDef finalDef) { private Pair getOreDamage() { float curentWeight = 0.f; while (true) { - float randomnumber = XSTR.XSTR_INSTANCE.nextFloat() * totalWeight; - for (Map.Entry, Float> entry : dropmap.entrySet()) { + float randomnumber = XSTR.XSTR_INSTANCE.nextFloat() * this.totalWeight; + for (Map.Entry, Float> entry : this.dropmap.entrySet()) { curentWeight += entry.getValue(); if (randomnumber < curentWeight) return entry.getKey(); } @@ -375,7 +352,7 @@ private FluidStack getNobleGasInputAndSetMultiplier() { for (int i = 0; i < NOBLE_GASSES.length; i++) { FluidStack ng = NOBLE_GASSES[i]; if (ng.isFluidEqual(s)) { - multiplier = TIER_MULTIPLIER * (2 << (i == NOBLE_GASSES.length - 1 ? (i + 2) : (i + 1))); + this.multiplier = this.TIER_MULTIPLIER * (2 << (i == NOBLE_GASSES.length - 1 ? i + 2 : i + 1)); return s; } } @@ -404,8 +381,8 @@ private boolean consumeNobleGas(FluidStack gasToConsume) { * handler for the fluid consumption */ private void handleFluidConsumption() { - FluidStack storedNobleGas = getNobleGasInputAndSetMultiplier(); - if (storedNobleGas == null || !consumeNobleGas(storedNobleGas)) multiplier = TIER_MULTIPLIER; + FluidStack storedNobleGas = this.getNobleGasInputAndSetMultiplier(); + if (storedNobleGas == null || !this.consumeNobleGas(storedNobleGas)) this.multiplier = this.TIER_MULTIPLIER; } /** @@ -414,12 +391,12 @@ private void handleFluidConsumption() { * @param aID dim id of Ross128b or Ross128ba */ private void getDropMapRoss(int aID) { - Consumer addToList = makeAddToList(); + Consumer addToList = this.makeAddToList(); BW_OreLayer.sList.stream() .filter( gt_worldgen -> gt_worldgen.mEnabled && gt_worldgen instanceof BW_OreLayer && gt_worldgen.isGenerationAllowed(null, aID, 0)) - .collect(Collectors.toSet()).forEach(addToList); + .forEach(addToList); } /** @@ -431,8 +408,8 @@ private Consumer makeAddToList() { return element -> { List> data = element.getStacksRawData(); for (int i = 0; i < data.size(); i++) { - if (i < data.size() - 2) addDrop(data.get(i), (float) element.mWeight); - else addDrop(data.get(i), (element.mWeight / 8f)); + if (i < data.size() - 2) this.addDrop(data.get(i), element.mWeight); + else this.addDrop(data.get(i), element.mWeight / 8f); } }; } @@ -459,13 +436,12 @@ private ModDimensionDef makeModDimDef() { */ private void addOresVeinsBartworks(ModDimensionDef finalDef, Consumer addToList) { try { - Set space = GalacticGreg.oreVeinWorldgenList.stream() + GalacticGreg.oreVeinWorldgenList.stream() .filter( - gt_worldgen -> gt_worldgen.mEnabled && gt_worldgen instanceof BW_Worldgen_Ore_Layer_Space - && ((BW_Worldgen_Ore_Layer_Space) gt_worldgen).isEnabledForDim(finalDef)) - .collect(Collectors.toSet()); - - space.forEach(addToList); + gt_worldgen -> gt_worldgen.mEnabled + && gt_worldgen instanceof BW_Worldgen_Ore_Layer_Space oreLayerSpace + && oreLayerSpace.isEnabledForDim(finalDef)) + .map(gt_worldgen -> (BW_Worldgen_Ore_Layer_Space) gt_worldgen).forEach(addToList); } catch (NullPointerException ignored) {} } @@ -476,18 +452,14 @@ private void addOresVeinsBartworks(ModDimensionDef finalDef, Consumer gt_worldgen.mEnabled && gt_worldgen instanceof BW_Worldgen_Ore_SmallOre_Space - && ((BW_Worldgen_Ore_SmallOre_Space) gt_worldgen).isEnabledForDim(finalDef)) - .collect(Collectors.toSet()); - - space.forEach( - element -> addDrop( - new Pair<>( - ((BW_Worldgen_Ore_SmallOre_Space) element).mPrimaryMeta, - ((BW_Worldgen_Ore_SmallOre_Space) element).bwOres != 0), - (float) ((BW_Worldgen_Ore_SmallOre_Space) element).mDensity)); + gt_worldgen -> gt_worldgen.mEnabled + && gt_worldgen instanceof BW_Worldgen_Ore_SmallOre_Space smallOreSpace + && smallOreSpace.isEnabledForDim(finalDef)) + .map(gt_worldgen -> (BW_Worldgen_Ore_SmallOre_Space) gt_worldgen).forEach( + element -> this + .addDrop(new Pair<>(element.mPrimaryMeta, element.bwOres != 0), element.mDensity)); } catch (NullPointerException ignored) {} } @@ -498,15 +470,15 @@ private void addSmallOresBartworks(ModDimensionDef finalDef) { */ private void handleExtraDrops(int id) { Optional.ofNullable(getExtraDropsDimMap().get(id)) - .ifPresent(e -> e.forEach(f -> addDrop(f.getKey(), f.getValue()))); + .ifPresent(e -> e.forEach(f -> this.addDrop(f.getKey(), f.getValue()))); } /** * Computes the total weight for normalisation */ private void calculateTotalWeight() { - totalWeight = 0.0f; - dropmap.values().forEach(f -> totalWeight += f); + this.totalWeight = 0.0f; + this.dropmap.values().forEach(f -> this.totalWeight += f); } /** @@ -516,25 +488,25 @@ private void calculateTotalWeight() { */ private void handleModDimDef(int id) { // vanilla dims or TF - if ((id <= 1 && id >= -1) || id == 7) { - getDropsVanillaVeins(makeOreLayerPredicate()); - getDropsVanillaSmallOres(makeSmallOresPredicate()); + if (id <= 1 && id >= -1 || id == 7) { + this.getDropsVanillaVeins(this.makeOreLayerPredicate()); + this.getDropsVanillaSmallOres(this.makeSmallOresPredicate()); // ross dims } else if (id == ConfigHandler.ross128BID || id == ConfigHandler.ross128BAID) { - getDropMapRoss(id); + this.getDropMapRoss(id); // other space dims } else { - Optional.ofNullable(makeModDimDef()).ifPresent(def -> { + Optional.ofNullable(this.makeModDimDef()).ifPresent(def -> { // normal space dim - getDropsOreVeinsSpace(def); - getDropsSmallOreSpace(def); + this.getDropsOreVeinsSpace(def); + this.getDropsSmallOreSpace(def); // BW space dim - Consumer addToList = makeAddToList(); - addOresVeinsBartworks(def, addToList); - addSmallOresBartworks(def); + Consumer addToList = this.makeAddToList(); + this.addOresVeinsBartworks(def, addToList); + this.addSmallOresBartworks(def); }); } } @@ -544,24 +516,23 @@ private void handleModDimDef(int id) { * totalweight for normalisation */ private void calculateDropMap() { - dropmap = new HashMap<>(); + this.dropmap = new HashMap<>(); int id = this.getBaseMetaTileEntity().getWorld().provider.dimensionId; - handleModDimDef(id); - handleExtraDrops(id); - calculateTotalWeight(); + this.handleModDimDef(id); + this.handleExtraDrops(id); + this.calculateTotalWeight(); } /** * Output logic of the VM */ private void handleOutputs() { - Pair stats = getOreDamage(); final List inputOres = this.getStoredInputs().stream().filter(GT_Utility::isOre) .collect(Collectors.toList()); - final ItemStack output = getOreItemStack(stats); + final ItemStack output = this.getOreItemStack(this.getOreDamage()); if (inputOres.size() == 0 - || (mBlacklist && inputOres.stream().allMatch(is -> !GT_Utility.areStacksEqual(is, output))) - || (!mBlacklist && inputOres.stream().anyMatch(is -> GT_Utility.areStacksEqual(is, output)))) + || this.mBlacklist && inputOres.stream().allMatch(is -> !GT_Utility.areStacksEqual(is, output)) + || !this.mBlacklist && inputOres.stream().anyMatch(is -> GT_Utility.areStacksEqual(is, output))) this.addOutput(output); this.updateSlots(); } @@ -576,13 +547,13 @@ private void handleOutputs() { private ItemStack getOreItemStack(Pair stats) { return new ItemStack( stats.getValue() ? WerkstoffLoader.BWOres : GregTech_API.sBlockOres1, - multiplier, + this.multiplier, stats.getKey()); } @Override public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - mBlacklist = !mBlacklist; - GT_Utility.sendChatToPlayer(aPlayer, "Mode: " + (mBlacklist ? "Blacklist" : "Whitelist")); + this.mBlacklist = !this.mBlacklist; + GT_Utility.sendChatToPlayer(aPlayer, "Mode: " + (this.mBlacklist ? "Blacklist" : "Whitelist")); } } diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/PlanetsHelperClass.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/PlanetsHelperClass.java index c502437fc..c9cff6cd9 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/PlanetsHelperClass.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/PlanetsHelperClass.java @@ -25,18 +25,10 @@ public class PlanetsHelperClass { public static EntityLanderBase getLanderType(EntityPlayerMP player) { - EntityLanderBase elb; - switch (ConfigHandler.landerType) { - case 1: - elb = new EntityLander(player); - break; - case 2: - elb = new EntityLandingBalloons(player); - break; - default: - elb = new EntityEntryPod(player); - break; - } - return elb; + return switch (ConfigHandler.landerType) { + case 1 -> new EntityLander(player); + case 2 -> new EntityLandingBalloons(player); + default -> new EntityEntryPod(player); + }; } } diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/UniversalTeleportType.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/UniversalTeleportType.java index 4031e2491..b6fa575b5 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/UniversalTeleportType.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/UniversalTeleportType.java @@ -57,7 +57,7 @@ public Vector3 getParaChestSpawnLocation(WorldServer world, EntityPlayerMP playe @Override public void onSpaceDimensionChanged(World newWorld, EntityPlayerMP player, boolean ridingAutoRocket) { if (ridingAutoRocket) return; - if ((player != null) && (GCPlayerStats.get(player).teleportCooldown <= 0)) { + if (player != null && GCPlayerStats.get(player).teleportCooldown <= 0) { if (player.capabilities.isFlying) { player.capabilities.isFlying = false; } diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/atmosphere/BWAtmosphereManager.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/atmosphere/BWAtmosphereManager.java index e7693159d..77877011c 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/atmosphere/BWAtmosphereManager.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/atmosphere/BWAtmosphereManager.java @@ -32,7 +32,6 @@ import micdoodle8.mods.galacticraft.api.galaxies.GalaxyRegistry; import micdoodle8.mods.galacticraft.api.world.IAtmosphericGas; -@SuppressWarnings({ "unused", "RedundantSuppression" }) public final class BWAtmosphereManager { private static final Map COEFFICIENT_MAP = new HashMap<>(); @@ -82,7 +81,7 @@ public static void addGasToWorld(int worldID, Pair... } private static boolean addGCGasToWorld(int worldID, IAtmosphericGas gas, int aNumber, int aMaxNumber) { - if (gas.equals(IAtmosphericGas.CO2)) { + if (IAtmosphericGas.CO2.equals(gas)) { BWAtmosphereManager.addGasToWorld( worldID, Materials.CarbonDioxide, diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/ChunkProviderRoss128b.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/ChunkProviderRoss128b.java index 02acd6c03..c84ef4528 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/ChunkProviderRoss128b.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/ChunkProviderRoss128b.java @@ -25,6 +25,7 @@ import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.BiomeGenBase.SpawnListEntry; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.ChunkProviderGenerate; @@ -59,13 +60,14 @@ public ChunkProviderRoss128b(World par1World, long seed, boolean mapFeaturesEnab } @Override - @SuppressWarnings("rawtypes") - public List getPossibleCreatures(EnumCreatureType p_73155_1_, int p_73155_2_, int p_73155_3_, int p_73155_4_) { + public List getPossibleCreatures(EnumCreatureType p_73155_1_, int p_73155_2_, int p_73155_3_, + int p_73155_4_) { return null; } + @Override public Chunk provideChunk(int p_73154_1_, int p_73154_2_) { - this.rand.setSeed((long) p_73154_1_ * 341873128712L + (long) p_73154_2_ * 132897987541L); + this.rand.setSeed(p_73154_1_ * 341873128712L + p_73154_2_ * 132897987541L); Block[] ablock = new Block[65536]; byte[] abyte = new byte[65536]; this.func_147424_a(p_73154_1_, p_73154_2_, ablock); @@ -111,7 +113,7 @@ public void populate(IChunkProvider p_73153_1_, int p_73153_2_, int p_73153_3_) if (p_73153_2_ % 4 == 0 || p_73153_3_ % 4 == 0) { long i1 = this.rand.nextLong() / 2L * 2L + 1L; long j1 = this.rand.nextLong() / 2L * 2L + 1L; - this.rand.setSeed((long) p_73153_2_ * i1 + (long) p_73153_3_ * j1 ^ this.worldObj.getSeed()); + this.rand.setSeed(p_73153_2_ * i1 + p_73153_3_ * j1 ^ this.worldObj.getSeed()); } MinecraftForge.EVENT_BUS @@ -126,8 +128,8 @@ public void populate(IChunkProvider p_73153_1_, int p_73153_2_, int p_73153_3_) y1 = this.rand.nextInt(256); z1 = l + this.rand.nextInt(16) + 8; int rni = this.rand.nextInt(8); - if (rni == 0) (new WorldGenLakes(Blocks.ice)).generate(this.worldObj, this.rand, x1, y1, z1); - else if (rni == 4) (new WorldGenLakes(Blocks.water)).generate(this.worldObj, this.rand, x1, y1, z1); + if (rni == 0) new WorldGenLakes(Blocks.ice).generate(this.worldObj, this.rand, x1, y1, z1); + else if (rni == 4) new WorldGenLakes(Blocks.water).generate(this.worldObj, this.rand, x1, y1, z1); } if (biomegenbase != BiomeGenBase.ocean && biomegenbase != BiomeGenBase.deepOcean && biomegenbase != BiomeGenBase.river diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/WorldProviderRoss128b.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/WorldProviderRoss128b.java index a0eaf06d4..7a0c9a743 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/WorldProviderRoss128b.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/WorldProviderRoss128b.java @@ -33,6 +33,7 @@ public boolean canRespawnHere() { return true; } + @Override @SideOnly(Side.CLIENT) public Vec3 getFogColor(float cy, float noidea) { float angle = MathHelper.cos(cy * (float) Math.PI * 2.0F) * 2.0F + 0.5F; diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/ChunkProviderRoss128ba.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/ChunkProviderRoss128ba.java index 51b19bf5c..12668f59e 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/ChunkProviderRoss128ba.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/ChunkProviderRoss128ba.java @@ -48,8 +48,9 @@ public ChunkProviderRoss128ba(World world, long seed, boolean mapFeaturesEnabled this.worldObj = world; } + @Override public Chunk provideChunk(int cx, int cz) { - this.rand.setSeed((long) cx * 341873128712L + (long) cz * 132897987541L); + this.rand.setSeed(cx * 341873128712L + cz * 132897987541L); Block[] ids = new Block[65536]; byte[] meta = new byte[65536]; Arrays.fill(ids, Blocks.air); @@ -64,6 +65,7 @@ public Chunk provideChunk(int cx, int cz) { return Chunk; } + @Override public void decoratePlanet(World par1World, Random par2Random, int par3, int par4) {} @Override @@ -83,17 +85,18 @@ private int getIndex(int x, int y, int z) { final BartsNoise noiseGen2 = new BartsNoise(2, 0.01F, 1D, System.nanoTime()); final BartsNoise noiseGen3 = new BartsNoise(2, 0.002F, 1D, System.nanoTime()); + @Override public void generateTerrain(int chunkX, int chunkZ, Block[] idArray, byte[] metaArray) { for (int x = 0; x < 16; ++x) { for (int z = 0; z < 16; ++z) { - double d = noiseGen.getNoise(x + chunkX * 16, z + chunkZ * 16); - double d2 = noiseGen2.getNoise(x + chunkX * 16, z + chunkZ * 16); - double d3 = noiseGen3.getCosNoise(x + chunkX * 16, z + chunkZ * 16); + double d = this.noiseGen.getNoise(x + chunkX * 16, z + chunkZ * 16); + double d2 = this.noiseGen2.getNoise(x + chunkX * 16, z + chunkZ * 16); + double d3 = this.noiseGen3.getCosNoise(x + chunkX * 16, z + chunkZ * 16); double yDev = d * 4 + d2 * 2 + d3; for (int y = 0; y < 128; ++y) { - if ((double) y < 60.0D + yDev) { + if (y < 60.0D + yDev) { idArray[this.getIndex(x, y, z)] = this.lowerBlockID; int var10001 = this.getIndex(x, y, z); metaArray[var10001] = 4; diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128SolarSystem.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128SolarSystem.java index a69222d2b..171d14998 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128SolarSystem.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128SolarSystem.java @@ -57,7 +57,7 @@ public static void init() { Ross128SolarSystem.Ross128System.setMainStar(Ross128SolarSystem.Ross128); Ross128SolarSystem.Ross128b = new Planet("Ross128b").setParentSolarSystem(Ross128SolarSystem.Ross128System); - Ross128SolarSystem.Ross128b.setRingColorRGB((0x9F) / 255f, (0x8A) / 255f, (0x79) / 255f); + Ross128SolarSystem.Ross128b.setRingColorRGB(0x9F / 255f, 0x8A / 255f, 0x79 / 255f); Ross128SolarSystem.Ross128b.setPhaseShift(1.25F); Ross128SolarSystem.Ross128b.setBodyIcon( new ResourceLocation(BartWorksCrossmod.MOD_ID + ":galacticraft/Ross128b/MapObjs/Ross128b.png")); diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galaxySpace/tileEntity/DysonSwarmSunReplacement.java b/src/main/java/com/github/bartimaeusnek/crossmod/galaxySpace/tileEntity/DysonSwarmSunReplacement.java deleted file mode 100644 index fa0dedaaa..000000000 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galaxySpace/tileEntity/DysonSwarmSunReplacement.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following - * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial - * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -package com.github.bartimaeusnek.crossmod.galaxySpace.tileEntity; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import micdoodle8.mods.galacticraft.core.GalacticraftCore; - -public class DysonSwarmSunReplacement extends MetaTileEntity { - - private static boolean wasBuild; - private static long dysonObjs; - private static long swarmControllers; - - public DysonSwarmSunReplacement(int aID, String aBasicName, String aRegionalName, int aInvSlotCount) { - super(aID, aBasicName, aRegionalName, aInvSlotCount); - } - - private DysonSwarmSunReplacement(String aName, int aInvSlotCount) { - super(aName, aInvSlotCount); - } - - public void toggle() { - ResourceLocation resourceLocation = wasBuild - ? new ResourceLocation(GalacticraftCore.ASSET_PREFIX, "textures/gui/celestialbodies/sun.png") - : new ResourceLocation(GalacticraftCore.ASSET_PREFIX, "textures/gui/celestialbodies/moon.png"); - GalacticraftCore.solarSystemSol.getMainStar().setBodyIcon(resourceLocation); - wasBuild = !wasBuild; - - } - - @Override - public byte getTileEntityBaseType() { - return 2; - } - - @Override - public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { - ++swarmControllers; - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - toggle(); - return super.onRightclick(aBaseMetaTileEntity, aPlayer); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { - return new DysonSwarmSunReplacement(this.mName, this.mInventory.length); - } - - @Override - public void saveNBTData(NBTTagCompound nbtTagCompound) { - nbtTagCompound.setLong("dysonObjs", dysonObjs); - } - - @Override - public void loadNBTData(NBTTagCompound nbtTagCompound) { - dysonObjs = Math.max(dysonObjs, nbtTagCompound.getLong("dysonObjs")); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - aBaseMetaTileEntity - .increaseStoredEnergyUnits((DysonSwarmSunReplacement.dysonObjs * 10000) / swarmControllers, true); - } - - public boolean isEnetOutput() { - return true; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, - ItemStack itemStack) { - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, - ItemStack itemStack) { - return false; - } - - @Override - public String[] getDescription() { - return new String[0]; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity iGregTechTileEntity, ForgeDirection side, ForgeDirection facing, - int colorIndex, boolean b3, boolean b4) { - return new ITexture[0]; - } -} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galaxySpace/tileEntity/GalaxySpaceProxy.java b/src/main/java/com/github/bartimaeusnek/crossmod/galaxySpace/tileEntity/GalaxySpaceProxy.java deleted file mode 100644 index 1bdcc942b..000000000 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galaxySpace/tileEntity/GalaxySpaceProxy.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following - * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial - * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -package com.github.bartimaeusnek.crossmod.galaxySpace.tileEntity; - -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; - -public class GalaxySpaceProxy { - - private GalaxySpaceProxy() {} - - public static void postInit(FMLPostInitializationEvent e) {} - - public static void preInit(FMLPreInitializationEvent e) {} - - private static void serverpreInit(FMLPreInitializationEvent e) {} - - private static void clientpreInit(FMLPreInitializationEvent e) {} - - private static void commonpreInit(FMLPreInitializationEvent e) {} - - public static void init(FMLInitializationEvent e) {} - - private static void serverInit(FMLInitializationEvent e) {} - - private static void clientInit(FMLInitializationEvent e) {} - - private static void commonInit(FMLInitializationEvent e) {} - - private static void serverPostInit(FMLPostInitializationEvent e) {} - - private static void clientPostInit(FMLPostInitializationEvent e) {} - - private static void commonPostInit(FMLPostInitializationEvent e) {} -} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/TileEntity_GTDataServer.java b/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/TileEntity_GTDataServer.java index 997eb597e..469c23b06 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/TileEntity_GTDataServer.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/TileEntity_GTDataServer.java @@ -57,8 +57,8 @@ public String getComponentName() { @Callback public Object[] listData(Context context, Arguments args) { Set ret = new HashSet<>(); - for (Map.Entry entry : OrbDataBase.entrySet()) { - ret.add((entry.getValue().getId() + Long.MAX_VALUE) + ". " + entry.getValue().getmDataTitle()); + for (Map.Entry entry : this.OrbDataBase.entrySet()) { + ret.add(entry.getValue().getId() + Long.MAX_VALUE + ". " + entry.getValue().getmDataTitle()); } return ret.toArray(new String[0]); } @@ -78,41 +78,39 @@ public void updateEntity() { if (this.TickTimer++ % 20 != 0) return; if (this.isServerSide()) { - if (GT_Utility.areStacksEqual(this.mItems[0], ItemList.Tool_DataOrb.get(1))) { - if (this.mItems[0].hasTagCompound()) { - if (GT_NBT_DataBase.getIdFromTag(this.mItems[0].getTagCompound()) == null) { - this.OrbDataBase.put( - GT_NBT_DataBase.getMaxID(), - new GT_NBT_DataBase( - Behaviour_DataOrb.getDataName(this.mItems[0]), - Behaviour_DataOrb.getDataTitle(this.mItems[0]), - this.mItems[0].getTagCompound())); - } else { - long id = GT_NBT_DataBase.getIdFromTag(this.mItems[0].getTagCompound()); - this.OrbDataBase.put(id, GT_NBT_DataBase.getGTTagFromId(id)); - } + if (GT_Utility.areStacksEqual(this.mItems[0], ItemList.Tool_DataOrb.get(1)) + && this.mItems[0].hasTagCompound()) { + if (GT_NBT_DataBase.getIdFromTag(this.mItems[0].getTagCompound()) == null) { + this.OrbDataBase.put( + GT_NBT_DataBase.getMaxID(), + new GT_NBT_DataBase( + Behaviour_DataOrb.getDataName(this.mItems[0]), + Behaviour_DataOrb.getDataTitle(this.mItems[0]), + this.mItems[0].getTagCompound())); + } else { + long id = GT_NBT_DataBase.getIdFromTag(this.mItems[0].getTagCompound()); + this.OrbDataBase.put(id, GT_NBT_DataBase.getGTTagFromId(id)); } } - if (GT_Utility.areStacksEqual(this.mItems[0], ItemList.Tool_DataStick.get(1))) { - if (this.mItems[0].hasTagCompound()) { - - String bookTitle = GT_Utility.ItemNBT.getBookTitle(this.mItems[0]); - String punchcardData = GT_Utility.ItemNBT.getPunchCardData(this.mItems[0]); - short mapID = GT_Utility.ItemNBT.getMapID(this.mItems[0]); - byte data = (byte) (bookTitle.isEmpty() ? punchcardData.isEmpty() ? mapID != -1 ? 3 : -1 : 2 : 1); - - String title = data == 1 ? bookTitle - : data == 2 ? punchcardData : data == 3 ? "" + mapID : "Custom Data"; - String name = data == 1 ? "eBook" - : data == 2 ? "Punch Card Data" : data == 3 ? "Map Data" : "Custom Data"; - if (GT_NBT_DataBase.getIdFromTag(this.mItems[0].getTagCompound()) == null) { - this.OrbDataBase.put( - GT_NBT_DataBase.getMaxID(), - new GT_NBT_DataBase(name, title, this.mItems[0].getTagCompound())); - } else { - long id = GT_NBT_DataBase.getIdFromTag(this.mItems[0].getTagCompound()); - this.OrbDataBase.put(id, GT_NBT_DataBase.getGTTagFromId(id)); - } + if (GT_Utility.areStacksEqual(this.mItems[0], ItemList.Tool_DataStick.get(1)) + && this.mItems[0].hasTagCompound()) { + + String bookTitle = GT_Utility.ItemNBT.getBookTitle(this.mItems[0]); + String punchcardData = GT_Utility.ItemNBT.getPunchCardData(this.mItems[0]); + short mapID = GT_Utility.ItemNBT.getMapID(this.mItems[0]); + byte data = (byte) (bookTitle.isEmpty() ? punchcardData.isEmpty() ? mapID != -1 ? 3 : -1 : 2 : 1); + + String title = data == 1 ? bookTitle + : data == 2 ? punchcardData : data == 3 ? "" + mapID : "Custom Data"; + String name = data == 1 ? "eBook" + : data == 2 ? "Punch Card Data" : data == 3 ? "Map Data" : "Custom Data"; + if (GT_NBT_DataBase.getIdFromTag(this.mItems[0].getTagCompound()) == null) { + this.OrbDataBase.put( + GT_NBT_DataBase.getMaxID(), + new GT_NBT_DataBase(name, title, this.mItems[0].getTagCompound())); + } else { + long id = GT_NBT_DataBase.getIdFromTag(this.mItems[0].getTagCompound()); + this.OrbDataBase.put(id, GT_NBT_DataBase.getGTTagFromId(id)); } } } @@ -147,24 +145,24 @@ public int getSizeInventory() { } @Override - public ItemStack getStackInSlot(int p_70301_1_) { - return p_70301_1_ == 0 ? this.mItems[0] : this.mItems[1]; + public ItemStack getStackInSlot(int slotIn) { + return slotIn == 0 ? this.mItems[0] : this.mItems[1]; } @Override - public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) { + public ItemStack decrStackSize(int index, int count) { return null; } @Override - public ItemStack getStackInSlotOnClosing(int p_70304_1_) { + public ItemStack getStackInSlotOnClosing(int index) { return null; } @Override - public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { - if (p_70299_1_ > 1 || p_70299_1_ < 0) return; - this.mItems[p_70299_1_] = p_70299_2_; + public void setInventorySlotContents(int index, ItemStack stack) { + if (index > 1 || index < 0) return; + this.mItems[index] = stack; } @Override @@ -183,7 +181,7 @@ public int getInventoryStackLimit() { } @Override - public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { + public boolean isUseableByPlayer(EntityPlayer player) { return true; } @@ -194,7 +192,7 @@ public void openInventory() {} public void closeInventory() {} @Override - public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { - return p_94041_1_ == 0; + public boolean isItemValidForSlot(int index, ItemStack stack) { + return index == 0; } } diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/TT_TileEntity_ManualTrafo.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/TT_TileEntity_ManualTrafo.java index 360ccff45..35315b677 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/TT_TileEntity_ManualTrafo.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/TT_TileEntity_ManualTrafo.java @@ -25,7 +25,6 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; -@SuppressWarnings({ "unused", "RedundantSuppression" }) public class TT_TileEntity_ManualTrafo extends GT_TileEntity_ManualTrafo { ArrayList mTTEnergyHatches = new ArrayList<>(); @@ -39,29 +38,28 @@ public TT_TileEntity_ManualTrafo(String aName) { super(aName); } + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { return new TT_TileEntity_ManualTrafo(this.mName); } + @Override public boolean addEnergyOutput(long aEU) { if (aEU <= 0L) { return true; - } else { - return mTTDynamos.size() > 0 - || this.mDynamoHatches.size() > 0 && this.addEnergyOutputMultipleDynamos(aEU, true); } + return this.mTTDynamos.size() > 0 + || this.mDynamoHatches.size() > 0 && this.addEnergyOutputMultipleDynamos(aEU, true); } + @Override public boolean addEnergyOutputMultipleDynamos(long aEU, boolean aAllowMixedVoltageDynamos) { int injected = 0; long totalOutput = 0L; long aFirstVoltageFound = -1L; boolean aFoundMixedDynamos = false; - Iterator var10 = this.mDynamoHatches.iterator(); - long aVoltage; - while (var10.hasNext()) { - GT_MetaTileEntity_Hatch_Dynamo aDynamo = var10.next(); + for (GT_MetaTileEntity_Hatch_Dynamo aDynamo : this.mDynamoHatches) { if (aDynamo == null) { return false; } @@ -82,38 +80,38 @@ public boolean addEnergyOutputMultipleDynamos(long aEU, boolean aAllowMixedVolta if (totalOutput < aEU || aFoundMixedDynamos && !aAllowMixedVoltageDynamos) { this.explodeMultiblock(); return false; - } else { - Iterator var17 = this.mDynamoHatches.iterator(); + } + Iterator var17 = this.mDynamoHatches.iterator(); - while (true) { - GT_MetaTileEntity_Hatch_Dynamo aDynamo; - do { - if (!var17.hasNext()) { - return injected > 0; - } + while (true) { + GT_MetaTileEntity_Hatch_Dynamo aDynamo; + do { + if (!var17.hasNext()) { + return injected > 0; + } - aDynamo = var17.next(); - } while (!isValidMetaTileEntity(aDynamo)); + aDynamo = var17.next(); + } while (!isValidMetaTileEntity(aDynamo)); - long leftToInject = aEU - (long) injected; - aVoltage = aDynamo.maxEUOutput(); - int aAmpsToInject = (int) (leftToInject / aVoltage); - int aRemainder = (int) (leftToInject - (long) aAmpsToInject * aVoltage); - int ampsOnCurrentHatch = (int) Math.min(aDynamo.maxAmperesOut(), aAmpsToInject); + long leftToInject = aEU - injected; + aVoltage = aDynamo.maxEUOutput(); + int aAmpsToInject = (int) (leftToInject / aVoltage); + int aRemainder = (int) (leftToInject - aAmpsToInject * aVoltage); + int ampsOnCurrentHatch = (int) Math.min(aDynamo.maxAmperesOut(), aAmpsToInject); - for (int i = 0; i < ampsOnCurrentHatch; ++i) { - aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(aVoltage, false); - } + for (int i = 0; i < ampsOnCurrentHatch; ++i) { + aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(aVoltage, false); + } - injected = (int) ((long) injected + aVoltage * (long) ampsOnCurrentHatch); - if (aRemainder > 0 && (long) ampsOnCurrentHatch < aDynamo.maxAmperesOut()) { - aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(aRemainder, false); - injected += aRemainder; - } + injected = (int) (injected + aVoltage * ampsOnCurrentHatch); + if (aRemainder > 0 && ampsOnCurrentHatch < aDynamo.maxAmperesOut()) { + aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(aRemainder, false); + injected += aRemainder; } } } + @Override public boolean drainEnergyInput(long aEU) { if (aEU > 0L) { { diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/TecTechResearchLoader.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/TecTechResearchLoader.java index 2dd621b2b..9166424a4 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/TecTechResearchLoader.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/TecTechResearchLoader.java @@ -32,7 +32,6 @@ public class TecTechResearchLoader { - @SuppressWarnings("deprecation") public static void runResearches() { Fluid solderIndalloy = FluidRegistry.getFluid("molten.indalloy140") != null ? FluidRegistry.getFluid("molten.indalloy140") diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/LowPowerLaser.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/LowPowerLaser.java index 0307cbf17..ae19e8d63 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/LowPowerLaser.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/LowPowerLaser.java @@ -52,7 +52,7 @@ default long maxEUStore() { } default long getTotalPower() { - return this.getAMPERES() * Math.max(this.maxEUOutput(), this.maxEUInput()) - (this.getAMPERES() / 20); + return this.getAMPERES() * Math.max(this.maxEUOutput(), this.maxEUInput()) - this.getAMPERES() / 20; } default void moveAroundLowPower(IGregTechTileEntity aBaseMetaTileEntity) { @@ -73,42 +73,44 @@ default void moveAroundLowPower(IGregTechTileEntity aBaseMetaTileEntity) { return; } - if (aMetaTileEntity instanceof LowPowerLaser && ((LowPowerLaser) aMetaTileEntity).isReceiver() + if (aMetaTileEntity instanceof LowPowerLaser lowPowerLaser && lowPowerLaser.isReceiver() && opposite == tGTTileEntity.getFrontFacing()) { - if (this.maxEUOutput() > ((LowPowerLaser) aMetaTileEntity).maxEUInput() - || this.getAMPERES() > ((LowPowerLaser) aMetaTileEntity).getAMPERES()) { + if (this.maxEUOutput() > lowPowerLaser.maxEUInput() + || this.getAMPERES() > lowPowerLaser.getAMPERES()) { aMetaTileEntity.doExplosion(this.maxEUOutput()); this.setEUVar(aBaseMetaTileEntity.getStoredEU() - this.maxEUOutput()); return; } - if (this.maxEUOutput() == ((LowPowerLaser) aMetaTileEntity).maxEUInput()) { + if (this.maxEUOutput() == lowPowerLaser.maxEUInput()) { long diff = Math.min( this.getAMPERES() * 20L * this.maxEUOutput(), Math.min( - ((LowPowerLaser) aMetaTileEntity).maxEUStore() + lowPowerLaser.maxEUStore() - aMetaTileEntity.getBaseMetaTileEntity().getStoredEU(), aBaseMetaTileEntity.getStoredEU())); this.setEUVar(aBaseMetaTileEntity.getStoredEU() - diff); - ((LowPowerLaser) aMetaTileEntity) - .setEUVar(aMetaTileEntity.getBaseMetaTileEntity().getStoredEU() + diff); + lowPowerLaser.setEUVar(aMetaTileEntity.getBaseMetaTileEntity().getStoredEU() + diff); } return; } - if ((!(aMetaTileEntity instanceof LowPowerLaser) || !((LowPowerLaser) aMetaTileEntity).isTunnel()) + if ((!(aMetaTileEntity instanceof LowPowerLaser lowPowerLaser) || !lowPowerLaser.isTunnel()) && !(aMetaTileEntity instanceof GT_MetaTileEntity_Pipe_Energy)) { return; } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Pipe_Energy) { - if (((GT_MetaTileEntity_Pipe_Energy) aMetaTileEntity).connectionCount < 2) { + if (aMetaTileEntity instanceof GT_MetaTileEntity_Pipe_Energy tePipeEnergy) { + if (tePipeEnergy.connectionCount < 2) { return; } + tePipeEnergy.markUsed(); + return; + } - ((GT_MetaTileEntity_Pipe_Energy) aMetaTileEntity).markUsed(); - } else if (aMetaTileEntity instanceof LowPowerLaser && ((LowPowerLaser) aMetaTileEntity).isTunnel()) { - if (!((LowPowerLaser) aMetaTileEntity).isConnectedCorrectly(front)) return; + if (aMetaTileEntity instanceof LowPowerLaser lowPowerLaser && lowPowerLaser.isTunnel() + && !lowPowerLaser.isConnectedCorrectly(front)) { + return; } } } diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_Abstract_LowPowerLaserThingy.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_Abstract_LowPowerLaserThingy.java index b65b72c52..e1f69d8c0 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_Abstract_LowPowerLaserThingy.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_Abstract_LowPowerLaserThingy.java @@ -56,7 +56,7 @@ public TT_Abstract_LowPowerLaserThingy(String aName, int aTier, long aAmperes, i @Override public long getAMPERES() { - return AMPERES; + return this.AMPERES; } @Override @@ -93,12 +93,12 @@ public boolean isGivingInformation() { @Override public void saveNBTData(NBTTagCompound nbtTagCompound) { - Optional.ofNullable(nbtTagCompound).ifPresent(tag -> tag.setLong("AMPERES", AMPERES)); + Optional.ofNullable(nbtTagCompound).ifPresent(tag -> tag.setLong("AMPERES", this.AMPERES)); } @Override public void loadNBTData(NBTTagCompound nbtTagCompound) { - Optional.ofNullable(nbtTagCompound).ifPresent(tag -> AMPERES = tag.getLong("AMPERES")); + Optional.ofNullable(nbtTagCompound).ifPresent(tag -> this.AMPERES = tag.getLong("AMPERES")); } @Override @@ -148,6 +148,6 @@ public long getMinimumStoredEU() { @Override public long maxEUStore() { - return 512L + GT_Values.V[this.mTier + 1] * 24L * AMPERES; + return 512L + GT_Values.V[this.mTier + 1] * 24L * this.AMPERES; } } diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_LowPowerLaserBox.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_LowPowerLaserBox.java index 1fccb4dd2..d2e1c3aa5 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_LowPowerLaserBox.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_LowPowerLaserBox.java @@ -53,12 +53,12 @@ public boolean isTunnel() { @Override public long maxAmperesOut() { - return !this.getBaseMetaTileEntity().isAllowedToWork() ? AMPERES : 0; + return !this.getBaseMetaTileEntity().isAllowedToWork() ? this.AMPERES : 0; } @Override public long maxAmperesIn() { - return this.getBaseMetaTileEntity().isAllowedToWork() ? AMPERES + (AMPERES / 4) : 0; + return this.getBaseMetaTileEntity().isAllowedToWork() ? this.AMPERES + this.AMPERES / 4 : 0; } @Override @@ -68,7 +68,7 @@ public boolean hasAlternativeModeText() { @Override public String getAlternativeModeText() { - return isReceiver() ? "Set to receiving mode" : "Set to sending mode"; + return this.isReceiver() ? "Set to receiving mode" : "Set to sending mode"; } @Override @@ -101,7 +101,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()) { aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork()); - byte Tick = (byte) ((int) (aTick % 20L)); + byte Tick = (byte) (int) (aTick % 20L); if (16 == Tick) { if (aBaseMetaTileEntity.getStoredEU() > 0L) { this.setEUVar(aBaseMetaTileEntity.getStoredEU() - this.AMPERES); @@ -109,10 +109,10 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { this.setEUVar(0L); } } - if (this.getBaseMetaTileEntity().isAllowedToWork()) - if (aBaseMetaTileEntity.getStoredEU() > this.getMinimumStoredEU()) { - this.moveAroundLowPower(aBaseMetaTileEntity); - } + if (this.getBaseMetaTileEntity().isAllowedToWork() + && aBaseMetaTileEntity.getStoredEU() > this.getMinimumStoredEU()) { + this.moveAroundLowPower(aBaseMetaTileEntity); + } } } } diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_LowPowerLaserDynamo.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_LowPowerLaserDynamo.java index 570d4592c..d2c9d888a 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_LowPowerLaserDynamo.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_LowPowerLaserDynamo.java @@ -83,13 +83,11 @@ public String[] getDescription() { @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()) { - byte Tick = (byte) ((int) (aTick % 20L)); - if (16 == Tick) { - if (aBaseMetaTileEntity.getStoredEU() > 0L) { - this.setEUVar(aBaseMetaTileEntity.getStoredEU() - (long) this.Amperes); - if (aBaseMetaTileEntity.getStoredEU() < 0L) { - this.setEUVar(0L); - } + byte Tick = (byte) (int) (aTick % 20L); + if (16 == Tick && aBaseMetaTileEntity.getStoredEU() > 0L) { + this.setEUVar(aBaseMetaTileEntity.getStoredEU() - this.Amperes); + if (aBaseMetaTileEntity.getStoredEU() < 0L) { + this.setEUVar(0L); } } if (aBaseMetaTileEntity.getStoredEU() > this.getMinimumStoredEU()) { diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_Pipe_Energy_LowPower.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_Pipe_Energy_LowPower.java index 053a7b04a..63978c55d 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_Pipe_Energy_LowPower.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/tiered/TT_MetaTileEntity_Pipe_Energy_LowPower.java @@ -138,7 +138,6 @@ public long injectEnergyUnits(ForgeDirection side, long aVoltage, long aAmperage @Override @Deprecated - @SuppressWarnings("deprecation") public long transferElectricity(ForgeDirection side, long aVoltage, long aAmperage, ArrayList aAlreadyPassedTileEntityList) { return 0L; diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tgregworks/MaterialsInjector.java b/src/main/java/com/github/bartimaeusnek/crossmod/tgregworks/MaterialsInjector.java index 0a6b9d1cc..04e65781d 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/tgregworks/MaterialsInjector.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/tgregworks/MaterialsInjector.java @@ -20,10 +20,12 @@ modid = MaterialsInjector.MOD_ID, name = MaterialsInjector.NAME, version = MaterialsInjector.VERSION, - dependencies = "required-after:IC2; " + "required-after:gregtech; " - + "required-after:bartworks;" - + "before:TGregworks;" - + "before:miscutils; ") + dependencies = """ + required-after:IC2;\ + required-after:gregtech;\ + required-after:bartworks;\ + before:TGregworks;\ + before:miscutils;""") public class MaterialsInjector { public static final String NAME = "BartWorks Mod Additions - TGregworks Container"; diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/tile/GT_WandBuffer.java b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/tile/GT_WandBuffer.java index fcc45f069..5dfada8a8 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/tile/GT_WandBuffer.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/tile/GT_WandBuffer.java @@ -39,6 +39,7 @@ public GT_WandBuffer(String aName, int aTier, String[] aDescription, ITexture[][ super(aName, aTier, aDescription, aTextures, aSlotCount); } + @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()) { this.mCharge = aBaseMetaTileEntity.getStoredEU() / 2L > aBaseMetaTileEntity.getEUCapacity() / 3L; @@ -63,10 +64,12 @@ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex return ThaumcraftHandler.isWand(aStack); } + @Override public int getInventoryStackLimit() { return 1; } + @Override public long[] getStoredEnergy() { boolean scaleOverflow = false; boolean storedOverflow = false; diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java index f4db85e1e..7aca6b05b 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java @@ -14,7 +14,6 @@ package com.github.bartimaeusnek.crossmod.thaumcraft.util; import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import net.minecraft.item.ItemStack; @@ -27,14 +26,13 @@ import gregtech.api.enums.TC_Aspects; -@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) public class ThaumcraftHandler { private ThaumcraftHandler() {} private static Integer taintBiomeID; private static Integer magicalForestBiomeID; - private static Class mWandInterface; + private static Class mWandInterface; static { try { @@ -84,8 +82,8 @@ public static boolean isTaintBiome(int biomeID) { public static class AspectAdder { - public static Class mAspectListClass; - public static Class mAspectClass; + public static Class mAspectListClass; + public static Class mAspectClass; public static Method registerObjectTag; public static Method addToList; public static Method getName; @@ -129,11 +127,12 @@ public static class AspectAdder { } } + @SafeVarargs public static void addAspectViaBW(ItemStack stack, Pair... aspectPair) { if (stack == null || stack.getItem() == null || stack.getUnlocalizedName() == null) return; try { - Object aspectList = ThaumcraftHandler.AspectAdder.mAspectListClass.newInstance(); - for (Pair a : aspectPair) { + Object aspectList = ThaumcraftHandler.AspectAdder.mAspectListClass.getConstructor().newInstance(); + for (Pair a : aspectPair) { if (API_ConfigValues.debugLog) DebugLog.log( "Stack:" + stack.getDisplayName() + " Damage:" @@ -145,18 +144,18 @@ public static void addAspectViaBW(ItemStack stack, Pair... aspe ThaumcraftHandler.AspectAdder.addToList.invoke(aspectList, a.getKey(), a.getValue()); } ThaumcraftHandler.AspectAdder.registerObjectTag.invoke(null, stack, aspectList); - } catch (IllegalAccessException | InstantiationException | InvocationTargetException e) { + } catch (Exception e) { e.printStackTrace(); } } public static void addAspectViaGT(ItemStack stack, TC_Aspects.TC_AspectStack... tc_aspectStacks) { try { - Object aspectList = ThaumcraftHandler.AspectAdder.mAspectListClass.newInstance(); + Object aspectList = ThaumcraftHandler.AspectAdder.mAspectListClass.getConstructor().newInstance(); for (TC_Aspects.TC_AspectStack tc_aspects : tc_aspectStacks) ThaumcraftHandler.AspectAdder.addToList .invoke(aspectList, tc_aspects.mAspect.mAspect, (int) tc_aspects.mAmount); ThaumcraftHandler.AspectAdder.registerObjectTag.invoke(null, stack, aspectList); - } catch (IllegalAccessException | InstantiationException | InvocationTargetException e) { + } catch (Exception e) { e.printStackTrace(); } }