From 86f1765b171f4cc6f163b8027d1330f4e5094e2d Mon Sep 17 00:00:00 2001 From: Alexdoru <57050655+Alexdoru@users.noreply.github.com> Date: Sat, 28 Sep 2024 13:25:01 +0200 Subject: [PATCH] Remove more reflection + reorganize mixin accessors packages (#3260) Co-authored-by: Martin Robertz Co-authored-by: boubou19 --- .../common/commands/ClearCraftingCache.java | 2 +- .../CircuitImprintLoader.java | 2 +- .../gtenhancement/PlatinumSludgeOverHaul.java | 2 +- .../loader/NaquadahReworkRecipeLoader.java | 2 +- .../api/util/GTRecipeRegistrator.java | 17 +- .../gregtech/loaders/preload/GTPreLoad.java | 11 +- src/main/java/gregtech/mixin/Mixin.java | 17 +- .../BWCoreStaticReplacementMethodes.java | 2 +- .../{ => hooks}/MixinsVariablesHelper.java | 2 +- .../mixin/interfaces/IBlockStemAccesor.java | 8 - .../gregtech/mixin/interfaces/PotionExt.java | 7 - .../accessors/EntityPlayerMPAccessor.java | 7 + .../accessors/IBlockStemAccessor.java | 8 + .../accessors}/IRecipeMutableAccess.java | 2 +- .../interfaces/accessors/PotionAccessor.java | 7 + .../accessors/ShapedOreRecipeAccessor.java | 9 + src/main/java/gtPlusPlus/GTplusplus.java | 64 ++- .../gtPlusPlus/api/interfaces/IPlugin.java | 41 -- .../java/gtPlusPlus/api/objects/Logger.java | 5 +- .../api/objects/minecraft/ShapedRecipe.java | 15 +- .../core/config/ASMConfiguration.java | 11 - .../core/handler/PacketHandler.java | 11 - .../events/PlayerSleepEventHandler.java | 4 +- .../core/util/reflect/ReflectionUtils.java | 396 +----------------- .../gtPlusPlus/everglades/GTPPEverglades.java | 11 +- .../plugin/agrichem/AgrichemCore.java | 56 --- .../plugin/agrichem/block/AgrichemFluids.java | 2 +- .../agrichem/item/algae/ItemAgrichemBase.java | 2 +- .../agrichem/item/algae/ItemAlgaeBase.java | 8 +- .../agrichem/logic/AlgaeGeneticData.java | 15 +- .../logic/AlgaeGrowthRequirement.java | 4 - .../plugin/fixes/interfaces/IBugFix.java | 6 - .../vanilla/VanillaBackgroundMusicFix.java | 64 --- .../fixes/vanilla/VanillaBedHeightFix.java | 35 +- .../fixes/vanilla/VanillaFixesCore.java | 101 ----- .../fixes/vanilla/music/MusicTocker.java | 131 ------ .../plugin/manager/CoreManager.java | 95 ----- .../api/enums/GregtechOrePrefixes.java | 42 +- .../generators/MTERTGenerator.java | 25 +- .../hatch/MTEHatchBeamlineConnector.java | 11 +- .../java/gtnhlanth/loader/RecipeLoader.java | 2 +- .../multiblock/eigbuckets/EIGStemBucket.java | 4 +- .../tectech/thing/item/ItemEuMeterGT.java | 12 +- .../hatch/MTEHatchDataConnector.java | 11 +- .../hatch/MTEHatchDataItemsInput.java | 11 +- .../metaTileEntity/hatch/MTEHatchParam.java | 11 +- .../hatch/MTEHatchParamText.java | 11 +- .../metaTileEntity/hatch/MTEHatchRack.java | 11 +- .../hatch/MTEHatchUncertainty.java | 11 +- .../MTEHatchWirelessComputationInput.java | 11 - .../hatch/MTEHatchWirelessDataItemsInput.java | 11 +- .../multi/MTEResearchStation.java | 9 +- .../single/MTEOwnerDetector.java | 17 +- .../metaTileEntity/single/MTETeslaCoil.java | 10 +- src/main/java/tectech/util/TTUtility.java | 1 + .../early/minecraft/CraftingManagerMixin.java | 2 +- .../minecraft/LanguageRegistryMixin.java | 12 +- .../mixins/early/minecraft/LocaleMixin.java | 14 +- .../early/minecraft/StringTranslateMixin.java | 10 +- .../mixins/early/minecraft/WorldMixin.java | 3 +- .../{ => accessors}/BlockStemMixin.java | 8 +- .../accessors/EntityPlayerMPMixin.java | 21 + .../ForgeShapedRecipeMixin.java | 24 +- .../ForgeShapelessRecipeMixin.java | 4 +- .../{ => accessors}/PotionMixin.java | 6 +- .../VanillaShapedRecipeMixin.java | 4 +- .../VanillaShapelessRecipeMixin.java | 7 +- 67 files changed, 267 insertions(+), 1251 deletions(-) rename src/main/java/{bartworks => gregtech/mixin}/hooks/BWCoreStaticReplacementMethodes.java (99%) rename src/main/java/gregtech/mixin/{ => hooks}/MixinsVariablesHelper.java (76%) delete mode 100644 src/main/java/gregtech/mixin/interfaces/IBlockStemAccesor.java delete mode 100644 src/main/java/gregtech/mixin/interfaces/PotionExt.java create mode 100644 src/main/java/gregtech/mixin/interfaces/accessors/EntityPlayerMPAccessor.java create mode 100644 src/main/java/gregtech/mixin/interfaces/accessors/IBlockStemAccessor.java rename src/main/java/gregtech/{api/interfaces => mixin/interfaces/accessors}/IRecipeMutableAccess.java (92%) create mode 100644 src/main/java/gregtech/mixin/interfaces/accessors/PotionAccessor.java create mode 100644 src/main/java/gregtech/mixin/interfaces/accessors/ShapedOreRecipeAccessor.java delete mode 100644 src/main/java/gtPlusPlus/api/interfaces/IPlugin.java delete mode 100644 src/main/java/gtPlusPlus/plugin/agrichem/AgrichemCore.java delete mode 100644 src/main/java/gtPlusPlus/plugin/agrichem/logic/AlgaeGrowthRequirement.java delete mode 100644 src/main/java/gtPlusPlus/plugin/fixes/interfaces/IBugFix.java delete mode 100644 src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBackgroundMusicFix.java delete mode 100644 src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaFixesCore.java delete mode 100644 src/main/java/gtPlusPlus/plugin/fixes/vanilla/music/MusicTocker.java delete mode 100644 src/main/java/gtPlusPlus/plugin/manager/CoreManager.java rename src/mixin/java/gregtech/mixin/mixins/early/minecraft/{ => accessors}/BlockStemMixin.java (61%) create mode 100644 src/mixin/java/gregtech/mixin/mixins/early/minecraft/accessors/EntityPlayerMPMixin.java rename src/mixin/java/gregtech/mixin/mixins/early/minecraft/{ => accessors}/ForgeShapedRecipeMixin.java (59%) rename src/mixin/java/gregtech/mixin/mixins/early/minecraft/{ => accessors}/ForgeShapelessRecipeMixin.java (85%) rename src/mixin/java/gregtech/mixin/mixins/early/minecraft/{ => accessors}/PotionMixin.java (66%) rename src/mixin/java/gregtech/mixin/mixins/early/minecraft/{ => accessors}/VanillaShapedRecipeMixin.java (86%) rename src/mixin/java/gregtech/mixin/mixins/early/minecraft/{ => accessors}/VanillaShapelessRecipeMixin.java (80%) diff --git a/src/main/java/bartworks/common/commands/ClearCraftingCache.java b/src/main/java/bartworks/common/commands/ClearCraftingCache.java index 68172190f6b..24f82d90d84 100644 --- a/src/main/java/bartworks/common/commands/ClearCraftingCache.java +++ b/src/main/java/bartworks/common/commands/ClearCraftingCache.java @@ -17,7 +17,7 @@ import net.minecraft.command.ICommandSender; import net.minecraft.util.ChatComponentText; -import bartworks.hooks.BWCoreStaticReplacementMethodes; +import gregtech.mixin.hooks.BWCoreStaticReplacementMethodes; public class ClearCraftingCache extends CommandBase { diff --git a/src/main/java/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java b/src/main/java/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java index c3a8442397f..c75d561e29c 100644 --- a/src/main/java/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java +++ b/src/main/java/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java @@ -34,7 +34,6 @@ import bartworks.API.recipe.BWNBTDependantCraftingRecipe; import bartworks.API.recipe.BartWorksRecipeMaps; -import bartworks.hooks.BWCoreStaticReplacementMethodes; import bartworks.system.material.WerkstoffLoader; import bartworks.util.BWUtil; import bartworks.util.Pair; @@ -48,6 +47,7 @@ import gregtech.api.util.GTOreDictUnificator; import gregtech.api.util.GTRecipe; import gregtech.api.util.GTUtility; +import gregtech.mixin.hooks.BWCoreStaticReplacementMethodes; public class CircuitImprintLoader { diff --git a/src/main/java/bartworks/system/material/gtenhancement/PlatinumSludgeOverHaul.java b/src/main/java/bartworks/system/material/gtenhancement/PlatinumSludgeOverHaul.java index a21a9b5ae9c..e3504a4e9c4 100644 --- a/src/main/java/bartworks/system/material/gtenhancement/PlatinumSludgeOverHaul.java +++ b/src/main/java/bartworks/system/material/gtenhancement/PlatinumSludgeOverHaul.java @@ -110,7 +110,6 @@ import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.TierEU; -import gregtech.api.interfaces.IRecipeMutableAccess; import gregtech.api.interfaces.ISubTagContainer; import gregtech.api.items.GTGenericBlock; import gregtech.api.items.GTGenericItem; @@ -123,6 +122,7 @@ import gregtech.api.util.GTRecipe; import gregtech.api.util.GTUtility; import gregtech.common.blocks.BlockOresAbstract; +import gregtech.mixin.interfaces.accessors.IRecipeMutableAccess; import gtPlusPlus.core.block.base.BlockBaseModular; import gtPlusPlus.core.item.base.BaseItemComponent; diff --git a/src/main/java/goodgenerator/loader/NaquadahReworkRecipeLoader.java b/src/main/java/goodgenerator/loader/NaquadahReworkRecipeLoader.java index 56b21238fd0..3f43a635231 100644 --- a/src/main/java/goodgenerator/loader/NaquadahReworkRecipeLoader.java +++ b/src/main/java/goodgenerator/loader/NaquadahReworkRecipeLoader.java @@ -74,7 +74,6 @@ import gregtech.api.enums.Mods; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.TierEU; -import gregtech.api.interfaces.IRecipeMutableAccess; import gregtech.api.recipe.RecipeMaps; import gregtech.api.util.GTLog; import gregtech.api.util.GTOreDictUnificator; @@ -82,6 +81,7 @@ import gregtech.api.util.GTUtility; import gregtech.common.items.CombType; import gregtech.loaders.misc.GTBees; +import gregtech.mixin.interfaces.accessors.IRecipeMutableAccess; import gtPlusPlus.api.recipe.GTPPRecipeMaps; import gtPlusPlus.core.item.chemistry.GenericChem; diff --git a/src/main/java/gregtech/api/util/GTRecipeRegistrator.java b/src/main/java/gregtech/api/util/GTRecipeRegistrator.java index 919b37e7d96..745a544a520 100644 --- a/src/main/java/gregtech/api/util/GTRecipeRegistrator.java +++ b/src/main/java/gregtech/api/util/GTRecipeRegistrator.java @@ -31,7 +31,6 @@ import static gregtech.api.util.GTUtility.calculateRecipeEU; import static gregtech.api.util.GTUtility.getTier; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; import java.util.IdentityHashMap; @@ -53,7 +52,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.SetMultimap; -import cpw.mods.fml.relauncher.ReflectionHelper; import gregtech.api.GregTechAPI; import gregtech.api.enums.GTValues; import gregtech.api.enums.Materials; @@ -63,6 +61,7 @@ import gregtech.api.objects.ItemData; import gregtech.api.objects.MaterialStack; import gregtech.api.recipe.RecipeCategories; +import gregtech.mixin.interfaces.accessors.ShapedOreRecipeAccessor; import ic2.api.reactor.IReactorComponent; /** @@ -123,8 +122,6 @@ public class GTRecipeRegistrator { new RecipeShape(null, sMt1, null, sMt1, null, null, null, null, null), new RecipeShape(sMt1, sMt1, null, sMt2, null, sMt1, sMt2, null, null), new RecipeShape(null, sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2) }; - public static final Field SHAPED_ORE_RECIPE_WIDTH = ReflectionHelper.findField(ShapedOreRecipe.class, "width"); - public static final Field SHAPED_ORE_RECIPE_HEIGHT = ReflectionHelper.findField(ShapedOreRecipe.class, "height"); private static volatile Map> indexedRecipeListCache; private static final String[][] sShapesA = new String[][] { null, null, null, { "Helmet", s_P + s_P + s_P, s_P + s_H + s_P }, @@ -791,19 +788,11 @@ public static boolean hasVanillaRecipes(Materials materials) { } private static int getRecipeWidth(ShapedOreRecipe r) { - try { - return (int) SHAPED_ORE_RECIPE_WIDTH.get(r); - } catch (ReflectiveOperationException e) { - throw new RuntimeException(e); - } + return ((ShapedOreRecipeAccessor) r).gt5u$getWidth(); } private static int getRecipeHeight(ShapedOreRecipe r) { - try { - return (int) SHAPED_ORE_RECIPE_HEIGHT.get(r); - } catch (ReflectiveOperationException e) { - throw new RuntimeException(e); - } + return ((ShapedOreRecipeAccessor) r).gt5u$getHeight(); } private static int getRecipeHeight(ShapedRecipes r) { diff --git a/src/main/java/gregtech/loaders/preload/GTPreLoad.java b/src/main/java/gregtech/loaders/preload/GTPreLoad.java index 6216f752dc5..b3c4c480958 100644 --- a/src/main/java/gregtech/loaders/preload/GTPreLoad.java +++ b/src/main/java/gregtech/loaders/preload/GTPreLoad.java @@ -339,12 +339,9 @@ public static void adjustScrap() { try { Objects.requireNonNull(GTUtility.getField("ic2.core.item.ItemScrapbox$Drop", "topChance", true, true)) .set(null, 0); - ((List) Objects.requireNonNull( - GTUtility.getFieldContent( - GTUtility.getFieldContent("ic2.api.recipe.Recipes", "scrapboxDrops", true, true), - "drops", - true, - true))).clear(); + ((List) Objects + .requireNonNull(GTUtility.getFieldContent(ic2.api.recipe.Recipes.scrapboxDrops, "drops", true, true))) + .clear(); } catch (Throwable e) { if (GTValues.D1) { e.printStackTrace(GTLog.err); @@ -539,7 +536,7 @@ public static void loadConfig() { /** * Clamp value between 0 and 255 - * + * * @param value the value to clamp * @return the clamped value */ diff --git a/src/main/java/gregtech/mixin/Mixin.java b/src/main/java/gregtech/mixin/Mixin.java index 224c7b5f1c8..b9ba1db098b 100644 --- a/src/main/java/gregtech/mixin/Mixin.java +++ b/src/main/java/gregtech/mixin/Mixin.java @@ -48,16 +48,13 @@ public enum Mixin { .setSide(Side.BOTH)), VanillaAccessors(new Builder("Adds various accessors") .addMixinClasses( - "minecraft.VanillaShapedRecipeMixin", - "minecraft.VanillaShapelessRecipeMixin", - "minecraft.ForgeShapedRecipeMixin", - "minecraft.ForgeShapelessRecipeMixin", - "minecraft.PotionMixin") - .addTargetedMod(VANILLA) - .setApplyIf(() -> true) - .setPhase(Phase.EARLY) - .setSide(Side.BOTH)), - BlockStemMixin(new Builder("Stem Crop Block Accessor").addMixinClasses("minecraft.BlockStemMixin") + "minecraft.accessors.BlockStemMixin", + "minecraft.accessors.VanillaShapedRecipeMixin", + "minecraft.accessors.VanillaShapelessRecipeMixin", + "minecraft.accessors.ForgeShapedRecipeMixin", + "minecraft.accessors.ForgeShapelessRecipeMixin", + "minecraft.accessors.PotionMixin", + "minecraft.accessors.EntityPlayerMPMixin") .addTargetedMod(VANILLA) .setApplyIf(() -> true) .setPhase(Phase.EARLY) diff --git a/src/main/java/bartworks/hooks/BWCoreStaticReplacementMethodes.java b/src/main/java/gregtech/mixin/hooks/BWCoreStaticReplacementMethodes.java similarity index 99% rename from src/main/java/bartworks/hooks/BWCoreStaticReplacementMethodes.java rename to src/main/java/gregtech/mixin/hooks/BWCoreStaticReplacementMethodes.java index 6110d9c32d2..9f8f5fb8b46 100644 --- a/src/main/java/bartworks/hooks/BWCoreStaticReplacementMethodes.java +++ b/src/main/java/gregtech/mixin/hooks/BWCoreStaticReplacementMethodes.java @@ -11,7 +11,7 @@ * DEALINGS IN THE SOFTWARE. */ -package bartworks.hooks; +package gregtech.mixin.hooks; import java.util.HashSet; import java.util.Iterator; diff --git a/src/main/java/gregtech/mixin/MixinsVariablesHelper.java b/src/main/java/gregtech/mixin/hooks/MixinsVariablesHelper.java similarity index 76% rename from src/main/java/gregtech/mixin/MixinsVariablesHelper.java rename to src/main/java/gregtech/mixin/hooks/MixinsVariablesHelper.java index 96cc2ee115b..7925573f2d0 100644 --- a/src/main/java/gregtech/mixin/MixinsVariablesHelper.java +++ b/src/main/java/gregtech/mixin/hooks/MixinsVariablesHelper.java @@ -1,4 +1,4 @@ -package gregtech.mixin; +package gregtech.mixin.hooks; public class MixinsVariablesHelper { diff --git a/src/main/java/gregtech/mixin/interfaces/IBlockStemAccesor.java b/src/main/java/gregtech/mixin/interfaces/IBlockStemAccesor.java deleted file mode 100644 index 089479f8ad9..00000000000 --- a/src/main/java/gregtech/mixin/interfaces/IBlockStemAccesor.java +++ /dev/null @@ -1,8 +0,0 @@ -package gregtech.mixin.interfaces; - -import net.minecraft.block.Block; - -public interface IBlockStemAccesor { - - Block getCropBlock(); -} diff --git a/src/main/java/gregtech/mixin/interfaces/PotionExt.java b/src/main/java/gregtech/mixin/interfaces/PotionExt.java deleted file mode 100644 index 11ae365e5a9..00000000000 --- a/src/main/java/gregtech/mixin/interfaces/PotionExt.java +++ /dev/null @@ -1,7 +0,0 @@ -package gregtech.mixin.interfaces; - -public interface PotionExt { - - boolean gt5u$isBadEffect(); - -} diff --git a/src/main/java/gregtech/mixin/interfaces/accessors/EntityPlayerMPAccessor.java b/src/main/java/gregtech/mixin/interfaces/accessors/EntityPlayerMPAccessor.java new file mode 100644 index 00000000000..826c5d14748 --- /dev/null +++ b/src/main/java/gregtech/mixin/interfaces/accessors/EntityPlayerMPAccessor.java @@ -0,0 +1,7 @@ +package gregtech.mixin.interfaces.accessors; + +public interface EntityPlayerMPAccessor { + + String gt5u$getTranslator(); + +} diff --git a/src/main/java/gregtech/mixin/interfaces/accessors/IBlockStemAccessor.java b/src/main/java/gregtech/mixin/interfaces/accessors/IBlockStemAccessor.java new file mode 100644 index 00000000000..da3efa582dd --- /dev/null +++ b/src/main/java/gregtech/mixin/interfaces/accessors/IBlockStemAccessor.java @@ -0,0 +1,8 @@ +package gregtech.mixin.interfaces.accessors; + +import net.minecraft.block.Block; + +public interface IBlockStemAccessor { + + Block gt5u$getCropBlock(); +} diff --git a/src/main/java/gregtech/api/interfaces/IRecipeMutableAccess.java b/src/main/java/gregtech/mixin/interfaces/accessors/IRecipeMutableAccess.java similarity index 92% rename from src/main/java/gregtech/api/interfaces/IRecipeMutableAccess.java rename to src/main/java/gregtech/mixin/interfaces/accessors/IRecipeMutableAccess.java index 5c6d931d5a7..778e021205d 100644 --- a/src/main/java/gregtech/api/interfaces/IRecipeMutableAccess.java +++ b/src/main/java/gregtech/mixin/interfaces/accessors/IRecipeMutableAccess.java @@ -1,4 +1,4 @@ -package gregtech.api.interfaces; +package gregtech.mixin.interfaces.accessors; import net.minecraft.item.ItemStack; diff --git a/src/main/java/gregtech/mixin/interfaces/accessors/PotionAccessor.java b/src/main/java/gregtech/mixin/interfaces/accessors/PotionAccessor.java new file mode 100644 index 00000000000..48794c256ae --- /dev/null +++ b/src/main/java/gregtech/mixin/interfaces/accessors/PotionAccessor.java @@ -0,0 +1,7 @@ +package gregtech.mixin.interfaces.accessors; + +public interface PotionAccessor { + + boolean gt5u$isBadEffect(); + +} diff --git a/src/main/java/gregtech/mixin/interfaces/accessors/ShapedOreRecipeAccessor.java b/src/main/java/gregtech/mixin/interfaces/accessors/ShapedOreRecipeAccessor.java new file mode 100644 index 00000000000..9d2980e434e --- /dev/null +++ b/src/main/java/gregtech/mixin/interfaces/accessors/ShapedOreRecipeAccessor.java @@ -0,0 +1,9 @@ +package gregtech.mixin.interfaces.accessors; + +public interface ShapedOreRecipeAccessor { + + int gt5u$getWidth(); + + int gt5u$getHeight(); + +} diff --git a/src/main/java/gtPlusPlus/GTplusplus.java b/src/main/java/gtPlusPlus/GTplusplus.java index 893446ea72e..5de4fef23b5 100644 --- a/src/main/java/gtPlusPlus/GTplusplus.java +++ b/src/main/java/gtPlusPlus/GTplusplus.java @@ -4,12 +4,13 @@ import static gregtech.api.enums.Mods.Names; import static gregtech.api.enums.Mods.Thaumcraft; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.util.HashMap; import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.launchwrapper.Launch; import com.gtnewhorizon.gtnhlib.config.ConfigException; @@ -25,7 +26,6 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent; -import cpw.mods.fml.common.event.FMLServerStoppingEvent; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -44,7 +44,9 @@ import gtPlusPlus.core.lib.GTPPCore; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.data.LocaleUtils; -import gtPlusPlus.plugin.manager.CoreManager; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.plugin.agrichem.block.AgrichemFluids; +import gtPlusPlus.plugin.fixes.vanilla.VanillaBedHeightFix; import gtPlusPlus.xmod.gregtech.common.MetaGTProxy; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtTools; @@ -76,7 +78,7 @@ + " after:TGregworks;" + " after:StevesCarts;" + " required-after:gtnhlib@[0.0.10,);") -public class GTplusplus implements ActionListener { +public class GTplusplus { public enum INIT_PHASE { @@ -149,8 +151,6 @@ public GTplusplus() { @EventHandler public void preInit(final FMLPreInitializationEvent event) { INIT_PHASE.PRE_INIT.setPhaseActive(true); - // Load all class objects within the plugin package. - CoreManager.veryEarlyInit(); PacketHandler.init(); // Give this a go mate. @@ -162,7 +162,9 @@ public void preInit(final FMLPreInitializationEvent event) { proxy.preInit(event); Logger.INFO("Setting up our own GTProxy."); MetaGTProxy.preInit(); - CoreManager.preInit(); + AgrichemFluids.preInit(); + fixVanillaOreDict(); + new VanillaBedHeightFix(); } @EventHandler @@ -171,7 +173,6 @@ public void init(final FMLInitializationEvent event) { proxy.init(event); proxy.registerNetworkStuff(); MetaGTProxy.init(); - CoreManager.init(); // Used by foreign players to generate .lang files for translation. if (Configuration.debug.dumpItemAndBlockData) { LocaleUtils.generateFakeLocaleFile(); @@ -184,7 +185,6 @@ public void postInit(final FMLPostInitializationEvent event) { proxy.postInit(event); BookHandler.runLater(); MetaGTProxy.postInit(); - CoreManager.postInit(); Logger.INFO("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Logger.INFO( @@ -218,18 +218,9 @@ public synchronized void serverStarting(final FMLServerStartingEvent event) { if (Thaumcraft.isModLoaded()) { event.registerServerCommand(new CommandDumpAspects()); } - CoreManager.serverStart(); INIT_PHASE.STARTED.setPhaseActive(true); } - @EventHandler - public synchronized void serverStopping(final FMLServerStoppingEvent event) { - CoreManager.serverStop(); - } - - @Override - public void actionPerformed(final ActionEvent arg0) {} - /** * This {@link EventHandler} is called after the {@link FMLPostInitializationEvent} stages of all loaded mods * executes successfully. {@link #onLoadComplete(FMLLoadCompleteEvent)} exists to inject recipe generation after @@ -383,4 +374,39 @@ private static void remap(Block block, FMLMissingMappingsEvent.MissingMapping ma mapping.remap(block); Logger.INFO("Remapping block " + mapping.name + " to " + GTPlusPlus.ID + ":" + block.getUnlocalizedName()); } + + private static void fixVanillaOreDict() { + registerToOreDict(ItemUtils.getSimpleStack(Items.blaze_rod), "rodBlaze"); + registerToOreDict(ItemUtils.getSimpleStack(Items.nether_wart), "cropNetherWart"); + registerToOreDict(ItemUtils.getSimpleStack(Items.reeds), "sugarcane"); + registerToOreDict(ItemUtils.getSimpleStack(Items.paper), "paper"); + registerToOreDict(ItemUtils.getSimpleStack(Items.ender_pearl), "enderpearl"); + registerToOreDict(ItemUtils.getSimpleStack(Items.bone), "bone"); + registerToOreDict(ItemUtils.getSimpleStack(Items.gunpowder), "gunpowder"); + registerToOreDict(ItemUtils.getSimpleStack(Items.string), "string"); + registerToOreDict(ItemUtils.getSimpleStack(Items.nether_star), "netherStar"); + registerToOreDict(ItemUtils.getSimpleStack(Items.leather), "leather"); + registerToOreDict(ItemUtils.getSimpleStack(Items.feather), "feather"); + registerToOreDict(ItemUtils.getSimpleStack(Items.egg), "egg"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.end_stone), "endstone"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.vine), "vine"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.cactus), "blockCactus"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.grass), "grass"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.obsidian), "obsidian"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.crafting_table), "workbench"); + } + + private static void registerToOreDict(ItemStack aStack, String aString) { + if (aStack.getItem() == Items.blaze_rod) { + Logger + .INFO("Registering " + aStack.getDisplayName() + " to OreDictionary under the tag '" + aString + "'."); + } else { + Logger.INFO( + "Registering " + aStack.getDisplayName() + + " to OreDictionary under the tag '" + + aString + + "'. (Added to Forge in 1.8.9)"); + } + ItemUtils.addItemToOreDictionary(aStack, aString); + } } diff --git a/src/main/java/gtPlusPlus/api/interfaces/IPlugin.java b/src/main/java/gtPlusPlus/api/interfaces/IPlugin.java deleted file mode 100644 index d70a19925e0..00000000000 --- a/src/main/java/gtPlusPlus/api/interfaces/IPlugin.java +++ /dev/null @@ -1,41 +0,0 @@ -package gtPlusPlus.api.interfaces; - -import gtPlusPlus.api.objects.Logger; - -public interface IPlugin { - - /** - * @return A {@link String} object which returns the {@link IPlugin}'s name. - */ - public String getPluginName(); - - /** - * @return A {@link String} object which returns the {@link IPlugin}'s short name. This String should only contain 4 - * Characters. - */ - public String getPluginAbbreviation(); - - /** - * @param message - A {@link String} object which holds a message to be logged to console. - */ - default void log(String message) { - Logger.INFO("[" + getPluginAbbreviation() + "] " + message); - } - - /** - * @param message - A {@link String} object which holds a warning/error message to be logged to console. - */ - default void logDebug(String message) { - Logger.WARNING("[" + getPluginAbbreviation() + "] " + message); - } - - public boolean preInit(); - - public boolean init(); - - public boolean postInit(); - - public boolean serverStart(); - - public boolean serverStop(); -} diff --git a/src/main/java/gtPlusPlus/api/objects/Logger.java b/src/main/java/gtPlusPlus/api/objects/Logger.java index 2214e50e781..66506688949 100644 --- a/src/main/java/gtPlusPlus/api/objects/Logger.java +++ b/src/main/java/gtPlusPlus/api/objects/Logger.java @@ -23,7 +23,7 @@ public static org.apache.logging.log4j.Logger makeLogger() { private static final boolean enabled = !ASMConfiguration.debug.disableAllLogging; - public static final org.apache.logging.log4j.Logger getLogger() { + public static org.apache.logging.log4j.Logger getLogger() { return modLogger; } @@ -38,8 +38,7 @@ public static void INFO(final String s) { public static void MACHINE_INFO(String s, Object... args) { if (enabled) { if (Configuration.debug.MachineInfo || GTCorePlugin.isDevEnv()) { - final String name1 = gtPlusPlus.core.util.reflect.ReflectionUtils.getMethodName(2); - modLogger.info("Machine Info: " + s + " | " + name1, args); + modLogger.info("Machine Info: " + s + " ", args); } } } diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java b/src/main/java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java index 6852c93f055..867f247b6e3 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java @@ -6,7 +6,7 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.ShapedOreRecipe; -import gregtech.api.interfaces.IRecipeMutableAccess; +import gregtech.mixin.interfaces.accessors.IRecipeMutableAccess; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.util.minecraft.ItemUtils; @@ -25,14 +25,11 @@ public ShapedRecipe(Object aInput1, Object aInput2, Object aInput3, Object aInpu } public ShapedRecipe(Object[] aInputs, ItemStack aOutput) { - String aGridWhole = ""; - String aGrid[] = new String[3]; + StringBuilder aGridWhole = new StringBuilder(); + String[] aGrid = new String[3]; char[] aChar = new char[9]; String[] aLoggingInfo = new String[9]; - - if (mBlackList == null) { - mBlackList = new ItemStack[] {}; - } + mBlackList = new ItemStack[] {}; // Just to be safe try { @@ -68,7 +65,7 @@ public ShapedRecipe(Object[] aInputs, ItemStack aOutput) { Object[] mVarags2 = null; Logger.RECIPE("Generating Shaped Crafting Recipe for " + aOutput.getDisplayName()); - if (aInputs.length < 9 || aInputs.length > 9) { + if (aInputs.length != 9) { Logger.RECIPE( "[Fix] Recipe for " + aOutput.getDisplayName() + " has incorrect number of inputs. Size: " @@ -118,7 +115,7 @@ public ShapedRecipe(Object[] aInputs, ItemStack aOutput) { for (Pair h : aRecipePairs) { if (h.getKey() != null) { - aGridWhole += String.valueOf(h.getKey()); + aGridWhole.append(String.valueOf(h.getKey())); Logger.RECIPE("Adding '" + String.valueOf(h.getKey()) + "' to aGridWhole."); } } diff --git a/src/main/java/gtPlusPlus/core/config/ASMConfiguration.java b/src/main/java/gtPlusPlus/core/config/ASMConfiguration.java index a348998ef07..63d65b32c96 100644 --- a/src/main/java/gtPlusPlus/core/config/ASMConfiguration.java +++ b/src/main/java/gtPlusPlus/core/config/ASMConfiguration.java @@ -11,7 +11,6 @@ public class ASMConfiguration { public static Debug debug = new Debug(); - public static General general = new General(); // Debug @Config.Comment("Debug section") @@ -27,14 +26,4 @@ public static class Debug { } - @Config.Comment("General section") - public static class General { - // General Features - - @Config.Comment("Set to a value greater than 0 to reduce the ticks taken to delay between BGM tracks. Acceptable Values are 1-32767, where 0 is disabled. Vanilla Uses 12,000 & 24,000. 200 is 10s.") - @Config.DefaultInt(0) - @Config.RangeInt(min = 0, max = Short.MAX_VALUE) - public int enableWatchdogBGM; - - } } diff --git a/src/main/java/gtPlusPlus/core/handler/PacketHandler.java b/src/main/java/gtPlusPlus/core/handler/PacketHandler.java index 9c5d6b25d2c..504afc55d86 100644 --- a/src/main/java/gtPlusPlus/core/handler/PacketHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/PacketHandler.java @@ -9,12 +9,9 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.relauncher.Side; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.network.handler.AbstractClientMessageHandler; -import gtPlusPlus.core.network.packet.AbstractPacket; import gtPlusPlus.core.network.packet.PacketVolumetricFlaskGui; import gtPlusPlus.core.network.packet.PacketVolumetricFlaskGui2; -import gtPlusPlus.core.util.reflect.ReflectionUtils; public class PacketHandler { @@ -37,14 +34,6 @@ private static void registerMessage(Class handlerClass, Class messageClass) { private static void registerMessage(Class handlerClass, Class messageClass, Side side) { INSTANCE.registerMessage(handlerClass, messageClass, packetId++, side); - if (AbstractPacket.class.isInstance(messageClass.getClass())) { - AbstractPacket aPacket = ReflectionUtils.createNewInstanceFromConstructor( - ReflectionUtils.getConstructor(messageClass, new Class[] {}), - new Object[] {}); - if (aPacket != null) { - Logger.INFO("Registered Packet: " + aPacket.getPacketName()); - } - } } /** diff --git a/src/main/java/gtPlusPlus/core/handler/events/PlayerSleepEventHandler.java b/src/main/java/gtPlusPlus/core/handler/events/PlayerSleepEventHandler.java index 33649b4ff28..41755d6abc7 100644 --- a/src/main/java/gtPlusPlus/core/handler/events/PlayerSleepEventHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/events/PlayerSleepEventHandler.java @@ -11,7 +11,7 @@ import net.minecraftforge.event.entity.player.PlayerWakeUpEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import gregtech.mixin.interfaces.PotionExt; +import gregtech.mixin.interfaces.accessors.PotionAccessor; import gtPlusPlus.core.util.math.MathUtils; public class PlayerSleepEventHandler { @@ -43,7 +43,7 @@ public void onPlayerWakeUp(PlayerWakeUpEvent event) { final List potionToRemove = new ArrayList<>(); for (PotionEffect potionEffect : player.getActivePotionEffects()) { final Potion potion = Potion.potionTypes[potionEffect.getPotionID()]; - if (potion instanceof PotionExt && ((PotionExt) potion).gt5u$isBadEffect()) { + if (potion instanceof PotionAccessor && ((PotionAccessor) potion).gt5u$isBadEffect()) { potionToRemove.add(potion.id); } } diff --git a/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index 40b32fed86f..5dd9f9f426f 100644 --- a/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -1,56 +1,19 @@ package gtPlusPlus.core.util.reflect; -import java.io.IOException; -import java.lang.reflect.Constructor; import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.util.LinkedHashMap; +import java.util.HashMap; import java.util.Map; -import org.apache.commons.lang3.ArrayUtils; - -import com.google.common.reflect.ClassPath; import com.gtnewhorizon.gtnhlib.reflect.Fields; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.data.StringUtils; @SuppressWarnings({ "unchecked", "rawtypes" }) public class ReflectionUtils { - public static Map mCachedMethods = new LinkedHashMap<>(); - public static Map mCachedFields = new LinkedHashMap<>(); - public static Map mCachedConstructors = new LinkedHashMap<>(); - public static Map mCachedFieldAccessors = new LinkedHashMap<>(); - - private static class CachedConstructor { - - private final Constructor METHOD; - - public CachedConstructor(Constructor aCons) { - METHOD = aCons; - } - - public Constructor get() { - return METHOD; - } - } - - private static class CachedMethod { - - private final Method METHOD; - - public CachedMethod(Method aMethod, boolean isStatic) { - METHOD = aMethod; - } - - public Method get() { - return METHOD; - } - - } + public static Map mCachedFields = new HashMap<>(); + public static Map mCachedFieldAccessors = new HashMap<>(); private static class CachedField { @@ -73,22 +36,6 @@ private static Fields.ClassFields.Field cacheAccessor(Field f) { .getUntypedField(Fields.LookupType.DECLARED_IN_HIERARCHY, field.getName())); } - private static boolean cacheMethod(Class aClass, Method aMethod) { - if (aMethod == null) { - return false; - } - boolean isStatic = Modifier.isStatic(aMethod.getModifiers()); - CachedMethod y = mCachedMethods - .get(aClass.getName() + "." + aMethod.getName() + "." + ArrayUtils.toString(aMethod.getParameterTypes())); - if (y == null) { - mCachedMethods.put( - aClass.getName() + "." + aMethod.getName() + "." + ArrayUtils.toString(aMethod.getParameterTypes()), - new CachedMethod(aMethod, isStatic)); - return true; - } - return false; - } - private static boolean cacheField(Class aClass, Field aField) { if (aField == null) { return false; @@ -102,85 +49,6 @@ private static boolean cacheField(Class aClass, Field aField) { return false; } - private static void cacheConstructor(Class aClass, Constructor aConstructor) { - if (aConstructor == null) { - return; - } - mCachedConstructors.computeIfAbsent( - aClass.getName() + "." + ArrayUtils.toString(aConstructor.getParameterTypes()), - k -> new CachedConstructor(aConstructor)); - } - - /** - * Returns a cached {@link Constructor} object. - * - * @param aClass - Class containing the Constructor. - * @param aTypes - Varags Class Types for objects constructor. - * @return - Valid, non-final, {@link Method} object, or {@link null}. - */ - public static Constructor getConstructor(Class aClass, Class... aTypes) { - if (aClass == null || aTypes == null) { - return null; - } - - String aMethodKey = ArrayUtils.toString(aTypes); - // Logger.REFLECTION("Looking up method in cache: "+(aClass.getName()+"."+aMethodName + "." + aMethodKey)); - CachedConstructor y = mCachedConstructors.get(aClass.getName() + "." + aMethodKey); - if (y == null) { - Constructor u = getConstructor_Internal(aClass, aTypes); - if (u != null) { - Logger.REFLECTION("Caching Constructor: " + aClass.getName() + "." + aMethodKey); - cacheConstructor(aClass, u); - return u; - } else { - return null; - } - } else { - return y.get(); - } - } - - /** - * Returns a cached {@link Method} object. Wraps {@link #getMethod(Class, String, Class...)}. - * - * @param aObject - Object containing the Method. - * @param aMethodName - Method's name in {@link String} form. - * @param aTypes - Class Array of Types for {@link Method}'s constructor. - * @return - Valid, non-final, {@link Method} object, or {@link null}. - */ - public static Method getMethod(Object aObject, String aMethodName, Class[] aTypes) { - return getMethod(aObject.getClass(), aMethodName, aTypes); - } - - /** - * Returns a cached {@link Method} object. - * - * @param aClass - Class containing the Method. - * @param aMethodName - Method's name in {@link String} form. - * @param aTypes - Varags Class Types for {@link Method}'s constructor. - * @return - Valid, non-final, {@link Method} object, or {@link null}. - */ - public static Method getMethod(Class aClass, String aMethodName, Class... aTypes) { - if (aClass == null || aMethodName == null || aMethodName.length() <= 0) { - return null; - } - String aMethodKey = ArrayUtils.toString(aTypes); - // Logger.REFLECTION("Looking up method in cache: "+(aClass.getName()+"."+aMethodName + "." + aMethodKey)); - CachedMethod y = mCachedMethods.get(aClass.getName() + "." + aMethodName + "." + aMethodKey); - if (y == null) { - Method u = getMethod_Internal(aClass, aMethodName, aTypes); - if (u != null) { - Logger.REFLECTION("Caching Method: " + aMethodName + "." + aMethodKey); - cacheMethod(aClass, u); - return u; - } else { - return null; - } - } else { - return y.get(); - } - } - /** * Returns a cached {@link Field} object. * @@ -237,79 +105,6 @@ public static void makeFieldAccessible(final Field field) { } } - public static void makeMethodAccessible(final Method field) { - if (!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic( - field.getDeclaringClass() - .getModifiers())) { - field.setAccessible(true); - } - } - - /** - * Get the method name for a depth in call stack.
- * Utility function - * - * @param depth depth in the call stack (0 means current method, 1 means call method, ...) - * @return Method name - */ - public static String getMethodName(final int depth) { - final StackTraceElement[] ste = new Throwable().getStackTrace(); - // System. out.println(ste[ste.length-depth].getClassName()+"#"+ste[ste.length-depth].getMethodName()); - if (ste.length < depth) { - return "No valid stack."; - } - return ste[depth + 1].getMethodName(); - } - - /** - * - * @param aPackageName - The full {@link Package} name in {@link String} form. - * @return - {@link Boolean} object. True if loaded > 0 classes. - */ - public static boolean dynamicallyLoadClassesInPackage(String aPackageName) { - ClassLoader classLoader = ReflectionUtils.class.getClassLoader(); - int loaded = 0; - try { - ClassPath path = ClassPath.from(classLoader); - for (ClassPath.ClassInfo info : path.getTopLevelClassesRecursive(aPackageName)) { - Class clazz = Class.forName(info.getName(), true, classLoader); - if (clazz != null) { - loaded++; - Logger.INFO("Found " + clazz.getCanonicalName() + ". [" + loaded + "]"); - } - } - } catch (ClassNotFoundException | IOException e) { - - } - - return loaded > 0; - } - - public static boolean setField(final Object object, final String fieldName, final Object fieldValue) { - Class clazz; - if (object instanceof Class) { - clazz = (Class) object; - } else { - clazz = object.getClass(); - } - while (clazz != null) { - try { - final Field field = getField(clazz, fieldName); - if (field != null) { - setFieldValue_Internal(object, field, fieldValue); - return true; - } - } catch (final NoSuchFieldException e) { - Logger.REFLECTION("setField(" + object + ", " + fieldName + ") failed."); - clazz = clazz.getSuperclass(); - } catch (final Exception e) { - Logger.REFLECTION("setField(" + object + ", " + fieldName + ") failed."); - throw new IllegalStateException(e); - } - } - return false; - } - public static boolean setField(final Object object, final Field field, final Object fieldValue) { if (field == null) return false; Class clazz; @@ -336,51 +131,6 @@ public static boolean setField(final Object object, final Field field, final Obj return false; } - /** - * Allows to change the state of an immutable instance. Huh?!? - */ - public static void setFinalFieldValue(Class clazz, String fieldName, Object newValue) { - Field nameField = getField(clazz, fieldName); - try { - setFieldValue_Internal(clazz, nameField, newValue); - } catch (Throwable t) { - t.printStackTrace(); - } - } - - public static void setByte(Object clazz, String fieldName, byte newValue) { - Field nameField = getField(clazz.getClass(), fieldName); - cacheAccessor(nameField).setValue(null, newValue); - } - - public static boolean invokeVoid(Object objectInstance, String methodName, Class[] parameters, Object[] values) { - if (objectInstance == null || methodName == null || parameters == null || values == null) { - return false; - } - Class mLocalClass = (objectInstance instanceof Class ? (Class) objectInstance - : objectInstance.getClass()); - Logger.REFLECTION( - "Trying to invoke " + methodName + " on an instance of " + mLocalClass.getCanonicalName() + "."); - try { - Method mInvokingMethod = mLocalClass.getDeclaredMethod(methodName, parameters); - if (mInvokingMethod != null) { - Logger.REFLECTION(methodName + " was not null."); - mInvokingMethod.invoke(objectInstance, values); - Logger.REFLECTION("Successfully invoked " + methodName + "."); - return true; - } else { - Logger.REFLECTION(methodName + " is null."); - } - } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException - | InvocationTargetException e) { - Logger.REFLECTION( - "Failed to Dynamically invoke " + methodName + " on an object of type: " + mLocalClass.getName()); - } - - Logger.REFLECTION("Invoke failed or did something wrong."); - return false; - } - /* * Below Code block is used for determining generic types associated with type */ @@ -407,108 +157,6 @@ private static Field getField_Internal(final Class clazz, final String fieldN } } - private static Method getMethod_Internal(Class aClass, String aMethodName, Class... aTypes) { - Method m = null; - try { - Logger.REFLECTION("Method: Internal Lookup: " + aMethodName); - m = aClass.getDeclaredMethod(aMethodName, aTypes); - if (m != null) { - m.setAccessible(true); - } - } catch (Throwable t) { - Logger.REFLECTION("Method: Internal Lookup Failed: " + aMethodName); - try { - m = getMethodRecursively(aClass, aMethodName); - } catch (NoSuchMethodException e) { - Logger.REFLECTION("Unable to find method '" + aMethodName + "'"); - e.printStackTrace(); - dumpClassInfo(aClass); - } - } - return m; - } - - private static Constructor getConstructor_Internal(Class aClass, Class... aTypes) { - Constructor c = null; - try { - Logger.REFLECTION("Constructor: Internal Lookup: " + aClass.getName()); - c = aClass.getDeclaredConstructor(aTypes); - if (c != null) { - c.setAccessible(true); - } - } catch (Throwable t) { - Logger.REFLECTION("Constructor: Internal Lookup Failed: " + aClass.getName()); - try { - c = getConstructorRecursively(aClass, aTypes); - } catch (Exception e) { - Logger.REFLECTION("Unable to find method '" + aClass.getName() + "'"); - e.printStackTrace(); - dumpClassInfo(aClass); - } - } - return c; - } - - private static Constructor getConstructorRecursively(Class aClass, Class... aTypes) throws Exception { - try { - Logger.REFLECTION("Constructor: Recursion Lookup: " + aClass.getName()); - Constructor c = aClass.getConstructor(aTypes); - if (c != null) { - c.setAccessible(true); - } - return c; - } catch (final NoSuchMethodException | IllegalArgumentException e) { - final Class superClass = aClass.getSuperclass(); - if (superClass == null || superClass == Object.class) { - throw e; - } - return getConstructor_Internal(superClass, aTypes); - } - } - - private static Method getMethodRecursively(final Class clazz, final String aMethodName) - throws NoSuchMethodException { - try { - Logger.REFLECTION("Method: Recursion Lookup: " + aMethodName); - Method k = clazz.getDeclaredMethod(aMethodName); - makeMethodAccessible(k); - return k; - } catch (final NoSuchMethodException e) { - final Class superClass = clazz.getSuperclass(); - if (superClass == null || superClass == Object.class) { - throw e; - } - return getMethod_Internal(superClass, aMethodName); - } - } - - private static void dumpClassInfo(Class aClass) { - Logger.INFO( - "We ran into an error processing reflection in " + aClass.getName() + ", dumping all data for debugging."); - // Get the methods - Method[] methods = aClass.getDeclaredMethods(); - Field[] fields = aClass.getDeclaredFields(); - Constructor[] consts = aClass.getDeclaredConstructors(); - - Logger.INFO("Dumping all Methods."); - for (Method method : methods) { - System.out - .println(method.getName() + " | " + StringUtils.getDataStringFromArray(method.getParameterTypes())); - } - Logger.INFO("Dumping all Fields."); - for (Field f : fields) { - System.out.println(f.getName()); - } - Logger.INFO("Dumping all Constructors."); - for (Constructor c : consts) { - System.out.println( - c.getName() + " | " - + c.getParameterCount() - + " | " - + StringUtils.getDataStringFromArray(c.getParameterTypes())); - } - } - /** * * Set the value of a field reflectively. @@ -517,19 +165,6 @@ private static void setFieldValue_Internal(Object owner, Field field, Object val cacheAccessor(field).setValue(owner, value); } - public static boolean doesFieldExist(Class clazz, String string) { - if (clazz != null) { - if (ReflectionUtils.getField(clazz, string) != null) { - return true; - } - } - return false; - } - - public static T getFieldValue(Field field) { - return getFieldValue(field, null); - } - public static T getFieldValue(Field field, Object instance) { try { return (T) field.get(instance); @@ -537,29 +172,4 @@ public static T getFieldValue(Field field, Object instance) { return null; } - public static T createNewInstanceFromConstructor(Constructor aConstructor, Object[] aArgs) { - T aInstance; - try { - aInstance = (T) aConstructor.newInstance(aArgs); - return aInstance; - } catch (InstantiationException | IllegalAccessException | IllegalArgumentException - | InvocationTargetException e) { - e.printStackTrace(); - } - return null; - } - - public static Enum getEnum(Class sgtbees, String name) { - if (sgtbees.isEnum()) { - Object[] aValues = sgtbees.getEnumConstants(); - for (Object o : aValues) { - if (o.toString() - .toLowerCase() - .equals(name.toLowerCase())) { - return (Enum) o; - } - } - } - return null; - } } diff --git a/src/main/java/gtPlusPlus/everglades/GTPPEverglades.java b/src/main/java/gtPlusPlus/everglades/GTPPEverglades.java index d2052afb558..55bb39bd3e5 100644 --- a/src/main/java/gtPlusPlus/everglades/GTPPEverglades.java +++ b/src/main/java/gtPlusPlus/everglades/GTPPEverglades.java @@ -2,9 +2,6 @@ import static gregtech.api.enums.Mods.GTPlusPlusEverglades; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - import net.minecraft.block.Block; import net.minecraftforge.common.DimensionManager; @@ -35,7 +32,7 @@ name = Everglades.NAME, version = Everglades.VERSION, dependencies = "required-after:Forge; after:dreamcraft; after:IC2; required-after:gregtech; required-after:miscutils;") -public class GTPPEverglades implements ActionListener { +public class GTPPEverglades { // Mod Instance @Mod.Instance(Mods.Names.G_T_PLUS_PLUS_EVERGLADES) @@ -171,10 +168,4 @@ public static synchronized BiomeEverglades getEvergladesBiome() { public static synchronized void setEvergladesBiome(BiomeEverglades darkWorld_Biome) { Everglades_Biome = darkWorld_Biome; } - - @Override - public void actionPerformed(ActionEvent arg0) { - // TODO Auto-generated method stub - - } } diff --git a/src/main/java/gtPlusPlus/plugin/agrichem/AgrichemCore.java b/src/main/java/gtPlusPlus/plugin/agrichem/AgrichemCore.java deleted file mode 100644 index 6e5cc47e3a3..00000000000 --- a/src/main/java/gtPlusPlus/plugin/agrichem/AgrichemCore.java +++ /dev/null @@ -1,56 +0,0 @@ -package gtPlusPlus.plugin.agrichem; - -import gtPlusPlus.api.interfaces.IPlugin; -import gtPlusPlus.plugin.agrichem.block.AgrichemFluids; -import gtPlusPlus.plugin.manager.CoreManager; - -// Called by Core_Manager#veryEarlyInit -@SuppressWarnings("unused") -public class AgrichemCore implements IPlugin { - - static final AgrichemCore mInstance; - - static { - mInstance = new AgrichemCore(); - CoreManager.registerPlugin(mInstance); - mInstance.log("Preparing " + mInstance.getPluginName() + " for use."); - } - - @Override - public boolean preInit() { - AgrichemFluids.init(); - return true; - } - - @Override - public boolean init() { - mInstance.log("Setting Items"); - return true; - } - - @Override - public boolean postInit() { - mInstance.log("Generating Recipes"); - return true; - } - - @Override - public boolean serverStart() { - return true; - } - - @Override - public boolean serverStop() { - return true; - } - - @Override - public String getPluginName() { - return "GT++ Agrichemistry Module"; - } - - @Override - public String getPluginAbbreviation() { - return "FARM"; - } -} diff --git a/src/main/java/gtPlusPlus/plugin/agrichem/block/AgrichemFluids.java b/src/main/java/gtPlusPlus/plugin/agrichem/block/AgrichemFluids.java index bd72654f0ae..aa5b22f8fe2 100644 --- a/src/main/java/gtPlusPlus/plugin/agrichem/block/AgrichemFluids.java +++ b/src/main/java/gtPlusPlus/plugin/agrichem/block/AgrichemFluids.java @@ -22,7 +22,7 @@ public class AgrichemFluids { public static Fluid mAcetone; public static Fluid mButanol; - public static void init() { + public static void preInit() { if (!FluidRegistry.isFluidRegistered("aceticacid")) { mAceticAcid = FluidUtils .generateFluidNoPrefix("aceticacid", "Acetic Acid", 200, new short[] { 97, 168, 96, 100 }, true); diff --git a/src/main/java/gtPlusPlus/plugin/agrichem/item/algae/ItemAgrichemBase.java b/src/main/java/gtPlusPlus/plugin/agrichem/item/algae/ItemAgrichemBase.java index b7784580fd3..379aed4dcf8 100644 --- a/src/main/java/gtPlusPlus/plugin/agrichem/item/algae/ItemAgrichemBase.java +++ b/src/main/java/gtPlusPlus/plugin/agrichem/item/algae/ItemAgrichemBase.java @@ -23,7 +23,7 @@ public class ItemAgrichemBase extends Item { - protected final IIcon base[]; + protected final IIcon[] base; /* * 0 - Algae Biomass 1 - Green Algae Biomass 2 - Brown Algae Biomass 3 - Golden-Brown Algae Biomass 4 - Red Algae diff --git a/src/main/java/gtPlusPlus/plugin/agrichem/item/algae/ItemAlgaeBase.java b/src/main/java/gtPlusPlus/plugin/agrichem/item/algae/ItemAlgaeBase.java index ac38b78936a..213ee6b47e4 100644 --- a/src/main/java/gtPlusPlus/plugin/agrichem/item/algae/ItemAlgaeBase.java +++ b/src/main/java/gtPlusPlus/plugin/agrichem/item/algae/ItemAlgaeBase.java @@ -2,7 +2,6 @@ import static gregtech.api.enums.Mods.GTPlusPlus; -import java.util.ArrayList; import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; @@ -188,11 +187,9 @@ public AlgaeGeneticData getSpeciesData(ItemStack aStack) { NBTTagCompound aTag; if (!aStack.hasTagCompound() || aStack.getTagCompound() .hasNoTags()) { - aTag = new NBTTagCompound(); AlgaeGeneticData aGenes; if (aStack.getItemDamage() < 3 || aStack.getItemDamage() > 5) { aGenes = new AlgaeGeneticData(); - aTag = aGenes.writeToNBT(); } else { byte aTemp, aLifespan; float aFert, aSpeed; @@ -212,10 +209,9 @@ public AlgaeGeneticData getSpeciesData(ItemStack aStack) { aFert, aSpeed, aLifespan, - 0, - new ArrayList<>()); - aTag = aGenes.writeToNBT(); + 0); } + aTag = aGenes.writeToNBT(); } else { aTag = aStack.getTagCompound(); } diff --git a/src/main/java/gtPlusPlus/plugin/agrichem/logic/AlgaeGeneticData.java b/src/main/java/gtPlusPlus/plugin/agrichem/logic/AlgaeGeneticData.java index ef36d736862..462d1271be4 100644 --- a/src/main/java/gtPlusPlus/plugin/agrichem/logic/AlgaeGeneticData.java +++ b/src/main/java/gtPlusPlus/plugin/agrichem/logic/AlgaeGeneticData.java @@ -1,7 +1,5 @@ package gtPlusPlus.plugin.agrichem.logic; -import java.util.ArrayList; - import net.minecraft.nbt.NBTTagCompound; public class AlgaeGeneticData { @@ -24,15 +22,12 @@ public class AlgaeGeneticData { private final float mProductionSpeed; - private final ArrayList mSpecialRequirements; - public AlgaeGeneticData() { - this(true, true, true, true, (byte) 0, 1f, 1f, (byte) 30, 0, new ArrayList<>()); + this(true, true, true, true, (byte) 0, 1f, 1f, (byte) 30, 0); } public AlgaeGeneticData(boolean isDominant, boolean requiresLight, boolean isSalt, boolean isFresh, - byte aTempTolerance, float aFertility, float aSpeed, byte aLifespan, int aGeneration, - ArrayList aRequirements) { + byte aTempTolerance, float aFertility, float aSpeed, byte aLifespan, int aGeneration) { mIsDominant = isDominant; mRequiresLight = requiresLight; mSaltWater = isSalt; @@ -42,7 +37,6 @@ public AlgaeGeneticData(boolean isDominant, boolean requiresLight, boolean isSal mProductionSpeed = aSpeed; mLifespan = aLifespan; mGeneration = aGeneration; - mSpecialRequirements = aRequirements; } public AlgaeGeneticData(NBTTagCompound aNBT) { @@ -67,7 +61,6 @@ public AlgaeGeneticData(NBTTagCompound aNBT) { mLifespan = aNBT.getByte("mLifespan"); mGeneration = aNBT.getInteger("mGeneration"); } - mSpecialRequirements = new ArrayList<>(); } /** @@ -109,10 +102,6 @@ public final int getGeneration() { return this.mGeneration; } - public final ArrayList getSpecialRequirements() { - return this.mSpecialRequirements; - } - public NBTTagCompound writeToNBT() { NBTTagCompound aGenes = new NBTTagCompound(); aGenes.setBoolean("mIsDominant", this.mIsDominant); diff --git a/src/main/java/gtPlusPlus/plugin/agrichem/logic/AlgaeGrowthRequirement.java b/src/main/java/gtPlusPlus/plugin/agrichem/logic/AlgaeGrowthRequirement.java deleted file mode 100644 index 07b89e5b5e3..00000000000 --- a/src/main/java/gtPlusPlus/plugin/agrichem/logic/AlgaeGrowthRequirement.java +++ /dev/null @@ -1,4 +0,0 @@ -package gtPlusPlus.plugin.agrichem.logic; - -public class AlgaeGrowthRequirement { -} diff --git a/src/main/java/gtPlusPlus/plugin/fixes/interfaces/IBugFix.java b/src/main/java/gtPlusPlus/plugin/fixes/interfaces/IBugFix.java deleted file mode 100644 index b35ad2c0634..00000000000 --- a/src/main/java/gtPlusPlus/plugin/fixes/interfaces/IBugFix.java +++ /dev/null @@ -1,6 +0,0 @@ -package gtPlusPlus.plugin.fixes.interfaces; - -public interface IBugFix { - - boolean isFixValid(); -} diff --git a/src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBackgroundMusicFix.java b/src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBackgroundMusicFix.java deleted file mode 100644 index 386fac65ee8..00000000000 --- a/src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBackgroundMusicFix.java +++ /dev/null @@ -1,64 +0,0 @@ -package gtPlusPlus.plugin.fixes.vanilla; - -import java.util.Timer; -import java.util.TimerTask; - -import gtPlusPlus.api.interfaces.IPlugin; -import gtPlusPlus.core.config.ASMConfiguration; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.plugin.fixes.interfaces.IBugFix; -import gtPlusPlus.plugin.fixes.vanilla.music.MusicTocker; - -public class VanillaBackgroundMusicFix implements IBugFix { - - private final IPlugin mParent; - private final boolean enabled; - private MusicTocker mFixInstance; - - public VanillaBackgroundMusicFix(IPlugin minstance) { - mParent = minstance; - if (ASMConfiguration.general.enableWatchdogBGM > 0 && Utils.isClient()) { - mParent.log("[BGM] Registering BGM delay Fix."); - enabled = true; - mFixInstance = new MusicTocker(mParent); - } else if (ASMConfiguration.general.enableWatchdogBGM > 0 && Utils.isServer()) { - mParent.log("[BGM] Tried registering BGM delay Fix on Server, disabling."); - enabled = false; - } else { - mParent.log("[BGM] Not registering BGM delay Fix."); - enabled = false; - } - } - - @Override - public boolean isFixValid() { - return enabled; - } - - public void manage() { - if (ASMConfiguration.general.enableWatchdogBGM > 0 && Utils.isClient()) { - TimerTask task = new ManageTask(this.mFixInstance); - Timer timer = new Timer("BGM-WatchDog"); - long delay = 1000 * 60; - timer.scheduleAtFixedRate(task, delay, 5000); - } - } - - private static class ManageTask extends TimerTask { - - private final MusicTocker A; - - public ManageTask(MusicTocker a) { - A = a; - } - - @Override - public void run() { - if (ASMConfiguration.general.enableWatchdogBGM > 0 && Utils.isClient()) { - if (!A.mVanillaManager) { - A.run(); - } - } - } - } -} diff --git a/src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java b/src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java index 8395f7b3f78..0d1151abaae 100644 --- a/src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java +++ b/src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java @@ -10,39 +10,31 @@ import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gregtech.asm.GTCorePlugin; -import gtPlusPlus.api.interfaces.IPlugin; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.reflect.ReflectionUtils; -import gtPlusPlus.plugin.fixes.interfaces.IBugFix; // TODO move this as a mixin in hodgepodge -public class VanillaBedHeightFix implements IBugFix { +public class VanillaBedHeightFix { private final Method mSleepInBedAt; - private final IPlugin mParent; - public VanillaBedHeightFix(IPlugin minstance) { - mParent = minstance; - Method m = ReflectionUtils.getMethod( - EntityPlayer.class, - GTCorePlugin.isDevEnv() ? "sleepInBedAt" : "func_71018_a", - int.class, - int.class, - int.class); + public VanillaBedHeightFix() { + Method m = null; + try { + m = EntityPlayer.class.getDeclaredMethod( + GTCorePlugin.isDevEnv() ? "sleepInBedAt" : "func_71018_a", + int.class, + int.class, + int.class); + } catch (NoSuchMethodException ignored) {} if (m != null) { mSleepInBedAt = m; - mParent.log("Registering Bed Height Fix."); + Logger.INFO("Registering Bed Height Fix."); MinecraftForge.EVENT_BUS.register(this); } else { mSleepInBedAt = null; } } - @Override - public boolean isFixValid() { - return mSleepInBedAt != null; - } - /** * Fix created by deNULL - * https://github.com/deNULL/BugPatch/blob/master/src/main/java/ru/denull/BugPatch/mod/ClientEvents.java#L45 @@ -52,7 +44,7 @@ public boolean isFixValid() { @SubscribeEvent(priority = EventPriority.HIGHEST) public void playerSleepInBed(PlayerSleepInBedEvent evt) { Logger.WARNING("Sleep Event Detected. Player is sleeping at Y: " + evt.y); - if (evt.y <= 0 && isFixValid()) { + if (evt.y <= 0) { int correctY = 256 + evt.y; if (correctY <= 0) { Logger.WARNING( @@ -73,9 +65,6 @@ public void playerSleepInBed(PlayerSleepInBedEvent evt) { Logger.WARNING("Encountered an error trying to sleep."); } } - } else if (!isFixValid()) { - Logger.WARNING( - "Method sleepInBedAt was not found in EntityPlayer (wrong MC and/or Forge version?), unable to fix"); } } } diff --git a/src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaFixesCore.java b/src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaFixesCore.java deleted file mode 100644 index b6cfb9d3bac..00000000000 --- a/src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaFixesCore.java +++ /dev/null @@ -1,101 +0,0 @@ -package gtPlusPlus.plugin.fixes.vanilla; - -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; - -import gtPlusPlus.api.interfaces.IPlugin; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.plugin.manager.CoreManager; - -// Called by Core_Manager#veryEarlyInit -@SuppressWarnings("unused") -public class VanillaFixesCore implements IPlugin { - - static final VanillaFixesCore mInstance; - static final VanillaBedHeightFix mBedFixInstance; - static final VanillaBackgroundMusicFix mMusicFixInstance; - - static { - mInstance = new VanillaFixesCore(); - mBedFixInstance = new VanillaBedHeightFix(mInstance); - mMusicFixInstance = new VanillaBackgroundMusicFix(mInstance); - mInstance.log("Preparing " + mInstance.getPluginName() + " for use."); - } - - VanillaFixesCore() { - CoreManager.registerPlugin(this); - } - - @Override - public boolean preInit() { - return fixVanillaOD(); - } - - @Override - public boolean init() { - return true; - } - - @Override - public boolean postInit() { - return true; - } - - @Override - public boolean serverStart() { - mMusicFixInstance.manage(); - return true; - } - - @Override - public boolean serverStop() { - return true; - } - - @Override - public String getPluginName() { - return "GT++ Vanilla Fixes Module"; - } - - @Override - public String getPluginAbbreviation() { - return "VFIX"; - } - - private boolean fixVanillaOD() { - registerToOreDict(ItemUtils.getSimpleStack(Items.blaze_rod), "rodBlaze"); - registerToOreDict(ItemUtils.getSimpleStack(Items.nether_wart), "cropNetherWart"); - registerToOreDict(ItemUtils.getSimpleStack(Items.reeds), "sugarcane"); - registerToOreDict(ItemUtils.getSimpleStack(Items.paper), "paper"); - registerToOreDict(ItemUtils.getSimpleStack(Items.ender_pearl), "enderpearl"); - registerToOreDict(ItemUtils.getSimpleStack(Items.bone), "bone"); - registerToOreDict(ItemUtils.getSimpleStack(Items.gunpowder), "gunpowder"); - registerToOreDict(ItemUtils.getSimpleStack(Items.string), "string"); - registerToOreDict(ItemUtils.getSimpleStack(Items.nether_star), "netherStar"); - registerToOreDict(ItemUtils.getSimpleStack(Items.leather), "leather"); - registerToOreDict(ItemUtils.getSimpleStack(Items.feather), "feather"); - registerToOreDict(ItemUtils.getSimpleStack(Items.egg), "egg"); - registerToOreDict(ItemUtils.getSimpleStack(Blocks.end_stone), "endstone"); - registerToOreDict(ItemUtils.getSimpleStack(Blocks.vine), "vine"); - registerToOreDict(ItemUtils.getSimpleStack(Blocks.cactus), "blockCactus"); - registerToOreDict(ItemUtils.getSimpleStack(Blocks.grass), "grass"); - registerToOreDict(ItemUtils.getSimpleStack(Blocks.obsidian), "obsidian"); - registerToOreDict(ItemUtils.getSimpleStack(Blocks.crafting_table), "workbench"); - return true; - } - - private void registerToOreDict(ItemStack aStack, String aString) { - if (aStack.getItem() == Items.blaze_rod) { - mInstance - .log("Registering " + aStack.getDisplayName() + " to OreDictionary under the tag '" + aString + "'."); - } else { - mInstance.log( - "Registering " + aStack.getDisplayName() - + " to OreDictionary under the tag '" - + aString - + "'. (Added to Forge in 1.8.9)"); - } - ItemUtils.addItemToOreDictionary(aStack, aString); - } -} diff --git a/src/main/java/gtPlusPlus/plugin/fixes/vanilla/music/MusicTocker.java b/src/main/java/gtPlusPlus/plugin/fixes/vanilla/music/MusicTocker.java deleted file mode 100644 index 46dec56124d..00000000000 --- a/src/main/java/gtPlusPlus/plugin/fixes/vanilla/music/MusicTocker.java +++ /dev/null @@ -1,131 +0,0 @@ -package gtPlusPlus.plugin.fixes.vanilla.music; - -import java.lang.reflect.Field; -import java.util.Random; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.ISound; -import net.minecraft.client.audio.MusicTicker; -import net.minecraft.client.audio.PositionedSoundRecord; -import net.minecraft.util.MathHelper; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.objects.XSTR; -import gtPlusPlus.api.interfaces.IPlugin; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.config.ASMConfiguration; -import gtPlusPlus.core.util.reflect.ReflectionUtils; - -@SideOnly(Side.CLIENT) -public class MusicTocker extends MusicTicker implements Runnable { - - private final Random mRandom = new XSTR(); - private final Minecraft mMinecraft; - private final IPlugin mPlugin; - private ISound mSound; - private int mTimeUntilNextTrack = 100; - - public boolean mVanillaManager = false; - - public MusicTocker(IPlugin aPlugin) { - super(Minecraft.getMinecraft()); - mPlugin = aPlugin; - mMinecraft = Minecraft.getMinecraft(); - mPlugin.log("[BGM] Created BGM Watchdog with a delay of " + getDelay() + " ticks."); - inject(); - } - - private static int getDelay() { - return ASMConfiguration.general.enableWatchdogBGM; - } - - private boolean inject() { - mPlugin.log("[BGM] Inject new Watchdog into Minecraft instance."); - ReflectionUtils.setField(Minecraft.getMinecraft(), "mcMusicTicker", this); - mPlugin.log("[BGM] Verifying..."); - Field f = ReflectionUtils.getField(Minecraft.class, "mcMusicTicker"); - try { - Object m = f.get(mMinecraft); - if (m != null) { - if (m instanceof MusicTocker || m.getClass() - .isAssignableFrom(getClass())) { - mPlugin.log("[BGM] Success."); - return true; - } else if (m instanceof MusicTicker || m.getClass() - .isAssignableFrom(MusicTicker.class)) { - mPlugin.log("[BGM] Found Vanilla MusicTicker, but may be instance of MusicTocker."); - return true; - } - } - } catch (IllegalArgumentException | IllegalAccessException e) {} - - mPlugin.log("[BGM] Failed."); - return false; - } - - private void updateInternalNumber() { - if (ReflectionUtils.doesFieldExist(getClass(), "field_147676_d")) { - ReflectionUtils.setField(this, "field_147676_d", mTimeUntilNextTrack); - } - } - - private void updateInternalSound(ISound aSound) { - if (ReflectionUtils.doesFieldExist(getClass(), "field_147678_c")) { - ReflectionUtils.setField(this, "field_147678_c", aSound); - } - } - - /** - * Updates the JList with a new model. - */ - @Override - public void update() { - run(); - mVanillaManager = true; - } - - @Override - public void run() { - MusicType musictype = this.mMinecraft.func_147109_W(); - - if (this.mSound != null) { - if (!musictype.getMusicTickerLocation() - .equals(this.mSound.getPositionedSoundLocation())) { - this.mMinecraft.getSoundHandler() - .stopSound(this.mSound); - this.mTimeUntilNextTrack = MathHelper.getRandomIntegerInRange(this.mRandom, 0, getDelay() / 2); - updateInternalNumber(); - Logger.INFO("[BGM] Adjusted BGM delay 1"); - } - if (!this.mMinecraft.getSoundHandler() - .isSoundPlaying(this.mSound)) { - this.mSound = null; - updateInternalSound(null); - this.mTimeUntilNextTrack = Math.min( - MathHelper.getRandomIntegerInRange(this.mRandom, getDelay(), getDelay() * 2), - this.mTimeUntilNextTrack); - updateInternalNumber(); - Logger.INFO("[BGM] Adjusted BGM delay 2"); - } - } else if (this.mSound == null && this.mTimeUntilNextTrack-- <= 0) { - this.mSound = PositionedSoundRecord.func_147673_a(musictype.getMusicTickerLocation()); - updateInternalSound(mSound); - this.mMinecraft.getSoundHandler() - .playSound(this.mSound); - this.mTimeUntilNextTrack = getDelay(); - updateInternalNumber(); - Logger.INFO("[BGM] Adjusted BGM 3"); - } - - /* - * try { // Get Value stored in underlying object. Integer aRealDelay = (Integer) - * ReflectionUtils.getField(getClass(), "field_147676_d").get(this); if (aRealDelay == null) { return; } else { - * if (aRealDelay > getDelay() || aRealDelay <= 0) { this.mTimeUntilNextTrack = getDelay(); - * updateInternalNumber(); } else { this.mTimeUntilNextTrack -= 5 * 20; updateInternalNumber(); } aRealDelay = - * (Integer) ReflectionUtils.getField(getClass(), "field_147676_d").get(this); - * Logger.INFO("[BGM] Adjusted BGM - "+aRealDelay); } } catch (IllegalArgumentException | IllegalAccessException - * e) { } - */ - } -} diff --git a/src/main/java/gtPlusPlus/plugin/manager/CoreManager.java b/src/main/java/gtPlusPlus/plugin/manager/CoreManager.java deleted file mode 100644 index f618be2d9f7..00000000000 --- a/src/main/java/gtPlusPlus/plugin/manager/CoreManager.java +++ /dev/null @@ -1,95 +0,0 @@ -package gtPlusPlus.plugin.manager; - -import java.util.ArrayList; - -import gtPlusPlus.api.interfaces.IPlugin; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.reflect.ReflectionUtils; - -public class CoreManager { - - public static ArrayList mPlugins = new ArrayList<>(); - - /** - * @param plugin - Dynamically registers the plugin for loading. - */ - public static void registerPlugin(IPlugin plugin) { - Logger.INFO("[Plugin] " + "Registered " + plugin.getPluginName() + "."); - mPlugins.add(plugin); - } - - /** - * Dynamically loads all class objects within the "gtPlusPlus.plugin" package. - */ - public static void veryEarlyInit() { - if (ReflectionUtils.dynamicallyLoadClassesInPackage("gtPlusPlus.plugin")) { - Logger.INFO("[Plugin] Plugin System loaded."); - } - } - - public static boolean preInit() { - try { - for (IPlugin h : mPlugins) { - if (h.preInit()) { - Logger.INFO("[Plugin] Completed Pre-Init Phase for " + h.getPluginName() + "."); - } else { - Logger.INFO("[Plugin] Failed during Pre-Init Phase for " + h.getPluginName() + "."); - } - } - return true; - } catch (Throwable ignored) {} - return false; - } - - public static boolean init() { - try { - for (IPlugin h : mPlugins) { - if (h.init()) { - Logger.INFO("[Plugin] Completed Init Phase for " + h.getPluginName() + "."); - } else { - Logger.INFO("[Plugin] Failed during Init Phase for " + h.getPluginName() + "."); - } - } - return true; - } catch (Throwable ignored) {} - return false; - } - - public static boolean postInit() { - try { - for (IPlugin h : mPlugins) { - if (h.postInit()) { - Logger.INFO("[Plugin] Completed Post-Init Phase for " + h.getPluginName() + "."); - } else { - Logger.INFO("[Plugin] Failed during Post-Init Phase for " + h.getPluginName() + "."); - } - } - return true; - } catch (Throwable ignored) {} - return false; - } - - public static void serverStart() { - try { - for (IPlugin h : mPlugins) { - if (h.serverStart()) { - Logger.INFO("[Plugin] Completed Server Start Phase for " + h.getPluginName() + "."); - } else { - Logger.INFO("[Plugin] Failed during Server Start Phase for " + h.getPluginName() + "."); - } - } - } catch (Throwable ignored) {} - } - - public static void serverStop() { - try { - for (IPlugin h : mPlugins) { - if (h.serverStop()) { - Logger.INFO("[Plugin] Completed Server Stop Phase for " + h.getPluginName() + "."); - } else { - Logger.INFO("[Plugin] Failed during Server Stop Phase for " + h.getPluginName() + "."); - } - } - } catch (Throwable ignored) {} - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechOrePrefixes.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechOrePrefixes.java index fedd28f3422..9f829360352 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechOrePrefixes.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechOrePrefixes.java @@ -143,7 +143,7 @@ public enum GregtechOrePrefixes { */ public int mMaterialGenerationBits = 0; - private GregtechOrePrefixes(final String aRegularLocalName, final String aLocalizedMaterialPre, + GregtechOrePrefixes(final String aRegularLocalName, final String aLocalizedMaterialPre, final String aLocalizedMaterialPost, final boolean aIsUnificatable, final boolean aIsMaterialBased, final boolean aIsSelfReferencing, final boolean aIsContainer, final boolean aDontUnificateActively, final boolean aIsUsedForBlocks, final boolean aAllowNormalRecycling, final boolean aGenerateDefaultItem, @@ -277,18 +277,6 @@ public static String replacePrefix(final String aOre, final GregtechOrePrefixes return ""; } - public static GregtechOrePrefixes getPrefix(final String aPrefixName) { - return getPrefix(aPrefixName, null); - } - - public static GregtechOrePrefixes getPrefix(final String aPrefixName, final GregtechOrePrefixes aReplacement) { - final Object tObject = GTUtility.getFieldContent(GregtechOrePrefixes.class, aPrefixName, false, false); - if ((tObject != null) && (tObject instanceof GregtechOrePrefixes)) { - return (GregtechOrePrefixes) tObject; - } - return aReplacement; - } - public static Materials getMaterial(final String aOre) { return Materials.get(stripPrefix(aOre)); } @@ -302,7 +290,7 @@ public static Materials getRealMaterial(final String aOre, final GregtechOrePref } public static boolean isInstanceOf(final String aName, final GregtechOrePrefixes aPrefix) { - return aName == null ? false : aName.startsWith(aPrefix.toString()); + return aName != null && aName.startsWith(aPrefix.toString()); } public boolean add(final ItemStack aStack) { @@ -717,7 +705,7 @@ public enum GT_Materials implements IColorModulationContainer, ISubTagContainer */ public final Fluid mStandardMoltenFluid = null; - private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, + GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, final int aToolDurability, final int aToolQuality, final boolean aUnificatable) { this.mUnificatable = aUnificatable; this.mMaterialInto = this; @@ -735,7 +723,7 @@ private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final } } - private GT_Materials(final GT_Materials aMaterialInto, final boolean aReRegisterIntoThis) { + GT_Materials(final GT_Materials aMaterialInto, final boolean aReRegisterIntoThis) { this.mUnificatable = false; this.mDefaultLocalName = aMaterialInto.mDefaultLocalName; this.mMaterialInto = aMaterialInto.mMaterialInto; @@ -767,7 +755,7 @@ private GT_Materials(final GT_Materials aMaterialInto, final boolean aReRegister * @param aBlastFurnaceRequired If this requires a Blast Furnace. * @param aColor Vanilla MC Wool Color which comes the closest to this. */ - private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, + GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, final int aToolDurability, final int aToolQuality, final int aTypes, final int aR, final int aG, final int aB, final int aA, final String aLocalName, final int aFuelType, final int aFuelPower, final int aMeltingPoint, final int aBlastFurnaceTemp, final boolean aBlastFurnaceRequired, @@ -799,7 +787,7 @@ private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final } } - private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, + GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, final int aToolDurability, final int aToolQuality, final int aTypes, final int aR, final int aG, final int aB, final int aA, final String aLocalName, final int aFuelType, final int aFuelPower, final int aMeltingPoint, final int aBlastFurnaceTemp, final boolean aBlastFurnaceRequired, @@ -833,7 +821,7 @@ private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final /** * @param aElement The Element Enum represented by this Material */ - private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, + GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, final int aToolDurability, final int aToolQuality, final int aTypes, final int aR, final int aG, final int aB, final int aA, final String aLocalName, final int aFuelType, final int aFuelPower, final int aMeltingPoint, final int aBlastFurnaceTemp, final boolean aBlastFurnaceRequired, @@ -872,7 +860,7 @@ private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final this.mAspects.addAll(aAspects); } - private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, + GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, final int aToolDurability, final int aToolQuality, final int aTypes, final int aR, final int aG, final int aB, final int aA, final String aLocalName, final int aFuelType, final int aFuelPower, final int aMeltingPoint, final int aBlastFurnaceTemp, final boolean aBlastFurnaceRequired, @@ -905,7 +893,7 @@ private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final null); } - private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, + GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, final int aToolDurability, final int aToolQuality, final int aTypes, final int aR, final int aG, final int aB, final int aA, final String aLocalName, final int aFuelType, final int aFuelPower, final int aMeltingPoint, final int aBlastFurnaceTemp, final boolean aBlastFurnaceRequired, @@ -970,18 +958,6 @@ private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final } } - public static GT_Materials get(final String aMaterialName) { - final Object tObject = GTUtility.getFieldContent(GT_Materials.class, aMaterialName, false, false); - if ((tObject != null) && (tObject instanceof GT_Materials)) { - return (GT_Materials) tObject; - } - return _NULL; - } - - public static GT_Materials getRealMaterial(final String aMaterialName) { - return get(aMaterialName).mMaterialInto; - } - /** * Called in preInit with the Config to set Values. * diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTERTGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTERTGenerator.java index d94c764e537..9b51724b35a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTERTGenerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/MTERTGenerator.java @@ -23,8 +23,8 @@ import gtPlusPlus.core.lib.GTPPCore; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import tectech.util.TTUtility; public class MTERTGenerator extends MTEBasicGenerator { @@ -45,13 +45,11 @@ public int removeDayOfTime() { // Generates fuel value based on MC days public static int convertDaysToTicks(float days) { - int value = 0; - value = MathUtils.roundToClosestInt(20 * 86400 * days); - return value; + return MathUtils.roundToClosestInt(20 * 86400 * days); } public static long getTotalEUGenerated(int ticks, int voltage) { - return ticks * voltage; + return (long) ticks * voltage; } @Override @@ -84,18 +82,7 @@ public void loadNBTData(NBTTagCompound aNBT) { this.mDaysRemaining = aNBT.getInteger("mDaysRemaining"); this.mDayTick = aNBT.getInteger("mDayTick"); this.mNewTier = aNBT.getByte("mNewTier"); - - try { - ReflectionUtils.setByte(this, "mTier", this.mNewTier); - } catch (Exception e) { - if (this.getBaseMetaTileEntity() != null) { - IGregTechTileEntity thisTile = this.getBaseMetaTileEntity(); - if (thisTile.isAllowedToWork() || thisTile.isActive()) { - thisTile.setActive(false); - } - } - } - + TTUtility.setTier(this.mNewTier, this); final NBTTagList list = aNBT.getTagList("mRecipeItem", 10); final NBTTagCompound data = list.getCompoundTagAt(0); ItemStack lastUsedFuel = ItemStack.loadItemStackFromNBT(data); @@ -111,7 +98,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()) { if (this.mDayTick < 24000) { this.mDayTick++; - } else if (this.mDayTick >= 24000) { + } else { this.mDayTick = 0; this.mDaysRemaining = this.removeDayOfTime(); } @@ -327,7 +314,7 @@ public int getFuelValue(ItemStack aStack) { } else { mTier2 = 0; } - ReflectionUtils.setByte(this, "mTier", mTier2); + TTUtility.setTier(mTier2, this); this.mNewTier = mTier2; } catch (Exception e) { Logger.WARNING("Failed setting mTier."); diff --git a/src/main/java/gtnhlanth/common/hatch/MTEHatchBeamlineConnector.java b/src/main/java/gtnhlanth/common/hatch/MTEHatchBeamlineConnector.java index 9e223ee9a10..a1e43ad1745 100644 --- a/src/main/java/gtnhlanth/common/hatch/MTEHatchBeamlineConnector.java +++ b/src/main/java/gtnhlanth/common/hatch/MTEHatchBeamlineConnector.java @@ -4,16 +4,14 @@ import static tectech.util.CommonValues.MOVE_AT; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.reflect.FieldUtils; - import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.mixin.interfaces.accessors.EntityPlayerMPAccessor; import gtnhlanth.common.beamline.IConnectsToBeamline; import tectech.mechanics.dataTransport.DataPacket; import tectech.util.TTUtility; @@ -76,11 +74,8 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye if (aBaseMetaTileEntity.isClientSide()) { return true; } - try { - EntityPlayerMP player = (EntityPlayerMP) aPlayer; - clientLocale = (String) FieldUtils.readField(player, "translator", true); - } catch (Exception e) { - clientLocale = "en_US"; + if (aPlayer instanceof EntityPlayerMPAccessor) { + clientLocale = ((EntityPlayerMPAccessor) aPlayer).gt5u$getTranslator(); } return true; } diff --git a/src/main/java/gtnhlanth/loader/RecipeLoader.java b/src/main/java/gtnhlanth/loader/RecipeLoader.java index 6eb4fc8c62d..71d8eaa06c4 100644 --- a/src/main/java/gtnhlanth/loader/RecipeLoader.java +++ b/src/main/java/gtnhlanth/loader/RecipeLoader.java @@ -138,7 +138,6 @@ import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.TierEU; -import gregtech.api.interfaces.IRecipeMutableAccess; import gregtech.api.util.GTLog; import gregtech.api.util.GTModHandler; import gregtech.api.util.GTOreDictUnificator; @@ -146,6 +145,7 @@ import gregtech.api.util.GTRecipeBuilder; import gregtech.api.util.GTRecipeConstants; import gregtech.api.util.GTUtility; +import gregtech.mixin.interfaces.accessors.IRecipeMutableAccess; import gtnhlanth.Tags; import gtnhlanth.common.item.MaskList; import gtnhlanth.common.register.BotWerkstoffMaterialPool; diff --git a/src/main/java/kubatech/tileentity/gregtech/multiblock/eigbuckets/EIGStemBucket.java b/src/main/java/kubatech/tileentity/gregtech/multiblock/eigbuckets/EIGStemBucket.java index 76ba7620c6f..5f92f05d38b 100644 --- a/src/main/java/kubatech/tileentity/gregtech/multiblock/eigbuckets/EIGStemBucket.java +++ b/src/main/java/kubatech/tileentity/gregtech/multiblock/eigbuckets/EIGStemBucket.java @@ -10,7 +10,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.IPlantable; -import gregtech.mixin.interfaces.IBlockStemAccesor; +import gregtech.mixin.interfaces.accessors.IBlockStemAccessor; import kubatech.api.eig.EIGBucket; import kubatech.api.eig.EIGDropTable; import kubatech.api.eig.IEIGBucketFactory; @@ -113,7 +113,7 @@ public void recalculateDrops(MTEExtremeIndustrialGreenhouse greenhouse) { 0, 0); if (!(stemBlock instanceof BlockStem)) return; - Block cropBlock = ((IBlockStemAccesor) stemBlock).getCropBlock(); + Block cropBlock = ((IBlockStemAccessor) stemBlock).gt5u$getCropBlock(); if (cropBlock == null || cropBlock == Blocks.air) return; // if we know some crops needs a specific metadata, remap here int metadata = 0; diff --git a/src/main/java/tectech/thing/item/ItemEuMeterGT.java b/src/main/java/tectech/thing/item/ItemEuMeterGT.java index 72928360f3c..ccc9bdb6082 100644 --- a/src/main/java/tectech/thing/item/ItemEuMeterGT.java +++ b/src/main/java/tectech/thing/item/ItemEuMeterGT.java @@ -17,14 +17,13 @@ import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.ForgeDirection; -import org.apache.commons.lang3.reflect.FieldUtils; - import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.metatileentity.implementations.MTECable; import gregtech.api.util.GTUtility; +import gregtech.mixin.interfaces.accessors.EntityPlayerMPAccessor; import tectech.Reference; import tectech.TecTech; import tectech.util.CommonValues; @@ -49,11 +48,10 @@ public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWor return aPlayer instanceof EntityPlayerMP; } if (aPlayer instanceof EntityPlayerMP && !aPlayer.isSneaking() && tTileEntity instanceof IGregTechTileEntity) { - String clientLocale; - try { - EntityPlayerMP player = (EntityPlayerMP) aPlayer; - clientLocale = (String) FieldUtils.readField(player, "translator", true); - } catch (Exception e) { + final String clientLocale; + if (aPlayer instanceof EntityPlayerMPAccessor) { + clientLocale = ((EntityPlayerMPAccessor) aPlayer).gt5u$getTranslator(); + } else { clientLocale = "en_US"; } diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataConnector.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataConnector.java index 484fcdaff19..912457718b4 100644 --- a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataConnector.java +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataConnector.java @@ -5,15 +5,12 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.reflect.FieldUtils; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Dyes; @@ -22,6 +19,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.MTEHatch; import gregtech.api.objects.GTRenderedTexture; +import gregtech.mixin.interfaces.accessors.EntityPlayerMPAccessor; import tectech.mechanics.dataTransport.DataPacket; import tectech.mechanics.pipe.IConnectsToDataPipe; import tectech.util.CommonValues; @@ -119,11 +117,8 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye if (aBaseMetaTileEntity.isClientSide()) { return true; } - try { - EntityPlayerMP player = (EntityPlayerMP) aPlayer; - clientLocale = (String) FieldUtils.readField(player, "translator", true); - } catch (Exception e) { - clientLocale = "en_US"; + if (aPlayer instanceof EntityPlayerMPAccessor) { + clientLocale = ((EntityPlayerMPAccessor) aPlayer).gt5u$getTranslator(); } return true; } diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataItemsInput.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataItemsInput.java index 533c9cb6954..4db38300d49 100644 --- a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataItemsInput.java +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataItemsInput.java @@ -15,20 +15,18 @@ import java.util.stream.Collectors; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; -import org.apache.commons.lang3.reflect.FieldUtils; - import gregtech.api.enums.Dyes; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.MTEHatchDataAccess; import gregtech.api.objects.GTRenderedTexture; +import gregtech.mixin.interfaces.accessors.EntityPlayerMPAccessor; import tectech.mechanics.dataTransport.InventoryDataPacket; import tectech.mechanics.pipe.IConnectsToDataPipe; import tectech.recipe.TTRecipeAdder; @@ -89,11 +87,8 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye if (aBaseMetaTileEntity.isClientSide()) { return true; } - try { - EntityPlayerMP player = (EntityPlayerMP) aPlayer; - clientLocale = (String) FieldUtils.readField(player, "translator", true); - } catch (Exception e) { - clientLocale = "en_US"; + if (aPlayer instanceof EntityPlayerMPAccessor) { + clientLocale = ((EntityPlayerMPAccessor) aPlayer).gt5u$getTranslator(); } return true; } diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchParam.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchParam.java index 259bc4d164c..2bf8a2c3120 100644 --- a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchParam.java +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchParam.java @@ -7,15 +7,12 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.reflect.FieldUtils; - import com.gtnewhorizons.modularui.api.drawable.IDrawable; import com.gtnewhorizons.modularui.api.math.Alignment; import com.gtnewhorizons.modularui.api.screen.ModularWindow; @@ -37,6 +34,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.MTEHatch; import gregtech.api.objects.GTRenderedTexture; +import gregtech.mixin.interfaces.accessors.EntityPlayerMPAccessor; import tectech.TecTech; import tectech.thing.gui.TecTechUITextures; import tectech.util.CommonValues; @@ -208,11 +206,8 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye if (aBaseMetaTileEntity.isClientSide()) { return true; } - try { - EntityPlayerMP player = (EntityPlayerMP) aPlayer; - clientLocale = (String) FieldUtils.readField(player, "translator", true); - } catch (Exception e) { - clientLocale = "en_US"; + if (aPlayer instanceof EntityPlayerMPAccessor) { + clientLocale = ((EntityPlayerMPAccessor) aPlayer).gt5u$getTranslator(); } GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); return true; diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchParamText.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchParamText.java index 7efe4e1fd08..a9c2ef40cd4 100644 --- a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchParamText.java +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchParamText.java @@ -3,15 +3,12 @@ import static net.minecraft.util.StatCollector.translateToLocalFormatted; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.reflect.FieldUtils; - import com.gtnewhorizons.modularui.api.drawable.IDrawable; import com.gtnewhorizons.modularui.api.math.Alignment; import com.gtnewhorizons.modularui.api.math.Color; @@ -28,6 +25,7 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.mixin.interfaces.accessors.EntityPlayerMPAccessor; import tectech.TecTech; import tectech.thing.gui.TecTechUITextures; import tectech.util.CommonValues; @@ -145,11 +143,8 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye if (aBaseMetaTileEntity.isClientSide()) { return true; } - try { - EntityPlayerMP player = (EntityPlayerMP) aPlayer; - clientLocale = (String) FieldUtils.readField(player, "translator", true); - } catch (Exception e) { - clientLocale = "en_US"; + if (aPlayer instanceof EntityPlayerMPAccessor) { + clientLocale = ((EntityPlayerMPAccessor) aPlayer).gt5u$getTranslator(); } GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); return true; diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchRack.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchRack.java index 0d98f127426..bf77847d503 100644 --- a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchRack.java +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchRack.java @@ -12,14 +12,11 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; -import org.apache.commons.lang3.reflect.FieldUtils; - import com.gtnewhorizons.modularui.api.math.Pos2d; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; @@ -40,6 +37,7 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.MTEHatch; import gregtech.api.objects.GTRenderedTexture; +import gregtech.mixin.interfaces.accessors.EntityPlayerMPAccessor; import tectech.TecTech; import tectech.loader.ConfigHandler; import tectech.thing.gui.TecTechUITextures; @@ -167,11 +165,8 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye if (aBaseMetaTileEntity.isClientSide()) { return true; } - try { - EntityPlayerMP player = (EntityPlayerMP) aPlayer; - clientLocale = (String) FieldUtils.readField(player, "translator", true); - } catch (Exception e) { - clientLocale = "en_US"; + if (aPlayer instanceof EntityPlayerMPAccessor) { + clientLocale = ((EntityPlayerMPAccessor) aPlayer).gt5u$getTranslator(); } // if(aBaseMetaTileEntity.isActive()) // aPlayer.addChatComponentMessage(new ChatComponentText("It is still active...")); diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchUncertainty.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchUncertainty.java index f8c2587269f..38b90e47709 100644 --- a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchUncertainty.java +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchUncertainty.java @@ -12,15 +12,12 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.reflect.FieldUtils; - import com.gtnewhorizons.modularui.api.GlStateManager; import com.gtnewhorizons.modularui.api.drawable.UITexture; import com.gtnewhorizons.modularui.api.math.Pos2d; @@ -43,6 +40,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.MTEHatch; import gregtech.api.objects.GTRenderedTexture; +import gregtech.mixin.interfaces.accessors.EntityPlayerMPAccessor; import tectech.TecTech; import tectech.thing.gui.TecTechUITextures; import tectech.util.CommonValues; @@ -192,11 +190,8 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye if (aBaseMetaTileEntity.isClientSide()) { return true; } - try { - EntityPlayerMP player = (EntityPlayerMP) aPlayer; - clientLocale = (String) FieldUtils.readField(player, "translator", true); - } catch (Exception e) { - clientLocale = "en_US"; + if (aPlayer instanceof EntityPlayerMPAccessor) { + clientLocale = ((EntityPlayerMPAccessor) aPlayer).gt5u$getTranslator(); } GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); return true; diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessComputationInput.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessComputationInput.java index 94f8181566d..11f79a2ee89 100644 --- a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessComputationInput.java +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessComputationInput.java @@ -1,12 +1,9 @@ package tectech.thing.metaTileEntity.hatch; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -import org.apache.commons.lang3.reflect.FieldUtils; - import com.gtnewhorizons.modularui.api.math.Alignment; import com.gtnewhorizons.modularui.api.math.Color; import com.gtnewhorizons.modularui.api.screen.ModularWindow; @@ -29,8 +26,6 @@ public class MTEHatchWirelessComputationInput extends MTEHatchDataInput implemen public long requiredComputation = 10000; - private String clientLocale = "en_US"; - public MTEHatchWirelessComputationInput(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier); } @@ -46,12 +41,6 @@ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - try { - EntityPlayerMP player = (EntityPlayerMP) aPlayer; - clientLocale = (String) FieldUtils.readField(player, "translator", true); - } catch (Exception e) { - clientLocale = "en_US"; - } if (!aPlayer.isUsingItem()) { GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); } diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessDataItemsInput.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessDataItemsInput.java index f3e4619c05b..369e99725e3 100644 --- a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessDataItemsInput.java +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessDataItemsInput.java @@ -12,12 +12,9 @@ import java.util.stream.Collectors; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; -import org.apache.commons.lang3.reflect.FieldUtils; - import com.google.common.collect.ImmutableList; import gregtech.api.enums.Dyes; @@ -27,6 +24,7 @@ import gregtech.api.metatileentity.implementations.MTEHatchDataAccess; import gregtech.api.objects.GTRenderedTexture; import gregtech.common.WirelessDataStore; +import gregtech.mixin.interfaces.accessors.EntityPlayerMPAccessor; import tectech.util.CommonValues; import tectech.util.TTUtility; @@ -89,11 +87,8 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye if (aBaseMetaTileEntity.isClientSide()) { return true; } - try { - EntityPlayerMP player = (EntityPlayerMP) aPlayer; - clientLocale = (String) FieldUtils.readField(player, "translator", true); - } catch (Exception e) { - clientLocale = "en_US"; + if (aPlayer instanceof EntityPlayerMPAccessor) { + clientLocale = ((EntityPlayerMPAccessor) aPlayer).gt5u$getTranslator(); } return true; } diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/MTEResearchStation.java b/src/main/java/tectech/thing/metaTileEntity/multi/MTEResearchStation.java index 153a5a52eee..6d7b9d6f0d5 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/MTEResearchStation.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/MTEResearchStation.java @@ -32,7 +32,6 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import org.apache.commons.lang3.reflect.FieldUtils; import org.jetbrains.annotations.NotNull; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; @@ -63,6 +62,7 @@ import gregtech.api.util.IGTHatchAdder; import gregtech.api.util.MultiblockTooltipBuilder; import gregtech.api.util.shutdown.ShutDownReason; +import gregtech.mixin.interfaces.accessors.EntityPlayerMPAccessor; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import tectech.recipe.TecTechRecipeMaps; @@ -538,11 +538,8 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye super.onRightclick(aBaseMetaTileEntity, aPlayer); if (!aBaseMetaTileEntity.isClientSide() && aPlayer instanceof EntityPlayerMP) { - try { - EntityPlayerMP player = (EntityPlayerMP) aPlayer; - clientLocale = (String) FieldUtils.readField(player, "translator", true); - } catch (Exception e) { - clientLocale = "en_US"; + if (aPlayer instanceof EntityPlayerMPAccessor) { + clientLocale = ((EntityPlayerMPAccessor) aPlayer).gt5u$getTranslator(); } } else { return true; diff --git a/src/main/java/tectech/thing/metaTileEntity/single/MTEOwnerDetector.java b/src/main/java/tectech/thing/metaTileEntity/single/MTEOwnerDetector.java index 15cd63d6c92..72547cc6133 100644 --- a/src/main/java/tectech/thing/metaTileEntity/single/MTEOwnerDetector.java +++ b/src/main/java/tectech/thing/metaTileEntity/single/MTEOwnerDetector.java @@ -5,14 +5,11 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; -import org.apache.commons.lang3.reflect.FieldUtils; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -22,6 +19,7 @@ import gregtech.api.metatileentity.implementations.MTETieredMachineBlock; import gregtech.api.objects.GTRenderedTexture; import gregtech.api.util.GTUtility; +import gregtech.mixin.interfaces.accessors.EntityPlayerMPAccessor; import tectech.TecTech; import tectech.util.CommonValues; import tectech.util.TTUtility; @@ -123,8 +121,8 @@ public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide() && aTick % 20 == CommonValues.RECIPE_AT) { - boolean detected = TecTech.proxy.isOnlineUUID(uuid) || (uuid != null && uuid.length() > 0 - && TecTech.proxy.isOnlineName(aBaseMetaTileEntity.getOwnerName())); + boolean detected = TecTech.proxy.isOnlineUUID(uuid) + || (uuid != null && !uuid.isEmpty() && TecTech.proxy.isOnlineName(aBaseMetaTileEntity.getOwnerName())); aBaseMetaTileEntity.setActive(detected); aBaseMetaTileEntity.setGenericRedstoneOutput(detected); byte value = (byte) (detected ? 15 : 0); @@ -136,11 +134,10 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { @Override public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - String clientLocale; - try { - EntityPlayerMP player = (EntityPlayerMP) aPlayer; - clientLocale = (String) FieldUtils.readField(player, "translator", true); - } catch (Exception e) { + final String clientLocale; + if (aPlayer instanceof EntityPlayerMPAccessor) { + clientLocale = ((EntityPlayerMPAccessor) aPlayer).gt5u$getTranslator(); + } else { clientLocale = "en_US"; } interdimensional ^= true; diff --git a/src/main/java/tectech/thing/metaTileEntity/single/MTETeslaCoil.java b/src/main/java/tectech/thing/metaTileEntity/single/MTETeslaCoil.java index c5db9320417..bed3d342a48 100644 --- a/src/main/java/tectech/thing/metaTileEntity/single/MTETeslaCoil.java +++ b/src/main/java/tectech/thing/metaTileEntity/single/MTETeslaCoil.java @@ -9,13 +9,11 @@ import java.util.HashSet; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.reflect.FieldUtils; import com.google.common.collect.Multimap; import com.google.common.collect.MultimapBuilder; @@ -27,6 +25,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.MTEBasicBatteryBuffer; +import gregtech.mixin.interfaces.accessors.EntityPlayerMPAccessor; import tectech.loader.ConfigHandler; import tectech.loader.NetworkDispatcher; import tectech.mechanics.spark.RendererMessage; @@ -282,11 +281,8 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { if (aBaseMetaTileEntity.isServerSide()) { - try { - EntityPlayerMP player = (EntityPlayerMP) aPlayer; - clientLocale = (String) FieldUtils.readField(player, "translator", true); - } catch (Exception e) { - clientLocale = "en_US"; + if (aPlayer instanceof EntityPlayerMPAccessor) { + clientLocale = ((EntityPlayerMPAccessor) aPlayer).gt5u$getTranslator(); } GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); } diff --git a/src/main/java/tectech/util/TTUtility.java b/src/main/java/tectech/util/TTUtility.java index 7bfc612e572..f552fde9848 100644 --- a/src/main/java/tectech/util/TTUtility.java +++ b/src/main/java/tectech/util/TTUtility.java @@ -95,6 +95,7 @@ public static String getUniqueIdentifier(ItemStack is) { } public static void setTier(int tier, Object o) { + // TODO why is it using reflection to change a final field from GREGTECH ? if (!(o instanceof MTETieredMachineBlock)) { GTMod.GT_FML_LOGGER.error( "Could not set tier as object " + o.getClass() diff --git a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/CraftingManagerMixin.java b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/CraftingManagerMixin.java index 23432792d06..ceefe02f5aa 100644 --- a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/CraftingManagerMixin.java +++ b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/CraftingManagerMixin.java @@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; -import bartworks.hooks.BWCoreStaticReplacementMethodes; +import gregtech.mixin.hooks.BWCoreStaticReplacementMethodes; @Mixin(CraftingManager.class) public abstract class CraftingManagerMixin { diff --git a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/LanguageRegistryMixin.java b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/LanguageRegistryMixin.java index f6a0ebeaad1..5b0489651be 100644 --- a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/LanguageRegistryMixin.java +++ b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/LanguageRegistryMixin.java @@ -1,7 +1,5 @@ package gregtech.mixin.mixins.early.minecraft; -import static gregtech.mixin.MixinsVariablesHelper.currentlyTranslating; - import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -10,18 +8,18 @@ import cpw.mods.fml.common.ModContainer; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; +import gregtech.mixin.hooks.MixinsVariablesHelper; -@SuppressWarnings("unused") @Mixin(value = LanguageRegistry.class) public class LanguageRegistryMixin { @Inject(method = "loadLanguagesFor", at = @At(value = "HEAD"), remap = false, require = 1) - private void kubatech$loadLanguagesForHEAD(ModContainer container, Side side, CallbackInfo callbackInfo) { - currentlyTranslating = container.getModId(); + private void gt5u$loadLanguagesForHEAD(ModContainer container, Side side, CallbackInfo callbackInfo) { + MixinsVariablesHelper.currentlyTranslating = container.getModId(); } @Inject(method = "loadLanguagesFor", at = @At(value = "RETURN"), remap = false, require = 1) - private void kubatech$loadLanguagesForRETURN(ModContainer container, Side side, CallbackInfo callbackInfo) { - currentlyTranslating = null; + private void gt5u$loadLanguagesForRETURN(ModContainer container, Side side, CallbackInfo callbackInfo) { + MixinsVariablesHelper.currentlyTranslating = null; } } diff --git a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/LocaleMixin.java b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/LocaleMixin.java index e45548765cf..ceb54e54ce2 100644 --- a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/LocaleMixin.java +++ b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/LocaleMixin.java @@ -1,7 +1,5 @@ package gregtech.mixin.mixins.early.minecraft; -import static gregtech.mixin.MixinsVariablesHelper.currentlyTranslating; - import java.util.regex.Matcher; import net.minecraft.client.resources.Locale; @@ -12,9 +10,9 @@ import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.Redirect; +import gregtech.mixin.hooks.MixinsVariablesHelper; import kubatech.Tags; -@SuppressWarnings("unused") @Mixin(value = Locale.class) public class LocaleMixin { @@ -25,8 +23,8 @@ public class LocaleMixin { target = "Lnet/minecraft/client/resources/IResourceManager;getAllResources(Lnet/minecraft/util/ResourceLocation;)Ljava/util/List;"), index = 0, require = 1) - private ResourceLocation kubatech$loadLocaleDataFiles(ResourceLocation resourceLocation) { - currentlyTranslating = resourceLocation.getResourceDomain(); + private ResourceLocation gt5u$loadLocaleDataFiles(ResourceLocation resourceLocation) { + MixinsVariablesHelper.currentlyTranslating = resourceLocation.getResourceDomain(); return resourceLocation; } @@ -37,8 +35,10 @@ public class LocaleMixin { target = "Ljava/util/regex/Matcher;replaceAll(Ljava/lang/String;)Ljava/lang/String;", remap = false), require = 1) - private String kubatech$replaceAll(Matcher matcher, String replace) { - if (currentlyTranslating != null && currentlyTranslating.equals(Tags.MODID) && matcher.find()) { + private String gt5u$replaceAll(Matcher matcher, String replace) { + if (MixinsVariablesHelper.currentlyTranslating != null + && MixinsVariablesHelper.currentlyTranslating.equals(Tags.MODID) + && matcher.find()) { return matcher.replaceFirst(matcher.group()); } return matcher.replaceAll(replace); diff --git a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/StringTranslateMixin.java b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/StringTranslateMixin.java index 5fb393def98..0834b036c29 100644 --- a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/StringTranslateMixin.java +++ b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/StringTranslateMixin.java @@ -1,7 +1,5 @@ package gregtech.mixin.mixins.early.minecraft; -import static gregtech.mixin.MixinsVariablesHelper.currentlyTranslating; - import java.util.regex.Matcher; import net.minecraft.util.StringTranslate; @@ -10,9 +8,9 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; +import gregtech.mixin.hooks.MixinsVariablesHelper; import kubatech.Tags; -@SuppressWarnings("unused") @Mixin(value = StringTranslate.class) public class StringTranslateMixin { @@ -24,8 +22,10 @@ public class StringTranslateMixin { remap = false), remap = false, require = 1) - private static String kubatech$replaceAll(Matcher matcher, String replace) { - if (currentlyTranslating != null && currentlyTranslating.equals(Tags.MODID) && matcher.find()) { + private static String gt5u$replaceAll(Matcher matcher, String replace) { + if (MixinsVariablesHelper.currentlyTranslating != null + && MixinsVariablesHelper.currentlyTranslating.equals(Tags.MODID) + && matcher.find()) { return matcher.replaceFirst(matcher.group()); } return matcher.replaceAll(replace); diff --git a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/WorldMixin.java b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/WorldMixin.java index abdb61f55b1..7a21b8b577f 100644 --- a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/WorldMixin.java +++ b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/WorldMixin.java @@ -10,13 +10,12 @@ import kubatech.loaders.BlockLoader; -@SuppressWarnings("unused") @Mixin(value = World.class) public class WorldMixin { @SuppressWarnings("ConstantConditions") @ModifyReturnValue(method = "getBlock", at = @At("RETURN"), require = 1) - private Block kubatech$getBlockDetector(Block block, int x, int y, int z) { + private Block gt5u$getBlockDetector(Block block, int x, int y, int z) { if (block == BlockLoader.kubaBlock) BlockLoader.kubaBlock.setLastBlockAccess((World) (Object) this, x, y, z); return block; } diff --git a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/BlockStemMixin.java b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/accessors/BlockStemMixin.java similarity index 61% rename from src/mixin/java/gregtech/mixin/mixins/early/minecraft/BlockStemMixin.java rename to src/mixin/java/gregtech/mixin/mixins/early/minecraft/accessors/BlockStemMixin.java index 146c527d029..c3c8ecb5b4d 100644 --- a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/BlockStemMixin.java +++ b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/accessors/BlockStemMixin.java @@ -1,4 +1,4 @@ -package gregtech.mixin.mixins.early.minecraft; +package gregtech.mixin.mixins.early.minecraft.accessors; import net.minecraft.block.Block; import net.minecraft.block.BlockStem; @@ -7,17 +7,17 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import gregtech.mixin.interfaces.IBlockStemAccesor; +import gregtech.mixin.interfaces.accessors.IBlockStemAccessor; @Mixin(value = BlockStem.class) -public class BlockStemMixin implements IBlockStemAccesor { +public class BlockStemMixin implements IBlockStemAccessor { @Shadow @Final private Block field_149877_a; @Override - public Block getCropBlock() { + public Block gt5u$getCropBlock() { return this.field_149877_a; } } diff --git a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/accessors/EntityPlayerMPMixin.java b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/accessors/EntityPlayerMPMixin.java new file mode 100644 index 00000000000..a93f62a1a13 --- /dev/null +++ b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/accessors/EntityPlayerMPMixin.java @@ -0,0 +1,21 @@ +package gregtech.mixin.mixins.early.minecraft.accessors; + +import net.minecraft.entity.player.EntityPlayerMP; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +import gregtech.mixin.interfaces.accessors.EntityPlayerMPAccessor; + +@Mixin(EntityPlayerMP.class) +public class EntityPlayerMPMixin implements EntityPlayerMPAccessor { + + @Shadow + private String translator; + + @Override + public String gt5u$getTranslator() { + return this.translator; + } + +} diff --git a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/ForgeShapedRecipeMixin.java b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/accessors/ForgeShapedRecipeMixin.java similarity index 59% rename from src/mixin/java/gregtech/mixin/mixins/early/minecraft/ForgeShapedRecipeMixin.java rename to src/mixin/java/gregtech/mixin/mixins/early/minecraft/accessors/ForgeShapedRecipeMixin.java index 041df1937f1..9023880242a 100644 --- a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/ForgeShapedRecipeMixin.java +++ b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/accessors/ForgeShapedRecipeMixin.java @@ -1,4 +1,4 @@ -package gregtech.mixin.mixins.early.minecraft; +package gregtech.mixin.mixins.early.minecraft.accessors; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.ShapedOreRecipe; @@ -6,10 +6,11 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import gregtech.api.interfaces.IRecipeMutableAccess; +import gregtech.mixin.interfaces.accessors.IRecipeMutableAccess; +import gregtech.mixin.interfaces.accessors.ShapedOreRecipeAccessor; @Mixin(value = ShapedOreRecipe.class, remap = false) -public class ForgeShapedRecipeMixin implements IRecipeMutableAccess { +public class ForgeShapedRecipeMixin implements IRecipeMutableAccess, ShapedOreRecipeAccessor { @Shadow private ItemStack output; @@ -17,6 +18,12 @@ public class ForgeShapedRecipeMixin implements IRecipeMutableAccess { @Shadow private Object[] input; + @Shadow + private int width; + + @Shadow + private int height; + @Override public ItemStack gt5u$getRecipeOutputItem() { return this.output; @@ -31,4 +38,15 @@ public class ForgeShapedRecipeMixin implements IRecipeMutableAccess { public Object gt5u$getRecipeInputs() { return this.input; } + + @Override + public int gt5u$getWidth() { + return this.width; + } + + @Override + public int gt5u$getHeight() { + return this.height; + } + } diff --git a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/ForgeShapelessRecipeMixin.java b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/accessors/ForgeShapelessRecipeMixin.java similarity index 85% rename from src/mixin/java/gregtech/mixin/mixins/early/minecraft/ForgeShapelessRecipeMixin.java rename to src/mixin/java/gregtech/mixin/mixins/early/minecraft/accessors/ForgeShapelessRecipeMixin.java index 7bf4ba489e0..0a346175fd1 100644 --- a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/ForgeShapelessRecipeMixin.java +++ b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/accessors/ForgeShapelessRecipeMixin.java @@ -1,4 +1,4 @@ -package gregtech.mixin.mixins.early.minecraft; +package gregtech.mixin.mixins.early.minecraft.accessors; import java.util.ArrayList; @@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import gregtech.api.interfaces.IRecipeMutableAccess; +import gregtech.mixin.interfaces.accessors.IRecipeMutableAccess; @Mixin(value = ShapelessOreRecipe.class, remap = false) public class ForgeShapelessRecipeMixin implements IRecipeMutableAccess { diff --git a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/PotionMixin.java b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/accessors/PotionMixin.java similarity index 66% rename from src/mixin/java/gregtech/mixin/mixins/early/minecraft/PotionMixin.java rename to src/mixin/java/gregtech/mixin/mixins/early/minecraft/accessors/PotionMixin.java index 94b11af492b..0f8e9123371 100644 --- a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/PotionMixin.java +++ b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/accessors/PotionMixin.java @@ -1,4 +1,4 @@ -package gregtech.mixin.mixins.early.minecraft; +package gregtech.mixin.mixins.early.minecraft.accessors; import net.minecraft.potion.Potion; @@ -6,10 +6,10 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import gregtech.mixin.interfaces.PotionExt; +import gregtech.mixin.interfaces.accessors.PotionAccessor; @Mixin(Potion.class) -public class PotionMixin implements PotionExt { +public class PotionMixin implements PotionAccessor { @Shadow @Final diff --git a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/VanillaShapedRecipeMixin.java b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/accessors/VanillaShapedRecipeMixin.java similarity index 86% rename from src/mixin/java/gregtech/mixin/mixins/early/minecraft/VanillaShapedRecipeMixin.java rename to src/mixin/java/gregtech/mixin/mixins/early/minecraft/accessors/VanillaShapedRecipeMixin.java index 0eecaef6ea4..ff27b3d8ff7 100644 --- a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/VanillaShapedRecipeMixin.java +++ b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/accessors/VanillaShapedRecipeMixin.java @@ -1,4 +1,4 @@ -package gregtech.mixin.mixins.early.minecraft; +package gregtech.mixin.mixins.early.minecraft.accessors; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.ShapedRecipes; @@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import gregtech.api.interfaces.IRecipeMutableAccess; +import gregtech.mixin.interfaces.accessors.IRecipeMutableAccess; @Mixin(ShapedRecipes.class) public class VanillaShapedRecipeMixin implements IRecipeMutableAccess { diff --git a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/VanillaShapelessRecipeMixin.java b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/accessors/VanillaShapelessRecipeMixin.java similarity index 80% rename from src/mixin/java/gregtech/mixin/mixins/early/minecraft/VanillaShapelessRecipeMixin.java rename to src/mixin/java/gregtech/mixin/mixins/early/minecraft/accessors/VanillaShapelessRecipeMixin.java index 926ae6630cc..1088e77214c 100644 --- a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/VanillaShapelessRecipeMixin.java +++ b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/accessors/VanillaShapelessRecipeMixin.java @@ -1,4 +1,4 @@ -package gregtech.mixin.mixins.early.minecraft; +package gregtech.mixin.mixins.early.minecraft.accessors; import java.util.List; @@ -7,13 +7,16 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.Shadow; -import gregtech.api.interfaces.IRecipeMutableAccess; +import gregtech.mixin.interfaces.accessors.IRecipeMutableAccess; @Mixin(ShapelessRecipes.class) public class VanillaShapelessRecipeMixin implements IRecipeMutableAccess { + @Final + @Mutable @Shadow private ItemStack recipeOutput;