Merge pull request #125 from Turkey2349/master

Small tweaks and updates for Ex-Nihilo and Railcraft
This commit is contained in:
Yulife committed 2015-04-27 07:32:44 +02:00
commit a557ddaa9e
3 files changed
+171 -48

No files matched your search

@@ -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() {
}
}
}
@@ -2,63 +2,108 @@ package modtweaker2.mods.railcraft.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import java.lang.reflect.Field;
import java.util.List;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
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.common.util.crafting.CokeOvenCraftingManager.CokeOvenRecipe;
import modtweaker2.mods.railcraft.RailcraftHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.railcraft.CokeOven")
public class CokeOven {
@ZenMethod
public static void addRecipe(IItemStack input, boolean matchDamage, boolean matchNBT, IItemStack output, ILiquidStack fluidOutput, int cookTime) {
MineTweakerAPI.apply(new Add(RailcraftHelper.getCokeOvenRecipe(toStack(input), matchDamage, matchNBT, toStack(output), toFluid(fluidOutput), cookTime)));
}
@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));
}
private static class Add extends BaseListAddition {
public Add(ICokeOvenRecipe recipe) {
super("Coke Oven", RailcraftHelper.oven, recipe);
}
private static class Add implements IUndoableAction {
@Override
public String getRecipeInfo() {
return ((ICokeOvenRecipe) recipe).getOutput().getDisplayName();
}
}
private ItemStack stack;
private boolean matchDamage;
private boolean matchNBT;
private ItemStack stack2;
private FluidStack fluid;
private int cookTime;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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;
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
@Override
public void apply() {
CokeOvenCraftingManager.getInstance().addRecipe(stack, matchDamage, matchNBT, stack2, fluid, cookTime);
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Coke Oven", RailcraftHelper.oven, stack);
}
}
@Override
public void apply() {
for (ICokeOvenRecipe r : RailcraftHelper.oven) {
if (r.getOutput() != null && areEqual(r.getOutput(), stack)) {
recipe = r;
break;
}
}
@Override
public boolean canUndo() {
return false;
}
RailcraftHelper.oven.remove(recipe);
}
@Override
public String describe() {
return "Adding a Railcraft CokeOven recipie for " + stack.getUnlocalizedName() + " and " + stack2.getUnlocalizedName() + "to get " + fluid.getUnlocalizedName();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
@Override
public String describeUndo() {
return null;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public void undo() {
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Coke Oven", RailcraftHelper.oven, stack);
}
@Override
public void apply() {
for (ICokeOvenRecipe r : RailcraftHelper.oven) {
if (r.getOutput() != null && r.getOutput().getItem().equals(stack)) {
recipe = r;
break;
}
}
RailcraftHelper.oven.remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}