From 5b5a1a8234e419ade32a0bcd31898267a84508e9 Mon Sep 17 00:00:00 2001 From: glowredman <35727266+glowredman@users.noreply.github.com> Date: Sat, 23 Sep 2023 13:06:01 +0200 Subject: Cleanup (#354) * Fix most `@SuppressWarnings` * Update buildscript * Remove dead code * Add missing `@Override` annotations * Deobfuscate parameters * Collapse switch statements * Fix * Combine nested if statements in else block to else if * Reduce indentation when possible * Convert to switch when reasonable * Extract increment/decrement from statement * Pull up assignment * Simplify lambda expression and method reference syntax * Deduplicate code - Factorize operands - Replace (X && Y) || (!X && Z) by X ? Y : Z - Use '==' or '^' on booleans - Merge conditions of if/else if/else that have the same blocks - Pull down common code from if/else statement - Single 'if' statement rather than duplicate blocks that fall through - Remove redundant end of block with jump statement - Remove redundant if condition - Pull out a duplicate 'if' from an if/else * Use pattern matching for instanceof * Convert String concatenation to Text Block * Convert to switch expression where possible * Use diamond operator * Convert to enhanced 'for' loops * Always use 'this' qualifier * Convert fields into local variables if the use is only local * Use String.replace() instead of String.replaceAll() when possible * Avoid Object.equals() or String.equalsIgnoreCase() on null objects * Remove unnecessary casts * Push down negation * Remove redundant super() call in constructor * Remove overridden assignment * Remove redundant modifiers * Raise embedded if into parent if * Create array with curly brrackets when possible * Remove variable assignment before return * Remove unnecessary parentheses * spotlessApply (#355) Co-authored-by: GitHub GTNH Actions <> * Update dependencies.gradle * Update dependencies.gradle * Update dependencies.gradle * sa+deps * add back GG mod in dep file * Make requested changes --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Martin Robertz Former-commit-id: 11b283613ab93b60bf0e52aad99dbcaf9ace3a1f --- addon.gradle | 3 - dependencies.gradle | 1 - gradle.properties | 89 ++- .../bartworks/API/BioObjectAdder.java | 25 +- .../bartworks/API/BioObjectGetter.java | 1 - .../bartworks/API/BioRecipeAdder.java | 2 +- .../bartworks/API/BioVatLogicAdder.java | 1 - .../API/ITileHasDifferentTextureSides.java | 2 +- .../github/bartimaeusnek/bartworks/ASM/BWCore.java | 1 - .../ASM/BWCoreStaticReplacementMethodes.java | 52 +- .../bartworks/ASM/BWCoreTransformer.java | 18 +- .../github/bartimaeusnek/bartworks/GuiHandler.java | 2 +- .../github/bartimaeusnek/bartworks/MainMod.java | 25 +- .../client/ClientEventHandler/TooltipCache.java | 25 +- .../ClientEventHandler/TooltipEventHandler.java | 4 +- .../client/gui/BW_GUIContainer_RotorBlock.java | 8 +- .../client/renderer/BW_EICPistonVisualizer.java | 8 +- .../client/renderer/BW_GT_ItemRenderer.java | 30 +- .../renderer/RendererSwitchingColorFluid.java | 75 +-- .../bartworks/common/blocks/BW_Blocks.java | 3 +- .../bartworks/common/blocks/BW_GlasBlocks.java | 2 +- .../bartworks/common/blocks/BW_GlasBlocks2.java | 2 +- .../common/blocks/BW_TileEntityContainer.java | 42 +- .../blocks/BW_TileEntityContainer_Multiple.java | 24 +- .../bartworks/common/blocks/BioFluidBlock.java | 12 +- .../bartworks/common/commands/ChangeConfig.java | 24 +- .../common/commands/ClearCraftingCache.java | 6 +- .../common/commands/GetWorkingDirectory.java | 6 +- .../common/commands/PrintRecipeListToFile.java | 10 +- .../bartworks/common/commands/RunGC.java | 6 +- .../bartworks/common/commands/SummonRuin.java | 8 +- .../bartworks/common/configs/ConfigHandler.java | 4 +- .../bartworks/common/items/BW_ItemBlocks.java | 3 +- .../bartworks/common/items/BW_SimpleWindMeter.java | 7 +- .../bartworks/common/items/BW_Stonage_Rotors.java | 17 +- .../bartworks/common/items/Circuit_Programmer.java | 24 +- .../common/items/GT_Destructopack_Item.java | 6 +- .../bartworks/common/items/GT_Rockcutter_Item.java | 17 +- .../bartworks/common/items/GT_Teslastaff_Item.java | 13 +- .../bartworks/common/items/LabModule.java | 8 +- .../bartworks/common/items/LabParts.java | 23 +- .../bartworks/common/items/SimpleIconItem.java | 1 + .../bartworks/common/items/SimpleSubItemClass.java | 18 +- .../ElectricImplosionCompressorRecipes.java | 42 +- .../bartworks/common/loaders/FluidLoader.java | 99 ++-- .../bartworks/common/loaders/ItemRegistry.java | 15 +- .../common/loaders/RadioHatchMaterialLoader.java | 5 +- .../common/loaders/StaticRecipeChangeLoaders.java | 229 ++------ .../common/loaders/recipes/Assembler.java | 18 +- .../common/loaders/recipes/CraftingRecipes.java | 18 +- .../bartworks/common/net/BW_Network.java | 52 +- .../common/net/CircuitProgrammerPacket.java | 26 +- .../bartworks/common/net/EICPacket.java | 13 +- .../bartworks/common/net/MetaBlockPacket.java | 29 +- .../bartworks/common/net/OreDictCachePacket.java | 17 +- .../bartworks/common/net/RendererPacket.java | 41 +- .../bartworks/common/net/ServerJoinedPackage.java | 11 +- .../common/tileentities/classic/BW_RotorBlock.java | 1 + .../BW_TileEntity_ExperimentalFloodGate.java | 27 +- .../classic/BW_TileEntity_HeatedWaterPump.java | 84 ++- .../classic/BW_TileEntity_InfinityTank.java | 6 +- .../tileentities/multis/GT_TileEntity_BioVat.java | 119 ++--- .../multis/GT_TileEntity_CircuitAssemblyLine.java | 90 ++-- .../tileentities/multis/GT_TileEntity_DEHP.java | 97 ++-- .../GT_TileEntity_ElectricImplosionCompressor.java | 117 ++-- .../tileentities/multis/GT_TileEntity_HTGR.java | 71 +-- .../tileentities/multis/GT_TileEntity_LESU.java | 96 ++-- .../multis/GT_TileEntity_ManualTrafo.java | 43 +- .../tileentities/multis/GT_TileEntity_THTR.java | 32 +- .../multis/GT_TileEntity_Windmill.java | 156 +++--- .../mega/GT_TileEntity_MegaBlastFurnace.java | 80 +-- .../mega/GT_TileEntity_MegaChemicalReactor.java | 25 +- .../mega/GT_TileEntity_MegaDistillTower.java | 100 ++-- .../mega/GT_TileEntity_MegaMultiBlockBase.java | 20 +- .../multis/mega/GT_TileEntity_MegaOilCracker.java | 76 +-- .../mega/GT_TileEntity_MegaVacuumFreezer.java | 17 +- .../tiered/GT_MetaTileEntity_AcidGenerator.java | 12 + .../tiered/GT_MetaTileEntity_BioLab.java | 155 +++--- .../tiered/GT_MetaTileEntity_Diode.java | 7 +- .../GT_MetaTileEntity_EnergyDistributor.java | 8 +- .../tiered/GT_MetaTileEntity_RadioHatch.java | 117 ++-- .../tiered/GT_MetaTileEntity_Transistor.java | 13 +- .../bartworks/neiHandler/BW_NEI_BioLabHandler.java | 10 +- .../bartworks/neiHandler/BW_NEI_BioVatHandler.java | 10 +- .../bartworks/neiHandler/BW_NEI_OreHandler.java | 33 +- .../server/EventHandler/ServerEventHandler.java | 25 +- .../material/BW_MetaGeneratedBlock_Item.java | 24 +- .../material/BW_MetaGeneratedBlocks_Casing.java | 9 +- .../BW_MetaGeneratedBlocks_CasingAdvanced_TE.java | 2 +- .../material/BW_MetaGeneratedBlocks_Casing_TE.java | 2 +- .../system/material/BW_MetaGeneratedFrames.java | 12 +- .../system/material/BW_MetaGeneratedOreTE.java | 2 +- .../material/BW_MetaGeneratedSmallOreTE.java | 5 +- .../system/material/BW_MetaGenerated_Block_TE.java | 5 +- .../system/material/BW_MetaGenerated_Blocks.java | 27 +- .../system/material/BW_MetaGenerated_Items.java | 23 +- .../system/material/BW_MetaGenerated_Ores.java | 56 +- .../material/BW_MetaGenerated_SmallOres.java | 32 +- .../BW_MetaGenerated_WerkstoffBlock_TE.java | 2 +- .../material/BW_MetaGenerated_WerkstoffBlocks.java | 5 +- .../system/material/BW_NonMeta_MaterialItems.java | 86 +-- .../material/CircuitGeneration/BW_Meta_Items.java | 25 +- .../material/CircuitGeneration/CircuitData.java | 6 +- .../CircuitGeneration/CircuitImprintLoader.java | 20 +- .../CircuitGeneration/CircuitPartLoader.java | 2 +- .../material/GT_Enhancement/BWGTMetaItems.java | 94 ++-- .../GT_Enhancement/GTMetaItemEnhancer.java | 8 +- .../GT_Enhancement/PlatinumSludgeOverHaul.java | 220 ++++---- .../bartworks/system/material/Werkstoff.java | 149 +++--- .../bartworks/system/material/WerkstoffLoader.java | 40 +- .../processingLoaders/AdditionalRecipes.java | 20 +- .../werkstoff_loaders/recipe/AspectLoader.java | 12 +- .../werkstoff_loaders/recipe/CasingLoader.java | 10 +- .../werkstoff_loaders/recipe/CellLoader.java | 4 +- .../werkstoff_loaders/recipe/CrushedLoader.java | 2 +- .../werkstoff_loaders/recipe/DustLoader.java | 128 ++--- .../werkstoff_loaders/recipe/GemLoader.java | 14 +- .../werkstoff_loaders/recipe/MoltenCellLoader.java | 8 +- .../registration/BridgeMaterialsLoader.java | 131 +++-- .../bartworks/system/oredict/OreDictHandler.java | 15 +- .../bartworks/system/oregen/BW_OreLayer.java | 89 ++- .../bartworks/system/oregen/BW_WordGenerator.java | 8 +- .../system/oregen/BW_WorldGenRoss128b.java | 1 + .../bartworks/system/worldgen/MapGenRuins.java | 267 +++++---- .../bartimaeusnek/bartworks/util/BWRecipes.java | 100 ++-- .../bartimaeusnek/bartworks/util/BW_ColorUtil.java | 17 +- .../bartimaeusnek/bartworks/util/BW_Util.java | 595 +++++---------------- .../bartimaeusnek/bartworks/util/BioCulture.java | 13 +- .../bartimaeusnek/bartworks/util/BioDNA.java | 2 +- .../bartimaeusnek/bartworks/util/BioData.java | 6 +- .../bartimaeusnek/bartworks/util/BioPlasmid.java | 2 +- .../bartworks/util/ConnectedBlocksChecker.java | 103 ++-- .../util/ConnectedBlocksCheckerIteration.java | 121 ++--- .../bartimaeusnek/bartworks/util/Coords.java | 27 +- .../bartimaeusnek/bartworks/util/MathUtils.java | 18 +- .../bartimaeusnek/bartworks/util/MurmurHash3.java | 65 ++- .../bartworks/util/NoiseUtil/SimplexNoise.java | 79 ++- .../bartworks/util/NonNullWrappedHashMap.java | 3 +- .../bartworks/util/NonNullWrappedHashSet.java | 9 +- .../github/bartimaeusnek/bartworks/util/Pair.java | 10 +- .../bartworks/util/RecipeFinderForParallel.java | 5 +- .../bartworks/util/ResultWrongSievert.java | 31 +- .../accessprioritylist/AccessPriorityList.java | 116 ++-- .../AccessPriorityListIterators.java | 44 +- .../accessprioritylist/AccessPriorityListNode.java | 14 +- .../bartworks/util/flowerset/FlowerSet.java | 34 +- .../bartimaeusnek/crossmod/BartWorksCrossmod.java | 18 +- .../crossmod/GTpp/loader/RadioHatchCompat.java | 42 +- .../bartimaeusnek/crossmod/cls/CLSCompat.java | 2 +- .../galacticgreg/GT_TileEntity_VoidMiner_Base.java | 247 ++++----- .../crossmod/galacticraft/PlanetsHelperClass.java | 18 +- .../galacticraft/UniversalTeleportType.java | 2 +- .../atmosphere/BWAtmosphereManager.java | 3 +- .../planets/ross128b/ChunkProviderRoss128b.java | 14 +- .../planets/ross128b/WorldProviderRoss128b.java | 1 + .../planets/ross128ba/ChunkProviderRoss128ba.java | 13 +- .../solarsystems/Ross128SolarSystem.java | 2 +- .../tileEntity/DysonSwarmSunReplacement.java | 114 ---- .../galaxySpace/tileEntity/GalaxySpaceProxy.java | 47 -- .../openComputers/TileEntity_GTDataServer.java | 88 ++- .../tectech/TT_TileEntity_ManualTrafo.java | 60 +-- .../crossmod/tectech/TecTechResearchLoader.java | 1 - .../tectech/tileentites/tiered/LowPowerLaser.java | 30 +- .../tiered/TT_Abstract_LowPowerLaserThingy.java | 8 +- .../tiered/TT_MetaTileEntity_LowPowerLaserBox.java | 16 +- .../TT_MetaTileEntity_LowPowerLaserDynamo.java | 12 +- .../TT_MetaTileEntity_Pipe_Energy_LowPower.java | 1 - .../crossmod/tgregworks/MaterialsInjector.java | 10 +- .../crossmod/thaumcraft/tile/GT_WandBuffer.java | 3 + .../thaumcraft/util/ThaumcraftHandler.java | 19 +- 170 files changed, 3030 insertions(+), 3640 deletions(-) delete mode 100644 addon.gradle delete mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galaxySpace/tileEntity/DysonSwarmSunReplacement.java delete mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galaxySpace/tileEntity/GalaxySpaceProxy.java diff --git a/addon.gradle b/addon.gradle deleted file mode 100644 index cc0f5d57e5..0000000000 --- a/addon.gradle +++ /dev/null @@ -1,3 +0,0 @@ -compileJava { - options.encoding = "UTF-8" -} diff --git a/dependencies.gradle b/dependencies.gradle index 13d6112f9b..4038924ff4 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 7b394d5ef5..dbd43421de 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 f13035b5c9..fc09d943bc 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.enums.Mods.Gendustry; 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.BioDNA; 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 final class BioObjectAdder { 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 final class BioObjectAdder { 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 final class BioObjectAdder { 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 35c12e1cae..ba1308c427 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.BioDNA; 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 b456f8d562..527b62bae3 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 com.github.bartimaeusnek.bartworks.util.BioCulture; import gregtech.api.enums.Materials; -@SuppressWarnings("ALL") public final class BioRecipeAdder { public static final int STANDART = 0; @@ -108,6 +107,7 @@ public final class BioRecipeAdder { * @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 fdfb020919..4084f485ab 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.ItemList; 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 4100b17760..698c28fbf7 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 @@ public interface ITileHasDifferentTextureSides { @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 60202e102e..05877f42e0 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.event.FMLPreInitializationEvent; 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 86480db53c..8d3fe4876c 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 class BWCoreStaticReplacementMethodes { 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 class BWCoreStaticReplacementMethodes { 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 1605192572..794fd2881f 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 @@ public class BWCoreTransformer implements IClassTransformer { 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 class BWCoreTransformer implements IClassTransformer { 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 class BWCoreTransformer implements IClassTransformer { } } 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 class BWCoreTransformer implements IClassTransformer { 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 class BWCoreTransformer implements IClassTransformer { 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 class BWCoreTransformer implements IClassTransformer { 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 class BWCoreTransformer implements IClassTransformer { 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 bb9a40934f..c104d09f3a 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 class GuiHandler implements IGuiHandler { @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 cf88fe51bb..e4a73d1996 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.recipe.check.CheckRecipeResultRegistry; 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 4c59aa38ef..a23020e787 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 @@ class TooltipCache { } 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 1c004ec151..2b7e686814 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 class TooltipEventHandler { 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 ccacef6c3f..188c0c9e69 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 class BW_GUIContainer_RotorBlock extends GuiWindKineticGenerator { 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 @@ public class BW_GUIContainer_RotorBlock extends GuiWindKineticGenerator { 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 @@ public class BW_GUIContainer_RotorBlock extends GuiWindKineticGenerator { } } + @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 4b5923fd23..bb48e4067e 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 @@ import gregtech.api.GregTech_API; 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 class BW_EICPistonVisualizer extends EntityFX { // 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 4a6561f9ef..363de0eda7 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 class BW_GT_ItemRenderer implements IItemRenderer { || aType == IItemRenderer.ItemRenderType.INVENTORY || aType == IItemRenderer.ItemRenderType.EQUIPPED || aType == IItemRenderer.ItemRenderType.ENTITY; - } else { - return false; } + return false; } @Override @@ -60,9 +59,8 @@ public class BW_GT_ItemRenderer implements IItemRenderer { 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 class BW_GT_ItemRenderer implements IItemRenderer { 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 class BW_GT_ItemRenderer implements IItemRenderer { -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 894d15cf4c..6e1bffcd08 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 @@ public class RendererSwitchingColorFluid implements ISimpleBlockRenderingHandler 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 class RendererSwitchingColorFluid implements ISimpleBlockRenderingHandler @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 class RendererSwitchingColorFluid implements ISimpleBlockRenderingHandler 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 class RendererSwitchingColorFluid implements ISimpleBlockRenderingHandler 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 3dccd88475..1a00d16d85 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 class BW_Blocks extends Block { @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 8bd57edaf9..a2f5e520b9 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 class BW_GlasBlocks extends BW_Blocks { @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 16688fbc33..337db90324 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 class BW_GlasBlocks2 extends BW_Blocks { @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 2cfc787a1d..07db82fcb2 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 class BW_TileEntityContainer extends BlockContainer implements ITileAddsI } @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 class BW_TileEntityContainer extends BlockContainer implements ITileAddsI 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 class BW_TileEntityContainer extends BlockContainer implements ITileAddsI 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 class BW_TileEntityContainer extends BlockContainer implements ITileAddsI @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 class BW_TileEntityContainer extends BlockContainer implements ITileAddsI 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 class BW_TileEntityContainer extends BlockContainer implements ITileAddsI 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 22b14db261..a7b39dcee3 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 class BW_TileEntityContainer_Multiple extends BlockContainer { } @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 true; } @@ -73,20 +73,19 @@ public class BW_TileEntityContainer_Multiple extends BlockContainer { TileEntity tile = worldObj.getTileEntity(x, y, z); if (tile instanceof IHasGui) { return worldObj.isRemote || IC2.platform.launchGui(player, (IHasGui) tile); - } else if (tile instanceof ITileWithModularUI) { - if (!worldObj.isRemote) { - UIInfos.TILE_MODULAR_UI.open(player, worldObj, x, y, z); - } + } + if (tile instanceof ITileWithModularUI && !worldObj.isRemote) { + UIInfos.TILE_MODULAR_UI.open(player, worldObj, x, y, z); } } 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) { @@ -116,8 +115,7 @@ public class BW_TileEntityContainer_Multiple extends BlockContainer { @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 <