mirror of
https://github.com/GTNewHorizons/BloodMagic.git
synced 2026-11-27 15:23:06 +00:00
137 lines
4.0 KiB
Java
137 lines
4.0 KiB
Java
package WayofTime.alchemicalWizardry.common.tweaker;
|
|
|
|
import static WayofTime.alchemicalWizardry.common.tweaker.MTHelper.toStack;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import minetweaker.IUndoableAction;
|
|
import minetweaker.MineTweakerAPI;
|
|
import minetweaker.api.item.IItemStack;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraftforge.oredict.OreDictionary;
|
|
|
|
import stanhebben.zenscript.annotations.ZenClass;
|
|
import stanhebben.zenscript.annotations.ZenMethod;
|
|
import WayofTime.alchemicalWizardry.common.summoning.meteor.MeteorParadigm;
|
|
import WayofTime.alchemicalWizardry.common.summoning.meteor.MeteorRegistry;
|
|
|
|
/**
|
|
* MineTweaker3 Falling Tower Paradigm Handler by hilburn *
|
|
*/
|
|
@ZenClass("mods.bloodmagic.FallingTower")
|
|
public class FallingTower {
|
|
|
|
@ZenMethod
|
|
public static void addFocus(IItemStack stack, int radius, String[] components) {
|
|
MineTweakerAPI.apply(new Add(toStack(stack), radius, 10000, components));
|
|
}
|
|
|
|
@ZenMethod
|
|
public static void addFocus(IItemStack stack, int radius, String components) {
|
|
MineTweakerAPI.apply(new Add(toStack(stack), radius, 10000, components.split("\\s*,\\s*")));
|
|
}
|
|
|
|
@ZenMethod
|
|
public static void addFocus(IItemStack stack, int radius, int cost, String[] components) {
|
|
MineTweakerAPI.apply(new Add(toStack(stack), radius, cost, components));
|
|
}
|
|
|
|
@ZenMethod
|
|
public static void addFocus(IItemStack stack, int radius, int cost, String components) {
|
|
MineTweakerAPI.apply(new Add(toStack(stack), radius, cost, components.split("\\s*,\\s*")));
|
|
}
|
|
|
|
@ZenMethod
|
|
public static void removeFocus(IItemStack output) {
|
|
MineTweakerAPI.apply(new Remove(toStack(output)));
|
|
}
|
|
|
|
private static class Add implements IUndoableAction {
|
|
|
|
private MeteorParadigm paradigm;
|
|
|
|
public Add(ItemStack stack, int radius, int cost, String[] components) {
|
|
paradigm = new MeteorParadigm(stack, radius, cost);
|
|
paradigm.parseStringArray(components);
|
|
}
|
|
|
|
@Override
|
|
public void apply() {
|
|
MeteorRegistry.registerMeteorParadigm(paradigm);
|
|
}
|
|
|
|
@Override
|
|
public boolean canUndo() {
|
|
return MeteorRegistry.paradigmList != null;
|
|
}
|
|
|
|
@Override
|
|
public void undo() {
|
|
MeteorRegistry.paradigmList.remove(paradigm);
|
|
}
|
|
|
|
@Override
|
|
public String describe() {
|
|
return "Adding Falling Tower Focus for " + paradigm.focusStack.getDisplayName();
|
|
}
|
|
|
|
@Override
|
|
public String describeUndo() {
|
|
return "Removing Falling Tower Focus for " + paradigm.focusStack.getDisplayName();
|
|
}
|
|
|
|
@Override
|
|
public Object getOverrideKey() {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
private static class Remove implements IUndoableAction {
|
|
|
|
private final ItemStack focus;
|
|
private MeteorParadigm paradigm;
|
|
|
|
public Remove(ItemStack focus) {
|
|
this.focus = focus;
|
|
}
|
|
|
|
@Override
|
|
public void apply() {
|
|
for (Iterator<MeteorParadigm> itr = MeteorRegistry.paradigmList.iterator(); itr.hasNext();) {
|
|
MeteorParadigm paradigm = itr.next();
|
|
if (OreDictionary.itemMatches(paradigm.focusStack, focus, false)) {
|
|
this.paradigm = paradigm;
|
|
itr.remove();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public boolean canUndo() {
|
|
return MeteorRegistry.paradigmList != null && paradigm != null;
|
|
}
|
|
|
|
@Override
|
|
public void undo() {
|
|
MeteorRegistry.paradigmList.add(paradigm);
|
|
}
|
|
|
|
@Override
|
|
public String describe() {
|
|
return "Removing Falling Tower Focus for " + focus.getDisplayName();
|
|
}
|
|
|
|
@Override
|
|
public String describeUndo() {
|
|
return "Restoring Falling Tower Focus for " + focus.getDisplayName();
|
|
}
|
|
|
|
@Override
|
|
public Object getOverrideKey() {
|
|
return null;
|
|
}
|
|
}
|
|
}
|