Merge remote-tracking branch 'upstream/master'
Conflicts: src/main/java/modtweaker2/mods/railcraft/handlers/CokeOven.java
This commit is contained in:
commit
149d52bb6c
1 changed files with 66 additions and 54 deletions
|
@ -8,79 +8,91 @@ 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 minetweaker.api.liquid.ILiquidStack;
|
||||
import mods.railcraft.api.crafting.ICokeOvenRecipe;
|
||||
import mods.railcraft.common.util.crafting.CokeOvenCraftingManager;
|
||||
import mods.railcraft.api.crafting.RailcraftCraftingManager;
|
||||
import mods.railcraft.common.util.crafting.CokeOvenCraftingManager.CokeOvenRecipe;
|
||||
import modtweaker2.helpers.InputHelper;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.mods.railcraft.RailcraftHelper;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
@ZenClass("mods.railcraft.CokeOven")
|
||||
public class CokeOven {
|
||||
|
||||
public static final String name = "Railcraft Coke Oven";
|
||||
public static final String name = "Railcraft Coke Oven";
|
||||
|
||||
/**
|
||||
* Adds a recipe for the Coke Oven
|
||||
*
|
||||
* @param itemOutput ItemStack result
|
||||
* @param fluidOutput FluidStack result
|
||||
* @param ingredient item input
|
||||
* @param timePerItem time per item to process
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack input, boolean matchDamage, boolean matchNBT, IItemStack output, ILiquidStack fluidOutput, int cookTime) {
|
||||
MineTweakerAPI.apply(new Add(toStack(input), matchDamage, matchNBT, toStack(output), toFluid(fluidOutput), cookTime));
|
||||
public static void addRecipe(IItemStack itemOutput, ILiquidStack fluidOutput, IItemStack ingredient, int timePerItem) {
|
||||
boolean matchEmptyNBT;
|
||||
if (toStack(ingredient).stackTagCompound == null)
|
||||
matchEmptyNBT = false;
|
||||
else
|
||||
matchEmptyNBT = true;
|
||||
|
||||
if (ingredient.getDamage() == OreDictionary.WILDCARD_VALUE)
|
||||
MineTweakerAPI.apply(new Add( new CokeOvenRecipe(toStack(ingredient), false, matchEmptyNBT, toStack(itemOutput), toFluid(fluidOutput), timePerItem) ));
|
||||
else
|
||||
MineTweakerAPI.apply(new Add( new CokeOvenRecipe(toStack(ingredient), true, matchEmptyNBT, toStack(itemOutput), toFluid(fluidOutput), timePerItem) ));
|
||||
}
|
||||
/**
|
||||
* Adds a recipe for the Coke Oven (Use this, if you want to have an Input strictly without NBT Data)
|
||||
*
|
||||
* @param itemOutput ItemStack result
|
||||
* @param fluidOutput FluidStack result
|
||||
* @param ingredient item input
|
||||
* @param matchEmptyNBT should the input only match an item with no NBT Data
|
||||
* @param timePerItem time per item to process
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack itemOutput, ILiquidStack fluidOutput, IItemStack ingredient, boolean matchEmptyNBT, int timePerItem) {
|
||||
if (ingredient.getDamage() == OreDictionary.WILDCARD_VALUE)
|
||||
MineTweakerAPI.apply(new Add( new CokeOvenRecipe(toStack(ingredient), false, matchEmptyNBT, toStack(itemOutput), toFluid(fluidOutput), timePerItem) ));
|
||||
else
|
||||
MineTweakerAPI.apply(new Add( new CokeOvenRecipe(toStack(ingredient), true, matchEmptyNBT, toStack(itemOutput), toFluid(fluidOutput), timePerItem) ));
|
||||
}
|
||||
|
||||
private static class Add implements IUndoableAction {
|
||||
/**
|
||||
* Adds a recipe for the Coke Oven
|
||||
*
|
||||
* @param ingredient item input
|
||||
* @param matchDamage should the recipe compare NBT Data
|
||||
* @param matchNBT should the recipe compare NBT Data
|
||||
* @param itemOutput ItemStack result
|
||||
* @param fluidOutput FluidStack result
|
||||
* @param cookTime time per item to process
|
||||
*/
|
||||
@Deprecated
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack input, boolean matchDamage, boolean matchNBT, IItemStack output, ILiquidStack fluidOutput, int cookTime) {
|
||||
MineTweakerAPI.apply(new Add( new CokeOvenRecipe(toStack(input), matchDamage, matchNBT, toStack(output), toFluid(fluidOutput), cookTime) ));
|
||||
}
|
||||
|
||||
private ItemStack stack;
|
||||
private boolean matchDamage;
|
||||
private boolean matchNBT;
|
||||
private ItemStack stack2;
|
||||
private FluidStack fluid;
|
||||
private int cookTime;
|
||||
private static class Add extends BaseListAddition<ICokeOvenRecipe> {
|
||||
|
||||
public Add(ItemStack stack, boolean matchDamage, boolean matchNBT, ItemStack stack2, FluidStack fluid, int cookTime) {
|
||||
this.stack = stack;
|
||||
this.matchDamage = matchDamage;
|
||||
this.matchNBT = matchNBT;
|
||||
this.stack2 = stack2;
|
||||
this.fluid = fluid;
|
||||
this.cookTime = cookTime;
|
||||
public Add(ICokeOvenRecipe recipe) {
|
||||
super(CokeOven.name, (List<ICokeOvenRecipe>)RailcraftCraftingManager.cokeOven.getRecipes());
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
CokeOvenCraftingManager.getInstance().addRecipe(stack, matchDamage, matchNBT, stack2, fluid, cookTime);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding a Railcraft CokeOven recipie for " + stack.getUnlocalizedName() + " and " + stack2.getUnlocalizedName() + "to get " + fluid.getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
|
||||
public String getRecipeInfo(ICokeOvenRecipe recipe) {
|
||||
return InputHelper.getStackDescription(recipe.getInput());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,12 +117,12 @@ public class CokeOven {
|
|||
|
||||
private static class Remove extends BaseListRemoval<ICokeOvenRecipe> {
|
||||
public Remove(List<ICokeOvenRecipe> recipes) {
|
||||
super("Coke Oven", (List<ICokeOvenRecipe>)RailcraftHelper.oven, recipes);
|
||||
super(CokeOven.name, (List<ICokeOvenRecipe>)RailcraftHelper.oven, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(ICokeOvenRecipe recipe) {
|
||||
return InputHelper.getStackDescription(recipe.getOutput());
|
||||
return InputHelper.getStackDescription(recipe.getInput());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue