ModTweaker2 Rework

- Revised base classes for IUndoableAction
- Reordered lots of code, so stuck actions should be less frequent
- Added wildcard support to many "remove" methods
- Started working on exist & duplicate checks
This commit is contained in:
Zixxl committed 2015-06-29 16:36:35 +02:00
1 parent f5034b04d8
commit da33cc6fab
112 files changed
+4596 -3522

No files matched your search

@@ -4,11 +4,8 @@ import static modtweaker2.helpers.LogHelper.print;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.api.player.IPlayer;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+1 -4
View File
@@ -2,10 +2,8 @@ package modtweaker2;
import java.io.File;
import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.MineTweakerImplementationAPI.ReloadEvent;
import minetweaker.mc1710.MineTweakerMod;
import minetweaker.runtime.providers.ScriptProviderDirectory;
import minetweaker.util.IEventHandler;
import modtweaker2.mods.appeng.AppliedEnergistics;
@@ -18,7 +16,6 @@ import modtweaker2.mods.factorization.Factorization;
import modtweaker2.mods.forestry.Forestry;
import modtweaker2.mods.fsp.Steamcraft;
import modtweaker2.mods.mariculture.Mariculture;
import modtweaker2.mods.mekanism.Mekanism;
import modtweaker2.mods.metallurgy.Metallurgy;
import modtweaker2.mods.pneumaticcraft.PneumaticCraft;
import modtweaker2.mods.railcraft.Railcraft;
@@ -74,7 +71,7 @@ public class ModTweaker2 {
TweakerPlugin.register("extendedWorkbench", ExtendedWorkbench.class);
TweakerPlugin.register("factorization", Factorization.class);
TweakerPlugin.register("Mariculture", Mariculture.class);
TweakerPlugin.register("Mekanism", Mekanism.class);
// TweakerPlugin.register("Mekanism", Mekanism.class);
TweakerPlugin.register("Metallurgy", Metallurgy.class);
TweakerPlugin.register("PneumaticCraft", PneumaticCraft.class);
TweakerPlugin.register("Railcraft", Railcraft.class);
@@ -1,11 +1,12 @@
package modtweaker2.helpers;
import static modtweaker2.helpers.ReflectionHelper.getFinalObject;
import static modtweaker2.helpers.ReflectionHelper.getStaticObject;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static modtweaker2.helpers.ReflectionHelper.*;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
@@ -2,13 +2,16 @@ package modtweaker2.helpers;
import java.util.ArrayList;
import minetweaker.MineTweakerAPI;
import minetweaker.api.entity.IEntity;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import minetweaker.api.oredict.IOreDictEntry;
import minetweaker.mc1710.data.NBTConverter;
import minetweaker.mc1710.item.MCItemStack;
import minetweaker.mc1710.liquid.MCLiquidStack;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
@@ -18,11 +21,55 @@ import net.minecraftforge.fluids.FluidStack;
public class InputHelper {
public static boolean isABlock(IItemStack block) {
if (!(isABlock(toStack(block)))) {
MineTweakerAPI.getLogger().logError("Item must be a block, or you must specify a block to render as when adding a TConstruct Melting recipe");
LogHelper.logError("Item must be a block, or you must specify a block to render as when adding a TConstruct Melting recipe");
return false;
} else
return true;
}
/**
* Returns a string representation of the item which can also be used in scripts
*/
public static String getStackDescription(ItemStack stack) {
if(stack != null) {
StringBuilder sb = new StringBuilder();
// Creates a name like <minecraft:piston> or <appliedenergistics2:item.ItemMultiMaterial:156>
sb.append('<');
sb.append(Item.itemRegistry.getNameForObject(stack.getItem()));
if(stack.getItemDamage() == 32767) {
sb.append(":*");
} else if (stack.getItemDamage() > 0) {
sb.append(":").append(stack.getItemDamage());
}
sb.append('>');
// Do we have a tag? (e.g. <Botania:specialFlower>.withTag({}) )
if(stack.getTagCompound() != null)
{
sb.append(".withTag(");
sb.append(NBTConverter.from(stack.getTagCompound(), true));
sb.append(')');
}
// Do we have a stack size > 1?
if(stack.stackSize > 1) {
sb.append(" * ").append(stack.stackSize);
}
return sb.toString();
} else {
return "null object";
}
}
public static String getStackDescription(FluidStack stack) {
if(stack != null) {
return "<liquid:" + stack.getFluid().getName() + ">";
} else {
return "null object";
}
}
public static IItemStack[] toStacks(IIngredient[] iIngredient) {
ArrayList<IItemStack> stacks = new ArrayList<IItemStack>();
@@ -52,12 +99,39 @@ public class InputHelper {
else {
Object internal = iStack.getInternal();
if (internal == null || !(internal instanceof ItemStack)) {
MineTweakerAPI.getLogger().logError("Not a valid item stack: " + iStack);
LogHelper.logError("Not a valid item stack: " + iStack);
}
return (ItemStack) internal;
}
}
public static IIngredient toIngredient(ItemStack stack) {
return toIItemStack(stack);
}
public static IIngredient toIngredient(FluidStack stack) {
if(stack == null)
return null;
return new MCLiquidStack(stack);
}
public static IItemStack toIItemStack(ItemStack stack) {
if(stack == null) {
return null;
}
return new MCItemStack(stack);
}
public static ILiquidStack toILiquidStack(FluidStack stack) {
if(stack == null) {
return null;
}
return new MCLiquidStack(stack);
}
public static ItemStack[] toStacks(IItemStack[] iStack) {
if (iStack == null)
@@ -21,4 +21,20 @@ public class LogHelper {
System.out.println(string);
MineTweakerAPI.logCommand(string);
}
public static void logError(String message) {
MineTweakerAPI.logError("[ModTweaker2] " + message);
}
public static void logError(String message, Throwable exception) {
MineTweakerAPI.logError("[ModTweaker2] " + message, exception);
}
public static void logWarning(String message) {
MineTweakerAPI.logWarning("[ModTweaker2] " + message);
}
public static void logInfo(String message) {
MineTweakerAPI.logInfo("[ModTweaker2] " + message);
}
}
@@ -1,19 +1,90 @@
package modtweaker2.helpers;
//import modtweaker2.mods.botania.Botania;
import static modtweaker2.helpers.InputHelper.toStack;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.mods.botania.Botania;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.item.ItemStack;
public class StackHelper {
// Stack is the stack that is part of a recipe, stack2 is the one input
// trying to match
public static boolean areEqual(ItemStack stack, ItemStack stack2) {
if (stack == null || stack2 == null)
/**
* Compares two ItemStack instances, trying to match the referenced item.
*/
public static boolean areEqual(ItemStack stack1, ItemStack stack2) {
if (stack1 == null || stack2 == null) {
return false;
else if (TweakerPlugin.isLoaded("Botania") && Botania.isSubtile(stack) && Botania.isSubtile(stack2)) {
return Botania.subtileMatches(stack, stack2);
} else
return stack.isItemEqual(stack2);
} else if (TweakerPlugin.isLoaded("Botania") && Botania.isSubtile(stack1) && Botania.isSubtile(stack2)) {
return Botania.subtileMatches(stack1, stack2);
} else {
return stack1.isItemEqual(stack2);
}
}
/**
* Compares two ItemStack instances if they reference the same object or
* are both null. If false, the method areEqual() is called to check if the
* two instances reference the same item.
*/
public static boolean areEqualOrNull(ItemStack stack1, ItemStack stack2) {
// Check if they reference the same object or are are both null
if(stack1 == stack2) {
return true;
}
return(areEqual(stack1, stack2));
}
/**
* Adds extra check to IIngredient matches() for Botania special flowers
*/
public static boolean matches(IIngredient ingredient, IItemStack itemStack) {
if(ingredient == null) {
return false;
}
if(!ingredient.matches(itemStack)) {
return false;
}
// Do we have a wildcard (<*>) or an actual item?
if(ingredient.getItems() != null) {
for(IItemStack item : ingredient.getItems()) {
if(areEqual(toStack(item), toStack(itemStack))) {
return true;
}
}
} else {
return true;
}
return false;
}
/**
* This function compares an ingredient with a fluid. MCLiquidStack.matches() function
* is currently broken in MineTweaker3, thus this function is only a workaround.
*/
public static boolean matches(IIngredient ingredient, ILiquidStack liquidStack) {
if(ingredient == null) {
return false;
}
// Do we have a wildcard (<*>) ?
if(ingredient.matches(liquidStack)) {
return true;
}
// Does ingredient reference liquids?
if(ingredient.getLiquids() != null) {
for (ILiquidStack liquid : ingredient.getLiquids()) {
if(InputHelper.toFluid(liquid).isFluidEqual(InputHelper.toFluid(liquidStack))) {
return true;
}
}
}
return false;
}
}
@@ -9,7 +9,5 @@ public class AppliedEnergistics {
public AppliedEnergistics() {
MineTweakerAPI.registerClass(Inscriber.class);
MineTweakerAPI.registerClass(Grind.class);
}
}
@@ -0,0 +1,77 @@
package modtweaker2.mods.appeng;
import static modtweaker2.helpers.StackHelper.areEqualOrNull;
import net.minecraft.item.ItemStack;
import appeng.api.features.IGrinderEntry;
import appeng.api.features.IInscriberRecipe;
public class AppliedEnergisticsHelper {
/**
* Compares two IInscriberRecipe objects, if they are the same or have the same inputs
*/
public static boolean equals(IInscriberRecipe r1, IInscriberRecipe r2) {
if(r1 == r2) {
return true;
}
if (r1 == null || r2 == null) {
return false;
}
if(!areEqualOrNull(r1.getTopOptional().orNull(), r2.getTopOptional().orNull())) {
return false;
}
if(!areEqualOrNull(r1.getBottomOptional().orNull(), r2.getBottomOptional().orNull())) {
return false;
}
if(r1.getInputs() == null && r2.getInputs() != null || r1.getInputs() != null && r2.getInputs() == null) {
return false;
}
if(r1.getInputs() != null && r2.getInputs() != null) {
if(r1.getInputs().size() != r2.getInputs().size()) {
return false;
}
// Check if every item in recipe 1 is in recipe 2
for(ItemStack i1 : r1.getInputs()) {
boolean found = false;
for(ItemStack i2 : r2.getInputs()) {
if(areEqualOrNull(i1, i2)) {
found = true;
}
}
if(!found) {
return false;
}
}
}
return true;
}
/**
* Compares two IGrinderEntry objects, if they are the same or have the same inputs
*/
public static boolean equals(IGrinderEntry r1, IGrinderEntry r2) {
if(r1 == r2) {
return true;
}
if (r1 == null || r2 == null) {
return false;
}
if(!areEqualOrNull(r1.getInput(), r2.getInput())) {
return false;
}
return true;
}
}
@@ -1,14 +1,20 @@
package modtweaker2.mods.appeng.handlers;
import java.util.ArrayList;
import java.util.List;
import static modtweaker2.helpers.InputHelper.getStackDescription;
import static modtweaker2.helpers.InputHelper.toIngredient;
import static modtweaker2.helpers.InputHelper.toStack;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.appeng.AppliedEnergisticsHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import appeng.api.AEApi;
@@ -17,49 +23,83 @@ import appeng.core.features.registries.entries.AppEngGrinderRecipe;
@ZenClass("mods.appeng.Grinder")
public class Grind {
protected static final String name = "Applied Energistics 2 Grinder";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output, int energy, @Optional IItemStack output2, @Optional float chance2, @Optional IItemStack output3, @Optional float chance3) {
// Create recipe
IGrinderEntry recipe;
if(output2 != null && output3 != null)
recipe = new AppEngGrinderRecipe(InputHelper.toStack(input), InputHelper.toStack(output), InputHelper.toStack(output2), InputHelper.toStack(output3), chance2, chance3, energy);
else if(output2 != null)
recipe = new AppEngGrinderRecipe(InputHelper.toStack(input), InputHelper.toStack(output), InputHelper.toStack(output2), chance2, energy);
else
recipe = new AppEngGrinderRecipe(InputHelper.toStack(input), InputHelper.toStack(output), energy);
// Check if the recipe is already present, we don't want to add duplicates
for(IGrinderEntry r : AEApi.instance().registries().grinder().getRecipes()) {
if(r != null && AppliedEnergisticsHelper.equals(r, recipe)) {
LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", Grind.name, InputHelper.getStackDescription(toStack(input))));
return;
}
}
MineTweakerAPI.apply(new Add(recipe));
}
private static class Add extends BaseListAddition<IGrinderEntry> {
public Add(IGrinderEntry recipe) {
super(Grind.name, AEApi.instance().registries().grinder().getRecipes());
recipes.add(recipe);
}
@Override
public String getRecipeInfo(IGrinderEntry recipe) {
return getStackDescription(recipe.getInput());
}
@Override
protected boolean equals(IGrinderEntry recipe, IGrinderEntry otherRecipe) {
return AppliedEnergisticsHelper.equals(recipe, otherRecipe);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output, int energy) {
MineTweakerAPI.apply(new Add(new AppEngGrinderRecipe(InputHelper.toStack(input), InputHelper.toStack(output), energy)));
public static void removeRecipe(IIngredient output) {
// Get list of existing recipes, matching with parameter
LinkedList<IGrinderEntry> result = new LinkedList<IGrinderEntry>();
for(IGrinderEntry entry : AEApi.instance().registries().grinder().getRecipes()) {
if(entry != null && entry.getOutput() != null && output.contains(toIngredient(entry.getOutput()))) {
result.add(entry);
}
}
// Check if we found the recipes and apply the action
if(!result.isEmpty()) {
MineTweakerAPI.apply(new Remove(result));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Grind.name, output.toString()));
}
}
private static class Add extends BaseListAddition {
public Add(AppEngGrinderRecipe recipe) {
super(AEApi.instance().registries().grinder().getRecipes(), recipe);
private static class Remove extends BaseListRemoval<IGrinderEntry> {
public Remove(LinkedList<IGrinderEntry> recipes) {
super(Grind.name, AEApi.instance().registries().grinder().getRecipes(), recipes);
}
@Override
public void apply() {
AEApi.instance().registries().grinder().getRecipes().add((AppEngGrinderRecipe) recipe);
public String getRecipeInfo(IGrinderEntry recipe) {
return getStackDescription(recipe.getOutput());
}
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(InputHelper.toStack(output)));
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Applied Energistics 2 Grinder", AEApi.instance().registries().grinder().getRecipes(), stack);
}
@Override
public void apply() {
for (IGrinderEntry r : AEApi.instance().registries().grinder().getRecipes()) {
if (r.getOutput().isItemEqual(stack)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -1,77 +1,151 @@
package modtweaker2.mods.appeng.handlers;
import static modtweaker2.helpers.InputHelper.getStackDescription;
import static modtweaker2.helpers.InputHelper.toIngredient;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.InputHelper.toStacks;
import java.util.ArrayList;
import java.util.LinkedList;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.appeng.AppliedEnergisticsHelper;
import modtweaker2.utils.ArrayUtils;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import appeng.api.AEApi;
import appeng.api.features.IInscriberRecipe;
import appeng.api.features.InscriberProcessType;
import appeng.core.features.registries.entries.InscriberRecipe;
import appeng.recipes.handlers.Inscribe;
@ZenClass("mods.appeng.Inscriber")
public class Inscriber {
protected static final String name = "Applied Energistics 2 Inscriber";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack[] imprintable, IItemStack plateA, IItemStack plateB, IItemStack out, String type) {
MineTweakerAPI.apply(new Add(new InscriberRecipe(ArrayUtils.toArrayList(toStacks(imprintable)), toStack(out), toStack(plateA), toStack(plateB), InscriberProcessType.valueOf(type))));
for (IItemStack stack : imprintable) {
AEApi.instance().registries().inscriber().getInputs().add(toStack(stack));
}
if (plateA != null)
AEApi.instance().registries().inscriber().getOptionals().add(toStack(plateA));
if (plateB != null)
AEApi.instance().registries().inscriber().getOptionals().add(toStack(plateB));
// Create recipe
IInscriberRecipe recipe = new InscriberRecipe(ArrayUtils.toArrayList(toStacks(imprintable)), toStack(out), toStack(plateA), toStack(plateB), InscriberProcessType.valueOf(type));
// Check if the recipe is already present, we don't want to add duplicates
for(IInscriberRecipe r : AEApi.instance().registries().inscriber().getRecipes()) {
if(r != null && AppliedEnergisticsHelper.equals(r, recipe)) {
LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", Inscriber.name, InputHelper.getStackDescription(toStack(out))));
return;
}
}
MineTweakerAPI.apply(new Add(recipe));
}
public static class Add extends BaseListAddition {
public static class Add extends BaseListAddition<IInscriberRecipe> {
public Add(IInscriberRecipe recipe) {
super(recipe.toString(), AEApi.instance().registries().inscriber().getRecipes(), recipe);
super(Inscriber.name, AEApi.instance().registries().inscriber().getRecipes());
recipes.add(recipe);
}
@Override
public void apply() {
AEApi.instance().registries().inscriber().addRecipe((IInscriberRecipe) recipe);
}
if(recipes.isEmpty()) {
return;
}
for(IInscriberRecipe recipe : recipes) {
try {
AEApi.instance().registries().inscriber().addRecipe(recipe);
successful.add(recipe);
} catch (Exception ex) { LogHelper.logError("Error adding inscriber recipe.", ex); }
}
}
@Override
public void undo() {
if(successful.isEmpty()) {
return;
}
for(IInscriberRecipe recipe : successful) {
try {
AEApi.instance().registries().inscriber().removeRecipe(recipe);
} catch (Exception ex) { LogHelper.logError("Error removing inscriber recipe.", ex); }
}
}
@Override
public String getRecipeInfo(IInscriberRecipe recipe) {
return getStackDescription(recipe.getOutput());
}
@Override
protected boolean equals(IInscriberRecipe recipe, IInscriberRecipe otherRecipe) {
return AppliedEnergisticsHelper.equals(recipe, otherRecipe);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
public static void removeRecipe(IIngredient output) {
// Get list of existing recipes, matching with parameter
LinkedList<IInscriberRecipe> result = new LinkedList<IInscriberRecipe>();
for(IInscriberRecipe entry : AEApi.instance().registries().inscriber().getRecipes()) {
if(entry != null && entry.getOutput() != null && output.contains(toIngredient(entry.getOutput()))) {
result.add(entry);
}
}
// Check if we found the recipes and apply the action
if(!result.isEmpty()) {
MineTweakerAPI.apply(new Remove(result));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Inscriber.name, output.toString()));
}
}
public static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Applied Energistics 2 Inscriber", AEApi.instance().registries().inscriber().getRecipes(), stack);
}
@Override
public void apply() {
for (IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes()) {
if (recipe != null && recipe.getOutput() != null && recipe.getOutput().isItemEqual(stack)) {
recipes.add(recipe);
}
}
super.apply();
public static class Remove extends BaseListRemoval<IInscriberRecipe> {
public Remove(LinkedList<IInscriberRecipe> recipes) {
super(Inscriber.name, AEApi.instance().registries().inscriber().getRecipes(), recipes);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
@Override
public void apply() {
if(this.recipes.isEmpty()) {
return;
}
for(IInscriberRecipe recipe : recipes) {
try {
AEApi.instance().registries().inscriber().removeRecipe(recipe);
successful.add(recipe);
} catch (Exception ex) { LogHelper.logError("Error removing inscriber recipe.", ex); }
}
}
@Override
public void undo() {
if(successful.isEmpty()) {
return;
}
for(IInscriberRecipe recipe : successful) {
try {
AEApi.instance().registries().inscriber().addRecipe(recipe);
} catch (Exception ex) { LogHelper.logError("Error restoring inscriber recipe.", ex); }
}
}
@Override
public String getRecipeInfo(IInscriberRecipe recipe) {
return getStackDescription(recipe.getOutput());
}
}
}
@@ -2,8 +2,6 @@ package modtweaker2.mods.auracascade.aura;
import java.util.List;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import minetweaker.IBracketHandler;
import minetweaker.MineTweakerAPI;
import minetweaker.annotations.BracketHandler;
@@ -56,8 +54,8 @@ public class AuraBracketHandler implements IBracketHandler {
}
private IZenSymbol find(IEnvironmentGlobal environment, List<Token> tokens, int startIndex, int endIndex) {
StringBuilder valueBuilder = new StringBuilder();
// }
//StringBuilder valueBuilder = new StringBuilder();
for (EnumAura a : EnumAura.values()) {
for (int i = startIndex; i < endIndex; i++) {
Token token = tokens.get(i);
@@ -1,14 +1,11 @@
package modtweaker2.mods.auracascade.aura;
import java.util.Set;
import pixlepix.auracascade.data.EnumAura;
import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.api.player.IPlayer;
import minetweaker.api.server.ICommandFunction;
import modtweaker2.ModTweaker2;
import net.minecraft.entity.EntityList;
import pixlepix.auracascade.data.EnumAura;
public class AuraLogger implements ICommandFunction {
@@ -1,16 +1,20 @@
package modtweaker2.mods.auracascade.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.auracascade.AuraCascadeHelper;
import modtweaker2.mods.auracascade.aura.IAuraStack;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import pixlepix.auracascade.data.recipe.PylonRecipe;
import pixlepix.auracascade.data.recipe.PylonRecipeComponent;
import pixlepix.auracascade.data.recipe.PylonRecipeRegistry;
@@ -19,7 +23,11 @@ import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.auraCascade.Pylon")
public class Pylon {
protected static final String name = "Aura Cascade Pylon";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack ouput, IAuraStack stack, IItemStack input) {
addRecipe(ouput, stack, input, stack, input, stack, input, stack, input);
@@ -27,37 +35,53 @@ public class Pylon {
@ZenMethod
public static void addRecipe(IItemStack ouput, IAuraStack aura1, IItemStack input1, IAuraStack aura2, IItemStack input2, IAuraStack aura3, IItemStack input3, IAuraStack aura4, IItemStack input4) {
MineTweakerAPI.apply(new Add(new PylonRecipe(toStack(ouput), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura1), toStack(input1)), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura2), toStack(input2)), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura3), toStack(input3)), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura1), toStack(input4)))));
List<PylonRecipe> recipes = new LinkedList<PylonRecipe>();
recipes.add(new PylonRecipe(toStack(ouput), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura1), toStack(input1)), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura2), toStack(input2)), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura3), toStack(input3)), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura1), toStack(input4))));
MineTweakerAPI.apply(new Add(recipes));
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<PylonRecipe> {
public Add(PylonRecipe recipe) {
super(PylonRecipeRegistry.recipes, recipe);
public Add(List<PylonRecipe> recipes) {
super(Pylon.name, PylonRecipeRegistry.recipes, recipes);
}
@Override
protected String getRecipeInfo(PylonRecipe recipe) {
return InputHelper.getStackDescription(recipe.result);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack ouput) {
MineTweakerAPI.apply(new Remove(toStack(ouput)));
public static void removeRecipe(IIngredient output) {
List<PylonRecipe> recipes = new LinkedList<PylonRecipe>();
for (PylonRecipe r : PylonRecipeRegistry.recipes) {
if (output.matches(toIItemStack(r.result))) {
recipes.add(r);
}
}
// Check if we found the recipes and apply the action
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Pylon.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super(PylonRecipeRegistry.recipes, stack);
}
@Override
public void apply() {
for (PylonRecipe r : PylonRecipeRegistry.recipes) {
if (r.result.isItemEqual(stack)) {
recipes.add(r);
}
}
super.apply();
private static class Remove extends BaseListRemoval<PylonRecipe> {
public Remove(List<PylonRecipe> recipes) {
super(Pylon.name, PylonRecipeRegistry.recipes, recipes);
}
@Override
protected String getRecipeInfo(PylonRecipe recipe) {
return InputHelper.getStackDescription(recipe.result);
}
}
}
@@ -1,14 +1,20 @@
package modtweaker2.mods.botania.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toObjects;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import vazkii.botania.api.BotaniaAPI;
@@ -17,6 +23,11 @@ import vazkii.botania.common.item.block.ItemBlockSpecialFlower;
@ZenClass("mods.botania.Apothecary")
public class Apothecary {
protected static final String name = "Botania Petal";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack output, IIngredient[] input) {
MineTweakerAPI.apply(new Add(new RecipePetals(toStack(output), toObjects(input))));
@@ -24,50 +35,55 @@ public class Apothecary {
@ZenMethod
public static void addRecipe(String output, IIngredient[] input) {
MineTweakerAPI.apply(new Add(new RecipePetals(ItemBlockSpecialFlower.ofType(output), toObjects(input))));
addRecipe(toIItemStack(ItemBlockSpecialFlower.ofType(output)), input);
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<RecipePetals> {
public Add(RecipePetals recipe) {
super("Botania Petal Recipe", BotaniaAPI.petalRecipes, recipe);
super("Botania Petal", BotaniaAPI.petalRecipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((RecipePetals) recipe).getOutput().getDisplayName();
public String getRecipeInfo(RecipePetals recipe) {
return InputHelper.getStackDescription(recipe.getOutput());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
public static void removeRecipe(IIngredient output) {
// Get list of existing recipes, matching with parameter
LinkedList<RecipePetals> result = new LinkedList<RecipePetals>();
for(RecipePetals entry : BotaniaAPI.petalRecipes) {
if(entry != null && entry.getOutput() != null && matches(output, toIItemStack(entry.getOutput()))) {
result.add(entry);
}
}
// Check if we found the recipes and apply the action
if(!result.isEmpty()) {
MineTweakerAPI.apply(new Remove(result));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Apothecary.name, output.toString()));
}
}
@ZenMethod
public static void removeRecipe(String output) {
MineTweakerAPI.apply(new Remove(ItemBlockSpecialFlower.ofType(output)));
removeRecipe(toIItemStack(ItemBlockSpecialFlower.ofType(output)));
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Botania Petal recipe", BotaniaAPI.petalRecipes, stack);
private static class Remove extends BaseListRemoval<RecipePetals> {
public Remove(List<RecipePetals> recipes) {
super(Apothecary.name, BotaniaAPI.petalRecipes, recipes);
}
@Override
public void apply() {
for (RecipePetals r : BotaniaAPI.petalRecipes) {
if (areEqual(r.getOutput(), stack)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(RecipePetals recipe) {
return InputHelper.getStackDescription(recipe.getOutput());
}
}
}
@@ -1,14 +1,20 @@
package modtweaker2.mods.botania.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toObjects;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import vazkii.botania.api.BotaniaAPI;
@@ -16,47 +22,57 @@ import vazkii.botania.api.recipe.RecipeElvenTrade;
@ZenClass("mods.botania.ElvenTrade")
public class ElvenTrade {
protected static final String name = "Botania Eleven Trade";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack output, IIngredient[] input) {
MineTweakerAPI.apply(new Add(new RecipeElvenTrade(toStack(output), toObjects(input))));
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<RecipeElvenTrade> {
public Add(RecipeElvenTrade recipe) {
super("Botania Eleven Trade", BotaniaAPI.elvenTradeRecipes, recipe);
super(ElvenTrade.name, BotaniaAPI.elvenTradeRecipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((RecipeElvenTrade) recipe).getOutput().getDisplayName();
public String getRecipeInfo(RecipeElvenTrade recipe) {
return InputHelper.getStackDescription(recipe.getOutput());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
public static void removeRecipe(IIngredient output) {
// Get list of existing recipes, matching with parameter
LinkedList<RecipeElvenTrade> recipes = new LinkedList<RecipeElvenTrade>();
for(RecipeElvenTrade entry : BotaniaAPI.elvenTradeRecipes) {
if(entry != null && entry.getOutput() != null && matches(output, toIItemStack(entry.getOutput()))) {
recipes.add(entry);
}
}
// Check if we found the recipes and apply the action
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ElvenTrade.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Botania Elven Trade", BotaniaAPI.elvenTradeRecipes, stack);
private static class Remove extends BaseListRemoval<RecipeElvenTrade> {
public Remove(List<RecipeElvenTrade> recipes) {
super(ElvenTrade.name, BotaniaAPI.elvenTradeRecipes, recipes);
}
@Override
public void apply() {
for (RecipeElvenTrade r : BotaniaAPI.elvenTradeRecipes) {
if (r.getOutput() != null && areEqual(r.getOutput(), stack)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(RecipeElvenTrade recipe) {
return InputHelper.getStackDescription(recipe.getOutput());
}
}
}
@@ -1,14 +1,20 @@
package modtweaker2.mods.botania.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toObject;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import vazkii.botania.api.BotaniaAPI;
@@ -17,6 +23,9 @@ import vazkii.botania.api.recipe.RecipeManaInfusion;
@ZenClass("mods.botania.ManaInfusion")
public class ManaInfusion {
protected static final String name = "Botania Mana Infusion";
@ZenMethod
public static void addInfusion(IItemStack output, IIngredient input, int mana) {
MineTweakerAPI.apply(new Add(new RecipeManaInfusion(toStack(output), toObject(input), mana)));
@@ -36,42 +45,47 @@ public class ManaInfusion {
MineTweakerAPI.apply(new Add(recipe));
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<RecipeManaInfusion> {
public Add(RecipeManaInfusion recipe) {
super("Botania Mana Infusion", BotaniaAPI.manaInfusionRecipes, recipe);
super(ManaInfusion.name, BotaniaAPI.manaInfusionRecipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((RecipeManaInfusion) recipe).getOutput().getDisplayName();
public String getRecipeInfo(RecipeManaInfusion recipe) {
return InputHelper.getStackDescription(recipe.getOutput());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
public static void removeRecipe(IIngredient output) {
// Get list of existing recipes, matching with parameter
List<RecipeManaInfusion> recipes = new LinkedList<RecipeManaInfusion>();
for (RecipeManaInfusion r : BotaniaAPI.manaInfusionRecipes) {
if (r.getOutput() != null && matches(output, toIItemStack(r.getOutput()))) {
recipes.add(r);
}
}
// Check if we found the recipes and apply the action
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ManaInfusion.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Botania Mana Infusion", BotaniaAPI.manaInfusionRecipes, stack);
private static class Remove extends BaseListRemoval<RecipeManaInfusion> {
public Remove(List<RecipeManaInfusion> recipes) {
super(ManaInfusion.name, BotaniaAPI.manaInfusionRecipes, recipes);
}
@Override
public void apply() {
for (RecipeManaInfusion r : BotaniaAPI.manaInfusionRecipes) {
if (r.getOutput() != null && areEqual(r.getOutput(), stack)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(RecipeManaInfusion recipe) {
return InputHelper.getStackDescription(recipe.getOutput());
}
}
}
@@ -1,14 +1,20 @@
package modtweaker2.mods.botania.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toObjects;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import vazkii.botania.api.BotaniaAPI;
@@ -16,47 +22,58 @@ import vazkii.botania.api.recipe.RecipeRuneAltar;
@ZenClass("mods.botania.RuneAltar")
public class RuneAltar {
protected static final String name = "Botania Rune Altar";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack output, IIngredient[] input, int mana) {
MineTweakerAPI.apply(new Add(new RecipeRuneAltar(toStack(output), mana, toObjects(input))));
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<RecipeRuneAltar> {
public Add(RecipeRuneAltar recipe) {
super("Botania Rune Altar", BotaniaAPI.runeAltarRecipes, recipe);
super(RuneAltar.name, BotaniaAPI.runeAltarRecipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((RecipeRuneAltar) recipe).getOutput().getDisplayName();
public String getRecipeInfo(RecipeRuneAltar recipe) {
return InputHelper.getStackDescription(recipe.getOutput());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
public static void removeRecipe(IIngredient output) {
// Get list of existing recipes, matching with parameter
List<RecipeRuneAltar> recipes = new LinkedList<RecipeRuneAltar>();
for (RecipeRuneAltar r : BotaniaAPI.runeAltarRecipes) {
if (r != null && r.getOutput() != null && matches(output, toIItemStack(r.getOutput()))) {
recipes.add(r);
}
}
// Check if we found the recipes and apply the action
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ElvenTrade.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Botania Rune Altar", BotaniaAPI.runeAltarRecipes, stack);
private static class Remove extends BaseListRemoval<RecipeRuneAltar> {
public Remove(List<RecipeRuneAltar> recipes) {
super(RuneAltar.name, BotaniaAPI.runeAltarRecipes, recipes);
}
@Override
public void apply() {
for (RecipeRuneAltar r : BotaniaAPI.runeAltarRecipes) {
if (r.getOutput() != null && areEqual(r.getOutput(), stack)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(RecipeRuneAltar recipe) {
return InputHelper.getStackDescription(recipe.getOutput());
}
}
}
@@ -3,10 +3,14 @@ package modtweaker2.mods.exnihilo.handlers;
import static modtweaker2.helpers.InputHelper.isABlock;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toStack;
import java.util.Map.Entry;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraft.block.Block;
@@ -20,6 +24,7 @@ import exnihilo.registries.helpers.Meltable;
@ZenClass("mods.exnihilo.Crucible")
public class Crucible {
/************************************************ Crucible Melting ************************************************/
//Adding a Ex Nihilo Crucible recipe
@ZenMethod
@@ -32,14 +37,15 @@ public class Crucible {
}
//Passes the list to the map list implementation, and adds the recipe
private static class AddRecipe extends BaseMapAddition {
private static class AddRecipe extends BaseMapAddition<String, Meltable> {
public AddRecipe(Meltable recipe) {
super("ExNihilo Crucible", CrucibleRegistry.entries, recipe.block + ":" + recipe.meta, recipe);
super("ExNihilo Crucible", CrucibleRegistry.entries);
recipes.put(recipe.block + ":" + recipe.meta, recipe);
}
@Override
public String getRecipeInfo() {
return new ItemStack(((Meltable) recipe).block, 1, ((Meltable) recipe).meta).getDisplayName();
protected String getRecipeInfo(Entry<String, Meltable> recipe) {
return InputHelper.getStackDescription(new ItemStack(recipe.getValue().block, 1, recipe.getValue().meta));
}
}
@@ -54,14 +60,21 @@ public class Crucible {
}
//Removes a recipe, will always remove the key, so all should be good
private static class RemoveRecipe extends BaseMapRemoval {
private static class RemoveRecipe extends BaseMapRemoval<String, Meltable> {
public RemoveRecipe(ItemStack stack) {
super("ExNihilo Crucible", CrucibleRegistry.entries, Block.getBlockFromItem(stack.getItem()) + ":" + stack.getItemDamage(), stack);
super("ExNihilo Crucible", CrucibleRegistry.entries);
String key = Block.getBlockFromItem(stack.getItem()) + ":" + stack.getItemDamage();
for(Entry<String, Meltable> entry : map.entrySet()) {
if(entry.getKey().equals(key))
recipes.put(entry.getKey(), entry.getValue());
}
}
@Override
public String getRecipeInfo() {
return ((ItemStack) stack).getDisplayName();
protected String getRecipeInfo(Entry<String, Meltable> recipe) {
return InputHelper.getStackDescription(new ItemStack(recipe.getValue().block, 1, recipe.getValue().meta));
}
}
@@ -2,20 +2,14 @@ package modtweaker2.mods.exnihilo.handlers;
import static modtweaker2.helpers.InputHelper.isABlock;
import static modtweaker2.helpers.InputHelper.toStack;
import java.util.List;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import exnihilo.registries.HammerRegistry;
import exnihilo.registries.helpers.Smashable;
import exnihilo.utils.ItemInfo;
@ZenClass("mods.exnihilo.Hammer")
public class Hammer {
@@ -2,24 +2,30 @@ package modtweaker2.mods.extendedworkbench.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.InputHelper.toStacks;
import static modtweaker2.helpers.StackHelper.areEqual;
import java.util.Arrays;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseCraftingAddition;
import modtweaker2.utils.BaseCraftingRemoval;
import naruto1310.extendedWorkbench.crafting.ExtendedCraftingManager;
import naruto1310.extendedWorkbench.crafting.ExtendedShapedRecipes;
import naruto1310.extendedWorkbench.crafting.ExtendedShapelessRecipes;
import naruto1310.extendedWorkbench.crafting.IExtendedRecipe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.extendedworkbench")
public class ExtendedCrafting {
public static final String name = "Extended Workbench";
@ZenMethod
public static void addShaped(IItemStack output, IItemStack[][] ingredients) {
MineTweakerAPI.apply(new Add(getShapedRecipe(output, ingredients)));
@@ -30,17 +36,10 @@ public class ExtendedCrafting {
MineTweakerAPI.apply(new Add(new ExtendedShapelessRecipes(toStack(output), Arrays.asList(toStacks(ingredients)))));
}
private static class Add extends BaseListAddition {
private static class Add extends BaseCraftingAddition {
public Add(IExtendedRecipe recipe) {
super("Extended Workbench", ExtendedCraftingManager.getInstance().getRecipeList(), recipe);
}
@Override
public String getRecipeInfo() {
Object out = ((IExtendedRecipe) recipe).getRecipeOutput();
if (out != null) {
return ((ItemStack) out).getDisplayName();
} else return super.getRecipeInfo();
super(ExtendedCrafting.name, ExtendedCraftingManager.getInstance().getRecipeList());
recipes.add(recipe);
}
}
@@ -71,32 +70,13 @@ public class ExtendedCrafting {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Extended Workbench", ExtendedCraftingManager.getInstance().getRecipeList(), stack);
}
@Override
public void apply() {
for (Object o : ExtendedCraftingManager.getInstance().getRecipeList()) {
if (o instanceof IExtendedRecipe) {
IExtendedRecipe r = (IExtendedRecipe) o;
if (r.getRecipeOutput() != null && areEqual((ItemStack) r.getRecipeOutput(), stack)) {
recipes.add(r);
}
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public static void removeRecipe(IIngredient output) {
List<IRecipe> recipes = BaseCraftingRemoval.getRecipes(ExtendedCraftingManager.getInstance().getRecipeList(), output);
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new BaseCraftingRemoval(ExtendedCrafting.name, ExtendedCraftingManager.getInstance().getRecipeList(), recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ExtendedCrafting.name, output));
}
}
}
@@ -1,9 +1,17 @@
package modtweaker2.mods.factorization.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.ReflectionHelper;
import modtweaker2.mods.factorization.FactorizationHelper;
import modtweaker2.utils.BaseListAddition;
@@ -15,59 +23,59 @@ import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.factorization.Crystallizer")
public class Crystallizer {
public static final String name = "Factorization Crystallizer";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output, IItemStack solution, double output_count) {
Object recipe = FactorizationHelper.getCrystallizerRecipe(toStack(input), toStack(output), toStack(solution), (float) output_count);
MineTweakerAPI.apply(new Add(toStack(input), recipe));
MineTweakerAPI.apply(new Add(recipe));
}
private static class Add extends BaseListAddition {
private final ItemStack output;
public Add(ItemStack output, Object recipe) {
super("Crystallizer", FactorizationHelper.crystallizer, recipe);
this.output = output;
private static class Add extends BaseListAddition<Object> {
public Add(Object recipe) {
super(Crystallizer.name, FactorizationHelper.crystallizer);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return output.getDisplayName();
public String getRecipeInfo(Object recipe) {
return InputHelper.getStackDescription((ItemStack)ReflectionHelper.getObject(recipe, "output"));
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Crystallizer", FactorizationHelper.crystallizer, stack);
}
//Returns the output ItemStack
private ItemStack getOutput(Object o) {
return (ItemStack) ReflectionHelper.getObject(o, "output");
}
@Override
public void apply() {
for (Object r : list) {
if (r != null) {
ItemStack output = getOutput(r);
if (output != null && areEqual(output, stack)) {
recipes.add(r);
}
public static void removeRecipe(IIngredient output) {
List<Object> recipes = new LinkedList<Object>();
for (Object r : FactorizationHelper.crystallizer) {
if (r != null) {
ItemStack out = (ItemStack) ReflectionHelper.getObject(r, "output");;
if (out != null && matches(output, toIItemStack(out))) {
recipes.add(r);
}
}
super.apply();
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Crystallizer.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval<Object> {
public Remove(List<Object> recipes) {
super(Crystallizer.name, FactorizationHelper.crystallizer, recipes);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(Object recipe) {
return InputHelper.getStackDescription((ItemStack)ReflectionHelper.getObject(recipe, "output"));
}
}
}
@@ -1,9 +1,17 @@
package modtweaker2.mods.factorization.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.ReflectionHelper;
import modtweaker2.mods.factorization.FactorizationHelper;
import modtweaker2.utils.BaseListAddition;
@@ -14,57 +22,58 @@ import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.factorization.Lacerator")
public class Lacerator {
public static final String name = "Factorization Lacerator";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output, double probability) {
Object recipe = FactorizationHelper.getLaceratorRecipe(toStack(input), toStack(output), (float) probability);
MineTweakerAPI.apply(new Add(toStack(input), recipe));
}
private static class Add extends BaseListAddition {
private final ItemStack output;
private static class Add extends BaseListAddition<Object> {
public Add(ItemStack output, Object recipe) {
super("Lacerator", FactorizationHelper.lacerator, recipe);
this.output = output;
super(Lacerator.name, FactorizationHelper.lacerator);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return output.getDisplayName();
public String getRecipeInfo(Object recipe) {
return InputHelper.getStackDescription((ItemStack) ReflectionHelper.getObject(recipe, "output"));
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Lacerator", FactorizationHelper.lacerator, stack);
}
//Returns the output ItemStack
private ItemStack getOutput(Object o) {
return (ItemStack) ReflectionHelper.getObject(o, "output");
}
@Override
public void apply() {
for (Object r : list) {
ItemStack output = getOutput(r);
if (output != null && areEqual(output, stack)) {
public static void removeRecipe(IIngredient output) {
List<Object> recipes = new LinkedList<Object>();
for (Object r : FactorizationHelper.lacerator) {
if(r != null) {
ItemStack out = (ItemStack) ReflectionHelper.getObject(r, "output");
if (output != null && matches(output, toIItemStack(out))) {
recipes.add(r);
}
}
super.apply();
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored", Lacerator.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval<Object> {
public Remove(List<Object> recipes) {
super(Lacerator.name, FactorizationHelper.lacerator, recipes);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(Object recipe) {
return InputHelper.getStackDescription((ItemStack) ReflectionHelper.getObject(recipe, "output"));
}
}
}
@@ -1,74 +1,81 @@
package modtweaker2.mods.factorization.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.ReflectionHelper;
import modtweaker2.mods.factorization.FactorizationHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseMultipleListRemoval;
import modtweaker2.utils.BaseMultipleListRemoval.Position;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.factorization.SlagFurnace")
public class SlagFurnace {
public static final String name = "Factorization Slag Furnace";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output2, double chance2, IItemStack output1, double chance1) {
Object recipe = FactorizationHelper.getSlagFurnaceRecipe(toStack(input), (float) chance1, toStack(output1), (float) chance2, toStack(output2));
MineTweakerAPI.apply(new Add(toStack(input), recipe));
}
private static class Add extends BaseListAddition {
private final ItemStack input;
private static class Add extends BaseListAddition<Object> {
public Add(ItemStack input, Object recipe) {
super("Slag Furnace", FactorizationHelper.slag, recipe);
this.input = input;
super(SlagFurnace.name, FactorizationHelper.slag);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return input.getDisplayName();
public String getRecipeInfo(Object recipe) {
return InputHelper.getStackDescription((ItemStack) ReflectionHelper.getObject(recipe, "input"));
}
}
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input), Position.ALL));
public static void removeRecipe(IIngredient input) {
List<Object> recipes = new LinkedList<Object>();
for(Object r : FactorizationHelper.slag) {
if(r != null) {
ItemStack in = (ItemStack) ReflectionHelper.getObject(r, "input");
if(matches(input, toIItemStack(in))) {
recipes.add(r);
}
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", SlagFurnace.name, input));
}
}
@ZenMethod
public static void removeFirst(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output), Position.FIRST));
}
@ZenMethod
public static void removeLast(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output), Position.LAST));
}
private static class Remove extends BaseMultipleListRemoval {
public Remove(ItemStack stack, Position pos) {
super("Slag Furnace", FactorizationHelper.slag, stack, pos);
private static class Remove extends BaseListRemoval<Object> {
public Remove(List<Object> recipes) {
super(SlagFurnace.name, FactorizationHelper.slag, recipes);
}
@Override
protected boolean isEqual(Object recipe, Object search) {
ItemStack input = (ItemStack) ReflectionHelper.getObject(recipe, "input");
if (input != null && areEqual(input, (ItemStack) search)) {
return true;
} else
return false;
}
@Override
public String getRecipeInfo() {
return ((ItemStack) search).getDisplayName();
}
@Override
public String getRecipeInfo(Object recipe) {
return InputHelper.getStackDescription((ItemStack) ReflectionHelper.getObject(recipe, "input"));
}
}
}
@@ -1,15 +1,21 @@
package modtweaker2.mods.forestry.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.InputHelper.toStacks;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.forestry.ForestryHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
@@ -24,7 +30,11 @@ import forestry.factory.gadgets.MachineCarpenter.RecipeManager;
@ZenClass("mods.forestry.Carpenter")
public class Carpenter {
public static final String name = "Forestry Carpenter";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(int packagingTime, ILiquidStack liquid, IItemStack[] ingredients, IItemStack ingredient, IItemStack product) {
ArrayList<ItemStack> stacks = new ArrayList<ItemStack>();
@@ -45,10 +55,11 @@ public class Carpenter {
return null;
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<Recipe> {
public Add(Recipe recipe) {
super("Forestry Carpenter", MachineCarpenter.RecipeManager.recipes, recipe);
super(Carpenter.name, MachineCarpenter.RecipeManager.recipes);
recipes.add(recipe);
// The Carpenter has a list of valid Fluids, access them via
// Relfection because of private
@@ -59,37 +70,43 @@ public class Carpenter {
ForestryHelper.addCarpenterRecipeBox(recipe.getBox());
}
}
@Override
public String getRecipeInfo(){
return ((MachineCarpenter.Recipe) recipe).getCraftingResult().getDisplayName();
protected String getRecipeInfo(Recipe recipe) {
return InputHelper.getStackDescription(recipe.getCraftingResult());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(MachineCarpenter.RecipeManager.recipes, toStack(output)));
public static void removeRecipe(IIngredient output) {
List<Recipe> recipes = new LinkedList<Recipe>();
for(Recipe recipe : RecipeManager.recipes) {
if(recipe != null && recipe.getCraftingResult() != null && matches(output, toIItemStack(recipe.getCraftingResult()))) {
recipes.add(recipe);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Carpenter.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval {
private static class Remove extends BaseListRemoval<Recipe> {
public Remove(List list, ItemStack stack) {
super("Forestry Carpenter", list, stack);
public Remove(List<Recipe> recipes) {
super(Carpenter.name, RecipeManager.recipes, recipes);
}
@Override
public void apply() {
for (Recipe r : RecipeManager.recipes) {
if (r.getCraftingResult() != null && r.getCraftingResult().isItemEqual(stack)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo(){
return "Removed recipe for: " + stack.getDisplayName();
protected String getRecipeInfo(Recipe recipe) {
return InputHelper.getStackDescription(recipe.getCraftingResult());
}
}
}
@@ -1,12 +1,18 @@
package modtweaker2.mods.forestry.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
@@ -19,6 +25,10 @@ import forestry.factory.gadgets.MachineCentrifuge.RecipeManager;
@ZenClass("mods.forestry.Centrifuge")
public class Centrifuge {
public static final String name = "Forestry Centrifuge";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(int timePerItem, IItemStack itemInput, IItemStack[] output, int[] chances) {
HashMap<ItemStack, Integer> products = new HashMap<ItemStack, Integer>();
@@ -31,47 +41,47 @@ public class Centrifuge {
MineTweakerAPI.apply(new Add(new Recipe(timePerItem, toStack(itemInput), products)));
}
@ZenMethod
public static void removeRecipe(IItemStack itemInput) {
MineTweakerAPI.apply(new Remove(RecipeManager.recipes, toStack(itemInput)));
private static class Add extends BaseListAddition<Recipe> {
public Add(Recipe recipe) {
super(Centrifuge.name, RecipeManager.recipes);
recipes.add(recipe);
}
@Override
protected String getRecipeInfo(Recipe recipe) {
return InputHelper.getStackDescription(recipe.resource);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IIngredient input) {
List<Recipe> recipes = new LinkedList<Recipe>();
for(Recipe recipe : RecipeManager.recipes) {
if(recipe != null && matches(input, toIItemStack(recipe.resource))) {
recipes.add(recipe);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Centrifuge.name, input.toString()));
}
}
/*
Implements the actions to add the recipe
*/
private static class Add extends BaseListAddition {
private static class Remove extends BaseListRemoval<Recipe> {
public Add(Recipe recipe) {
super("Forestry Centrifuge", RecipeManager.recipes, recipe);
}
@Override
public String getRecipeInfo() {
return " Input:" + ((Recipe) recipe).resource.getDisplayName();
}
}
/*
Implements the actions to remove the recipe
*/
private static class Remove extends BaseListRemoval {
public Remove(List list, ItemStack input) {
super("Forestry Centrifuge", RecipeManager.recipes, input);
public Remove(List<Recipe> recipes) {
super(Centrifuge.name, RecipeManager.recipes, recipes);
}
@Override
public void apply() {
for (Recipe r : RecipeManager.recipes) {
if (r.matches(stack)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return " Input:" + stack.getDisplayName();
protected String getRecipeInfo(Recipe recipe) {
return InputHelper.getStackDescription(recipe.resource);
}
}
}
@@ -1,67 +1,179 @@
package modtweaker2.mods.forestry.handlers;
import static modtweaker2.helpers.InputHelper.getFluid;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toILiquidStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import forestry.factory.gadgets.MachineFermenter;
import forestry.factory.gadgets.MachineFermenter.Recipe;
import forestry.factory.gadgets.MachineFermenter.RecipeManager;
@ZenClass("mods.forestry.Fermenter")
public class Fermenter {
public static final String name = "Forestry Fermenter";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack resource, ILiquidStack liquid, int fermentationValue, float modifier, ILiquidStack output) {
MineTweakerAPI.apply(new Add(new Recipe(toStack(resource), fermentationValue, modifier, toFluid(output), toFluid(liquid))));
MachineFermenter.RecipeManager.recipeFluidInputs.add(getFluid(liquid));
MachineFermenter.RecipeManager.recipeFluidOutputs.add(getFluid(output));
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<Recipe> {
public Add(Recipe recipe) {
super("Forestry Fermenter", MachineFermenter.RecipeManager.recipes, recipe);
super(Fermenter.name, RecipeManager.recipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((Recipe) recipe).output.getLocalizedName();
}
}
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(MachineFermenter.RecipeManager.recipes, toStack(input)));
}
private static class Remove extends BaseListRemoval {
public Remove(List list, ItemStack stack) {
super(list, stack);
}
@Override
public void apply() {
for (Recipe r : RecipeManager.recipes) {
if (r != null && r.resource != null && r.resource.isItemEqual(stack)) {
recipes.add(r);
}
}
super.apply();
// add liquids to valid input / output
for(Recipe recipe : successful) {
RecipeManager.recipeFluidInputs.add(recipe.liquid.getFluid());
RecipeManager.recipeFluidOutputs.add(recipe.output.getFluid());
}
super.apply();
}
@Override
public void undo() {
super.undo();
// Tidy up valid inputs
for(Iterator<Fluid> iter = RecipeManager.recipeFluidInputs.iterator(); iter.hasNext();) {
boolean found = false;
Fluid fluid = iter.next();
for(Recipe recipe : list) {
if(recipe != null && recipe.liquid != null && recipe.liquid.getFluid().equals(fluid)) {
found = true;
}
}
if(!found) {
iter.remove();
}
}
// Tidy up valid outputs
for(Iterator<Fluid> iter = RecipeManager.recipeFluidOutputs.iterator(); iter.hasNext();) {
boolean found = false;
Fluid fluid = iter.next();
for(Recipe recipe : list) {
if(recipe != null && recipe.output != null && recipe.output.getFluid().equals(fluid)) {
found = true;
}
}
if(!found) {
iter.remove();
}
}
}
@Override
public String getRecipeInfo(Recipe recipe) {
return InputHelper.getStackDescription(recipe.output);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IIngredient input) {
List<Recipe> recipes = new LinkedList<Recipe>();
for(Recipe recipe : RecipeManager.recipes) {
// check for input items
if(recipe != null && recipe.resource != null && matches(input, toIItemStack(recipe.resource))) {
recipes.add(recipe);
}
// check for input liquids
if(recipe != null && recipe.resource != null && matches(input, toILiquidStack(recipe.liquid))) {
recipes.add(recipe);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Fermenter.name, input.toString()));
}
}
private static class Remove extends BaseListRemoval<Recipe> {
public Remove(List<Recipe> recipes) {
super(Fermenter.name, RecipeManager.recipes, recipes);
}
@Override
public void apply() {
super.apply();
// Tidy up valid inputs
for(Iterator<Fluid> iter = RecipeManager.recipeFluidInputs.iterator(); iter.hasNext();) {
boolean found = false;
Fluid fluid = iter.next();
for(Recipe recipe : list) {
if(recipe != null && recipe.liquid != null && recipe.liquid.getFluid().equals(fluid)) {
found = true;
}
}
if(!found) {
iter.remove();
}
}
// Tidy up valid outputs
for(Iterator<Fluid> iter = RecipeManager.recipeFluidOutputs.iterator(); iter.hasNext();) {
boolean found = false;
Fluid fluid = iter.next();
for(Recipe recipe : list) {
if(recipe != null && recipe.output != null && recipe.output.getFluid().equals(fluid)) {
found = true;
}
}
if(!found) {
iter.remove();
}
}
}
@Override
public void undo() {
// add liquids to valid input / output
for(Recipe recipe : successful) {
RecipeManager.recipeFluidInputs.add(recipe.liquid.getFluid());
RecipeManager.recipeFluidOutputs.add(recipe.output.getFluid());
}
super.undo();
}
@Override
public String getRecipeInfo(Recipe recipe) {
return InputHelper.getStackDescription(recipe.output);
}
}
}
@@ -1,14 +1,19 @@
package modtweaker2.mods.forestry.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import forestry.factory.gadgets.MachineMoistener;
@@ -17,6 +22,10 @@ import forestry.factory.gadgets.MachineMoistener.RecipeManager;
@ZenClass("mods.forestry.Moistener")
public class Moistener {
public static final String name = "Forestry Moistener";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(int timePerItem, IItemStack resource, IItemStack product) {
@@ -24,37 +33,45 @@ public class Moistener {
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<Recipe> {
public Add(Recipe recipe) {
super("Forestry Moistener", MachineMoistener.RecipeManager.recipes, recipe);
super(Moistener.name, MachineMoistener.RecipeManager.recipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((Recipe) recipe).product.getDisplayName();
public String getRecipeInfo(Recipe recipe) {
return InputHelper.getStackDescription(recipe.product);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(MachineMoistener.RecipeManager.recipes, toStack(output)));
public static void removeRecipe(IIngredient output) {
List<Recipe> recipes = new LinkedList<Recipe>();
for (Recipe recipe : RecipeManager.recipes) {
if (recipe != null && recipe.product != null && matches(output, toIItemStack(recipe.product))) {
recipes.add(recipe);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Moistener.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval {
public Remove(List list, ItemStack stack) {
super(list, stack);
private static class Remove extends BaseListRemoval<Recipe> {
public Remove(List<Recipe> recipes) {
super(Moistener.name, RecipeManager.recipes, recipes);
}
@Override
public void apply() {
for (Recipe r : RecipeManager.recipes) {
if (r.product != null && r.product.isItemEqual(stack)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo(Recipe recipe) {
return InputHelper.getStackDescription(recipe.product);
}
}
}
@@ -2,18 +2,23 @@ package modtweaker2.mods.forestry.handlers;
import static modtweaker2.helpers.InputHelper.getFluid;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toILiquidStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.InputHelper.toStacks;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import forestry.factory.gadgets.MachineSqueezer;
@@ -22,6 +27,10 @@ import forestry.factory.gadgets.MachineSqueezer.RecipeManager;
@ZenClass("mods.forestry.Squeezer")
public class Squeezer {
public static final String name = "Forestry Squeezer";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(int timePerItem, IItemStack[] resources, ILiquidStack liquid, IItemStack remnants, int chance) {
@@ -30,38 +39,53 @@ public class Squeezer {
MachineSqueezer.RecipeManager.recipeInputs.addAll(Arrays.asList(toStacks(resources)));
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<Recipe> {
public Add(Recipe recipe) {
super("Forestry Squeezer", MachineSqueezer.RecipeManager.recipes, recipe);
super(Squeezer.name, MachineSqueezer.RecipeManager.recipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((Recipe) recipe).liquid.getLocalizedName();
public String getRecipeInfo(Recipe recipe) {
return InputHelper.getStackDescription(recipe.liquid);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(ILiquidStack liquid) {
MineTweakerAPI.apply(new Remove(MachineSqueezer.RecipeManager.recipes, toFluid(liquid)));
public static void removeRecipe(IIngredient liquid) {
List<Recipe> recipes = new LinkedList<Recipe>();
for (Recipe r : RecipeManager.recipes) {
if (r != null && r.liquid != null && matches(liquid, toILiquidStack(r.liquid))) {
recipes.add(r);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Squeezer.name, liquid.toString()));
}
}
private static class Remove extends BaseListRemoval {
public Remove(List list, FluidStack liquid) {
super(list, liquid);
private static class Remove extends BaseListRemoval<Recipe> {
public Remove(List<Recipe> recipes) {
super(Squeezer.name, MachineSqueezer.RecipeManager.recipes, recipes);
}
@Override
public void apply() {
for (Recipe r : RecipeManager.recipes) {
if (r.liquid != null && r.liquid.isFluidEqual(fluid)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo(Recipe recipe) {
return InputHelper.getStackDescription(recipe.liquid);
}
}
}
@@ -2,14 +2,18 @@ package modtweaker2.mods.forestry.handlers;
import static modtweaker2.helpers.InputHelper.getFluid;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toILiquidStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import forestry.factory.gadgets.MachineStill;
@@ -18,6 +22,10 @@ import forestry.factory.gadgets.MachineStill.RecipeManager;
@ZenClass("mods.forestry.Still")
public class Still {
public static final String name = "Forestry Still";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(int timePerUnit, ILiquidStack input, ILiquidStack output) {
@@ -29,37 +37,46 @@ public class Still {
MachineStill.RecipeManager.recipeFluidOutputs.add(getFluid(output));
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<Recipe> {
public Add(Recipe recipe) {
super("Forestry Still", MachineStill.RecipeManager.recipes, recipe);
super("Forestry Still", MachineStill.RecipeManager.recipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((Recipe) recipe).output.getLocalizedName();
public String getRecipeInfo(Recipe recipe) {
return InputHelper.getStackDescription(recipe.output);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(ILiquidStack output, ILiquidStack input) {
MineTweakerAPI.apply(new Remove(MachineStill.RecipeManager.recipes, toFluid(input)));
List<Recipe> recipes = new LinkedList<Recipe>();
for (Recipe r : RecipeManager.recipes) {
if (r != null && r.output != null && matches(output, toILiquidStack(r.output))) {
recipes.add(r);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Still.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval {
public Remove(List list, FluidStack input) {
super(list, input);
private static class Remove extends BaseListRemoval<Recipe> {
public Remove(List<Recipe> recipes) {
super(Still.name, RecipeManager.recipes, recipes);
}
@Override
public void apply() {
for (Recipe r : RecipeManager.recipes) {
if (r.output != null && r.output.isFluidEqual(fluid)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo(Recipe recipe) {
return InputHelper.getStackDescription(recipe.output);
}
}
}
@@ -1,13 +1,19 @@
package modtweaker2.mods.forestry.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
@@ -21,18 +27,20 @@ import forestry.factory.gadgets.MachineFabricator.Smelting;
@ZenClass("mods.forestry.ThermionicFabricator")
public class ThermionicFabricator {
public static final String nameSmelting = "Forestry Thermionic Fabricator (Smelting)";
public static final String nameCasting = "Forestry Thermionic Fabricator (Casting)";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//first production step: smelting item into liquid
@ZenMethod
public static void addSmelting(IItemStack itemInput, int meltingPoint, int fluidOutput) {
//The machines internal tank accept only liquid glass, therefor this function only accept the amount and hardcode the fluid to glass
MineTweakerAPI.apply(new Add(new Smelting(toStack(itemInput), FluidRegistry.getFluidStack("glass", fluidOutput), meltingPoint)));
MineTweakerAPI.apply(new AddSmelting(new Smelting(toStack(itemInput), FluidRegistry.getFluidStack("glass", fluidOutput), meltingPoint)));
}
@ZenMethod
public static void removeSmelting(IItemStack itemInput) {
MineTweakerAPI.apply(new Remove(toStack(itemInput), RecipeManager.smeltings, RecipeType.Smelting));
}
//second step: casting liquid + objetcs + plan into result
@ZenMethod
@@ -44,86 +52,95 @@ public class ThermionicFabricator {
}
}
MineTweakerAPI.apply(new Add(new Recipe(toStack(plan), toFluid(fluidInput), new ShapedRecipeCustom(3, 3, flatList, toStack(product)))));
}
@ZenMethod
public static void removeCasts(IItemStack product) {
MineTweakerAPI.apply(new Remove(toStack(product), RecipeManager.recipes, RecipeType.Casting));
MineTweakerAPI.apply(new AddCast(new Recipe(toStack(plan), toFluid(fluidInput), new ShapedRecipeCustom(3, 3, flatList, toStack(product)))));
}
/*
Implements the actions to add a recipe
Since the machine has two crafting Steps, this is a constructors for both
*/
private static class Add extends BaseListAddition {
private static class AddSmelting extends BaseListAddition<Smelting> {
public Add(Smelting recipe) {
super("Forestry Thermionic Fabricator (Smelting)", RecipeManager.smeltings, recipe);
public AddSmelting(Smelting recipe) {
super(ThermionicFabricator.nameSmelting, RecipeManager.smeltings);
recipes.add(recipe);
}
public Add(Recipe recipe) {
super("Forestry Thermionic Fabricator (Casting)", RecipeManager.recipes, recipe);
@Override
public String getRecipeInfo(Smelting recipe) {
return InputHelper.getStackDescription(recipe.getResource());
}
}
private static class AddCast extends BaseListAddition<Recipe> {
public AddCast(Recipe recipe) {
super(ThermionicFabricator.nameCasting, RecipeManager.recipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo(Recipe recipe) {
return InputHelper.getStackDescription(recipe.getPlan());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeSmelting(IIngredient itemInput) {
List<Smelting> recipes = new LinkedList<Smelting>();
for (Smelting r : RecipeManager.smeltings) {
if (r != null && r.getResource() != null && matches(itemInput, toIItemStack(r.getResource()))) {
recipes.add(r);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveSmelting(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ThermionicFabricator.nameSmelting, itemInput.toString()));
}
}
@ZenMethod
public static void removeCasts(IIngredient product) {
List<Recipe> recipes = new LinkedList<Recipe>();
for (Recipe r : RecipeManager.recipes) {
if (r != null && r.asIRecipe().getRecipeOutput() != null && matches(product, toIItemStack(r.asIRecipe().getRecipeOutput()))) {
recipes.add(r);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveCasts(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ThermionicFabricator.nameSmelting, product.toString()));
}
}
private static class RemoveSmelting extends BaseListRemoval<Smelting> {
public RemoveSmelting(List<Smelting> recipes) {
super(ThermionicFabricator.nameSmelting, RecipeManager.smeltings, recipes);
}
@Override
public String getRecipeInfo() {
if (recipe instanceof Smelting)
return " Input:" + ((Smelting) recipe).getResource().getDisplayName();
else
return "Output: " + ((Recipe) recipe).asIRecipe().getRecipeOutput().getDisplayName();
public String getRecipeInfo(Smelting recipe) {
return InputHelper.getStackDescription(recipe.getResource());
}
}
private static class RemoveCasts extends BaseListRemoval<Recipe> {
public RemoveCasts(List<Recipe> recipes) {
super(ThermionicFabricator.nameCasting, RecipeManager.recipes, recipes);
}
/*
Implements the actions to remove recipes
*/
private static class Remove extends BaseListRemoval {
private final RecipeType type;
public Remove(ItemStack input, List list, RecipeType type) {
super(String.format("Forestry Thermionic Fabricator (%s)", type.toString()), list, input);
this.type = type;
}
@Override
public void apply() {
switch(type) {
case Smelting:
for (Object r : list) {
if (((Smelting)r).getResource() != null && ((Smelting)r).getResource().isItemEqual(stack)) {
recipes.add(r);
}
}
break;
case Casting:
for (Object r : list) {
if (((Recipe)r).asIRecipe().getRecipeOutput() != null && ((Recipe)r).asIRecipe().getRecipeOutput().isItemEqual(stack)) {
recipes.add(r);
}
}
break;
}
super.apply();
}
@Override
public String getRecipeInfo() {
switch(type) {
case Smelting:
return " Input:" + stack.getDisplayName(); // + " -- Output:" + ((Smelting) recipe).getProduct().getLocalizedName();
case Casting:
return " Output:" + stack.getDisplayName(); // + " -- Output:" + ((Recipe) recipe).asIRecipe().getIngredients()[0].getDisplayName();
}
return stack.getDisplayName();
}
}
public enum RecipeType {
Smelting,
Casting
@Override
public String getRecipeInfo(Recipe recipe) {
return InputHelper.getStackDescription(recipe.getPlan());
}
}
}
@@ -1,12 +1,23 @@
package modtweaker2.mods.fsp.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import static modtweaker2.mods.fsp.FSPHelper.getLiquid;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.tuple.MutablePair;
@@ -20,6 +31,11 @@ import flaxbeard.steamcraft.api.Tuple3;
@ZenClass("mods.fsp.Crucible")
public class Crucible {
public static final String nameLiquid = "FSP Crucible (Liquid)";
public static final String nameMelting = "FSP Crucible (Liquid)";
public static final String nameDunking = "FSP Crucible (Dunking)";
@ZenMethod
public static void addLiquid(String name, IItemStack ingot, IItemStack plate, IItemStack nugget, int r, int g, int b) {
MineTweakerAPI.apply(new AddLiquid(new CrucibleLiquid(name, toStack(ingot), toStack(plate), toStack(nugget), null, r, g, b)));
@@ -30,14 +46,15 @@ public class Crucible {
MineTweakerAPI.apply(new AddLiquid(new CrucibleLiquid(name, toStack(ingot), toStack(plate), toStack(nugget), new CrucibleFormula(getLiquid(l1), n1, getLiquid(l2), n2, n3), r, g, b)));
}
private static class AddLiquid extends BaseListAddition {
private static class AddLiquid extends BaseListAddition<CrucibleLiquid> {
public AddLiquid(CrucibleLiquid recipe) {
super("FSP Crucible Liquid", SteamcraftRegistry.liquids, recipe);
super(nameLiquid, SteamcraftRegistry.liquids);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((CrucibleLiquid) recipe).name;
public String getRecipeInfo(CrucibleLiquid recipe) {
return recipe.name;
}
}
@@ -50,41 +67,43 @@ public class Crucible {
}
}
private static class AddMelting extends BaseMapAddition {
private final ItemStack stack;
public AddMelting(ItemStack stack, Object key, Object recipe) {
super("FSP Crucible Melting", SteamcraftRegistry.smeltThings, key, recipe);
this.stack = stack;
private static class AddMelting extends BaseMapAddition<MutablePair<Item, Integer>, MutablePair<CrucibleLiquid, Integer>> {
public AddMelting(ItemStack stack, MutablePair<Item, Integer> key, MutablePair<CrucibleLiquid, Integer> recipe) {
super(nameMelting, SteamcraftRegistry.smeltThings);
map.put(key, recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
protected String getRecipeInfo(Entry<MutablePair<Item, Integer>, MutablePair<CrucibleLiquid, Integer>> recipe) {
return InputHelper.getStackDescription(new ItemStack(recipe.getKey().left, 1, recipe.getKey().right));
}
}
@ZenMethod
public static void removeMelting(IItemStack input) {
MineTweakerAPI.apply(new RemoveMelting(toStack(input), MutablePair.of(toStack(input).getItem(), toStack(input).getItemDamage())));
}
private static class RemoveMelting extends BaseMapRemoval {
private final ItemStack stack;
public RemoveMelting(ItemStack stack, Object key) {
super("FSP Crucible Melting", SteamcraftRegistry.smeltThings, key);
this.stack = stack;
public static void removeMelting(IIngredient input) {
Map<MutablePair<Item, Integer>, MutablePair<CrucibleLiquid, Integer>> recipes = new HashMap<MutablePair<Item, Integer>, MutablePair<CrucibleLiquid, Integer>>();
for(Entry<MutablePair<Item, Integer>, MutablePair<CrucibleLiquid, Integer>> entry : SteamcraftRegistry.smeltThings.entrySet()) {
if(matches(input, toIItemStack(new ItemStack(entry.getKey().left, 1, entry.getKey().right)))) {
recipes.put(entry.getKey(), entry.getValue());
}
}
public void apply(){
SteamcraftRegistry.smeltThings.remove(stack);
MutablePair<String, Integer> pair;
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveMelting(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipes found for %s", Crucible.nameMelting, input));
}
}
private static class RemoveMelting extends BaseMapRemoval<MutablePair<Item, Integer>, MutablePair<CrucibleLiquid, Integer>> {
public RemoveMelting(Map<MutablePair<Item, Integer>, MutablePair<CrucibleLiquid, Integer>> recipes) {
super(nameMelting, SteamcraftRegistry.smeltThings, recipes);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
protected String getRecipeInfo(Entry<MutablePair<Item, Integer>, MutablePair<CrucibleLiquid, Integer>> recipe) {
return InputHelper.getStackDescription(new ItemStack(recipe.getKey().left, 1, recipe.getKey().right));
}
}
@@ -93,40 +112,50 @@ public class Crucible {
ItemStack stack = toStack(input);
CrucibleLiquid fluid = getLiquid(liquid);
if (fluid != null) {
MineTweakerAPI.apply(new AddDunking(toStack(input), new Tuple3(stack.getItem(), stack.getItemDamage(), fluid), MutablePair.of(volume, toStack(output))));
MineTweakerAPI.apply(new AddDunking(new Tuple3(stack.getItem(), stack.getItemDamage(), fluid), MutablePair.of(volume, toStack(output))));
}
}
private static class AddDunking extends BaseMapAddition {
private final ItemStack stack;
public AddDunking(ItemStack stack, Object key, Object recipe) {
super("FSP Crucible Dunking", SteamcraftRegistry.dunkThings, key, recipe);
this.stack = stack;
private static class AddDunking extends BaseMapAddition<Tuple3, MutablePair<Integer, ItemStack>> {
public AddDunking(Tuple3 key, MutablePair<Integer, ItemStack> recipe) {
super(Crucible.nameDunking, SteamcraftRegistry.dunkThings);
recipes.put(key, recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(Entry<Tuple3, MutablePair<Integer, ItemStack>> recipe) {
return InputHelper.getStackDescription(recipe.getValue().right);
}
}
@ZenMethod
public static void removeDunking(IItemStack input, String liquid) {
MineTweakerAPI.apply(new RemoveDunking(toStack(input), new Tuple3(toStack(input).getItem(), toStack(input).getItemDamage(), getLiquid(liquid))));
public static void removeDunking(IIngredient input, String liquid) {
Map<Tuple3, MutablePair<Integer, ItemStack>> recipes = new HashMap<Tuple3, MutablePair<Integer, ItemStack>>();
for(Entry<Tuple3, MutablePair<Integer, ItemStack>> recipe : SteamcraftRegistry.dunkThings.entrySet()) {
if(recipe.getValue() != null && recipe.getValue().right != null && matches(input, toIItemStack(recipe.getValue().right))) {
if(((CrucibleLiquid)recipe.getKey().third).equals(getLiquid(liquid))) {
recipes.put(recipe.getKey(), recipe.getValue());
}
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveDunking(recipes));
} else {
LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", Crucible.nameDunking, input.toString(), liquid));
}
}
private static class RemoveDunking extends BaseMapRemoval {
private final ItemStack stack;
public RemoveDunking(ItemStack stack, Object key) {
super("FSP Crucible Dunking", SteamcraftRegistry.dunkThings, key);
this.stack = stack;
private static class RemoveDunking extends BaseMapRemoval<Tuple3, MutablePair<Integer, ItemStack>> {
public RemoveDunking(Map<Tuple3, MutablePair<Integer, ItemStack>> recipes) {
super(Crucible.nameDunking, SteamcraftRegistry.dunkThings, recipes);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(Entry<Tuple3, MutablePair<Integer, ItemStack>> recipe) {
return InputHelper.getStackDescription(recipe.getValue().right);
}
}
}
@@ -1,10 +1,21 @@
package modtweaker2.mods.fsp.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.tuple.MutablePair;
@@ -15,41 +26,51 @@ import flaxbeard.steamcraft.api.SteamcraftRegistry;
@ZenClass("mods.fsp.Furnace")
public class Furnace {
public static final String name = "FSP Furnace (Steamed Foods)";
@ZenMethod
public static void addSteamFood(IItemStack input, IItemStack output) {
MineTweakerAPI.apply(new AddSteamFood(toStack(input), MutablePair.of(toStack(input).getItem(), toStack(input).getItemDamage()), MutablePair.of(toStack(output).getItem(), toStack(output).getItemDamage())));
}
private static class AddSteamFood extends BaseMapAddition {
private final ItemStack stack;
public AddSteamFood(ItemStack stack, MutablePair key, MutablePair recipe) {
super("FSP Furnace - Steam Food", SteamcraftRegistry.steamedFoods, key, recipe);
this.stack = stack;
private static class AddSteamFood extends BaseMapAddition<MutablePair<Item, Integer>, MutablePair<Item, Integer>> {
public AddSteamFood(ItemStack stack, MutablePair<Item, Integer> key, MutablePair<Item, Integer> recipe) {
super(Furnace.name, SteamcraftRegistry.steamedFoods);
recipes.put(key, recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(Entry<MutablePair<Item, Integer>, MutablePair<Item, Integer>> recipe) {
return InputHelper.getStackDescription(new ItemStack(recipe.getKey().left, 1, recipe.getKey().right));
}
}
@ZenMethod
public static void removeSteamFood(IItemStack input) {
MineTweakerAPI.apply(new RemoveSteamFood(toStack(input), MutablePair.of(toStack(input).getItem(), toStack(input).getItemDamage())));
public static void removeSteamFood(IIngredient input) {
Map<MutablePair<Item, Integer>, MutablePair<Item, Integer>> recipes = new HashMap<MutablePair<Item, Integer>, MutablePair<Item, Integer>>();
for(Entry<MutablePair<Item, Integer>, MutablePair<Item, Integer>> recipe : SteamcraftRegistry.steamedFoods.entrySet()) {
if(matches(input, toIItemStack(new ItemStack(recipe.getKey().left, 1, recipe.getKey().right)))) {
recipes.put(recipe.getKey(), recipe.getValue());
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveSteamFood(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Furnace.name, input.toString()));
}
}
private static class RemoveSteamFood extends BaseMapRemoval {
private final ItemStack stack;
public RemoveSteamFood(ItemStack stack, MutablePair key) {
super("FSP Furnace - Steam Food", SteamcraftRegistry.steamedFoods, key);
this.stack = stack;
private static class RemoveSteamFood extends BaseMapRemoval<MutablePair<Item, Integer>, MutablePair<Item, Integer>> {
public RemoveSteamFood(Map<MutablePair<Item, Integer>, MutablePair<Item, Integer>> recipes) {
super(Furnace.name, SteamcraftRegistry.steamedFoods, recipes);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(Entry<MutablePair<Item, Integer>, MutablePair<Item, Integer>> recipe) {
return InputHelper.getStackDescription(new ItemStack(recipe.getKey().left, 1, recipe.getKey().right));
}
}
}
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import mariculture.api.core.FuelInfo;
import mariculture.api.core.MaricultureHandlers;
import mariculture.api.fishery.Fishing;
import mariculture.api.fishery.Loot;
@@ -15,7 +16,7 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
public class MaricultureHelper {
public static Map fuels = null;
public static Map<Object, FuelInfo> fuels = null;
public static HashMap<Rarity, ArrayList<Loot>> loot = null;
static {
@@ -27,7 +28,7 @@ public class MaricultureHelper {
private MaricultureHelper() {}
//Helper for getting the key that is used when adding/removing fuels
// Helper for getting the key that is used when adding/removing fuels
public static String getKey(Object o) {
if (o instanceof String) return (String) o;
else if (o instanceof ItemStack) {
@@ -1,33 +1,47 @@
package modtweaker2.mods.mariculture.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import mariculture.api.core.IAnvilHandler.RecipeAnvil;
import mariculture.api.core.MaricultureHandlers;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.mariculture.MaricultureHelper;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mariculture.Anvil")
public class Anvil {
//Adding a Mariculture Anvil recipe
public static final String name = "Mariculture Anvil";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output, int hits) {
MineTweakerAPI.apply(new Add(new RecipeAnvil(toStack(input), toStack(output), hits)));
}
private static class Add extends BaseMapAddition {
private static class Add extends BaseMapAddition<String, RecipeAnvil> {
public Add(RecipeAnvil recipe) {
super("Mariculture Anvil", MaricultureHandlers.anvil.getRecipes(), MaricultureHelper.getKey(recipe.input), recipe);
super("Mariculture Anvil", MaricultureHandlers.anvil.getRecipes());
recipes.put(MaricultureHelper.getKey(recipe.input), recipe);
}
@Override
public String getRecipeInfo() {
return ((RecipeAnvil) recipe).output.getDisplayName();
public String getRecipeInfo(Entry<String, RecipeAnvil> recipe) {
return InputHelper.getStackDescription(recipe.getValue().output);
}
}
@@ -35,18 +49,30 @@ public class Anvil {
//Removing a Mariculture Anvil recipe
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input)));
public static void removeRecipe(IIngredient input) {
Map<String, RecipeAnvil> recipes = new HashMap<String, RecipeAnvil>();
for(Entry<String, RecipeAnvil> recipe : MaricultureHandlers.anvil.getRecipes().entrySet()) {
if(recipe != null && recipe.getValue() != null && recipe.getValue().input != null && matches(input, toIItemStack(recipe.getValue().input))) {
recipes.put(recipe.getKey(), recipe.getValue());
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Anvil.name, input.toString()));
}
}
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack stack) {
super("Mariculture Anvil", MaricultureHandlers.anvil.getRecipes(), MaricultureHelper.getKey(stack), stack);
private static class Remove extends BaseMapRemoval<String, RecipeAnvil> {
public Remove(Map<String, RecipeAnvil> recipes) {
super("Mariculture Anvil", MaricultureHandlers.anvil.getRecipes(), recipes);
}
@Override
public String getRecipeInfo() {
return ((ItemStack) stack).getDisplayName();
public String getRecipeInfo(Entry<String, RecipeAnvil> recipe) {
return InputHelper.getStackDescription(recipe.getValue().output);
}
}
}
@@ -1,26 +1,36 @@
package modtweaker2.mods.mariculture.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toILiquidStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import mariculture.api.core.MaricultureHandlers;
import mariculture.api.core.RecipeCasting;
import mariculture.api.core.RecipeCasting.RecipeNuggetCasting;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.mods.mariculture.MaricultureHelper;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mariculture.Casting")
public class Casting {
//Adding Mariculture Casting Recipes
public static final String name = "Mariculture Casting";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addNuggetRecipe(ILiquidStack input, IItemStack output) {
MineTweakerAPI.apply(new Add(new RecipeNuggetCasting(toFluid(input), toStack(output)), MaricultureHandlers.casting.getNuggetRecipes()));
@@ -36,43 +46,63 @@ public class Casting {
MineTweakerAPI.apply(new Add(new RecipeNuggetCasting(toFluid(input), toStack(output)), MaricultureHandlers.casting.getBlockRecipes()));
}
private static class Add extends BaseMapAddition {
public Add(RecipeCasting recipe, HashMap map) {
super("Mariculture Casting", map, MaricultureHelper.getKey(recipe.fluid), recipe);
private static class Add extends BaseMapAddition<String, RecipeCasting> {
public Add(RecipeCasting recipe, HashMap<String, RecipeCasting> map) {
super(Casting.name, map);
recipes.put(MaricultureHelper.getKey(recipe.fluid), recipe);
}
@Override
public String getRecipeInfo() {
return ((RecipeCasting) recipe).output.getDisplayName();
public String getRecipeInfo(Entry<String, RecipeCasting> recipe) {
return InputHelper.getStackDescription(recipe.getValue().output);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing Mariculture Casting Recipes
@ZenMethod
public static void removeNuggetRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input), MaricultureHandlers.casting.getNuggetRecipes()));
public static void removeNuggetRecipe(IIngredient ingredient) {
removeRecipe(ingredient, MaricultureHandlers.casting.getNuggetRecipes());
}
@ZenMethod
public static void removeIngotRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input), MaricultureHandlers.casting.getIngotRecipes()));
public static void removeIngotRecipe(IIngredient ingredient) {
removeRecipe(ingredient, MaricultureHandlers.casting.getIngotRecipes());
}
@ZenMethod
public static void removeBlockRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input), MaricultureHandlers.casting.getBlockRecipes()));
public static void removeBlockRecipe(IIngredient ingredient) {
removeRecipe(ingredient, MaricultureHandlers.casting.getBlockRecipes());
}
public static void removeRecipe(IIngredient ingredient, HashMap<String, RecipeCasting> map) {
Map<String, RecipeCasting> recipes = new HashMap<String, RecipeCasting>();
for(Entry<String, RecipeCasting> recipe : map.entrySet()) {
if(recipe != null && recipe.getValue() != null) {
if(recipe.getValue().fluid != null && matches(ingredient, toILiquidStack(recipe.getValue().fluid))) {
recipes.put(recipe.getKey(), recipe.getValue());
}
if(recipe.getValue().output != null && matches(ingredient, toIItemStack(recipe.getValue().output))) {
recipes.put(recipe.getKey(), recipe.getValue());
}
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(map, recipes));
}
}
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack stack, HashMap map) {
super("Mariculture Casting", map, MaricultureHelper.getKey(stack), stack);
private static class Remove extends BaseMapRemoval<String, RecipeCasting> {
public Remove(Map<String, RecipeCasting> map, Map<String, RecipeCasting> recipes) {
super(Casting.name, map, recipes);
}
@Override
public String getRecipeInfo() {
return ((ItemStack) stack).getDisplayName();
public String getRecipeInfo(Entry<String, RecipeCasting> recipe) {
return InputHelper.getStackDescription(recipe.getValue().output);
}
}
}
@@ -1,14 +1,25 @@
package modtweaker2.mods.mariculture.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import mariculture.api.core.FuelInfo;
import mariculture.api.core.MaricultureHandlers;
import mariculture.api.core.RecipeSmelter;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.mariculture.MaricultureHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
@@ -21,6 +32,9 @@ import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mariculture.Crucible")
public class Crucible {
public static final String nameSmelting = "Mariculture Crucible (Smelting)";
public static final String nameFuel = "Mariculture Crucible (Fuel)";
/********************************************** Mariculture Crucible Recipes **********************************************/
@@ -32,14 +46,15 @@ public class Crucible {
}
// Passes the list to the base list implementation, and adds the recipe
private static class AddRecipe extends BaseListAddition {
private static class AddRecipe extends BaseListAddition<RecipeSmelter> {
public AddRecipe(RecipeSmelter recipe) {
super("Mariculture Crucible", MaricultureHandlers.crucible.getRecipes(), recipe);
super(Crucible.nameSmelting, MaricultureHandlers.crucible.getRecipes());
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((RecipeSmelter) recipe).input.getDisplayName();
public String getRecipeInfo(RecipeSmelter recipe) {
return InputHelper.getStackDescription(recipe.input);
}
}
@@ -47,35 +62,34 @@ public class Crucible {
// Removing a Mariculture Crucible recipe
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new RemoveRecipe(toStack(input)));
public static void removeRecipe(IIngredient input) {
List<RecipeSmelter> recipes = new LinkedList<RecipeSmelter>();
for (RecipeSmelter r : MaricultureHandlers.crucible.getRecipes()) {
if (r != null) {
if (r.input != null && matches(input, toIItemStack(r.input))) {
recipes.add(r);
}
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveRecipe(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored", Crucible.nameSmelting, input.toString()));
}
}
// Removes a recipe, apply is never the same for anything, so will always
// need to override it
private static class RemoveRecipe extends BaseListRemoval {
public RemoveRecipe(ItemStack stack) {
super("Mariculture Crucible", MaricultureHandlers.crucible.getRecipes(), stack);
}
// Loops through the registry, to find the item that matches, saves that
// recipe then removes it
@Override
public void apply() {
for (RecipeSmelter r : MaricultureHandlers.crucible.getRecipes()) {
if (r != null) {
if (r.input != null && stack != null && areEqual(r.input, stack)) {
recipes.add(r);
}
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
private static class RemoveRecipe extends BaseListRemoval<RecipeSmelter> {
public RemoveRecipe(List<RecipeSmelter> recipes) {
super(Crucible.nameSmelting, MaricultureHandlers.crucible.getRecipes(), recipes);
}
@Override
public String getRecipeInfo(RecipeSmelter recipe) {
return InputHelper.getStackDescription(recipe.input);
}
}
/********************************************** Crucible Fuels **********************************************/
@@ -95,42 +109,58 @@ public class Crucible {
}
// Passes the list to the base map implementation, and adds the recipe
private static class AddFuel extends BaseMapAddition {
private static class AddFuel extends BaseMapAddition<Object, FuelInfo> {
public AddFuel(Object o, FuelInfo info) {
super("Mariculture Crucible Fuel", MaricultureHelper.fuels, MaricultureHelper.getKey(o), info);
super(Crucible.nameFuel, MaricultureHelper.fuels);
recipes.put(MaricultureHelper.getKey(o), info);
}
@Override
public String getRecipeInfo() {
return (String) key;
}
@Override
public String getRecipeInfo(Entry<Object, FuelInfo> recipe) {
return (String) recipe.getKey();
}
}
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeFuel(IItemStack fuel) {
MineTweakerAPI.apply(new RemoveFuel(fuel));
removeFuelEntry(fuel);
}
@ZenMethod
public static void removeFuel(ILiquidStack fuel) {
MineTweakerAPI.apply(new RemoveFuel(fuel));
removeFuelEntry(fuel);
}
@ZenMethod
public static void removeFuel(String fuel) {
MineTweakerAPI.apply(new RemoveFuel(fuel));
removeFuelEntry(fuel);
}
public static void removeFuelEntry(Object o) {
String key = MaricultureHelper.getKey(o);
Map<Object, FuelInfo> recipes = new HashMap<Object, FuelInfo>();
for(Entry<Object, FuelInfo> entry : MaricultureHelper.fuels.entrySet()) {
if(key.matches((String)entry.getKey())) {
recipes.put(key, entry.getValue());
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveFuel(recipes));
}
}
// Removes a recipe, will always remove the key, so all should be good
private static class RemoveFuel extends BaseMapRemoval {
public RemoveFuel(Object o) {
super("Mariculture Crucible Fuel", MaricultureHelper.fuels, MaricultureHelper.getKey(o), null);
private static class RemoveFuel extends BaseMapRemoval<Object, FuelInfo> {
public RemoveFuel(Map<Object, FuelInfo> recipes) {
super(Crucible.nameFuel, MaricultureHelper.fuels, recipes);
}
@Override
public String getRecipeInfo() {
return (String) key;
}
@Override
public String getRecipeInfo(Entry<Object, FuelInfo> recipe) {
return (String) recipe.getKey();
}
}
}
@@ -14,8 +14,7 @@ import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.ReflectionHelper;
import modtweaker2.mods.mariculture.MaricultureHelper;
import modtweaker2.utils.BaseDescriptionAddition;
import modtweaker2.utils.BaseDescriptionRemoval;
import modtweaker2.utils.BaseUndoable;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
@@ -67,7 +66,7 @@ public class Fishing {
}
}
private static class AddLoot extends BaseDescriptionAddition {
private static class AddLoot extends BaseUndoable {
private final Loot loot;
public AddLoot(Loot loot, String description) {
@@ -80,6 +79,7 @@ public class Fishing {
ArrayList<Loot> list = MaricultureHelper.loot.get(loot.rarity);
list.add(loot);
MaricultureHelper.loot.put(loot.rarity, list);
success = true;
}
@Override
@@ -103,7 +103,7 @@ public class Fishing {
MineTweakerAPI.apply(new RemoveLoot(toStack(loot)));
}
private static class RemoveLoot extends BaseDescriptionRemoval {
private static class RemoveLoot extends BaseUndoable {
private HashMap<Rarity, Loot> loot;
private final ItemStack stack;
@@ -119,6 +119,7 @@ public class Fishing {
apply(Rarity.JUNK);
apply(Rarity.GOOD);
apply(Rarity.RARE);
success = true;
}
//Performs the apply function on all rarity types
@@ -1,22 +1,34 @@
package modtweaker2.mods.mariculture.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toILiquidStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import mariculture.api.core.MaricultureHandlers;
import mariculture.api.core.RecipeVat;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mariculture.Vat")
public class Vat {
public static final String name = "Mariculture Vat";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Adding a Mariculture Vat recipe
@ZenMethod
public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, ILiquidStack outputFluid, int time) {
@@ -64,74 +76,82 @@ public class Vat {
}
// Passes the list to the base list implementation, and adds the recipe
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<RecipeVat> {
public Add(RecipeVat recipe) {
super("Mariculture Vat", MaricultureHandlers.vat.getRecipes(), recipe);
super("Mariculture Vat", MaricultureHandlers.vat.getRecipes());
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
if (((RecipeVat) recipe).outputItem != null)
return ((RecipeVat) recipe).outputItem.getDisplayName();
else
return ((RecipeVat) recipe).outputFluid.getFluid().getLocalizedName();
public String getRecipeInfo(RecipeVat recipe) {
if(recipe.outputItem != null) {
return InputHelper.getStackDescription(recipe.outputItem);
} else {
return InputHelper.getStackDescription(recipe.outputFluid);
}
}
}
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Removing a Mariculture Vat recipe
@ZenMethod
public static void removeRecipe(IItemStack outputItem) {
MineTweakerAPI.apply(new Remove(toStack(outputItem), null));
public static void removeRecipe(IIngredient ingredient) {
List<RecipeVat> recipes = new LinkedList<RecipeVat>();
for(RecipeVat r : MaricultureHandlers.vat.getRecipes()) {
if(r != null) {
if(r.outputItem != null && matches(ingredient, toIItemStack(r.outputItem))) {
recipes.add(r);
}
else if(r.outputFluid != null && matches(ingredient, toILiquidStack(r.outputFluid))) {
recipes.add(r);
}
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipes found for %s. Command ignored!", Vat.name, ingredient.toString()));
}
}
@ZenMethod
public static void removeRecipe(ILiquidStack outputFluid) {
MineTweakerAPI.apply(new Remove(null, toFluid(outputFluid)));
}
@ZenMethod
public static void removeRecipe(IItemStack outputItem, ILiquidStack outputFluid) {
MineTweakerAPI.apply(new Remove(toStack(outputItem), toFluid(outputFluid)));
public static void removeRecipe(IIngredient outputItem, IIngredient outputFluid) {
List<RecipeVat> recipes = new LinkedList<RecipeVat>();
for (RecipeVat r : MaricultureHandlers.vat.getRecipes()) {
if (r != null) {
if (r.outputItem != null && matches(outputItem, toIItemStack(r.outputItem))) {
if (r.outputFluid != null && matches(outputFluid, toILiquidStack(r.outputFluid))) {
recipes.add(r);
}
}
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipes found for %s and %s. Command ignored!", Vat.name, outputItem.toString(), outputFluid.toString()));
}
}
// Removes a recipe, apply is never the same for anything, so will always
// need to override it
private static class Remove extends BaseListRemoval {
private FluidStack fluid = null;
public Remove(ItemStack stack, FluidStack fluid) {
super("Mariculture Vat", MaricultureHandlers.vat.getRecipes(), stack);
if (fluid != null)
this.fluid = fluid;
private static class Remove extends BaseListRemoval<RecipeVat> {
public Remove(List<RecipeVat> recipes) {
super("Mariculture Vat", MaricultureHandlers.vat.getRecipes(), recipes);
}
// Loops through the registry, to find the item that matches, saves that
// recipe then removes it
@Override
public void apply() {
for (RecipeVat r : MaricultureHandlers.vat.getRecipes()) {
if (r != null)
if (r.outputItem != null && stack != null && areEqual(r.outputItem, stack)) {
if (r.outputFluid == null || (fluid != null && r.outputFluid.isFluidStackIdentical(fluid))) {
recipes.add(r);
break;
}
}
if ((r.outputFluid != null && fluid != null && r.outputFluid.isFluidStackIdentical(fluid))) {
recipes.add(r);
break;
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack != null ? stack.getDisplayName() : fluid.getFluid().getLocalizedName();
}
@Override
public String getRecipeInfo(RecipeVat recipe) {
if(recipe.outputItem != null) {
return InputHelper.getStackDescription(recipe.outputItem);
} else {
return InputHelper.getStackDescription(recipe.outputFluid);
}
}
}
}
@@ -1,56 +1,56 @@
package modtweaker2.mods.mekanism;
import java.util.regex.Pattern;
import minetweaker.MineTweakerAPI;
import modtweaker2.mods.mekanism.gas.GasBracketHandler;
import modtweaker2.mods.mekanism.handlers.v8.ChemicalInfuser;
import modtweaker2.mods.mekanism.handlers.v8.ChemicalInjection;
import modtweaker2.mods.mekanism.handlers.ChemicalOxidizer;
import modtweaker2.mods.mekanism.handlers.ChemicalWasher;
import modtweaker2.mods.mekanism.handlers.Combiner;
import modtweaker2.mods.mekanism.handlers.Compressor;
import modtweaker2.mods.mekanism.handlers.Crusher;
import modtweaker2.mods.mekanism.handlers.Enrichment;
import modtweaker2.mods.mekanism.handlers.Purification;
import modtweaker2.mods.mekanism.handlers.Reaction;
import modtweaker2.mods.mekanism.handlers.Sawmill;
import modtweaker2.mods.mekanism.handlers.Separator;
import modtweaker2.mods.mekanism.handlers.v8.ChemicalCrystallizer;
import modtweaker2.mods.mekanism.handlers.v8.ChemicalDissolution;
import modtweaker2.mods.mekanism.handlers.v8.Infuser;
import modtweaker2.utils.TweakerPlugin;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
public class Mekanism extends TweakerPlugin {
public static final boolean v7 = isV7();
public Mekanism() {
MineTweakerAPI.registerBracketHandler(new GasBracketHandler());
MineTweakerAPI.registerClass(Combiner.class);
MineTweakerAPI.registerClass(Compressor.class);
MineTweakerAPI.registerClass(Crusher.class);
MineTweakerAPI.registerClass(Enrichment.class);
MineTweakerAPI.registerClass(Infuser.class);
MineTweakerAPI.registerClass(Purification.class);
MineTweakerAPI.registerClass(Reaction.class);
MineTweakerAPI.registerClass(Sawmill.class);
MineTweakerAPI.registerClass(Separator.class);
//package modtweaker2.mods.mekanism;
//
//import java.util.regex.Pattern;
//
//import minetweaker.MineTweakerAPI;
//import modtweaker2.mods.mekanism.gas.GasBracketHandler;
//import modtweaker2.mods.mekanism.handlers.ChemicalOxidizer;
//import modtweaker2.mods.mekanism.handlers.ChemicalWasher;
//import modtweaker2.mods.mekanism.handlers.Combiner;
//import modtweaker2.mods.mekanism.handlers.Compressor;
//import modtweaker2.mods.mekanism.handlers.Crusher;
//import modtweaker2.mods.mekanism.handlers.Enrichment;
//import modtweaker2.mods.mekanism.handlers.Purification;
//import modtweaker2.mods.mekanism.handlers.Reaction;
//import modtweaker2.mods.mekanism.handlers.Sawmill;
//import modtweaker2.mods.mekanism.handlers.Separator;
//import modtweaker2.mods.mekanism.handlers.v8.ChemicalCrystallizer;
//import modtweaker2.mods.mekanism.handlers.v8.ChemicalDissolution;
//import modtweaker2.mods.mekanism.handlers.v8.ChemicalInfuser;
//import modtweaker2.mods.mekanism.handlers.v8.ChemicalInjection;
//import modtweaker2.mods.mekanism.handlers.v8.Infuser;
//import modtweaker2.utils.TweakerPlugin;
//import cpw.mods.fml.common.Loader;
//import cpw.mods.fml.common.ModContainer;
//
//public class Mekanism extends TweakerPlugin {
// public static final boolean v7 = isV7();
// public Mekanism() {
// MineTweakerAPI.registerBracketHandler(new GasBracketHandler());
// MineTweakerAPI.registerClass(Combiner.class);
// MineTweakerAPI.registerClass(Compressor.class);
// MineTweakerAPI.registerClass(Crusher.class);
// MineTweakerAPI.registerClass(Enrichment.class);
// MineTweakerAPI.registerClass(Infuser.class);
// MineTweakerAPI.registerClass(Purification.class);
// MineTweakerAPI.registerClass(Reaction.class);
// MineTweakerAPI.registerClass(Sawmill.class);
// MineTweakerAPI.registerClass(Separator.class);
//// MineTweakerAPI.registerClass(ChemicalCrystallizer.class);
// MineTweakerAPI.registerClass(ChemicalCrystallizer.class);
MineTweakerAPI.registerClass(ChemicalCrystallizer.class);
MineTweakerAPI.registerClass(ChemicalDissolution.class);
MineTweakerAPI.registerClass(ChemicalInfuser.class);
MineTweakerAPI.registerClass(ChemicalInjection.class);
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;
}
}
// MineTweakerAPI.registerClass(ChemicalDissolution.class);
// MineTweakerAPI.registerClass(ChemicalInfuser.class);
// MineTweakerAPI.registerClass(ChemicalInjection.class);
// 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;
// }
//}
@@ -1,27 +1,27 @@
package modtweaker2.mods.mekanism;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import minetweaker.api.item.IIngredient;
import modtweaker2.mods.mekanism.gas.IGasStack;
public class MekanismHelper {
private MekanismHelper() {}
public static GasStack toGas(IGasStack iStack) {
if (iStack == null) {
return null;
} else return new GasStack(GasRegistry.getGas(iStack.getName()), iStack.getAmount());
}
public static GasStack[] toGases(IIngredient[] input) {
return toGases((IGasStack[]) input);
}
public static GasStack[] toGases(IGasStack[] iStack) {
GasStack[] stack = new GasStack[iStack.length];
for (int i = 0; i < stack.length; i++)
stack[i] = toGas(iStack[i]);
return stack;
}
}
//package modtweaker2.mods.mekanism;
//
//import mekanism.api.gas.GasRegistry;
//import mekanism.api.gas.GasStack;
//import minetweaker.api.item.IIngredient;
//import modtweaker2.mods.mekanism.gas.IGasStack;
//
//public class MekanismHelper {
// private MekanismHelper() {}
//
// public static GasStack toGas(IGasStack iStack) {
// if (iStack == null) {
// return null;
// } else return new GasStack(GasRegistry.getGas(iStack.getName()), iStack.getAmount());
// }
//
// public static GasStack[] toGases(IIngredient[] input) {
// return toGases((IGasStack[]) input);
// }
//
// public static GasStack[] toGases(IGasStack[] iStack) {
// GasStack[] stack = new GasStack[iStack.length];
// for (int i = 0; i < stack.length; i++)
// stack[i] = toGas(iStack[i]);
// return stack;
// }
//}
@@ -1,34 +1,34 @@
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.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;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Crystallizer")
public class ChemicalCrystallizer {
@ZenMethod
public static void addRecipe(IGasStack input, IItemStack 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)));
}
}
//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.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;
//import stanhebben.zenscript.annotations.ZenClass;
//import stanhebben.zenscript.annotations.ZenMethod;
//
//@ZenClass("mods.mekanism.chemical.Crystallizer")
//public class ChemicalCrystallizer {
// @ZenMethod
// public static void addRecipe(IGasStack input, IItemStack 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)));
// }
//}
@@ -1,90 +1,90 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import java.util.Iterator;
import java.util.List;
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;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Dissolution")
public class ChemicalDissolution {
@ZenMethod
public static void addRecipe(IItemStack input, IGasStack 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<ItemStack> stacks = OreDictionary.getOres(InputHelper.toString(input));
for (ItemStack stack : stacks) {
MineTweakerAPI.apply(new Remove("CHEMICAL_DISSOLUTION_CHAMBER", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), stack));
}
}
@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)));
}
private static class Remove extends RemoveMekanismRecipe {
public Remove(String string, Map map, Object key) {
super(string, map, key);
}
@Override
public void apply() {
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry) it.next();
ItemStack key = (ItemStack) pairs.getKey();
GasStack value = (GasStack) pairs.getValue();
if (key != null) {
if (this.key instanceof ItemStack && areEqual(key, (ItemStack) this.key)) {
this.key = key;
break;
} else if (this.key instanceof GasStack && value.isGasEqual((GasStack) this.key)) {
this.key = key;
break;
}
}
}
recipe = map.get(key);
map.remove(key);
}
}
}
//package modtweaker2.mods.mekanism.handlers;
//
//import static modtweaker2.helpers.InputHelper.toStack;
//import static modtweaker2.helpers.StackHelper.areEqual;
//import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
//
//import java.util.Iterator;
//import java.util.List;
//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;
//import net.minecraft.item.ItemStack;
//import net.minecraftforge.oredict.OreDictionary;
//import stanhebben.zenscript.annotations.ZenClass;
//import stanhebben.zenscript.annotations.ZenMethod;
//
//@ZenClass("mods.mekanism.chemical.Dissolution")
//public class ChemicalDissolution {
// @ZenMethod
// public static void addRecipe(IItemStack input, IGasStack 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<ItemStack> stacks = OreDictionary.getOres(InputHelper.toString(input));
// for (ItemStack stack : stacks) {
// MineTweakerAPI.apply(new Remove("CHEMICAL_DISSOLUTION_CHAMBER", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), stack));
// }
// }
//
// @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)));
// }
//
// private static class Remove extends RemoveMekanismRecipe {
// public Remove(String string, Map map, Object key) {
// super(string, map, key);
// }
//
// @Override
// public void apply() {
// Iterator it = map.entrySet().iterator();
// while (it.hasNext()) {
// Map.Entry pairs = (Map.Entry) it.next();
// ItemStack key = (ItemStack) pairs.getKey();
// GasStack value = (GasStack) pairs.getValue();
// if (key != null) {
// if (this.key instanceof ItemStack && areEqual(key, (ItemStack) this.key)) {
// this.key = key;
// break;
// } else if (this.key instanceof GasStack && value.isGasEqual((GasStack) this.key)) {
// this.key = key;
// break;
// }
// }
//
// }
//
// recipe = map.get(key);
// map.remove(key);
// }
// }
//}
@@ -1,36 +1,36 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.ChemicalPairInput;
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;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Infuser")
public class ChemicalInfuser {
@ZenMethod
public static void addRecipe(IGasStack left, IGasStack right, IGasStack out) {
if (Mekanism.v7) {
ChemicalPairInput pair = new ChemicalPairInput(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)));
}
}
//package modtweaker2.mods.mekanism.handlers;
//
//import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
//import mekanism.common.recipe.RecipeHandler.Recipe;
//import mekanism.common.recipe.inputs.ChemicalPairInput;
//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;
//import stanhebben.zenscript.annotations.ZenClass;
//import stanhebben.zenscript.annotations.ZenMethod;
//
//@ZenClass("mods.mekanism.chemical.Infuser")
//public class ChemicalInfuser {
// @ZenMethod
// public static void addRecipe(IGasStack left, IGasStack right, IGasStack out) {
// if (Mekanism.v7) {
// ChemicalPairInput pair = new ChemicalPairInput(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)));
//
//
// }
//}
@@ -1,38 +1,38 @@
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.inputs.AdvancedMachineInput;
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;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Injection")
public class ChemicalInjection {
@ZenMethod
public static void addRecipe(IItemStack input, IGasStack gas, IItemStack output) {
if (Mekanism.v7)
{
AdvancedMachineInput aInput = new AdvancedMachineInput(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)));
}
}
//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.inputs.AdvancedMachineInput;
//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;
//import stanhebben.zenscript.annotations.ZenClass;
//import stanhebben.zenscript.annotations.ZenMethod;
//
//@ZenClass("mods.mekanism.chemical.Injection")
//public class ChemicalInjection {
// @ZenMethod
// public static void addRecipe(IItemStack input, IGasStack gas, IItemStack output) {
// if (Mekanism.v7)
// {
// AdvancedMachineInput aInput = new AdvancedMachineInput(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)));
// }
//}
@@ -1,36 +1,36 @@
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;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Oxidizer")
public class ChemicalOxidizer {
@ZenMethod
public static void addRecipe(IItemStack input, IGasStack 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)));
}
}
//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;
//import stanhebben.zenscript.annotations.ZenClass;
//import stanhebben.zenscript.annotations.ZenMethod;
//
//@ZenClass("mods.mekanism.chemical.Oxidizer")
//public class ChemicalOxidizer {
// @ZenMethod
// public static void addRecipe(IItemStack input, IGasStack 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)));
// }
//}
@@ -1,65 +1,65 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import java.util.Iterator;
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;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Washer")
public class ChemicalWasher {
@ZenMethod
public static void addRecipe(IGasStack input, IGasStack 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)));
}
private static class Remove extends RemoveMekanismRecipe {
public Remove(String string, Map map, Object key) {
super(string, map, key);
}
@Override
public void apply() {
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry) it.next();
GasStack key = (GasStack) pairs.getKey();
GasStack value = (GasStack) pairs.getValue();
if (key != null) {
if (this.key instanceof GasStack && value.isGasEqual((GasStack) this.key)) {
this.key = key;
break;
}
}
}
recipe = map.get(key);
map.remove(key);
}
}
}
//package modtweaker2.mods.mekanism.handlers;
//
//import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
//
//import java.util.Iterator;
//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;
//import stanhebben.zenscript.annotations.ZenClass;
//import stanhebben.zenscript.annotations.ZenMethod;
//
//@ZenClass("mods.mekanism.chemical.Washer")
//public class ChemicalWasher {
// @ZenMethod
// public static void addRecipe(IGasStack input, IGasStack 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)));
// }
//
// private static class Remove extends RemoveMekanismRecipe {
// public Remove(String string, Map map, Object key) {
// super(string, map, key);
// }
//
// @Override
// public void apply() {
// Iterator it = map.entrySet().iterator();
// while (it.hasNext()) {
// Map.Entry pairs = (Map.Entry) it.next();
// GasStack key = (GasStack) pairs.getKey();
// GasStack value = (GasStack) pairs.getValue();
// if (key != null) {
// if (this.key instanceof GasStack && value.isGasEqual((GasStack) this.key)) {
// this.key = key;
// break;
// }
// }
//
// }
//
// recipe = map.get(key);
// map.remove(key);
// }
// }
//}
@@ -1,35 +1,35 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import mekanism.api.gas.GasRegistry;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.AdvancedMachineInput;
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;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Combiner")
public class Combiner {
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output) {
AdvancedMachineInput aInput = new AdvancedMachineInput(toStack(input), GasRegistry.getGas("liquidStone"));
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)));
}
}
//package modtweaker2.mods.mekanism.handlers;
//
//import static modtweaker2.helpers.InputHelper.toStack;
//import mekanism.api.gas.GasRegistry;
//import mekanism.common.recipe.RecipeHandler.Recipe;
//import mekanism.common.recipe.inputs.AdvancedMachineInput;
//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;
//import stanhebben.zenscript.annotations.ZenMethod;
//
//@ZenClass("mods.mekanism.Combiner")
//public class Combiner {
// @ZenMethod
// public static void addRecipe(IItemStack input, IItemStack output) {
// AdvancedMachineInput aInput = new AdvancedMachineInput(toStack(input), GasRegistry.getGas("liquidStone"));
// 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)));
// }
//}
@@ -1,35 +1,35 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import mekanism.api.gas.GasRegistry;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.AdvancedMachineInput;
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;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Compressor")
public class Compressor {
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output) {
AdvancedMachineInput aInput = new AdvancedMachineInput(toStack(input), GasRegistry.getGas("liquidOsmium"));
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)));
}
}
//package modtweaker2.mods.mekanism.handlers;
//
//import static modtweaker2.helpers.InputHelper.toStack;
//import mekanism.api.gas.GasRegistry;
//import mekanism.common.recipe.RecipeHandler.Recipe;
//import mekanism.common.recipe.inputs.AdvancedMachineInput;
//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;
//import stanhebben.zenscript.annotations.ZenMethod;
//
//@ZenClass("mods.mekanism.Compressor")
//public class Compressor {
// @ZenMethod
// public static void addRecipe(IItemStack input, IItemStack output) {
// AdvancedMachineInput aInput = new AdvancedMachineInput(toStack(input), GasRegistry.getGas("liquidOsmium"));
// 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)));
// }
//}
@@ -1,32 +1,32 @@
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;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Crusher")
public class Crusher {
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack 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)));
}
}
//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;
//import stanhebben.zenscript.annotations.ZenMethod;
//
//@ZenClass("mods.mekanism.Crusher")
//public class Crusher {
// @ZenMethod
// public static void addRecipe(IItemStack input, IItemStack 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)));
// }
//}
@@ -1,32 +1,32 @@
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;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Enrichment")
public class Enrichment {
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack 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)));
}
}
//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;
//import stanhebben.zenscript.annotations.ZenMethod;
//
//@ZenClass("mods.mekanism.Enrichment")
//public class Enrichment {
// @ZenMethod
// public static void addRecipe(IItemStack input, IItemStack 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)));
// }
//}
@@ -1,62 +1,62 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import java.util.Map;
import mekanism.api.gas.GasRegistry;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.AdvancedMachineInput;
import mekanism.common.recipe.machines.PurificationRecipe;
import mekanism.common.recipe.outputs.MachineOutput;
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;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Purification")
public class Purification {
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output) {
if (Mekanism.v7)
{
AdvancedMachineInput aInput = new AdvancedMachineInput(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)));
}
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack stack) {
super("Purification Chamber", Recipe.PURIFICATION_CHAMBER.get(), stack);
}
//We must search through the recipe entries so that we can assign the correct key for removal
@Override
public void apply() {
for (Map.Entry<MachineOutput, ItemStack> entry : ((Map<MachineOutput, ItemStack>) map).entrySet()) {
if (entry.getValue() != null && areEqual(entry.getValue(), (ItemStack) stack)) {
key = entry.getKey();
break;
}
}
super.apply();
}
}
}
//package modtweaker2.mods.mekanism.handlers;
//
//import static modtweaker2.helpers.InputHelper.toStack;
//import static modtweaker2.helpers.StackHelper.areEqual;
//
//import java.util.Map;
//
//import mekanism.api.gas.GasRegistry;
//import mekanism.common.recipe.RecipeHandler.Recipe;
//import mekanism.common.recipe.inputs.AdvancedMachineInput;
//import mekanism.common.recipe.machines.PurificationRecipe;
//import mekanism.common.recipe.outputs.MachineOutput;
//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;
//import stanhebben.zenscript.annotations.ZenClass;
//import stanhebben.zenscript.annotations.ZenMethod;
//
//@ZenClass("mods.mekanism.Purification")
//public class Purification {
// @ZenMethod
// public static void addRecipe(IItemStack input, IItemStack output) {
// if (Mekanism.v7)
// {
// AdvancedMachineInput aInput = new AdvancedMachineInput(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)));
// }
//
// private static class Remove extends BaseMapRemoval {
// public Remove(ItemStack stack) {
// super("Purification Chamber", Recipe.PURIFICATION_CHAMBER.get(), stack);
// }
//
// //We must search through the recipe entries so that we can assign the correct key for removal
// @Override
// public void apply() {
// for (Map.Entry<MachineOutput, ItemStack> entry : ((Map<MachineOutput, ItemStack>) map).entrySet()) {
// if (entry.getValue() != null && areEqual(entry.getValue(), (ItemStack) stack)) {
// key = entry.getKey();
// break;
// }
// }
//
// super.apply();
// }
// }
//}
@@ -1,42 +1,42 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.PressurizedInput;
import mekanism.common.recipe.machines.PressurizedRecipe;
import mekanism.common.recipe.outputs.PressurizedOutput;
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;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Reaction")
public class Reaction {
@ZenMethod
public static void addRecipe(IItemStack solid, ILiquidStack liquid, IGasStack gas, IItemStack outItem, IGasStack outGas, double energy, int ticks) {
if (Mekanism.v7)
{
PressurizedInput input = new PressurizedInput(toStack(solid), toFluid(liquid), toGas(gas));
PressurizedRecipe recipe = new PressurizedRecipe(input, new PressurizedOutput(toStack(outItem), toGas(outGas)), energy, 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");
PressurizedOutput output = new PressurizedOutput(toStack(outItem), toGas(outGas));
MineTweakerAPI.apply(new RemoveMekanismRecipe("PRESSURIZED_REACTION_CHAMBER", Recipe.PRESSURIZED_REACTION_CHAMBER.get(), output));
}
}
//package modtweaker2.mods.mekanism.handlers;
//
//import static modtweaker2.helpers.InputHelper.toFluid;
//import static modtweaker2.helpers.InputHelper.toStack;
//import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
//import mekanism.common.recipe.RecipeHandler.Recipe;
//import mekanism.common.recipe.inputs.PressurizedInput;
//import mekanism.common.recipe.machines.PressurizedRecipe;
//import mekanism.common.recipe.outputs.PressurizedOutput;
//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;
//import stanhebben.zenscript.annotations.ZenClass;
//import stanhebben.zenscript.annotations.ZenMethod;
//
//@ZenClass("mods.mekanism.Reaction")
//public class Reaction {
// @ZenMethod
// public static void addRecipe(IItemStack solid, ILiquidStack liquid, IGasStack gas, IItemStack outItem, IGasStack outGas, double energy, int ticks) {
// if (Mekanism.v7)
// {
// PressurizedInput input = new PressurizedInput(toStack(solid), toFluid(liquid), toGas(gas));
// PressurizedRecipe recipe = new PressurizedRecipe(input, new PressurizedOutput(toStack(outItem), toGas(outGas)), energy, 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");
// PressurizedOutput output = new PressurizedOutput(toStack(outItem), toGas(outGas));
// MineTweakerAPI.apply(new RemoveMekanismRecipe("PRESSURIZED_REACTION_CHAMBER", Recipe.PRESSURIZED_REACTION_CHAMBER.get(), output));
// }
//}
@@ -1,61 +1,61 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import java.util.Map;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.machines.SawmillRecipe;
import mekanism.common.recipe.outputs.ChanceOutput;
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;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Sawmill")
public class Sawmill {
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output1, @Optional IItemStack output2, @Optional double chance) {
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)));
}
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack stack) {
super("Precision Sawmill", Recipe.PRECISION_SAWMILL.get(), stack);
}
//We must search through the recipe entries so that we can assign the correct key for removal
@Override
public void apply() {
for (Map.Entry<ItemStack, Object> entry : ((Map<ItemStack, Object>) map).entrySet()) {
if (entry.getKey() != null && areEqual(entry.getKey(), (ItemStack) stack)) {
key = entry.getKey();
break;
}
}
super.apply();
}
}
}
//package modtweaker2.mods.mekanism.handlers;
//
//import static modtweaker2.helpers.InputHelper.toStack;
//import static modtweaker2.helpers.StackHelper.areEqual;
//
//import java.util.Map;
//
//import mekanism.common.recipe.RecipeHandler.Recipe;
//import mekanism.common.recipe.machines.SawmillRecipe;
//import mekanism.common.recipe.outputs.ChanceOutput;
//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;
//import stanhebben.zenscript.annotations.Optional;
//import stanhebben.zenscript.annotations.ZenClass;
//import stanhebben.zenscript.annotations.ZenMethod;
//
//@ZenClass("mods.mekanism.Sawmill")
//public class Sawmill {
// @ZenMethod
// public static void addRecipe(IItemStack input, IItemStack output1, @Optional IItemStack output2, @Optional double chance) {
// 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)));
// }
//
// private static class Remove extends BaseMapRemoval {
// public Remove(ItemStack stack) {
// super("Precision Sawmill", Recipe.PRECISION_SAWMILL.get(), stack);
// }
//
// //We must search through the recipe entries so that we can assign the correct key for removal
// @Override
// public void apply() {
// for (Map.Entry<ItemStack, Object> entry : ((Map<ItemStack, Object>) map).entrySet()) {
// if (entry.getKey() != null && areEqual(entry.getKey(), (ItemStack) stack)) {
// key = entry.getKey();
// break;
// }
// }
//
// super.apply();
// }
// }
//}
@@ -1,72 +1,72 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import java.util.Map;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.ChemicalPairInput;
import mekanism.common.recipe.machines.SeparatorRecipe;
import mekanism.common.recipe.outputs.ChemicalPairOutput;
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;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Separator")
public class Separator {
@ZenMethod
public static void addRecipe(ILiquidStack input, IGasStack gas1, IGasStack gas2) {
if (Mekanism.v7)
{
ChemicalPairInput pair = new ChemicalPairInput(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)));
}
private static class Remove extends BaseMapRemoval {
public Remove(FluidStack stack) {
super("Electrolytic Separator", Recipe.ELECTROLYTIC_SEPARATOR.get(), stack);
}
//We must search through the recipe entries so that we can assign the correct key for removal
@Override
public void apply() {
for (Map.Entry<FluidStack, ChemicalPairOutput> entry : ((Map<FluidStack, ChemicalPairOutput>) map).entrySet()) {
if (entry.getKey() != null && entry.getKey().isFluidEqual((FluidStack) stack)) {
key = entry.getKey();
break;
}
}
super.apply();
}
}
}
//package modtweaker2.mods.mekanism.handlers;
//
//import static modtweaker2.helpers.InputHelper.toFluid;
//import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
//
//import java.util.Map;
//
//import mekanism.common.recipe.RecipeHandler.Recipe;
//import mekanism.common.recipe.inputs.ChemicalPairInput;
//import mekanism.common.recipe.machines.SeparatorRecipe;
//import mekanism.common.recipe.outputs.ChemicalPairOutput;
//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;
//import net.minecraftforge.fluids.FluidStack;
//import stanhebben.zenscript.annotations.ZenClass;
//import stanhebben.zenscript.annotations.ZenMethod;
//
//@ZenClass("mods.mekanism.Separator")
//public class Separator {
// @ZenMethod
// public static void addRecipe(ILiquidStack input, IGasStack gas1, IGasStack gas2) {
// if (Mekanism.v7)
// {
// ChemicalPairInput pair = new ChemicalPairInput(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)));
// }
//
// private static class Remove extends BaseMapRemoval {
// public Remove(FluidStack stack) {
// super("Electrolytic Separator", Recipe.ELECTROLYTIC_SEPARATOR.get(), stack);
// }
//
// //We must search through the recipe entries so that we can assign the correct key for removal
// @Override
// public void apply() {
// for (Map.Entry<FluidStack, ChemicalPairOutput> entry : ((Map<FluidStack, ChemicalPairOutput>) map).entrySet()) {
// if (entry.getKey() != null && entry.getKey().isFluidEqual((FluidStack) stack)) {
// key = entry.getKey();
// break;
// }
// }
//
// super.apply();
// }
// }
//}
@@ -1,85 +1,83 @@
package modtweaker2.mods.mekanism.handlers.v8;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import mekanism.api.gas.GasStack;
import mekanism.common.KeySync.KeySet;
import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.GasInput;
import mekanism.common.recipe.machines.CrystallizerRecipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.mods.mekanism.gas.IGasStack;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Crystallizer")
public class ChemicalCrystallizer {
@ZenMethod
public static void addRecipe(IItemStack output, IGasStack input) {
MineTweakerAPI.apply(new Add(new ChemicalCrystallizerRecipe(toGas(input), InputHelper.toStack(output))));
}
private static class Add extends BaseMapAddition {
public Add(ChemicalCrystallizerRecipe recipe) {
super("Chemical Crystallizer", Recipe.CHEMICAL_CRYSTALLIZER.get(), recipe.inputGas, recipe.outputItem);
}
@Override
public void apply() {
RecipeHandler.addChemicalCrystallizerRecipe((GasStack) key, (ItemStack) recipe);
}
}
private static class ChemicalCrystallizerRecipe {
public GasStack inputGas;
public ItemStack outputItem;
public ChemicalCrystallizerRecipe(GasStack inputGas, ItemStack outputItem) {
this.inputGas = inputGas;
this.outputItem = outputItem;
}
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(InputHelper.toStack(output)));
}
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack stack) {
super("Chemical Crystallizer", Recipe.CHEMICAL_CRYSTALLIZER.get(), stack);
}
@SuppressWarnings("unchecked")
@Override
public void apply() {
List<GasInput> gasesToRemove = new ArrayList<GasInput>();
for(GasInput stack : (Set<GasInput>)Recipe.CHEMICAL_CRYSTALLIZER.get().keySet()){
CrystallizerRecipe crystalRecipe= (CrystallizerRecipe)Recipe.CHEMICAL_CRYSTALLIZER.get().get(stack);
if(crystalRecipe.getOutput().output.isItemEqual((ItemStack) this.stack)){
gasesToRemove.add(stack);
}
}
for(GasInput stack : gasesToRemove){
Recipe.CHEMICAL_CRYSTALLIZER.get().remove(stack);
}
}
}
}
//package modtweaker2.mods.mekanism.handlers.v8;
//
//import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Set;
//
//import mekanism.api.gas.GasStack;
//import mekanism.common.recipe.RecipeHandler;
//import mekanism.common.recipe.RecipeHandler.Recipe;
//import mekanism.common.recipe.inputs.GasInput;
//import mekanism.common.recipe.machines.CrystallizerRecipe;
//import minetweaker.MineTweakerAPI;
//import minetweaker.api.item.IItemStack;
//import modtweaker2.helpers.InputHelper;
//import modtweaker2.mods.mekanism.gas.IGasStack;
//import modtweaker2.utils.BaseMapAddition;
//import modtweaker2.utils.BaseMapRemoval;
//import net.minecraft.item.ItemStack;
//import stanhebben.zenscript.annotations.ZenClass;
//import stanhebben.zenscript.annotations.ZenMethod;
//
//@ZenClass("mods.mekanism.chemical.Crystallizer")
//public class ChemicalCrystallizer {
//
// @ZenMethod
// public static void addRecipe(IItemStack output, IGasStack input) {
// MineTweakerAPI.apply(new Add(new ChemicalCrystallizerRecipe(toGas(input), InputHelper.toStack(output))));
// }
//
// private static class Add extends BaseMapAddition {
//
// public Add(ChemicalCrystallizerRecipe recipe) {
// super("Chemical Crystallizer", Recipe.CHEMICAL_CRYSTALLIZER.get(), recipe.inputGas, recipe.outputItem);
// }
//
// @Override
// public void apply() {
// RecipeHandler.addChemicalCrystallizerRecipe((GasStack) key, (ItemStack) recipe);
// }
//
// }
//
// private static class ChemicalCrystallizerRecipe {
// public GasStack inputGas;
// public ItemStack outputItem;
//
// public ChemicalCrystallizerRecipe(GasStack inputGas, ItemStack outputItem) {
// this.inputGas = inputGas;
// this.outputItem = outputItem;
//
// }
// }
//
// @ZenMethod
// public static void removeRecipe(IItemStack output) {
// MineTweakerAPI.apply(new Remove(InputHelper.toStack(output)));
// }
//
// private static class Remove extends BaseMapRemoval {
//
// public Remove(ItemStack stack) {
// super("Chemical Crystallizer", Recipe.CHEMICAL_CRYSTALLIZER.get(), stack);
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public void apply() {
// List<GasInput> gasesToRemove = new ArrayList<GasInput>();
// for(GasInput stack : (Set<GasInput>)Recipe.CHEMICAL_CRYSTALLIZER.get().keySet()){
// CrystallizerRecipe crystalRecipe= (CrystallizerRecipe)Recipe.CHEMICAL_CRYSTALLIZER.get().get(stack);
// if(crystalRecipe.getOutput().output.isItemEqual((ItemStack) this.stack)){
// gasesToRemove.add(stack);
// }
// }
// for(GasInput stack : gasesToRemove){
// Recipe.CHEMICAL_CRYSTALLIZER.get().remove(stack);
// }
// }
//
// }
//}
@@ -1,84 +1,84 @@
package modtweaker2.mods.mekanism.handlers.v8;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import mekanism.api.gas.GasStack;
import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.ItemStackInput;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.mods.mekanism.MekanismHelper;
import modtweaker2.mods.mekanism.gas.IGasStack;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Dissolution")
public class ChemicalDissolution {
@ZenMethod
public static void addRecipe(IGasStack output, IItemStack input) {
MineTweakerAPI.apply(new Add(new DissolutionRecipe(MekanismHelper.toGas(output), InputHelper.toStack(input))));
}
private static class Add extends BaseMapAddition {
public DissolutionRecipe recipe;
public Add(DissolutionRecipe recipe) {
super("Dissolution Infuser", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), recipe.input, recipe.output);
this.recipe = recipe;
}
@Override
public void apply() {
RecipeHandler.addChemicalDissolutionChamberRecipe(recipe.input, recipe.output);
}
}
private static class DissolutionRecipe {
public GasStack output;
public ItemStack input;
public DissolutionRecipe(GasStack output, ItemStack input) {
this.output = output;
this.input = input;
}
}
@ZenMethod
public static void removeRecipe(IGasStack output) {
MineTweakerAPI.apply(new Remove(MekanismHelper.toGas(output)));
}
private static class Remove extends BaseMapRemoval {
public Remove(GasStack stack) {
super("Dissolution Infuser", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), stack);
}
@SuppressWarnings("unchecked")
@Override
public void apply() {
List<ItemStackInput> toRemove = new ArrayList<ItemStackInput>();
for (ItemStackInput stack : (Set<ItemStackInput>) Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().keySet()) {
mekanism.common.recipe.machines.DissolutionRecipe recipe = (mekanism.common.recipe.machines.DissolutionRecipe) Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().get(stack);
if (recipe.getOutput().output.isGasEqual((GasStack) this.stack)) {
toRemove.add(stack);
}
}
for (ItemStackInput stack : toRemove) {
Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().remove(stack);
}
}
}
}
//package modtweaker2.mods.mekanism.handlers.v8;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Set;
//
//import mekanism.api.gas.GasStack;
//import mekanism.common.recipe.RecipeHandler;
//import mekanism.common.recipe.RecipeHandler.Recipe;
//import mekanism.common.recipe.inputs.ItemStackInput;
//import minetweaker.MineTweakerAPI;
//import minetweaker.api.item.IItemStack;
//import modtweaker2.helpers.InputHelper;
//import modtweaker2.mods.mekanism.MekanismHelper;
//import modtweaker2.mods.mekanism.gas.IGasStack;
//import modtweaker2.utils.BaseMapAddition;
//import modtweaker2.utils.BaseMapRemoval;
//import net.minecraft.item.ItemStack;
//import stanhebben.zenscript.annotations.ZenClass;
//import stanhebben.zenscript.annotations.ZenMethod;
//
//@ZenClass("mods.mekanism.chemical.Dissolution")
//public class ChemicalDissolution {
//
// @ZenMethod
// public static void addRecipe(IGasStack output, IItemStack input) {
// MineTweakerAPI.apply(new Add(new DissolutionRecipe(MekanismHelper.toGas(output), InputHelper.toStack(input))));
// }
//
// private static class Add extends BaseMapAddition {
//
// public DissolutionRecipe recipe;
//
// public Add(DissolutionRecipe recipe) {
// super("Dissolution Infuser", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), recipe.input, recipe.output);
// this.recipe = recipe;
// }
//
// @Override
// public void apply() {
// RecipeHandler.addChemicalDissolutionChamberRecipe(recipe.input, recipe.output);
//
// }
// }
//
// private static class DissolutionRecipe {
// public GasStack output;
// public ItemStack input;
//
// public DissolutionRecipe(GasStack output, ItemStack input) {
// this.output = output;
// this.input = input;
// }
//
// }
//
// @ZenMethod
// public static void removeRecipe(IGasStack output) {
// MineTweakerAPI.apply(new Remove(MekanismHelper.toGas(output)));
// }
//
// private static class Remove extends BaseMapRemoval {
//
// public Remove(GasStack stack) {
// super("Dissolution Infuser", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), stack);
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public void apply() {
// List<ItemStackInput> toRemove = new ArrayList<ItemStackInput>();
// for (ItemStackInput stack : (Set<ItemStackInput>) Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().keySet()) {
// mekanism.common.recipe.machines.DissolutionRecipe recipe = (mekanism.common.recipe.machines.DissolutionRecipe) Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().get(stack);
// if (recipe.getOutput().output.isGasEqual((GasStack) this.stack)) {
// toRemove.add(stack);
// }
// }
// for (ItemStackInput stack : toRemove) {
// Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().remove(stack);
// }
// }
//
// }
//}
@@ -1,85 +1,85 @@
package modtweaker2.mods.mekanism.handlers.v8;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import mekanism.api.gas.GasStack;
import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.ChemicalPairInput;
import mekanism.common.recipe.machines.ChemicalInfuserRecipe;
import mekanism.common.recipe.outputs.GasOutput;
import minetweaker.MineTweakerAPI;
import modtweaker2.mods.mekanism.MekanismHelper;
import modtweaker2.mods.mekanism.gas.IGasStack;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Infuser")
public class ChemicalInfuser {
@ZenMethod
public static void addRecipe(IGasStack output, IGasStack inputLeft, IGasStack inputRight) {
MineTweakerAPI.apply(new Add(new InfuserRecipe(MekanismHelper.toGas(output), MekanismHelper.toGas(inputLeft), MekanismHelper.toGas(inputRight))));
}
private static class Add extends BaseMapAddition {
public InfuserRecipe recipe;
public Add(InfuserRecipe recipe) {
super("Chemical Infuser", Recipe.CHEMICAL_INFUSER.get(), new ChemicalPairInput(recipe.inputLeft, recipe.inputRight), new GasOutput(recipe.output));
this.recipe = recipe;
}
@Override
public void apply() {
RecipeHandler.addChemicalInfuserRecipe(recipe.inputLeft, recipe.inputRight, recipe.output);
}
}
private static class InfuserRecipe {
public GasStack output;
public GasStack inputLeft;
public GasStack inputRight;
public InfuserRecipe(GasStack output, GasStack inputLeft, GasStack inputRight) {
this.output = output;
this.inputLeft = inputLeft;
this.inputRight = inputRight;
}
}
@ZenMethod
public static void removeRecipe(IGasStack output) {
MineTweakerAPI.apply(new Remove(MekanismHelper.toGas(output)));
}
private static class Remove extends BaseMapRemoval {
public Remove(GasStack stack) {
super("Chemical Infuser", Recipe.CHEMICAL_INFUSER.get(), stack);
}
@SuppressWarnings("unchecked")
@Override
public void apply() {
List<ChemicalPairInput> toRemove = new ArrayList<ChemicalPairInput>();
for (ChemicalPairInput stack : (Set<ChemicalPairInput>) Recipe.CHEMICAL_INFUSER.get().keySet()) {
ChemicalInfuserRecipe recipe = (ChemicalInfuserRecipe) Recipe.CHEMICAL_INFUSER.get().get(stack);
if (recipe.getOutput().output.isGasEqual((GasStack)this.stack)) {
toRemove.add(stack);
}
}
for (ChemicalPairInput stack : toRemove) {
Recipe.CHEMICAL_INFUSER.get().remove(stack);
}
}
}
}
//package modtweaker2.mods.mekanism.handlers.v8;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Set;
//
//import mekanism.api.gas.GasStack;
//import mekanism.common.recipe.RecipeHandler;
//import mekanism.common.recipe.RecipeHandler.Recipe;
//import mekanism.common.recipe.inputs.ChemicalPairInput;
//import mekanism.common.recipe.machines.ChemicalInfuserRecipe;
//import mekanism.common.recipe.outputs.GasOutput;
//import minetweaker.MineTweakerAPI;
//import modtweaker2.mods.mekanism.MekanismHelper;
//import modtweaker2.mods.mekanism.gas.IGasStack;
//import modtweaker2.utils.BaseMapAddition;
//import modtweaker2.utils.BaseMapRemoval;
//import stanhebben.zenscript.annotations.ZenClass;
//import stanhebben.zenscript.annotations.ZenMethod;
//
//@ZenClass("mods.mekanism.chemical.Infuser")
//public class ChemicalInfuser {
//
// @ZenMethod
// public static void addRecipe(IGasStack output, IGasStack inputLeft, IGasStack inputRight) {
// MineTweakerAPI.apply(new Add(new InfuserRecipe(MekanismHelper.toGas(output), MekanismHelper.toGas(inputLeft), MekanismHelper.toGas(inputRight))));
// }
//
// private static class Add extends BaseMapAddition {
//
// public InfuserRecipe recipe;
//
// public Add(InfuserRecipe recipe) {
// super("Chemical Infuser", Recipe.CHEMICAL_INFUSER.get(), new ChemicalPairInput(recipe.inputLeft, recipe.inputRight), new GasOutput(recipe.output));
// this.recipe = recipe;
// }
//
// @Override
// public void apply() {
// RecipeHandler.addChemicalInfuserRecipe(recipe.inputLeft, recipe.inputRight, recipe.output);
//
// }
// }
//
// private static class InfuserRecipe {
// public GasStack output;
// public GasStack inputLeft;
// public GasStack inputRight;
//
// public InfuserRecipe(GasStack output, GasStack inputLeft, GasStack inputRight) {
// this.output = output;
// this.inputLeft = inputLeft;
// this.inputRight = inputRight;
// }
//
// }
//
// @ZenMethod
// public static void removeRecipe(IGasStack output) {
// MineTweakerAPI.apply(new Remove(MekanismHelper.toGas(output)));
// }
//
// private static class Remove extends BaseMapRemoval {
//
// public Remove(GasStack stack) {
// super("Chemical Infuser", Recipe.CHEMICAL_INFUSER.get(), stack);
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public void apply() {
// List<ChemicalPairInput> toRemove = new ArrayList<ChemicalPairInput>();
// for (ChemicalPairInput stack : (Set<ChemicalPairInput>) Recipe.CHEMICAL_INFUSER.get().keySet()) {
// ChemicalInfuserRecipe recipe = (ChemicalInfuserRecipe) Recipe.CHEMICAL_INFUSER.get().get(stack);
// if (recipe.getOutput().output.isGasEqual((GasStack)this.stack)) {
// toRemove.add(stack);
// }
// }
// for (ChemicalPairInput stack : toRemove) {
// Recipe.CHEMICAL_INFUSER.get().remove(stack);
// }
// }
//
// }
//}
@@ -1,86 +1,86 @@
package modtweaker2.mods.mekanism.handlers.v8;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import mekanism.api.gas.GasStack;
import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.AdvancedMachineInput;
import mekanism.common.recipe.outputs.ItemStackOutput;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.mods.mekanism.MekanismHelper;
import modtweaker2.mods.mekanism.gas.IGasStack;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Injection")
public class ChemicalInjection {
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input, IGasStack gas) {
MineTweakerAPI.apply(new Add(new InjectionRecipe(InputHelper.toStack(output), InputHelper.toStack(input), MekanismHelper.toGas(gas))));
}
private static class Add extends BaseMapAddition {
public InjectionRecipe recipe;
public Add(InjectionRecipe recipe) {
super("Chemical Injection", Recipe.CHEMICAL_INJECTION_CHAMBER.get(), recipe.input, recipe.output);
this.recipe = recipe;
}
@Override
public void apply() {
RecipeHandler.addChemicalInjectionChamberRecipe(recipe.input, recipe.gas.getGas().getLocalizedName(), recipe.output);
}
}
private static class InjectionRecipe {
public ItemStack output;
public ItemStack input;
public GasStack gas;
public InjectionRecipe(ItemStack output, ItemStack input, GasStack gas) {
this.output = output;
this.input = input;
this.gas = gas;
}
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(InputHelper.toStack(output)));
}
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack output) {
super("Chemical Injection", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), output);
}
@SuppressWarnings("unchecked")
@Override
public void apply() {
List<AdvancedMachineInput> toRemove = new ArrayList<AdvancedMachineInput>();
for (AdvancedMachineInput stack : (Set<AdvancedMachineInput>) Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().keySet()) {
ItemStackOutput recipe = (ItemStackOutput) Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().get(stack);
if (recipe.output.isItemEqual((ItemStack)this.stack)) {
toRemove.add(stack);
}
}
for (AdvancedMachineInput stack : toRemove) {
Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().remove(stack);
}
}
}
}
//package modtweaker2.mods.mekanism.handlers.v8;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Set;
//
//import mekanism.api.gas.GasStack;
//import mekanism.common.recipe.RecipeHandler;
//import mekanism.common.recipe.RecipeHandler.Recipe;
//import mekanism.common.recipe.inputs.AdvancedMachineInput;
//import mekanism.common.recipe.outputs.ItemStackOutput;
//import minetweaker.MineTweakerAPI;
//import minetweaker.api.item.IItemStack;
//import modtweaker2.helpers.InputHelper;
//import modtweaker2.mods.mekanism.MekanismHelper;
//import modtweaker2.mods.mekanism.gas.IGasStack;
//import modtweaker2.utils.BaseMapAddition;
//import modtweaker2.utils.BaseMapRemoval;
//import net.minecraft.item.ItemStack;
//import stanhebben.zenscript.annotations.ZenClass;
//import stanhebben.zenscript.annotations.ZenMethod;
//
//@ZenClass("mods.mekanism.chemical.Injection")
//public class ChemicalInjection {
//
// @ZenMethod
// public static void addRecipe(IItemStack output, IItemStack input, IGasStack gas) {
// MineTweakerAPI.apply(new Add(new InjectionRecipe(InputHelper.toStack(output), InputHelper.toStack(input), MekanismHelper.toGas(gas))));
// }
//
// private static class Add extends BaseMapAddition {
//
// public InjectionRecipe recipe;
//
// public Add(InjectionRecipe recipe) {
// super("Chemical Injection", Recipe.CHEMICAL_INJECTION_CHAMBER.get(), recipe.input, recipe.output);
// this.recipe = recipe;
// }
//
// @Override
// public void apply() {
// RecipeHandler.addChemicalInjectionChamberRecipe(recipe.input, recipe.gas.getGas().getLocalizedName(), recipe.output);
// }
// }
//
// private static class InjectionRecipe {
// public ItemStack output;
// public ItemStack input;
// public GasStack gas;
//
// public InjectionRecipe(ItemStack output, ItemStack input, GasStack gas) {
// this.output = output;
// this.input = input;
// this.gas = gas;
// }
//
// }
//
// @ZenMethod
// public static void removeRecipe(IItemStack output) {
// MineTweakerAPI.apply(new Remove(InputHelper.toStack(output)));
// }
//
// private static class Remove extends BaseMapRemoval {
//
// public Remove(ItemStack output) {
// super("Chemical Injection", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), output);
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public void apply() {
// List<AdvancedMachineInput> toRemove = new ArrayList<AdvancedMachineInput>();
// for (AdvancedMachineInput stack : (Set<AdvancedMachineInput>) Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().keySet()) {
// ItemStackOutput recipe = (ItemStackOutput) Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().get(stack);
// if (recipe.output.isItemEqual((ItemStack)this.stack)) {
// toRemove.add(stack);
// }
// }
// for (AdvancedMachineInput stack : toRemove) {
// Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().remove(stack);
// }
// }
//
// }
//}
@@ -1,90 +1,90 @@
package modtweaker2.mods.mekanism.handlers.v8;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import mekanism.api.infuse.InfuseRegistry;
import mekanism.api.infuse.InfuseType;
import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.InfusionInput;
import mekanism.common.recipe.machines.MetallurgicInfuserRecipe;
import mekanism.common.recipe.outputs.ItemStackOutput;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Infuser")
public class Infuser {
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input, int amount, String infuseType) {
InfuseType type = InfuseRegistry.get(infuseType);
MineTweakerAPI.apply(new Add(new InfuserRecipe(InputHelper.toStack(output), InputHelper.toStack(input), amount, type)));
}
private static class Add extends BaseMapAddition {
public InfuserRecipe recipe;
public Add(InfuserRecipe recipe) {
super("Metallurgic Infuser", Recipe.METALLURGIC_INFUSER.get(), new InfusionInput(recipe.type, recipe.amount, recipe.input), new ItemStackOutput(recipe.output));
this.recipe = recipe;
}
@Override
public void apply() {
RecipeHandler.addMetallurgicInfuserRecipe(recipe.type, recipe.amount, recipe.input, recipe.output);
}
}
private static class InfuserRecipe {
public ItemStack output;
public ItemStack input;
public int amount;
public InfuseType type;
public InfuserRecipe(ItemStack output, ItemStack input, int amount, InfuseType type) {
this.output = output;
this.input = input;
this.amount = amount;
this.type = type;
}
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(InputHelper.toStack(output)));
}
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack stack) {
super("Metallurgic Infuser", Recipe.METALLURGIC_INFUSER.get(), stack);
}
@SuppressWarnings("unchecked")
@Override
public void apply() {
List<InfusionInput> toRemove = new ArrayList<InfusionInput>();
for (InfusionInput stack : (Set<InfusionInput>) Recipe.METALLURGIC_INFUSER.get().keySet()) {
MetallurgicInfuserRecipe recipe = (MetallurgicInfuserRecipe) Recipe.METALLURGIC_INFUSER.get().get(stack);
if (recipe.getOutput().output.isItemEqual((ItemStack) this.stack)) {
toRemove.add(stack);
}
}
for (InfusionInput stack : toRemove) {
Recipe.METALLURGIC_INFUSER.get().remove(stack);
}
}
}
}
//package modtweaker2.mods.mekanism.handlers.v8;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Set;
//
//import mekanism.api.infuse.InfuseRegistry;
//import mekanism.api.infuse.InfuseType;
//import mekanism.common.recipe.RecipeHandler;
//import mekanism.common.recipe.RecipeHandler.Recipe;
//import mekanism.common.recipe.inputs.InfusionInput;
//import mekanism.common.recipe.machines.MetallurgicInfuserRecipe;
//import mekanism.common.recipe.outputs.ItemStackOutput;
//import minetweaker.MineTweakerAPI;
//import minetweaker.api.item.IItemStack;
//import modtweaker2.helpers.InputHelper;
//import modtweaker2.utils.BaseMapAddition;
//import modtweaker2.utils.BaseMapRemoval;
//import net.minecraft.item.ItemStack;
//import stanhebben.zenscript.annotations.ZenClass;
//import stanhebben.zenscript.annotations.ZenMethod;
//
//@ZenClass("mods.mekanism.Infuser")
//public class Infuser {
//
// @ZenMethod
// public static void addRecipe(IItemStack output, IItemStack input, int amount, String infuseType) {
// InfuseType type = InfuseRegistry.get(infuseType);
// MineTweakerAPI.apply(new Add(new InfuserRecipe(InputHelper.toStack(output), InputHelper.toStack(input), amount, type)));
// }
//
// private static class Add extends BaseMapAddition {
//
// public InfuserRecipe recipe;
//
// public Add(InfuserRecipe recipe) {
// super("Metallurgic Infuser", Recipe.METALLURGIC_INFUSER.get(), new InfusionInput(recipe.type, recipe.amount, recipe.input), new ItemStackOutput(recipe.output));
// this.recipe = recipe;
// }
//
// @Override
// public void apply() {
// RecipeHandler.addMetallurgicInfuserRecipe(recipe.type, recipe.amount, recipe.input, recipe.output);
//
// }
// }
//
// private static class InfuserRecipe {
// public ItemStack output;
// public ItemStack input;
// public int amount;
// public InfuseType type;
//
// public InfuserRecipe(ItemStack output, ItemStack input, int amount, InfuseType type) {
// this.output = output;
// this.input = input;
// this.amount = amount;
// this.type = type;
// }
//
// }
//
// @ZenMethod
// public static void removeRecipe(IItemStack output) {
// MineTweakerAPI.apply(new Remove(InputHelper.toStack(output)));
// }
//
// private static class Remove extends BaseMapRemoval {
//
// public Remove(ItemStack stack) {
// super("Metallurgic Infuser", Recipe.METALLURGIC_INFUSER.get(), stack);
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public void apply() {
// List<InfusionInput> toRemove = new ArrayList<InfusionInput>();
// for (InfusionInput stack : (Set<InfusionInput>) Recipe.METALLURGIC_INFUSER.get().keySet()) {
// MetallurgicInfuserRecipe recipe = (MetallurgicInfuserRecipe) Recipe.METALLURGIC_INFUSER.get().get(stack);
// if (recipe.getOutput().output.isItemEqual((ItemStack) this.stack)) {
// toRemove.add(stack);
// }
// }
// for (InfusionInput stack : toRemove) {
// Recipe.METALLURGIC_INFUSER.get().remove(stack);
// }
// }
//
// }
//}
@@ -1,67 +1,67 @@
package modtweaker2.mods.mekanism.util;
import java.util.Map;
import mekanism.api.gas.GasStack;
import mekanism.common.recipe.inputs.ChemicalPairInput;
import mekanism.common.recipe.inputs.InfusionInput;
import mekanism.common.recipe.machines.PressurizedRecipe;
import mekanism.common.recipe.outputs.ChanceOutput;
import mekanism.common.recipe.outputs.ChemicalPairOutput;
import mekanism.common.recipe.outputs.PressurizedOutput;
import modtweaker2.mods.mekanism.Mekanism;
import modtweaker2.utils.BaseMapAddition;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
public class AddMekanismRecipe extends BaseMapAddition {
public AddMekanismRecipe(String str, Map map, Object key, Object recipe) {
super(str.toLowerCase(), map, key, recipe);
}
@Override
public String describe() {
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 ChemicalPairInput)
return "Adding " + description + " Recipe for : " + ((ChemicalPairInput) 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 PressurizedRecipe)
return "Adding " + description + " Recipe for : " + ((PressurizedRecipe) recipe).getOutput().getItemOutput().getDisplayName();
else if (recipe instanceof InfusionInput)
return "Adding " + description + " Recipe for : " + ((InfusionInput) recipe).inputStack.getDisplayName();
else
return super.getRecipeInfo();
}
return "";
}
@Override
public String describeUndo() {
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 ChemicalPairOutput)
return "Removing " + description + " Recipe for : " + ((ChemicalPairOutput) 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 PressurizedOutput)
return "Removing " + description + " Recipe for : " + ((PressurizedOutput) recipe).getItemOutput().getDisplayName();
else if (recipe instanceof InfusionInput)
return "Removing " + description + " Recipe for : " + ((InfusionInput) recipe).inputStack.getDisplayName();
else
return super.getRecipeInfo();
}
return "";
}
}
//package modtweaker2.mods.mekanism.util;
//
//import java.util.Map;
//
//import mekanism.api.gas.GasStack;
//import mekanism.common.recipe.inputs.ChemicalPairInput;
//import mekanism.common.recipe.inputs.InfusionInput;
//import mekanism.common.recipe.machines.PressurizedRecipe;
//import mekanism.common.recipe.outputs.ChanceOutput;
//import mekanism.common.recipe.outputs.ChemicalPairOutput;
//import mekanism.common.recipe.outputs.PressurizedOutput;
//import modtweaker2.mods.mekanism.Mekanism;
//import modtweaker2.utils.BaseMapAddition;
//import net.minecraft.item.ItemStack;
//import net.minecraftforge.fluids.FluidStack;
//
//public class AddMekanismRecipe extends BaseMapAddition {
// public AddMekanismRecipe(String str, Map map, Object key, Object recipe) {
// super(str.toLowerCase(), map, key, recipe);
// }
//
// @Override
// public String describe() {
// 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 ChemicalPairInput)
// return "Adding " + description + " Recipe for : " + ((ChemicalPairInput) 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 PressurizedRecipe)
// return "Adding " + description + " Recipe for : " + ((PressurizedRecipe) recipe).getOutput().getItemOutput().getDisplayName();
// else if (recipe instanceof InfusionInput)
// return "Adding " + description + " Recipe for : " + ((InfusionInput) recipe).inputStack.getDisplayName();
// else
// return super.getRecipeInfo();
// }
// return "";
// }
//
// @Override
// public String describeUndo() {
// 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 ChemicalPairOutput)
// return "Removing " + description + " Recipe for : " + ((ChemicalPairOutput) 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 PressurizedOutput)
// return "Removing " + description + " Recipe for : " + ((PressurizedOutput) recipe).getItemOutput().getDisplayName();
// else if (recipe instanceof InfusionInput)
// return "Removing " + description + " Recipe for : " + ((InfusionInput) recipe).inputStack.getDisplayName();
// else
// return super.getRecipeInfo();
// }
// return "";
// }
//}
@@ -1,150 +1,150 @@
package modtweaker2.mods.mekanism.util;
import static modtweaker2.helpers.StackHelper.areEqual;
import java.util.Iterator;
import java.util.Map;
import mekanism.api.gas.GasStack;
import mekanism.common.recipe.inputs.InfusionInput;
import mekanism.common.recipe.inputs.PressurizedInput;
import mekanism.common.recipe.machines.PressurizedRecipe;
import mekanism.common.recipe.outputs.ChanceOutput;
import mekanism.common.recipe.outputs.ChemicalPairOutput;
import mekanism.common.recipe.outputs.PressurizedOutput;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
public class RemoveMekanismRecipe extends BaseMapRemoval {
private Object tmp;
public RemoveMekanismRecipe(String string, Map map, Object key) {
super(string.toLowerCase().replace('_', ' '), map, key, null);
this.tmp = key;
}
@Override
public void apply() {
try {
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry) it.next();
if (pairs != null) {
Object value = pairs.getValue();
if (value != null && tmp != null) {
if (tmp instanceof ItemStack && value instanceof ItemStack) {
if (areEqual(((ItemStack) tmp), (ItemStack) value)) {
key = pairs.getKey();
break;
}
}
if (tmp instanceof FluidStack && value instanceof FluidStack) {
if (((FluidStack) tmp).isFluidEqual((FluidStack) value)) {
key = pairs.getKey();
break;
}
}
if (tmp instanceof GasStack && value instanceof GasStack) {
if (((GasStack) tmp).isGasEqual((GasStack) value)) {
key = pairs.getKey();
break;
}
}
if (tmp instanceof ItemStack && value instanceof InfusionInput) {
if (areEqual(((ItemStack) tmp), ((InfusionInput) value).inputStack)) {
key = pairs.getKey();
break;
}
}
if (tmp instanceof ChemicalPairOutput && value instanceof ChemicalPairOutput) {
ChemicalPairOutput par1 = (ChemicalPairOutput) tmp;
ChemicalPairOutput par2 = (ChemicalPairOutput) value;
if (par1.leftGas.isGasEqual(par2.leftGas) && par1.rightGas.isGasEqual(par2.rightGas)) {
key = pairs.getKey();
break;
}
}
if (tmp instanceof ChanceOutput && value instanceof ChanceOutput) {
ChanceOutput par1 = (ChanceOutput) tmp;
ChanceOutput par2 = (ChanceOutput) value;
if (areEqual(par1.primaryOutput, par2.primaryOutput)) {
if (par1.secondaryOutput == null || (par1.secondaryOutput != null && par2.secondaryOutput != null && areEqual(par1.secondaryOutput, par2.secondaryOutput))) {
key = pairs.getKey();
break;
}
}
}
if (tmp instanceof PressurizedOutput && value instanceof PressurizedRecipe) {
PressurizedOutput par1 = (PressurizedOutput) tmp;
PressurizedOutput par2 = ((PressurizedRecipe) value).recipeOutput;
if (areEqual(par1.getItemOutput(), (par2.getItemOutput()))) {
if (par1.getGasOutput().isGasEqual(par2.getGasOutput())) {
key = pairs.getKey();
break;
}
}
}
}
it.remove();
}
}
recipe = map.get(key);
} catch (Exception e) {
e.printStackTrace();
}
map.remove(key);
}
@Override
public String describe() {
if (tmp instanceof ItemStack)
return "Removing " + description + " Recipe for : " + ((ItemStack) tmp).getDisplayName();
else if (tmp instanceof FluidStack)
return "Removing " + description + " Recipe for : " + ((FluidStack) tmp).getFluid().getLocalizedName();
else if (tmp instanceof ChemicalPairOutput)
return "Removing " + description + " Recipe for : " + ((ChemicalPairOutput) tmp).leftGas.getGas().getLocalizedName();
else if (tmp instanceof ChanceOutput)
return "Removing " + description + " Recipe for : " + ((ChanceOutput) tmp).primaryOutput.getDisplayName();
else if (tmp instanceof GasStack)
return "Removing " + description + " Recipe for : " + ((GasStack) tmp).getGas().getLocalizedName();
else if (tmp instanceof PressurizedInput)
return "Removing " + description + " Recipe for : " + ((PressurizedInput) tmp).getSolid().getDisplayName();
else if (tmp instanceof InfusionInput)
return "Removing " + description + " Recipe for : " + ((InfusionInput) tmp).inputStack.getDisplayName();
else
return super.getRecipeInfo();
}
@Override
public String describeUndo() {
if (tmp instanceof ItemStack)
return "Restoring " + description + " Recipe for : " + ((ItemStack) tmp).getDisplayName();
else if (tmp instanceof FluidStack)
return "Restoring " + description + " Recipe for : " + ((FluidStack) tmp).getFluid().getLocalizedName();
else if (tmp instanceof ChemicalPairOutput)
return "Restoring " + description + " Recipe for : " + ((ChemicalPairOutput) tmp).leftGas.getGas().getLocalizedName();
else if (tmp instanceof ChanceOutput)
return "Restoring " + description + " Recipe for : " + ((ChanceOutput) tmp).primaryOutput.getDisplayName();
else if (tmp instanceof GasStack)
return "Restoring " + description + " Recipe for : " + ((GasStack) tmp).getGas().getLocalizedName();
else if (tmp instanceof PressurizedInput)
return "Restoring " + description + " Recipe for : " + ((PressurizedInput) tmp).getSolid().getDisplayName();
else if (tmp instanceof InfusionInput)
return "Restoring " + description + " Recipe for : " + ((InfusionInput) tmp).inputStack.getDisplayName();
else
return super.getRecipeInfo();
}
}
//package modtweaker2.mods.mekanism.util;
//
//import static modtweaker2.helpers.StackHelper.areEqual;
//
//import java.util.Iterator;
//import java.util.Map;
//
//import mekanism.api.gas.GasStack;
//import mekanism.common.recipe.inputs.InfusionInput;
//import mekanism.common.recipe.inputs.PressurizedInput;
//import mekanism.common.recipe.machines.PressurizedRecipe;
//import mekanism.common.recipe.outputs.ChanceOutput;
//import mekanism.common.recipe.outputs.ChemicalPairOutput;
//import mekanism.common.recipe.outputs.PressurizedOutput;
//import modtweaker2.utils.BaseMapRemoval;
//import net.minecraft.item.ItemStack;
//import net.minecraftforge.fluids.FluidStack;
//
//public class RemoveMekanismRecipe extends BaseMapRemoval {
// private Object tmp;
//
// public RemoveMekanismRecipe(String string, Map map, Object key) {
// super(string.toLowerCase().replace('_', ' '), map, key, null);
// this.tmp = key;
// }
//
// @Override
// public void apply() {
// try {
// Iterator it = map.entrySet().iterator();
//
// while (it.hasNext()) {
// Map.Entry pairs = (Map.Entry) it.next();
// if (pairs != null) {
// Object value = pairs.getValue();
// if (value != null && tmp != null) {
// if (tmp instanceof ItemStack && value instanceof ItemStack) {
// if (areEqual(((ItemStack) tmp), (ItemStack) value)) {
// key = pairs.getKey();
// break;
// }
// }
//
// if (tmp instanceof FluidStack && value instanceof FluidStack) {
// if (((FluidStack) tmp).isFluidEqual((FluidStack) value)) {
// key = pairs.getKey();
// break;
// }
// }
//
// if (tmp instanceof GasStack && value instanceof GasStack) {
// if (((GasStack) tmp).isGasEqual((GasStack) value)) {
// key = pairs.getKey();
// break;
// }
// }
//
// if (tmp instanceof ItemStack && value instanceof InfusionInput) {
// if (areEqual(((ItemStack) tmp), ((InfusionInput) value).inputStack)) {
// key = pairs.getKey();
// break;
// }
// }
//
// if (tmp instanceof ChemicalPairOutput && value instanceof ChemicalPairOutput) {
// ChemicalPairOutput par1 = (ChemicalPairOutput) tmp;
// ChemicalPairOutput par2 = (ChemicalPairOutput) value;
// if (par1.leftGas.isGasEqual(par2.leftGas) && par1.rightGas.isGasEqual(par2.rightGas)) {
// key = pairs.getKey();
// break;
// }
// }
//
// if (tmp instanceof ChanceOutput && value instanceof ChanceOutput) {
// ChanceOutput par1 = (ChanceOutput) tmp;
// ChanceOutput par2 = (ChanceOutput) value;
// if (areEqual(par1.primaryOutput, par2.primaryOutput)) {
// if (par1.secondaryOutput == null || (par1.secondaryOutput != null && par2.secondaryOutput != null && areEqual(par1.secondaryOutput, par2.secondaryOutput))) {
// key = pairs.getKey();
// break;
// }
// }
// }
//
// if (tmp instanceof PressurizedOutput && value instanceof PressurizedRecipe) {
// PressurizedOutput par1 = (PressurizedOutput) tmp;
// PressurizedOutput par2 = ((PressurizedRecipe) value).recipeOutput;
// if (areEqual(par1.getItemOutput(), (par2.getItemOutput()))) {
// if (par1.getGasOutput().isGasEqual(par2.getGasOutput())) {
// key = pairs.getKey();
// break;
//
// }
// }
// }
// }
//
// it.remove();
// }
// }
//
// recipe = map.get(key);
//
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// map.remove(key);
// }
//
// @Override
// public String describe() {
// if (tmp instanceof ItemStack)
// return "Removing " + description + " Recipe for : " + ((ItemStack) tmp).getDisplayName();
// else if (tmp instanceof FluidStack)
// return "Removing " + description + " Recipe for : " + ((FluidStack) tmp).getFluid().getLocalizedName();
// else if (tmp instanceof ChemicalPairOutput)
// return "Removing " + description + " Recipe for : " + ((ChemicalPairOutput) tmp).leftGas.getGas().getLocalizedName();
// else if (tmp instanceof ChanceOutput)
// return "Removing " + description + " Recipe for : " + ((ChanceOutput) tmp).primaryOutput.getDisplayName();
// else if (tmp instanceof GasStack)
// return "Removing " + description + " Recipe for : " + ((GasStack) tmp).getGas().getLocalizedName();
// else if (tmp instanceof PressurizedInput)
// return "Removing " + description + " Recipe for : " + ((PressurizedInput) tmp).getSolid().getDisplayName();
// else if (tmp instanceof InfusionInput)
// return "Removing " + description + " Recipe for : " + ((InfusionInput) tmp).inputStack.getDisplayName();
// else
// return super.getRecipeInfo();
// }
//
// @Override
// public String describeUndo() {
// if (tmp instanceof ItemStack)
// return "Restoring " + description + " Recipe for : " + ((ItemStack) tmp).getDisplayName();
// else if (tmp instanceof FluidStack)
// return "Restoring " + description + " Recipe for : " + ((FluidStack) tmp).getFluid().getLocalizedName();
// else if (tmp instanceof ChemicalPairOutput)
// return "Restoring " + description + " Recipe for : " + ((ChemicalPairOutput) tmp).leftGas.getGas().getLocalizedName();
// else if (tmp instanceof ChanceOutput)
// return "Restoring " + description + " Recipe for : " + ((ChanceOutput) tmp).primaryOutput.getDisplayName();
// else if (tmp instanceof GasStack)
// return "Restoring " + description + " Recipe for : " + ((GasStack) tmp).getGas().getLocalizedName();
// else if (tmp instanceof PressurizedInput)
// return "Restoring " + description + " Recipe for : " + ((PressurizedInput) tmp).getSolid().getDisplayName();
// else if (tmp instanceof InfusionInput)
// return "Restoring " + description + " Recipe for : " + ((InfusionInput) tmp).inputStack.getDisplayName();
// else
// return super.getRecipeInfo();
// }
//}
@@ -1,13 +1,19 @@
package modtweaker2.mods.metallurgy.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.mods.metallurgy.MetallurgyHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@@ -15,52 +21,50 @@ import com.teammetallurgy.metallurgy.recipes.AlloyerRecipes.AlloyRecipe;
@ZenClass("mods.metallurgy.Alloyer")
public class Alloyer {
//Adding a Metallurgy Alloyer recipe
public static final String name = "Metallurgy Alloyer";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack first, IItemStack base, IItemStack result) {
MineTweakerAPI.apply(new Add(MetallurgyHelper.getAlloyRecipe(toStack(first), toStack(base), toStack(result))));
}
//Passes the list to the base list implementation, and adds the recipe
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<AlloyRecipe> {
public Add(AlloyRecipe recipe) {
super("Metallurgy Alloyer", MetallurgyHelper.alloyerRecipes, recipe);
super(Alloyer.name, MetallurgyHelper.alloyerRecipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((AlloyRecipe) recipe).getCraftingResult().getDisplayName();
public String getRecipeInfo(AlloyRecipe recipe) {
return InputHelper.getStackDescription(recipe.getCraftingResult());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a Metallurgy Alloyer recipe
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
public static void removeRecipe(IIngredient output) {
List<AlloyRecipe> recipes = new LinkedList<AlloyRecipe>();
for (AlloyRecipe r : MetallurgyHelper.alloyerRecipes) {
if (r != null && r.getCraftingResult() != null && matches(output, toIItemStack(r.getCraftingResult()))) {
recipes.add(r);
}
}
MineTweakerAPI.apply(new Remove(recipes));
}
//Removes a recipe, apply is never the same for anything, so will always need to override it
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Metallurgy Alloyer", MetallurgyHelper.alloyerRecipes, stack);
}
//Loops through the registry, to find the item that matches, saves that recipe then removes it
@Override
public void apply() {
for (AlloyRecipe r : MetallurgyHelper.alloyerRecipes) {
if (r.getCraftingResult() != null && areEqual(r.getCraftingResult(), stack)) {
recipes.add(r);
}
}
super.apply();
private static class Remove extends BaseListRemoval<AlloyRecipe> {
public Remove(List<AlloyRecipe> recipes) {
super(Alloyer.name, MetallurgyHelper.alloyerRecipes, recipes);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(AlloyRecipe recipe) {
return InputHelper.getStackDescription(recipe.getCraftingResult());
}
}
}
@@ -2,8 +2,12 @@ package modtweaker2.mods.metallurgy.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import java.util.Map.Entry;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.mods.metallurgy.MetallurgyHelper;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
@@ -19,24 +23,34 @@ public class Crusher {
MineTweakerAPI.apply(new Add(toStack(input), toStack(output)));
}
private static class Add extends BaseMapAddition {
private static class Add extends BaseMapAddition<String, ItemStack> {
private final ItemStack stack;
public Add(ItemStack input, ItemStack output) {
super("Metallurgy Crusher", MetallurgyHelper.crusherMetaList, MetallurgyHelper.getCrusherKey(input), output);
super("Metallurgy Crusher", MetallurgyHelper.crusherMetaList);
this.stack = input;
recipes.put(MetallurgyHelper.getCrusherKey(input), output);
}
@Override
public void apply() {
super.apply();
addToInput(stack, (ItemStack) recipe);
for(Entry<String, ItemStack> recipe : successful.entrySet()) {
addToInput(stack, recipe.getValue());
}
}
@Override
public void undo() {
super.undo();
removeFromInput(stack, (ItemStack) recipe);
for(Entry<String, ItemStack> recipe : successful.entrySet()) {
removeFromInput(stack, recipe.getValue());
}
}
@Override
protected String getRecipeInfo(Entry<String, ItemStack> recipe) {
return InputHelper.getStackDescription(recipe.getValue());
}
}
@@ -48,26 +62,35 @@ public class Crusher {
MineTweakerAPI.apply(new Remove(toStack(input)));
}
private static class Remove extends BaseMapRemoval {
private static class Remove extends BaseMapRemoval<String, ItemStack> {
private ItemStack stack;
public Remove(ItemStack stack) {
super("Metallurgy Crusher", MetallurgyHelper.crusherMetaList, MetallurgyHelper.getCrusherKey(stack), stack);
}
@Override
public String getRecipeInfo() {
return ((ItemStack) stack).getDisplayName();
super("Metallurgy Crusher", MetallurgyHelper.crusherMetaList);
map.put(MetallurgyHelper.getCrusherKey(stack), MetallurgyHelper.crusherMetaList.get(MetallurgyHelper.getCrusherKey(stack)));
this.stack = stack;
}
@Override
public void apply() {
super.apply();
removeFromInput(((ItemStack) stack), (ItemStack) recipe);
for(Entry<String, ItemStack> recipe : successful.entrySet()) {
removeFromInput(stack, recipe.getValue());
}
}
@Override
public void undo() {
super.undo();
addToInput(((ItemStack) stack), (ItemStack) recipe);
for(Entry<String, ItemStack> recipe : successful.entrySet()) {
addToInput(stack, recipe.getValue());
}
}
@Override
protected String getRecipeInfo(Entry<String, ItemStack> recipe) {
return InputHelper.getStackDescription(recipe.getValue());
}
}
@@ -1,21 +1,28 @@
package modtweaker2.mods.pneumaticcraft.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import pneumaticCraft.api.recipe.AssemblyRecipe;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.pneumaticcraft.Assembly")
public class Assembly {
public static final String name = "PneumaticCraft Assembly";
@ZenMethod
public static void addDrillRecipe(IItemStack input, IItemStack output) {
MineTweakerAPI.apply(new Add(new AssemblyRecipe(toStack(input), toStack(output)), AssemblyRecipe.drillRecipes));
@@ -31,53 +38,59 @@ public class Assembly {
MineTweakerAPI.apply(new Add(new AssemblyRecipe(toStack(input), toStack(output)), AssemblyRecipe.drillLaserRecipes));
}
private static class Add extends BaseListAddition {
public Add(AssemblyRecipe recipe, List list) {
super("Pneumaticraft Assembly", list, recipe);
private static class Add extends BaseListAddition<AssemblyRecipe> {
public Add(AssemblyRecipe recipe, List<AssemblyRecipe> list) {
super(Assembly.name, list);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((AssemblyRecipe) recipe).getOutput().getDisplayName();
public String getRecipeInfo(AssemblyRecipe recipe) {
return InputHelper.getStackDescription(recipe.getOutput());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeDrillRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output), AssemblyRecipe.drillRecipes));
public static void removeDrillRecipe(IIngredient output) {
removeRecipe(AssemblyRecipe.drillRecipes, output);
}
@ZenMethod
public static void removeLaserRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output), AssemblyRecipe.laserRecipes));
public static void removeLaserRecipe(IIngredient output) {
removeRecipe(AssemblyRecipe.laserRecipes, output);
}
@ZenMethod
public static void removeLaserDrillRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output), AssemblyRecipe.drillLaserRecipes));
public static void removeLaserDrillRecipe(IIngredient output) {
removeRecipe(AssemblyRecipe.drillLaserRecipes, output);
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack, List list) {
super("Pneumaticraft Assembly", list, stack);
}
@Override
public void apply() {
for (AssemblyRecipe r : (List<AssemblyRecipe>) list) {
if (r.getOutput() != null && areEqual(r.getOutput(), stack)) {
recipes.add(r);
}
public static void removeRecipe(List<AssemblyRecipe> list, IIngredient output) {
List<AssemblyRecipe> recipes = new LinkedList<AssemblyRecipe>();
for (AssemblyRecipe r : list) {
if (r.getOutput() != null && matches(output, toIItemStack(r.getOutput()))) {
recipes.add(r);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(list, recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Assembly.name, output.toString()));
}
}
super.apply();
private static class Remove extends BaseListRemoval<AssemblyRecipe> {
public Remove(List<AssemblyRecipe> list, List<AssemblyRecipe> recipes) {
super(Assembly.name, list, recipes);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(AssemblyRecipe recipe) {
return InputHelper.getStackDescription(recipe.getOutput());
}
}
}
@@ -1,9 +1,16 @@
package modtweaker2.mods.pneumaticcraft.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStacks;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
@@ -13,48 +20,41 @@ import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.pneumaticcraft.Pressure")
public class Pressure {
public static final String name = "PneumaticCraft Pressure Chamber";
@ZenMethod
public static void addRecipe(IItemStack[] input, double pressure, IItemStack[] output, boolean asBlock) {
MineTweakerAPI.apply(new Add(new PressureChamberRecipe(toStacks(input), (float) pressure, toStacks(output), asBlock)));
}
private static class Add extends BaseListAddition {
private ItemStack stack;
private static class Add extends BaseListAddition<PressureChamberRecipe> {
public Add(PressureChamberRecipe recipe) {
super("Pneumaticraft Pressure Chamber", PressureChamberRecipe.chamberRecipes, recipe);
this.stack = recipe.output[0];
super(Pressure.name, PressureChamberRecipe.chamberRecipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(PressureChamberRecipe recipe) {
return InputHelper.getStackDescription(recipe.output[0]);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack[] output) {
MineTweakerAPI.apply(new Remove(toStacks(output)));
}
private static class Remove extends BaseListRemoval {
private final ItemStack[] stacks;
public Remove(ItemStack[] stacks) {
super("Pneumaticraft Pressure Chamber", PressureChamberRecipe.chamberRecipes, stacks[0]);
this.stacks = stacks;
}
@Override
public void apply() {
for (PressureChamberRecipe r : PressureChamberRecipe.chamberRecipes) {
public static void removeRecipe(IIngredient[] output) {
List<PressureChamberRecipe> recipes = new LinkedList<PressureChamberRecipe>();
for (PressureChamberRecipe r : PressureChamberRecipe.chamberRecipes) {
if(r != null) {
boolean matches = true;
for (int i = 0; i < stacks.length; i++) {
if (!areEqual(stacks[i], r.output[i])) { // possible IndexOutOfBoundsException on r.output[i]
matches = false;
break;
for (IIngredient ingredient : output) {
for(ItemStack stack : r.output) {
if (!matches(ingredient, toIItemStack(stack))) {
matches = false;
break;
}
}
}
@@ -62,12 +62,19 @@ public class Pressure {
recipes.add(r);
}
}
super.apply();
}
MineTweakerAPI.apply(new Remove(recipes));
}
private static class Remove extends BaseListRemoval<PressureChamberRecipe> {
public Remove(List<PressureChamberRecipe> recipes) {
super(Pressure.name, PressureChamberRecipe.chamberRecipes, recipes);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(PressureChamberRecipe recipe) {
return InputHelper.getStackDescription(recipe.output[0]);
}
}
}
@@ -1,62 +1,71 @@
package modtweaker2.mods.railcraft.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import mods.railcraft.api.crafting.IBlastFurnaceRecipe;
import mods.railcraft.api.crafting.RailcraftCraftingManager;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.railcraft.RailcraftHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.railcraft.BlastFurnace")
public class BlastFurnace {
public static final String name = "Railcraft Blast Furnace";
@ZenMethod
public static void addRecipe(IItemStack input, boolean matchDamage, boolean matchNBT, int cookTime, IItemStack output) {
MineTweakerAPI.apply(new Add(RailcraftHelper.getBlastFurnaceRecipe(toStack(input), matchDamage, matchNBT, cookTime, toStack(output))));
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<IBlastFurnaceRecipe> {
public Add(IBlastFurnaceRecipe recipe) {
super("Blast Furnace", RailcraftHelper.furnace, recipe);
super(BlastFurnace.name, (List<IBlastFurnaceRecipe>)RailcraftHelper.furnace);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((IBlastFurnaceRecipe) recipe).getOutput().getDisplayName();
public String getRecipeInfo(IBlastFurnaceRecipe recipe) {
return InputHelper.getStackDescription(recipe.getOutput());
}
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
public static void removeRecipe(IIngredient output) {
List<IBlastFurnaceRecipe> recipes = new LinkedList<IBlastFurnaceRecipe>();
for (IBlastFurnaceRecipe r : RailcraftHelper.furnace) {
if (r != null && r.getOutput() != null && matches(output, toIItemStack(r.getOutput()))) {
recipes.add(r);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", BlastFurnace.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Blast Furnace", RailcraftHelper.furnace, stack);
private static class Remove extends BaseListRemoval<IBlastFurnaceRecipe> {
public Remove(List<IBlastFurnaceRecipe> recipes) {
super(BlastFurnace.name, (List<IBlastFurnaceRecipe>)RailcraftHelper.furnace, recipes);
}
@Override
public void apply() {
for (IBlastFurnaceRecipe r : RailcraftHelper.furnace) {
if (r.getOutput() != null && stack.isItemEqual(r.getOutput())) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
@Override
public String getRecipeInfo(IBlastFurnaceRecipe recipe) {
return InputHelper.getStackDescription(recipe.getOutput());
}
}
}
@@ -1,18 +1,22 @@
package modtweaker2.mods.railcraft.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.lang.reflect.Field;
import java.util.LinkedList;
import java.util.List;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import mods.railcraft.api.crafting.ICokeOvenRecipe;
import mods.railcraft.common.util.crafting.CokeOvenCraftingManager;
import mods.railcraft.common.util.crafting.CokeOvenCraftingManager.CokeOvenRecipe;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.railcraft.RailcraftHelper;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
@@ -22,6 +26,9 @@ import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.railcraft.CokeOven")
public class CokeOven {
public static final String name = "Railcraft Coke Oven";
@ZenMethod
public static void addRecipe(IItemStack input, boolean matchDamage, boolean matchNBT, IItemStack output, ILiquidStack fluidOutput, int cookTime) {
MineTweakerAPI.apply(new Add(toStack(input), matchDamage, matchNBT, toStack(output), toFluid(fluidOutput), cookTime));
@@ -80,28 +87,30 @@ public class CokeOven {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
public static void removeRecipe(IIngredient output) {
List<ICokeOvenRecipe> recipes = new LinkedList<ICokeOvenRecipe>();
for (ICokeOvenRecipe r : RailcraftHelper.oven) {
if (r.getOutput() != null && matches(output, toIItemStack(r.getOutput()))) {
recipes.add(r);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", CokeOven.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Coke Oven", RailcraftHelper.oven, stack);
private static class Remove extends BaseListRemoval<ICokeOvenRecipe> {
public Remove(List<ICokeOvenRecipe> recipes) {
super("Coke Oven", (List<ICokeOvenRecipe>)RailcraftHelper.oven, recipes);
}
@Override
public void apply() {
for (ICokeOvenRecipe r : RailcraftHelper.oven) {
if (r.getOutput() != null && r.getOutput().getItem().equals(stack)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(ICokeOvenRecipe recipe) {
return InputHelper.getStackDescription(recipe.getOutput());
}
}
}
@@ -1,63 +1,79 @@
package modtweaker2.mods.railcraft.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import mods.railcraft.api.crafting.IRockCrusherRecipe;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.railcraft.RailcraftHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.railcraft.RockCrusher")
public class RockCrusher {
public static final String name = "Railcraft Rock Crusher";
@ZenMethod
public static void addRecipe(IItemStack input, boolean matchDamage, boolean matchNBT, IItemStack[] output, double[] chances) {
IRockCrusherRecipe recipe = RailcraftHelper.getRockCrusherRecipe(toStack(input), matchDamage, matchNBT);
for (int i = 0; i < output.length; i++)
for (int i = 0; i < output.length; i++) {
recipe.addOutput(toStack(output[i]), (float) chances[i]);
}
MineTweakerAPI.apply(new Add(recipe));
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<IRockCrusherRecipe> {
public Add(IRockCrusherRecipe recipe) {
super("Rock Crusher", RailcraftHelper.crusher, recipe);
super(RockCrusher.name, (List<IRockCrusherRecipe>)RailcraftHelper.crusher);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((IRockCrusherRecipe) recipe).getInput().getDisplayName();
public String getRecipeInfo(IRockCrusherRecipe recipe) {
return InputHelper.getStackDescription(recipe.getInput());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input)));
public static void removeRecipe(IIngredient input) {
List<IRockCrusherRecipe> recipes = new LinkedList<IRockCrusherRecipe>();
for (IRockCrusherRecipe r : RailcraftHelper.crusher) {
if (r.getInput() != null && matches(input, toIItemStack(r.getInput()))) {
recipes.add(r);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", RockCrusher.name, input.toString()));
}
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Rock Crusher", RailcraftHelper.crusher, stack);
private static class Remove extends BaseListRemoval<IRockCrusherRecipe> {
public Remove(List<IRockCrusherRecipe> recipes) {
super("Rock Crusher", (List<IRockCrusherRecipe>)RailcraftHelper.crusher, recipes);
}
@Override
public void apply() {
for (IRockCrusherRecipe r : RailcraftHelper.crusher) {
if (r.getInput() != null && areEqual(r.getInput(), stack)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(IRockCrusherRecipe recipe) {
return InputHelper.getStackDescription(recipe.getInput());
}
}
}
@@ -3,15 +3,17 @@ package modtweaker2.mods.railcraft.handlers;
import static modtweaker2.helpers.InputHelper.toObjects;
import static modtweaker2.helpers.InputHelper.toShapedObjects;
import static modtweaker2.helpers.InputHelper.toStack;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import mods.railcraft.api.crafting.RailcraftCraftingManager;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.railcraft.RailcraftHelper;
import modtweaker2.utils.BaseCraftingAddition;
import modtweaker2.utils.BaseCraftingRemoval;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import stanhebben.zenscript.annotations.ZenClass;
@@ -19,42 +21,42 @@ import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.railcraft.Rolling")
public class RollingMachine {
public static final String name = "Railcraft Rolling Machine";
@ZenMethod
public static void addShaped(IItemStack output, IIngredient[][] ingredients) {
MineTweakerAPI.apply(new Add(false, toStack(output), toShapedObjects(ingredients)));
MineTweakerAPI.apply(new Add(new ShapedOreRecipe(toStack(output), toShapedObjects(ingredients))));
}
@ZenMethod
public static void addShapeless(IItemStack output, IIngredient[] ingredients) {
MineTweakerAPI.apply(new Add(true, toStack(output), toObjects(ingredients)));
MineTweakerAPI.apply(new Add(new ShapelessOreRecipe(toStack(output), toObjects(ingredients))));
}
private static class Add extends BaseCraftingAddition {
public Add(boolean shapeless, ItemStack output, Object... recipe) {
super("Rolling Machine", shapeless, RailcraftHelper.rolling, output, recipe);
}
@Override
public void applyShaped() {
RailcraftHelper.rolling.add(new ShapedOreRecipe(output, recipe));
}
@Override
public void applyShapeless() {
RailcraftHelper.rolling.add(new ShapelessOreRecipe(output, recipe));
public Add(IRecipe recipe) {
super(RollingMachine.name, RailcraftHelper.rolling);
recipes.add(recipe);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
public static void removeRecipe(IIngredient ingredient) {
List<IRecipe> recipes = BaseCraftingRemoval.getRecipes(RailcraftHelper.rolling, ingredient);
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipes found for %s. Command ignored!", RollingMachine.name, ingredient.toString()));
}
}
private static class Remove extends BaseCraftingRemoval {
public Remove(ItemStack stack) {
super("Rolling Machine", RailcraftHelper.rolling, stack);
public Remove(List<IRecipe> recipes) {
super(RollingMachine.name, RailcraftHelper.rolling, recipes);
}
}
}
@@ -1,6 +1,7 @@
package modtweaker2.mods.tconstruct;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -9,6 +10,7 @@ import java.util.Map;
import mantle.utils.ItemMetaWrapper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.crafting.AlloyMix;
@@ -16,6 +18,7 @@ import tconstruct.library.crafting.CastingRecipe;
import tconstruct.library.crafting.DryingRackRecipes.DryingRecipe;
import tconstruct.library.crafting.ModifyBuilder;
import tconstruct.library.crafting.PatternBuilder.ItemKey;
import tconstruct.library.crafting.Smeltery;
import tconstruct.library.modifier.ItemModifier;
import tconstruct.library.tools.ToolMaterial;
@@ -27,6 +30,7 @@ public class TConstructHelper {
public static Map<ItemMetaWrapper, FluidStack> smeltingList = null;
public static Map<ItemMetaWrapper, Integer> temperatureList = null;
public static Map<ItemMetaWrapper, ItemStack> renderIndex = null;
public static Map<Fluid, Integer[]> fuelList = null;
public static List<ItemModifier> modifiers = null;
public static List<ItemModifier> modifiers_clone = null;
@@ -44,7 +48,8 @@ public class TConstructHelper {
for (Map.Entry<Integer, ToolMaterial> entry : TConstructRegistry.toolMaterials.entrySet()) {
mappings.put(entry.getValue().materialName, entry.getKey());
}
fuelList = getFuelList();
} catch (Exception e) {}
}
@@ -55,6 +60,20 @@ public class TConstructHelper {
return -1;
} else return mappings.get(material);
}
public static Map<Fluid, Integer[]> getFuelList() {
Smeltery smelteryInstance = tconstruct.library.crafting.Smeltery.instance;
try {
Field smelteryFuels = Smeltery.class.getDeclaredField("smelteryFuels");
smelteryFuels.setAccessible(true);
return (Map<Fluid, Integer[]>)smelteryFuels.get(smelteryInstance);
} catch (Exception e) {
e.printStackTrace();
throw new NullPointerException("Failed to instantiate smeltery fuel map");
}
}
//Returns a Drying Recipe, using reflection as the constructor is not visible
public static DryingRecipe getDryingRecipe(ItemStack input, int time, ItemStack output) {
@@ -1,21 +1,23 @@
package modtweaker2.mods.tconstruct.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toILiquidStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Iterator;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.tconstruct.TConstructHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@@ -23,7 +25,11 @@ import tconstruct.library.crafting.CastingRecipe;
@ZenClass("mods.tconstruct.Casting")
public class Casting {
//Adding a TConstruct Casting recipe
protected static final String name = "TConstruct Casting";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addBasinRecipe(IItemStack output, ILiquidStack metal, @Optional IItemStack cast, @Optional boolean consume, int delay) {
MineTweakerAPI.apply(new Add(new CastingRecipe(toStack(output), toFluid(metal), toStack(cast), consume, delay, null), TConstructHelper.basinCasting));
@@ -35,98 +41,90 @@ public class Casting {
}
//Passes the list to the base list implementation, and adds the recipe
private static class Add extends BaseListAddition {
public Add(CastingRecipe recipe, ArrayList list) {
super("TConstruct Casting", list, recipe);
private static class Add extends BaseListAddition<CastingRecipe> {
public Add(CastingRecipe recipe, ArrayList<CastingRecipe> list) {
super("TConstruct Casting", list);
this.recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((CastingRecipe) recipe).output.getDisplayName();
protected String getRecipeInfo(CastingRecipe recipe) {
return InputHelper.getStackDescription(recipe.output);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a TConstruct Casting recipe
@ZenMethod
public static void removeBasinRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove((toStack(output)), TConstructHelper.basinCasting, RecipeComponent.Output));
}
@ZenMethod
public static void removeTableRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove((toStack(output)), TConstructHelper.tableCasting, RecipeComponent.Output));
public static void removeTableRecipe(IIngredient output) {
removeRecipe(output, TConstructHelper.tableCasting, RecipeComponent.Output);
}
@ZenMethod
public static void removeBasinMaterial(ILiquidStack fluid) {
MineTweakerAPI.apply(new Remove((toFluid(fluid)), TConstructHelper.basinCasting));
public static void removeTableMaterial(IIngredient material) {
removeRecipe(material, TConstructHelper.tableCasting, RecipeComponent.Material);
}
@ZenMethod
public static void removeTableMaterial(ILiquidStack fluid) {
MineTweakerAPI.apply(new Remove((toFluid(fluid)), TConstructHelper.tableCasting));
public static void removeCastRecipes(IIngredient cast) {
removeRecipe(cast, TConstructHelper.tableCasting, RecipeComponent.Cast);
}
@ZenMethod
public static void removeCastRecipes(IItemStack cast) {
MineTweakerAPI.apply(new Remove((toStack(cast)), TConstructHelper.tableCasting, RecipeComponent.Cast));
public static void removeBasinRecipe(IIngredient output) {
removeRecipe(output, TConstructHelper.basinCasting, RecipeComponent.Output);
}
@ZenMethod
public static void removeBasinMaterial(IIngredient material) {
removeRecipe(material, TConstructHelper.basinCasting, RecipeComponent.Material);
}
// Removes all matching recipes, apply is never the same for anything, so will always need to override it
private static class Remove extends BaseListRemoval {
protected final RecipeComponent component;
public static void removeRecipe(IIngredient ingredient, List<CastingRecipe> list, RecipeComponent component) {
public Remove(ItemStack item, ArrayList list, RecipeComponent component) {
super("TConstruct Casting", list, item);
this.component = component;
}
List<CastingRecipe> recipes = new LinkedList<CastingRecipe>();
public Remove(FluidStack fluid, ArrayList list) {
super("TConstruct Casting", list, fluid);
this.component = RecipeComponent.Material;
}
// Loops through the registry, to find all items that matches, then removes them
@Override
public void apply() {
for (Iterator<CastingRecipe> iterator = ((ArrayList<CastingRecipe>)list).iterator(); iterator.hasNext();) {
CastingRecipe r = iterator.next();
switch(component)
{
for(CastingRecipe recipe : list) {
if(recipe != null) {
switch(component) {
case Cast:
if (r.cast != null && areEqual(r.cast, stack)) {
recipes.add(r);
if(recipe.cast != null && ingredient.contains(toIItemStack(recipe.cast))) {
recipes.add(recipe);
}
break;
case Material:
if (r.castingMetal != null && r.castingMetal.isFluidEqual(fluid)) {
recipes.add(r);
}
break;
case Output:
if (r.output != null && areEqual(r.output, stack)) {
recipes.add(r);
if (recipe.output != null && ingredient.contains(toIItemStack(recipe.output))) {
recipes.add(recipe);
}
break;
case Material:
if (recipe.castingMetal != null && ingredient.contains(toILiquidStack(recipe.castingMetal))) {
// TODO: Currently broken, because MCLiquidStack equals() method always returns false
recipes.add(recipe);
}
break;
}
}
super.apply();
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(list, recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Casting.name, ingredient.toString()));
}
}
// Removes all matching recipes, apply is never the same for anything, so will always need to override it
private static class Remove extends BaseListRemoval<CastingRecipe> {
public Remove(List<CastingRecipe> list, List<CastingRecipe> recipes) {
super(Casting.name, list, recipes);
}
@Override
public String getRecipeInfo() {
if(component == RecipeComponent.Material)
return fluid.getLocalizedName();
else
return stack.getDisplayName();
protected String getRecipeInfo(CastingRecipe recipe) {
return InputHelper.getStackDescription(recipe.output);
}
}
@@ -1,16 +1,19 @@
package modtweaker2.mods.tconstruct.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.tconstruct.TConstructHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import tconstruct.library.crafting.DryingRackRecipes;
@@ -18,21 +21,26 @@ import tconstruct.library.crafting.DryingRackRecipes.DryingRecipe;
@ZenClass("mods.tconstruct.Drying")
public class Drying {
//Adding a TConstruct Drying Rack recipe
protected static final String name = "TConstruct Drying Rack";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output, int time) {
MineTweakerAPI.apply(new Add(TConstructHelper.getDryingRecipe(toStack(input), time, toStack(output))));
}
//Passes the list to the base list implementation, and adds the recipe
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<DryingRecipe> {
public Add(DryingRecipe recipe) {
super("TConstruct Drying Rack", DryingRackRecipes.recipes, recipe);
super(Drying.name, DryingRackRecipes.recipes);
this.recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((DryingRecipe) recipe).result.getDisplayName();
protected String getRecipeInfo(DryingRecipe recipe) {
return InputHelper.getStackDescription(recipe.result);
}
}
@@ -40,30 +48,31 @@ public class Drying {
//Removing a TConstruct Drying Rack recipe
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove((toStack(output))));
public static void removeRecipe(IIngredient ingredient) {
List<DryingRecipe> recipes = new LinkedList<DryingRecipe>();
for (DryingRecipe recipe : DryingRackRecipes.recipes) {
if (recipe != null && recipe.result != null && ingredient.matches(toIItemStack(recipe.result))) {
recipes.add(recipe);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Drying.name, ingredient.toString()));
}
}
//Removes a recipe, apply is never the same for anything, so will always need to override it
private static class Remove extends BaseListRemoval {
public Remove(ItemStack output) {
super("TConstruct Drying Rack", DryingRackRecipes.recipes, output);
}
//Loops through the registry, to find the item that matches, saves that recipe then removes it
@Override
public void apply() {
for (DryingRecipe r : (ArrayList<DryingRecipe>) list) {
if (r.result != null && areEqual(r.result, stack)) {
recipes.add(r);
}
}
super.apply();
private static class Remove extends BaseListRemoval<DryingRecipe> {
public Remove(List<DryingRecipe> list) {
super(Drying.name, DryingRackRecipes.recipes, list);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
protected String getRecipeInfo(DryingRecipe recipe) {
return InputHelper.getStackDescription(recipe.result);
}
}
}
@@ -1,8 +1,10 @@
package modtweaker2.mods.tconstruct.handlers;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.tconstruct.TConstructHelper;
import modtweaker2.utils.BaseListRemoval;
import stanhebben.zenscript.annotations.ZenClass;
@@ -11,28 +13,37 @@ import tconstruct.library.modifier.ItemModifier;
@ZenClass("mods.tconstruct.Modifiers")
public class Modifiers {
protected static final String name = "TConstruct Modifier";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void remove(String mod) {
MineTweakerAPI.apply(new Remove(mod));
List<ItemModifier> recipes = new LinkedList<ItemModifier>();
for (ItemModifier recipe : TConstructHelper.modifiers) {
if (recipe.key.equals(mod)) {
recipes.add(recipe);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Modifiers.name, mod));
}
}
//Searches through the modifiers and removes the first valid entry
private static class Remove extends BaseListRemoval {
private final String check;
public Remove(String check) {
super("Modifier", TConstructHelper.modifiers);
this.check = check;
private static class Remove extends BaseListRemoval<ItemModifier>{
public Remove(List<ItemModifier> recipes) {
super(Modifiers.name, TConstructHelper.modifiers, recipes);
}
@Override
public void apply() {
for (ItemModifier m : (List<ItemModifier>) list) {
if (m.key.equals(check)) {
recipes. add(m);
}
}
super.apply();
protected String getRecipeInfo(ItemModifier recipe) {
return recipe.key;
}
}
}
@@ -3,24 +3,34 @@ package modtweaker2.mods.tconstruct.handlers;
import static modtweaker2.helpers.InputHelper.isABlock;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toFluids;
import static modtweaker2.helpers.InputHelper.toILiquidStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import mantle.utils.ItemMetaWrapper;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.api.oredict.IOreDictEntry;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.tconstruct.TConstructHelper;
import modtweaker2.utils.BaseDescriptionAddition;
import modtweaker2.utils.BaseDescriptionRemoval;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
import modtweaker2.utils.BaseUndoable;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
import stanhebben.zenscript.annotations.Optional;
@@ -30,6 +40,8 @@ import tconstruct.library.crafting.AlloyMix;
@ZenClass("mods.tconstruct.Smeltery")
public class Smeltery {
public static final String nameFuel = "TConstruct Smeltery - Fuel";
/********************************************** TConstruct Alloy Recipes **********************************************/
@@ -40,14 +52,15 @@ public class Smeltery {
}
// Passes the list to the base list implementation, and adds the recipe
private static class AddAlloy extends BaseListAddition {
private static class AddAlloy extends BaseListAddition<AlloyMix> {
public AddAlloy(AlloyMix recipe) {
super("Smeltery - Alloy", TConstructHelper.alloys, recipe);
super("TConstruct Smeltery - Alloy", TConstructHelper.alloys);
this.recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((AlloyMix) recipe).result.getFluid().getName();
protected String getRecipeInfo(AlloyMix recipe) {
return InputHelper.getStackDescription(recipe.result);
}
}
@@ -61,27 +74,21 @@ public class Smeltery {
// Removes a recipe, apply is never the same for anything, so will always
// need to override it
private static class RemoveAlloy extends BaseListRemoval {
private static class RemoveAlloy extends BaseListRemoval<AlloyMix> {
public RemoveAlloy(FluidStack output) {
super("Smeltery - Alloy", TConstructHelper.alloys, output);
super("Smeltery - Alloy", TConstructHelper.alloys);
for (AlloyMix r : TConstructHelper.alloys) {
if (r.result != null && output != null && r.result.getFluid() == output.getFluid()) {
recipes.add(r);
}
}
}
// Loops through the registry, to find the item that matches, saves that
// recipe then removes it
@Override
public void apply() {
for (AlloyMix r : TConstructHelper.alloys) {
if (r.result != null && fluid != null && r.result.getFluid() == fluid.getFluid()) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return fluid.getFluid().getName();
}
@Override
protected String getRecipeInfo(AlloyMix recipe) {
return InputHelper.getStackDescription(recipe.result);
}
}
/********************************************** TConstruct Melting Recipes **********************************************/
@@ -106,7 +113,7 @@ public class Smeltery {
}
// Takes all the variables and saves them in place
private static class AddMelting extends BaseDescriptionAddition {
private static class AddMelting extends BaseUndoable {
private final ItemStack input;
private final Block block;
private final int meta;
@@ -136,14 +143,15 @@ public class Smeltery {
TConstructHelper.temperatureList.remove(in);
TConstructHelper.renderIndex.remove(in);
}
@Override
public String getRecipeInfo() {
return input.getDisplayName();
}
}
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Removing a TConstruct Melting recipe
@ZenMethod
@@ -160,7 +168,7 @@ public class Smeltery {
// Removes a recipe, apply is never the same for anything, so will always
// need to override it
private static class RemoveMelting extends BaseDescriptionRemoval {
private static class RemoveMelting extends BaseUndoable {
private final ItemStack input;
private FluidStack fluid;
private Integer temp;
@@ -197,4 +205,58 @@ public class Smeltery {
return input.getDisplayName();
}
}
/********************************************** TConstruct Fuel Recipes **********************************************/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removFuel(IIngredient input) {
Map<Fluid, Integer[]> recipes = new HashMap<Fluid, Integer[]>();
for(Entry<Fluid, Integer[]> fuel : TConstructHelper.fuelList.entrySet()) {
if(fuel != null && fuel.getKey() != null && matches(input, toILiquidStack(new FluidStack(fuel.getKey(), 1)))) {
recipes.put(fuel.getKey(), fuel.getValue());
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveFuel(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe for %s found. Command ignored!", Smeltery.nameFuel, input.toString()));
}
}
public static class RemoveFuel extends BaseMapRemoval<Fluid, Integer[]> {
public RemoveFuel(Map<Fluid, Integer[]> recipes) {
super(Smeltery.nameFuel, TConstructHelper.fuelList, recipes);
}
@Override
public String getRecipeInfo(Entry<Fluid, Integer[]> recipe) {
return InputHelper.getStackDescription(new FluidStack(recipe.getKey(), 1));
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addFuel(ILiquidStack liquid, int power, int duration) {
Map<Fluid, Integer[]> recipes = new HashMap<Fluid, Integer[]>();
recipes.put(toFluid(liquid).getFluid(), new Integer[] {power, duration});
MineTweakerAPI.apply(new AddFuel(recipes));
}
public static class AddFuel extends BaseMapAddition<Fluid, Integer[]> {
public AddFuel(Map<Fluid, Integer[]> recipes) {
super(Smeltery.nameFuel, TConstructHelper.fuelList, recipes);
}
@Override
public String getRecipeInfo(Entry<Fluid, Integer[]> recipe) {
return InputHelper.getStackDescription(new FluidStack(recipe.getKey(), 1));
}
}
}
@@ -1,8 +1,15 @@
package modtweaker2.mods.tconstruct.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.mods.tconstruct.TConstructHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
@@ -63,51 +70,49 @@ public class TiCTweaks {
}
// Tweaks for setting repair materials
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<ItemKey> {
public Add(ItemKey recipe) {
super("Repair Material", PatternBuilder.instance.materials, recipe);
super("Repair Material", PatternBuilder.instance.materials);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return new ItemStack(((ItemKey) recipe).item, 1, ((ItemKey) recipe).damage).getDisplayName();
protected String getRecipeInfo(ItemKey recipe) {
return InputHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.damage));
}
}
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRepairMaterial(IItemStack output, @Optional String material) {
MineTweakerAPI.apply(new Remove(toStack(output), material));
public static void removeRepairMaterial(IIngredient output, @Optional String material) {
List<ItemKey> recipes = new LinkedList<ItemKey>();
for (ItemKey recipe : PatternBuilder.instance.materials) {
IItemStack clone = toIItemStack(new ItemStack(recipe.item, 1, recipe.damage));
if ((material != null && material.equalsIgnoreCase(recipe.key)) || (material == null)) {
if (output.matches(clone)) {
recipes.add(recipe);
}
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
}
}
// Removes a recipe, apply is never the same for anything, so will always
// need to override it
private static class Remove extends BaseListRemoval {
private final String material;
public Remove(ItemStack stack, String material) {
super("Repair Material", PatternBuilder.instance.materials, stack);
this.material = material;
}
// Loops through the registry, to find the item that matches, saves that
// recipe then removes it
@Override
public void apply() {
for (ItemKey r : PatternBuilder.instance.materials) {
ItemStack clone = new ItemStack(r.item, 1, r.damage);
if ((material != null && material.equalsIgnoreCase(r.key)) || (material == null)) {
if (clone.isItemEqual(stack)) {
recipes.add(r);
}
}
}
super.apply();
private static class Remove extends BaseListRemoval<ItemKey> {
public Remove(List<ItemKey> recipes) {
super("Repair Material", PatternBuilder.instance.materials, recipes);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
protected String getRecipeInfo(ItemKey recipe) {
return InputHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.damage));
}
}
}
@@ -1,14 +1,18 @@
package modtweaker2.mods.tfcraft.handlers;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.InputHelper.toStack;
import static com.bioxx.tfc.api.Crafting.AnvilReq.getReqFromInt;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import net.minecraft.item.ItemStack;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.tfcraft.TFCHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
@@ -21,10 +25,15 @@ import com.bioxx.tfc.api.Crafting.AnvilRecipe;
@ZenClass("mods.tfcraft.Anvil")
public class Anvil {
public static final String nameRegular = "TFC Anvil-Regular";
public static final String nameWeld = "TFC Anvil-Weld";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void add(IItemStack input1, IItemStack input2, String plan, int value, boolean flux, int req, IItemStack output){
MineTweakerAPI.apply(new Add(new AnvilRecipe(toStack(input1), toStack(input2), plan, value, flux, req, toStack(output))));
addRecipe(nameRegular, TFCHelper.anvilRecipes, new AnvilRecipe(toStack(input1), toStack(input2), plan, value, flux, req, toStack(output)));
}
/**
@@ -33,60 +42,63 @@ public class Anvil {
*/
@ZenMethod
public static void addWeld(IItemStack input1, IItemStack input2, int req, IItemStack output){
MineTweakerAPI.apply(new AddWeld(new AnvilRecipe(toStack(input1), toStack(input2), true, getReqFromInt(req), toStack(output))));
addRecipe(nameWeld, TFCHelper.anvilWeldRecipes, new AnvilRecipe(toStack(input1), toStack(input2), true, getReqFromInt(req), toStack(output)));
}
@ZenMethod
public static void remove(IItemStack stack){
MineTweakerAPI.apply(new Remove(toStack(stack)));
}
@ZenMethod
public static void removeWeld(IItemStack stack){
MineTweakerAPI.apply(new RemoveWeld(toStack(stack)));
}
private static class Add extends BaseListAddition{
public Add(AnvilRecipe recipe) {
super("Anvil-Regular", TFCHelper.anvilRecipes, recipe);
}
}
private static class AddWeld extends BaseListAddition{
public AddWeld(AnvilRecipe recipe) {
super("Anvil-Weld", TFCHelper.anvilWeldRecipes, recipe);
}
}
private static class Remove extends BaseListRemoval{
public Remove(ItemStack out){
super("Anvil-Remove-Regular", TFCHelper.anvilRecipes, out);
}
public static void addRecipe(String name, List<AnvilRecipe> list, AnvilRecipe recipe) {
List<AnvilRecipe> recipes = new LinkedList<AnvilRecipe>();
recipes.add(recipe);
MineTweakerAPI.apply(new Add(name, list, recipes));
}
@Override
public void apply() {
for (AnvilRecipe recipe : AnvilManager.getInstance().getRecipeList()){
if (recipe.getCraftingResult() != null && areEqual(recipe.getCraftingResult(), stack)){
recipes.add(recipe);
}
}
super.apply();
private static class Add extends BaseListAddition<AnvilRecipe> {
public Add(String name, List<AnvilRecipe> list, List<AnvilRecipe> recipes) {
super(name, list, recipes);
}
@Override
protected String getRecipeInfo(AnvilRecipe recipe) {
return InputHelper.getStackDescription(recipe.getCraftingResult());
}
}
private static class RemoveWeld extends BaseListRemoval{
public RemoveWeld(ItemStack out){
super("Anvil-Remove-Weld", TFCHelper.anvilWeldRecipes, out);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void remove(IIngredient ingredient) {
removeRecipe(nameRegular, TFCHelper.anvilRecipes, ingredient);
}
@ZenMethod
public static void removeWeld(IIngredient ingredient) {
removeRecipe(nameWeld, TFCHelper.anvilWeldRecipes, ingredient);
}
public static void removeRecipe(String name, List<AnvilRecipe> list, IIngredient ingredient) {
List<AnvilRecipe> recipes = new LinkedList<AnvilRecipe>();
for (AnvilRecipe recipe : AnvilManager.getInstance().getRecipeList()){
if (recipe.getCraftingResult() != null && matches(ingredient, toIItemStack(recipe.getCraftingResult()))) {
recipes.add(recipe);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(name, list, recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipes found for %s. Command ignored.", name, ingredient.toString()));
}
}
private static class Remove extends BaseListRemoval<AnvilRecipe> {
public Remove(String name, List<AnvilRecipe> list, List<AnvilRecipe> recipes){
super(name, list, recipes);
}
@Override
public void apply() {
for (AnvilRecipe recipe : AnvilManager.getInstance().getRecipeList()){
if (recipe.getCraftingResult() != null && recipe.getCraftingResult() == stack){
recipes.add(recipe);
}
}
super.apply();
protected String getRecipeInfo(AnvilRecipe recipe) {
return InputHelper.getStackDescription(recipe.getCraftingResult());
}
}
}
@@ -1,19 +1,23 @@
package modtweaker2.mods.tfcraft.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toILiquidStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.tfcraft.TFCHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@@ -23,6 +27,10 @@ import com.bioxx.tfc.api.Crafting.BarrelRecipe;
@ZenClass("mods.tfcraft.Barrel")
public class Barrel {
public static final String name = "TFC Barrel";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* @param outputFluid If you want this recipe consume fluid, <code>outputFluid=inputFluid</code>
@@ -53,44 +61,63 @@ public class Barrel {
MineTweakerAPI.apply(new AddRecipe(new BarrelLiquidToLiquidRecipe(toFluid(inputInBarrel), toFluid(input), toFluid(output))));
}
@ZenMethod
public static void remove(IItemStack output){
MineTweakerAPI.apply(new RemoveRecipe(toStack(output)));
}
@ZenMethod
public static void remove(ILiquidStack output){
MineTweakerAPI.apply(new RemoveRecipe(toFluid(output)));
}
private static class AddRecipe extends BaseListAddition{
private static class AddRecipe extends BaseListAddition<BarrelRecipe> {
public AddRecipe(BarrelRecipe recipe){
super("Barrel", TFCHelper.barrelRecipes, recipe);
}
}
private static class RemoveRecipe extends BaseListRemoval{
public RemoveRecipe(ItemStack stack){
super("Barrel-Remove", TFCHelper.barrelRecipes, stack);
super(Barrel.name, TFCHelper.barrelRecipes);
recipes.add(recipe);
}
public RemoveRecipe(FluidStack fluid){
super("Barrel-Remove", TFCHelper.barrelRecipes, fluid);
}
@Override
public void apply() {
for (BarrelRecipe recipe : BarrelManager.getInstance().getRecipes()){
if (recipe.getRecipeOutIS() != null && areEqual(recipe.getRecipeOutIS(), stack)){
recipes.add(recipe);
}
}
for (BarrelRecipe recipe : BarrelManager.getInstance().getRecipes()){
if (recipe.getRecipeOutFluid() != null && recipe.getRecipeOutFluid().isFluidEqual(fluid)){
recipes.add(recipe);
}
}
super.apply();
protected String getRecipeInfo(BarrelRecipe recipe) {
if(recipe.getRecipeOutIS() != null)
return InputHelper.getStackDescription(recipe.getRecipeOutIS());
else if(recipe.getRecipeOutFluid() != null)
return InputHelper.getStackDescription(recipe.getRecipeOutFluid());
else
return "Unknown output";
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void remove(IIngredient output){
List<BarrelRecipe> recipes = new LinkedList<BarrelRecipe>();
// Test for item outputs
for (BarrelRecipe recipe : BarrelManager.getInstance().getRecipes()){
if (recipe.getRecipeOutIS() != null && matches(output, toIItemStack(recipe.getRecipeOutIS()))) {
recipes.add(recipe);
}
}
// Test for liquid outputs
for (BarrelRecipe recipe : BarrelManager.getInstance().getRecipes()){
if (recipe.getRecipeOutFluid() != null && matches(output, toILiquidStack(recipe.getRecipeOutFluid()))) {
recipes.add(recipe);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveRecipe(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Barrel.name, output.toString()));
}
}
private static class RemoveRecipe extends BaseListRemoval<BarrelRecipe> {
public RemoveRecipe(List<BarrelRecipe> recipes){
super(Barrel.name, TFCHelper.barrelRecipes, recipes);
}
@Override
protected String getRecipeInfo(BarrelRecipe recipe) {
if(recipe.getRecipeOutIS() != null)
return InputHelper.getStackDescription(recipe.getRecipeOutIS());
else if(recipe.getRecipeOutFluid() != null)
return InputHelper.getStackDescription(recipe.getRecipeOutFluid());
else
return "Unknown output";
}
}
}
@@ -1,16 +1,19 @@
package modtweaker2.mods.tfcraft.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.mods.tfcraft.TFCHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@@ -19,6 +22,8 @@ import com.bioxx.tfc.api.Crafting.KilnRecipe;
@ZenClass("mods.tfcraft.Kiln")
public class Kiln {
public static final String name = "TFC Kiln";
/** Deprecated, since pottery kiln will check <code>x instanceof ItemPotteryBase</code>
* <p>If you have a such item, you might consider to use it
@@ -29,31 +34,40 @@ public class Kiln {
MineTweakerAPI.apply(new AddRecipe(new KilnRecipe(toStack(input), lv, toStack(output))));
}
@ZenMethod
public static void remove(IItemStack stack){
MineTweakerAPI.apply(new RemoveRecipe(toStack(stack)));
}
private static class AddRecipe extends BaseListAddition{
private static class AddRecipe extends BaseListAddition<KilnRecipe> {
public AddRecipe(KilnRecipe recipe) {
super("Kiln", TFCHelper.kilnRecipes, recipe);
super(Kiln.name, TFCHelper.kilnRecipes);
recipes.add(recipe);
}
@Override
protected String getRecipeInfo(KilnRecipe recipe) {
return InputHelper.getStackDescription(recipe.getCraftingResult());
}
}
private static class RemoveRecipe extends BaseListRemoval{
public RemoveRecipe(ItemStack out){
super("Kiln-Remove", TFCHelper.kilnRecipes, out);
}
@Override
public void apply() {
for (KilnRecipe recipe : KilnCraftingManager.getInstance().getRecipeList()){
if (recipe.getCraftingResult() != null && areEqual(recipe.getCraftingResult(), stack)){
recipes.add(recipe);
}
}
super.apply();
@ZenMethod
public static void remove(IIngredient output){
List<KilnRecipe> recipes = new LinkedList<KilnRecipe>();
for (KilnRecipe recipe : KilnCraftingManager.getInstance().getRecipeList()){
if (recipe.getCraftingResult() != null && matches(output, toIItemStack(recipe.getCraftingResult()))) {
recipes.add(recipe);
}
}
MineTweakerAPI.apply(new RemoveRecipe(recipes));
}
private static class RemoveRecipe extends BaseListRemoval<KilnRecipe> {
public RemoveRecipe(List<KilnRecipe> recipes) {
super(Kiln.name, TFCHelper.kilnRecipes, recipes);
}
@Override
protected String getRecipeInfo(KilnRecipe recipe) {
return InputHelper.getStackDescription(recipe.getCraftingResult());
}
}
}
@@ -1,13 +1,16 @@
package modtweaker2.mods.tfcraft.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import net.minecraft.item.ItemStack;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.mods.tfcraft.TFCHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
@@ -19,39 +22,70 @@ import com.bioxx.tfc.api.Crafting.QuernRecipe;
@ZenClass("mods.tfcraft.Quern")
public class Quern {
public static final String name = "TFC Quern";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void add(IItemStack input, IItemStack output) {
MineTweakerAPI.apply(new AddRecipe(new QuernRecipe(toStack(input), toStack(output))));
}
@ZenMethod
public static void remove(IItemStack input){
MineTweakerAPI.apply(new RemoveRecipe(toStack(input)));
}
private static class AddRecipe extends BaseListAddition{
private static class AddRecipe extends BaseListAddition<QuernRecipe> {
public AddRecipe(QuernRecipe recipe) {
super("Quern", TFCHelper.quernRecipes, recipe);
TFCHelper.quernVaildItems.add(recipe.getInItem());
super(Quern.name, TFCHelper.quernRecipes);
recipes.add(recipe);
}
@Override
public void apply() {
super.apply();
for (QuernRecipe recipe : successful){
TFCHelper.quernVaildItems.add(recipe.getInItem());
}
}
@Override
public void undo() {
for (QuernRecipe recipe : successful){
TFCHelper.quernVaildItems.remove(recipe.getInItem());
}
super.undo();
}
@Override
protected String getRecipeInfo(QuernRecipe recipe) {
return InputHelper.getStackDescription(recipe.getResult());
}
}
private static class RemoveRecipe extends BaseListRemoval{
public RemoveRecipe(ItemStack stack) {
super("Quern-Remove", TFCHelper.quernRecipes, stack);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void remove(IIngredient output) {
List<QuernRecipe> recipes = new LinkedList<QuernRecipe>();
for (QuernRecipe recipe : QuernManager.getInstance().getRecipes()) {
if (recipe != null && recipe.getResult() != null && matches(output, toIItemStack(recipe.getResult()))){
recipes.add(recipe);
}
}
MineTweakerAPI.apply(new RemoveRecipe(recipes));
}
private static class RemoveRecipe extends BaseListRemoval<QuernRecipe> {
public RemoveRecipe(List<QuernRecipe> recipes) {
super(Quern.name, TFCHelper.quernRecipes, recipes);
}
@Override
public void apply() {
for (QuernRecipe recipe : QuernManager.getInstance().getRecipes()){
if (recipe.getResult() !=null && areEqual(recipe.getResult(), stack)){
recipes.add(recipe);
}
}
for (Object aRecipe : recipes){
TFCHelper.quernVaildItems.remove(((QuernRecipe)aRecipe).getInItem());
for (QuernRecipe recipe : recipes) {
TFCHelper.quernVaildItems.remove(recipe.getInItem());
}
super.apply();
@@ -59,11 +93,16 @@ public class Quern {
@Override
public void undo() {
for (Object aRecipe : recipes){
TFCHelper.quernVaildItems.add(((QuernRecipe)aRecipe).getInItem());
}
super.undo();
for (QuernRecipe recipe : successful){
TFCHelper.quernVaildItems.add(recipe.getInItem());
}
}
@Override
protected String getRecipeInfo(QuernRecipe recipe) {
return InputHelper.getStackDescription(recipe.getResult());
}
}
@@ -5,9 +5,9 @@ import modtweaker2.mods.thaumcraft.handlers.Arcane;
import modtweaker2.mods.thaumcraft.handlers.Aspects;
import modtweaker2.mods.thaumcraft.handlers.Crucible;
import modtweaker2.mods.thaumcraft.handlers.Infusion;
import modtweaker2.mods.thaumcraft.handlers.Loot;
import modtweaker2.mods.thaumcraft.handlers.Research;
import modtweaker2.mods.thaumcraft.handlers.Warp;
import modtweaker2.mods.thaumcraft.handlers.Loot;
public class Thaumcraft {
public Thaumcraft() {
@@ -1,18 +1,22 @@
package modtweaker2.mods.thaumcraft.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toObjects;
import static modtweaker2.helpers.InputHelper.toShapedObjects;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@@ -23,61 +27,74 @@ import thaumcraft.api.crafting.ShapelessArcaneRecipe;
@ZenClass("mods.thaumcraft.Arcane")
public class Arcane {
public static final String name = "Thaumcraft Arcane Worktable";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addShaped(String key, IItemStack output, String aspects, IIngredient[][] ingredients) {
MineTweakerAPI.apply(new Add(new ShapedArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toShapedObjects(ingredients))));
MineTweakerAPI.apply(new Add(new ShapedArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toShapedObjects(ingredients))));
}
@ZenMethod
public static void addShapeless(String key, IItemStack output, String aspects, IIngredient[] ingredients) {
MineTweakerAPI.apply(new Add(new ShapelessArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toObjects(ingredients))));
MineTweakerAPI.apply(new Add(new ShapelessArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toObjects(ingredients))));
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<IArcaneRecipe> {
public Add(IArcaneRecipe recipe) {
super("Thaumcraft Arcane Worktable", ThaumcraftApi.getCraftingRecipes(), recipe);
super(Arcane.name, ThaumcraftApi.getCraftingRecipes());
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
Object out = ((IArcaneRecipe) recipe).getRecipeOutput();
if (out instanceof ItemStack) {
return ((ItemStack) out).getDisplayName();
} else
return super.getRecipeInfo();
protected String getRecipeInfo(IArcaneRecipe recipe) {
ItemStack stack = recipe.getRecipeOutput();
if(stack instanceof ItemStack)
return InputHelper.getStackDescription(stack);
else
return "Unknown output";
}
}
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
public static void removeRecipe(IIngredient output) {
List<IArcaneRecipe> recipes = new LinkedList<IArcaneRecipe>();
for(Object o : ThaumcraftApi.getCraftingRecipes()) {
if(o != null && o instanceof IArcaneRecipe) {
IArcaneRecipe recipe = (IArcaneRecipe)o;
if(recipe.getRecipeOutput() != null && matches(output, toIItemStack(recipe.getRecipeOutput()))) {
recipes.add(recipe);
}
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command Ignored", Arcane.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Thaumcraft Arcane Worktable", ThaumcraftApi.getCraftingRecipes(), stack);
private static class Remove extends BaseListRemoval<IArcaneRecipe> {
public Remove(List<IArcaneRecipe> recipes) {
super(Arcane.name, ThaumcraftApi.getCraftingRecipes(), recipes);
}
@Override
public void apply() {
for (Object o : ThaumcraftApi.getCraftingRecipes()) {
if (o != null && o instanceof IArcaneRecipe) {
IArcaneRecipe r = (IArcaneRecipe) o;
if (r.getRecipeOutput() != null && r.getRecipeOutput().isItemEqual(stack)) {
recipes.add(r);
}
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
@Override
protected String getRecipeInfo(IArcaneRecipe recipe) {
ItemStack stack = recipe.getRecipeOutput();
if(stack instanceof ItemStack)
return InputHelper.getStackDescription(stack);
else
return "Unknown output";
}
}
}
@@ -7,9 +7,7 @@ import java.util.Arrays;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
import modtweaker2.utils.BaseDescriptionAddition;
import modtweaker2.utils.BaseDescriptionRemoval;
import modtweaker2.utils.TweakerPlugin;
import modtweaker2.utils.BaseUndoable;
import net.minecraft.entity.EntityList;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
@@ -34,7 +32,7 @@ public class Aspects {
}
// Adds or sets Aspects
private static class Add extends BaseDescriptionAddition {
private static class Add extends BaseUndoable {
private final ItemStack stack;
private final String aspects;
private final boolean replace;
@@ -55,7 +53,10 @@ public class Aspects {
newList = ThaumcraftHelper.parseAspects(oldList, aspects);
else
newList = ThaumcraftHelper.parseAspects(aspects);
ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), newList);
success = true;
}
@Override
@@ -80,7 +81,7 @@ public class Aspects {
MineTweakerAPI.apply(new Remove(toStack(stack), aspects));
}
private static class Remove extends BaseDescriptionRemoval {
private static class Remove extends BaseUndoable {
private final ItemStack stack;
private final String aspects;
private AspectList oldList;
@@ -99,6 +100,8 @@ public class Aspects {
newList = ThaumcraftHelper.removeAspects(oldList, aspects);
ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), newList);
}
success = true;
}
@Override
@@ -139,7 +142,7 @@ public class Aspects {
}
// Adds or sets Aspects
private static class AddEntity extends BaseDescriptionAddition {
private static class AddEntity extends BaseUndoable {
private final String entityName;
private final String aspects;
private final boolean replace;
@@ -162,6 +165,8 @@ public class Aspects {
newList = ThaumcraftHelper.parseAspects(aspects);
ThaumcraftHelper.removeEntityAspects(entityName);
ThaumcraftApi.registerEntityTag(entityName, newList);
success = true;
}
@Override
@@ -189,7 +194,7 @@ public class Aspects {
MineTweakerAPI.apply(new RemoveEntity(entityName, aspects));
}
private static class RemoveEntity extends BaseDescriptionRemoval {
private static class RemoveEntity extends BaseUndoable {
private final String entityName;
private final String aspects;
private AspectList oldList;
@@ -209,6 +214,8 @@ public class Aspects {
ThaumcraftHelper.removeEntityAspects(entityName);
ThaumcraftApi.registerEntityTag(entityName, newList);
}
success = true;
}
@Override
@@ -1,16 +1,21 @@
package modtweaker2.mods.thaumcraft.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toObject;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import thaumcraft.api.ThaumcraftApi;
@@ -18,52 +23,56 @@ import thaumcraft.api.crafting.CrucibleRecipe;
@ZenClass("mods.thaumcraft.Crucible")
public class Crucible {
public static final String name = "Thaumcraft Crucible";
@ZenMethod
public static void addRecipe(String key, IItemStack result, IIngredient catalyst, String aspects) {
MineTweakerAPI.apply(new Add(new CrucibleRecipe(key, toStack(result), toObject(catalyst), ThaumcraftHelper.parseAspects(aspects))));
MineTweakerAPI.apply(new Add(new CrucibleRecipe(key, toStack(result), toObject(catalyst), ThaumcraftHelper.parseAspects(aspects))));
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<CrucibleRecipe> {
public Add(CrucibleRecipe recipe) {
super("Thaumcraft Crucible", ThaumcraftApi.getCraftingRecipes(), recipe);
super(Crucible.name, ThaumcraftApi.getCraftingRecipes());
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((CrucibleRecipe) recipe).getRecipeOutput().getDisplayName();
protected String getRecipeInfo(CrucibleRecipe recipe) {
return InputHelper.getStackDescription(recipe.getRecipeOutput());
}
}
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
public static void removeRecipe(IIngredient output) {
List<CrucibleRecipe> recipes = new LinkedList<CrucibleRecipe>();
for (Object o : ThaumcraftApi.getCraftingRecipes()) {
if (o instanceof CrucibleRecipe) {
CrucibleRecipe r = (CrucibleRecipe) o;
if (r.getRecipeOutput() != null && matches(output, toIItemStack(r.getRecipeOutput()))) {
recipes.add(r);
}
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Crucible.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Thaumcraft Crucible", ThaumcraftApi.getCraftingRecipes(), stack);
private static class Remove extends BaseListRemoval<CrucibleRecipe> {
public Remove(List<CrucibleRecipe> recipes) {
super(Crucible.name, ThaumcraftApi.getCraftingRecipes(), recipes);
}
@Override
public void apply() {
for (Object o : ThaumcraftApi.getCraftingRecipes()) {
if (o instanceof CrucibleRecipe) {
CrucibleRecipe r = (CrucibleRecipe) o;
if (r.getRecipeOutput() != null && areEqual(r.getRecipeOutput(), stack)) {
recipes.add(r);
}
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
@Override
protected String getRecipeInfo(CrucibleRecipe recipe) {
return InputHelper.getStackDescription(recipe.getRecipeOutput());
}
}
}
@@ -1,16 +1,22 @@
package modtweaker2.mods.thaumcraft.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.InputHelper.toStacks;
import static modtweaker2.helpers.StackHelper.areEqual;
import minetweaker.IUndoableAction;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
import modtweaker2.mods.thaumcraft.recipe.MTInfusionRecipe;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
@@ -21,6 +27,10 @@ import thaumcraft.api.crafting.InfusionRecipe;
@ZenClass("mods.thaumcraft.Infusion")
public class Infusion {
public static final String name = "Thaumcraft Infusion";
public static final String enchName = name + " Enchantment";
@ZenMethod
public static void addRecipe(String key, IItemStack input, IItemStack[] recipe, String aspects, IItemStack result, int instability) {
@@ -31,131 +41,112 @@ public class Infusion {
// fuzzy or not
@ZenMethod
public static void addRecipe(String key, IItemStack input, IItemStack[] recipe, String aspects, IItemStack result, int instability, boolean fuzzyCentre, boolean[] fuzzyRecipe) {
MineTweakerAPI.apply(new Add(new MTInfusionRecipe(key, toStack(result), instability, ThaumcraftHelper.parseAspects(aspects), toStack(input), toStacks(recipe), fuzzyCentre, fuzzyRecipe)));
MineTweakerAPI.apply(new Add(new MTInfusionRecipe(key, toStack(result), instability, ThaumcraftHelper.parseAspects(aspects), toStack(input), toStacks(recipe), fuzzyCentre, fuzzyRecipe)));
}
@ZenMethod
public static void addEnchantment(String key, int enchantID, int instability, String aspects, IItemStack[] recipe) {
MineTweakerAPI.apply(new AddEnchant(new InfusionEnchantmentRecipe(key, Enchantment.enchantmentsList[enchantID], instability, ThaumcraftHelper.parseAspects(aspects), toStacks(recipe))));
MineTweakerAPI.apply(new AddEnchant(new InfusionEnchantmentRecipe(key, Enchantment.enchantmentsList[enchantID], instability, ThaumcraftHelper.parseAspects(aspects), toStacks(recipe))));
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<InfusionRecipe> {
public Add(InfusionRecipe recipe) {
super("Thaumcraft Infusion", ThaumcraftApi.getCraftingRecipes(), recipe);
super(Infusion.name, ThaumcraftApi.getCraftingRecipes());
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
Object out = ((InfusionRecipe) recipe).getRecipeOutput();
if (out instanceof ItemStack) {
return ((ItemStack) out).getDisplayName();
} else
return super.getRecipeInfo();
protected String getRecipeInfo(InfusionRecipe recipe) {
Object out = ((InfusionRecipe) recipe).getRecipeOutput();
if (out instanceof ItemStack) {
return ((ItemStack) out).getDisplayName();
} else
return "Unknown item";
}
}
private static class AddEnchant implements IUndoableAction {
InfusionEnchantmentRecipe recipe;
private static class AddEnchant extends BaseListAddition<InfusionEnchantmentRecipe> {
public AddEnchant(InfusionEnchantmentRecipe inp) {
recipe = inp;
}
@Override
public void apply() {
ThaumcraftApi.getCraftingRecipes().add(recipe);
}
@Override
public String describe() {
return "Adding Infusion Enchantment Recipe: " + recipe.enchantment.getName();
}
@Override
public boolean canUndo() {
return recipe != null;
}
@Override
public void undo() {
ThaumcraftApi.getCraftingRecipes().remove(recipe);
}
@Override
public String describeUndo() {
return "Removing Infusion Enchantment Recipe: " + recipe.enchantment.getName();
}
@Override
public String getOverrideKey() {
return null;
super(Infusion.enchName, ThaumcraftApi.getCraftingRecipes());
recipes.add(inp);
}
@Override
protected String getRecipeInfo(InfusionEnchantmentRecipe recipe) {
return recipe.getEnchantment().getName();
}
}
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
public static void removeRecipe(IIngredient output) {
List<InfusionRecipe> recipes = new LinkedList<InfusionRecipe>();
for (Object o : ThaumcraftApi.getCraftingRecipes()) {
if (o instanceof InfusionRecipe) {
InfusionRecipe r = (InfusionRecipe) o;
if (r.getRecipeOutput() != null && r.getRecipeOutput() instanceof ItemStack && matches(output, toIItemStack((ItemStack)r.getRecipeOutput()))) {
recipes.add(r);
}
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Infusion.name, output.toString()));
}
}
@ZenMethod
public static void removeEnchant(int id) {
MineTweakerAPI.apply(new RemoveEnchant(Enchantment.enchantmentsList[id]));
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Thaumcraft Infusion", ThaumcraftApi.getCraftingRecipes(), stack);
}
@Override
public void apply() {
for (Object o : ThaumcraftApi.getCraftingRecipes()) {
if (o instanceof InfusionRecipe) {
InfusionRecipe r = (InfusionRecipe) o;
if (r.getRecipeOutput() != null && r.getRecipeOutput() instanceof ItemStack && areEqual((ItemStack) r.getRecipeOutput(), stack)) {
recipes.add(r);
}
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
private static class RemoveEnchant extends BaseListRemoval {
Enchantment enchant;
public RemoveEnchant(Enchantment ench) {
super("Thaumcraft Infusion Enchantment", ThaumcraftApi.getCraftingRecipes());
enchant = ench;
}
@Override
public void apply() {
for (Object recipe : list) {
if (recipe instanceof InfusionEnchantmentRecipe) {
InfusionEnchantmentRecipe enchRecipe = (InfusionEnchantmentRecipe) recipe;
if (enchRecipe.getEnchantment() == enchant) {
recipes.add(enchRecipe);
}
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return enchant.getName();
List<InfusionEnchantmentRecipe> recipes = new LinkedList<InfusionEnchantmentRecipe>();
Enchantment ench = Enchantment.enchantmentsList[id];
for (Object recipe : ThaumcraftApi.getCraftingRecipes()) {
if (recipe instanceof InfusionEnchantmentRecipe) {
InfusionEnchantmentRecipe enchRecipe = (InfusionEnchantmentRecipe) recipe;
if (enchRecipe.getEnchantment() == ench) {
recipes.add(enchRecipe);
}
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveEnchant(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Infusion.enchName + " Enchantment", ench.getName()));
}
}
private static class Remove extends BaseListRemoval<InfusionRecipe> {
public Remove(List<InfusionRecipe> recipes) {
super(Infusion.name, ThaumcraftApi.getCraftingRecipes(), recipes);
}
@Override
protected String getRecipeInfo(InfusionRecipe recipe) {
Object o = recipe.getRecipeOutput();
if(o instanceof ItemStack) {
return InputHelper.getStackDescription((ItemStack)o);
} else {
return "Unknown Item";
}
}
}
private static class RemoveEnchant extends BaseListRemoval<InfusionEnchantmentRecipe> {
public RemoveEnchant(List<InfusionEnchantmentRecipe> recipes) {
super(Infusion.enchName, ThaumcraftApi.getCraftingRecipes(), recipes);
}
@Override
protected String getRecipeInfo(InfusionEnchantmentRecipe recipe) {
return recipe.getEnchantment().getName();
}
}
}
@@ -1,20 +1,28 @@
package modtweaker2.mods.thaumcraft.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import net.minecraft.item.ItemStack;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import thaumcraft.api.ThaumcraftApi;
import thaumcraft.api.internal.WeightedRandomLoot;
@ZenClass("mods.thaumcraft.Loot")
public class Loot {
public static final String name = "Thaumcraft LootBag";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addCommonLoot(IItemStack stack, int weight) {
@@ -31,40 +39,59 @@ public class Loot {
MineTweakerAPI.apply(new Add(WeightedRandomLoot.lootBagRare, new WeightedRandomLoot(InputHelper.toStack(stack), weight)));
}
public static class Add extends BaseListAddition {
public Add(List list, WeightedRandomLoot recipe) {
super(list, recipe);
public static class Add extends BaseListAddition<WeightedRandomLoot> {
public Add(List<WeightedRandomLoot> list, WeightedRandomLoot recipe) {
super(Loot.name, list);
recipes.add(recipe);
}
@Override
protected String getRecipeInfo(WeightedRandomLoot recipe) {
return InputHelper.getStackDescription(recipe.item);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeCommonLoot(IIngredient stack) {
removeLoot(WeightedRandomLoot.lootBagCommon, stack);
}
@ZenMethod
public static void removeCommonLoot(IItemStack stack) {
MineTweakerAPI.apply(new Remove(WeightedRandomLoot.lootBagCommon, InputHelper.toStack(stack)));
public static void removeUncommonLoot(IIngredient stack) {
removeLoot(WeightedRandomLoot.lootBagUncommon, stack);
}
@ZenMethod
public static void removeUncommonLoot(IItemStack stack) {
MineTweakerAPI.apply(new Remove(WeightedRandomLoot.lootBagUncommon, InputHelper.toStack(stack)));
public static void removeRareLoot(IIngredient stack) {
removeLoot(WeightedRandomLoot.lootBagRare, stack);
}
public static void removeLoot(List<WeightedRandomLoot> list, IIngredient ingredient) {
List<WeightedRandomLoot> recipes = new LinkedList<WeightedRandomLoot>();
for (WeightedRandomLoot loot : list) {
if (matches(ingredient, toIItemStack(loot.item))) {
recipes.add(loot);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(list, recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored.", Loot.name, ingredient.toString()));
}
}
@ZenMethod
public static void removeRareLoot(IItemStack stack) {
MineTweakerAPI.apply(new Remove(WeightedRandomLoot.lootBagRare, InputHelper.toStack(stack)));
}
public static class Remove extends BaseListRemoval {
public Remove(List list, ItemStack stack) {
super(list, stack);
public static class Remove extends BaseListRemoval<WeightedRandomLoot> {
public Remove(List<WeightedRandomLoot> list, List<WeightedRandomLoot> recipes) {
super(Loot.name, list, recipes);
}
@Override
public void apply() {
for (WeightedRandomLoot stack : (List<WeightedRandomLoot>) list) {
if (stack.item.isItemEqual(this.stack)) {
recipes.add(stack);
}
}
super.apply();
protected String getRecipeInfo(WeightedRandomLoot recipe) {
return InputHelper.getStackDescription(recipe.item);
}
}
}
@@ -21,7 +21,6 @@ import modtweaker2.mods.thaumcraft.research.RemoveResearch;
import modtweaker2.mods.thaumcraft.research.RemoveTab;
import modtweaker2.mods.thaumcraft.research.SetAspects;
import modtweaker2.mods.thaumcraft.research.SetResearch;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.util.ResourceLocation;
import stanhebben.zenscript.annotations.Optional;
@@ -10,7 +10,6 @@ import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@@ -1,5 +1,6 @@
package modtweaker2.mods.thaumcraft.research;
import static modtweaker2.helpers.StackHelper.areEqual;
import minetweaker.IUndoableAction;
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
import net.minecraft.enchantment.Enchantment;
@@ -14,8 +15,6 @@ import thaumcraft.api.crafting.InfusionRecipe;
import thaumcraft.api.research.ResearchCategories;
import thaumcraft.api.research.ResearchPage;
import thaumcraft.api.research.ResearchPage.PageType;
import static modtweaker2.helpers.InputHelper.*;
import static modtweaker2.helpers.StackHelper.*;
public class AddPage implements IUndoableAction {
String key;
@@ -1,5 +1,6 @@
package modtweaker2.mods.thaumcraft.research;
import static modtweaker2.helpers.StackHelper.areEqual;
import minetweaker.IUndoableAction;
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
import net.minecraft.item.ItemStack;
@@ -12,8 +13,6 @@ import thaumcraft.api.crafting.InfusionRecipe;
import thaumcraft.api.research.ResearchCategories;
import thaumcraft.api.research.ResearchItem;
import thaumcraft.api.research.ResearchPage;
import static modtweaker2.helpers.InputHelper.*;
import static modtweaker2.helpers.StackHelper.*;
public class RefreshResearch implements IUndoableAction {
String research;
@@ -1,11 +1,11 @@
package modtweaker2.mods.thaumcraft.research.commands;
import static modtweaker2.helpers.LogHelper.log;
import static modtweaker2.helpers.LogHelper.logPrinted;
import minetweaker.MineTweakerAPI;
import minetweaker.api.player.IPlayer;
import minetweaker.api.server.ICommandFunction;
import thaumcraft.api.research.ResearchCategories;
import static modtweaker2.helpers.InputHelper.*;
import static modtweaker2.helpers.LogHelper.*;
public class ResearchLogger implements ICommandFunction {
@Override
@@ -7,7 +7,6 @@ import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.ZenClass;
@@ -19,8 +18,7 @@ import cofh.thermalexpansion.util.crafting.CrucibleManager.RecipeCrucible;
public class Crucible {
@ZenMethod
public static void addRecipe(int energy, IItemStack input, ILiquidStack output) {
MineTweakerAPI.apply(new Add(energy, toStack(input), toFluid(output)));
MineTweakerAPI.apply(new Add(energy, toStack(input), toFluid(output)));
}
private static class Add implements IUndoableAction {
@@ -4,7 +4,6 @@ import static modtweaker2.helpers.InputHelper.toStack;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@@ -4,7 +4,6 @@ import static modtweaker2.helpers.InputHelper.toStack;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@@ -4,7 +4,6 @@ import static modtweaker2.helpers.InputHelper.toStack;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@@ -9,9 +9,7 @@ import java.util.Map;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.thermalexpansion.ThermalHelper;
import modtweaker2.utils.BaseDescriptionAddition;
import modtweaker2.utils.BaseDescriptionRemoval;
import modtweaker2.utils.TweakerPlugin;
import modtweaker2.utils.BaseMultiModification;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@@ -52,7 +50,7 @@ public class Smelter {
MineTweakerAPI.apply(new Add(in1, in2, recipe));
}
private static class Add extends BaseDescriptionAddition {
private static class Add extends BaseMultiModification {
private final ComparableItemStackSafe input1;
private final ComparableItemStackSafe input2;
private final List key;
@@ -99,7 +97,7 @@ public class Smelter {
MineTweakerAPI.apply(new Remove(toStack(input), toStack(input2)));
}
private static class Remove extends BaseDescriptionRemoval {
private static class Remove extends BaseMultiModification {
private final ComparableItemStackSafe input1;
private final ComparableItemStackSafe input2;
private final List key;
@@ -11,9 +11,7 @@ import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.mods.thermalexpansion.ThermalHelper;
import modtweaker2.utils.BaseDescriptionAddition;
import modtweaker2.utils.BaseDescriptionRemoval;
import modtweaker2.utils.TweakerPlugin;
import modtweaker2.utils.BaseUndoable;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.ZenClass;
@@ -65,7 +63,7 @@ public class Transposer {
MineTweakerAPI.apply(new Add(in, fluid, recipe, isFillRecipe));
}
private static class Add extends BaseDescriptionAddition {
private static class Add extends BaseUndoable {
private List key;
private boolean isFillRecipe;
private final ComparableItemStackSafe input;
@@ -132,7 +130,7 @@ public class Transposer {
MineTweakerAPI.apply(new Remove(toStack(input), toFluid(liquid), isFillRecipe));
}
private static class Remove extends BaseDescriptionRemoval {
private static class Remove extends BaseUndoable {
private final boolean isFillRecipe;
private final ComparableItemStackSafe input;
private List key;
@@ -2,8 +2,6 @@ package modtweaker2.utils;
import java.util.ArrayList;
import net.minecraftforge.common.util.ForgeDirection;
public class ArrayUtils {
@@ -1,56 +1,22 @@
package modtweaker2.utils;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import java.util.List;
import static modtweaker2.helpers.StackHelper.areEqual;
import modtweaker2.helpers.InputHelper;
import net.minecraft.item.crafting.IRecipe;
public abstract class BaseCraftingAddition extends BaseDescriptionAddition {
protected final List<IRecipe> list;
protected final boolean shapeless;
protected final ItemStack output;
protected final Object[] recipe;
public abstract class BaseCraftingAddition extends BaseListAddition<IRecipe> {
public BaseCraftingAddition(String name, boolean shapeless, List list, ItemStack output, Object... recipe) {
super(name);
this.shapeless = shapeless;
this.output = output;
this.recipe = recipe;
this.list = list;
}
@Override
public void apply() {
if (shapeless) applyShapeless();
else applyShaped();
}
public abstract void applyShaped();
public abstract void applyShapeless();
@Override
public boolean canUndo() {
return list != null;
}
@Override
public void undo() {
IRecipe remove = null;
for (IRecipe recipe : list) {
if (recipe.getRecipeOutput() != null && areEqual(recipe.getRecipeOutput(), output)) {
remove = recipe;
break;
}
}
list.remove(remove);
}
@Override
public String getRecipeInfo() {
return output.getDisplayName();
}
protected BaseCraftingAddition(String name, List<IRecipe> list) {
super(name, list);
}
protected BaseCraftingAddition(String name, List<IRecipe> list, List<IRecipe> recipes) {
super(name, list, recipes);
}
@Override
protected String getRecipeInfo(IRecipe recipe) {
return InputHelper.getStackDescription(recipe.getRecipeOutput());
}
}
@@ -1,29 +1,35 @@
package modtweaker2.utils;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.api.item.IIngredient;
import modtweaker2.helpers.InputHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import java.util.List;
import static modtweaker2.helpers.StackHelper.areEqual;
public class BaseCraftingRemoval extends BaseListRemoval {
public BaseCraftingRemoval(String name, List list, ItemStack stack) {
super(name, list, stack);
public class BaseCraftingRemoval extends BaseListRemoval<IRecipe> {
public BaseCraftingRemoval(String name, List<IRecipe> list, List<IRecipe> recipes) {
super(name, list, recipes);
}
@Override
public void apply() {
for (IRecipe r : (List<IRecipe>) list) {
if (r.getRecipeOutput() != null && r.getRecipeOutput() instanceof ItemStack && areEqual(r.getRecipeOutput(), stack)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
@Override
public String getRecipeInfo(IRecipe recipe) {
return InputHelper.getStackDescription(recipe.getRecipeOutput());
}
public static List<IRecipe> getRecipes(List<IRecipe> list, IIngredient ingredient) {
List<IRecipe> recipes = new LinkedList<IRecipe>();
for (IRecipe r : list) {
if (r != null && r.getRecipeOutput() != null && r.getRecipeOutput() instanceof ItemStack && matches(ingredient, toIItemStack(r.getRecipeOutput()))) {
recipes.add(r);
}
}
return recipes;
}
}
@@ -1,36 +0,0 @@
package modtweaker2.utils;
import net.minecraft.item.ItemStack;
import minetweaker.IUndoableAction;
public abstract class BaseDescriptionAddition implements IUndoableAction {
protected String description;
public BaseDescriptionAddition(String description) {
this.description = description;
}
@Override
public boolean canUndo() {
return true;
}
public String getRecipeInfo() {
return "Unknown Item";
}
@Override
public String describe() {
return "Adding " + description + " Recipe for :" + getRecipeInfo();
}
@Override
public String describeUndo() {
return "Removing " + description + " Recipe for :" + getRecipeInfo();
}
@Override
public Object getOverrideKey() {
return null;
}
}
Loaded 100 of 112 files, more files were not shown because too many files have changed in this diff. Show more