diff options
Diffstat (limited to 'src')
3 files changed, 248 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java index c37a696439..b833ab023a 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java @@ -6,6 +6,7 @@ import gtPlusPlus.xmod.forestry.HANDLER_FR; import gtPlusPlus.xmod.gregtech.HANDLER_GT; import gtPlusPlus.xmod.growthcraft.HANDLER_GC; import gtPlusPlus.xmod.ic2.HANDLER_IC2; +import gtPlusPlus.xmod.mekanism.HANDLER_Mekanism; import gtPlusPlus.xmod.rftools.HANDLER_RfTools; import gtPlusPlus.xmod.thermalfoundation.HANDLER_TF; @@ -20,6 +21,7 @@ public class COMPAT_IntermodStaging { HANDLER_Computronics.preInit(); HANDLER_BiomesOPlenty.preInit(); HANDLER_RfTools.preInit(); + HANDLER_Mekanism.preInit(); } @@ -32,6 +34,7 @@ public class COMPAT_IntermodStaging { HANDLER_Computronics.init(); HANDLER_BiomesOPlenty.init(); HANDLER_RfTools.init(); + HANDLER_Mekanism.init(); } public static void postInit(){ @@ -43,6 +46,7 @@ public class COMPAT_IntermodStaging { HANDLER_Computronics.postInit(); HANDLER_BiomesOPlenty.postInit(); HANDLER_RfTools.postInit(); + HANDLER_Mekanism.postInit(); } diff --git a/src/Java/gtPlusPlus/preloader/Preloader_GT_OreDict.java b/src/Java/gtPlusPlus/preloader/Preloader_GT_OreDict.java index 9b3b7092da..26cefe7254 100644 --- a/src/Java/gtPlusPlus/preloader/Preloader_GT_OreDict.java +++ b/src/Java/gtPlusPlus/preloader/Preloader_GT_OreDict.java @@ -101,6 +101,16 @@ public class Preloader_GT_OreDict { } } } + //Shard + if (Class.forName("mekanism.common.item.ItemShard") != null) { + Class<?> MekIngot = Class.forName("mekanism.common.item.ItemShard"); + if (isInstanceOf(MekIngot, bannedItem.getItem())) { + if (bannedItem.getItemDamage() == 2){ + FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing "+bannedItem.getDisplayName()+" from the OreDictionary to balance Mekanism."); + return true; + } + } + } //Clump if (Class.forName("mekanism.common.item.ItemClump") != null) { Class<?> MekIngot = Class.forName("mekanism.common.item.ItemClump"); diff --git a/src/Java/gtPlusPlus/xmod/mekanism/HANDLER_Mekanism.java b/src/Java/gtPlusPlus/xmod/mekanism/HANDLER_Mekanism.java new file mode 100644 index 0000000000..b277928aeb --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/mekanism/HANDLER_Mekanism.java @@ -0,0 +1,234 @@ +package gtPlusPlus.xmod.mekanism; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import gregtech.api.util.GT_ModHandler; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.ItemUtils; +import gtPlusPlus.core.util.nbt.NBTUtils; +import gtPlusPlus.core.util.recipe.RecipeUtils; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +public class HANDLER_Mekanism { + + public static void preInit(){ + if (LoadedMods.Mekanism){ + + } + } + + public static void init(){ + if (LoadedMods.Mekanism){ + + } + } + + public static void postInit(){ + if (LoadedMods.Mekanism){ + //Steel Casing + ItemStack tSteelCasing = ItemUtils.simpleMetaStack("Mekanism:BasicBlock:8", 8, 1); + addNewRecipe( + "plateSteel", "blockGlass", "plateSteel", + "blockGlass", "plateStainlessSteel", "blockGlass", + "plateSteel", "blockGlass", "plateSteel", + tSteelCasing); + + //Energy Storage + ItemStack tAdvancedEnergyCube = ItemUtils.simpleMetaStack("Mekanism:EnergyCube", 0, 1); + NBTUtils.setString(tAdvancedEnergyCube, "tier", "Advanced"); + ItemStack tBasicEnergyCube = ItemUtils.simpleMetaStack("Mekanism:EnergyCube", 0, 1); + NBTUtils.setString(tBasicEnergyCube, "tier", "Basic"); + + //Machines that use Osmium + ItemStack tMachineBlock_Basic = ItemUtils.simpleMetaStack("Mekanism:MachineBlock:5", 5, 1); + ItemStack tMachineBlock = ItemUtils.simpleMetaStack("Mekanism:MachineBlock:6", 6, 1); + + //Smelting + ItemStack tMachineBlock_0_Basic = tMachineBlock_Basic; + NBTUtils.setInteger(tMachineBlock_0_Basic, "recipeType", 0); + ItemStack tMachineBlock_0 = tMachineBlock; + NBTUtils.setInteger(tMachineBlock_0, "recipeType", 0); + //Enriching + ItemStack tMachineBlock_1_Basic = tMachineBlock_Basic; + NBTUtils.setInteger(tMachineBlock_1_Basic, "recipeType", 1); + ItemStack tMachineBlock_1 = tMachineBlock; + NBTUtils.setInteger(tMachineBlock_1, "recipeType", 1); + //Crushing + ItemStack tMachineBlock_2_Basic = tMachineBlock_Basic; + NBTUtils.setInteger(tMachineBlock_2_Basic, "recipeType", 2); + ItemStack tMachineBlock_2 = tMachineBlock; + NBTUtils.setInteger(tMachineBlock_2, "recipeType", 2); + //Compressing + ItemStack tMachineBlock_3_Basic = tMachineBlock_Basic; + NBTUtils.setInteger(tMachineBlock_3_Basic, "recipeType", 3); + ItemStack tMachineBlock_3 = tMachineBlock; + NBTUtils.setInteger(tMachineBlock_3, "recipeType", 3); + //Combining + ItemStack tMachineBlock_4_Basic = tMachineBlock_Basic; + NBTUtils.setInteger(tMachineBlock_4_Basic, "recipeType", 4); + ItemStack tMachineBlock_4 = tMachineBlock; + NBTUtils.setInteger(tMachineBlock_4, "recipeType", 4); + //Purifying + ItemStack tMachineBlock_5_Basic = tMachineBlock_Basic; + NBTUtils.setInteger(tMachineBlock_5_Basic, "recipeType", 5); + ItemStack tMachineBlock_5 = tMachineBlock; + NBTUtils.setInteger(tMachineBlock_5, "recipeType", 5); + //Injecting + ItemStack tMachineBlock_6_Basic = tMachineBlock_Basic; + NBTUtils.setInteger(tMachineBlock_6_Basic, "recipeType", 6); + ItemStack tMachineBlock_6 = tMachineBlock; + NBTUtils.setInteger(tMachineBlock_6, "recipeType", 6); + //Infusing + ItemStack tMachineBlock_7_Basic = tMachineBlock_Basic; + NBTUtils.setInteger(tMachineBlock_7_Basic, "recipeType", 7); + ItemStack tMachineBlock_7 = tMachineBlock; + NBTUtils.setInteger(tMachineBlock_7, "recipeType", 7); + + //Infuser + ItemStack tMachineBlock_8 = ItemUtils.simpleMetaStack("Mekanism:MachineBlock:8", 8, 1); + //Purification + ItemStack tMachineBlock_9 = ItemUtils.simpleMetaStack("Mekanism:MachineBlock:9", 9, 1); + //Pump + ItemStack tMachineBlock_12 = ItemUtils.simpleMetaStack("Mekanism:MachineBlock:12", 12, 1); + + //<Mekanism:ElectrolyticCore> + ItemStack tItem_1 = ItemUtils.simpleMetaStack("Mekanism:ElectrolyticCore", 0, 1); + //<Mekanism:FactoryInstaller:1> + ItemStack tItem_2 = ItemUtils.simpleMetaStack("Mekanism:FactoryInstaller:1", 1, 1); + //<Mekanism:SpeedUpgrade> + ItemStack tItem_3 = ItemUtils.simpleMetaStack("Mekanism:SpeedUpgrade", 0, 1); + + //MiscItems + String tAdvancedAlloy = "alloyAdvanced"; + String tCircuitAdvanced = "circuitAdvanced"; + ItemStack tMekBatterySimple = ItemUtils.simpleMetaStack("Mekanism:EnergyTablet", 0, 1); + + //Items + addNewRecipe( + tAdvancedAlloy, "plateTitanium", tAdvancedAlloy, + "dustIron", tAdvancedAlloy, "dustGold", + tAdvancedAlloy, "plateTitanium", tAdvancedAlloy, + tItem_1); + addNewRecipe( + tAdvancedAlloy, "circuitAdvanced", tAdvancedAlloy, + "plateStainlessSteel", "plankWood", "plateStainlessSteel", + tAdvancedAlloy, "circuitAdvanced", tAdvancedAlloy, + tItem_2); + addNewRecipe( + null, "blockGlass", null, + tAdvancedAlloy, "plateTungsten", tAdvancedAlloy, + null, "blockGlass", null, + tItem_3); + + //Power Storage + addNewRecipe( + tAdvancedAlloy, tMekBatterySimple, tAdvancedAlloy, + "plateAluminium", tBasicEnergyCube, "plateAluminium", + tAdvancedAlloy, tMekBatterySimple, tAdvancedAlloy, + tAdvancedEnergyCube); + + //Blocks + addNewRecipe( + "plateSteel", "craftingFurnace", "plateSteel", + "plateRedstone", "platePlatinum", "plateRedstone", + "plateSteel", "craftingFurnace", "plateSteel", + tMachineBlock_8); + addNewRecipe( + tAdvancedAlloy, "circuitAdvanced", tAdvancedAlloy, + "plateTitanium", ItemUtils.simpleMetaStack("Mekanism:MachineBlock", 0, 1), "plateTitanium", + tAdvancedAlloy, "circuitAdvanced", tAdvancedAlloy, + tMachineBlock_9); + addNewRecipe( + null, ItemUtils.getSimpleStack(Items.bucket), null, + tAdvancedAlloy, tSteelCasing, tAdvancedAlloy, + "plateStainlessSteel", "plateStainlessSteel", "plateStainlessSteel", + tMachineBlock_12); + + //Machines + addNewRecipe( + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + "plateStainlessSteel", tMachineBlock_0_Basic, "plateStainlessSteel", + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + tMachineBlock_0); + addNewRecipe( + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + "plateStainlessSteel", tMachineBlock_1_Basic, "plateStainlessSteel", + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + tMachineBlock_1); + addNewRecipe( + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + "plateStainlessSteel", tMachineBlock_2_Basic, "plateStainlessSteel", + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + tMachineBlock_2); + addNewRecipe( + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + "plateStainlessSteel", tMachineBlock_3_Basic, "plateStainlessSteel", + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + tMachineBlock_3); + addNewRecipe( + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + "plateStainlessSteel", tMachineBlock_4_Basic, "plateStainlessSteel", + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + tMachineBlock_4); + addNewRecipe( + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + "plateStainlessSteel", tMachineBlock_5_Basic, "plateStainlessSteel", + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + tMachineBlock_5); + addNewRecipe( + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + "plateStainlessSteel", tMachineBlock_6_Basic, "plateStainlessSteel", + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + tMachineBlock_6); + addNewRecipe( + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + "plateStainlessSteel", tMachineBlock_7_Basic, "plateStainlessSteel", + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + tMachineBlock_7); + } + } + + private static boolean addNewRecipe( + final Object InputItem1, final Object InputItem2, final Object InputItem3, + final Object InputItem4, final Object InputItem5, final Object InputItem6, + final Object InputItem7, final Object InputItem8, final Object InputItem9, + final ItemStack OutputItem){ + + if (removeRecipe(OutputItem)){ + return RecipeUtils.recipeBuilder( + InputItem1, InputItem2, InputItem3, + InputItem4, InputItem5, InputItem6, + InputItem7, InputItem8, InputItem9, + OutputItem); + } + return false; + + } + + private static boolean removeRecipe(ItemStack item){ + Class<?> mekUtils; + boolean removed = false; + try { + mekUtils = Class.forName("mekanism.common.util.RecipeUtils"); + if (mekUtils != null){ + Method mRemoveRecipe = mekUtils.getDeclaredMethod("removeRecipes", ItemStack.class); + if (mRemoveRecipe != null){ + removed = (boolean) mRemoveRecipe.invoke(mekUtils, ItemUtils.simpleMetaStack("Mekanism:BasicBlock:8", 8, 1)); + if (!removed) { + removed = (boolean) mRemoveRecipe.invoke(null, ItemUtils.simpleMetaStack("Mekanism:BasicBlock:8", 8, 1)); + } + } + } + } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + Utils.LOG_INFO("[Mek] Failed to use the built-in recipe remover from Mekanism."); + } + if (!removed){ + removed = GT_ModHandler.removeRecipeByOutput(ItemUtils.simpleMetaStack("Mekanism:BasicBlock:8", 8, 1)); + } + return removed; + } + +} |