mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-26 06:42:57 +00:00
- Improved IC2 implementation
- Fixed multiply operator on liquid stacks
This commit is contained in:
1 parent
ea0d369519
commit
fd9bf8b080
17 files changed
+843
-7
No files matched your search
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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<IUndoableAction> actions = new ArrayList<IUndoableAction>();
|
||||
private final Set<IUndoableAction> wereStuck = new HashSet<IUndoableAction>();
|
||||
private final Set<IUndoableAction> wereStuck = new LinkedHashSet<IUndoableAction>();
|
||||
private final Map<Object, IUndoableAction> stuckOverridable = new HashMap<Object, IUndoableAction>();
|
||||
|
||||
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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
+16
-1
@@ -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 ###
|
||||
// ######################
|
||||
|
||||
@@ -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();
|
||||
|
||||
+16
-1
@@ -32,7 +32,7 @@ public class MCOreDictEntry implements IOreDictEntry {
|
||||
private static final List<ArrayList<ItemStack>> OREDICT_CONTENTS = MineTweakerHacks.getOreIdStacks();
|
||||
private static final List<ArrayList<ItemStack>> 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 ###
|
||||
// ######################
|
||||
|
||||
@@ -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();
|
||||
|
||||
+16
-1
@@ -32,7 +32,7 @@ public class MCOreDictEntry implements IOreDictEntry {
|
||||
private static final List<ArrayList<ItemStack>> OREDICT_CONTENTS = MineTweakerHacks.getOreIdStacks();
|
||||
private static final List<ArrayList<ItemStack>> 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 ###
|
||||
// ######################
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+35
@@ -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)));
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+91
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,7 +159,7 @@ public class NEI {
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user