From fd9bf8b080ad92039e134c396a75adfa8e958a95 Mon Sep 17 00:00:00 2001 From: Stan Hebben Date: Sun, 29 Jun 2014 18:36:29 +0200 Subject: [PATCH] - Improved IC2 implementation - Fixed multiply operator on liquid stacks --- .../java/minetweaker/api/item/IItemStack.java | 6 + .../api/item/WeightedItemStack.java | 69 +++++ .../minetweaker/api/liquid/ILiquidStack.java | 3 + .../minetweaker/expand/ExpandItemStack.java | 24 ++ .../java/minetweaker/runtime/Tweaker.java | 28 +- .../minetweaker/mc164/item/MCItemStack.java | 37 +++ .../mc164/oredict/MCOreDictEntry.java | 17 +- .../minetweaker/mc1710/item/MCItemStack.java | 37 +++ .../mc1710/oredict/MCOreDictEntry.java | 17 +- .../minetweaker/mc172/item/MCItemStack.java | 37 +++ .../mc172/oredict/MCOreDictEntry.java | 17 +- .../minetweaker/mods/ic2/machines/Canner.java | 259 ++++++++++++++++++ .../mods/ic2/machines/MatterAmplifier.java | 35 +++ .../mods/ic2/machines/Recycler.java | 81 ++++++ .../mods/ic2/machines/ScrapBox.java | 90 ++++++ .../mods/ic2/machines/SemiFluidGenerator.java | 91 ++++++ .../main/java/minetweaker/mods/nei/NEI.java | 2 +- 17 files changed, 843 insertions(+), 7 deletions(-) create mode 100644 MineTweaker3-API/src/main/java/minetweaker/api/item/WeightedItemStack.java create mode 100644 MineTweaker3-API/src/main/java/minetweaker/expand/ExpandItemStack.java create mode 100644 MineTweaker3-MC172-Mod-IC2/src/main/java/minetweaker/mods/ic2/machines/Canner.java create mode 100644 MineTweaker3-MC172-Mod-IC2/src/main/java/minetweaker/mods/ic2/machines/MatterAmplifier.java create mode 100644 MineTweaker3-MC172-Mod-IC2/src/main/java/minetweaker/mods/ic2/machines/Recycler.java create mode 100644 MineTweaker3-MC172-Mod-IC2/src/main/java/minetweaker/mods/ic2/machines/ScrapBox.java create mode 100644 MineTweaker3-MC172-Mod-IC2/src/main/java/minetweaker/mods/ic2/machines/SemiFluidGenerator.java diff --git a/MineTweaker3-API/src/main/java/minetweaker/api/item/IItemStack.java b/MineTweaker3-API/src/main/java/minetweaker/api/item/IItemStack.java index b18dfa4..880a5e2 100644 --- a/MineTweaker3-API/src/main/java/minetweaker/api/item/IItemStack.java +++ b/MineTweaker3-API/src/main/java/minetweaker/api/item/IItemStack.java @@ -49,6 +49,12 @@ public interface IItemStack extends IIngredient { @ZenMethod public IItemStack amount(int amount); + @ZenOperator(OperatorType.MOD) + public WeightedItemStack percent(float p); + + @ZenMethod + public WeightedItemStack weight(float p); + @ZenMethod public IIngredient anyDamage(); diff --git a/MineTweaker3-API/src/main/java/minetweaker/api/item/WeightedItemStack.java b/MineTweaker3-API/src/main/java/minetweaker/api/item/WeightedItemStack.java new file mode 100644 index 0000000..f2bf42d --- /dev/null +++ b/MineTweaker3-API/src/main/java/minetweaker/api/item/WeightedItemStack.java @@ -0,0 +1,69 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package minetweaker.api.item; + +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenGetter; + +/** + * + * @author Stan + */ +@ZenClass("minetweaker.item.WeightedItemStack") +public final class WeightedItemStack { + private final IItemStack stack; + private final float p; + + public WeightedItemStack(IItemStack stack, float p) { + this.stack = stack; + this.p = p; + } + + @ZenGetter("stack") + public IItemStack getStack() { + return stack; + } + + @ZenGetter("chance") + public float getChance() { + return p; + } + + @ZenGetter("percent") + public float getPercent() { + return p * 100; + } + + // ############################# + // ### Object implementation ### + // ############################# + @Override + public int hashCode() { + int hash = 7; + hash = 29 * hash + (this.stack != null ? this.stack.hashCode() : 0); + hash = 29 * hash + Float.floatToIntBits(this.p); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final WeightedItemStack other = (WeightedItemStack) obj; + if (this.stack != other.stack && (this.stack == null || !this.stack.equals(other.stack))) { + return false; + } + if (Float.floatToIntBits(this.p) != Float.floatToIntBits(other.p)) { + return false; + } + return true; + } +} diff --git a/MineTweaker3-API/src/main/java/minetweaker/api/liquid/ILiquidStack.java b/MineTweaker3-API/src/main/java/minetweaker/api/liquid/ILiquidStack.java index d48f13e..2df1a69 100644 --- a/MineTweaker3-API/src/main/java/minetweaker/api/liquid/ILiquidStack.java +++ b/MineTweaker3-API/src/main/java/minetweaker/api/liquid/ILiquidStack.java @@ -7,9 +7,11 @@ package minetweaker.api.liquid; import minetweaker.api.data.IData; +import stanhebben.zenscript.annotations.OperatorType; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenGetter; import stanhebben.zenscript.annotations.ZenMethod; +import stanhebben.zenscript.annotations.ZenOperator; /** * @@ -50,6 +52,7 @@ public interface ILiquidStack { @ZenMethod public ILiquidStack withTag(IData data); + @ZenOperator(OperatorType.MUL) @ZenMethod public ILiquidStack withAmount(int amount); diff --git a/MineTweaker3-API/src/main/java/minetweaker/expand/ExpandItemStack.java b/MineTweaker3-API/src/main/java/minetweaker/expand/ExpandItemStack.java new file mode 100644 index 0000000..ffac22c --- /dev/null +++ b/MineTweaker3-API/src/main/java/minetweaker/expand/ExpandItemStack.java @@ -0,0 +1,24 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package minetweaker.expand; + +import minetweaker.api.item.IItemStack; +import minetweaker.api.item.WeightedItemStack; +import stanhebben.zenscript.annotations.ZenCaster; +import stanhebben.zenscript.annotations.ZenExpansion; + +/** + * + * @author Stan + */ +@ZenExpansion("minetweaker.item.IItemStack") +public class ExpandItemStack { + @ZenCaster + public static WeightedItemStack asWeightedItemStack(IItemStack value) { + return new WeightedItemStack(value, 1.0f); + } +} diff --git a/MineTweaker3-API/src/main/java/minetweaker/runtime/Tweaker.java b/MineTweaker3-API/src/main/java/minetweaker/runtime/Tweaker.java index f57071b..0766a04 100644 --- a/MineTweaker3-API/src/main/java/minetweaker/runtime/Tweaker.java +++ b/MineTweaker3-API/src/main/java/minetweaker/runtime/Tweaker.java @@ -14,6 +14,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -36,7 +37,8 @@ import stanhebben.zenscript.parser.ParseException; */ public class Tweaker implements IMineTweaker { private final List actions = new ArrayList(); - private final Set wereStuck = new HashSet(); + private final Set wereStuck = new LinkedHashSet(); + private final Map stuckOverridable = new HashMap(); private IScriptProvider scriptProvider; private byte[] scriptData; @@ -44,8 +46,23 @@ public class Tweaker implements IMineTweaker { @Override public void apply(IUndoableAction action) { MineTweakerAPI.logger.logInfo(action.describe()); - action.apply(); - actions.add(action); + + Object overrideKey = action.getOverrideKey(); + if (wereStuck.contains(action)) { + wereStuck.remove(action); + + if (overrideKey != null) { + stuckOverridable.remove(overrideKey); + } + } else { + if (overrideKey != null && stuckOverridable.containsKey(overrideKey)) { + wereStuck.remove(stuckOverridable.get(overrideKey)); + stuckOverridable.remove(overrideKey); + } + + action.apply(); + actions.add(action); + } } @Override @@ -65,6 +82,11 @@ public class Tweaker implements IMineTweaker { MineTweakerAPI.logger.logInfo("[Stuck] " + action.describe()); stuck.add(0, action); wereStuck.add(action); + + Object overrideKey = action.getOverrideKey(); + if (overrideKey != null) { + stuckOverridable.put(overrideKey, action); + } } } actions.clear(); diff --git a/MineTweaker3-MC164-Main/src/main/java/minetweaker/mc164/item/MCItemStack.java b/MineTweaker3-MC164-Main/src/main/java/minetweaker/mc164/item/MCItemStack.java index 1f8b2f0..f7cdfa2 100644 --- a/MineTweaker3-MC164-Main/src/main/java/minetweaker/mc164/item/MCItemStack.java +++ b/MineTweaker3-MC164-Main/src/main/java/minetweaker/mc164/item/MCItemStack.java @@ -18,6 +18,7 @@ import minetweaker.api.item.IItemDefinition; import minetweaker.api.item.IItemStack; import minetweaker.api.item.IItemTransformer; import minetweaker.api.item.IngredientItem; +import minetweaker.api.item.WeightedItemStack; import minetweaker.api.liquid.ILiquidStack; import static minetweaker.api.minecraft.MineTweakerMC.getItemStack; import minetweaker.mc164.actions.SetTranslationAction; @@ -182,6 +183,16 @@ public class MCItemStack implements IItemStack { public IItemStack amount(int amount) { return withAmount(amount); } + + @Override + public WeightedItemStack percent(float chance) { + return new WeightedItemStack(this, chance * 0.01f); + } + + @Override + public WeightedItemStack weight(float chance) { + return new WeightedItemStack(this, chance); + } @Override public IIngredient transform(IItemTransformer transformer) { @@ -233,6 +244,32 @@ public class MCItemStack implements IItemStack { // ### Object implementation ### // ############################# + @Override + public int hashCode() { + int hash = 7; + hash = 41 * hash + (this.stack != null ? this.stack.hashCode() : 0); + hash = 41 * hash + (this.wildcardSize ? 1 : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final MCItemStack other = (MCItemStack) obj; + if (this.stack != other.stack && (this.stack == null || !this.stack.equals(other.stack))) { + return false; + } + if (this.wildcardSize != other.wildcardSize) { + return false; + } + return true; + } + @Override public String toString() { StringBuilder result = new StringBuilder(); diff --git a/MineTweaker3-MC164-Main/src/main/java/minetweaker/mc164/oredict/MCOreDictEntry.java b/MineTweaker3-MC164-Main/src/main/java/minetweaker/mc164/oredict/MCOreDictEntry.java index 3cca380..96c80d8 100644 --- a/MineTweaker3-MC164-Main/src/main/java/minetweaker/mc164/oredict/MCOreDictEntry.java +++ b/MineTweaker3-MC164-Main/src/main/java/minetweaker/mc164/oredict/MCOreDictEntry.java @@ -29,7 +29,7 @@ import net.minecraftforge.oredict.OreDictionary; * @author Stan */ public class MCOreDictEntry implements IOreDictEntry { - private final Integer id; + private final int id; public MCOreDictEntry(Integer id) { this.id = id; @@ -166,6 +166,21 @@ public class MCOreDictEntry implements IOreDictEntry { return OreDictionary.getOreName(id); } + // ############################# + // ### Object implementation ### + // ############################# + + @Override + public int hashCode() { + return id; + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof MCOreDictEntry)) return false; + return ((MCOreDictEntry) other).id == id; + } + // ###################### // ### Action classes ### // ###################### diff --git a/MineTweaker3-MC1710-Main/src/main/java/minetweaker/mc1710/item/MCItemStack.java b/MineTweaker3-MC1710-Main/src/main/java/minetweaker/mc1710/item/MCItemStack.java index 63d4bf5..a59efd8 100644 --- a/MineTweaker3-MC1710-Main/src/main/java/minetweaker/mc1710/item/MCItemStack.java +++ b/MineTweaker3-MC1710-Main/src/main/java/minetweaker/mc1710/item/MCItemStack.java @@ -18,6 +18,7 @@ import minetweaker.api.item.IItemDefinition; import minetweaker.api.item.IItemStack; import minetweaker.api.item.IItemTransformer; import minetweaker.api.item.IngredientItem; +import minetweaker.api.item.WeightedItemStack; import minetweaker.api.liquid.ILiquidStack; import static minetweaker.api.minecraft.MineTweakerMC.getItemStack; import minetweaker.mc1710.actions.SetTranslationAction; @@ -183,6 +184,16 @@ public class MCItemStack implements IItemStack { public IItemStack amount(int amount) { return withAmount(amount); } + + @Override + public WeightedItemStack percent(float chance) { + return new WeightedItemStack(this, chance * 0.01f); + } + + @Override + public WeightedItemStack weight(float chance) { + return new WeightedItemStack(this, chance); + } @Override public IIngredient transform(IItemTransformer transformer) { @@ -230,6 +241,32 @@ public class MCItemStack implements IItemStack { // ### Object implementation ### // ############################# + @Override + public int hashCode() { + int hash = 7; + hash = 41 * hash + (this.stack != null ? this.stack.hashCode() : 0); + hash = 41 * hash + (this.wildcardSize ? 1 : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final MCItemStack other = (MCItemStack) obj; + if (this.stack != other.stack && (this.stack == null || !this.stack.equals(other.stack))) { + return false; + } + if (this.wildcardSize != other.wildcardSize) { + return false; + } + return true; + } + @Override public String toString() { StringBuilder result = new StringBuilder(); diff --git a/MineTweaker3-MC1710-Main/src/main/java/minetweaker/mc1710/oredict/MCOreDictEntry.java b/MineTweaker3-MC1710-Main/src/main/java/minetweaker/mc1710/oredict/MCOreDictEntry.java index cb1dd88..c36b375 100644 --- a/MineTweaker3-MC1710-Main/src/main/java/minetweaker/mc1710/oredict/MCOreDictEntry.java +++ b/MineTweaker3-MC1710-Main/src/main/java/minetweaker/mc1710/oredict/MCOreDictEntry.java @@ -32,7 +32,7 @@ public class MCOreDictEntry implements IOreDictEntry { private static final List> OREDICT_CONTENTS = MineTweakerHacks.getOreIdStacks(); private static final List> OREDICT_CONTENTS_UN = MineTweakerHacks.getOreIdStacksUn(); - private final Integer id; + private final int id; public MCOreDictEntry(Integer id) { this.id = id; @@ -167,6 +167,21 @@ public class MCOreDictEntry implements IOreDictEntry { return OreDictionary.getOreName(id); } + // ############################# + // ### Object implementation ### + // ############################# + + @Override + public int hashCode() { + return id; + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof MCOreDictEntry)) return false; + return ((MCOreDictEntry) other).id == id; + } + // ###################### // ### Action classes ### // ###################### diff --git a/MineTweaker3-MC172-Main/src/main/java/minetweaker/mc172/item/MCItemStack.java b/MineTweaker3-MC172-Main/src/main/java/minetweaker/mc172/item/MCItemStack.java index cfcf840..6580b2d 100644 --- a/MineTweaker3-MC172-Main/src/main/java/minetweaker/mc172/item/MCItemStack.java +++ b/MineTweaker3-MC172-Main/src/main/java/minetweaker/mc172/item/MCItemStack.java @@ -18,6 +18,7 @@ import minetweaker.api.item.IItemDefinition; import minetweaker.api.item.IItemStack; import minetweaker.api.item.IItemTransformer; import minetweaker.api.item.IngredientItem; +import minetweaker.api.item.WeightedItemStack; import minetweaker.api.liquid.ILiquidStack; import static minetweaker.api.minecraft.MineTweakerMC.getItemStack; import minetweaker.mc172.actions.SetTranslationAction; @@ -183,6 +184,16 @@ public class MCItemStack implements IItemStack { public IItemStack amount(int amount) { return withAmount(amount); } + + @Override + public WeightedItemStack percent(float chance) { + return new WeightedItemStack(this, chance * 0.01f); + } + + @Override + public WeightedItemStack weight(float chance) { + return new WeightedItemStack(this, chance); + } @Override public IIngredient transform(IItemTransformer transformer) { @@ -230,6 +241,32 @@ public class MCItemStack implements IItemStack { // ### Object implementation ### // ############################# + @Override + public int hashCode() { + int hash = 7; + hash = 41 * hash + (this.stack != null ? this.stack.hashCode() : 0); + hash = 41 * hash + (this.wildcardSize ? 1 : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final MCItemStack other = (MCItemStack) obj; + if (this.stack != other.stack && (this.stack == null || !this.stack.equals(other.stack))) { + return false; + } + if (this.wildcardSize != other.wildcardSize) { + return false; + } + return true; + } + @Override public String toString() { StringBuilder result = new StringBuilder(); diff --git a/MineTweaker3-MC172-Main/src/main/java/minetweaker/mc172/oredict/MCOreDictEntry.java b/MineTweaker3-MC172-Main/src/main/java/minetweaker/mc172/oredict/MCOreDictEntry.java index cff2abc..ed67f54 100644 --- a/MineTweaker3-MC172-Main/src/main/java/minetweaker/mc172/oredict/MCOreDictEntry.java +++ b/MineTweaker3-MC172-Main/src/main/java/minetweaker/mc172/oredict/MCOreDictEntry.java @@ -32,7 +32,7 @@ public class MCOreDictEntry implements IOreDictEntry { private static final List> OREDICT_CONTENTS = MineTweakerHacks.getOreIdStacks(); private static final List> OREDICT_CONTENTS_UN = MineTweakerHacks.getOreIdStacksUn(); - private final Integer id; + private final int id; public MCOreDictEntry(Integer id) { this.id = id; @@ -167,6 +167,21 @@ public class MCOreDictEntry implements IOreDictEntry { return OreDictionary.getOreName(id); } + // ############################# + // ### Object implementation ### + // ############################# + + @Override + public int hashCode() { + return id; + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof MCOreDictEntry)) return false; + return ((MCOreDictEntry) other).id == id; + } + // ###################### // ### Action classes ### // ###################### diff --git a/MineTweaker3-MC172-Mod-IC2/src/main/java/minetweaker/mods/ic2/machines/Canner.java b/MineTweaker3-MC172-Mod-IC2/src/main/java/minetweaker/mods/ic2/machines/Canner.java new file mode 100644 index 0000000..0d1c1b7 --- /dev/null +++ b/MineTweaker3-MC172-Mod-IC2/src/main/java/minetweaker/mods/ic2/machines/Canner.java @@ -0,0 +1,259 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package minetweaker.mods.ic2.machines; + +import ic2.api.recipe.RecipeInputFluidContainer; +import ic2.api.recipe.Recipes; +import minetweaker.MineTweakerAPI; +import minetweaker.OneWayAction; +import minetweaker.annotations.ModOnly; +import minetweaker.api.item.IIngredient; +import minetweaker.api.item.IItemStack; +import minetweaker.api.liquid.ILiquidStack; +import static minetweaker.api.minecraft.MineTweakerMC.getItemStack; +import minetweaker.mods.ic2.IC2RecipeInput; +import net.minecraftforge.fluids.FluidStack; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenMethod; + +/** + * + * @author Stan + */ +@ZenClass("mods.ic2.Canner") +@ModOnly("IC2") +public class Canner { + @ZenMethod + public static void addBottleRecipe(IIngredient container, IIngredient fill, IItemStack output) { + MineTweakerAPI.tweaker.apply(new AddBottleIngredientAction(container, fill, output)); + } + + @ZenMethod + public static void addBottleRecipe(IIngredient container, ILiquidStack liquid, IItemStack output) { + MineTweakerAPI.tweaker.apply(new AddBottleLiquidAction(container, liquid, output)); + } + + @ZenMethod + public static void addEnrichRecipe(ILiquidStack input, IIngredient additive, ILiquidStack output) { + MineTweakerAPI.tweaker.apply(new AddEnrichIngredientAction(input, additive, output)); + } + + @ZenMethod + public static void addEnrichRecipe(ILiquidStack input, ILiquidStack additive, ILiquidStack output) { + MineTweakerAPI.tweaker.apply(new AddEnrichLiquidAction(input, additive, output)); + } + + private static class AddBottleIngredientAction extends OneWayAction { + private final IIngredient container; + private final IIngredient fill; + private final IItemStack output; + + public AddBottleIngredientAction(IIngredient container, IIngredient fill, IItemStack output) { + this.container = container; + this.fill = fill; + this.output = output; + } + + @Override + public void apply() { + Recipes.cannerBottle.addRecipe( + new IC2RecipeInput(container), + new IC2RecipeInput(fill), + getItemStack(output)); + } + + @Override + public String describe() { + return "Adding canner bottle recipe " + container + " + " + fill + " => " + output; + } + + @Override + public Object getOverrideKey() { + return null; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 67 * hash + (this.container != null ? this.container.hashCode() : 0); + hash = 67 * hash + (this.fill != null ? this.fill.hashCode() : 0); + hash = 67 * hash + (this.output != null ? this.output.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final AddBottleIngredientAction other = (AddBottleIngredientAction) obj; + if (this.container != other.container && (this.container == null || !this.container.equals(other.container))) { + return false; + } + if (this.fill != other.fill && (this.fill == null || !this.fill.equals(other.fill))) { + return false; + } + if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) { + return false; + } + return true; + } + } + + private static class AddBottleLiquidAction extends OneWayAction { + private final IIngredient container; + private final ILiquidStack fill; + private final IItemStack output; + + public AddBottleLiquidAction(IIngredient container, ILiquidStack fill, IItemStack output) { + this.container = container; + this.fill = fill; + this.output = output; + } + + @Override + public void apply() { + Recipes.cannerBottle.addRecipe( + new IC2RecipeInput(container), + new RecipeInputFluidContainer( + ((FluidStack) fill.getInternal()).getFluid(), + fill.getAmount()), + getItemStack(output)); + } + + @Override + public String describe() { + return "Adding cannor bottle recipe " + container + " + " + fill + " => " + output; + } + + @Override + public Object getOverrideKey() { + return null; + } + } + + private static class AddEnrichIngredientAction extends OneWayAction { + private final ILiquidStack input; + private final IIngredient additive; + private final ILiquidStack output; + + public AddEnrichIngredientAction(ILiquidStack input, IIngredient additive, ILiquidStack output) { + this.input = input; + this.additive = additive; + this.output = output; + } + + @Override + public void apply() { + Recipes.cannerEnrich.addRecipe((FluidStack) input.getInternal(), new IC2RecipeInput(additive), (FluidStack) output.getInternal()); + } + + @Override + public String describe() { + return "Adding canner enrich recipe " + input + " + " + additive + " => " + output; + } + + @Override + public Object getOverrideKey() { + return null; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 47 * hash + (this.input != null ? this.input.hashCode() : 0); + hash = 47 * hash + (this.additive != null ? this.additive.hashCode() : 0); + hash = 47 * hash + (this.output != null ? this.output.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final AddEnrichIngredientAction other = (AddEnrichIngredientAction) obj; + if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) { + return false; + } + if (this.additive != other.additive && (this.additive == null || !this.additive.equals(other.additive))) { + return false; + } + if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) { + return false; + } + return true; + } + } + + private static class AddEnrichLiquidAction extends OneWayAction { + private final ILiquidStack input; + private final ILiquidStack additive; + private final ILiquidStack output; + + public AddEnrichLiquidAction(ILiquidStack input, ILiquidStack additive, ILiquidStack output) { + this.input = input; + this.additive = additive; + this.output = output; + } + + @Override + public void apply() { + Recipes.cannerEnrich.addRecipe( + (FluidStack) input.getInternal(), new RecipeInputFluidContainer( + ((FluidStack) additive.getInternal()).getFluid(), + additive.getAmount()), + (FluidStack) output.getInternal()); + } + + @Override + public String describe() { + return "Adding canner enrich recipe " + input + " + " + additive + " => " + output; + } + + @Override + public Object getOverrideKey() { + return null; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 19 * hash + (this.input != null ? this.input.hashCode() : 0); + hash = 19 * hash + (this.additive != null ? this.additive.hashCode() : 0); + hash = 19 * hash + (this.output != null ? this.output.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final AddEnrichLiquidAction other = (AddEnrichLiquidAction) obj; + if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) { + return false; + } + if (this.additive != other.additive && (this.additive == null || !this.additive.equals(other.additive))) { + return false; + } + if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) { + return false; + } + return true; + } + } +} diff --git a/MineTweaker3-MC172-Mod-IC2/src/main/java/minetweaker/mods/ic2/machines/MatterAmplifier.java b/MineTweaker3-MC172-Mod-IC2/src/main/java/minetweaker/mods/ic2/machines/MatterAmplifier.java new file mode 100644 index 0000000..780e8a4 --- /dev/null +++ b/MineTweaker3-MC172-Mod-IC2/src/main/java/minetweaker/mods/ic2/machines/MatterAmplifier.java @@ -0,0 +1,35 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package minetweaker.mods.ic2.machines; + +import ic2.api.recipe.Recipes; +import minetweaker.MineTweakerAPI; +import minetweaker.annotations.ModOnly; +import minetweaker.api.item.IIngredient; +import minetweaker.mods.ic2.IC2RecipeInput; +import minetweaker.mods.ic2.MachineAddRecipeAction; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenMethod; + +/** + * + * @author Stan + */ +@ZenClass("mods.ic2.MatterAmplifier") +@ModOnly("IC2") +public class MatterAmplifier { + private MatterAmplifier() {} + + @ZenMethod + public static void setAmplifier(IIngredient item, int amplifier) { + NBTTagCompound data = new NBTTagCompound(); + data.setInteger("amplification", amplifier); + MineTweakerAPI.tweaker.apply(new MachineAddRecipeAction("matter amplifier", Recipes.matterAmplifier, new ItemStack[0], data, new IC2RecipeInput(item))); + } +} diff --git a/MineTweaker3-MC172-Mod-IC2/src/main/java/minetweaker/mods/ic2/machines/Recycler.java b/MineTweaker3-MC172-Mod-IC2/src/main/java/minetweaker/mods/ic2/machines/Recycler.java new file mode 100644 index 0000000..8344fad --- /dev/null +++ b/MineTweaker3-MC172-Mod-IC2/src/main/java/minetweaker/mods/ic2/machines/Recycler.java @@ -0,0 +1,81 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package minetweaker.mods.ic2.machines; + +import ic2.api.recipe.Recipes; +import minetweaker.MineTweakerAPI; +import minetweaker.OneWayAction; +import minetweaker.annotations.ModOnly; +import minetweaker.api.item.IIngredient; +import minetweaker.api.item.IItemStack; +import static minetweaker.api.minecraft.MineTweakerMC.getItemStack; +import minetweaker.mods.ic2.IC2RecipeInput; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenMethod; + +/** + * + * @author Stan + */ +@ZenClass("mods.ic2.Recycler") +@ModOnly("IC2") +public class Recycler { + @ZenMethod + public static void addBlacklist(IIngredient ingredient) { + MineTweakerAPI.tweaker.apply(new AddBlacklistAction(ingredient)); + } + + @ZenMethod + public static boolean isBlacklisted(IItemStack item) { + return Recipes.recyclerBlacklist.contains(getItemStack(item)); + } + + private static class AddBlacklistAction extends OneWayAction { + private IIngredient ingredient; + + public AddBlacklistAction(IIngredient ingredient) { + this.ingredient = ingredient; + } + + @Override + public void apply() { + Recipes.recyclerBlacklist.add(new IC2RecipeInput(ingredient)); + } + + @Override + public String describe() { + return "Adding " + ingredient + " to the recycler blacklist"; + } + + @Override + public Object getOverrideKey() { + return null; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 29 * hash + (this.ingredient != null ? this.ingredient.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final AddBlacklistAction other = (AddBlacklistAction) obj; + if (this.ingredient != other.ingredient && (this.ingredient == null || !this.ingredient.equals(other.ingredient))) { + return false; + } + return true; + } + } +} diff --git a/MineTweaker3-MC172-Mod-IC2/src/main/java/minetweaker/mods/ic2/machines/ScrapBox.java b/MineTweaker3-MC172-Mod-IC2/src/main/java/minetweaker/mods/ic2/machines/ScrapBox.java new file mode 100644 index 0000000..a6afae6 --- /dev/null +++ b/MineTweaker3-MC172-Mod-IC2/src/main/java/minetweaker/mods/ic2/machines/ScrapBox.java @@ -0,0 +1,90 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package minetweaker.mods.ic2.machines; + +import ic2.api.recipe.Recipes; +import minetweaker.MineTweakerAPI; +import minetweaker.OneWayAction; +import minetweaker.annotations.ModOnly; +import minetweaker.api.item.WeightedItemStack; +import static minetweaker.api.minecraft.MineTweakerMC.getItemStack; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenMethod; + +/** + * + * @author Stan + */ +@ZenClass("mods.ic2.ScrapBox") +@ModOnly("IC2") +public class ScrapBox { + /** + * Adds an item drop. + * + * Reference scrap box chance values: + * + * 0.1: Diamond + * 0.5: Cake, Gold Helmet, Iron Ore, Gold Ore + * 1.0: Wooden tools, Soul Sand, Sign, Leather, Feather, Bone + * 1.5: Apple, Bread + * 2.0: Netherrack, Rotten Flesh + * 3.0: Grass, Gravel + * 4.0: Stick + * 5.0: Dirt, Wooden Hoe + * + * @param stack weighted item stack to add + */ + @ZenMethod + public static void addDrop(WeightedItemStack stack) { + MineTweakerAPI.tweaker.apply(new AddDropAction(stack)); + } + + private static class AddDropAction extends OneWayAction { + private final WeightedItemStack stack; + + public AddDropAction(WeightedItemStack stack) { + this.stack = stack; + } + + @Override + public void apply() { + Recipes.scrapboxDrops.addDrop(getItemStack(stack.getStack()), stack.getChance()); + } + + @Override + public String describe() { + return "Adding scrapbox drop " + stack.getStack(); + } + + @Override + public Object getOverrideKey() { + return null; + } + + @Override + public int hashCode() { + int hash = 5; + hash = 71 * hash + (this.stack != null ? this.stack.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final AddDropAction other = (AddDropAction) obj; + if (this.stack != other.stack && (this.stack == null || !this.stack.equals(other.stack))) { + return false; + } + return true; + } + } +} diff --git a/MineTweaker3-MC172-Mod-IC2/src/main/java/minetweaker/mods/ic2/machines/SemiFluidGenerator.java b/MineTweaker3-MC172-Mod-IC2/src/main/java/minetweaker/mods/ic2/machines/SemiFluidGenerator.java new file mode 100644 index 0000000..1dd960e --- /dev/null +++ b/MineTweaker3-MC172-Mod-IC2/src/main/java/minetweaker/mods/ic2/machines/SemiFluidGenerator.java @@ -0,0 +1,91 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package minetweaker.mods.ic2.machines; + +import ic2.api.recipe.Recipes; +import minetweaker.MineTweakerAPI; +import minetweaker.OneWayAction; +import minetweaker.annotations.ModOnly; +import minetweaker.api.liquid.ILiquidStack; +import net.minecraftforge.fluids.FluidRegistry; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenMethod; + +/** + * + * @author Stan + */ +@ZenClass("mods.ic2.SemiFluidGenerator") +@ModOnly("IC2") +public class SemiFluidGenerator { + @ZenMethod + public static void addFluid(ILiquidStack liquidPerTick, int energyPerTick) { + MineTweakerAPI.tweaker.apply(new AddFluidAction(liquidPerTick.getName(), liquidPerTick.getAmount(), energyPerTick)); + } + + @ZenMethod + public static boolean accepts(ILiquidStack liquid) { + return Recipes.semiFluidGenerator.acceptsFluid(FluidRegistry.getFluid(liquid.getName())); + } + + private static class AddFluidAction extends OneWayAction { + private final String name; + private final int liquidPerTick; + private final int energyPerTick; + + public AddFluidAction(String name, int liquidPerTick, int energyPerTick) { + this.name = name; + this.liquidPerTick = liquidPerTick; + this.energyPerTick = energyPerTick; + } + + @Override + public void apply() { + Recipes.semiFluidGenerator.addFluid(name, liquidPerTick, energyPerTick); + } + + @Override + public String describe() { + return "Adding liquid " + name + " as semifluid fuel"; + } + + @Override + public Object getOverrideKey() { + return null; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 47 * hash + (this.name != null ? this.name.hashCode() : 0); + hash = 47 * hash + this.liquidPerTick; + hash = 47 * hash + this.energyPerTick; + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final AddFluidAction other = (AddFluidAction) obj; + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + if (this.liquidPerTick != other.liquidPerTick) { + return false; + } + if (this.energyPerTick != other.energyPerTick) { + return false; + } + return true; + } + } +} diff --git a/MineTweaker3-MC172-Mod-NEI/src/main/java/minetweaker/mods/nei/NEI.java b/MineTweaker3-MC172-Mod-NEI/src/main/java/minetweaker/mods/nei/NEI.java index 62ed700..e9d0a61 100644 --- a/MineTweaker3-MC172-Mod-NEI/src/main/java/minetweaker/mods/nei/NEI.java +++ b/MineTweaker3-MC172-Mod-NEI/src/main/java/minetweaker/mods/nei/NEI.java @@ -159,7 +159,7 @@ public class NEI { @Override public Object getOverrideKey() { - return null; + return item; } } }