From eb25cb901172dfa4d68f44de8f61d52958f53cfa Mon Sep 17 00:00:00 2001 From: Alexdoru <57050655+Alexdoru@users.noreply.github.com> Date: Thu, 5 Sep 2024 01:11:15 +0200 Subject: Delete/modify some reflection + more renaming (#3037) --- src/main/java/gregtech/api/GregTechAPI.java | 296 --------------------- .../java/gregtech/api/objects/GTChunkManager.java | 18 +- .../gregtech/api/objects/GTRenderedTexture.java | 2 +- .../api/threads/RunnableMachineUpdate.java | 6 +- .../gregtech/api/util/GTChunkAssociatedData.java | 2 +- src/main/java/gregtech/api/util/GTModHandler.java | 65 ++--- 6 files changed, 31 insertions(+), 358 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/GregTechAPI.java b/src/main/java/gregtech/api/GregTechAPI.java index 6cabb8e04c..e10c773579 100644 --- a/src/main/java/gregtech/api/GregTechAPI.java +++ b/src/main/java/gregtech/api/GregTechAPI.java @@ -26,7 +26,6 @@ import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -47,10 +46,6 @@ import gregtech.api.interfaces.internal.IGTRecipeAdder; import gregtech.api.interfaces.internal.IThaumcraftCompat; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IMachineBlockUpdateable; -import gregtech.api.items.GTGenericItem; -import gregtech.api.items.ItemCoolantCell; -import gregtech.api.items.ItemCoolantCellIC; -import gregtech.api.items.ItemTool; import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.objects.GTCoverDefault; import gregtech.api.objects.GTCoverNone; @@ -287,20 +282,7 @@ public class GregTechAPI { static { sItemStackMappings.add(sCovers); sItemStackMappings.add(sCoverBehaviors); - dummyWorlds.add(GTDummyWorld.class); - tryAddDummyWorld("blockrenderer6343.client.world.DummyWorld"); - } - - private static void tryAddDummyWorld(String className) { - ClassLoader cl = GregTechAPI.class.getClassLoader(); - Class clazz; - try { - clazz = Class.forName(className, false, cl); - } catch (ReflectiveOperationException ex) { - return; - } - dummyWorlds.add(clazz); } public static void addDummyWorld(Class clazz) { @@ -407,284 +389,6 @@ public class GregTechAPI { return false; } - /** - * Creates a new Coolant Cell Item for your Nuclear Reactor - */ - public static Item constructCoolantCellItem(String aUnlocalized, String aEnglish, int aMaxStore) { - try { - return new ItemCoolantCellIC(aUnlocalized, aEnglish, aMaxStore); - } catch (Throwable e) { - /* Do nothing */ - } - try { - return new ItemCoolantCell(aUnlocalized, aEnglish, aMaxStore); - } catch (Throwable e) { - /* Do nothing */ - } - return new GTGenericItem(aUnlocalized, aEnglish, "Doesn't work as intended, this is a Bug"); - } - - /** - * Creates a new Energy Armor Item - */ - public static Item constructElectricArmorItem(String aUnlocalized, String aEnglish, int aCharge, int aTransfer, - int aTier, int aDamageEnergyCost, int aSpecials, double aArmorAbsorbtionPercentage, boolean aChargeProvider, - int aType, int aArmorIndex) { - try { - return (Item) Class.forName("gregtechmod.api.items.GT_EnergyArmorIC_Item") - .getConstructors()[0].newInstance( - aUnlocalized, - aEnglish, - aCharge, - aTransfer, - aTier, - aDamageEnergyCost, - aSpecials, - aArmorAbsorbtionPercentage, - aChargeProvider, - aType, - aArmorIndex); - } catch (Throwable e) { - /* Do nothing */ - } - try { - return (Item) Class.forName("gregtechmod.api.items.GT_EnergyArmor_Item") - .getConstructors()[0].newInstance( - aUnlocalized, - aEnglish, - aCharge, - aTransfer, - aTier, - aDamageEnergyCost, - aSpecials, - aArmorAbsorbtionPercentage, - aChargeProvider, - aType, - aArmorIndex); - } catch (Throwable e) { - /* Do nothing */ - } - return new GTGenericItem(aUnlocalized, aEnglish, "Doesn't work as intended, this is a Bug"); - } - - /** - * Creates a new Energy Battery Item - */ - public static Item constructElectricEnergyStorageItem(String aUnlocalized, String aEnglish, int aCharge, - int aTransfer, int aTier, int aEmptyID, int aFullID) { - try { - return (Item) Class.forName("gregtechmod.api.items.GT_EnergyStoreIC_Item") - .getConstructors()[0].newInstance(aUnlocalized, aEnglish, aCharge, aTransfer, aTier, aEmptyID, aFullID); - } catch (Throwable e) { - /* Do nothing */ - } - try { - return (Item) Class.forName("gregtechmod.api.items.GT_EnergyStore_Item") - .getConstructors()[0].newInstance(aUnlocalized, aEnglish, aCharge, aTransfer, aTier, aEmptyID, aFullID); - } catch (Throwable e) { - /* Do nothing */ - } - return new GTGenericItem(aUnlocalized, aEnglish, "Doesn't work as intended, this is a Bug"); - } - - /** - * Creates a new Hard Hammer Item - */ - public static ItemTool constructHardHammerItem(String aUnlocalized, String aEnglish, int aMaxDamage, - int aEntityDamage) { - try { - return (ItemTool) Class.forName("gregtechmod.api.items.GT_HardHammer_Item") - .getConstructors()[0].newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage); - } catch (Throwable e) { - /* Do nothing */ - } - return new ItemTool( - aUnlocalized, - aEnglish, - "Doesn't work as intended, this is a Bug", - aMaxDamage, - aEntityDamage, - false); - } - - /** - * Creates a new Crowbar Item - */ - public static ItemTool constructCrowbarItem(String aUnlocalized, String aEnglish, int aMaxDamage, - int aEntityDamage) { - try { - return (ItemTool) Class.forName("gregtechmod.api.items.GT_CrowbarRC_Item") - .getConstructors()[0].newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage); - } catch (Throwable e) { - /* Do nothing */ - } - try { - return (ItemTool) Class.forName("gregtechmod.api.items.GT_Crowbar_Item") - .getConstructors()[0].newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage); - } catch (Throwable e) { - /* Do nothing */ - } - return new ItemTool( - aUnlocalized, - aEnglish, - "Doesn't work as intended, this is a Bug", - aMaxDamage, - aEntityDamage, - false); - } - - /** - * Creates a new Wrench Item - */ - public static ItemTool constructWrenchItem(String aUnlocalized, String aEnglish, int aMaxDamage, int aEntityDamage, - int aDisChargedGTID) { - try { - return (ItemTool) Class.forName("gregtechmod.api.items.GT_Wrench_Item") - .getConstructors()[0].newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage, aDisChargedGTID); - } catch (Throwable e) { - /* Do nothing */ - } - return new ItemTool( - aUnlocalized, - aEnglish, - "Doesn't work as intended, this is a Bug", - aMaxDamage, - aEntityDamage, - false); - } - - /** - * Creates a new electric Screwdriver Item - */ - public static ItemTool constructElectricScrewdriverItem(String aUnlocalized, String aEnglish, int aMaxDamage, - int aEntityDamage, int aDisChargedGTID) { - try { - return (ItemTool) Class.forName("gregtechmod.api.items.GT_ScrewdriverIC_Item") - .getConstructors()[0].newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage, aDisChargedGTID); - } catch (Throwable e) { - /* Do nothing */ - } - return new ItemTool( - aUnlocalized, - aEnglish, - "Doesn't work as intended, this is a Bug", - aMaxDamage, - aEntityDamage, - false); - } - - /** - * Creates a new electric Wrench Item - */ - public static ItemTool constructElectricWrenchItem(String aUnlocalized, String aEnglish, int aMaxDamage, - int aEntityDamage, int aDisChargedGTID) { - try { - return (ItemTool) Class.forName("gregtechmod.api.items.GT_WrenchIC_Item") - .getConstructors()[0].newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage, aDisChargedGTID); - } catch (Throwable e) { - /* Do nothing */ - } - return new ItemTool( - aUnlocalized, - aEnglish, - "Doesn't work as intended, this is a Bug", - aMaxDamage, - aEntityDamage, - false); - } - - /** - * Creates a new electric Saw Item - */ - public static ItemTool constructElectricSawItem(String aUnlocalized, String aEnglish, int aMaxDamage, - int aEntityDamage, int aToolQuality, float aToolStrength, int aEnergyConsumptionPerBlockBreak, - int aDisChargedGTID) { - try { - return (ItemTool) Class.forName("gregtechmod.api.items.GT_SawIC_Item") - .getConstructors()[0].newInstance( - aUnlocalized, - aEnglish, - aMaxDamage, - aEntityDamage, - aToolQuality, - aToolStrength, - aEnergyConsumptionPerBlockBreak, - aDisChargedGTID); - } catch (Throwable e) { - /* Do nothing */ - } - return new ItemTool( - aUnlocalized, - aEnglish, - "Doesn't work as intended, this is a Bug", - aMaxDamage, - aEntityDamage, - false); - } - - /** - * Creates a new electric Drill Item - */ - public static ItemTool constructElectricDrillItem(String aUnlocalized, String aEnglish, int aMaxDamage, - int aEntityDamage, int aToolQuality, float aToolStrength, int aEnergyConsumptionPerBlockBreak, - int aDisChargedGTID) { - try { - return (ItemTool) Class.forName("gregtechmod.api.items.GT_DrillIC_Item") - .getConstructors()[0].newInstance( - aUnlocalized, - aEnglish, - aMaxDamage, - aEntityDamage, - aToolQuality, - aToolStrength, - aEnergyConsumptionPerBlockBreak, - aDisChargedGTID); - } catch (Throwable e) { - /* Do nothing */ - } - return new ItemTool( - aUnlocalized, - aEnglish, - "Doesn't work as intended, this is a Bug", - aMaxDamage, - aEntityDamage, - false); - } - - /** - * Creates a new electric Soldering Tool - */ - public static ItemTool constructElectricSolderingToolItem(String aUnlocalized, String aEnglish, int aMaxDamage, - int aEntityDamage, int aDisChargedGTID) { - try { - return (ItemTool) Class.forName("gregtechmod.api.items.GT_SolderingToolIC_Item") - .getConstructors()[0].newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage, aDisChargedGTID); - } catch (Throwable e) { - /* Do nothing */ - } - return new ItemTool( - aUnlocalized, - aEnglish, - "Doesn't work as intended, this is a Bug", - aMaxDamage, - aEntityDamage, - false); - } - - /** - * Creates a new empty electric Tool - */ - public static ItemTool constructEmptyElectricToolItem(String aUnlocalized, String aEnglish, int aMaxDamage, - int aChargedGTID) { - try { - return (ItemTool) Class.forName("gregtechmod.api.items.GT_EmptyToolIC_Item") - .getConstructors()[0].newInstance(aUnlocalized, aEnglish, aMaxDamage, aChargedGTID); - } catch (Throwable e) { - /* Do nothing */ - } - return new ItemTool(aUnlocalized, aEnglish, "Doesn't work as intended, this is a Bug", aMaxDamage, 0, false); - } - /** * Provides a new BaseMetaTileEntity. Because some interfaces are not always loaded (Buildcraft, Universal * Electricity) we have to use invocation at the constructor of the BaseMetaTileEntity. diff --git a/src/main/java/gregtech/api/objects/GTChunkManager.java b/src/main/java/gregtech/api/objects/GTChunkManager.java index 59bc90aa1c..436fd0d7d8 100644 --- a/src/main/java/gregtech/api/objects/GTChunkManager.java +++ b/src/main/java/gregtech/api/objects/GTChunkManager.java @@ -111,7 +111,7 @@ public class GTChunkManager if (!GTValues.enableChunkloaders) return false; if (!GTValues.alwaysReloadChunkloaders && chunkXZ == null) return false; if (GTValues.debugChunkloaders && chunkXZ != null) - GTLog.out.println("GT_ChunkManager: Chunk request: (" + chunkXZ.chunkXPos + ", " + chunkXZ.chunkZPos + ")"); + GTLog.out.println("GTChunkManager: Chunk request: (" + chunkXZ.chunkXPos + ", " + chunkXZ.chunkZPos + ")"); if (instance.registeredTickets.containsKey(owner)) { ForgeChunkManager.forceChunk(instance.registeredTickets.get(owner), chunkXZ); } else { @@ -122,11 +122,11 @@ public class GTChunkManager .requestPlayerTicket(GTMod.instance, player, owner.getWorldObj(), ForgeChunkManager.Type.NORMAL); if (ticket == null) { if (GTValues.debugChunkloaders) - GTLog.out.println("GT_ChunkManager: ForgeChunkManager.requestTicket failed"); + GTLog.out.println("GTChunkManager: ForgeChunkManager.requestTicket failed"); return false; } if (GTValues.debugChunkloaders) GTLog.out.println( - "GT_ChunkManager: ticket issued for machine at: (" + owner.xCoord + "GTChunkManager: ticket issued for machine at: (" + owner.xCoord + ", " + owner.yCoord + ", " @@ -154,7 +154,7 @@ public class GTChunkManager Ticket ticket = instance.registeredTickets.get(owner); if (ticket != null) { if (GTValues.debugChunkloaders) GTLog.out - .println("GT_ChunkManager: Chunk release: (" + chunkXZ.chunkXPos + ", " + chunkXZ.chunkZPos + ")"); + .println("GTChunkManager: Chunk release: (" + chunkXZ.chunkXPos + ", " + chunkXZ.chunkZPos + ")"); ForgeChunkManager.unforceChunk(ticket, chunkXZ); } } @@ -165,14 +165,14 @@ public class GTChunkManager if (ticket != null) { if (GTValues.debugChunkloaders) { GTLog.out.println( - "GT_ChunkManager: ticket released by machine at: (" + owner.xCoord + "GTChunkManager: ticket released by machine at: (" + owner.xCoord + ", " + owner.yCoord + ", " + owner.zCoord + ")"); for (ChunkCoordIntPair chunk : ticket.getChunkList()) GTLog.out - .println("GT_ChunkManager: Chunk release: (" + chunk.chunkXPos + ", " + chunk.chunkZPos + ")"); + .println("GTChunkManager: Chunk release: (" + chunk.chunkXPos + ", " + chunk.chunkZPos + ")"); } ForgeChunkManager.releaseTicket(ticket); instance.registeredTickets.remove(owner); @@ -180,10 +180,10 @@ public class GTChunkManager } public static void printTickets() { - GTLog.out.println("GT_ChunkManager: Start forced chunks dump:"); + GTLog.out.println("GTChunkManager: Start forced chunks dump:"); instance.registeredTickets.forEach((machine, ticket) -> { GTLog.out.print( - "GT_ChunkManager: Chunks forced by the machine at (" + machine.xCoord + "GTChunkManager: Chunks forced by the machine at (" + machine.xCoord + ", " + machine.yCoord + ", " @@ -199,6 +199,6 @@ public class GTChunkManager GTLog.out.print("), "); } }); - GTLog.out.println("GT_ChunkManager: End forced chunks dump:"); + GTLog.out.println("GTChunkManager: End forced chunks dump:"); } } diff --git a/src/main/java/gregtech/api/objects/GTRenderedTexture.java b/src/main/java/gregtech/api/objects/GTRenderedTexture.java index a4d0a064ff..abb2e28051 100644 --- a/src/main/java/gregtech/api/objects/GTRenderedTexture.java +++ b/src/main/java/gregtech/api/objects/GTRenderedTexture.java @@ -14,7 +14,7 @@ public class GTRenderedTexture extends gregtech.common.render.GTRenderedTexture public GTRenderedTexture(IIconContainer aIcon, short[] aRGBa, boolean aAllowAlpha) { super(aIcon, aRGBa, aAllowAlpha, false, true, false); - if (aRGBa.length != 4) throw new IllegalArgumentException("RGBa doesn't have 4 Values @ GT_RenderedTexture"); + if (aRGBa.length != 4) throw new IllegalArgumentException("RGBa doesn't have 4 Values @ GTRenderedTexture"); mRGBa = aRGBa; } diff --git a/src/main/java/gregtech/api/threads/RunnableMachineUpdate.java b/src/main/java/gregtech/api/threads/RunnableMachineUpdate.java index d11e176f3d..7b0af48085 100644 --- a/src/main/java/gregtech/api/threads/RunnableMachineUpdate.java +++ b/src/main/java/gregtech/api/threads/RunnableMachineUpdate.java @@ -98,8 +98,8 @@ public class RunnableMachineUpdate implements Runnable { EXECUTOR_SERVICE.shutdownNow(); // Cancel currently executing tasks // Wait a while for tasks to respond to being cancelled if (!EXECUTOR_SERVICE.awaitTermination(60, TimeUnit.SECONDS)) { - GTMod.GT_FML_LOGGER.error( - "Well this didn't terminated well... GT_Runnable_MachineBlockUpdate.shutdownExecutorService"); + GTMod.GT_FML_LOGGER + .error("Well this didn't terminated well... RunnableMachineUpdate.shutdownExecutorService"); } } } catch (InterruptedException ie) { @@ -114,7 +114,7 @@ public class RunnableMachineUpdate implements Runnable { // (Re-)Cancel in case EXECUTOR_SERVICE.shutdownNow(); } finally { - GTMod.GT_FML_LOGGER.info("Leaving... GT_Runnable_MachineBlockUpdate.shutdownExecutorService"); + GTMod.GT_FML_LOGGER.info("Leaving... RunnableMachineUpdate.shutdownExecutorService"); } } diff --git a/src/main/java/gregtech/api/util/GTChunkAssociatedData.java b/src/main/java/gregtech/api/util/GTChunkAssociatedData.java index 7a81c715cb..c87697b80d 100644 --- a/src/main/java/gregtech/api/util/GTChunkAssociatedData.java +++ b/src/main/java/gregtech/api/util/GTChunkAssociatedData.java @@ -114,7 +114,7 @@ public abstract class GTChunkAssociatedData getExtractorRecipeList() { - try { - return ic2.api.recipe.Recipes.extractor.getRecipes(); - } catch (Throwable e) { - /* Do nothing */ - } - return emptyRecipeMap; + return Recipes.extractor.getRecipes(); } public static Map getCompressorRecipeList() { - try { - return ic2.api.recipe.Recipes.compressor.getRecipes(); - } catch (Throwable e) { - /* Do nothing */ - } - return emptyRecipeMap; + return Recipes.compressor.getRecipes(); } public static Map getMaceratorRecipeList() { - try { - return ic2.api.recipe.Recipes.macerator.getRecipes(); - } catch (Throwable e) { - /* Do nothing */ - } - return emptyRecipeMap; + return Recipes.macerator.getRecipes(); } public static Map getThermalCentrifugeRecipeList() { - try { - return ic2.api.recipe.Recipes.centrifuge.getRecipes(); - } catch (Throwable e) { - /* Do nothing */ - } - return emptyRecipeMap; + return Recipes.centrifuge.getRecipes(); } public static Map getOreWashingRecipeList() { - try { - return ic2.api.recipe.Recipes.oreWashing.getRecipes(); - } catch (Throwable e) { - /* Do nothing */ - } - return emptyRecipeMap; + return Recipes.oreWashing.getRecipes(); } /** @@ -1997,13 +1966,13 @@ public class GTModHandler { private static void generateRecyclerCache() { recyclerWhitelist = new HashSet<>(); - for (IRecipeInput input : ic2.api.recipe.Recipes.recyclerWhitelist) { + for (IRecipeInput input : Recipes.recyclerWhitelist) { for (ItemStack stack : input.getInputs()) { recyclerWhitelist.add(GTUtility.ItemId.create(stack.getItem(), stack.getItemDamage(), null)); } } recyclerBlacklist = new HashSet<>(); - for (IRecipeInput input : ic2.api.recipe.Recipes.recyclerBlacklist) { + for (IRecipeInput input : Recipes.recyclerBlacklist) { for (ItemStack stack : input.getInputs()) { recyclerBlacklist.add(GTUtility.ItemId.create(stack.getItem(), stack.getItemDamage(), null)); } @@ -2022,7 +1991,7 @@ public class GTModHandler { * For the Scrapboxinator */ public static ItemStack getRandomScrapboxDrop() { - return ic2.api.recipe.Recipes.scrapboxDrops.getDrop(ItemList.IC2_Scrapbox.get(1), false); + return Recipes.scrapboxDrops.getDrop(ItemList.IC2_Scrapbox.get(1), false); } /** -- cgit