Thermal Expansion Rework
This commit is contained in:
parent
40605f5fa9
commit
22e09c9392
|
@ -1,79 +1,44 @@
|
|||
package modtweaker2.mods.thermalexpansion;
|
||||
|
||||
import static modtweaker2.helpers.ReflectionHelper.getConstructor;
|
||||
import static modtweaker2.helpers.ReflectionHelper.getStaticObject;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import cofh.lib.inventory.ComparableItemStackSafe;
|
||||
import cofh.thermalexpansion.util.crafting.SmelterManager.ComparableItemStackSmelter;
|
||||
import cofh.thermalexpansion.util.crafting.CrucibleManager.RecipeCrucible;
|
||||
import cofh.thermalexpansion.util.crafting.FurnaceManager.RecipeFurnace;
|
||||
import cofh.thermalexpansion.util.crafting.PulverizerManager.RecipePulverizer;
|
||||
import cofh.thermalexpansion.util.crafting.SawmillManager.RecipeSawmill;
|
||||
import cofh.thermalexpansion.util.crafting.SmelterManager.RecipeSmelter;
|
||||
import cofh.thermalexpansion.util.crafting.TransposerManager.RecipeTransposer;
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class ThermalHelper {
|
||||
private static Map<List<ComparableItemStackSmelter>, RecipeSmelter> smelter;
|
||||
public static Set<ComparableItemStackSmelter> smelterValid;
|
||||
private static Map crucible;
|
||||
|
||||
private static Map<List<Integer>, RecipeTransposer> transposerFill;
|
||||
private static Map<ComparableItemStackSafe, RecipeTransposer> transposerEmpty;
|
||||
public static Set<ComparableItemStackSafe> transposerValid;
|
||||
|
||||
public static Constructor smelterRecipe;
|
||||
public static Constructor transposerRecipe;
|
||||
|
||||
public static Constructor<RecipeCrucible> crucibleRecipe;
|
||||
public static Constructor<RecipeFurnace> furanceRecipe;
|
||||
public static Constructor<RecipePulverizer> pulverizerRecipe;
|
||||
public static Constructor<RecipeSawmill> sawmillRecipe;
|
||||
public static Constructor<RecipeSmelter> smelterRecipe;
|
||||
public static Constructor<RecipeTransposer> transposerRecipe;
|
||||
|
||||
static {
|
||||
try {
|
||||
smelterRecipe = getConstructor("cofh.thermalexpansion.util.crafting.SmelterManager$RecipeSmelter", ItemStack.class, ItemStack.class, ItemStack.class, ItemStack.class, int.class, int.class);
|
||||
crucibleRecipe = getConstructor("cofh.thermalexpansion.util.crafting.CrucibleManager$RecipeCrucible", ItemStack.class, FluidStack.class, int.class);
|
||||
furanceRecipe = getConstructor("cofh.thermalexpansion.util.crafting.FurnaceManager$RecipeFurnace", ItemStack.class, ItemStack.class, int.class);
|
||||
pulverizerRecipe = getConstructor("cofh.thermalexpansion.util.crafting.PulverizerManager$RecipePulverizer", ItemStack.class, ItemStack.class, ItemStack.class, int.class, int.class);
|
||||
sawmillRecipe = getConstructor("cofh.thermalexpansion.util.crafting.SawmillManager$RecipeSawmill", ItemStack.class, ItemStack.class, ItemStack.class, int.class, int.class);
|
||||
smelterRecipe = getConstructor("cofh.thermalexpansion.util.crafting.SmelterManager$RecipeSmelter", ItemStack.class, ItemStack.class, ItemStack.class, ItemStack.class, int.class, int.class);
|
||||
transposerRecipe = getConstructor("cofh.thermalexpansion.util.crafting.TransposerManager$RecipeTransposer", ItemStack.class, ItemStack.class, FluidStack.class, int.class, int.class);
|
||||
} catch (Exception e) {}
|
||||
} catch (Exception e) { LogHelper.logError("Exception getting constructor for Thermal Expansion recipes!", e); }
|
||||
}
|
||||
|
||||
/** Need to perform this reflection on the fly as the map is ALWAYS changing, thanks to the way that te handles stuff */
|
||||
public static Map<List<ComparableItemStackSmelter>, RecipeSmelter> getSmelterMap() {
|
||||
try {
|
||||
smelter = getStaticObject(Class.forName("cofh.thermalexpansion.util.crafting.SmelterManager"), "recipeMap");
|
||||
smelterValid = getStaticObject(Class.forName("cofh.thermalexpansion.util.crafting.SmelterManager"), "validationSet");
|
||||
} catch (Exception e) {}
|
||||
|
||||
return smelter;
|
||||
}
|
||||
|
||||
public static Map<List<Integer>, RecipeTransposer> getFillMap() {
|
||||
try {
|
||||
transposerFill = getStaticObject(Class.forName("cofh.thermalexpansion.util.crafting.TransposerManager"), "recipeMapFill");
|
||||
transposerValid = getStaticObject(Class.forName("cofh.thermalexpansion.util.crafting.TransposerManager"), "validationSet");
|
||||
} catch (Exception e) {}
|
||||
|
||||
return transposerFill;
|
||||
}
|
||||
|
||||
public static Map<ComparableItemStackSafe, RecipeTransposer> getExtractMap() {
|
||||
try {
|
||||
transposerEmpty = getStaticObject(Class.forName("cofh.thermalexpansion.util.crafting.TransposerManager"), "recipeMapExtraction");
|
||||
transposerValid = getStaticObject(Class.forName("cofh.thermalexpansion.util.crafting.TransposerManager"), "validationSet");
|
||||
} catch (Exception e) {}
|
||||
|
||||
return transposerEmpty;
|
||||
}
|
||||
|
||||
public static boolean removeCrucibleRecipe(ItemStack input) {
|
||||
try {
|
||||
crucible = getStaticObject(Class.forName("cofh.thermalexpansion.util.crafting.CrucibleManager"), "recipeMap");
|
||||
} catch (Exception e) {}
|
||||
|
||||
return crucible.remove(new ComparableItemStackSafe(input)) != null;
|
||||
}
|
||||
|
||||
public static Object getTERecipe(Constructor constructor, Object... items) {
|
||||
public static <T> T getTERecipe(Constructor<T> constructor, Object... items) {
|
||||
try {
|
||||
return constructor.newInstance(items);
|
||||
} catch (Exception e) {}
|
||||
} catch (Exception e) { LogHelper.logError("Exception creating instance of Thermal Expansion recipe!", e); }
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -10,8 +10,17 @@ import minetweaker.api.player.IPlayer;
|
|||
import minetweaker.api.server.ICommandFunction;
|
||||
import modtweaker2.helpers.InputHelper;
|
||||
import modtweaker2.helpers.StringHelper;
|
||||
import modtweaker2.mods.thermalexpansion.ThermalHelper;
|
||||
import cofh.thermalexpansion.util.crafting.CrucibleManager;
|
||||
import cofh.thermalexpansion.util.crafting.CrucibleManager.RecipeCrucible;
|
||||
import cofh.thermalexpansion.util.crafting.FurnaceManager;
|
||||
import cofh.thermalexpansion.util.crafting.FurnaceManager.RecipeFurnace;
|
||||
import cofh.thermalexpansion.util.crafting.PulverizerManager;
|
||||
import cofh.thermalexpansion.util.crafting.PulverizerManager.RecipePulverizer;
|
||||
import cofh.thermalexpansion.util.crafting.SawmillManager;
|
||||
import cofh.thermalexpansion.util.crafting.SawmillManager.RecipeSawmill;
|
||||
import cofh.thermalexpansion.util.crafting.SmelterManager;
|
||||
import cofh.thermalexpansion.util.crafting.SmelterManager.RecipeSmelter;
|
||||
import cofh.thermalexpansion.util.crafting.TransposerManager;
|
||||
import cofh.thermalexpansion.util.crafting.TransposerManager.RecipeTransposer;
|
||||
|
||||
public class ThermalExpansionLogger implements ICommandFunction {
|
||||
|
@ -22,6 +31,7 @@ public class ThermalExpansionLogger implements ICommandFunction {
|
|||
validArguments.add("furnace");
|
||||
validArguments.add("pulverizer");
|
||||
validArguments.add("sawmill");
|
||||
validArguments.add("smelter");
|
||||
validArguments.add("transposer");
|
||||
}
|
||||
|
||||
|
@ -34,8 +44,62 @@ public class ThermalExpansionLogger implements ICommandFunction {
|
|||
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", ")));
|
||||
}
|
||||
} else {
|
||||
if(args.isEmpty() || args.contains("crucible")) {
|
||||
for(RecipeCrucible recipe : CrucibleManager.getRecipeList()) {
|
||||
MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Crucible.addRecipe(%d, %s, %s);",
|
||||
recipe.getEnergy(),
|
||||
InputHelper.getStackDescription(recipe.getInput()),
|
||||
InputHelper.getStackDescription(recipe.getOutput())));
|
||||
}
|
||||
}
|
||||
|
||||
if(args.isEmpty() || args.contains("furnace")) {
|
||||
for(RecipeFurnace recipe : FurnaceManager.getRecipeList()) {
|
||||
MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Furnace.addRecipe(%d, %s, %s);",
|
||||
recipe.getEnergy(),
|
||||
InputHelper.getStackDescription(recipe.getInput()),
|
||||
InputHelper.getStackDescription(recipe.getOutput())));
|
||||
}
|
||||
}
|
||||
|
||||
if(args.isEmpty() || args.contains("pulverizer")) {
|
||||
for(RecipePulverizer recipe : PulverizerManager.getRecipeList()) {
|
||||
if(recipe.getSecondaryOutput() != null) {
|
||||
MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Pulverizer.addRecipe(%d, %s, %s, %s, %d);",
|
||||
recipe.getEnergy(),
|
||||
InputHelper.getStackDescription(recipe.getInput()),
|
||||
InputHelper.getStackDescription(recipe.getPrimaryOutput()),
|
||||
InputHelper.getStackDescription(recipe.getSecondaryOutput()),
|
||||
recipe.getSecondaryOutputChance()));
|
||||
} else {
|
||||
MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Pulverizer.addRecipe(%d, %s, %s);",
|
||||
recipe.getEnergy(),
|
||||
InputHelper.getStackDescription(recipe.getInput()),
|
||||
InputHelper.getStackDescription(recipe.getPrimaryOutput())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(args.isEmpty() || args.contains("sawmill")) {
|
||||
for(RecipeSawmill recipe : SawmillManager.getRecipeList()) {
|
||||
if(recipe.getSecondaryOutput() != null) {
|
||||
MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Sawmill.addRecipe(%d, %s, %s, %s, %d);",
|
||||
recipe.getEnergy(),
|
||||
InputHelper.getStackDescription(recipe.getInput()),
|
||||
InputHelper.getStackDescription(recipe.getPrimaryOutput()),
|
||||
InputHelper.getStackDescription(recipe.getSecondaryOutput()),
|
||||
recipe.getSecondaryOutputChance()));
|
||||
} else {
|
||||
MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Sawmill.addRecipe(%d, %s, %s);",
|
||||
recipe.getEnergy(),
|
||||
InputHelper.getStackDescription(recipe.getInput()),
|
||||
InputHelper.getStackDescription(recipe.getPrimaryOutput())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(args.isEmpty() || args.contains("smelter")) {
|
||||
for(RecipeSmelter recipe : ThermalHelper.getSmelterMap().values()) {
|
||||
for(RecipeSmelter recipe : SmelterManager.getRecipeList()) {
|
||||
if(recipe.getSecondaryOutput() != null) {
|
||||
MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Smelter.addRecipe(%d, %s, %s, %s, %s, %d);",
|
||||
recipe.getEnergy(),
|
||||
|
@ -55,7 +119,7 @@ public class ThermalExpansionLogger implements ICommandFunction {
|
|||
}
|
||||
|
||||
if(args.isEmpty() || args.contains("transposer")) {
|
||||
for(RecipeTransposer recipe : ThermalHelper.getFillMap().values()) {
|
||||
for(RecipeTransposer recipe : TransposerManager.getFillRecipeList()) {
|
||||
MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Transposer.addFillRecipe(%d, %s, %s, %s);",
|
||||
recipe.getEnergy(),
|
||||
InputHelper.getStackDescription(recipe.getInput()),
|
||||
|
@ -63,7 +127,7 @@ public class ThermalExpansionLogger implements ICommandFunction {
|
|||
InputHelper.getStackDescription(recipe.getFluid())));
|
||||
}
|
||||
|
||||
for(RecipeTransposer recipe : ThermalHelper.getExtractMap().values()) {
|
||||
for(RecipeTransposer recipe : TransposerManager.getExtractionRecipeList()) {
|
||||
MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Transposer.addExtractRecipe(%d, %s, %s, %s, %d);",
|
||||
recipe.getEnergy(),
|
||||
InputHelper.getStackDescription(recipe.getInput()),
|
||||
|
|
|
@ -1,14 +1,22 @@
|
|||
package modtweaker2.mods.thermalexpansion.handlers;
|
||||
|
||||
import static modtweaker2.helpers.InputHelper.toFluid;
|
||||
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
||||
import static modtweaker2.helpers.InputHelper.toStack;
|
||||
import static modtweaker2.mods.thermalexpansion.ThermalHelper.removeCrucibleRecipe;
|
||||
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 minetweaker.api.liquid.ILiquidStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import modtweaker2.helpers.InputHelper;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.mods.thermalexpansion.ThermalHelper;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import cofh.thermalexpansion.util.crafting.CrucibleManager;
|
||||
|
@ -16,90 +24,103 @@ import cofh.thermalexpansion.util.crafting.CrucibleManager.RecipeCrucible;
|
|||
|
||||
@ZenClass("mods.thermalexpansion.Crucible")
|
||||
public class Crucible {
|
||||
|
||||
public static final String name = "Thermal Expansion Crucible";
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(int energy, IItemStack input, ILiquidStack output) {
|
||||
MineTweakerAPI.apply(new Add(energy, toStack(input), toFluid(output)));
|
||||
if(input == null || output == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||
return;
|
||||
}
|
||||
|
||||
if(CrucibleManager.recipeExists(toStack(input))) {
|
||||
LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", name, InputHelper.getStackDescription(toStack(input))));
|
||||
return;
|
||||
}
|
||||
|
||||
MineTweakerAPI.apply(new Add(ThermalHelper.getTERecipe(ThermalHelper.crucibleRecipe, toStack(input), toFluid(output), energy)));
|
||||
}
|
||||
|
||||
private static class Add implements IUndoableAction {
|
||||
ItemStack input;
|
||||
FluidStack output;
|
||||
int energy;
|
||||
boolean applied = false;
|
||||
private static class Add extends BaseListAddition<RecipeCrucible> {
|
||||
|
||||
public Add(int rf, ItemStack inp, FluidStack out) {
|
||||
energy = rf;
|
||||
input = inp;
|
||||
output = out;
|
||||
public Add(RecipeCrucible recipe) {
|
||||
super(Crucible.name, null);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
public void apply() {
|
||||
applied = CrucibleManager.addRecipe(energy, input, output);
|
||||
}
|
||||
|
||||
public boolean canUndo() {
|
||||
return input != null && applied;
|
||||
}
|
||||
|
||||
public String describe() {
|
||||
return "Adding TE Magma Crucible Recipe using " + input.getDisplayName();
|
||||
for(RecipeCrucible recipe : recipes) {
|
||||
boolean applied = CrucibleManager.addRecipe(
|
||||
recipe.getEnergy(),
|
||||
recipe.getInput(),
|
||||
recipe.getOutput());
|
||||
|
||||
if(applied) {
|
||||
successful.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void undo() {
|
||||
removeCrucibleRecipe(input);
|
||||
for(RecipeCrucible recipe : successful) {
|
||||
CrucibleManager.removeRecipe(recipe.getInput());
|
||||
}
|
||||
}
|
||||
|
||||
public String describeUndo() {
|
||||
return "Removing TE Magma Crucible Recipe using " + input.getDisplayName();
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(RecipeCrucible recipe) {
|
||||
return InputHelper.getStackDescription(recipe.getInput());
|
||||
}
|
||||
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IItemStack input) {
|
||||
|
||||
MineTweakerAPI.apply(new Remove(toStack(input)));
|
||||
public static void removeRecipe(IIngredient input) {
|
||||
List<RecipeCrucible> recipes = new LinkedList<RecipeCrucible>();
|
||||
|
||||
for(RecipeCrucible recipe : CrucibleManager.getRecipeList()) {
|
||||
if(recipe != null && matches(input, toIItemStack(recipe.getInput()))) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s.", name, input.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove implements IUndoableAction {
|
||||
ItemStack input;
|
||||
RecipeCrucible removed;
|
||||
private static class Remove extends BaseListRemoval<RecipeCrucible> {
|
||||
|
||||
public Remove(ItemStack inp) {
|
||||
input = inp;
|
||||
public Remove(List<RecipeCrucible> recipes) {
|
||||
super(Crucible.name, null, recipes);
|
||||
}
|
||||
|
||||
public void apply() {
|
||||
removed = CrucibleManager.getRecipe(input);
|
||||
removeCrucibleRecipe(input);
|
||||
}
|
||||
|
||||
public boolean canUndo() {
|
||||
return removed != null;
|
||||
}
|
||||
|
||||
public String describe() {
|
||||
return "Removing TE Magma Crucible Recipe using " + input.getDisplayName();
|
||||
for(RecipeCrucible recipe : recipes) {
|
||||
boolean removed = CrucibleManager.removeRecipe(recipe.getInput());
|
||||
|
||||
if(removed) {
|
||||
successful.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void undo() {
|
||||
CrucibleManager.addRecipe(removed.getEnergy(), removed.getInput(), removed.getOutput());
|
||||
for(RecipeCrucible recipe : successful) {
|
||||
CrucibleManager.addRecipe(
|
||||
recipe.getEnergy(),
|
||||
recipe.getInput(),
|
||||
recipe.getOutput());
|
||||
}
|
||||
}
|
||||
|
||||
public String describeUndo() {
|
||||
return "Restoring TE Magma Crucible Recipe using " + input.getDisplayName();
|
||||
}
|
||||
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(RecipeCrucible recipe) {
|
||||
return InputHelper.getStackDescription(recipe.getInput());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,21 @@
|
|||
package modtweaker2.mods.thermalexpansion.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.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import modtweaker2.helpers.InputHelper;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.mods.thermalexpansion.ThermalHelper;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import cofh.thermalexpansion.util.crafting.FurnaceManager;
|
||||
|
@ -12,94 +23,111 @@ import cofh.thermalexpansion.util.crafting.FurnaceManager.RecipeFurnace;
|
|||
|
||||
@ZenClass("mods.thermalexpansion.Furnace")
|
||||
public class Furnace {
|
||||
|
||||
public static final String name = "Thermal Expansion Furnace";
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(int energy, IItemStack input, IItemStack output) {
|
||||
|
||||
MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output)));
|
||||
if(input == null || output == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||
return;
|
||||
}
|
||||
|
||||
if(FurnaceManager.recipeExists(toStack(input))) {
|
||||
LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", name, InputHelper.getStackDescription(toStack(input))));
|
||||
return;
|
||||
}
|
||||
|
||||
MineTweakerAPI.apply(new Add(ThermalHelper.getTERecipe(ThermalHelper.furanceRecipe, toStack(input), toStack(output), energy)));
|
||||
}
|
||||
|
||||
private static class Add implements IUndoableAction {
|
||||
ItemStack input;
|
||||
ItemStack output;
|
||||
int energy;
|
||||
boolean applied = false;
|
||||
|
||||
public Add(int rf, ItemStack inp, ItemStack out) {
|
||||
energy = rf;
|
||||
input = inp;
|
||||
output = out;
|
||||
private static class Add extends BaseListAddition<RecipeFurnace> {
|
||||
public Add(RecipeFurnace recipe) {
|
||||
super(Furnace.name, null);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
public void apply() {
|
||||
FurnaceManager.addRecipe(energy, input, output, false);
|
||||
}
|
||||
for(RecipeFurnace recipe : recipes) {
|
||||
boolean applied = FurnaceManager.addRecipe(
|
||||
recipe.getEnergy(),
|
||||
recipe.getInput(),
|
||||
recipe.getOutput(),
|
||||
false);
|
||||
|
||||
if(applied) {
|
||||
successful.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canUndo() {
|
||||
return input != null;
|
||||
}
|
||||
|
||||
public String describe() {
|
||||
return "Adding Redstone Furnace Recipe using " + input.getDisplayName();
|
||||
}
|
||||
|
||||
public void undo() {
|
||||
FurnaceManager.removeRecipe(input);
|
||||
for(RecipeFurnace recipe : recipes) {
|
||||
FurnaceManager.removeRecipe(recipe.getInput());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String describeUndo() {
|
||||
return "Removing Redstone Furnace Recipe using " + input.getDisplayName();
|
||||
@Override
|
||||
protected String getRecipeInfo(RecipeFurnace recipe) {
|
||||
return InputHelper.getStackDescription(recipe.getOutput());
|
||||
}
|
||||
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IItemStack input) {
|
||||
public static void removeRecipe(IIngredient input) {
|
||||
List<RecipeFurnace> recipes = new LinkedList<RecipeFurnace>();
|
||||
|
||||
MineTweakerAPI.apply(new Remove(toStack(input)));
|
||||
for(RecipeFurnace recipe : FurnaceManager.getRecipeList()) {
|
||||
if(recipe != null && matches(input, toIItemStack(recipe.getInput()))) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s.", name, input.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove implements IUndoableAction {
|
||||
ItemStack input;
|
||||
RecipeFurnace removed;
|
||||
|
||||
public Remove(ItemStack inp) {
|
||||
input = inp;
|
||||
private static class Remove extends BaseListRemoval<RecipeFurnace> {
|
||||
public Remove(List<RecipeFurnace> recipes) {
|
||||
super(Furnace.name, null, recipes);
|
||||
}
|
||||
|
||||
public void apply() {
|
||||
removed = FurnaceManager.getRecipe(input);
|
||||
FurnaceManager.removeRecipe(input);
|
||||
}
|
||||
|
||||
public boolean canUndo() {
|
||||
return removed != null;
|
||||
}
|
||||
|
||||
public String describe() {
|
||||
return "Removing Redstone Furnace Recipe using " + input.getDisplayName();
|
||||
for(RecipeFurnace recipe : recipes) {
|
||||
boolean removed = FurnaceManager.removeRecipe(recipe.getInput());
|
||||
|
||||
if(removed) {
|
||||
successful.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void undo() {
|
||||
FurnaceManager.addRecipe(removed.getEnergy(), removed.getInput(), removed.getOutput(), false);
|
||||
}
|
||||
|
||||
public String describeUndo() {
|
||||
return "Restoring Redstone Furnace Recipe using " + input.getDisplayName();
|
||||
}
|
||||
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
for(RecipeFurnace recipe : successful) {
|
||||
FurnaceManager.addRecipe(
|
||||
recipe.getEnergy(),
|
||||
recipe.getInput(),
|
||||
recipe.getOutput(),
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(RecipeFurnace recipe) {
|
||||
return InputHelper.getStackDescription(recipe.getOutput());
|
||||
}
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void refreshRecipes() {
|
||||
|
@ -130,7 +158,5 @@ public class Furnace {
|
|||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,20 @@
|
|||
package modtweaker2.mods.thermalexpansion.handlers;
|
||||
|
||||
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
||||
import static modtweaker2.helpers.InputHelper.toStack;
|
||||
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 net.minecraft.item.ItemStack;
|
||||
import modtweaker2.helpers.InputHelper;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.mods.thermalexpansion.ThermalHelper;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import cofh.thermalexpansion.util.crafting.PulverizerManager;
|
||||
|
@ -12,101 +22,114 @@ import cofh.thermalexpansion.util.crafting.PulverizerManager.RecipePulverizer;
|
|||
|
||||
@ZenClass("mods.thermalexpansion.Pulverizer")
|
||||
public class Pulverizer {
|
||||
|
||||
public static final String name = "Thermal Expansion Pulverizer";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(int energy, IItemStack input, IItemStack output) {
|
||||
|
||||
MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output), null, 0));
|
||||
addRecipe(energy, input, output, null, 0);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(int energy, IItemStack input, IItemStack output, IItemStack secondary, int secondaryChance) {
|
||||
|
||||
MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output), toStack(secondary), secondaryChance));
|
||||
if(input == null || output == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||
return;
|
||||
}
|
||||
|
||||
if(PulverizerManager.recipeExists(toStack(input))) {
|
||||
LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", name, InputHelper.getStackDescription(toStack(input))));
|
||||
return;
|
||||
}
|
||||
|
||||
MineTweakerAPI.apply(new Add(ThermalHelper.getTERecipe(ThermalHelper.pulverizerRecipe, energy, toStack(input), toStack(output), toStack(secondary), secondaryChance)));
|
||||
}
|
||||
|
||||
private static class Add implements IUndoableAction {
|
||||
ItemStack input;
|
||||
ItemStack output;
|
||||
ItemStack secondary;
|
||||
int secondaryChance;
|
||||
int energy;
|
||||
boolean applied = false;
|
||||
|
||||
public Add(int rf, ItemStack inp, ItemStack out, ItemStack sec, int chance) {
|
||||
energy = rf;
|
||||
input = inp;
|
||||
output = out;
|
||||
secondary = sec;
|
||||
secondaryChance = chance;
|
||||
private static class Add extends BaseListAddition<RecipePulverizer> {
|
||||
public Add(RecipePulverizer recipe) {
|
||||
super(Pulverizer.name, null);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
public void apply() {
|
||||
applied = PulverizerManager.addRecipe(energy, input, output, secondary, secondaryChance);
|
||||
}
|
||||
|
||||
public boolean canUndo() {
|
||||
return input != null && applied;
|
||||
}
|
||||
|
||||
public String describe() {
|
||||
return "Adding Pulverizer Recipe using " + input.getDisplayName();
|
||||
for(RecipePulverizer recipe : recipes) {
|
||||
boolean applied = PulverizerManager.addRecipe(
|
||||
recipe.getEnergy(),
|
||||
recipe.getInput(),
|
||||
recipe.getPrimaryOutput(),
|
||||
recipe.getSecondaryOutput(),
|
||||
recipe.getSecondaryOutputChance());
|
||||
|
||||
if(applied) {
|
||||
successful.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void undo() {
|
||||
PulverizerManager.removeRecipe(input);
|
||||
for(RecipePulverizer recipe : successful) {
|
||||
PulverizerManager.removeRecipe(recipe.getInput());
|
||||
}
|
||||
}
|
||||
|
||||
public String describeUndo() {
|
||||
return "Removing Pulverizer Recipe using " + input.getDisplayName();
|
||||
@Override
|
||||
protected String getRecipeInfo(RecipePulverizer recipe) {
|
||||
return InputHelper.getStackDescription(recipe.getInput());
|
||||
}
|
||||
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IItemStack input) {
|
||||
|
||||
MineTweakerAPI.apply(new Remove(toStack(input)));
|
||||
public static void removeRecipe(IIngredient input) {
|
||||
List<RecipePulverizer> recipes = new LinkedList<RecipePulverizer>();
|
||||
RecipePulverizer[] list = PulverizerManager.getRecipeList();
|
||||
|
||||
for(RecipePulverizer recipe : list) {
|
||||
if(recipe != null && recipe.getInput() != null && matches(input, toIItemStack(recipe.getInput()))) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s.", name, input.toString()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class Remove implements IUndoableAction {
|
||||
ItemStack input;
|
||||
RecipePulverizer removed;
|
||||
|
||||
public Remove(ItemStack inp) {
|
||||
input = inp;
|
||||
private static class Remove extends BaseListRemoval<RecipePulverizer> {
|
||||
public Remove(List<RecipePulverizer> recipes) {
|
||||
super(Pulverizer.name, null, recipes);
|
||||
}
|
||||
|
||||
public void apply() {
|
||||
removed = PulverizerManager.getRecipe(input);
|
||||
PulverizerManager.removeRecipe(input);
|
||||
}
|
||||
|
||||
public boolean canUndo() {
|
||||
return removed != null;
|
||||
}
|
||||
|
||||
public String describe() {
|
||||
return "Removing Pulverizer Recipe using " + input.getDisplayName();
|
||||
for(RecipePulverizer recipe : recipes) {
|
||||
boolean removed = PulverizerManager.removeRecipe(recipe.getInput());
|
||||
|
||||
if(removed) {
|
||||
successful.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void undo() {
|
||||
PulverizerManager.addRecipe(removed.getEnergy(), removed.getInput(), removed.getPrimaryOutput(), removed.getSecondaryOutput(), removed.getSecondaryOutputChance());
|
||||
}
|
||||
|
||||
public String describeUndo() {
|
||||
return "Restoring Pulverizer Recipe using " + input.getDisplayName();
|
||||
}
|
||||
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
for(RecipePulverizer recipe : successful) {
|
||||
PulverizerManager.addRecipe(
|
||||
recipe.getEnergy(),
|
||||
recipe.getInput(),
|
||||
recipe.getPrimaryOutput(),
|
||||
recipe.getSecondaryOutput(),
|
||||
recipe.getSecondaryOutputChance());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(RecipePulverizer recipe) {
|
||||
return InputHelper.getStackDescription(recipe.getInput());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,20 @@
|
|||
package modtweaker2.mods.thermalexpansion.handlers;
|
||||
|
||||
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
||||
import static modtweaker2.helpers.InputHelper.toStack;
|
||||
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 net.minecraft.item.ItemStack;
|
||||
import modtweaker2.helpers.InputHelper;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.mods.thermalexpansion.ThermalHelper;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import cofh.thermalexpansion.util.crafting.SawmillManager;
|
||||
|
@ -12,99 +22,117 @@ import cofh.thermalexpansion.util.crafting.SawmillManager.RecipeSawmill;
|
|||
|
||||
@ZenClass("mods.thermalexpansion.Sawmill")
|
||||
public class Sawmill {
|
||||
|
||||
public static final String name = "Thermal Expansion Sawmill";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(int energy, IItemStack input, IItemStack output) {
|
||||
MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output), null, 0));
|
||||
addRecipe(energy, input, output, null, 0);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(int energy, IItemStack input, IItemStack output, IItemStack secondary, int secondaryChance) {
|
||||
MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output), toStack(secondary), secondaryChance));
|
||||
if(input == null || output == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||
return;
|
||||
}
|
||||
|
||||
if(SawmillManager.recipeExists(toStack(input))) {
|
||||
LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", name, InputHelper.getStackDescription(toStack(input))));
|
||||
return;
|
||||
}
|
||||
|
||||
MineTweakerAPI.apply(new Add(ThermalHelper.getTERecipe(ThermalHelper.sawmillRecipe, toStack(input), toStack(output), toStack(secondary), secondaryChance, energy)));
|
||||
}
|
||||
|
||||
private static class Add implements IUndoableAction {
|
||||
ItemStack input;
|
||||
ItemStack output;
|
||||
ItemStack secondary;
|
||||
int secondaryChance;
|
||||
int energy;
|
||||
boolean applied = false;
|
||||
|
||||
public Add(int rf, ItemStack inp, ItemStack out, ItemStack sec, int chance) {
|
||||
energy = rf;
|
||||
input = inp;
|
||||
output = out;
|
||||
secondary = sec;
|
||||
secondaryChance = chance;
|
||||
private static class Add extends BaseListAddition<RecipeSawmill> {
|
||||
public Add(RecipeSawmill recipe) {
|
||||
super(Sawmill.name, null);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
applied = SawmillManager.addRecipe(energy, input, output, secondary, secondaryChance);
|
||||
}
|
||||
|
||||
public boolean canUndo() {
|
||||
return input != null && applied;
|
||||
}
|
||||
|
||||
public String describe() {
|
||||
return "Adding Sawmill Recipe using " + input.getDisplayName();
|
||||
for(RecipeSawmill recipe : recipes) {
|
||||
boolean applied = SawmillManager.addRecipe(
|
||||
recipe.getEnergy(),
|
||||
recipe.getInput(),
|
||||
recipe.getPrimaryOutput(),
|
||||
recipe.getSecondaryOutput(),
|
||||
recipe.getSecondaryOutputChance());
|
||||
|
||||
if(applied) {
|
||||
successful.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
SawmillManager.removeRecipe(input);
|
||||
for(RecipeSawmill recipe : successful) {
|
||||
SawmillManager.removeRecipe(recipe.getInput());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String describeUndo() {
|
||||
return "Removing Sawmill Recipe using " + input.getDisplayName();
|
||||
}
|
||||
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
protected String getRecipeInfo(RecipeSawmill 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<RecipeSawmill> recipes = new LinkedList<RecipeSawmill>();
|
||||
RecipeSawmill[] list = SawmillManager.getRecipeList();
|
||||
|
||||
for(RecipeSawmill recipe : list) {
|
||||
if(recipe != null && recipe.getInput() != null && matches(input, toIItemStack(recipe.getInput()))) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s.", name, input.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove implements IUndoableAction {
|
||||
ItemStack input;
|
||||
RecipeSawmill removed;
|
||||
|
||||
public Remove(ItemStack inp) {
|
||||
input = inp;
|
||||
private static class Remove extends BaseListRemoval<RecipeSawmill> {
|
||||
public Remove(List<RecipeSawmill> recipes) {
|
||||
super(Sawmill.name, null, recipes);
|
||||
}
|
||||
|
||||
public void apply() {
|
||||
removed = SawmillManager.getRecipe(input);
|
||||
SawmillManager.removeRecipe(input);
|
||||
}
|
||||
|
||||
public boolean canUndo() {
|
||||
return removed != null;
|
||||
}
|
||||
|
||||
public String describe() {
|
||||
return "Removing Sawmill Recipe using " + input.getDisplayName();
|
||||
for(RecipeSawmill recipe : recipes) {
|
||||
boolean removed = SawmillManager.removeRecipe(recipe.getInput());
|
||||
if(removed) {
|
||||
successful.add(recipe);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void undo() {
|
||||
SawmillManager.addRecipe(removed.getEnergy(), removed.getInput(), removed.getPrimaryOutput(), removed.getSecondaryOutput(), removed.getSecondaryOutputChance());
|
||||
for(RecipeSawmill recipe : successful) {
|
||||
SawmillManager.addRecipe(
|
||||
recipe.getEnergy(),
|
||||
recipe.getInput(),
|
||||
recipe.getPrimaryOutput(),
|
||||
recipe.getSecondaryOutput(),
|
||||
recipe.getSecondaryOutputChance());
|
||||
}
|
||||
}
|
||||
|
||||
public String describeUndo() {
|
||||
return "Restoring Sawmill Recipe using " + input.getDisplayName();
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(RecipeSawmill recipe) {
|
||||
return InputHelper.getStackDescription(recipe.getInput());
|
||||
}
|
||||
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,11 +4,8 @@ import static modtweaker2.helpers.InputHelper.toIItemStack;
|
|||
import static modtweaker2.helpers.InputHelper.toStack;
|
||||
import static modtweaker2.helpers.StackHelper.matches;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
|
@ -16,19 +13,19 @@ import minetweaker.api.item.IItemStack;
|
|||
import modtweaker2.helpers.InputHelper;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.mods.thermalexpansion.ThermalHelper;
|
||||
import modtweaker2.utils.BaseMapAddition;
|
||||
import modtweaker2.utils.BaseMapRemoval;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import cofh.thermalexpansion.util.crafting.SmelterManager;
|
||||
import cofh.thermalexpansion.util.crafting.SmelterManager.ComparableItemStackSmelter;
|
||||
import cofh.thermalexpansion.util.crafting.SmelterManager.RecipeSmelter;
|
||||
|
||||
@ZenClass("mods.thermalexpansion.Smelter")
|
||||
public class Smelter {
|
||||
|
||||
public static final String name = "Thermal Expansion Smelter";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(int energy, IItemStack input, IItemStack input2, IItemStack output) {
|
||||
|
@ -37,90 +34,107 @@ public class Smelter {
|
|||
|
||||
@ZenMethod
|
||||
public static void addRecipe(int energy, IItemStack input, IItemStack input2, IItemStack output, IItemStack output2, int chance) {
|
||||
ItemStack in1 = toStack(input);
|
||||
ItemStack in2 = toStack(input2);
|
||||
ItemStack out1 = toStack(output);
|
||||
ItemStack out2 = toStack(output2);
|
||||
|
||||
List<ComparableItemStackSmelter> key = Arrays.asList(new ComparableItemStackSmelter[] { new ComparableItemStackSmelter(in1), new ComparableItemStackSmelter(in2) });
|
||||
RecipeSmelter value = (RecipeSmelter) ThermalHelper.getTERecipe(ThermalHelper.smelterRecipe, in1, in2, out1, out2, chance, energy);
|
||||
|
||||
Map<List<ComparableItemStackSmelter>, RecipeSmelter> recipes = new HashMap<List<ComparableItemStackSmelter>, RecipeSmelter>();
|
||||
|
||||
recipes.put(key, value);
|
||||
|
||||
MineTweakerAPI.apply(new Add(recipes));
|
||||
if(input == null || input2 == null || output == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||
return;
|
||||
}
|
||||
|
||||
if(SmelterManager.recipeExists(toStack(input), toStack(input2))) {
|
||||
LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s and %s. Command ignored!", name, InputHelper.getStackDescription(toStack(input)), InputHelper.getStackDescription(toStack(input2))));
|
||||
return;
|
||||
}
|
||||
|
||||
MineTweakerAPI.apply(new Add(ThermalHelper.getTERecipe(ThermalHelper.smelterRecipe, toStack(input), toStack(input2), toStack(output), toStack(output2), chance, energy)));
|
||||
}
|
||||
|
||||
private static class Add extends BaseMapAddition<List<ComparableItemStackSmelter>, RecipeSmelter> {
|
||||
public Add(Map<List<ComparableItemStackSmelter>, RecipeSmelter> recipes) {
|
||||
super(Smelter.name, ThermalHelper.getSmelterMap(), recipes);
|
||||
private static class Add extends BaseListAddition<RecipeSmelter> {
|
||||
public Add(RecipeSmelter recipe) {
|
||||
super(Smelter.name, null);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
map = ThermalHelper.getSmelterMap();
|
||||
super.apply();
|
||||
SmelterManager.refreshRecipes();
|
||||
for(RecipeSmelter recipe : recipes) {
|
||||
boolean applied = SmelterManager.addRecipe(
|
||||
recipe.getEnergy(),
|
||||
recipe.getPrimaryInput(),
|
||||
recipe.getSecondaryInput(),
|
||||
recipe.getPrimaryOutput(),
|
||||
recipe.getSecondaryOutput(),
|
||||
recipe.getSecondaryOutputChance());
|
||||
|
||||
if(applied) {
|
||||
successful.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
map = ThermalHelper.getSmelterMap();
|
||||
super.undo();
|
||||
SmelterManager.refreshRecipes();
|
||||
for(RecipeSmelter recipe : successful) {
|
||||
SmelterManager.removeRecipe(recipe.getPrimaryInput(), recipe.getSecondaryInput());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(Entry<List<ComparableItemStackSmelter>, RecipeSmelter> recipe) {
|
||||
return InputHelper.getStackDescription(recipe.getValue().getPrimaryOutput());
|
||||
public String getRecipeInfo(RecipeSmelter recipe) {
|
||||
return InputHelper.getStackDescription(recipe.getPrimaryOutput());
|
||||
}
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient input1, IIngredient input2) {
|
||||
Map<List<ComparableItemStackSmelter>, RecipeSmelter> recipes = new HashMap<List<ComparableItemStackSmelter>, RecipeSmelter>();
|
||||
List<RecipeSmelter> recipes = new LinkedList<RecipeSmelter>();
|
||||
|
||||
for(Entry<List<ComparableItemStackSmelter>, RecipeSmelter> entry : ThermalHelper.getSmelterMap().entrySet()) {
|
||||
RecipeSmelter recipe = entry.getValue();
|
||||
|
||||
for(RecipeSmelter recipe : SmelterManager.getRecipeList()) {
|
||||
if(recipe != null && matches(input1, toIItemStack(recipe.getPrimaryInput())) && matches(input2, toIItemStack(recipe.getSecondaryInput()))) {
|
||||
recipes.put(entry.getKey(), entry.getValue());
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipes found for %s and %s. Command ignored!", Smelter.name, input1.toString(), input2.toString()));
|
||||
LogHelper.logWarning(String.format("No %s Recipes found for %s and %s.", name, input1.toString(), input2.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove extends BaseMapRemoval<List<ComparableItemStackSmelter>, RecipeSmelter> {
|
||||
private static class Remove extends BaseListRemoval<RecipeSmelter> {
|
||||
|
||||
public Remove(Map<List<ComparableItemStackSmelter>, RecipeSmelter> recipes) {
|
||||
super(Smelter.name, ThermalHelper.getSmelterMap(), recipes);
|
||||
public Remove(List<RecipeSmelter> recipes) {
|
||||
super(Smelter.name, null, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
map = ThermalHelper.getSmelterMap();
|
||||
super.apply();
|
||||
SmelterManager.refreshRecipes();
|
||||
for(RecipeSmelter recipe : recipes) {
|
||||
boolean removed = SmelterManager.removeRecipe(recipe.getPrimaryInput(), recipe.getSecondaryInput());
|
||||
|
||||
if(removed) {
|
||||
successful.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
map = ThermalHelper.getSmelterMap();
|
||||
super.undo();
|
||||
SmelterManager.refreshRecipes();
|
||||
for(RecipeSmelter recipe : recipes) {
|
||||
SmelterManager.addRecipe(
|
||||
recipe.getEnergy(),
|
||||
recipe.getPrimaryInput(),
|
||||
recipe.getSecondaryInput(),
|
||||
recipe.getPrimaryOutput(),
|
||||
recipe.getSecondaryOutput(),
|
||||
recipe.getSecondaryOutputChance());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(Entry<List<ComparableItemStackSmelter>, RecipeSmelter> recipe) {
|
||||
return InputHelper.getStackDescription(recipe.getValue().getPrimaryOutput());
|
||||
public String getRecipeInfo(RecipeSmelter recipe) {
|
||||
return InputHelper.getStackDescription(recipe.getPrimaryOutput());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,26 +6,21 @@ import static modtweaker2.helpers.InputHelper.toILiquidStack;
|
|||
import static modtweaker2.helpers.InputHelper.toStack;
|
||||
import static modtweaker2.helpers.StackHelper.matches;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.item.IngredientAny;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import modtweaker2.helpers.InputHelper;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.mods.thermalexpansion.ThermalHelper;
|
||||
import modtweaker2.utils.BaseMapAddition;
|
||||
import modtweaker2.utils.BaseMapRemoval;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import cofh.lib.inventory.ComparableItemStackSafe;
|
||||
import cofh.thermalexpansion.util.crafting.TransposerManager;
|
||||
import cofh.thermalexpansion.util.crafting.TransposerManager.RecipeTransposer;
|
||||
|
||||
|
@ -39,170 +34,185 @@ public class Transposer {
|
|||
|
||||
@ZenMethod
|
||||
public static void addFillRecipe(int energy, IItemStack input, IItemStack output, ILiquidStack liquid) {
|
||||
Map<List<Integer>, RecipeTransposer> recipes = new HashMap<List<Integer>, RecipeTransposer>();
|
||||
ItemStack in = toStack(input);
|
||||
ItemStack out = toStack(output);
|
||||
FluidStack fluid = toFluid(liquid);
|
||||
List<Integer> key = Arrays.asList(new Integer[] { Integer.valueOf(new ComparableItemStackSafe(in).hashCode()), Integer.valueOf(fluid.fluidID) });
|
||||
RecipeTransposer value = (RecipeTransposer) ThermalHelper.getTERecipe(ThermalHelper.transposerRecipe, in, out, fluid, energy, 100);
|
||||
if(input == null || output == null || liquid == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameFill));
|
||||
return;
|
||||
}
|
||||
|
||||
recipes.put(key, value);
|
||||
|
||||
MineTweakerAPI.apply(new AddFill(recipes));
|
||||
if(TransposerManager.fillRecipeExists(toStack(input), toFluid(liquid))) {
|
||||
LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s and %s. Command ignored!", Transposer.nameFill, InputHelper.getStackDescription(toStack(input)), InputHelper.getStackDescription(toFluid(liquid))));
|
||||
return;
|
||||
}
|
||||
|
||||
MineTweakerAPI.apply(new Add(ThermalHelper.getTERecipe(ThermalHelper.transposerRecipe, toStack(input), toStack(output), toFluid(liquid), energy, 100), RecipeType.Fill));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addExtractRecipe(int energy, IItemStack input, IItemStack output, ILiquidStack liquid, int chance) {
|
||||
Map<ComparableItemStackSafe, RecipeTransposer> recipes = new HashMap<ComparableItemStackSafe, RecipeTransposer>();
|
||||
ItemStack in = toStack(input);
|
||||
ItemStack out = toStack(output);
|
||||
FluidStack fluid = toFluid(liquid);
|
||||
ComparableItemStackSafe key = new ComparableItemStackSafe(in);
|
||||
RecipeTransposer value = (RecipeTransposer) ThermalHelper.getTERecipe(ThermalHelper.transposerRecipe, in, out, fluid, energy, 100);
|
||||
if(input == null || output == null || liquid == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameExtract));
|
||||
return;
|
||||
}
|
||||
|
||||
recipes.put(key, value);
|
||||
|
||||
MineTweakerAPI.apply(new AddExtract(recipes));
|
||||
if(TransposerManager.extractionRecipeExists(toStack(input), toFluid(liquid))) {
|
||||
LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s and %s. Command ignored!", Transposer.nameExtract, InputHelper.getStackDescription(toStack(input)), InputHelper.getStackDescription(toFluid(liquid))));
|
||||
return;
|
||||
}
|
||||
|
||||
MineTweakerAPI.apply(new Add(ThermalHelper.getTERecipe(ThermalHelper.transposerRecipe, toStack(input), toStack(output), toFluid(liquid), energy, 100), RecipeType.Extract));
|
||||
}
|
||||
|
||||
private static class AddFill extends BaseMapAddition<List<Integer>, RecipeTransposer> {
|
||||
private static class Add extends BaseListAddition<RecipeTransposer> {
|
||||
private RecipeType type;
|
||||
|
||||
protected AddFill(Map<List<Integer>, RecipeTransposer> recipes) {
|
||||
super(Transposer.nameFill, ThermalHelper.getFillMap());
|
||||
recipes.putAll(recipes);
|
||||
protected Add(RecipeTransposer recipe, RecipeType type) {
|
||||
super(type == RecipeType.Fill ? Transposer.nameFill : Transposer.nameExtract, null);
|
||||
this.type = type;
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
map = ThermalHelper.getFillMap();
|
||||
super.apply();
|
||||
TransposerManager.refreshRecipes();
|
||||
for(RecipeTransposer recipe : recipes) {
|
||||
boolean applied = false;
|
||||
switch(type) {
|
||||
case Fill:
|
||||
applied = TransposerManager.addFillRecipe(
|
||||
recipe.getEnergy(),
|
||||
recipe.getInput(),
|
||||
recipe.getOutput(),
|
||||
recipe.getFluid(),
|
||||
false);
|
||||
break;
|
||||
|
||||
case Extract:
|
||||
applied = TransposerManager.addExtractionRecipe(
|
||||
recipe.getEnergy(),
|
||||
recipe.getInput(),
|
||||
recipe.getOutput(),
|
||||
recipe.getFluid(),
|
||||
recipe.getChance(),
|
||||
false);
|
||||
break;
|
||||
}
|
||||
|
||||
if(applied) {
|
||||
successful.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
map = ThermalHelper.getFillMap();
|
||||
super.undo();
|
||||
TransposerManager.refreshRecipes();
|
||||
for(RecipeTransposer recipe : successful) {
|
||||
switch(type)
|
||||
{
|
||||
case Fill:
|
||||
TransposerManager.removeFillRecipe(recipe.getInput(), recipe.getFluid());
|
||||
break;
|
||||
case Extract:
|
||||
TransposerManager.removeExtractionRecipe(recipe.getInput());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(Entry<List<Integer>, RecipeTransposer> recipe) {
|
||||
return InputHelper.getStackDescription(recipe.getValue().getOutput());
|
||||
protected String getRecipeInfo(RecipeTransposer recipe) {
|
||||
return InputHelper.getStackDescription(recipe.getInput());
|
||||
}
|
||||
}
|
||||
|
||||
private static class AddExtract extends BaseMapAddition<ComparableItemStackSafe, RecipeTransposer> {
|
||||
|
||||
protected AddExtract(Map<ComparableItemStackSafe, RecipeTransposer> recipes) {
|
||||
super(Transposer.nameFill, ThermalHelper.getExtractMap());
|
||||
recipes.putAll(recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
map = ThermalHelper.getExtractMap();
|
||||
super.apply();
|
||||
TransposerManager.refreshRecipes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
map = ThermalHelper.getExtractMap();
|
||||
super.undo();
|
||||
TransposerManager.refreshRecipes();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(Entry<ComparableItemStackSafe, RecipeTransposer> recipe) {
|
||||
return InputHelper.getStackDescription(recipe.getValue().getInput());
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeFillRecipe(IIngredient input, IIngredient liquid) {
|
||||
Map<List<Integer>, RecipeTransposer> recipes = new HashMap<List<Integer>, RecipeTransposer>();
|
||||
for(Entry<List<Integer>, RecipeTransposer> recipe : ThermalHelper.getFillMap().entrySet()) {
|
||||
if(recipe != null && recipe.getValue() != null && matches(input, toIItemStack(recipe.getValue().getInput())) && matches(liquid, toILiquidStack(recipe.getValue().getFluid()))) {
|
||||
recipes.put(recipe.getKey(), recipe.getValue());
|
||||
}
|
||||
}
|
||||
removeRecipe(input, liquid, RecipeType.Fill);
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new RemoveFill(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s and %s. Command ignored!", nameFill, input.toString(), liquid.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeExtractRecipe(IIngredient input) {
|
||||
Map<ComparableItemStackSafe, RecipeTransposer> recipes = new HashMap<ComparableItemStackSafe, RecipeTransposer>();
|
||||
for(Entry<ComparableItemStackSafe, RecipeTransposer> recipe : ThermalHelper.getExtractMap().entrySet()) {
|
||||
if(recipe != null && recipe.getValue() != null && matches(input, toIItemStack(recipe.getValue().getInput()))) {
|
||||
recipes.put(recipe.getKey(), recipe.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new RemoveExtract(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", nameFill, input.toString()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class RemoveFill extends BaseMapRemoval<List<Integer>, RecipeTransposer> {
|
||||
|
||||
protected RemoveFill(Map<List<Integer>, RecipeTransposer> recipes) {
|
||||
super(nameFill, ThermalHelper.getFillMap(), recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
map = ThermalHelper.getFillMap();
|
||||
super.apply();
|
||||
TransposerManager.refreshRecipes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
map = ThermalHelper.getFillMap();
|
||||
super.undo();
|
||||
TransposerManager.refreshRecipes();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(Entry<List<Integer>, RecipeTransposer> recipe) {
|
||||
return InputHelper.getStackDescription(recipe.getValue().getOutput());
|
||||
}
|
||||
removeRecipe(input, IngredientAny.INSTANCE, RecipeType.Extract);
|
||||
}
|
||||
|
||||
private static class RemoveExtract extends BaseMapRemoval<ComparableItemStackSafe, RecipeTransposer> {
|
||||
public static void removeRecipe(IIngredient input, IIngredient liquid, RecipeType type) {
|
||||
List<RecipeTransposer> recipes = new LinkedList<RecipeTransposer>();
|
||||
|
||||
for(RecipeTransposer recipe : type == RecipeType.Fill ? TransposerManager.getFillRecipeList() : TransposerManager.getExtractionRecipeList()) {
|
||||
if(recipe != null && matches(input, toIItemStack(recipe.getInput())) && matches(liquid, toILiquidStack(recipe.getFluid()))) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes, type));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s and %s.", type == RecipeType.Fill ? Transposer.nameFill : Transposer.nameExtract, input.toString(), liquid.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
protected RemoveExtract(Map<ComparableItemStackSafe, RecipeTransposer> recipes) {
|
||||
super(nameExtract, ThermalHelper.getExtractMap(), recipes);
|
||||
private static class Remove extends BaseListRemoval<RecipeTransposer> {
|
||||
private RecipeType type;
|
||||
|
||||
protected Remove(List<RecipeTransposer> recipes, RecipeType type) {
|
||||
super(type == RecipeType.Fill ? Transposer.nameFill : Transposer.nameExtract, null, recipes);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
map = ThermalHelper.getExtractMap();
|
||||
super.apply();
|
||||
TransposerManager.refreshRecipes();
|
||||
for(RecipeTransposer recipe : recipes) {
|
||||
boolean removed = false;
|
||||
switch(type) {
|
||||
case Fill:
|
||||
removed = TransposerManager.removeFillRecipe(recipe.getInput(), recipe.getFluid());
|
||||
break;
|
||||
case Extract:
|
||||
removed = TransposerManager.removeExtractionRecipe(recipe.getInput());
|
||||
break;
|
||||
}
|
||||
|
||||
if(removed) {
|
||||
successful.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
map = ThermalHelper.getExtractMap();
|
||||
super.undo();
|
||||
TransposerManager.refreshRecipes();
|
||||
for(RecipeTransposer recipe : successful) {
|
||||
switch(type) {
|
||||
case Fill:
|
||||
TransposerManager.addFillRecipe(
|
||||
recipe.getEnergy(),
|
||||
recipe.getInput(),
|
||||
recipe.getOutput(),
|
||||
recipe.getFluid(),
|
||||
false);
|
||||
break;
|
||||
|
||||
case Extract:
|
||||
TransposerManager.addExtractionRecipe(
|
||||
recipe.getEnergy(),
|
||||
recipe.getInput(),
|
||||
recipe.getOutput(),
|
||||
recipe.getFluid(),
|
||||
recipe.getChance(),
|
||||
false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(Entry<ComparableItemStackSafe, RecipeTransposer> recipe) {
|
||||
return InputHelper.getStackDescription(recipe.getValue().getInput());
|
||||
protected String getRecipeInfo(RecipeTransposer recipe) {
|
||||
return InputHelper.getStackDescription(recipe.getOutput());
|
||||
}
|
||||
}
|
||||
|
||||
protected enum RecipeType {
|
||||
Fill,
|
||||
Extract
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public abstract class BaseListModification<T> extends BaseUndoable {
|
|||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
if(list == null || recipes.isEmpty() || successful.isEmpty())
|
||||
if(recipes.isEmpty() || successful.isEmpty())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -33,7 +33,11 @@ public abstract class BaseListModification<T> extends BaseUndoable {
|
|||
sb.append(getRecipeInfo(recipe)).append(", ");
|
||||
}
|
||||
}
|
||||
sb.setLength(sb.length() - 2);
|
||||
|
||||
if(sb.length() > 0 ) {
|
||||
sb.setLength(sb.length() - 2);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,11 @@ public abstract class BaseMapModification<K, V> extends BaseUndoable {
|
|||
sb.append(getRecipeInfo(recipe)).append(", ");
|
||||
}
|
||||
}
|
||||
sb.setLength(sb.length() - 2);
|
||||
|
||||
if(sb.length() > 0) {
|
||||
sb.setLength(sb.length() - 2);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue