From cfbd10cfb2644a981b9b2763166aa66fce5cd491 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Tue, 7 Apr 2020 15:12:31 +0100 Subject: + Added support for Custom Machines being registered to the PA. (If GT is up-to date) + Added more ASM patches for better Hazmat handling. % Renamed Chemical Dehydrator to Dehydrator for clearer logic in NEI. $ Fixed a small bug in ReflectionUtils. $ Rewrote parts of my Hazmat handling, it should now work correctly for all items which apply radiation from IC2/GT or their addons. --- src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java | 4 ++ .../loaders/misc/AddCustomMachineToPA.java | 51 ++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AddCustomMachineToPA.java (limited to 'src/Java/gtPlusPlus/xmod/gregtech') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java index 1cb499479f..7c1b854770 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -53,6 +53,7 @@ import gtPlusPlus.xmod.gregtech.loaders.ProcessingElectricButcherKnife; import gtPlusPlus.xmod.gregtech.loaders.ProcessingElectricLighter; import gtPlusPlus.xmod.gregtech.loaders.ProcessingElectricSnips; import gtPlusPlus.xmod.gregtech.loaders.ProcessingToolHeadChoocher; +import gtPlusPlus.xmod.gregtech.loaders.misc.AddCustomMachineToPA; import gtPlusPlus.xmod.gregtech.loaders.misc.WoodCentrifuging; import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_AlgaeFarm; import gtPlusPlus.xmod.gregtech.recipes.RecipesToRemove; @@ -129,6 +130,9 @@ public class HANDLER_GT { if (ConfigSwitches.enableOldGTcircuits && !CORE.GTNH){ OldCircuitHandler.postInit(); } + + // Register custom singles to the PA + AddCustomMachineToPA.register(); // Register the No-Bonus Special Behaviour. diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AddCustomMachineToPA.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AddCustomMachineToPA.java new file mode 100644 index 0000000000..321cab4628 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AddCustomMachineToPA.java @@ -0,0 +1,51 @@ +package gtPlusPlus.xmod.gregtech.loaders.misc; + +import java.lang.reflect.Method; + +import gregtech.api.util.Recipe_GT; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.core.util.reflect.ReflectionUtils; + +public class AddCustomMachineToPA { + + private static final boolean sDoesPatchExist; + private static final Class sManagerPA; + private static final Method sRegisterRecipeMapForMeta; + + static { + sDoesPatchExist = ReflectionUtils.doesClassExist("gregtech.api.util.GT_ProcessingArray_Manager"); + if (sDoesPatchExist) { + sManagerPA = ReflectionUtils.getClass("gregtech.api.util.GT_ProcessingArray_Manager"); + sRegisterRecipeMapForMeta = ReflectionUtils.getMethod(sManagerPA, "registerRecipeMapForMeta", int.class, GT_Recipe_Map.class); + } + else { + sManagerPA = null; + sRegisterRecipeMapForMeta = null; + } + } + + public static final void registerRecipeMapForID(int aID, GT_Recipe_Map aMap) { + if (sDoesPatchExist) { + ReflectionUtils.invokeNonBool(null, sRegisterRecipeMapForMeta, new Object[] {aID, aMap}); + } + + } + + public static final void registerRecipeMapBetweenRangeOfIDs(int aMin, int aMax, GT_Recipe_Map aMap) { + if (sDoesPatchExist) { + for (int i=aMin; i<=aMax;i++) { + ReflectionUtils.invokeNonBool(null, sRegisterRecipeMapForMeta, new Object[] {i, aMap}); + //GT_ProcessingArray_Manager.registerRecipeMapForMeta(i, aMap); + } + } + } + + public static void register() { + + // Simple Washers + registerRecipeMapForID(767, Recipe_GT.Gregtech_Recipe_Map.sSimpleWasherRecipes); + registerRecipeMapBetweenRangeOfIDs(31017, 31020, Recipe_GT.Gregtech_Recipe_Map.sSimpleWasherRecipes); + + } + +} -- cgit