From 6f47542c306bec8d61d83cdff4fb11feade60a7d Mon Sep 17 00:00:00 2001 From: Turkey Date: Sun, 26 Apr 2015 22:14:35 -0400 Subject: [PATCH] - Added Ex-Nihilo unregisterAll options for the sieve --- .../mods/exnihilo/handlers/Sieve.java | 96 +++++++++++++++++-- 1 file changed, 87 insertions(+), 9 deletions(-) diff --git a/src/main/java/modtweaker2/mods/exnihilo/handlers/Sieve.java b/src/main/java/modtweaker2/mods/exnihilo/handlers/Sieve.java index 07a21fa..d9c8863 100644 --- a/src/main/java/modtweaker2/mods/exnihilo/handlers/Sieve.java +++ b/src/main/java/modtweaker2/mods/exnihilo/handlers/Sieve.java @@ -83,15 +83,26 @@ public class Sieve { } } - // TODO: Add other 2 remove methods that exNihilo provided - /* - * @ZenMethod public static void removeFirst(IItemStack output) { - * MineTweakerAPI.apply(new Remove(toStack(output), Position.FIRST)); } - * - * @ZenMethod public static void removeLast(IItemStack output) { - * MineTweakerAPI.apply(new Remove(toStack(output), Position.LAST)); } - */ + @ZenMethod + public static void removeRewardFromAllBlocks(IItemStack output) + { + Item theItem = toStack(output).getItem(); + int theMeta = toStack(output).getItemDamage(); + MineTweakerAPI.apply(new RemoveRewardFromAllBlocks(theItem, theMeta)); + } + + @ZenMethod + public static void removeAllRewardsFromBlock(IItemStack output) + { + if (isABlock(output)) { + Block theBlock = Block.getBlockFromItem(toStack(output).getItem()); + int theMeta = toStack(output).getItemDamage(); + MineTweakerAPI.apply(new RemoveAllRewardsFromBlock(theBlock, theMeta)); + } + } + + // Removes a recipe, apply is never the same for anything, so will always // need to override it @@ -100,7 +111,6 @@ public class Sieve { int sourceMeta; Item output; int outputMeta; - int rarity; public Remove(Block source, int sourceMeta, Item output, int outputMeta) { @@ -143,4 +153,72 @@ public class Sieve { SieveRegistry.register(this.source, this.sourceMeta, this.output, this.outputMeta, rarity); } } + + private static class RemoveAllRewardsFromBlock implements IUndoableAction { + Block block; + int blockMeta; + + public RemoveAllRewardsFromBlock(Block block, int blockMeta) { + this.block = block; + this.blockMeta = blockMeta; + } + + public void apply() { + SieveRegistry.unregisterAllRewardsFromBlock(block, blockMeta); + } + + public boolean canUndo() { + return false; + } + + public String describe() { + return "Removing All ExNihilo Sieve rewards from " + block.getLocalizedName(); + + } + + public String describeUndo() { + return ""; + } + + public Object getOverrideKey() { + return null; + } + + public void undo() { + } + } + + private static class RemoveRewardFromAllBlocks implements IUndoableAction { + Item reward; + int rewardMeta; + + public RemoveRewardFromAllBlocks(Item reward, int rewardMeta) { + this.reward = reward; + this.rewardMeta = rewardMeta; + } + + public void apply() { + SieveRegistry.unregisterRewardFromAllBlocks(reward, rewardMeta); + } + + public boolean canUndo() { + return false; + } + + public String describe() { + return "Removing ExNihilo Sieve reward of " + reward.getUnlocalizedName() + " from all Blocks"; + + } + + public String describeUndo() { + return ""; + } + + public Object getOverrideKey() { + return null; + } + + public void undo() { + } + } }