From db089891a20e5696096907864578e39586035e6e Mon Sep 17 00:00:00 2001 From: chill Date: Mon, 5 Jun 2023 06:51:28 +0200 Subject: Code cleanup (#2040) * remove redundant suppressions * prettify commented code * improve comments The integer comment contradicted the code, so I deleted it. * delete commented-out code * update bitwise int flip from XOR to the dedicated tilda operator The flip was a 32-bit XOR, which is an int-flip. That XOR was replaced with an equivalent tilda operator. * convert a field to inline This field was used only once, so put it straight to where it is used. * remove fluid fix since no-one uses Forge version 1355 or earlier * unwrap switches where fitting In some places, we suppress IntelliJ's inspection RedundantLabeledSwitchRuleCodeBlock - we don't want to unwrap some of the suggested cases because we want to keep the consistency in a switch statement for the sake of readability. * fuse "collect" into Stream API * fix javadocs * remove unnecessary public modifiers from an interface Members of an interface are public by default. * move common parts outside of if * suppress OverrideOnly warning in a javadoc * remove unused lock * suppress warnings about unchecked casts These warnings require non-trivial fixes that are yet to arrive. For now, let's suppress them to reduce the warning-bloat. * remove outdated comment * remove final modifier from private methods Because they are private, it is hard to accidentally overwrite them. Therefore, the final modifier is redundant in this case. * refactor getIcon The first 'if' doesn't cover only tMeta == 9 && mConnectedMachineTextures, therefore the second if can be unrolled. The last switch is redundant because all tMeta values are covered by switches, but let's keep SOLID_STEEL as a fallback just in case. * explain what the casings are and why block casings are split * suppress switch-to-if suggestion * remove unnecessary null check The null is handled in doGenerateItem() * address redundant local variables * rename variables in onTick * suppress warning about accessing static member via instance * rephrase exception * rephrase javadoc * address field-can-be-final warnings * remove empty methods * enum cannot inherit, so protected is redundant * remove redundant throws * update imports to be not wildcard * remove unnecessary try-catch * update for loop * remove redundant code in order to use the diamond operator * update instanceof to use pattern variables * replace blank lines with

in javadocs * fix dangling javadocs * suppress warning about unreachable methods in javadocs * remove redundant operation * add the descriptions of parameters in javadocs Also fix javadocs along the way. * relax returned type in javadoc That was done in order to make the docs reflect the code more often. Otherwise, people may forget to change the returned type again with another change. * make long conversion explicit Integer multiplication can give a wrong result if one of the parts is not explicitly cast to long. Let's cast one of the parts where applicable. * remove unary plus * simplify unary minus * use addAll instead of forEach,add It was suggested by IntelliJ to replace the iteration with a bulk operation to improve performance. * replace .asList with .singletonList for consistency * simplify toArray calls Explanation from IntelliJ: There are two styles to convert a collection to an array: * A pre-sized array, for example, c.toArray(new String[c.size()]) * An empty array, for example, c.toArray(new String[0]) In older Java versions, using a pre-sized array was recommended, as the reflection call necessary to create an array of proper size was quite slow. However, since late updates of OpenJDK 6, this call was intrinsified, making the performance of the empty array version the same, and sometimes even better, compared to the pre-sized version. Also, passing a pre-sized array is dangerous for a concurrent or synchronized collection as a data race is possible between the size and toArray calls. This may result in extra nulls at the end of the array if the collection was concurrently shrunk during the operation. * split StringBuilder append Explanation by IntelliJ: Reports String concatenation used as the argument to appends. Such calls may profitably be turned into chained append calls on the existing StringBuilder saving the cost of an extra StringBuilder allocation. This inspection ignores compile-time evaluated String concatenations, in which case the conversion would only worsen performance. * annotate overriding methods with @Nonnull where needed The method that was overridden has @Nonnull so the method that is overriding should also have @Nonnull. * remove set adding itself to itself * remove null check because findField either works or blows up cpw.mods.fml.relauncher.ReflectionHelper::findField either returns a non-null value or throws a RuntimeException, so no need to check of null. * remove slot comparison with tInventory.length slot max value is 127 when tInventory.length is set to 256, which results in that the condition is always true and unnecessary. * remove aOutput2 null check As GT_Values.NI is null, there is no need to check aOutput2 for null again * suppress the suggestion to delete tMeta < 13 mConnectedMachineTextures can change, so tMeta range is not guaranteed * remove aCoverVariable % 3 < 2 the if above already limits the result of % 3 to "2", so the condition "less than 2" is always false. * unwrap "if" because bonus is unchanged Unwrap if because even if the bonus is a variable, it hasn't been changed for the past 8 years and is unlikely to be changed in the future. * reformat javadoc * improve ignoring an exception Make them either more clear or concise * fixup fix typo * update deprecated calls of newInstance() * remove testing BaseMetaTileEntity GregTech_API.constructBaseMetaTileEntity() checks the creation by itself, logging and throwing a runtime error if failed. * unwrap hatch-fill for do_SolarSalt To reach this branch, do_coolant needs to be false and we need to still be in the function, which means that do_SolarSalt was set to true in the previous top-tier "if". * remove always-false input-bus checks of MTE PlasmaForge size() is non-negative, and the values it is compared to are final and 0. * length and size are non-negative Therefore, there's no need to check their negativity * aOutput is guaranteed to be positive * tThereWasARecipe is always false when reached in its first occurrence * convert an assert into if Only tStack 2 is checked for null because if it isn't null then tStack1 also isn't null based on the "if" above. Also IntelliJ was sure that tStack is not null for some reason. On a side note, assertions work only either with a specified flag or in debug runs. Therefore, it is dangerous to rely on them. * simplify stone-gravel-cobble if tBlock != Blocks.stone because of the if at the start of the method. for the last else-if, tBlock == Blocks.gravel because of the check slightly above the change. * interDimensional is always true because of the first if * convert an example to javadoc * remove always-false statements * replace referential string equality with equals If we compare strings by "==", we compare references to them, which is not what we usually want. I wasn't sure if String Pool works here, so I played it save with equals(). * use Automatic Resource Management for AutoCloseable ByteBufOutputStream * add todo to swap from sleep to event bus * null is checked by instanceof * merge switch branches * add a TODO to use clamp() * new String declaration is redundant * use getOrDefault for a map * replace StringBuilder with concatenation where fitting Using a StringBuilder to concatenate two string will not make the program faster or more understandable, so I swapped it to concatenation. * remove unnecessary continue * flip if * remove redundant returns * unwrap ifs It's checked at the top "if" that aType == IItemRenderer.ItemRenderType.INVENTORY, so all aType.equals(IItemRenderer.ItemRenderType.INVENTORY below are always true. * remove checking all GT VERSIONs except the API one * remove version check from GT_Mod and delete respective VERSION fields Aside from GregTech_API.VERSION, these fields are not used anywhere in the project, so only GregTech_API.VERSION was kept. The idea and the usage check were done by miozune. --- src/main/java/gregtech/common/GT_Client.java | 14 ++- src/main/java/gregtech/common/GT_Network.java | 23 ++++- .../gregtech/common/GT_PlayerActivityLogger.java | 3 +- src/main/java/gregtech/common/GT_Pollution.java | 13 +-- src/main/java/gregtech/common/GT_Proxy.java | 35 +++++-- src/main/java/gregtech/common/GT_RecipeAdder.java | 8 +- .../java/gregtech/common/GT_ThaumcraftCompat.java | 2 +- .../java/gregtech/common/GT_UndergroundOil.java | 8 +- .../gregtech/common/GT_Worldgen_GT_Ore_Layer.java | 19 +--- .../common/GT_Worldgen_GT_Ore_SmallPieces.java | 2 +- .../java/gregtech/common/GT_Worldgen_Stone.java | 4 +- .../java/gregtech/common/GT_Worldgenerator.java | 10 +- .../gregtech/common/bees/GT_AlleleBeeSpecies.java | 2 +- .../java/gregtech/common/bees/GT_AlleleHelper.java | 22 +++-- .../java/gregtech/common/bees/GT_Bee_Mutation.java | 6 +- .../gregtech/common/blocks/GT_Block_Casings1.java | 4 + .../gregtech/common/blocks/GT_Block_Casings2.java | 4 + .../gregtech/common/blocks/GT_Block_Casings3.java | 4 + .../gregtech/common/blocks/GT_Block_Casings4.java | 9 +- .../gregtech/common/blocks/GT_Block_Casings5.java | 20 +++- .../gregtech/common/blocks/GT_Block_Casings6.java | 4 + .../gregtech/common/blocks/GT_Block_Casings8.java | 100 +++++++++----------- .../gregtech/common/blocks/GT_Block_Casings9.java | 4 + .../common/blocks/GT_Block_Casings_Abstract.java | 3 + .../common/blocks/GT_Block_Reinforced.java | 14 ++- .../common/blocks/GT_Block_Stones_Abstract.java | 5 +- .../gregtech/common/blocks/GT_Item_Casings1.java | 4 + .../gregtech/common/blocks/GT_Item_Casings2.java | 4 + .../gregtech/common/blocks/GT_Item_Casings3.java | 4 + .../gregtech/common/blocks/GT_Item_Casings4.java | 4 + .../gregtech/common/blocks/GT_Item_Casings5.java | 4 + .../gregtech/common/blocks/GT_Item_Casings6.java | 4 + .../gregtech/common/blocks/GT_Item_Casings8.java | 4 + .../gregtech/common/blocks/GT_Item_Casings9.java | 4 + .../gregtech/common/blocks/GT_Item_Machines.java | 4 +- .../java/gregtech/common/covers/GT_Cover_Arm.java | 2 +- .../gregtech/common/covers/GT_Cover_Drain.java | 4 +- .../common/entities/GT_EntityFXPollution.java | 2 +- .../gregtech/common/entities/GT_Entity_Arrow.java | 18 ++-- .../modularui/uifactory/SelectItemUIFactory.java | 2 +- src/main/java/gregtech/common/items/CombType.java | 9 +- .../common/items/GT_IntegratedCircuit_Item.java | 20 ++-- .../common/items/GT_MetaGenerated_Item_01.java | 104 ++++++++++++++++----- .../common/items/GT_MetaGenerated_Item_02.java | 17 +++- .../common/items/GT_MetaGenerated_Item_03.java | 35 +++++-- .../common/items/GT_MetaGenerated_Tool_01.java | 55 ++++++++++- .../gregtech/common/items/GT_SensorCard_Item.java | 7 +- src/main/java/gregtech/common/items/ItemComb.java | 19 ++-- .../items/behaviors/Behaviour_Cover_Tool.java | 5 +- .../common/items/behaviors/Behaviour_DataOrb.java | 2 +- .../items/behaviors/Behaviour_DataStick.java | 12 +-- src/main/java/gregtech/common/misc/GT_Command.java | 3 +- .../common/misc/GlobalEnergyWorldSavedData.java | 13 ++- .../spaceprojects/SpaceProjectWorldSavedData.java | 15 ++- .../common/misc/spaceprojects/base/SP_Upgrade.java | 3 +- .../misc/spaceprojects/commands/SPM_Command.java | 6 +- .../misc/spaceprojects/enums/SolarSystem.java | 11 ++- .../spaceprojects/interfaces/ISpaceProject.java | 4 +- .../common/redstonecircuits/GT_Circuit_Pulser.java | 15 ++- .../render/GT_MetaGenerated_Tool_Renderer.java | 56 +---------- .../java/gregtech/common/render/GT_RenderUtil.java | 24 ++--- .../render/items/GT_GeneratedItem_Renderer.java | 9 +- .../items/GT_GeneratedMaterial_Renderer.java | 2 +- .../common/render/items/GaiaSpiritRenderer.java | 2 +- .../common/render/items/UniversiumRenderer.java | 2 +- .../boilers/GT_MetaTileEntity_Boiler_Solar.java | 2 +- .../GT_MetaTileEntity_DieselGenerator.java | 22 ++++- .../generators/GT_MetaTileEntity_GasTurbine.java | 22 ++++- .../GT_MetaTileEntity_MagicalEnergyAbsorber.java | 12 ++- .../GT_MetaTileEntity_NaquadahReactor.java | 45 +++++---- .../generators/GT_MetaTileEntity_SteamTurbine.java | 22 ++++- .../GT_MetaTileEntity_Hatch_InputBus_ME.java | 7 +- .../GT_MetaTileEntity_Hatch_OutputBus_ME.java | 2 +- .../GT_MetaTileEntity_Hatch_Output_ME.java | 2 +- .../GT_MetaTileEntity_AdvSeismicProspector.java | 21 ++++- .../basic/GT_MetaTileEntity_Boxinator.java | 17 +++- .../basic/GT_MetaTileEntity_IndustrialApiary.java | 51 +++++++++- .../basic/GT_MetaTileEntity_Massfabricator.java | 17 +++- .../basic/GT_MetaTileEntity_PotionBrewer.java | 17 +++- .../basic/GT_MetaTileEntity_Replicator.java | 30 ++++-- .../basic/GT_MetaTileEntity_RockBreaker.java | 17 +++- .../machines/basic/GT_MetaTileEntity_Scanner.java | 19 +++- .../basic/GT_MetaTileEntity_SeismicProspector.java | 17 +++- .../basic/GT_MetaTileEntity_Teleporter.java | 41 ++------ .../multi/GT_MetaTileEntity_AssemblyLine.java | 16 +++- .../multi/GT_MetaTileEntity_Cleanroom.java | 10 +- .../GT_MetaTileEntity_ConcreteBackfillerBase.java | 5 +- .../multi/GT_MetaTileEntity_DieselEngine.java | 2 +- .../multi/GT_MetaTileEntity_DistillationTower.java | 7 +- .../multi/GT_MetaTileEntity_DrillerBase.java | 13 ++- .../GT_MetaTileEntity_ElectricBlastFurnace.java | 22 ++++- .../GT_MetaTileEntity_ExtremeDieselEngine.java | 2 +- .../multi/GT_MetaTileEntity_FusionComputer.java | 5 +- .../multi/GT_MetaTileEntity_HeatExchanger.java | 25 ++--- .../GT_MetaTileEntity_ImplosionCompressor.java | 5 +- .../GT_MetaTileEntity_IntegratedOreFactory.java | 46 ++++++--- .../multi/GT_MetaTileEntity_LargeBoiler.java | 8 +- .../GT_MetaTileEntity_LargeChemicalReactor.java | 21 ++++- .../multi/GT_MetaTileEntity_LargeTurbine.java | 10 +- .../multi/GT_MetaTileEntity_LargeTurbine_Gas.java | 6 +- ...GT_MetaTileEntity_LargeTurbine_GasAdvanced.java | 6 +- .../GT_MetaTileEntity_LargeTurbine_HPSteam.java | 6 +- .../GT_MetaTileEntity_LargeTurbine_Plasma.java | 6 +- .../GT_MetaTileEntity_LargeTurbine_Steam.java | 6 +- .../multi/GT_MetaTileEntity_MultiFurnace.java | 6 +- .../multi/GT_MetaTileEntity_NanoForge.java | 10 +- .../multi/GT_MetaTileEntity_OilCracker.java | 15 ++- .../multi/GT_MetaTileEntity_OilDrillBase.java | 8 +- .../GT_MetaTileEntity_OreDrillingPlantBase.java | 4 +- .../multi/GT_MetaTileEntity_PCBFactory.java | 23 +++-- .../multi/GT_MetaTileEntity_PlasmaForge.java | 28 ++++-- .../GT_MetaTileEntity_PrimitiveBlastFurnace.java | 7 +- .../multi/GT_MetaTileEntity_ProcessingArray.java | 18 +++- .../multi/GT_MetaTileEntity_PyrolyseOven.java | 13 ++- .../GT_MetaTileEntity_TranscendentPlasmaMixer.java | 13 ++- .../machines/multiblock/AdvChemicalReactor.java | 17 ++-- .../tileentities/machines/multiblock/CokeOven.java | 2 - .../multiblock/logic/CokeOvenProcessingLogic.java | 2 +- .../GT_MetaTileEntity_AlloySmelter_Bronze.java | 17 +++- .../GT_MetaTileEntity_AlloySmelter_Steel.java | 17 +++- .../steam/GT_MetaTileEntity_Compressor_Bronze.java | 17 +++- .../steam/GT_MetaTileEntity_Compressor_Steel.java | 17 +++- .../steam/GT_MetaTileEntity_Extractor_Bronze.java | 17 +++- .../steam/GT_MetaTileEntity_Extractor_Steel.java | 17 +++- .../GT_MetaTileEntity_ForgeHammer_Bronze.java | 17 +++- .../steam/GT_MetaTileEntity_ForgeHammer_Steel.java | 17 +++- .../steam/GT_MetaTileEntity_Furnace_Bronze.java | 16 +++- .../steam/GT_MetaTileEntity_Furnace_Steel.java | 16 +++- .../steam/GT_MetaTileEntity_Macerator_Bronze.java | 17 +++- .../steam/GT_MetaTileEntity_Macerator_Steel.java | 17 +++- .../GT_MetaTileEntity_DigitalChestBase.java | 2 +- .../storage/GT_MetaTileEntity_DigitalTankBase.java | 5 +- 132 files changed, 1310 insertions(+), 531 deletions(-) (limited to 'src/main/java/gregtech/common') diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 01dc86de8e..38ed683523 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -52,7 +52,10 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.common.network.FMLNetworkEvent; import gregtech.api.GregTech_API; -import gregtech.api.enums.*; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.SoundResource; import gregtech.api.gui.GT_GUIColorOverride; import gregtech.api.gui.modularui.FallbackableSteamTexture; import gregtech.api.interfaces.tileentity.ICoverable; @@ -74,7 +77,14 @@ import gregtech.api.util.GT_Utility; import gregtech.api.util.WorldSpawnedEventBuilder; import gregtech.common.entities.GT_Entity_Arrow; import gregtech.common.entities.GT_Entity_Arrow_Potion; -import gregtech.common.render.*; +import gregtech.common.render.GT_CapeRenderer; +import gregtech.common.render.GT_FlaskRenderer; +import gregtech.common.render.GT_FluidDisplayStackRenderer; +import gregtech.common.render.GT_MetaGenerated_Tool_Renderer; +import gregtech.common.render.GT_MultiTile_Renderer; +import gregtech.common.render.GT_PollutionRenderer; +import gregtech.common.render.GT_Renderer_Block; +import gregtech.common.render.GT_Renderer_Entity_Arrow; import gregtech.common.render.items.GT_MetaGenerated_Item_Renderer; import gregtech.common.tileentities.debug.GT_MetaTileEntity_AdvDebugStructureWriter; import gregtech.loaders.ExtraIcons; diff --git a/src/main/java/gregtech/common/GT_Network.java b/src/main/java/gregtech/common/GT_Network.java index 253f2025ba..4e6aab914d 100644 --- a/src/main/java/gregtech/common/GT_Network.java +++ b/src/main/java/gregtech/common/GT_Network.java @@ -19,7 +19,23 @@ import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.internal.FMLProxyPacket; import cpw.mods.fml.relauncher.Side; import gregtech.api.enums.GT_Values; -import gregtech.api.net.*; +import gregtech.api.net.GT_Packet; +import gregtech.api.net.GT_Packet_Block_Event; +import gregtech.api.net.GT_Packet_ClientPreference; +import gregtech.api.net.GT_Packet_GtTileEntityGuiRequest; +import gregtech.api.net.GT_Packet_MultiTileEntity; +import gregtech.api.net.GT_Packet_Pollution; +import gregtech.api.net.GT_Packet_RequestCoverData; +import gregtech.api.net.GT_Packet_SendCoverData; +import gregtech.api.net.GT_Packet_SetConfigurationCircuit; +import gregtech.api.net.GT_Packet_Sound; +import gregtech.api.net.GT_Packet_TileEntity; +import gregtech.api.net.GT_Packet_TileEntityCover; +import gregtech.api.net.GT_Packet_TileEntityCoverGUI; +import gregtech.api.net.GT_Packet_TileEntityCoverNew; +import gregtech.api.net.GT_Packet_UpdateItem; +import gregtech.api.net.GT_Packet_WirelessRedstoneCover; +import gregtech.api.net.IGT_NetworkHandler; import gregtech.common.blocks.GT_Packet_Ores; import gregtech.common.net.MessageSetFlaskCapacity; import io.netty.buffer.ByteBuf; @@ -73,7 +89,7 @@ public class GT_Network extends MessageToMessageCodec } @Override - protected void encode(ChannelHandlerContext aContext, GT_Packet aPacket, List aOutput) throws Exception { + protected void encode(ChannelHandlerContext aContext, GT_Packet aPacket, List aOutput) { final ByteBuf tBuf = Unpooled.buffer() .writeByte(aPacket.getPacketID()); aPacket.encode(tBuf); @@ -86,8 +102,7 @@ public class GT_Network extends MessageToMessageCodec } @Override - protected void decode(ChannelHandlerContext aContext, FMLProxyPacket aPacket, List aOutput) - throws Exception { + protected void decode(ChannelHandlerContext aContext, FMLProxyPacket aPacket, List aOutput) { final ByteArrayDataInput aData = ByteStreams.newDataInput( aPacket.payload() .array()); diff --git a/src/main/java/gregtech/common/GT_PlayerActivityLogger.java b/src/main/java/gregtech/common/GT_PlayerActivityLogger.java index 7a113bdfb3..c60378ca5e 100644 --- a/src/main/java/gregtech/common/GT_PlayerActivityLogger.java +++ b/src/main/java/gregtech/common/GT_PlayerActivityLogger.java @@ -26,8 +26,9 @@ public class GT_PlayerActivityLogger implements Runnable { } } buffer.clear(); + // TODO: swap from sleep to event bus Thread.sleep(10000L); } - } catch (Throwable e) {} + } catch (Throwable ignored) {} } } diff --git a/src/main/java/gregtech/common/GT_Pollution.java b/src/main/java/gregtech/common/GT_Pollution.java index ff32ba956f..405c968baa 100644 --- a/src/main/java/gregtech/common/GT_Pollution.java +++ b/src/main/java/gregtech/common/GT_Pollution.java @@ -180,9 +180,6 @@ public class GT_Pollution { // Poison effects if (tPollution > GT_Mod.gregtechproxy.mPollutionPoisonLimit) { - // AxisAlignedBB chunk = AxisAlignedBB.getBoundingBox(tPos.chunkPosX*16, 0, tPos.chunkPosZ*16, - // tPos.chunkPosX*16+16, 256, tPos.chunkPosZ*16+16); - // List tEntitys = aWorld.getEntitiesWithinAABB(EntityLiving.class, chunk); for (EntityLivingBase tEnt : tEntitys) { if (tEnt instanceof EntityPlayerMP && ((EntityPlayerMP) tEnt).capabilities.isCreativeMode) continue; @@ -292,14 +289,12 @@ public class GT_Pollution { } if (sourRain && world.isRaining() - && (tBlock == Blocks.stone || tBlock == Blocks.gravel || tBlock == Blocks.cobblestone) + && (tBlock == Blocks.gravel || tBlock == Blocks.cobblestone) && world.getBlock(x, y + 1, z) == Blocks.air && world.canBlockSeeTheSky(x, y, z)) { - if (tBlock == Blocks.stone) { - world.setBlock(x, y, z, Blocks.cobblestone); - } else if (tBlock == Blocks.cobblestone) { + if (tBlock == Blocks.cobblestone) { world.setBlock(x, y, z, Blocks.gravel); - } else if (tBlock == Blocks.gravel) { + } else { world.setBlock(x, y, z, Blocks.sand); } } @@ -372,7 +367,7 @@ public class GT_Pollution { /** * Get the pollution in specified chunk - * + * * @param w world to look in. can be a client world, but that limits the knowledge to what server side send us * @param chunkX chunk coordinate X, i.e. blockX >> 4 * @param chunkZ chunk coordinate Z, i.e. blockZ >> 4 diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index d5ba06a7fa..6fc3f41d12 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -7,14 +7,35 @@ import static gregtech.api.enums.FluidState.MOLTEN; import static gregtech.api.enums.FluidState.PLASMA; import static gregtech.api.enums.GT_Values.W; import static gregtech.api.enums.GT_Values.debugEntityCramming; -import static gregtech.api.enums.Mods.*; +import static gregtech.api.enums.Mods.AdvancedSolarPanel; +import static gregtech.api.enums.Mods.AppliedEnergistics2; +import static gregtech.api.enums.Mods.Avaritia; +import static gregtech.api.enums.Mods.BetterLoadingScreen; +import static gregtech.api.enums.Mods.DraconicEvolution; +import static gregtech.api.enums.Mods.ElectroMagicTools; +import static gregtech.api.enums.Mods.EnderIO; +import static gregtech.api.enums.Mods.Forestry; +import static gregtech.api.enums.Mods.GTPlusPlus; +import static gregtech.api.enums.Mods.GalacticraftCore; +import static gregtech.api.enums.Mods.GalaxySpace; +import static gregtech.api.enums.Mods.GanysSurface; +import static gregtech.api.enums.Mods.GraviSuite; +import static gregtech.api.enums.Mods.GregTech; +import static gregtech.api.enums.Mods.IguanaTweaksTinkerConstruct; +import static gregtech.api.enums.Mods.MagicalCrops; +import static gregtech.api.enums.Mods.Names; +import static gregtech.api.enums.Mods.Railcraft; +import static gregtech.api.enums.Mods.TaintedMagic; +import static gregtech.api.enums.Mods.Thaumcraft; +import static gregtech.api.enums.Mods.ThaumicTinkerer; +import static gregtech.api.enums.Mods.TwilightForest; +import static gregtech.api.enums.Mods.WitchingGadgets; import static gregtech.api.util.GT_Recipe.GT_Recipe_Map.sWiremillRecipes; import static gregtech.api.util.GT_RecipeBuilder.SECONDS; import static gregtech.api.util.GT_RecipeConstants.UniversalChemical; import static gregtech.api.util.GT_Util.LAST_BROKEN_TILEENTITY; import java.io.File; -import java.lang.reflect.InvocationTargetException; import java.text.DateFormat; import java.util.ArrayList; import java.util.Arrays; @@ -122,7 +143,6 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Item; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.objects.GT_ChunkManager; -import gregtech.api.objects.GT_FluidStack; import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.GT_UO_DimensionList; import gregtech.api.objects.ItemData; @@ -1323,8 +1343,6 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler, IG public void onServerStarted() { GregTech_API.sWirelessRedstone.clear(); - GT_FluidStack.fixAllThoseFuckingFluidIDs(); - GT_Log.out.println( "GT_Mod: Cleaning up all OreDict Crafting Recipes, which have an empty List in them, since they are never meeting any Condition."); List tList = CraftingManager.getInstance() @@ -1530,7 +1548,6 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler, IG ForgeEventFactory.onPlayerDestroyItem(aEvent.entityPlayer, aStack); } } - return; } } @@ -2910,7 +2927,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler, IG GT_Values.cls_enabled = true; try { GT_CLS_Compat.stepMaterialsCLS(mEvents, progressBar); - } catch (IllegalAccessException | InvocationTargetException e) { + } catch (IllegalAccessException e) { GT_FML_LOGGER.catching(e); } } else GT_Proxy.stepMaterialsVanilla(this.mEvents, progressBar); @@ -3028,9 +3045,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler, IG @SubscribeEvent public void onItemTooltip(ItemTooltipEvent event) { - if (event.itemStack == null) { - return; - } else { + if (event.itemStack != null) { ItemStack aStackTemp = event.itemStack; GT_ItemStack aStack = new GT_ItemStack(aStackTemp); if (providesProtection(aStackTemp)) { diff --git a/src/main/java/gregtech/common/GT_RecipeAdder.java b/src/main/java/gregtech/common/GT_RecipeAdder.java index b518b94923..f4510f9ea0 100644 --- a/src/main/java/gregtech/common/GT_RecipeAdder.java +++ b/src/main/java/gregtech/common/GT_RecipeAdder.java @@ -27,8 +27,13 @@ import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.internal.IGT_RecipeAdder; import gregtech.api.objects.GT_FluidStack; import gregtech.api.objects.ItemData; -import gregtech.api.util.*; +import gregtech.api.util.GT_AssemblyLineUtils; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_AssemblyLine; +import gregtech.api.util.GT_RecipeBuilder; +import gregtech.api.util.GT_Utility; import gregtech.common.items.GT_IntegratedCircuit_Item; import ic2.core.init.MainConfig; import ic2.core.util.ConfigUtil; @@ -1307,6 +1312,7 @@ public class GT_RecipeAdder implements IGT_RecipeAdder { int tExplosives = Math.min(aInput2, 64); int tGunpowder = tExplosives << 1; // Worst int tDynamite = Math.max(1, tExplosives >> 1); // good + @SuppressWarnings("UnnecessaryLocalVariable") int tTNT = tExplosives; // Slightly better int tITNT = Math.max(1, tExplosives >> 2); // the best // new GT_Recipe(aInput1, aInput2, aOutput1, aOutput2); diff --git a/src/main/java/gregtech/common/GT_ThaumcraftCompat.java b/src/main/java/gregtech/common/GT_ThaumcraftCompat.java index c5275ef3a1..6804beb402 100644 --- a/src/main/java/gregtech/common/GT_ThaumcraftCompat.java +++ b/src/main/java/gregtech/common/GT_ThaumcraftCompat.java @@ -120,7 +120,7 @@ public class GT_ThaumcraftCompat implements IThaumcraftCompat { GT_LanguageManager.addStringLocalization("tc.aspect.radio", "Radiation"); } - private static final AspectList getAspectList(List aAspects) { + private static AspectList getAspectList(List aAspects) { AspectList rAspects = new AspectList(); TC_Aspects.TC_AspectStack tAspect; for (Iterator i$ = aAspects.iterator(); i$.hasNext(); rAspects diff --git a/src/main/java/gregtech/common/GT_UndergroundOil.java b/src/main/java/gregtech/common/GT_UndergroundOil.java index f522ff5895..17a5662c09 100644 --- a/src/main/java/gregtech/common/GT_UndergroundOil.java +++ b/src/main/java/gregtech/common/GT_UndergroundOil.java @@ -37,7 +37,7 @@ public class GT_UndergroundOil { /** * Effectively just call {@code undergroundOil(te, -1)} for you - * + * * @see #undergroundOil(World, int, int, float) */ public static FluidStack undergroundOilReadInformation(IGregTechTileEntity te) { @@ -49,7 +49,7 @@ public class GT_UndergroundOil { /** * Effectively just call {@code undergroundOil(chunk, -1)} for you - * + * * @see #undergroundOil(World, int, int, float) */ public static FluidStack undergroundOilReadInformation(Chunk chunk) { @@ -73,7 +73,7 @@ public class GT_UndergroundOil { /** * Pump fluid or read info. - * + * * @param w a remote World. For a WorldClient it will always tell you null * @param chunkX chunk coordinate X, i.e. blockX >> 4 * @param chunkZ chunk coordinate Z, i.e. blockZ >> 4 @@ -121,7 +121,7 @@ public class GT_UndergroundOil { /** * Get the deposit as if it is never exploited - * + * * @return UO fluid kind and amount, or null if nothing here. */ public static Pair getPristineAmount(World world, int chunkX, int chunkZ) { diff --git a/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_Layer.java b/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_Layer.java index 3b64655f05..5528b4ac63 100644 --- a/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_Layer.java +++ b/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_Layer.java @@ -57,9 +57,6 @@ public class GT_Worldgen_GT_Ore_Layer extends GT_Worldgen { this.mNether = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Nether", aNether); this.mEnd = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "TheEnd", aEnd); this.mEndAsteroid = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "EndAsteroid", aEnd); - // this.mMoon = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Moon", aMoon); - // this.mMars = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Mars", aMars); - // this.mAsteroid = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Asteroid", aAsteroid); this.mMinY = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MinHeight", aMinY)); short mMaxY = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MaxHeight", aMaxY)); if (mMaxY < (this.mMinY + 9)) { @@ -152,26 +149,18 @@ public class GT_Worldgen_GT_Ore_Layer extends GT_Worldgen { int aChunkZ, int aSeedX, int aSeedZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { if (mWorldGenName.equals("NoOresInVein")) { if (debugOrevein) GT_Log.out.println(" NoOresInVein"); - // This is a special empty orevein + // Return a special empty orevein return ORE_PLACED; } if (!isGenerationAllowed( aWorld, aDimensionType, ((aDimensionType == -1) && (this.mNether)) || ((aDimensionType == 0) && (this.mOverworld)) - || ((aDimensionType == 1) && (this.mEnd)) ? aDimensionType : aDimensionType ^ 0xFFFFFFFF)) { - /* - * // Debug code, but spams log if (debugOrevein) { GT_Log.out.println( "Wrong dimension" ); } - */ + || ((aDimensionType == 1) && (this.mEnd)) ? aDimensionType : ~aDimensionType)) { + // The following code can be used for debugging, but it spams in logs + // if (debugOrevein) { GT_Log.out.println( "Wrong dimension" ); } return WRONG_DIMENSION; } - /* - * if (!((aWorld.provider.getDimensionName().equalsIgnoreCase("Overworld")) || - * (aWorld.provider.getDimensionName().equalsIgnoreCase("Nether"))||(aWorld.provider.getDimensionName(). - * equalsIgnoreCase("Underdark"))||(aWorld.provider.getDimensionName().equalsIgnoreCase("Twilight Forest"))||( - * aWorld.provider.getDimensionName().equalsIgnoreCase("Underdark"))||(aWorld.provider.getDimensionName(). - * equalsIgnoreCase("The End")))) return WRONG_DIMENSION; - */ if (!this.mRestrictBiome.equals("None") && !(this.mRestrictBiome.equals(aBiome))) { return WRONG_BIOME; diff --git a/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_SmallPieces.java b/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_SmallPieces.java index 5a461dab9c..c8219e8361 100644 --- a/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_SmallPieces.java +++ b/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_SmallPieces.java @@ -76,7 +76,7 @@ public class GT_Worldgen_GT_Ore_SmallPieces extends GT_Worldgen { aWorld, aDimensionType, ((aDimensionType == -1) && (this.mNether)) || ((aDimensionType == 0) && (this.mOverworld)) - || ((aDimensionType == 1) && (this.mEnd)) ? aDimensionType : aDimensionType ^ 0xFFFFFFFF)) { + || ((aDimensionType == 1) && (this.mEnd)) ? aDimensionType : ~aDimensionType)) { return false; } int count = 0; diff --git a/src/main/java/gregtech/common/GT_Worldgen_Stone.java b/src/main/java/gregtech/common/GT_Worldgen_Stone.java index 17e47cb138..835f9d5c67 100644 --- a/src/main/java/gregtech/common/GT_Worldgen_Stone.java +++ b/src/main/java/gregtech/common/GT_Worldgen_Stone.java @@ -257,9 +257,7 @@ public class GT_Worldgen_Stone extends GT_Worldgen_Ore { double zCalc = ((double) (iZ - tZ) * zSize); zCalc = zCalc * zCalc; leftHandSize = zCalc + xCalc + yCalc; - if (leftHandSize > rightHandSide) { - continue; - } else { + if (leftHandSize <= rightHandSide) { // Yay! We can actually place a block now. (this part copied from original code) Block tTargetedBlock = aWorld.getBlock(iX, iY, iZ); if (tTargetedBlock instanceof GT_Block_Ores_Abstract) { diff --git a/src/main/java/gregtech/common/GT_Worldgenerator.java b/src/main/java/gregtech/common/GT_Worldgenerator.java index be0eb4e9ea..c731042390 100644 --- a/src/main/java/gregtech/common/GT_Worldgenerator.java +++ b/src/main/java/gregtech/common/GT_Worldgenerator.java @@ -492,9 +492,7 @@ public class GT_Worldgenerator implements IWorldGenerator { tRandomWeight -= tWorldGen.mWeight; if (tRandomWeight <= 0) { try { - // if ((tWorldGen.mEndAsteroid && tDimensionType == 1) || (tWorldGen.mAsteroid && - // tDimensionType == -30)) { - if (tWorldGen.mEndAsteroid && tDimensionType == 1) { + if (tWorldGen.mEndAsteroid) { primaryMeta = tWorldGen.mPrimaryMeta; secondaryMeta = tWorldGen.mSecondaryMeta; betweenMeta = tWorldGen.mBetweenMeta; @@ -513,11 +511,7 @@ public class GT_Worldgenerator implements IWorldGenerator { int tX = mX * 16 + aRandom.nextInt(16); int tY = 50 + aRandom.nextInt(200 - 50); int tZ = mZ * 16 + aRandom.nextInt(16); - if (tDimensionType == 1) { - mSize = aRandom.nextInt(endMaxSize - endMinSize); - // } else if (tDimensionName.equals("Asteroids")) { - // mSize = aRandom.nextInt((int) (gcMaxSize - gcMinSize)); - } + mSize = aRandom.nextInt(endMaxSize - endMinSize); if ((mWorld.getBlock(tX, tY, tZ) .isAir(mWorld, tX, tY, tZ))) { float randomRadian = aRandom.nextFloat() * (float) Math.PI; diff --git a/src/main/java/gregtech/common/bees/GT_AlleleBeeSpecies.java b/src/main/java/gregtech/common/bees/GT_AlleleBeeSpecies.java index d4aa78ecf3..b264737677 100644 --- a/src/main/java/gregtech/common/bees/GT_AlleleBeeSpecies.java +++ b/src/main/java/gregtech/common/bees/GT_AlleleBeeSpecies.java @@ -1,6 +1,6 @@ package gregtech.common.bees; -import java.awt.*; +import java.awt.Color; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; diff --git a/src/main/java/gregtech/common/bees/GT_AlleleHelper.java b/src/main/java/gregtech/common/bees/GT_AlleleHelper.java index 4609f11aa0..496aff29ca 100644 --- a/src/main/java/gregtech/common/bees/GT_AlleleHelper.java +++ b/src/main/java/gregtech/common/bees/GT_AlleleHelper.java @@ -9,11 +9,22 @@ import org.apache.commons.lang3.reflect.FieldUtils; import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.arboriculture.EnumTreeChromosome; -import forestry.api.genetics.*; +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.EnumTolerance; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IAlleleBoolean; +import forestry.api.genetics.IAlleleInteger; +import forestry.api.genetics.IAlleleTolerance; +import forestry.api.genetics.IChromosomeType; import forestry.api.lepidopterology.EnumButterflyChromosome; import forestry.apiculture.flowers.FlowerProvider; import forestry.core.config.Constants; -import forestry.core.genetics.alleles.*; +import forestry.core.genetics.alleles.AlleleBoolean; +import forestry.core.genetics.alleles.AlleleHelper; +import forestry.core.genetics.alleles.AlleleInteger; +import forestry.core.genetics.alleles.AlleleTolerance; +import forestry.core.genetics.alleles.EnumAllele; +import forestry.core.genetics.alleles.IAlleleValue; import forestry.core.utils.vect.IVect; import forestry.plugins.PluginManager; import gregtech.GT_Mod; @@ -151,10 +162,10 @@ public class GT_AlleleHelper extends AlleleHelper { return; } - // uncomment this once all addon mods are using the allele registration with IChromosomeType + // TODO: uncomment this once all addon mods are using the allele registration with IChromosomeType // Collection validTypes = AlleleManager.alleleRegistry.getChromosomeTypes(allele); // if (validTypes.size() > 0 && !validTypes.contains(chromosomeType)) { - // throw new IllegalArgumentException("Allele can't applied to this Chromosome type. Expected: " + validTypes + // throw new IllegalArgumentException("Allele can't be applied to this Chromosome type. Expected: " + validTypes // + " Got: " + chromosomeType); // } @@ -162,8 +173,7 @@ public class GT_AlleleHelper extends AlleleHelper { } @Override - public & IChromosomeType> void set(IAllele[] alleles, T chromosomeType, - @SuppressWarnings("rawtypes") IAlleleValue value) { + public & IChromosomeType> void set(IAllele[] alleles, T chromosomeType, IAlleleValue value) { set(alleles, chromosomeType, get(value)); } diff --git a/src/main/java/gregtech/common/bees/GT_Bee_Mutation.java b/src/main/java/gregtech/common/bees/GT_Bee_Mutation.java index 17a764e2b9..e8b2d5b8c6 100644 --- a/src/main/java/gregtech/common/bees/GT_Bee_Mutation.java +++ b/src/main/java/gregtech/common/bees/GT_Bee_Mutation.java @@ -8,7 +8,11 @@ import net.minecraft.world.World; import org.apache.commons.lang3.reflect.FieldUtils; -import forestry.api.apiculture.*; +import forestry.api.apiculture.BeeManager; +import forestry.api.apiculture.IAlleleBeeSpecies; +import forestry.api.apiculture.IBeeGenome; +import forestry.api.apiculture.IBeeHousing; +import forestry.api.apiculture.IBeeModifier; import forestry.api.core.IClimateProvider; import forestry.api.genetics.IAllele; import forestry.api.genetics.IGenome; diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java index 7610bfa769..897011eba9 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java @@ -8,6 +8,10 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; import gregtech.api.util.GT_LanguageManager; +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ public class GT_Block_Casings1 extends GT_Block_Casings_Abstract { /** diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java index c93d613936..f1fbc30236 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java @@ -14,6 +14,10 @@ import gregtech.api.enums.Textures; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_LanguageManager; +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ public class GT_Block_Casings2 extends GT_Block_Casings_Abstract { public GT_Block_Casings2() { diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings3.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings3.java index 3d81a8de18..ada77814c8 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings3.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings3.java @@ -7,6 +7,10 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; import gregtech.api.util.GT_LanguageManager; +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ public class GT_Block_Casings3 extends GT_Block_Casings_Abstract { public GT_Block_Casings3() { diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java index 023f97d5b1..49c9c6c992 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java @@ -15,11 +15,15 @@ import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_RenderingWorld; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeTurbine; +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { /** * This mapping is used to look up which texture should be used to render the connected texture for fusion casings. - * + *

* This mapping is computed from that giant if ladder from #getIcon in commit * da3421547afadc49938b5b6a7f9a9679afa1d570 The exact meaning of these numbers are like black magic. Read the * original getIcon implementation to understand why it is 0, 1, etc, if that if ladder is even intelligible. @@ -48,8 +52,6 @@ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { .addStringLocalization(getUnlocalizedName() + ".1.name", "Clean Stainless Steel Machine Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Stable Titanium Machine Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Titanium Firebox Casing"); - // GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Fusion Casing"); - // GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Fusion Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Fusion Machine Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Fusion Coil Block"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Fusion Machine Casing MK II"); @@ -163,6 +165,7 @@ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { || !mConnectedMachineTextures) { return getIcon(ordinalSide, tMeta); } + // noinspection ConstantValue // tMeta < 13 should stay because mConnectedMachineTextures can be changed if (tMeta > 8 && tMeta < 13) { int tInvertLeftRightMod = ordinalSide % 2 * 2 - 1; switch (ordinalSide / 2) { diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java index d5746b4360..3a9efdbe71 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java @@ -1,6 +1,20 @@ package gregtech.common.blocks; -import static gregtech.api.enums.HeatingCoilLevel.*; +import static gregtech.api.enums.HeatingCoilLevel.EV; +import static gregtech.api.enums.HeatingCoilLevel.HV; +import static gregtech.api.enums.HeatingCoilLevel.IV; +import static gregtech.api.enums.HeatingCoilLevel.LV; +import static gregtech.api.enums.HeatingCoilLevel.LuV; +import static gregtech.api.enums.HeatingCoilLevel.MAX; +import static gregtech.api.enums.HeatingCoilLevel.MV; +import static gregtech.api.enums.HeatingCoilLevel.None; +import static gregtech.api.enums.HeatingCoilLevel.UEV; +import static gregtech.api.enums.HeatingCoilLevel.UHV; +import static gregtech.api.enums.HeatingCoilLevel.UIV; +import static gregtech.api.enums.HeatingCoilLevel.UMV; +import static gregtech.api.enums.HeatingCoilLevel.UV; +import static gregtech.api.enums.HeatingCoilLevel.UXV; +import static gregtech.api.enums.HeatingCoilLevel.ZPM; import java.util.function.Consumer; @@ -15,6 +29,10 @@ import gregtech.api.enums.Textures; import gregtech.api.interfaces.IHeatingCoil; import gregtech.api.util.GT_LanguageManager; +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ public class GT_Block_Casings5 extends GT_Block_Casings_Abstract implements IHeatingCoil { public GT_Block_Casings5() { diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings6.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings6.java index d359a30df0..9bdbf256cc 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings6.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings6.java @@ -10,6 +10,10 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; import gregtech.api.util.GT_LanguageManager; +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ public class GT_Block_Casings6 extends GT_Block_Casings_Abstract { public GT_Block_Casings6() { diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java index a864132549..26830a3b83 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java @@ -14,6 +14,10 @@ import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_RenderingWorld; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeTurbine; +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ public class GT_Block_Casings8 extends GT_Block_Casings_Abstract { public static boolean mConnectedMachineTextures = true; @@ -98,6 +102,7 @@ public class GT_Block_Casings8 extends GT_Block_Casings_Abstract { @Deprecated public IIcon getTurbineCasing(int meta, int iconIndex, boolean active) { + // noinspection SwitchStatementWithTooFewBranches // "if" is harder to edit return switch (meta) { case 9 -> active ? Textures.BlockIcons.TURBINE_ADVGASACTIVE[iconIndex].getIcon() : Textures.BlockIcons.TURBINEADVGAS[iconIndex].getIcon(); @@ -107,6 +112,7 @@ public class GT_Block_Casings8 extends GT_Block_Casings_Abstract { } public IIcon getTurbineCasing(int meta, int iconIndex, boolean active, boolean hasTurbine) { + // noinspection SwitchStatementWithTooFewBranches // "if" is harder to edit return switch (meta) { case 9 -> active ? Textures.BlockIcons.TURBINE_ADVGASACTIVE[iconIndex].getIcon() : hasTurbine ? Textures.BlockIcons.TURBINEADVGAS[iconIndex].getIcon() @@ -134,74 +140,60 @@ public class GT_Block_Casings8 extends GT_Block_Casings_Abstract { public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int ordinalSide) { aWorld = GT_RenderingWorld.getInstance(aWorld); final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + if (tMeta != 9 || !mConnectedMachineTextures) { return getIcon(ordinalSide, tMeta); } - if (tMeta == 9) { - int tInvertLeftRightMod = ordinalSide % 2 * 2 - 1; - switch (ordinalSide / 2) { - case 0 -> { - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (i == 0 && j == 0) continue; - int tState; - if ((tState = isTurbineControllerWithSide( - aWorld, - xCoord + j, - yCoord, - zCoord + i, - ordinalSide)) != 0) { - return getTurbineCasing(tMeta, 4 - i * 3 - j, tState == 1, tState == 2); - } + + int tInvertLeftRightMod = ordinalSide % 2 * 2 - 1; + + switch (ordinalSide / 2) { + case 0 -> { + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) continue; + int tState; + if ((tState = isTurbineControllerWithSide(aWorld, xCoord + j, yCoord, zCoord + i, ordinalSide)) + != 0) { + return getTurbineCasing(tMeta, 4 - i * 3 - j, tState == 1, tState == 2); } } } - case 1 -> { - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (i == 0 && j == 0) continue; - int tState; - if ((tState = isTurbineControllerWithSide( - aWorld, - xCoord + j, - yCoord + i, - zCoord, - ordinalSide)) != 0) { - return getTurbineCasing( - tMeta, - 4 + i * 3 - j * tInvertLeftRightMod, - tState == 1, - tState == 2); - } + } + case 1 -> { + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) continue; + int tState; + if ((tState = isTurbineControllerWithSide(aWorld, xCoord + j, yCoord + i, zCoord, ordinalSide)) + != 0) { + return getTurbineCasing( + tMeta, + 4 + i * 3 - j * tInvertLeftRightMod, + tState == 1, + tState == 2); } } } - case 2 -> { - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (i == 0 && j == 0) continue; - int tState; - if ((tState = isTurbineControllerWithSide( - aWorld, - xCoord, - yCoord + i, - zCoord + j, - ordinalSide)) != 0) { - return getTurbineCasing( - tMeta, - 4 + i * 3 + j * tInvertLeftRightMod, - tState == 1, - tState == 2); - } + } + case 2 -> { + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) continue; + int tState; + if ((tState = isTurbineControllerWithSide(aWorld, xCoord, yCoord + i, zCoord + j, ordinalSide)) + != 0) { + return getTurbineCasing( + tMeta, + 4 + i * 3 + j * tInvertLeftRightMod, + tState == 1, + tState == 2); } } } } - return switch (tMeta) { - case 9 -> Textures.BlockIcons.MACHINE_CASING_ADVANCEDGAS.getIcon(); - default -> Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); - }; } + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); } } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings9.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings9.java index 3aa1756d0c..bc6aca6255 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings9.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings9.java @@ -9,6 +9,10 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; import gregtech.api.util.GT_LanguageManager; +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ public class GT_Block_Casings9 extends GT_Block_Casings_Abstract { public GT_Block_Casings9() { diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings_Abstract.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings_Abstract.java index cef97ecb95..59144666df 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings_Abstract.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings_Abstract.java @@ -24,6 +24,9 @@ import gregtech.api.items.GT_Generic_Block; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_LanguageManager; +/** + * The base class for casings. Casings are the blocks that are mainly used to build multiblocks. + */ public abstract class GT_Block_Casings_Abstract extends GT_Generic_Block implements gregtech.api.interfaces.IHasIndexedTexture { diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java b/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java index 1849994e02..a78fe5b70d 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java @@ -25,7 +25,11 @@ import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; -import gregtech.api.enums.*; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SoundResource; +import gregtech.api.enums.Textures; import gregtech.api.items.GT_Generic_Block; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_LanguageManager; @@ -174,18 +178,12 @@ public class GT_Block_Reinforced extends GT_Generic_Block { case 3 -> { return Textures.BlockIcons.BLOCK_TSREIN.getIcon(); } - case 4 -> { + case 4, 6, 7 -> { return Blocks.coal_block.getIcon(0, 0); } case 5 -> { return Textures.BlockIcons.COVER_WOOD_PLATE.getIcon(); } - case 6 -> { - return Blocks.coal_block.getIcon(0, 0); - } - case 7 -> { - return Blocks.coal_block.getIcon(0, 0); - } case 8 -> { return Textures.BlockIcons.BLOCK_STEELPREIN.getIcon(); } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Stones_Abstract.java b/src/main/java/gregtech/common/blocks/GT_Block_Stones_Abstract.java index 0cfa6477fd..0852e67ecf 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Stones_Abstract.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Stones_Abstract.java @@ -24,7 +24,10 @@ import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; -import gregtech.api.enums.*; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OreDictNames; +import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.IOreRecipeRegistrator; import gregtech.api.items.GT_Generic_Block; import gregtech.api.util.GT_ModHandler; diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings1.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings1.java index cd2f818b37..1a86a2e534 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings1.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings1.java @@ -2,6 +2,10 @@ package gregtech.common.blocks; import net.minecraft.block.Block; +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ public class GT_Item_Casings1 extends GT_Item_Casings_Abstract { public GT_Item_Casings1(Block block) { diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings2.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings2.java index ec30251560..f98c169c7f 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings2.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings2.java @@ -6,6 +6,10 @@ import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ public class GT_Item_Casings2 extends GT_Item_Casings_Abstract { public GT_Item_Casings2(Block block) { diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings3.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings3.java index fdcb5dbd86..861774d96f 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings3.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings3.java @@ -2,6 +2,10 @@ package gregtech.common.blocks; import net.minecraft.block.Block; +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ public class GT_Item_Casings3 extends GT_Item_Casings_Abstract { public GT_Item_Casings3(Block block) { diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings4.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings4.java index 5665150407..e2badca2cb 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings4.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings4.java @@ -2,6 +2,10 @@ package gregtech.common.blocks; import net.minecraft.block.Block; +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ public class GT_Item_Casings4 extends GT_Item_Casings_Abstract { public GT_Item_Casings4(Block block) { diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings5.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings5.java index ae40636eaf..3b3ab68cb1 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings5.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings5.java @@ -11,6 +11,10 @@ import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.HeatingCoilLevel; import gregtech.api.util.GT_LanguageManager; +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ public class GT_Item_Casings5 extends GT_Item_Casings_Abstract { public GT_Item_Casings5(Block block) { diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings6.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings6.java index f5250e73da..af533acfa8 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings6.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings6.java @@ -2,6 +2,10 @@ package gregtech.common.blocks; import net.minecraft.block.Block; +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ public class GT_Item_Casings6 extends GT_Item_Casings_Abstract { public GT_Item_Casings6(Block block) { diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings8.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings8.java index 3130006a50..e3f3bbdf97 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings8.java