Add MineTweaker 3 Integration.
This commit is contained in:
parent
25bc226994
commit
772bcf1ee6
8 changed files with 648 additions and 0 deletions
|
@ -0,0 +1,146 @@
|
|||
package WayofTime.alchemicalWizardry.common.tweaker;
|
||||
|
||||
import static WayofTime.alchemicalWizardry.common.tweaker.MTHelper.toObjects;
|
||||
import static WayofTime.alchemicalWizardry.common.tweaker.MTHelper.toShapedObjects;
|
||||
import static WayofTime.alchemicalWizardry.common.tweaker.MTHelper.toStack;
|
||||
|
||||
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 net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import WayofTime.alchemicalWizardry.api.items.ShapedBloodOrbRecipe;
|
||||
|
||||
/**
|
||||
* MineTweaker3 Blood Orb Recipe Handler by joshie *
|
||||
*/
|
||||
@ZenClass("mods.bloodmagic.BloodOrb")
|
||||
public class BloodOrb
|
||||
{
|
||||
@ZenMethod
|
||||
public static void addShaped(IItemStack output, IIngredient[][] ingredients)
|
||||
{
|
||||
MineTweakerAPI.apply(new Add(false, toStack(output), toShapedObjects(ingredients)));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addShapeless(IItemStack output, IIngredient[] ingredients)
|
||||
{
|
||||
MineTweakerAPI.apply(new Add(true, toStack(output), toObjects(ingredients)));
|
||||
}
|
||||
|
||||
private static class Add implements IUndoableAction {
|
||||
private IRecipe iRecipe;
|
||||
private final boolean isShapeless;
|
||||
private final ItemStack output;
|
||||
private final Object[] recipe;
|
||||
|
||||
public Add(boolean isShapeless, ItemStack output, Object... recipe)
|
||||
{
|
||||
this.isShapeless = isShapeless;
|
||||
this.output = output;
|
||||
this.recipe = recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply()
|
||||
{
|
||||
if (isShapeless) iRecipe = new ShapedBloodOrbRecipe(output, recipe);
|
||||
else iRecipe = new ShapedBloodOrbRecipe(output, recipe);
|
||||
CraftingManager.getInstance().getRecipeList().add(iRecipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo()
|
||||
{
|
||||
return CraftingManager.getInstance().getRecipeList() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo()
|
||||
{
|
||||
CraftingManager.getInstance().getRecipeList().remove(iRecipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding Blood Orb Recipe for " + output.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo()
|
||||
{
|
||||
return "Removing Blood Orb Recipe for " + output.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IItemStack output) {
|
||||
MineTweakerAPI.apply(new Remove(toStack(output)));
|
||||
}
|
||||
|
||||
private static class Remove implements IUndoableAction {
|
||||
private final ItemStack output;
|
||||
private IRecipe iRecipe;
|
||||
|
||||
public Remove(ItemStack output)
|
||||
{
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply()
|
||||
{
|
||||
for (IRecipe r : (List<IRecipe>) CraftingManager.getInstance().getRecipeList())
|
||||
{
|
||||
if(r.getRecipeOutput() != null && r.getRecipeOutput().isItemEqual(output)) {
|
||||
iRecipe = r;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().remove(iRecipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo()
|
||||
{
|
||||
return CraftingManager.getInstance().getRecipeList() != null && iRecipe != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo()
|
||||
{
|
||||
CraftingManager.getInstance().getRecipeList().add(iRecipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing Blood Orb Recipe for " + output.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo()
|
||||
{
|
||||
return "Restoring Blood Orb Recipe for " + output.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue