mirror of
https://github.com/GTNewHorizons/BloodMagic.git
synced 2026-11-27 15:23:06 +00:00
* disable blood frame recipe * Nuking the Blood Frame * bs+sa --------- Co-authored-by: Alastors <[email protected]>
152 lines
4.7 KiB
Java
152 lines
4.7 KiB
Java
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.ArrayList;
|
|
import java.util.List;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.item.crafting.CraftingManager;
|
|
import net.minecraft.item.crafting.IRecipe;
|
|
|
|
import WayofTime.alchemicalWizardry.api.items.ShapedBloodOrbRecipe;
|
|
import WayofTime.alchemicalWizardry.api.items.ShapelessBloodOrbRecipe;
|
|
import minetweaker.IUndoableAction;
|
|
import minetweaker.MineTweakerAPI;
|
|
import minetweaker.api.item.IIngredient;
|
|
import minetweaker.api.item.IItemStack;
|
|
import stanhebben.zenscript.annotations.ZenClass;
|
|
import stanhebben.zenscript.annotations.ZenMethod;
|
|
|
|
/**
|
|
* MineTweaker3 Blood Orb Recipe Handler by joshie *
|
|
*/
|
|
@ZenClass("mods.bloodmagic.BloodOrb")
|
|
public class BloodOrb {
|
|
|
|
public static List<IUndoableAction> lateAdditions = new ArrayList<>();
|
|
public static List<IUndoableAction> lateRemovals = new ArrayList<>();
|
|
|
|
public static void applyAdditionsAndRemovals() {
|
|
for (IUndoableAction toRemove : lateRemovals) {
|
|
MineTweakerAPI.apply(toRemove);
|
|
}
|
|
for (IUndoableAction toAdd : lateAdditions) {
|
|
MineTweakerAPI.apply(toAdd);
|
|
}
|
|
|
|
lateAdditions.clear();
|
|
}
|
|
|
|
@ZenMethod
|
|
public static void addShaped(IItemStack output, IIngredient[][] ingredients) {
|
|
lateAdditions.add(new Add(false, toStack(output), toShapedObjects(ingredients)));
|
|
}
|
|
|
|
@ZenMethod
|
|
public static void addShapeless(IItemStack output, IIngredient[] ingredients) {
|
|
lateAdditions.add((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 ShapelessBloodOrbRecipe(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) {
|
|
lateRemovals.add(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 instanceof ShapedBloodOrbRecipe || r instanceof ShapelessBloodOrbRecipe)
|
|
&& 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;
|
|
}
|
|
}
|
|
}
|