Close #435
This commit is contained in:
parent
04e5a559e0
commit
94d69f8ba5
3 changed files with 453 additions and 359 deletions
|
@ -1,143 +1,183 @@
|
|||
package modtweaker.mods.embers.handlers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.helpers.StackHelper;
|
||||
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 com.blamejared.mtlib.utils.*;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import minetweaker.api.oredict.IOreDictEntry;
|
||||
import modtweaker.mods.embers.Embers;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import teamroots.embers.recipe.ItemMeltingOreRecipe;
|
||||
import teamroots.embers.recipe.ItemMeltingRecipe;
|
||||
import teamroots.embers.recipe.RecipeRegistry;
|
||||
import stanhebben.zenscript.annotations.*;
|
||||
import teamroots.embers.compat.jei.MeltingRecipeWrapper;
|
||||
import teamroots.embers.recipe.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static com.blamejared.mtlib.helpers.InputHelper.*;
|
||||
import static com.blamejared.mtlib.helpers.StackHelper.matches;
|
||||
|
||||
@ZenClass("mods.embers.Melter")
|
||||
public class Melter {
|
||||
public static String name = "Embers Melter";
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack input, ILiquidStack outputOne, boolean matchMeta, boolean matchNBT) {
|
||||
MineTweakerAPI.apply(new Add(toStack(input), new ItemMeltingRecipe(toStack(input),toFluid(outputOne), matchMeta, matchNBT)));
|
||||
}
|
||||
public static String name = "Embers Melter";
|
||||
|
||||
@ZenMethod
|
||||
public static void addOreRecipe(IOreDictEntry key, ILiquidStack outputOne, boolean matchMeta, boolean matchNBT) {
|
||||
MineTweakerAPI.apply(new AddOre(key.getName(), new ItemMeltingOreRecipe(key.getName(),toFluid(outputOne))));
|
||||
}
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack input, ILiquidStack outputOne, boolean matchMeta, boolean matchNBT) {
|
||||
MineTweakerAPI.apply(new Add(toStack(input), new ItemMeltingRecipe(toStack(input), toFluid(outputOne), matchMeta, matchNBT)));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addOreRecipe(IOreDictEntry key, ILiquidStack outputOne, boolean matchMeta, boolean matchNBT) {
|
||||
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);
|
||||
@ZenMethod
|
||||
public static void remove(ILiquidStack fluid) {
|
||||
List<ItemStack> recipes = new ArrayList<>();
|
||||
List<String> oreRecipes = new ArrayList<>();
|
||||
if(fluid == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||
return;
|
||||
}
|
||||
|
||||
this.recipes.put(stack, recipe);
|
||||
}
|
||||
for(int i = 0; i < RecipeRegistry.meltingRecipes.size(); i++) {
|
||||
if(((ItemMeltingRecipe) RecipeRegistry.meltingRecipes.values().toArray()[i]).getFluid().getFluid().getName().equals(toFluid(fluid).getFluid().getName())) {
|
||||
recipes.add(((ItemStack) RecipeRegistry.meltingRecipes.keySet().toArray()[i]));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(Entry<String, ItemMeltingOreRecipe> arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
return arg0.getValue().getOreName();
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < RecipeRegistry.meltingOreRecipes.size(); i++) {
|
||||
if(((ItemMeltingOreRecipe) RecipeRegistry.meltingOreRecipes.values().toArray()[i]).getFluid().getFluid().getName().equals(toFluid(fluid).getFluid().getName())) {
|
||||
oreRecipes.add(((String) RecipeRegistry.meltingOreRecipes.keySet().toArray()[i]));
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
Map<ItemStack, ItemMeltingRecipe> map = new HashMap<ItemStack, ItemMeltingRecipe>();
|
||||
for(int i = 0; i < recipes.size(); i++) {
|
||||
map.put(recipes.get(i), RecipeRegistry.meltingRecipes.get(recipes.get(i)));
|
||||
}
|
||||
MineTweakerAPI.apply(new Remove(map));
|
||||
} else if(!oreRecipes.isEmpty()) {
|
||||
Map<String, ItemMeltingOreRecipe> map = new HashMap<String, ItemMeltingOreRecipe>();
|
||||
for(int i = 0; i < oreRecipes.size(); i++) {
|
||||
map.put(oreRecipes.get(i), RecipeRegistry.meltingOreRecipes.get(oreRecipes.get(i)));
|
||||
}
|
||||
MineTweakerAPI.apply(new RemoveOre(map));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for output %s. Command ignored!", Melter.name, fluid.toString()));
|
||||
}
|
||||
|
||||
private static class Add extends BaseMapAddition<ItemStack, ItemMeltingRecipe> {
|
||||
public Add(ItemStack stack, ItemMeltingRecipe recipe) {
|
||||
super(Melter.name, RecipeRegistry.meltingRecipes);
|
||||
}
|
||||
|
||||
this.recipes.put(stack, recipe);
|
||||
}
|
||||
private static class AddOre extends BaseMapAddition<String, ItemMeltingOreRecipe> {
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(Entry<ItemStack, ItemMeltingRecipe> arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
return LogHelper.getStackDescription(arg0.getValue().getStack());
|
||||
}
|
||||
}
|
||||
public AddOre(String stack, ItemMeltingOreRecipe recipe) {
|
||||
super(Melter.name, RecipeRegistry.meltingOreRecipes);
|
||||
|
||||
@ZenMethod
|
||||
public static void remove(ILiquidStack fluid) {
|
||||
List<ItemStack> recipes = new ArrayList<ItemStack>();
|
||||
List<String> oreRecipes = new ArrayList<String>();
|
||||
if (fluid == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||
return;
|
||||
}
|
||||
this.recipes.put(stack, recipe);
|
||||
}
|
||||
|
||||
for (int i = 0; i < RecipeRegistry.meltingRecipes.size(); i ++){
|
||||
if (((ItemMeltingRecipe)RecipeRegistry.meltingRecipes.values().toArray()[i]).getFluid().getFluid().getName().equals(toFluid(fluid).getFluid().getName())){
|
||||
recipes.add(((ItemStack)RecipeRegistry.meltingRecipes.keySet().toArray()[i]));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void apply() {
|
||||
super.apply();
|
||||
successful.forEach((stack, recipe) -> {
|
||||
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(new MeltingRecipeWrapper(recipe));
|
||||
});
|
||||
}
|
||||
|
||||
for (int i = 0; i < RecipeRegistry.meltingOreRecipes.size(); i ++){
|
||||
if (((ItemMeltingOreRecipe)RecipeRegistry.meltingOreRecipes.values().toArray()[i]).getFluid().getFluid().getName().equals(toFluid(fluid).getFluid().getName())){
|
||||
oreRecipes.add(((String)RecipeRegistry.meltingOreRecipes.keySet().toArray()[i]));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void undo() {
|
||||
super.undo();
|
||||
successful.forEach((stack, recipe) -> {
|
||||
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(new MeltingRecipeWrapper(recipe));
|
||||
});
|
||||
}
|
||||
|
||||
if (!recipes.isEmpty()) {
|
||||
Map<ItemStack, ItemMeltingRecipe> map = new HashMap<ItemStack, ItemMeltingRecipe>();
|
||||
for (int i = 0; i < recipes.size(); i ++){
|
||||
map.put(recipes.get(i), RecipeRegistry.meltingRecipes.get(recipes.get(i)));
|
||||
}
|
||||
MineTweakerAPI.apply(new Remove(map));
|
||||
} else if (!oreRecipes.isEmpty()) {
|
||||
Map<String, ItemMeltingOreRecipe> map = new HashMap<String, ItemMeltingOreRecipe>();
|
||||
for (int i = 0; i < oreRecipes.size(); i ++){
|
||||
map.put(oreRecipes.get(i), RecipeRegistry.meltingOreRecipes.get(oreRecipes.get(i)));
|
||||
}
|
||||
MineTweakerAPI.apply(new RemoveOre(map));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for output %s. Command ignored!", Melter.name,
|
||||
fluid.toString()));
|
||||
}
|
||||
@Override
|
||||
protected String getRecipeInfo(Entry<String, ItemMeltingOreRecipe> arg0) {
|
||||
return arg0.getValue().getOreName();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private static class Add extends BaseMapAddition<ItemStack, ItemMeltingRecipe> {
|
||||
|
||||
private static class Remove extends BaseMapRemoval<ItemStack, ItemMeltingRecipe> {
|
||||
public Add(ItemStack stack, ItemMeltingRecipe recipe) {
|
||||
super(Melter.name, RecipeRegistry.meltingRecipes);
|
||||
this.recipes.put(stack, recipe);
|
||||
}
|
||||
|
||||
public Remove(Map<ItemStack, ItemMeltingRecipe> recipes) {
|
||||
super(Melter.name, RecipeRegistry.meltingRecipes, recipes);
|
||||
}
|
||||
@Override
|
||||
public void apply() {
|
||||
super.apply();
|
||||
successful.forEach((stack, recipe) -> {
|
||||
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(new MeltingRecipeWrapper(recipe));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(Entry<ItemStack, ItemMeltingRecipe> arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
return LogHelper.getStackDescription(arg0.getValue().getStack());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void undo() {
|
||||
super.undo();
|
||||
successful.forEach((stack, recipe) -> {
|
||||
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(new MeltingRecipeWrapper(recipe));
|
||||
});
|
||||
}
|
||||
|
||||
private static class RemoveOre extends BaseMapRemoval<String, ItemMeltingOreRecipe> {
|
||||
@Override
|
||||
protected String getRecipeInfo(Entry<ItemStack, ItemMeltingRecipe> arg0) {
|
||||
return LogHelper.getStackDescription(arg0.getValue().getStack());
|
||||
}
|
||||
}
|
||||
|
||||
public RemoveOre(Map<String, ItemMeltingOreRecipe> recipes) {
|
||||
super(Melter.name, RecipeRegistry.meltingOreRecipes, recipes);
|
||||
}
|
||||
private static class Remove extends BaseMapRemoval<ItemStack, ItemMeltingRecipe> {
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(Entry<String, ItemMeltingOreRecipe> arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
return arg0.getValue().getOreName();
|
||||
}
|
||||
}
|
||||
public Remove(Map<ItemStack, ItemMeltingRecipe> 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
|
||||
protected String getRecipeInfo(Entry<ItemStack, ItemMeltingRecipe> arg0) {
|
||||
return LogHelper.getStackDescription(arg0.getValue().getStack());
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveOre extends BaseMapRemoval<String, ItemMeltingOreRecipe> {
|
||||
|
||||
public RemoveOre(Map<String, ItemMeltingOreRecipe> 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
|
||||
protected String getRecipeInfo(Entry<String, ItemMeltingOreRecipe> arg0) {
|
||||
return arg0.getValue().getOreName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,107 +1,115 @@
|
|||
package modtweaker.mods.embers.handlers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.helpers.StackHelper;
|
||||
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 com.blamejared.mtlib.utils.*;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
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 stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
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 stanhebben.zenscript.annotations.*;
|
||||
import teamroots.embers.compat.jei.MixingRecipeWrapper;
|
||||
import teamroots.embers.recipe.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.*;
|
||||
|
||||
import static com.blamejared.mtlib.helpers.InputHelper.*;
|
||||
import static com.blamejared.mtlib.helpers.StackHelper.matches;
|
||||
import static com.blamejared.mtlib.helpers.InputHelper.toFluid;
|
||||
|
||||
@ZenClass("mods.embers.Mixer")
|
||||
public class Mixer {
|
||||
public static String name = "Embers Mixer";
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(ILiquidStack input1, ILiquidStack input2, ILiquidStack input3, ILiquidStack input4, ILiquidStack output) {
|
||||
ArrayList<FluidStack> fluids = new ArrayList<FluidStack>();
|
||||
if (input1 != null){
|
||||
fluids.add(toFluid(input1));
|
||||
}
|
||||
if (input2 != null){
|
||||
fluids.add(toFluid(input2));
|
||||
}
|
||||
if (input3 != null){
|
||||
fluids.add(toFluid(input3));
|
||||
}
|
||||
if (input4 != null){
|
||||
fluids.add(toFluid(input4));
|
||||
}
|
||||
MineTweakerAPI.apply(new Add(new FluidMixingRecipe(fluids.toArray(new FluidStack[fluids.size()]), toFluid(output))));
|
||||
}
|
||||
public static String name = "Embers Mixer";
|
||||
|
||||
private static class Add extends BaseListAddition<FluidMixingRecipe> {
|
||||
public Add(FluidMixingRecipe recipe) {
|
||||
super(Mixer.name, RecipeRegistry.mixingRecipes);
|
||||
@ZenMethod
|
||||
public static void addRecipe(ILiquidStack input1, ILiquidStack input2, ILiquidStack input3, ILiquidStack input4, ILiquidStack output) {
|
||||
ArrayList<FluidStack> fluids = new ArrayList<>();
|
||||
if(input1 != null) {
|
||||
fluids.add(toFluid(input1));
|
||||
}
|
||||
if(input2 != null) {
|
||||
fluids.add(toFluid(input2));
|
||||
}
|
||||
if(input3 != null) {
|
||||
fluids.add(toFluid(input3));
|
||||
}
|
||||
if(input4 != null) {
|
||||
fluids.add(toFluid(input4));
|
||||
}
|
||||
MineTweakerAPI.apply(new Add(new FluidMixingRecipe(fluids.toArray(new FluidStack[fluids.size()]), toFluid(output))));
|
||||
}
|
||||
|
||||
this.recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(FluidMixingRecipe arg0) {
|
||||
return LogHelper.getStackDescription(arg0.output);
|
||||
}
|
||||
}
|
||||
@ZenMethod
|
||||
public static void remove(ILiquidStack output) {
|
||||
List<FluidMixingRecipe> recipes = new ArrayList<>();
|
||||
|
||||
@ZenMethod
|
||||
public static void remove(ILiquidStack output) {
|
||||
List<FluidMixingRecipe> recipes = new ArrayList<FluidMixingRecipe>();
|
||||
for(int i = 0; i < RecipeRegistry.mixingRecipes.size(); i++) {
|
||||
if(RecipeRegistry.mixingRecipes.get(i).output.getFluid().getName().equals(toFluid(output).getFluid().getName())) {
|
||||
recipes.add(RecipeRegistry.mixingRecipes.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < RecipeRegistry.mixingRecipes.size(); i ++){
|
||||
if (RecipeRegistry.mixingRecipes.get(i).output.getFluid().getName().equals(toFluid(output).getFluid().getName())){
|
||||
recipes.add(RecipeRegistry.mixingRecipes.get(i));
|
||||
}
|
||||
}
|
||||
if(!recipes.isEmpty()) {
|
||||
for(int i = 0; i < recipes.size(); i++) {
|
||||
MineTweakerAPI.apply(new Remove(recipes.get(i)));
|
||||
}
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for output %s. Command ignored!", Mixer.name, output.toString()));
|
||||
}
|
||||
|
||||
if (!recipes.isEmpty()) {
|
||||
for (int i = 0; i < recipes.size(); i ++){
|
||||
MineTweakerAPI.apply(new Remove(recipes.get(i)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for output %s. Command ignored!", Mixer.name,
|
||||
output.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private static class Add extends BaseListAddition<FluidMixingRecipe> {
|
||||
|
||||
private static class Remove extends BaseListRemoval<FluidMixingRecipe> {
|
||||
public Add(FluidMixingRecipe recipe) {
|
||||
super(Mixer.name, RecipeRegistry.mixingRecipes);
|
||||
this.recipes.add(recipe);
|
||||
}
|
||||
|
||||
public Remove(FluidMixingRecipe recipe) {
|
||||
super(Mixer.name, RecipeRegistry.mixingRecipes);
|
||||
this.recipes.remove(recipe);
|
||||
}
|
||||
@Override
|
||||
public void apply() {
|
||||
super.apply();
|
||||
successful.forEach(rec ->{
|
||||
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(new MixingRecipeWrapper(rec));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(FluidMixingRecipe arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
return LogHelper.getStackDescription(arg0.output);
|
||||
}
|
||||
}
|
||||
@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> {
|
||||
|
||||
public Remove(FluidMixingRecipe recipe) {
|
||||
super(Mixer.name, RecipeRegistry.mixingRecipes);
|
||||
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
|
||||
protected String getRecipeInfo(FluidMixingRecipe arg0) {
|
||||
return LogHelper.getStackDescription(arg0.output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,153 +1,199 @@
|
|||
package modtweaker.mods.embers.handlers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.helpers.StackHelper;
|
||||
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 com.blamejared.mtlib.utils.*;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import minetweaker.api.oredict.IOreDictEntry;
|
||||
import modtweaker.mods.embers.Embers;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import stanhebben.zenscript.annotations.*;
|
||||
import teamroots.embers.compat.jei.StampingRecipeWrapper;
|
||||
import teamroots.embers.item.EnumStampType;
|
||||
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 teamroots.embers.recipe.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.*;
|
||||
|
||||
import static com.blamejared.mtlib.helpers.InputHelper.*;
|
||||
import static com.blamejared.mtlib.helpers.StackHelper.matches;
|
||||
|
||||
@ZenClass("mods.embers.Stamper")
|
||||
public class 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
|
||||
public static void addRecipe(IItemStack itemInput, ILiquidStack fluidInput, String stampType, IItemStack result, boolean matchMeta, boolean matchNBT) {
|
||||
MineTweakerAPI.apply(new Add(new ItemStampingRecipe(toStack(itemInput), toFluid(fluidInput), getStampFromString(stampType), toStack(result), matchMeta, matchNBT)));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IOreDictEntry key, ILiquidStack fluidInput, String stampType, IItemStack result) {
|
||||
MineTweakerAPI.apply(new AddOre(new ItemStampingOreRecipe(key.getName(), toFluid(fluidInput), getStampFromString(stampType), toStack(result), false, false)));
|
||||
}
|
||||
public static String name = "Embers Stamper";
|
||||
|
||||
|
||||
private static class AddOre extends BaseListAddition<ItemStampingOreRecipe> {
|
||||
public AddOre(ItemStampingOreRecipe recipe) {
|
||||
super(Stamper.name, RecipeRegistry.stampingOreRecipes);
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack itemInput, ILiquidStack fluidInput, String stampType, IItemStack result, boolean matchMeta, boolean matchNBT) {
|
||||
MineTweakerAPI.apply(new Add(new ItemStampingRecipe(toStack(itemInput), toFluid(fluidInput), getStampFromString(stampType), toStack(result), matchMeta, matchNBT)));
|
||||
}
|
||||
|
||||
this.recipes.add(recipe);
|
||||
}
|
||||
@ZenMethod
|
||||
public static void addRecipe(IOreDictEntry key, ILiquidStack fluidInput, String stampType, IItemStack result) {
|
||||
MineTweakerAPI.apply(new AddOre(new ItemStampingOreRecipe(key.getName(), toFluid(fluidInput), getStampFromString(stampType), toStack(result), false, false)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(ItemStampingOreRecipe arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
return arg0.getOre();
|
||||
}
|
||||
}
|
||||
@ZenMethod
|
||||
public static void remove(IItemStack item) {
|
||||
List<ItemStampingRecipe> recipes = new ArrayList<ItemStampingRecipe>();
|
||||
List<ItemStampingOreRecipe> oreRecipes = new ArrayList<ItemStampingOreRecipe>();
|
||||
|
||||
if(item == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0; i < RecipeRegistry.stampingRecipes.size(); i++) {
|
||||
if(ItemStack.areItemsEqual(RecipeRegistry.stampingRecipes.get(i).result, toStack(item))) {
|
||||
recipes.add(RecipeRegistry.stampingRecipes.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < RecipeRegistry.stampingOreRecipes.size(); i++) {
|
||||
if(ItemStack.areItemsEqual(RecipeRegistry.stampingOreRecipes.get(i).result, toStack(item))) {
|
||||
oreRecipes.add(RecipeRegistry.stampingOreRecipes.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes));
|
||||
} else if(!oreRecipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new RemoveOre(oreRecipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for output %s. Command ignored!", Stamper.name, 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);
|
||||
private static class Add extends BaseListAddition<ItemStampingRecipe> {
|
||||
|
||||
this.recipes.add(recipe);
|
||||
}
|
||||
public Add(ItemStampingRecipe recipe) {
|
||||
super(Stamper.name, RecipeRegistry.stampingRecipes);
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(ItemStampingRecipe arg0) {
|
||||
return LogHelper.getStackDescription(arg0.getStack());
|
||||
}
|
||||
}
|
||||
this.recipes.add(recipe);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void remove(IItemStack item) {
|
||||
List<ItemStampingRecipe> recipes = new ArrayList<ItemStampingRecipe>();
|
||||
List<ItemStampingOreRecipe> oreRecipes = new ArrayList<ItemStampingOreRecipe>();
|
||||
@Override
|
||||
public void apply() {
|
||||
super.apply();
|
||||
successful.forEach(rec -> {
|
||||
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(new StampingRecipeWrapper(rec));
|
||||
});
|
||||
}
|
||||
|
||||
if (item == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void undo() {
|
||||
super.undo();
|
||||
successful.forEach(rec -> {
|
||||
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(new StampingRecipeWrapper(rec));
|
||||
});
|
||||
}
|
||||
|
||||
for (int i = 0; i < RecipeRegistry.stampingRecipes.size(); i ++){
|
||||
if (ItemStack.areItemsEqual(RecipeRegistry.stampingRecipes.get(i).result,toStack(item))){
|
||||
recipes.add(RecipeRegistry.stampingRecipes.get(i));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected String getRecipeInfo(ItemStampingRecipe arg0) {
|
||||
return LogHelper.getStackDescription(arg0.getStack());
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < RecipeRegistry.stampingOreRecipes.size(); i ++){
|
||||
if (ItemStack.areItemsEqual(RecipeRegistry.stampingOreRecipes.get(i).result,toStack(item))){
|
||||
oreRecipes.add(RecipeRegistry.stampingOreRecipes.get(i));
|
||||
}
|
||||
}
|
||||
private static class Remove extends BaseListRemoval<ItemStampingRecipe> {
|
||||
|
||||
if (!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes));
|
||||
}
|
||||
else if (!oreRecipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new RemoveOre(oreRecipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for output %s. Command ignored!", Stamper.name,
|
||||
item.toString()));
|
||||
}
|
||||
public Remove(List<ItemStampingRecipe> recipes) {
|
||||
super(Stamper.name, RecipeRegistry.stampingRecipes, recipes);
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void apply() {
|
||||
super.apply();
|
||||
successful.forEach(rec -> {
|
||||
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(new StampingRecipeWrapper(rec));
|
||||
});
|
||||
}
|
||||
|
||||
private static class Remove extends BaseListRemoval<ItemStampingRecipe> {
|
||||
@Override
|
||||
public void undo() {
|
||||
super.undo();
|
||||
successful.forEach(rec -> {
|
||||
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(new StampingRecipeWrapper(rec));
|
||||
});
|
||||
}
|
||||
|
||||
public Remove(List<ItemStampingRecipe> recipes) {
|
||||
super(Stamper.name, RecipeRegistry.stampingRecipes, recipes);
|
||||
}
|
||||
@Override
|
||||
protected String getRecipeInfo(ItemStampingRecipe arg0) {
|
||||
return LogHelper.getStackDescription(arg0.getStack());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(ItemStampingRecipe arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
return LogHelper.getStackDescription(arg0.getStack());
|
||||
}
|
||||
}
|
||||
private static class RemoveOre extends BaseListRemoval<ItemStampingOreRecipe> {
|
||||
|
||||
private static class RemoveOre extends BaseListRemoval<ItemStampingOreRecipe> {
|
||||
public RemoveOre(List<ItemStampingOreRecipe> recipes) {
|
||||
super(Stamper.name, RecipeRegistry.stampingOreRecipes, recipes);
|
||||
}
|
||||
|
||||
public RemoveOre(List<ItemStampingOreRecipe> recipes) {
|
||||
super(Stamper.name, RecipeRegistry.stampingOreRecipes, recipes);
|
||||
}
|
||||
@Override
|
||||
public void apply() {
|
||||
super.apply();
|
||||
successful.forEach(rec -> {
|
||||
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(new StampingRecipeWrapper(rec));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(ItemStampingOreRecipe arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
return arg0.getOre();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void undo() {
|
||||
super.undo();
|
||||
successful.forEach(rec -> {
|
||||
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(new StampingRecipeWrapper(rec));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(ItemStampingOreRecipe arg0) {
|
||||
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