diff --git a/.gitignore b/.gitignore index 2824c52..83c3720 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ /forge-1.7.2* /build /common +/out/ /eclipse/* /.gradle /bin/* diff --git a/libs/Mekanism-1.7.10-8.1.0.215.jar b/libs/Mekanism-1.7.10-8.1.0.215.jar new file mode 100644 index 0000000..ae7ad32 Binary files /dev/null and b/libs/Mekanism-1.7.10-8.1.0.215.jar differ diff --git a/src/main/java/modtweaker2/ModTweaker2.java b/src/main/java/modtweaker2/ModTweaker2.java index f2721fd..863547a 100644 --- a/src/main/java/modtweaker2/ModTweaker2.java +++ b/src/main/java/modtweaker2/ModTweaker2.java @@ -1,10 +1,5 @@ package modtweaker2; -import java.io.File; - -import minetweaker.MineTweakerImplementationAPI; -import minetweaker.MineTweakerImplementationAPI.ReloadEvent; -import minetweaker.util.IEventHandler; import modtweaker2.mods.appeng.AppliedEnergistics; import modtweaker2.mods.auracascade.AuraCascade; import modtweaker2.mods.botania.Botania; @@ -15,7 +10,6 @@ import modtweaker2.mods.factorization.Factorization; import modtweaker2.mods.forestry.Forestry; import modtweaker2.mods.fsp.Steamcraft; import modtweaker2.mods.hee.HardcoreEnderExpansion; -import modtweaker2.mods.imc.handler.Message; import modtweaker2.mods.mariculture.Mariculture; import modtweaker2.mods.mekanism.Mekanism; import modtweaker2.mods.metallurgy.Metallurgy; diff --git a/src/main/java/modtweaker2/mods/mekanism/Mekanism.java b/src/main/java/modtweaker2/mods/mekanism/Mekanism.java index 915fa2b..cceeb02 100644 --- a/src/main/java/modtweaker2/mods/mekanism/Mekanism.java +++ b/src/main/java/modtweaker2/mods/mekanism/Mekanism.java @@ -1,5 +1,7 @@ package modtweaker2.mods.mekanism; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; import minetweaker.MineTweakerAPI; import modtweaker2.mods.mekanism.gas.GasBracketHandler; import modtweaker2.mods.mekanism.handlers.ChemicalCrystallizer; @@ -19,7 +21,10 @@ import modtweaker2.mods.mekanism.handlers.Sawmill; import modtweaker2.mods.mekanism.handlers.Separator; import modtweaker2.utils.TweakerPlugin; +import java.util.regex.Pattern; + public class Mekanism extends TweakerPlugin { + public static final boolean v7 = isV7(); public Mekanism() { MineTweakerAPI.registerBracketHandler(new GasBracketHandler()); MineTweakerAPI.registerClass(Combiner.class); @@ -38,4 +43,13 @@ public class Mekanism extends TweakerPlugin { MineTweakerAPI.registerClass(ChemicalOxidizer.class); MineTweakerAPI.registerClass(ChemicalWasher.class); } + + public static boolean isV7(){ + Pattern version = Pattern.compile("7.*"); + for (ModContainer loadedMod : Loader.instance().getActiveModList()) + { + if (loadedMod.getModId().equals("Mekanism") && version.matcher(loadedMod.getVersion()).find()) return true; + } + return false; + } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalCrystallizer.java b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalCrystallizer.java index a4c67ef..edf0f0e 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalCrystallizer.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalCrystallizer.java @@ -3,9 +3,10 @@ package modtweaker2.mods.mekanism.handlers; import static modtweaker2.helpers.InputHelper.toStack; import static modtweaker2.mods.mekanism.MekanismHelper.toGas; import mekanism.common.recipe.RecipeHandler.Recipe; -import minetweaker.IUndoableAction; +import mekanism.common.recipe.machines.CrystallizerRecipe; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; +import modtweaker2.mods.mekanism.Mekanism; import modtweaker2.mods.mekanism.gas.IGasStack; import modtweaker2.mods.mekanism.util.AddMekanismRecipe; import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe; @@ -16,11 +17,18 @@ import stanhebben.zenscript.annotations.ZenMethod; public class ChemicalCrystallizer { @ZenMethod public static void addRecipe(IGasStack input, IItemStack output) { - MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_CRYSTALLIZER", Recipe.CHEMICAL_CRYSTALLIZER.get(), toGas(input), toStack(output))); + if (Mekanism.v7) + MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_CRYSTALLIZER", Recipe.CHEMICAL_CRYSTALLIZER.get(), toGas(input), toStack(output))); + else + { + CrystallizerRecipe recipe = new CrystallizerRecipe(toGas(input), toStack(output)); + MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_CRYSTALLIZER", Recipe.CHEMICAL_CRYSTALLIZER.get(), recipe.getInput(), recipe)); + } } @ZenMethod public static void removeRecipe(IItemStack output) { + if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet"); MineTweakerAPI.apply(new RemoveMekanismRecipe("CHEMICAL_CRYSTALLIZER", Recipe.CHEMICAL_CRYSTALLIZER.get(), toStack(output))); } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalDissolution.java b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalDissolution.java index 312ce44..82aaace 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalDissolution.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalDissolution.java @@ -10,10 +10,12 @@ import java.util.Map; import mekanism.api.gas.GasStack; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.DissolutionRecipe; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; import minetweaker.api.oredict.IOreDictEntry; import modtweaker2.helpers.InputHelper; +import modtweaker2.mods.mekanism.Mekanism; import modtweaker2.mods.mekanism.gas.IGasStack; import modtweaker2.mods.mekanism.util.AddMekanismRecipe; import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe; @@ -26,16 +28,25 @@ import stanhebben.zenscript.annotations.ZenMethod; public class ChemicalDissolution { @ZenMethod public static void addRecipe(IItemStack input, IGasStack output) { - MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_DISSOLUTION_CHAMBER", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), toStack(input), toGas(output))); + if (Mekanism.v7) + { + MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_DISSOLUTION_CHAMBER", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), toStack(input), toGas(output))); + } + else { + DissolutionRecipe recipe = new DissolutionRecipe(toStack(input), toGas(output)); + MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_DISSOLUTION_CHAMBER", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), recipe.getInput(), recipe)); + } } @ZenMethod public static void removeRecipe(IItemStack input) { + if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet"); MineTweakerAPI.apply(new Remove("CHEMICAL_DISSOLUTION_CHAMBER", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), toStack(input))); } @ZenMethod public static void removeRecipe(IOreDictEntry input) { + if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet"); List stacks = OreDictionary.getOres(InputHelper.toString(input)); for (ItemStack stack : stacks) { MineTweakerAPI.apply(new Remove("CHEMICAL_DISSOLUTION_CHAMBER", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), stack)); @@ -44,6 +55,7 @@ public class ChemicalDissolution { @ZenMethod public static void removeRecipe(IGasStack input) { + if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet"); MineTweakerAPI.apply(new Remove("CHEMICAL_DISSOLUTION_CHAMBER", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), toGas(input))); } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalInfuser.java b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalInfuser.java index ef47e40..76acf30 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalInfuser.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalInfuser.java @@ -3,7 +3,9 @@ package modtweaker2.mods.mekanism.handlers; import static modtweaker2.mods.mekanism.MekanismHelper.toGas; import mekanism.api.ChemicalPair; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.ChemicalInfuserRecipe; import minetweaker.MineTweakerAPI; +import modtweaker2.mods.mekanism.Mekanism; import modtweaker2.mods.mekanism.gas.IGasStack; import modtweaker2.mods.mekanism.util.AddMekanismRecipe; import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe; @@ -14,12 +16,21 @@ import stanhebben.zenscript.annotations.ZenMethod; public class ChemicalInfuser { @ZenMethod public static void addRecipe(IGasStack left, IGasStack right, IGasStack out) { - ChemicalPair pair = new ChemicalPair(toGas(left), toGas(right)); - MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), pair, toGas(out))); + if (Mekanism.v7) + { + ChemicalPair pair = new ChemicalPair(toGas(left), toGas(right)); + MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), pair, toGas(out))); + } + else + { + ChemicalInfuserRecipe recipe = new ChemicalInfuserRecipe(toGas(left),toGas(right), toGas(out)); + MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), recipe.getInput(), recipe)); + } } @ZenMethod public static void removeRecipe(IGasStack output) { + if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet"); MineTweakerAPI.apply(new RemoveMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), toGas(output))); } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalInjection.java b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalInjection.java index 848fd14..d81b50b 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalInjection.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalInjection.java @@ -4,8 +4,10 @@ import static modtweaker2.helpers.InputHelper.toStack; import static modtweaker2.mods.mekanism.MekanismHelper.toGas; import mekanism.api.AdvancedInput; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.InjectionRecipe; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; +import modtweaker2.mods.mekanism.Mekanism; import modtweaker2.mods.mekanism.gas.IGasStack; import modtweaker2.mods.mekanism.util.AddMekanismRecipe; import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe; @@ -16,12 +18,21 @@ import stanhebben.zenscript.annotations.ZenMethod; public class ChemicalInjection { @ZenMethod public static void addRecipe(IItemStack input, IGasStack gas, IItemStack output) { - AdvancedInput aInput = new AdvancedInput(toStack(input), toGas(gas).getGas()); - MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_INJECTION_CHAMBER", Recipe.CHEMICAL_INJECTION_CHAMBER.get(), aInput, toStack(output))); + if (Mekanism.v7) + { + AdvancedInput aInput = new AdvancedInput(toStack(input), toGas(gas).getGas()); + MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_INJECTION_CHAMBER", Recipe.CHEMICAL_INJECTION_CHAMBER.get(), aInput, toStack(output))); + } + else + { + InjectionRecipe recipe = new InjectionRecipe(toStack(input), gas.getName(), toStack(output)); + MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_INJECTION_CHAMBER", Recipe.CHEMICAL_INJECTION_CHAMBER.get(), recipe.getInput(), recipe)); + } } @ZenMethod public static void removeRecipe(IItemStack output) { + if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet"); MineTweakerAPI.apply(new RemoveMekanismRecipe("CHEMICAL_INJECTION_CHAMBER", Recipe.CHEMICAL_INJECTION_CHAMBER.get(), toStack(output))); } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalOxidizer.java b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalOxidizer.java index 9a2b568..5db57c6 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalOxidizer.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalOxidizer.java @@ -3,8 +3,10 @@ package modtweaker2.mods.mekanism.handlers; import static modtweaker2.helpers.InputHelper.toStack; import static modtweaker2.mods.mekanism.MekanismHelper.toGas; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.OxidationRecipe; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; +import modtweaker2.mods.mekanism.Mekanism; import modtweaker2.mods.mekanism.gas.IGasStack; import modtweaker2.mods.mekanism.util.AddMekanismRecipe; import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe; @@ -15,11 +17,20 @@ import stanhebben.zenscript.annotations.ZenMethod; public class ChemicalOxidizer { @ZenMethod public static void addRecipe(IItemStack input, IGasStack output) { - MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_OXIDIZER", Recipe.CHEMICAL_OXIDIZER.get(), toStack(input), toGas(output))); + if (Mekanism.v7) + { + MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_OXIDIZER", Recipe.CHEMICAL_OXIDIZER.get(), toStack(input), toGas(output))); + } + else + { + OxidationRecipe recipe = new OxidationRecipe(toStack(input), toGas(output)); + MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_OXIDIZER", Recipe.CHEMICAL_OXIDIZER.get(), recipe.getInput(), recipe)); + } } @ZenMethod public static void removeRecipe(IGasStack output) { + if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet"); MineTweakerAPI.apply(new RemoveMekanismRecipe("CHEMICAL_OXIDIZER", Recipe.CHEMICAL_OXIDIZER.get(), toGas(output))); } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalWasher.java b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalWasher.java index 6688408..523fb1f 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalWasher.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalWasher.java @@ -7,7 +7,9 @@ import java.util.Map; import mekanism.api.gas.GasStack; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.WasherRecipe; import minetweaker.MineTweakerAPI; +import modtweaker2.mods.mekanism.Mekanism; import modtweaker2.mods.mekanism.gas.IGasStack; import modtweaker2.mods.mekanism.util.AddMekanismRecipe; import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe; @@ -18,11 +20,20 @@ import stanhebben.zenscript.annotations.ZenMethod; public class ChemicalWasher { @ZenMethod public static void addRecipe(IGasStack input, IGasStack output) { - MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_WASHER", Recipe.CHEMICAL_WASHER.get(), toGas(input), toGas(output))); + if (Mekanism.v7) + { + MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_WASHER", Recipe.CHEMICAL_WASHER.get(), toGas(input), toGas(output))); + } + else + { + WasherRecipe recipe = new WasherRecipe(toGas(input), toGas(output)); + MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_WASHER", Recipe.CHEMICAL_WASHER.get(), recipe.getInput(), recipe)); + } } @ZenMethod public static void removeRecipe(IGasStack output) { + if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet"); MineTweakerAPI.apply(new Remove("CHEMICAL_WASHER", Recipe.CHEMICAL_WASHER.get(), toGas(output))); } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/Combiner.java b/src/main/java/modtweaker2/mods/mekanism/handlers/Combiner.java index c9f77a8..35c358a 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/Combiner.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/Combiner.java @@ -4,8 +4,10 @@ import static modtweaker2.helpers.InputHelper.toStack; import mekanism.api.AdvancedInput; import mekanism.api.gas.GasRegistry; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.CombinerRecipe; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; +import modtweaker2.mods.mekanism.Mekanism; import modtweaker2.mods.mekanism.util.AddMekanismRecipe; import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe; import stanhebben.zenscript.annotations.ZenClass; @@ -16,11 +18,18 @@ public class Combiner { @ZenMethod public static void addRecipe(IItemStack input, IItemStack output) { AdvancedInput aInput = new AdvancedInput(toStack(input), GasRegistry.getGas("liquidStone")); - MineTweakerAPI.apply(new AddMekanismRecipe("COMBINER", Recipe.COMBINER.get(), aInput, toStack(output))); + if (Mekanism.v7) + MineTweakerAPI.apply(new AddMekanismRecipe("COMBINER", Recipe.COMBINER.get(), aInput, toStack(output))); + else + { + CombinerRecipe recipe = new CombinerRecipe(toStack(input), toStack(output)); + MineTweakerAPI.apply(new AddMekanismRecipe("COMBINER", Recipe.COMBINER.get(), recipe.getInput(), recipe)); + } } @ZenMethod public static void removeRecipe(IItemStack output) { + if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet"); MineTweakerAPI.apply(new RemoveMekanismRecipe("COMBINER", Recipe.COMBINER.get(), toStack(output))); } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/Compressor.java b/src/main/java/modtweaker2/mods/mekanism/handlers/Compressor.java index bae7388..b8280f8 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/Compressor.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/Compressor.java @@ -4,8 +4,10 @@ import static modtweaker2.helpers.InputHelper.toStack; import mekanism.api.AdvancedInput; import mekanism.api.gas.GasRegistry; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.OsmiumCompressorRecipe; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; +import modtweaker2.mods.mekanism.Mekanism; import modtweaker2.mods.mekanism.util.AddMekanismRecipe; import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe; import stanhebben.zenscript.annotations.ZenClass; @@ -16,11 +18,18 @@ public class Compressor { @ZenMethod public static void addRecipe(IItemStack input, IItemStack output) { AdvancedInput aInput = new AdvancedInput(toStack(input), GasRegistry.getGas("liquidOsmium")); - MineTweakerAPI.apply(new AddMekanismRecipe("OSMIUM_COMPRESSOR", Recipe.OSMIUM_COMPRESSOR.get(), aInput, toStack(output))); + if (Mekanism.v7) + MineTweakerAPI.apply(new AddMekanismRecipe("OSMIUM_COMPRESSOR", Recipe.OSMIUM_COMPRESSOR.get(), aInput, toStack(output))); + else + { + OsmiumCompressorRecipe recipe = new OsmiumCompressorRecipe(toStack(input), toStack(output)); + MineTweakerAPI.apply(new AddMekanismRecipe("OSMIUM_COMPRESSOR", Recipe.OSMIUM_COMPRESSOR.get(), recipe.getInput(), recipe)); + } } @ZenMethod public static void removeRecipe(IItemStack output) { + if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet"); MineTweakerAPI.apply(new RemoveMekanismRecipe("OSMIUM_COMPRESSOR", Recipe.OSMIUM_COMPRESSOR.get(), toStack(output))); } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/Crusher.java b/src/main/java/modtweaker2/mods/mekanism/handlers/Crusher.java index 48ec092..637e8b8 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/Crusher.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/Crusher.java @@ -2,8 +2,10 @@ package modtweaker2.mods.mekanism.handlers; import static modtweaker2.helpers.InputHelper.toStack; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.CrusherRecipe; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; +import modtweaker2.mods.mekanism.Mekanism; import modtweaker2.mods.mekanism.util.AddMekanismRecipe; import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe; import stanhebben.zenscript.annotations.ZenClass; @@ -13,11 +15,18 @@ import stanhebben.zenscript.annotations.ZenMethod; public class Crusher { @ZenMethod public static void addRecipe(IItemStack input, IItemStack output) { - MineTweakerAPI.apply(new AddMekanismRecipe("CRUSHER", Recipe.CRUSHER.get(), toStack(input), toStack(output))); + if (Mekanism.v7) + MineTweakerAPI.apply(new AddMekanismRecipe("CRUSHER", Recipe.CRUSHER.get(), toStack(input), toStack(output))); + else + { + CrusherRecipe recipe = new CrusherRecipe(toStack(input), toStack(output)); + MineTweakerAPI.apply(new AddMekanismRecipe("CRUSHER", Recipe.CRUSHER.get(), recipe.getInput(), recipe)); + } } @ZenMethod public static void removeRecipe(IItemStack output) { + if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet"); MineTweakerAPI.apply(new RemoveMekanismRecipe("CRUSHER", Recipe.CRUSHER.get(), toStack(output))); } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/Enrichment.java b/src/main/java/modtweaker2/mods/mekanism/handlers/Enrichment.java index 3fddaac..863ccde 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/Enrichment.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/Enrichment.java @@ -2,8 +2,10 @@ package modtweaker2.mods.mekanism.handlers; import static modtweaker2.helpers.InputHelper.toStack; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.EnrichmentRecipe; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; +import modtweaker2.mods.mekanism.Mekanism; import modtweaker2.mods.mekanism.util.AddMekanismRecipe; import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe; import stanhebben.zenscript.annotations.ZenClass; @@ -13,11 +15,18 @@ import stanhebben.zenscript.annotations.ZenMethod; public class Enrichment { @ZenMethod public static void addRecipe(IItemStack input, IItemStack output) { - MineTweakerAPI.apply(new AddMekanismRecipe("ENRICHMENT_CHAMBER", Recipe.ENRICHMENT_CHAMBER.get(), toStack(input), toStack(output))); + if (Mekanism.v7) + MineTweakerAPI.apply(new AddMekanismRecipe("ENRICHMENT_CHAMBER", Recipe.ENRICHMENT_CHAMBER.get(), toStack(input), toStack(output))); + else + { + EnrichmentRecipe recipe = new EnrichmentRecipe(toStack(input), toStack(output)); + MineTweakerAPI.apply(new AddMekanismRecipe("ENRICHMENT_CHAMBER", Recipe.ENRICHMENT_CHAMBER.get(), recipe.getInput(), recipe)); + } } @ZenMethod public static void removeRecipe(IItemStack input) { + if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet"); MineTweakerAPI.apply(new RemoveMekanismRecipe("ENRICHMENT_CHAMBER", Recipe.ENRICHMENT_CHAMBER.get(), toStack(input))); } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/Infuser.java b/src/main/java/modtweaker2/mods/mekanism/handlers/Infuser.java index a1a0840..9daf3cf 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/Infuser.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/Infuser.java @@ -5,14 +5,18 @@ import static modtweaker2.helpers.StackHelper.areEqual; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import java.util.Map; import mekanism.api.infuse.InfuseRegistry; import mekanism.api.infuse.InfusionInput; import mekanism.api.infuse.InfusionOutput; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.MetallurgicInfuserRecipe; +import mekanism.common.recipe.outputs.ItemStackOutput; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; +import modtweaker2.mods.mekanism.Mekanism; import modtweaker2.mods.mekanism.util.AddMekanismRecipe; import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe; import stanhebben.zenscript.annotations.ZenClass; @@ -22,42 +26,62 @@ import stanhebben.zenscript.annotations.ZenMethod; public class Infuser { @ZenMethod public static void addRecipe(String type, int infuse, IItemStack input, IItemStack output) { - InfusionInput infuseIn = new InfusionInput(InfuseRegistry.get(type), infuse, toStack(input)); - InfusionOutput infuseOut = new InfusionOutput(infuseIn, toStack(output)); - MineTweakerAPI.apply(new AddMekanismRecipe("METALLURGIC_INFUSER", Recipe.METALLURGIC_INFUSER.get(), infuseIn, infuseOut)); + if (Mekanism.v7) + { + InfusionInput infuseIn = new InfusionInput(InfuseRegistry.get(type), infuse, toStack(input)); + InfusionOutput infuseOut = new InfusionOutput(infuseIn, toStack(output)); + MineTweakerAPI.apply(new AddMekanismRecipe("METALLURGIC_INFUSER", Recipe.METALLURGIC_INFUSER.get(), infuseIn, infuseOut)); + } + else + { + MetallurgicInfuserRecipe recipe = new MetallurgicInfuserRecipe(new mekanism.common.recipe.inputs.InfusionInput(InfuseRegistry.get(type), infuse, toStack(input)), toStack(output)); + MineTweakerAPI.apply(new AddMekanismRecipe("METALLURGIC_INFUSER", Recipe.METALLURGIC_INFUSER.get(), recipe.getInput(), recipe)); + } } @ZenMethod public static void removeRecipe(IItemStack output) { - MineTweakerAPI.apply(new Remove("METALLURGIC_INFUSER", Recipe.METALLURGIC_INFUSER.get(), new InfusionOutput(null, toStack(output)))); + if (Mekanism.v7) + { + MineTweakerAPI.apply(new Remove("METALLURGIC_INFUSER", Recipe.METALLURGIC_INFUSER.get(), new InfusionOutput(null, toStack(output)))); + } + else + { + throw new UnsupportedOperationException("Function not added to v8 compatibility yet"); + } } private static class Remove extends RemoveMekanismRecipe { public Remove(String string, Map map, Object key) { super(string, map, key); } - + private List removed = new ArrayList(); @Override public void apply() { - ArrayList recipesToRemove = new ArrayList(); Iterator it = map.entrySet().iterator(); while (it.hasNext()) { - Map.Entry pairs = (Map.Entry) it.next(); - InfusionInput key = (InfusionInput) pairs.getKey(); - InfusionOutput value = (InfusionOutput) pairs.getValue(); - if (key != null) { - if (this.key instanceof InfusionOutput && areEqual(value.resource, ((InfusionOutput) this.key).resource)) { - this.key = key; - recipesToRemove.add(key); - } - } - + Map.Entry pairs = (Map.Entry)it.next(); + InfusionInput key = (InfusionInput)pairs.getKey(); + InfusionOutput value = (InfusionOutput)pairs.getValue(); + if (key != null) + { + if (this.key instanceof InfusionOutput && areEqual(value.resource, ((InfusionOutput)this.key).resource)) + { + this.key = key; + removed.add(value); + it.remove(); + } + } } - for (InfusionInput r : recipesToRemove) { - map.remove(r); - } - recipe = map.get(key); - } - } + + @Override + public void undo() + { + for (Object recipe : removed) + { + map.put(key, recipe); + } + } + } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/Purification.java b/src/main/java/modtweaker2/mods/mekanism/handlers/Purification.java index e92dbde..f36d5d2 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/Purification.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/Purification.java @@ -8,8 +8,10 @@ import java.util.Map; import mekanism.api.AdvancedInput; import mekanism.api.gas.GasRegistry; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.PurificationRecipe; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; +import modtweaker2.mods.mekanism.Mekanism; import modtweaker2.mods.mekanism.util.AddMekanismRecipe; import modtweaker2.utils.BaseMapRemoval; import net.minecraft.item.ItemStack; @@ -20,12 +22,21 @@ import stanhebben.zenscript.annotations.ZenMethod; public class Purification { @ZenMethod public static void addRecipe(IItemStack input, IItemStack output) { - AdvancedInput aInput = new AdvancedInput(toStack(input), GasRegistry.getGas("oxygen")); - MineTweakerAPI.apply(new AddMekanismRecipe("PURIFICATION_CHAMBER", Recipe.PURIFICATION_CHAMBER.get(), aInput, toStack(output))); + if (Mekanism.v7) + { + AdvancedInput aInput = new AdvancedInput(toStack(input), GasRegistry.getGas("oxygen")); + MineTweakerAPI.apply(new AddMekanismRecipe("PURIFICATION_CHAMBER", Recipe.PURIFICATION_CHAMBER.get(), aInput, toStack(output))); + } + else + { + PurificationRecipe recipe = new PurificationRecipe(toStack(input), toStack(output)); + MineTweakerAPI.apply(new AddMekanismRecipe("PURIFICATION_CHAMBER", Recipe.PURIFICATION_CHAMBER.get(), recipe.getInput(), recipe)); + } } @ZenMethod public static void removeRecipe(IItemStack output) { + if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet"); MineTweakerAPI.apply(new Remove(toStack(output))); } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/Reaction.java b/src/main/java/modtweaker2/mods/mekanism/handlers/Reaction.java index a45ef29..004c81b 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/Reaction.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/Reaction.java @@ -10,6 +10,7 @@ import mekanism.common.recipe.RecipeHandler.Recipe; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; import minetweaker.api.liquid.ILiquidStack; +import modtweaker2.mods.mekanism.Mekanism; import modtweaker2.mods.mekanism.gas.IGasStack; import modtweaker2.mods.mekanism.util.AddMekanismRecipe; import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe; @@ -20,13 +21,21 @@ import stanhebben.zenscript.annotations.ZenMethod; public class Reaction { @ZenMethod public static void addRecipe(IItemStack solid, ILiquidStack liquid, IGasStack gas, IItemStack outItem, IGasStack outGas, double energy, int ticks) { - PressurizedReactants input = new PressurizedReactants(toStack(solid), toFluid(liquid), toGas(gas)); - PressurizedRecipe recipe = new PressurizedRecipe(input, energy, new PressurizedProducts(toStack(outItem), toGas(outGas)), ticks); - MineTweakerAPI.apply(new AddMekanismRecipe("PRESSURIZED_REACTION_CHAMBER", Recipe.PRESSURIZED_REACTION_CHAMBER.get(), input, recipe)); + if (Mekanism.v7) + { + PressurizedReactants input = new PressurizedReactants(toStack(solid), toFluid(liquid), toGas(gas)); + PressurizedRecipe recipe = new PressurizedRecipe(input, energy, new PressurizedProducts(toStack(outItem), toGas(outGas)), ticks); + MineTweakerAPI.apply(new AddMekanismRecipe("PRESSURIZED_REACTION_CHAMBER", Recipe.PRESSURIZED_REACTION_CHAMBER.get(), input, recipe)); + } + else { + mekanism.common.recipe.machines.PressurizedRecipe recipe = new mekanism.common.recipe.machines.PressurizedRecipe(toStack(solid), toFluid(liquid), toGas(gas), toStack(outItem), toGas(outGas), energy, ticks); + MineTweakerAPI.apply(new AddMekanismRecipe("PRESSURIZED_REACTION_CHAMBER", Recipe.PRESSURIZED_REACTION_CHAMBER.get(), recipe.getInput(), recipe)); + } } @ZenMethod public static void removeRecipe(IItemStack outItem, IGasStack outGas) { + if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet"); PressurizedProducts output = new PressurizedProducts(toStack(outItem), toGas(outGas)); MineTweakerAPI.apply(new RemoveMekanismRecipe("PRESSURIZED_REACTION_CHAMBER", Recipe.PRESSURIZED_REACTION_CHAMBER.get(), output)); } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/Sawmill.java b/src/main/java/modtweaker2/mods/mekanism/handlers/Sawmill.java index d64687f..d2d5d77 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/Sawmill.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/Sawmill.java @@ -7,8 +7,10 @@ import java.util.Map; import mekanism.api.ChanceOutput; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.SawmillRecipe; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; +import modtweaker2.mods.mekanism.Mekanism; import modtweaker2.mods.mekanism.util.AddMekanismRecipe; import modtweaker2.utils.BaseMapRemoval; import net.minecraft.item.ItemStack; @@ -20,12 +22,21 @@ import stanhebben.zenscript.annotations.ZenMethod; public class Sawmill { @ZenMethod public static void addRecipe(IItemStack input, IItemStack output1, @Optional IItemStack output2, @Optional double chance) { - ChanceOutput chanceOutput = new ChanceOutput(toStack(output1), toStack(output2), chance); - MineTweakerAPI.apply(new AddMekanismRecipe("PRECISION_SAWMILL", Recipe.PRECISION_SAWMILL.get(), toStack(input), chanceOutput)); + if (Mekanism.v7) + { + ChanceOutput chanceOutput = new ChanceOutput(toStack(output1), toStack(output2), chance); + MineTweakerAPI.apply(new AddMekanismRecipe("PRECISION_SAWMILL", Recipe.PRECISION_SAWMILL.get(), toStack(input), chanceOutput)); + } + else + { + SawmillRecipe recipe = chance>0?new SawmillRecipe(toStack(input), toStack(output1), toStack(output2), chance) : new SawmillRecipe(toStack(input), toStack(output1)); + MineTweakerAPI.apply(new AddMekanismRecipe("PRECISION_SAWMILL", Recipe.PRECISION_SAWMILL.get(), recipe.getInput(), recipe)); + } } @ZenMethod public static void removeRecipe(IItemStack input) { + if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet"); MineTweakerAPI.apply(new Remove(toStack(input))); } @@ -37,7 +48,7 @@ public class Sawmill { //We must search through the recipe entries so that we can assign the correct key for removal @Override public void apply() { - for (Map.Entry entry : ((Map) map).entrySet()) { + for (Map.Entry entry : ((Map) map).entrySet()) { if (entry.getKey() != null && areEqual(entry.getKey(), (ItemStack) stack)) { key = entry.getKey(); break; diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/Separator.java b/src/main/java/modtweaker2/mods/mekanism/handlers/Separator.java index e54ab40..ca509b6 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/Separator.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/Separator.java @@ -7,8 +7,10 @@ import java.util.Map; import mekanism.api.ChemicalPair; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.SeparatorRecipe; import minetweaker.MineTweakerAPI; import minetweaker.api.liquid.ILiquidStack; +import modtweaker2.mods.mekanism.Mekanism; import modtweaker2.mods.mekanism.gas.IGasStack; import modtweaker2.mods.mekanism.util.AddMekanismRecipe; import modtweaker2.utils.BaseMapRemoval; @@ -20,12 +22,31 @@ import stanhebben.zenscript.annotations.ZenMethod; public class Separator { @ZenMethod public static void addRecipe(ILiquidStack input, IGasStack gas1, IGasStack gas2) { - ChemicalPair pair = new ChemicalPair(toGas(gas1), toGas(gas2)); - MineTweakerAPI.apply(new AddMekanismRecipe("ELECTROLYTIC_SEPARATOR", Recipe.ELECTROLYTIC_SEPARATOR.get(), toFluid(input), pair)); + if (Mekanism.v7) + { + ChemicalPair pair = new ChemicalPair(toGas(gas1), toGas(gas2)); + MineTweakerAPI.apply(new AddMekanismRecipe("ELECTROLYTIC_SEPARATOR", Recipe.ELECTROLYTIC_SEPARATOR.get(), toFluid(input), pair)); + } else + { + throw new UnsupportedOperationException("Syntax for v8 is: Fluid, Energy, Gas, Gas"); + } + } + + @ZenMethod + public static void addRecipe(ILiquidStack input, double energy, IGasStack gas1, IGasStack gas2) { + if (Mekanism.v7) + { + throw new UnsupportedOperationException("Syntax for v7 is: Fluid, Gas, Gas"); + } else + { + SeparatorRecipe recipe = new SeparatorRecipe(toFluid(input), energy, toGas(gas1), toGas(gas2)); + MineTweakerAPI.apply(new AddMekanismRecipe("ELECTROLYTIC_SEPARATOR", Recipe.ELECTROLYTIC_SEPARATOR.get(), recipe.getInput(), recipe)); + } } @ZenMethod public static void removeRecipe(ILiquidStack input) { + if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet"); MineTweakerAPI.apply(new Remove(toFluid(input))); } diff --git a/src/main/java/modtweaker2/mods/mekanism/util/AddMekanismRecipe.java b/src/main/java/modtweaker2/mods/mekanism/util/AddMekanismRecipe.java index 81bae1f..32cc858 100644 --- a/src/main/java/modtweaker2/mods/mekanism/util/AddMekanismRecipe.java +++ b/src/main/java/modtweaker2/mods/mekanism/util/AddMekanismRecipe.java @@ -7,6 +7,7 @@ import mekanism.api.ChemicalPair; import mekanism.api.PressurizedReactants; import mekanism.api.gas.GasStack; import mekanism.api.infuse.InfusionOutput; +import modtweaker2.mods.mekanism.Mekanism; import modtweaker2.utils.BaseMapAddition; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; @@ -18,25 +19,47 @@ public class AddMekanismRecipe extends BaseMapAddition { @Override public String describe() { - if (recipe instanceof ItemStack) return "Adding " + description + " Recipe for : " + ((ItemStack) recipe).getDisplayName(); - else if (recipe instanceof FluidStack) return "Adding " + description + " Recipe for : " + ((FluidStack) recipe).getFluid().getLocalizedName(); - else if (recipe instanceof ChemicalPair) return "Adding " + description + " Recipe for : " + ((ChemicalPair) recipe).leftGas.getGas().getLocalizedName(); - else if (recipe instanceof ChanceOutput) return "Adding " + description + " Recipe for : " + ((ChanceOutput) recipe).primaryOutput.getDisplayName(); - else if (recipe instanceof GasStack) return "Adding " + description + " Recipe for : " + ((GasStack) recipe).getGas().getLocalizedName(); - else if (recipe instanceof PressurizedReactants) return "Adding " + description + " Recipe for : " + ((PressurizedReactants) recipe).getSolid().getDisplayName(); - else if (recipe instanceof InfusionOutput) return "Adding " + description + " Recipe for : " + ((InfusionOutput) recipe).resource.getDisplayName(); - else return super.getRecipeInfo(); + if (Mekanism.v7) + { + if (recipe instanceof ItemStack) + return "Adding " + description + " Recipe for : " + ((ItemStack)recipe).getDisplayName(); + else if (recipe instanceof FluidStack) + return "Adding " + description + " Recipe for : " + ((FluidStack)recipe).getFluid().getLocalizedName(); + else if (recipe instanceof ChemicalPair) + return "Adding " + description + " Recipe for : " + ((ChemicalPair)recipe).leftGas.getGas().getLocalizedName(); + else if (recipe instanceof ChanceOutput) + return "Adding " + description + " Recipe for : " + ((ChanceOutput)recipe).primaryOutput.getDisplayName(); + else if (recipe instanceof GasStack) + return "Adding " + description + " Recipe for : " + ((GasStack)recipe).getGas().getLocalizedName(); + else if (recipe instanceof PressurizedReactants) + return "Adding " + description + " Recipe for : " + ((PressurizedReactants)recipe).getSolid().getDisplayName(); + else if (recipe instanceof InfusionOutput) + return "Adding " + description + " Recipe for : " + ((InfusionOutput)recipe).resource.getDisplayName(); + else return super.getRecipeInfo(); + } + return ""; } @Override public String describeUndo() { - if (recipe instanceof ItemStack) return "Removing " + description + " Recipe for : " + ((ItemStack) recipe).getDisplayName(); - else if (recipe instanceof FluidStack) return "Removing " + description + " Recipe for : " + ((FluidStack) recipe).getFluid().getLocalizedName(); - else if (recipe instanceof ChemicalPair) return "Removing " + description + " Recipe for : " + ((ChemicalPair) recipe).leftGas.getGas().getLocalizedName(); - else if (recipe instanceof ChanceOutput) return "Removing " + description + " Recipe for : " + ((ChanceOutput) recipe).primaryOutput.getDisplayName(); - else if (recipe instanceof GasStack) return "Removing " + description + " Recipe for : " + ((GasStack) recipe).getGas().getLocalizedName(); - else if (recipe instanceof PressurizedReactants) return "Removing " + description + " Recipe for : " + ((PressurizedReactants) recipe).getSolid().getDisplayName(); - else if (recipe instanceof InfusionOutput) return "Removing " + description + " Recipe for : " + ((InfusionOutput) recipe).resource.getDisplayName(); - else return super.getRecipeInfo(); + if (Mekanism.isV7()) + { + if (recipe instanceof ItemStack) + return "Removing " + description + " Recipe for : " + ((ItemStack)recipe).getDisplayName(); + else if (recipe instanceof FluidStack) + return "Removing " + description + " Recipe for : " + ((FluidStack)recipe).getFluid().getLocalizedName(); + else if (recipe instanceof ChemicalPair) + return "Removing " + description + " Recipe for : " + ((ChemicalPair)recipe).leftGas.getGas().getLocalizedName(); + else if (recipe instanceof ChanceOutput) + return "Removing " + description + " Recipe for : " + ((ChanceOutput)recipe).primaryOutput.getDisplayName(); + else if (recipe instanceof GasStack) + return "Removing " + description + " Recipe for : " + ((GasStack)recipe).getGas().getLocalizedName(); + else if (recipe instanceof PressurizedReactants) + return "Removing " + description + " Recipe for : " + ((PressurizedReactants)recipe).getSolid().getDisplayName(); + else if (recipe instanceof InfusionOutput) + return "Removing " + description + " Recipe for : " + ((InfusionOutput)recipe).resource.getDisplayName(); + else return super.getRecipeInfo(); + } + return ""; } } diff --git a/src/main/java/modtweaker2/utils/TweakerPlugin.java b/src/main/java/modtweaker2/utils/TweakerPlugin.java index 87427e6..fd7bdae 100644 --- a/src/main/java/modtweaker2/utils/TweakerPlugin.java +++ b/src/main/java/modtweaker2/utils/TweakerPlugin.java @@ -9,12 +9,16 @@ public class TweakerPlugin { public static void register(String mod, Class clazz) { if (Loader.isModLoaded(mod)) { - try { - clazz.newInstance(); - isLoaded.add(mod); - } catch (Exception e) { - isLoaded.remove(mod); - } + load(mod, clazz); + } + } + + public static void load(String mod, Class clazz) { + try { + clazz.newInstance(); + isLoaded.add(mod); + } catch (Exception e) { + isLoaded.remove(mod); } }