Close #435
This commit is contained in:
parent
04e5a559e0
commit
94d69f8ba5
3 changed files with 453 additions and 359 deletions
|
@ -1,38 +1,24 @@
|
||||||
package modtweaker.mods.embers.handlers;
|
package modtweaker.mods.embers.handlers;
|
||||||
|
|
||||||
import com.blamejared.mtlib.helpers.LogHelper;
|
import com.blamejared.mtlib.helpers.LogHelper;
|
||||||
import com.blamejared.mtlib.helpers.StackHelper;
|
import com.blamejared.mtlib.utils.*;
|
||||||
import com.blamejared.mtlib.utils.BaseListAddition;
|
|
||||||
import com.blamejared.mtlib.utils.BaseListRemoval;
|
|
||||||
import com.blamejared.mtlib.utils.BaseMapAddition;
|
|
||||||
import com.blamejared.mtlib.utils.BaseMapRemoval;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
import minetweaker.MineTweakerAPI;
|
||||||
import minetweaker.api.item.IIngredient;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
import minetweaker.api.item.IItemStack;
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import minetweaker.api.oredict.IOreDictEntry;
|
import minetweaker.api.oredict.IOreDictEntry;
|
||||||
import modtweaker.mods.embers.Embers;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import stanhebben.zenscript.annotations.Optional;
|
import stanhebben.zenscript.annotations.*;
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
import teamroots.embers.compat.jei.MeltingRecipeWrapper;
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
import teamroots.embers.recipe.*;
|
||||||
import teamroots.embers.recipe.ItemMeltingOreRecipe;
|
|
||||||
import teamroots.embers.recipe.ItemMeltingRecipe;
|
|
||||||
import teamroots.embers.recipe.RecipeRegistry;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import static com.blamejared.mtlib.helpers.InputHelper.*;
|
import static com.blamejared.mtlib.helpers.InputHelper.*;
|
||||||
import static com.blamejared.mtlib.helpers.StackHelper.matches;
|
|
||||||
|
|
||||||
@ZenClass("mods.embers.Melter")
|
@ZenClass("mods.embers.Melter")
|
||||||
public class Melter {
|
public class Melter {
|
||||||
|
|
||||||
public static String name = "Embers Melter";
|
public static String name = "Embers Melter";
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
|
@ -45,40 +31,10 @@ public class Melter {
|
||||||
MineTweakerAPI.apply(new AddOre(key.getName(), new ItemMeltingOreRecipe(key.getName(), toFluid(outputOne))));
|
MineTweakerAPI.apply(new AddOre(key.getName(), new ItemMeltingOreRecipe(key.getName(), toFluid(outputOne))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class AddOre extends BaseMapAddition<String, ItemMeltingOreRecipe> {
|
|
||||||
public AddOre(String stack, ItemMeltingOreRecipe recipe) {
|
|
||||||
super(Melter.name, RecipeRegistry.meltingOreRecipes);
|
|
||||||
|
|
||||||
this.recipes.put(stack, recipe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getRecipeInfo(Entry<String, ItemMeltingOreRecipe> arg0) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return arg0.getValue().getOreName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static class Add extends BaseMapAddition<ItemStack, ItemMeltingRecipe> {
|
|
||||||
public Add(ItemStack stack, ItemMeltingRecipe recipe) {
|
|
||||||
super(Melter.name, RecipeRegistry.meltingRecipes);
|
|
||||||
|
|
||||||
this.recipes.put(stack, recipe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getRecipeInfo(Entry<ItemStack, ItemMeltingRecipe> arg0) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return LogHelper.getStackDescription(arg0.getValue().getStack());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void remove(ILiquidStack fluid) {
|
public static void remove(ILiquidStack fluid) {
|
||||||
List<ItemStack> recipes = new ArrayList<ItemStack>();
|
List<ItemStack> recipes = new ArrayList<>();
|
||||||
List<String> oreRecipes = new ArrayList<String>();
|
List<String> oreRecipes = new ArrayList<>();
|
||||||
if(fluid == null) {
|
if(fluid == null) {
|
||||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||||
return;
|
return;
|
||||||
|
@ -109,21 +65,92 @@ public class Melter {
|
||||||
}
|
}
|
||||||
MineTweakerAPI.apply(new RemoveOre(map));
|
MineTweakerAPI.apply(new RemoveOre(map));
|
||||||
} else {
|
} else {
|
||||||
LogHelper.logWarning(String.format("No %s Recipe found for output %s. Command ignored!", Melter.name,
|
LogHelper.logWarning(String.format("No %s Recipe found for output %s. Command ignored!", Melter.name, fluid.toString()));
|
||||||
fluid.toString()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class AddOre extends BaseMapAddition<String, ItemMeltingOreRecipe> {
|
||||||
|
|
||||||
|
public AddOre(String stack, ItemMeltingOreRecipe recipe) {
|
||||||
|
super(Melter.name, RecipeRegistry.meltingOreRecipes);
|
||||||
|
|
||||||
|
this.recipes.put(stack, recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply() {
|
||||||
|
super.apply();
|
||||||
|
successful.forEach((stack, recipe) -> {
|
||||||
|
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(new MeltingRecipeWrapper(recipe));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void undo() {
|
||||||
|
super.undo();
|
||||||
|
successful.forEach((stack, recipe) -> {
|
||||||
|
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(new MeltingRecipeWrapper(recipe));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getRecipeInfo(Entry<String, ItemMeltingOreRecipe> arg0) {
|
||||||
|
return arg0.getValue().getOreName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Add extends BaseMapAddition<ItemStack, ItemMeltingRecipe> {
|
||||||
|
|
||||||
|
public Add(ItemStack stack, ItemMeltingRecipe recipe) {
|
||||||
|
super(Melter.name, RecipeRegistry.meltingRecipes);
|
||||||
|
this.recipes.put(stack, recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply() {
|
||||||
|
super.apply();
|
||||||
|
successful.forEach((stack, recipe) -> {
|
||||||
|
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(new MeltingRecipeWrapper(recipe));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void undo() {
|
||||||
|
super.undo();
|
||||||
|
successful.forEach((stack, recipe) -> {
|
||||||
|
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(new MeltingRecipeWrapper(recipe));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getRecipeInfo(Entry<ItemStack, ItemMeltingRecipe> arg0) {
|
||||||
|
return LogHelper.getStackDescription(arg0.getValue().getStack());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class Remove extends BaseMapRemoval<ItemStack, ItemMeltingRecipe> {
|
private static class Remove extends BaseMapRemoval<ItemStack, ItemMeltingRecipe> {
|
||||||
|
|
||||||
public Remove(Map<ItemStack, ItemMeltingRecipe> recipes) {
|
public Remove(Map<ItemStack, ItemMeltingRecipe> recipes) {
|
||||||
super(Melter.name, RecipeRegistry.meltingRecipes, recipes);
|
super(Melter.name, RecipeRegistry.meltingRecipes, recipes);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void apply() {
|
||||||
|
super.apply();
|
||||||
|
successful.forEach((stack, recipe) -> {
|
||||||
|
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(new MeltingRecipeWrapper(recipe));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void undo() {
|
||||||
|
super.undo();
|
||||||
|
successful.forEach((stack, recipe) -> {
|
||||||
|
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(new MeltingRecipeWrapper(recipe));
|
||||||
|
});
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
protected String getRecipeInfo(Entry<ItemStack, ItemMeltingRecipe> arg0) {
|
protected String getRecipeInfo(Entry<ItemStack, ItemMeltingRecipe> arg0) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return LogHelper.getStackDescription(arg0.getValue().getStack());
|
return LogHelper.getStackDescription(arg0.getValue().getStack());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,10 +160,23 @@ public class Melter {
|
||||||
public RemoveOre(Map<String, ItemMeltingOreRecipe> recipes) {
|
public RemoveOre(Map<String, ItemMeltingOreRecipe> recipes) {
|
||||||
super(Melter.name, RecipeRegistry.meltingOreRecipes, recipes);
|
super(Melter.name, RecipeRegistry.meltingOreRecipes, recipes);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void apply() {
|
||||||
|
super.apply();
|
||||||
|
successful.forEach((stack, recipe) -> {
|
||||||
|
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(new MeltingRecipeWrapper(recipe));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void undo() {
|
||||||
|
super.undo();
|
||||||
|
successful.forEach((stack, recipe) -> {
|
||||||
|
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(new MeltingRecipeWrapper(recipe));
|
||||||
|
});
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
protected String getRecipeInfo(Entry<String, ItemMeltingOreRecipe> arg0) {
|
protected String getRecipeInfo(Entry<String, ItemMeltingOreRecipe> arg0) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return arg0.getValue().getOreName();
|
return arg0.getValue().getOreName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,46 +1,26 @@
|
||||||
package modtweaker.mods.embers.handlers;
|
package modtweaker.mods.embers.handlers;
|
||||||
|
|
||||||
import com.blamejared.mtlib.helpers.LogHelper;
|
import com.blamejared.mtlib.helpers.LogHelper;
|
||||||
import com.blamejared.mtlib.helpers.StackHelper;
|
import com.blamejared.mtlib.utils.*;
|
||||||
import com.blamejared.mtlib.utils.BaseListAddition;
|
|
||||||
import com.blamejared.mtlib.utils.BaseListRemoval;
|
|
||||||
import com.blamejared.mtlib.utils.BaseMapAddition;
|
|
||||||
import com.blamejared.mtlib.utils.BaseMapRemoval;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
import minetweaker.MineTweakerAPI;
|
||||||
import minetweaker.api.item.IIngredient;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import minetweaker.api.oredict.IOreDictEntry;
|
|
||||||
import modtweaker.mods.embers.Embers;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import stanhebben.zenscript.annotations.Optional;
|
import stanhebben.zenscript.annotations.*;
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
import teamroots.embers.compat.jei.MixingRecipeWrapper;
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
import teamroots.embers.recipe.*;
|
||||||
import teamroots.embers.item.EnumStampType;
|
|
||||||
import teamroots.embers.recipe.FluidMixingRecipe;
|
|
||||||
import teamroots.embers.recipe.ItemMeltingOreRecipe;
|
|
||||||
import teamroots.embers.recipe.ItemMeltingRecipe;
|
|
||||||
import teamroots.embers.recipe.ItemStampingOreRecipe;
|
|
||||||
import teamroots.embers.recipe.ItemStampingRecipe;
|
|
||||||
import teamroots.embers.recipe.RecipeRegistry;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import static com.blamejared.mtlib.helpers.InputHelper.*;
|
import static com.blamejared.mtlib.helpers.InputHelper.toFluid;
|
||||||
import static com.blamejared.mtlib.helpers.StackHelper.matches;
|
|
||||||
|
|
||||||
@ZenClass("mods.embers.Mixer")
|
@ZenClass("mods.embers.Mixer")
|
||||||
public class Mixer {
|
public class Mixer {
|
||||||
|
|
||||||
public static String name = "Embers Mixer";
|
public static String name = "Embers Mixer";
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void addRecipe(ILiquidStack input1, ILiquidStack input2, ILiquidStack input3, ILiquidStack input4, ILiquidStack output) {
|
public static void addRecipe(ILiquidStack input1, ILiquidStack input2, ILiquidStack input3, ILiquidStack input4, ILiquidStack output) {
|
||||||
ArrayList<FluidStack> fluids = new ArrayList<FluidStack>();
|
ArrayList<FluidStack> fluids = new ArrayList<>();
|
||||||
if(input1 != null) {
|
if(input1 != null) {
|
||||||
fluids.add(toFluid(input1));
|
fluids.add(toFluid(input1));
|
||||||
}
|
}
|
||||||
|
@ -56,22 +36,10 @@ public class Mixer {
|
||||||
MineTweakerAPI.apply(new Add(new FluidMixingRecipe(fluids.toArray(new FluidStack[fluids.size()]), toFluid(output))));
|
MineTweakerAPI.apply(new Add(new FluidMixingRecipe(fluids.toArray(new FluidStack[fluids.size()]), toFluid(output))));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Add extends BaseListAddition<FluidMixingRecipe> {
|
|
||||||
public Add(FluidMixingRecipe recipe) {
|
|
||||||
super(Mixer.name, RecipeRegistry.mixingRecipes);
|
|
||||||
|
|
||||||
this.recipes.add(recipe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getRecipeInfo(FluidMixingRecipe arg0) {
|
|
||||||
return LogHelper.getStackDescription(arg0.output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void remove(ILiquidStack output) {
|
public static void remove(ILiquidStack output) {
|
||||||
List<FluidMixingRecipe> recipes = new ArrayList<FluidMixingRecipe>();
|
List<FluidMixingRecipe> recipes = new ArrayList<>();
|
||||||
|
|
||||||
for(int i = 0; i < RecipeRegistry.mixingRecipes.size(); i++) {
|
for(int i = 0; i < RecipeRegistry.mixingRecipes.size(); i++) {
|
||||||
if(RecipeRegistry.mixingRecipes.get(i).output.getFluid().getName().equals(toFluid(output).getFluid().getName())) {
|
if(RecipeRegistry.mixingRecipes.get(i).output.getFluid().getName().equals(toFluid(output).getFluid().getName())) {
|
||||||
|
@ -83,24 +51,64 @@ public class Mixer {
|
||||||
for(int i = 0; i < recipes.size(); i++) {
|
for(int i = 0; i < recipes.size(); i++) {
|
||||||
MineTweakerAPI.apply(new Remove(recipes.get(i)));
|
MineTweakerAPI.apply(new Remove(recipes.get(i)));
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
LogHelper.logWarning(String.format("No %s Recipe found for output %s. Command ignored!", Mixer.name, output.toString()));
|
||||||
LogHelper.logWarning(String.format("No %s Recipe found for output %s. Command ignored!", Mixer.name,
|
|
||||||
output.toString()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class Add extends BaseListAddition<FluidMixingRecipe> {
|
||||||
|
|
||||||
|
public Add(FluidMixingRecipe recipe) {
|
||||||
|
super(Mixer.name, RecipeRegistry.mixingRecipes);
|
||||||
|
this.recipes.add(recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply() {
|
||||||
|
super.apply();
|
||||||
|
successful.forEach(rec ->{
|
||||||
|
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(new MixingRecipeWrapper(rec));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void undo() {
|
||||||
|
super.undo();
|
||||||
|
successful.forEach(rec ->{
|
||||||
|
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(new MixingRecipeWrapper(rec));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getRecipeInfo(FluidMixingRecipe arg0) {
|
||||||
|
return LogHelper.getStackDescription(arg0.output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class Remove extends BaseListRemoval<FluidMixingRecipe> {
|
private static class Remove extends BaseListRemoval<FluidMixingRecipe> {
|
||||||
|
|
||||||
public Remove(FluidMixingRecipe recipe) {
|
public Remove(FluidMixingRecipe recipe) {
|
||||||
super(Mixer.name, RecipeRegistry.mixingRecipes);
|
super(Mixer.name, RecipeRegistry.mixingRecipes);
|
||||||
this.recipes.remove(recipe);
|
this.recipes.remove(recipe);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void apply() {
|
||||||
|
super.apply();
|
||||||
|
successful.forEach(rec ->{
|
||||||
|
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(new MixingRecipeWrapper(rec));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void undo() {
|
||||||
|
super.undo();
|
||||||
|
successful.forEach(rec ->{
|
||||||
|
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(new MixingRecipeWrapper(rec));
|
||||||
|
});
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
protected String getRecipeInfo(FluidMixingRecipe arg0) {
|
protected String getRecipeInfo(FluidMixingRecipe arg0) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return LogHelper.getStackDescription(arg0.output);
|
return LogHelper.getStackDescription(arg0.output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,56 +1,26 @@
|
||||||
package modtweaker.mods.embers.handlers;
|
package modtweaker.mods.embers.handlers;
|
||||||
|
|
||||||
import com.blamejared.mtlib.helpers.LogHelper;
|
import com.blamejared.mtlib.helpers.LogHelper;
|
||||||
import com.blamejared.mtlib.helpers.StackHelper;
|
import com.blamejared.mtlib.utils.*;
|
||||||
import com.blamejared.mtlib.utils.BaseListAddition;
|
|
||||||
import com.blamejared.mtlib.utils.BaseListRemoval;
|
|
||||||
import com.blamejared.mtlib.utils.BaseMapAddition;
|
|
||||||
import com.blamejared.mtlib.utils.BaseMapRemoval;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
import minetweaker.MineTweakerAPI;
|
||||||
import minetweaker.api.item.IIngredient;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
import minetweaker.api.item.IItemStack;
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import minetweaker.api.oredict.IOreDictEntry;
|
import minetweaker.api.oredict.IOreDictEntry;
|
||||||
import modtweaker.mods.embers.Embers;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import stanhebben.zenscript.annotations.*;
|
||||||
import stanhebben.zenscript.annotations.Optional;
|
import teamroots.embers.compat.jei.StampingRecipeWrapper;
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
|
||||||
import teamroots.embers.item.EnumStampType;
|
import teamroots.embers.item.EnumStampType;
|
||||||
import teamroots.embers.recipe.ItemMeltingOreRecipe;
|
import teamroots.embers.recipe.*;
|
||||||
import teamroots.embers.recipe.ItemMeltingRecipe;
|
|
||||||
import teamroots.embers.recipe.ItemStampingOreRecipe;
|
|
||||||
import teamroots.embers.recipe.ItemStampingRecipe;
|
|
||||||
import teamroots.embers.recipe.RecipeRegistry;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import static com.blamejared.mtlib.helpers.InputHelper.*;
|
import static com.blamejared.mtlib.helpers.InputHelper.*;
|
||||||
import static com.blamejared.mtlib.helpers.StackHelper.matches;
|
|
||||||
|
|
||||||
@ZenClass("mods.embers.Stamper")
|
@ZenClass("mods.embers.Stamper")
|
||||||
public class Stamper {
|
public class Stamper {
|
||||||
|
|
||||||
public static String name = "Embers Stamper";
|
public static String name = "Embers Stamper";
|
||||||
|
|
||||||
public static EnumStampType getStampFromString(String string){
|
|
||||||
switch (string){
|
|
||||||
default:
|
|
||||||
return EnumStampType.TYPE_NULL;
|
|
||||||
case "flat":
|
|
||||||
return EnumStampType.TYPE_FLAT;
|
|
||||||
case "bar":
|
|
||||||
return EnumStampType.TYPE_BAR;
|
|
||||||
case "plate":
|
|
||||||
return EnumStampType.TYPE_PLATE;
|
|
||||||
case "null":
|
|
||||||
return EnumStampType.TYPE_NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void addRecipe(IItemStack itemInput, ILiquidStack fluidInput, String stampType, IItemStack result, boolean matchMeta, boolean matchNBT) {
|
public static void addRecipe(IItemStack itemInput, ILiquidStack fluidInput, String stampType, IItemStack result, boolean matchMeta, boolean matchNBT) {
|
||||||
|
@ -62,35 +32,6 @@ public class Stamper {
|
||||||
MineTweakerAPI.apply(new AddOre(new ItemStampingOreRecipe(key.getName(), toFluid(fluidInput), getStampFromString(stampType), toStack(result), false, false)));
|
MineTweakerAPI.apply(new AddOre(new ItemStampingOreRecipe(key.getName(), toFluid(fluidInput), getStampFromString(stampType), toStack(result), false, false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class AddOre extends BaseListAddition<ItemStampingOreRecipe> {
|
|
||||||
public AddOre(ItemStampingOreRecipe recipe) {
|
|
||||||
super(Stamper.name, RecipeRegistry.stampingOreRecipes);
|
|
||||||
|
|
||||||
this.recipes.add(recipe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getRecipeInfo(ItemStampingOreRecipe arg0) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return arg0.getOre();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static class Add extends BaseListAddition<ItemStampingRecipe> {
|
|
||||||
public Add(ItemStampingRecipe recipe) {
|
|
||||||
super(Stamper.name, RecipeRegistry.stampingRecipes);
|
|
||||||
|
|
||||||
this.recipes.add(recipe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getRecipeInfo(ItemStampingRecipe arg0) {
|
|
||||||
return LogHelper.getStackDescription(arg0.getStack());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void remove(IItemStack item) {
|
public static void remove(IItemStack item) {
|
||||||
List<ItemStampingRecipe> recipes = new ArrayList<ItemStampingRecipe>();
|
List<ItemStampingRecipe> recipes = new ArrayList<ItemStampingRecipe>();
|
||||||
|
@ -115,25 +56,99 @@ public class Stamper {
|
||||||
|
|
||||||
if(!recipes.isEmpty()) {
|
if(!recipes.isEmpty()) {
|
||||||
MineTweakerAPI.apply(new Remove(recipes));
|
MineTweakerAPI.apply(new Remove(recipes));
|
||||||
}
|
} else if(!oreRecipes.isEmpty()) {
|
||||||
else if (!oreRecipes.isEmpty()) {
|
|
||||||
MineTweakerAPI.apply(new RemoveOre(oreRecipes));
|
MineTweakerAPI.apply(new RemoveOre(oreRecipes));
|
||||||
} else {
|
} else {
|
||||||
LogHelper.logWarning(String.format("No %s Recipe found for output %s. Command ignored!", Stamper.name,
|
LogHelper.logWarning(String.format("No %s Recipe found for output %s. Command ignored!", Stamper.name, item.toString()));
|
||||||
item.toString()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class AddOre extends BaseListAddition<ItemStampingOreRecipe> {
|
||||||
|
|
||||||
|
public AddOre(ItemStampingOreRecipe recipe) {
|
||||||
|
super(Stamper.name, RecipeRegistry.stampingOreRecipes);
|
||||||
|
|
||||||
|
this.recipes.add(recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply() {
|
||||||
|
super.apply();
|
||||||
|
successful.forEach(rec -> {
|
||||||
|
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(new StampingRecipeWrapper(rec));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void undo() {
|
||||||
|
super.undo();
|
||||||
|
successful.forEach(rec -> {
|
||||||
|
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(new StampingRecipeWrapper(rec));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getRecipeInfo(ItemStampingOreRecipe arg0) {
|
||||||
|
return arg0.getOre();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static class Add extends BaseListAddition<ItemStampingRecipe> {
|
||||||
|
|
||||||
|
public Add(ItemStampingRecipe recipe) {
|
||||||
|
super(Stamper.name, RecipeRegistry.stampingRecipes);
|
||||||
|
|
||||||
|
this.recipes.add(recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply() {
|
||||||
|
super.apply();
|
||||||
|
successful.forEach(rec -> {
|
||||||
|
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(new StampingRecipeWrapper(rec));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void undo() {
|
||||||
|
super.undo();
|
||||||
|
successful.forEach(rec -> {
|
||||||
|
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(new StampingRecipeWrapper(rec));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getRecipeInfo(ItemStampingRecipe arg0) {
|
||||||
|
return LogHelper.getStackDescription(arg0.getStack());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class Remove extends BaseListRemoval<ItemStampingRecipe> {
|
private static class Remove extends BaseListRemoval<ItemStampingRecipe> {
|
||||||
|
|
||||||
public Remove(List<ItemStampingRecipe> recipes) {
|
public Remove(List<ItemStampingRecipe> recipes) {
|
||||||
super(Stamper.name, RecipeRegistry.stampingRecipes, recipes);
|
super(Stamper.name, RecipeRegistry.stampingRecipes, recipes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply() {
|
||||||
|
super.apply();
|
||||||
|
successful.forEach(rec -> {
|
||||||
|
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(new StampingRecipeWrapper(rec));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void undo() {
|
||||||
|
super.undo();
|
||||||
|
successful.forEach(rec -> {
|
||||||
|
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(new StampingRecipeWrapper(rec));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getRecipeInfo(ItemStampingRecipe arg0) {
|
protected String getRecipeInfo(ItemStampingRecipe arg0) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return LogHelper.getStackDescription(arg0.getStack());
|
return LogHelper.getStackDescription(arg0.getStack());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,10 +159,41 @@ public class Stamper {
|
||||||
super(Stamper.name, RecipeRegistry.stampingOreRecipes, recipes);
|
super(Stamper.name, RecipeRegistry.stampingOreRecipes, recipes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply() {
|
||||||
|
super.apply();
|
||||||
|
successful.forEach(rec -> {
|
||||||
|
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(new StampingRecipeWrapper(rec));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void undo() {
|
||||||
|
super.undo();
|
||||||
|
successful.forEach(rec -> {
|
||||||
|
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(new StampingRecipeWrapper(rec));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getRecipeInfo(ItemStampingOreRecipe arg0) {
|
protected String getRecipeInfo(ItemStampingOreRecipe arg0) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return arg0.getOre();
|
return arg0.getOre();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static EnumStampType getStampFromString(String string) {
|
||||||
|
switch(string) {
|
||||||
|
default:
|
||||||
|
return EnumStampType.TYPE_NULL;
|
||||||
|
case "flat":
|
||||||
|
return EnumStampType.TYPE_FLAT;
|
||||||
|
case "bar":
|
||||||
|
return EnumStampType.TYPE_BAR;
|
||||||
|
case "plate":
|
||||||
|
return EnumStampType.TYPE_PLATE;
|
||||||
|
case "null":
|
||||||
|
return EnumStampType.TYPE_NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue