mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-19 19:49:35 +00:00
1.10.2 IC2 support
This commit is contained in:
1 parent
23cc4f1236
commit
d5e944bb6c
28 files changed
+2624
-1
No files matched your search
@@ -75,6 +75,12 @@
|
||||
!/MineTweaker3-MC1710-Mod-IC2/libs
|
||||
!/MineTweaker3-MC1710-Mod-IC2/build.gradle
|
||||
|
||||
!/MineTweaker3-MC1102-Mod-IC2
|
||||
/MineTweaker3-MC1102-Mod-IC2/*
|
||||
!/MineTweaker3-MC1102-Mod-IC2/src
|
||||
!/MineTweaker3-MC1102-Mod-IC2/libs
|
||||
!/MineTweaker3-MC1102-Mod-IC2/build.gradle
|
||||
|
||||
!/MineTweaker3-MC1710-Mod-MFR
|
||||
/MineTweaker3-MC1710-Mod-MFR/*
|
||||
!/MineTweaker3-MC1710-Mod-MFR/src
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import minetweaker.tasks.RegisterZenClassesTask;
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = "forge"
|
||||
url = "http://files.minecraftforge.net/maven"
|
||||
}
|
||||
maven {
|
||||
name = "sonatype"
|
||||
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
}
|
||||
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||
|
||||
version = "1.10.2-" + ext.mineTweakerVersion
|
||||
archivesBaseName = project.projectDir.name
|
||||
|
||||
minecraft {
|
||||
version = forgeVersion1102
|
||||
runDir = "eclipse"
|
||||
mappings = "snapshot_20160518"
|
||||
useDepAts = true
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':ZenScript')
|
||||
compile project(':MineTweaker3-API')
|
||||
compile project(':MineTweaker3-MC1102-Main')
|
||||
compile files('libs/industrialcraft-2-2.5.63-ex19-dev.jar')
|
||||
}
|
||||
|
||||
task makeRegistry(type: RegisterZenClassesTask) {
|
||||
inputDir = file('build/classes/main')
|
||||
outputDir = file('build/classes/main')
|
||||
className = 'minetweaker.mods.ic2.ClassRegistry'
|
||||
}
|
||||
|
||||
tasks.jar.dependsOn(makeRegistry)
|
||||
Binary file not shown.
+103
@@ -0,0 +1,103 @@
|
||||
package minetweaker.mods.ic2;
|
||||
|
||||
import ic2.api.item.IC2Items;
|
||||
import java.util.List;
|
||||
import minetweaker.IBracketHandler;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.BracketHandler;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getIItemStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import stanhebben.zenscript.ZenTokener;
|
||||
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
|
||||
import stanhebben.zenscript.expression.ExpressionInt;
|
||||
import stanhebben.zenscript.expression.ExpressionCallStatic;
|
||||
import stanhebben.zenscript.expression.ExpressionString;
|
||||
import stanhebben.zenscript.expression.partial.IPartialExpression;
|
||||
import stanhebben.zenscript.parser.Token;
|
||||
import stanhebben.zenscript.symbols.IZenSymbol;
|
||||
import stanhebben.zenscript.type.ZenType;
|
||||
import stanhebben.zenscript.type.natives.IJavaMethod;
|
||||
import stanhebben.zenscript.util.ZenPosition;
|
||||
|
||||
/**
|
||||
* Makes a ic2-item specific item syntax available in the form <item-ic2:name[:meta]>.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@BracketHandler
|
||||
@ModOnly("IC2")
|
||||
public class IC2BracketHandler implements IBracketHandler {
|
||||
public static IItemStack getItem(String name, int meta) {
|
||||
ItemStack stack = IC2Items.getItem(name);
|
||||
stack.setItemDamage(meta);
|
||||
return getIItemStack(stack);
|
||||
}
|
||||
|
||||
private final IJavaMethod method;
|
||||
|
||||
public IC2BracketHandler() {
|
||||
method = MineTweakerAPI.getJavaMethod(IC2BracketHandler.class, "getItem", String.class, int.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens) {
|
||||
if (tokens.size() >= 5) {
|
||||
if (tokens.get(0).getValue().equals("ic2")
|
||||
&& tokens.get(1).getValue().equals("-")
|
||||
&& tokens.get(2).getValue().equals("item")
|
||||
&& tokens.get(3).getValue().equals(":")) {
|
||||
String name = tokens.get(4).getValue();
|
||||
int meta = 0;
|
||||
if (tokens.size() > 6 && tokens.get(5).getValue().equals(":")) {
|
||||
if (tokens.get(6).getType() == ZenTokener.T_INTVALUE) {
|
||||
meta = Integer.parseInt(tokens.get(6).getValue());
|
||||
} else if (tokens.get(6).getValue().equals("*")) {
|
||||
meta = OreDictionary.WILDCARD_VALUE;
|
||||
} else {
|
||||
MineTweakerAPI.logError("Not a valid meta value: " + tokens.get(6).getValue());
|
||||
}
|
||||
}
|
||||
ItemStack item = IC2Items.getItem(name);
|
||||
if (item == null) {
|
||||
MineTweakerAPI.logError("Not a valid IC2 item: " + name);
|
||||
return null;
|
||||
} else {
|
||||
return new ItemReferenceSymbol(environment, name, meta);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// #############################
|
||||
// ### Private inner classes ###
|
||||
// #############################
|
||||
|
||||
private class ItemReferenceSymbol implements IZenSymbol {
|
||||
private final IEnvironmentGlobal environment;
|
||||
private final String name;
|
||||
private final int meta;
|
||||
|
||||
public ItemReferenceSymbol(IEnvironmentGlobal environment, String name, int meta) {
|
||||
this.environment = environment;
|
||||
this.name = name;
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartialExpression instance(ZenPosition position) {
|
||||
return new ExpressionCallStatic(
|
||||
position,
|
||||
environment,
|
||||
method,
|
||||
new ExpressionString(position, name),
|
||||
new ExpressionInt(position, meta, ZenType.INT));
|
||||
}
|
||||
}
|
||||
}
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
package minetweaker.mods.ic2;
|
||||
|
||||
import ic2.api.tile.ExplosionWhitelist;
|
||||
import minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Manages the explosion whitelist in IC2. Blocks on this whitelist will not resist
|
||||
* an explosion but won't be destroyed.
|
||||
*
|
||||
* The explosion code by default ignores blocks which absorb more than 1000 explosion power to
|
||||
* prevent abusing personal safes, Trade-O-Mats and other blocks to serve as a cheap and
|
||||
* invulnerable reactor chambers. Said blocks will not shield the explosion and won't get
|
||||
* destroyed.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.ic2.ExplosionWhitelist")
|
||||
@ModOnly("IC2")
|
||||
public class IC2ExplosionWhitelist {
|
||||
/**
|
||||
* Adds a block to the explosion whitelist.
|
||||
*
|
||||
* @param item item to add
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void add(IItemStack item) {
|
||||
ItemStack iStack = getItemStack(item);
|
||||
Block block = Block.getBlockFromItem(iStack.getItem());
|
||||
if (block == null) {
|
||||
MineTweakerAPI.logError("This item is not a block");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new AddAction(block));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a block from the explosion whitelist.
|
||||
*
|
||||
* @param item item to remove
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void remove(IItemStack item) {
|
||||
ItemStack iStack = getItemStack(item);
|
||||
Block block = Block.getBlockFromItem(iStack.getItem());
|
||||
if (block == null) {
|
||||
MineTweakerAPI.logError("This item is not a block");
|
||||
} else {
|
||||
if (ExplosionWhitelist.isBlockWhitelisted(block)) {
|
||||
MineTweakerAPI.logWarning("This block is not in the whitelist");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new RemoveAction(block));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given item is already whitelisted.
|
||||
*
|
||||
* @param item item to check
|
||||
* @return true if whitelisted
|
||||
*/
|
||||
@ZenMethod
|
||||
public static boolean isWhitelisted(IItemStack item) {
|
||||
ItemStack iStack = getItemStack(item);
|
||||
Block block = Block.getBlockFromItem(iStack.getItem());
|
||||
if (block == null) {
|
||||
MineTweakerAPI.logWarning("This item is not a block");
|
||||
return false;
|
||||
} else {
|
||||
return ExplosionWhitelist.isBlockWhitelisted(block);
|
||||
}
|
||||
}
|
||||
|
||||
// ######################
|
||||
// ### Action classes ###
|
||||
// ######################
|
||||
|
||||
private static class AddAction implements IUndoableAction {
|
||||
private final Block block;
|
||||
|
||||
public AddAction(Block block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
ExplosionWhitelist.addWhitelistedBlock(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
ExplosionWhitelist.removeWhitelistedBlock(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding block to IC2 explosion whitelist: " + block.getLocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing block from IC2 explosion whitelist: " + block.getLocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveAction implements IUndoableAction {
|
||||
private final Block block;
|
||||
|
||||
public RemoveAction(Block block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
ExplosionWhitelist.removeWhitelistedBlock(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
ExplosionWhitelist.addWhitelistedBlock(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing block from IC2 explosion whitelist: " + block.getLocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Adding block to IC2 explosion whitelist: " + block.getLocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import ic2.api.recipe.IRecipeInput;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getIItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Wrapper class for ITweakerItemStackPatterns to IC2 recipe inputs.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public class IC2RecipeInput implements IRecipeInput {
|
||||
private final IIngredient ingredient;
|
||||
|
||||
public IC2RecipeInput(IIngredient ingredient) {
|
||||
this.ingredient = ingredient;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack subject) {
|
||||
return ingredient.matches(getIItemStack(subject));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAmount() {
|
||||
return ingredient.getAmount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getInputs() {
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
for (IItemStack item : ingredient.getItems()) {
|
||||
items.add(getItemStack(item));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 89 * 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 IC2RecipeInput other = (IC2RecipeInput) obj;
|
||||
if (this.ingredient != other.ingredient && (this.ingredient == null || !this.ingredient.equals(other.ingredient))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
package minetweaker.mods.ic2;
|
||||
|
||||
import ic2.api.recipe.IMachineRecipeManager;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
public class MachineAddRecipeAction extends OneWayAction {
|
||||
private final String name;
|
||||
private final IMachineRecipeManager machine;
|
||||
private final ItemStack[] output;
|
||||
private final IC2RecipeInput input;
|
||||
private final NBTTagCompound tag;
|
||||
|
||||
public MachineAddRecipeAction(String name, IMachineRecipeManager machine, ItemStack[] output, NBTTagCompound tag, IC2RecipeInput input) {
|
||||
this.name = name;
|
||||
this.machine = machine;
|
||||
this.output = output;
|
||||
this.input = input;
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
try {
|
||||
machine.addRecipe(input, tag, false, output);
|
||||
} catch (RuntimeException ex) {
|
||||
MineTweakerAPI.logError(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
if (output.length == 1) {
|
||||
return "Adding " + name + " recipe for " + output[0].getDisplayName();
|
||||
} else {
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append("Adding ").append(name).append(" recipe for ");
|
||||
result.append("[");
|
||||
for (int i = 0; i < output.length; i++) {
|
||||
if (i == 0) {
|
||||
result.append(", ");
|
||||
} else {
|
||||
result.append(output[i].getDisplayName());
|
||||
}
|
||||
}
|
||||
result.append("]");
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@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.machine != null ? this.machine.hashCode() : 0);
|
||||
hash = 47 * hash + Arrays.deepHashCode(this.output);
|
||||
hash = 47 * hash + (this.input != null ? this.input.hashCode() : 0);
|
||||
hash = 47 * hash + (this.tag != null ? this.tag.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final MachineAddRecipeAction other = (MachineAddRecipeAction) obj;
|
||||
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
|
||||
return false;
|
||||
}
|
||||
if (this.machine != other.machine && (this.machine == null || !this.machine.equals(other.machine))) {
|
||||
return false;
|
||||
}
|
||||
if (!Arrays.deepEquals(this.output, other.output)) {
|
||||
return false;
|
||||
}
|
||||
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
|
||||
return false;
|
||||
}
|
||||
if (this.tag != other.tag && (this.tag == null || !this.tag.equals(other.tag))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package minetweaker.mods.ic2.crops;
|
||||
|
||||
import ic2.api.crops.CropCard;
|
||||
import stanhebben.zenscript.annotations.ZenCaster;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenGetter;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Read-only data accessor for crops
|
||||
* @author ben
|
||||
*
|
||||
*/
|
||||
@ZenClass("mods.ic2.Crop")
|
||||
public class Crop {
|
||||
private CropCard cc;
|
||||
|
||||
@ZenGetter("name")
|
||||
public String name() {
|
||||
return cc.getName();
|
||||
}
|
||||
|
||||
@ZenGetter("owner")
|
||||
public String owner() {
|
||||
return cc.getOwner();
|
||||
}
|
||||
|
||||
@ZenGetter("displayName")
|
||||
public String displayName() {
|
||||
return cc.getDisplayName();
|
||||
}
|
||||
|
||||
@ZenGetter("hashCode")
|
||||
public int hashCode() {
|
||||
return cc.hashCode();
|
||||
}
|
||||
|
||||
@ZenGetter("discoveredBy")
|
||||
public String discoveredBy() {
|
||||
return cc.getDiscoveredBy();
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public String desc(int i) {
|
||||
return cc.desc(i);
|
||||
}
|
||||
|
||||
@ZenGetter("tier")
|
||||
public int tier() {
|
||||
return cc.getProperties().getTier();
|
||||
}
|
||||
|
||||
|
||||
@ZenGetter("attributes")
|
||||
public String[] attributes() {
|
||||
return cc.getAttributes();
|
||||
}
|
||||
|
||||
@ZenGetter("maxSize")
|
||||
public int maxSize() {
|
||||
return cc.getMaxSize();
|
||||
}
|
||||
|
||||
@ZenGetter("dropGainChance")
|
||||
public double dropGainChance() {
|
||||
return cc.dropGainChance();
|
||||
}
|
||||
|
||||
@ZenCaster
|
||||
public String toString() {
|
||||
return cc.toString();
|
||||
}
|
||||
|
||||
public Crop(CropCard cc) {
|
||||
super();
|
||||
this.cc = cc;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+261
@@ -0,0 +1,261 @@
|
||||
package minetweaker.mods.ic2.crops;
|
||||
|
||||
import ic2.api.crops.CropCard;
|
||||
import ic2.api.crops.Crops;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.OneWayAction;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenGetter;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Provides access to IC2 crop system in general
|
||||
*
|
||||
* @author ben
|
||||
*/
|
||||
@ZenClass("mods.ic2.CropsConfig")
|
||||
@ModOnly("IC2")
|
||||
public class CropsConfig {
|
||||
/**
|
||||
* Action to add a new seed for a base crop
|
||||
* @author ben
|
||||
*
|
||||
*/
|
||||
private static final class RegisterBaseSeedAction extends OneWayAction {
|
||||
private IItemStack seed;
|
||||
private CropCard c;
|
||||
private int sz;
|
||||
private int growth;
|
||||
private int gain;
|
||||
private int resist;
|
||||
|
||||
public RegisterBaseSeedAction(IItemStack seed, CropCard c, int sz, int growth, int gain, int resist) {
|
||||
this.seed = seed;
|
||||
this.c = c;
|
||||
this.sz = sz;
|
||||
this.growth = growth;
|
||||
this.gain = gain;
|
||||
this.resist = resist;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Registering base seed for crop " + c.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
Crops.instance.registerBaseSeed(MineTweakerMC.getItemStack(seed), c, sz, growth, gain, resist);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action to register a new crop
|
||||
* @author ben
|
||||
*
|
||||
*/
|
||||
private static final class RegisterCropCardAction extends OneWayAction {
|
||||
private CropCard c;
|
||||
|
||||
public RegisterCropCardAction(CropCard c) {
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Registering crop " + c.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
Crops.instance.registerCrop(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action to add a biome nutrient bonus
|
||||
* @author ben
|
||||
*
|
||||
*/
|
||||
private static final class AddBiomeNutrientBonusAction extends OneWayAction {
|
||||
private String biomeType;
|
||||
private int nutrientBonus;
|
||||
|
||||
public AddBiomeNutrientBonusAction(String biomeType, int nutrientBonus) {
|
||||
this.biomeType = biomeType;
|
||||
this.nutrientBonus = nutrientBonus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Setting biome nutrient bonus for " + biomeType + " biomes to " +
|
||||
nutrientBonus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
Crops.instance.addBiomenutrientsBonus(BiomeDictionary.Type.valueOf(biomeType),
|
||||
nutrientBonus);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Action to add a biome humidity bonus
|
||||
* @author ben
|
||||
*
|
||||
*/
|
||||
private static final class AddBiomeHumidityBonusAction extends OneWayAction {
|
||||
private String biomeType;
|
||||
private int humidityBonus;
|
||||
|
||||
public AddBiomeHumidityBonusAction(String biomeType, int humidityBonus) {
|
||||
this.biomeType = biomeType;
|
||||
this.humidityBonus = humidityBonus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Setting biome humidity bonus for " + biomeType + " biomes to " +
|
||||
humidityBonus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
Crops.instance.addBiomehumidityBonus(BiomeDictionary.Type.valueOf(biomeType),
|
||||
humidityBonus);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a nutrient bonus to crops in a specific biome
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addBiomeNutrientBonus(String biomeType, int nutrientBonus) {
|
||||
if(BiomeDictionary.Type.valueOf(biomeType) == null) {
|
||||
MineTweakerAPI.logWarning("invalid biome type: " + biomeType);
|
||||
} else if (nutrientBonus < -10 || nutrientBonus > 10) {
|
||||
MineTweakerAPI.logWarning("nutrient bonus " + nutrientBonus +
|
||||
" not in -10, +10 range");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new AddBiomeNutrientBonusAction(biomeType, nutrientBonus));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a humidity bonus to crops in a specific biome
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addBiomeHumidityBonus(String biomeType, int humidityBonus) {
|
||||
if(BiomeDictionary.Type.valueOf(biomeType) == null) {
|
||||
MineTweakerAPI.logWarning("invalid biome type: " + biomeType);
|
||||
} else if (humidityBonus < -10 || humidityBonus > 10) {
|
||||
MineTweakerAPI.logWarning("humidity bonus " + humidityBonus +
|
||||
" not in -10, +10 range");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new AddBiomeHumidityBonusAction(biomeType, humidityBonus));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new synthetic crop to manipulate
|
||||
* @param cropOwner The mod that owns the crop
|
||||
* @param cropName The name of the crop
|
||||
*/
|
||||
@ZenMethod
|
||||
public static SyntheticCrop newCrop(String cropName, String cropOwner) {
|
||||
return new SyntheticCrop(cropName, cropOwner);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a crop into the crop system
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void registerCrop(CropCard c) {
|
||||
MineTweakerAPI.apply(new RegisterCropCardAction(c));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new base seed item to plant a crop
|
||||
*
|
||||
* @param seed The item to plant with
|
||||
* @param c The crop being planted
|
||||
* @param sz The initial size of the planted crop
|
||||
* @param growth The initial growth stat of the planted crop
|
||||
* @param gain The initial gain stat of the planted crop
|
||||
* @param resist The initial resistance of the planted crop
|
||||
*/
|
||||
public static void registerBaseSeed(IItemStack seed, CropCard c, int sz,
|
||||
int growth, int gain, int resist) {
|
||||
MineTweakerAPI.apply(new RegisterBaseSeedAction(seed, c, sz, growth, gain, resist));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a crop by its name and owning mod
|
||||
* @param owner The mod that owns the crop
|
||||
* @param name The name of the crop
|
||||
* @return A crop with the given name, owned by the given mod
|
||||
*/
|
||||
@ZenMethod
|
||||
public static Crop getCrop(String owner, String name) {
|
||||
return new Crop(Crops.instance.getCropCard(owner, name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a crop by the seed that plants it
|
||||
* @param seed The seed that plants the crop
|
||||
* @return The crop planted by the seed
|
||||
*/
|
||||
@ZenMethod
|
||||
public static Crop getCrop(IItemStack seed) {
|
||||
return new Crop(Crops.instance.getCropCard(MineTweakerMC.getItemStack(seed)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the currently registered crops
|
||||
* @return All of the currently registered crops
|
||||
*/
|
||||
@ZenGetter("crops")
|
||||
public static List<Crop> getAllCrops() {
|
||||
Collection<CropCard> ccList = Crops.instance.getCrops();
|
||||
|
||||
List<Crop> cList = new ArrayList<Crop>(ccList.size());
|
||||
for (CropCard cropCard : ccList) {
|
||||
cList.add(new Crop(cropCard));
|
||||
}
|
||||
|
||||
return cList;
|
||||
}
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
package minetweaker.mods.ic2.crops;
|
||||
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenGetter;
|
||||
import stanhebben.zenscript.annotations.ZenSetter;
|
||||
|
||||
/**
|
||||
* Contains all of the growth requirements for an IC2 crop in one easy place
|
||||
* @author ben
|
||||
*
|
||||
*/
|
||||
@ZenClass("mods.ic2.GrowthRequirements")
|
||||
public class GrowthRequirements {
|
||||
|
||||
private int minNutrients;
|
||||
private int minHumidity;
|
||||
private int minAirQuality;
|
||||
|
||||
private int minLight;
|
||||
private int maxLight = 17;
|
||||
|
||||
private IItemStack requiredBlock;
|
||||
|
||||
/**
|
||||
* Get the minimum amount of nutrients this plant needs to grow
|
||||
* @return The minimum amount of nutrients this plant needs
|
||||
*/
|
||||
@ZenGetter("minNutrients")
|
||||
public int getMinNutrients() {
|
||||
return minNutrients;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the minimum amount of nutrients this plant needs to grow
|
||||
* @param minNutrients The new minimum amount of nutrients this plant requires
|
||||
*/
|
||||
@ZenSetter("minNutrients")
|
||||
public void setMinNutrients(int minNutrients) {
|
||||
this.minNutrients = minNutrients;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the minimum amount of humidity this plant requires
|
||||
* @return The minimum amount of humidity this plant requires
|
||||
*/
|
||||
@ZenGetter("minHumidity")
|
||||
public int getMinHumidity() {
|
||||
return minHumidity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the minimum amount of humidity this plant requires
|
||||
* @param minHumidity The new minimum amount of humidity this plant requires
|
||||
*/
|
||||
@ZenSetter("minHumidity")
|
||||
public void setMinHumidity(int minHumidity) {
|
||||
this.minHumidity = minHumidity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the minimum air quality this plant requires
|
||||
* @return The minimum air quality this plant requires
|
||||
*/
|
||||
@ZenGetter("minAirQuality")
|
||||
public int getMinAirQuality() {
|
||||
return minAirQuality;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the minimum air quality this plant requires
|
||||
* @param minAirQuality The new amount of air quality this plant requires
|
||||
*/
|
||||
@ZenSetter("minAirQuality")
|
||||
public void setMinAirQuality(int minAirQuality) {
|
||||
this.minAirQuality = minAirQuality;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the minimum amount of light this plant requires
|
||||
* @return The minimum amount of light this plant requires
|
||||
*/
|
||||
@ZenGetter("minLight")
|
||||
public int getMinLight() {
|
||||
return minLight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the minimum amount of light this plant requires
|
||||
* @param minLight The new minimum amount of light this plant requires
|
||||
*/
|
||||
@ZenSetter("minLight")
|
||||
public void setMinLight(int minLight) {
|
||||
this.minLight = minLight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum amount of light this plant can have
|
||||
* @return The maximum amount of light this plant can have
|
||||
*/
|
||||
@ZenGetter("maxLight")
|
||||
public int getMaxLight() {
|
||||
return maxLight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maximum amount of light this plant can have
|
||||
* @param maxLight The new maximum amount of light thi plant can have
|
||||
*/
|
||||
@ZenSetter("maxLight")
|
||||
public void setMaxLight(int maxLight) {
|
||||
this.maxLight = maxLight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the block that is required to be below this one
|
||||
* @return The block required to be below this one
|
||||
*/
|
||||
@ZenGetter("requiredBlock")
|
||||
public IItemStack getRequiredBlock() {
|
||||
return requiredBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the block required to be below this one
|
||||
* @param requiredBlock The new block required to be below this one
|
||||
*/
|
||||
@ZenSetter("requiredBlock")
|
||||
public void setRequiredBlock(IItemStack requiredBlock) {
|
||||
this.requiredBlock = requiredBlock;
|
||||
}
|
||||
|
||||
|
||||
public GrowthRequirements(int minNutrients, int minHumidity, int minAirQuality, int minLight, int maxLight,
|
||||
IItemStack requiredBlock) {
|
||||
super();
|
||||
this.minNutrients = minNutrients;
|
||||
this.minHumidity = minHumidity;
|
||||
this.minAirQuality = minAirQuality;
|
||||
this.minLight = minLight;
|
||||
this.maxLight = maxLight;
|
||||
this.requiredBlock = requiredBlock;
|
||||
}
|
||||
}
|
||||
+261
@@ -0,0 +1,261 @@
|
||||
package minetweaker.mods.ic2.crops;
|
||||
|
||||
import ic2.api.crops.CropCard;
|
||||
import ic2.api.crops.CropProperties;
|
||||
import ic2.api.crops.ICropTile;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenGetter;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import stanhebben.zenscript.annotations.ZenSetter;
|
||||
|
||||
/**
|
||||
* A synthetic crop, created in ZS
|
||||
* <p>
|
||||
* For your crop textures to be picked up, put them at owner + ":crops/crop" +
|
||||
* name + "." + size where owner is the mod responsible for the crop name is the
|
||||
* name of the crop size is the current size of the crop, starting at 0 for new
|
||||
* crops
|
||||
* <p>
|
||||
* Localizations will be looked for at owner + ".crop." + name where each field
|
||||
* has the value it has above
|
||||
*
|
||||
* @author ben
|
||||
*/
|
||||
@ZenClass("mods.ic2.SyntheticCrop")
|
||||
public class SyntheticCrop extends CropCard {
|
||||
|
||||
private String name;
|
||||
private String owner;
|
||||
|
||||
private int tier;
|
||||
|
||||
private int[] stats = new int[4];
|
||||
private String[] attributes;
|
||||
|
||||
private int maxSize;
|
||||
|
||||
private float dropChance;
|
||||
private IItemStack fruit;
|
||||
|
||||
private GrowthRequirements reqs;
|
||||
private CropProperties properties;
|
||||
|
||||
/**
|
||||
* Create a new synthetic crop
|
||||
*
|
||||
* @param cropName The name of this crop
|
||||
* @param cropOwner The mod creating this crop
|
||||
*/
|
||||
public SyntheticCrop(String cropName, String cropOwner) {
|
||||
name = cropName;
|
||||
}
|
||||
|
||||
// Required IC2 Interface
|
||||
|
||||
/**
|
||||
* Gets the name of this crop used as a identifier
|
||||
*/
|
||||
@Override
|
||||
@ZenGetter("name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mod that owns this crop
|
||||
*/
|
||||
@Override
|
||||
@ZenGetter("owner")
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ZenGetter("properties")
|
||||
public CropProperties getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the localization key used for this crop
|
||||
*/
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return owner + ".crop." + name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the seed tier of this crop.
|
||||
*/
|
||||
@ZenGetter("tier")
|
||||
public int tier() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets any additional attributes of this crop
|
||||
*/
|
||||
@Override
|
||||
@ZenGetter("attributes")
|
||||
public String[] getAttributes() {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the maximum size of this crop
|
||||
*/
|
||||
@Override
|
||||
@ZenGetter("maxSize")
|
||||
public int getMaxSize() {
|
||||
return maxSize;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canGrow(ICropTile crop) {
|
||||
if (crop.getCurrentSize() == maxSize) {
|
||||
return false;
|
||||
} else if (reqs == null) {
|
||||
return true;
|
||||
} else {
|
||||
if (!crop.isBlockBelow(MineTweakerMC.getBlock(reqs.getRequiredBlock()))) {
|
||||
return false;
|
||||
} else if (crop.getAirQuality() < reqs.getMinAirQuality()) {
|
||||
return false;
|
||||
} else if (crop.getHumidity() < reqs.getMinHumidity()) {
|
||||
return false;
|
||||
} else if (crop.getNutrients() < reqs.getMinNutrients()) {
|
||||
return false;
|
||||
} else {
|
||||
int lgh = crop.getLightLevel();
|
||||
return reqs.getMinLight() < lgh && reqs.getMaxLight() > lgh;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canBeHarvested(ICropTile crop) {
|
||||
return crop.getCurrentSize() == maxSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getGain(ICropTile crop) {
|
||||
return MineTweakerMC.getItemStack(fruit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the chance for this crop to drop an item
|
||||
*/
|
||||
@Override
|
||||
@ZenGetter("dropChance")
|
||||
public double dropGainChance() {
|
||||
return dropChance;
|
||||
}
|
||||
|
||||
// ZS Support
|
||||
|
||||
/**
|
||||
* Sets the tier of this crop
|
||||
*
|
||||
* @param tier The new tier of this crop
|
||||
*/
|
||||
@ZenSetter("tier")
|
||||
public void setTier(int tier) {
|
||||
this.tier = tier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets all of the stats for this crop
|
||||
*
|
||||
* @param stats The new stats to give to this crop
|
||||
*/
|
||||
@ZenSetter("stats")
|
||||
public void setStats(int[] stats) {
|
||||
this.stats = stats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an individual stat for this crop
|
||||
*
|
||||
* @param stat The stat to set a value for
|
||||
* @param val The new value for this stat
|
||||
*/
|
||||
@ZenMethod
|
||||
public void setStat(int stat, int val) {
|
||||
if (stat < 0 || stat > 3) {
|
||||
MineTweakerAPI.logWarning("invalid stat index " + stat);
|
||||
} else {
|
||||
stats[stat] = val;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the additional attributes for this crop
|
||||
*
|
||||
* @param attributes Sets the attributes of this crop
|
||||
*/
|
||||
@ZenSetter("attributes")
|
||||
public void setAttributes(String[] attributes) {
|
||||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum size this crop goes to
|
||||
*
|
||||
* @param maxSize The new max size of this crop
|
||||
*/
|
||||
@ZenSetter("maxSize")
|
||||
public void setMaxSize(int maxSize) {
|
||||
this.maxSize = maxSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the item this crop gives when harvested
|
||||
*
|
||||
* @param fruit The item to give from the crop
|
||||
*/
|
||||
@ZenSetter("fruit")
|
||||
public void setFruit(IItemStack fruit) {
|
||||
this.fruit = fruit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the chance for this plant to yield its fruit
|
||||
*
|
||||
* @param dropChance The new chance for this plant to yield fruit
|
||||
*/
|
||||
@ZenSetter("dropChance")
|
||||
public void setDropChance(int dropChance) {
|
||||
this.dropChance = dropChance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current requirements for this plant to grow
|
||||
*
|
||||
* @return The current growth requirements for this plant
|
||||
*/
|
||||
public GrowthRequirements getReqs() {
|
||||
return reqs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current growth requirements for this plant to grow
|
||||
*
|
||||
* @param reqs The new requirements for this plant to grow
|
||||
*/
|
||||
public void setReqs(GrowthRequirements reqs) {
|
||||
this.reqs = reqs;
|
||||
}
|
||||
|
||||
|
||||
@ZenSetter("properties")
|
||||
public void setProperties(CropProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.expand;
|
||||
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemCondition;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.item.IItemTransformer;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
import stanhebben.zenscript.annotations.ZenExpansion;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenExpansion("minetweaker.item.IIngredient")
|
||||
@ModOnly("IC2")
|
||||
public class IngredientExpansion {
|
||||
@ZenMethod
|
||||
public static IIngredient onlyIC2ChargeAtLeast(IIngredient ingredient, final int charge) {
|
||||
return ingredient.only(new IItemCondition() {
|
||||
@Override
|
||||
public boolean matches(IItemStack stack) {
|
||||
return ItemExpansion.getIC2Charge(stack) >= charge;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static IIngredient onlyIC2ChargeAtMost(IIngredient ingredient, final int charge) {
|
||||
return ingredient.only(new IItemCondition() {
|
||||
@Override
|
||||
public boolean matches(IItemStack stack) {
|
||||
return ItemExpansion.getIC2Charge(stack) <= charge;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static IIngredient transformIC2Discharge(IIngredient ingredient, final int amount) {
|
||||
return ingredient.transform(new IItemTransformer() {
|
||||
@Override
|
||||
public IItemStack transform(IItemStack item, IPlayer byPlayer) {
|
||||
return ItemExpansion.ic2Discharge(item, amount, 0).withAmount(item.getAmount() + 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
package minetweaker.mods.ic2.expand;
|
||||
|
||||
import ic2.api.item.ElectricItem;
|
||||
import ic2.api.item.IElectricItem;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenExpansion;
|
||||
import stanhebben.zenscript.annotations.ZenGetter;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getIItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenExpansion("minecraft.item.IItemStack")
|
||||
@ModOnly("IC2")
|
||||
public class ItemExpansion {
|
||||
/**
|
||||
* Gets the charge level of this item.
|
||||
*
|
||||
* @param stack target
|
||||
* @return charge level
|
||||
*/
|
||||
@ZenGetter("ic2getCharge")
|
||||
public static double getIC2Charge(IItemStack stack) {
|
||||
return ElectricItem.manager.getCharge(getItemStack(stack));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tier level of this item.
|
||||
*
|
||||
* @param stack target
|
||||
* @return tier level
|
||||
*/
|
||||
@ZenGetter("ic2tier")
|
||||
public static int getIC2Tier(IItemStack stack) {
|
||||
ItemStack iStack = getItemStack(stack);
|
||||
if (iStack.getItem() instanceof IElectricItem) {
|
||||
return ((IElectricItem) iStack.getItem()).getTier(iStack);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the transfer limit of the specified stack.
|
||||
*
|
||||
* @param stack target
|
||||
* @return
|
||||
*/
|
||||
@ZenGetter("ic2transferLimit")
|
||||
public static double getIC2TransferLimit(IItemStack stack) {
|
||||
ItemStack iStack = getItemStack(stack);
|
||||
if (iStack.getItem() instanceof IElectricItem) {
|
||||
return ((IElectricItem) iStack.getItem()).getTransferLimit(iStack);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Charges the item with the specified amount and returns the charged item.
|
||||
*
|
||||
* @param stack target
|
||||
* @param amount charge amount
|
||||
* @param tier charge tier
|
||||
* @return charged item
|
||||
*/
|
||||
@ZenMethod("ic2charge")
|
||||
public static IItemStack ic2Charge(IItemStack stack, double amount, @Optional int tier) {
|
||||
if (tier == 0) {
|
||||
tier = getIC2Tier(stack);
|
||||
}
|
||||
|
||||
ItemStack iStack = getItemStack(stack).copy();
|
||||
ElectricItem.manager.charge(iStack, amount, tier, true, false);
|
||||
return getIItemStack(iStack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Discharges the item with the specified amount and returns the discharged item.
|
||||
*
|
||||
* @param stack target
|
||||
* @param amount discharge amount
|
||||
* @param tier charge tier
|
||||
* @return discharged item
|
||||
*/
|
||||
@ZenMethod("ic2discharge")
|
||||
public static IItemStack ic2Discharge(IItemStack stack, int amount, @Optional int tier) {
|
||||
if (tier == 0) {
|
||||
tier = getIC2Tier(stack);
|
||||
}
|
||||
|
||||
ItemStack iStack = getItemStack(stack).copy();
|
||||
ElectricItem.manager.discharge(iStack, amount, tier, true, false, false);
|
||||
return getIItemStack(iStack);
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.RecipeOutput;
|
||||
import ic2.api.recipe.Recipes;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.mods.ic2.IC2RecipeInput;
|
||||
import minetweaker.mods.ic2.MachineAddRecipeAction;
|
||||
import stanhebben.zenscript.annotations.NotNull;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.*;
|
||||
|
||||
/**
|
||||
* Provides access to the IC2 Blast Furnace recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.ic2.BlastFurnace")
|
||||
@ModOnly("IC2")
|
||||
public class BlastFurnace {
|
||||
/**
|
||||
* Adds a new recipe to the blast furnace.
|
||||
*
|
||||
* The recipe input can be any pattern, as long as the stack size is determined.
|
||||
* The output can be any item stack.
|
||||
*
|
||||
* @param output recipe output
|
||||
* @param ingredient recipe input
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(
|
||||
@NotNull IItemStack output,
|
||||
@NotNull IIngredient ingredient) {
|
||||
if (ingredient.getAmount() < 0) {
|
||||
MineTweakerAPI.logWarning("invalid ingredient: " + ingredient + " - stack size not known");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new MachineAddRecipeAction(
|
||||
"blast furnace",
|
||||
Recipes.blastfurnace,
|
||||
getItemStacks(output),
|
||||
null,
|
||||
new IC2RecipeInput(ingredient)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the recipe output for the given input. Will return the output
|
||||
* of a single item, even if the stack contains multiple items.
|
||||
*
|
||||
* @param input recipe input
|
||||
* @return recipe output
|
||||
*/
|
||||
@ZenMethod
|
||||
public static IItemStack getOutput(
|
||||
@NotNull IItemStack input) {
|
||||
RecipeOutput output = Recipes.blastfurnace.getOutputFor(getItemStack(input), false);
|
||||
if (output == null || output.items.isEmpty()) return null;
|
||||
return getIItemStack(output.items.get(0));
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.RecipeOutput;
|
||||
import ic2.api.recipe.Recipes;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getIItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStacks;
|
||||
import minetweaker.mods.ic2.IC2RecipeInput;
|
||||
import minetweaker.mods.ic2.MachineAddRecipeAction;
|
||||
import stanhebben.zenscript.annotations.NotNull;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the IC2 Block Cutter recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.ic2.BlockCutter")
|
||||
@ModOnly("IC2")
|
||||
public class BlockCutter {
|
||||
/**
|
||||
* Adds a new recipe to the block cutter.
|
||||
*
|
||||
* The recipe input can be any pattern, as long as the stack size is determined.
|
||||
* The output can be any item stack.
|
||||
*
|
||||
* @param output recipe output
|
||||
* @param ingredient recipe input
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(
|
||||
@NotNull IItemStack output,
|
||||
@NotNull IIngredient ingredient) {
|
||||
if (ingredient.getAmount() < 0) {
|
||||
MineTweakerAPI.logWarning("invalid ingredient: " + ingredient + " - stack size not known");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new MachineAddRecipeAction(
|
||||
"block cutter",
|
||||
Recipes.blockcutter,
|
||||
getItemStacks(output),
|
||||
null,
|
||||
new IC2RecipeInput(ingredient)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the recipe output for the given input. Will return the output
|
||||
* of a single item, even if the stack contains multiple items.
|
||||
*
|
||||
* @param input recipe input
|
||||
* @return recipe output
|
||||
*/
|
||||
@ZenMethod
|
||||
public static IItemStack getOutput(
|
||||
@NotNull IItemStack input) {
|
||||
RecipeOutput output = Recipes.blockcutter.getOutputFor(getItemStack(input), false);
|
||||
if (output == null || output.items.isEmpty()) return null;
|
||||
return getIItemStack(output.items.get(0));
|
||||
}
|
||||
}
|
||||
@@ -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(IItemStack output, IIngredient container, IIngredient fill) {
|
||||
MineTweakerAPI.apply(new AddBottleIngredientAction(container, fill, output));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addBottleRecipe(IItemStack output, IIngredient container, ILiquidStack liquid) {
|
||||
MineTweakerAPI.apply(new AddBottleLiquidAction(container, liquid, output));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addEnrichRecipe(ILiquidStack output, ILiquidStack input, IIngredient additive) {
|
||||
MineTweakerAPI.apply(new AddEnrichIngredientAction(input, additive, output));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addEnrichRecipe(ILiquidStack output, ILiquidStack input, ILiquidStack additive) {
|
||||
MineTweakerAPI.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package minetweaker.mods.ic2.machines;
|
||||
|
||||
import ic2.api.recipe.RecipeOutput;
|
||||
import ic2.api.recipe.Recipes;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getIItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStacks;
|
||||
import minetweaker.mods.ic2.IC2RecipeInput;
|
||||
import minetweaker.mods.ic2.MachineAddRecipeAction;
|
||||
import stanhebben.zenscript.annotations.NotNull;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the IC2 compressor recipes. Recipes can be added but not
|
||||
* removed, due to IC2 API restrictions.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.ic2.Compressor")
|
||||
@ModOnly("IC2")
|
||||
public class Compressor {
|
||||
/**
|
||||
* Adds a new recipe to the compressor.
|
||||
*
|
||||
* The recipe input can be any pattern, as long as the stack size is determined.
|
||||
* The output can be any item stack.
|
||||
*
|
||||
* @param output recipe output
|
||||
* @param ingredient recipe input
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(
|
||||
@NotNull IItemStack output,
|
||||
@NotNull IIngredient ingredient) {
|
||||
if (ingredient.getAmount() < 0) {
|
||||
MineTweakerAPI.logWarning("invalid ingredient: " + ingredient + " - stack size not known");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new MachineAddRecipeAction(
|
||||
"compressor",
|
||||
Recipes.compressor,
|
||||
getItemStacks(output),
|
||||
null,
|
||||
new IC2RecipeInput(ingredient)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the recipe output for the given input. Will return the output
|
||||
* of a single item, even if the stack contains multiple items.
|
||||
*
|
||||
* @param input recipe input
|
||||
* @return recipe output
|
||||
*/
|
||||
@ZenMethod
|
||||
public static IItemStack getOutput(
|
||||
@NotNull IItemStack input) {
|
||||
RecipeOutput output = Recipes.compressor.getOutputFor(getItemStack(input), false);
|
||||
if (output == null || output.items.isEmpty()) {
|
||||
System.out.println("No output");
|
||||
return null;
|
||||
}
|
||||
return getIItemStack(output.items.get(0));
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.RecipeOutput;
|
||||
import ic2.api.recipe.Recipes;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getIItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStacks;
|
||||
import minetweaker.mods.ic2.IC2RecipeInput;
|
||||
import minetweaker.mods.ic2.MachineAddRecipeAction;
|
||||
import stanhebben.zenscript.annotations.NotNull;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the IC2 Extractor recipes.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.ic2.Extractor")
|
||||
@ModOnly("IC2")
|
||||
public class Extractor {
|
||||
/**
|
||||
* Adds a new recipe to the extractor.
|
||||
*
|
||||
* The recipe input can be any pattern, as long as the stack size is determined.
|
||||
* The output can be any item stack.
|
||||
*
|
||||
* @param output recipe output
|
||||
* @param ingredient recipe input
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(
|
||||
@NotNull IItemStack output,
|
||||
@NotNull IIngredient ingredient) {
|
||||
if (ingredient.getAmount() < 0) {
|
||||
MineTweakerAPI.logWarning("invalid ingredient: " + ingredient + " - stack size not known");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new MachineAddRecipeAction(
|
||||
"extractor",
|
||||
Recipes.extractor,
|
||||
getItemStacks(output),
|
||||
null,
|
||||
new IC2RecipeInput(ingredient)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the recipe output for the given input. Will return the output
|
||||
* of a single item, even if the stack contains multiple items.
|
||||
*
|
||||
* @param input recipe input
|
||||
* @return recipe output
|
||||
*/
|
||||
@ZenMethod
|
||||
public static IItemStack getOutput(
|
||||
@NotNull IItemStack input) {
|
||||
RecipeOutput output = Recipes.extractor.getOutputFor(getItemStack(input), false);
|
||||
if (output == null || output.items.isEmpty()) return null;
|
||||
return getIItemStack(output.items.get(0));
|
||||
}
|
||||
}
|
||||
+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;
|
||||
|
||||
/**
|
||||
* Add a fluid to the fluid heat generator
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenClass("mods.ic2.FluidHeatGenerator")
|
||||
@ModOnly("IC2")
|
||||
public class FluidHeatGenerator {
|
||||
@ZenMethod
|
||||
public static void addFluid(ILiquidStack liquidPerTick, int heatPerTick) {
|
||||
MineTweakerAPI.apply(new AddFluidAction(liquidPerTick.getName(), liquidPerTick.getAmount(), heatPerTick));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static boolean accepts(ILiquidStack liquid) {
|
||||
return Recipes.fluidHeatGenerator.acceptsFluid(FluidRegistry.getFluid(liquid.getName()));
|
||||
}
|
||||
|
||||
private static class AddFluidAction extends OneWayAction {
|
||||
private final String name;
|
||||
private final int liquidPerTick;
|
||||
private final int heatPerTick;
|
||||
|
||||
public AddFluidAction(String name, int liquidPerTick, int heatPerTick) {
|
||||
this.name = name;
|
||||
this.liquidPerTick = liquidPerTick;
|
||||
this.heatPerTick = heatPerTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
Recipes.fluidHeatGenerator.addFluid(name, liquidPerTick, heatPerTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding liquid " + name + " as fluid heat generator 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.heatPerTick;
|
||||
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.heatPerTick != other.heatPerTick) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package minetweaker.mods.ic2.machines;
|
||||
|
||||
import ic2.api.recipe.RecipeOutput;
|
||||
import ic2.api.recipe.Recipes;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getIItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStacks;
|
||||
import minetweaker.mods.ic2.IC2RecipeInput;
|
||||
import minetweaker.mods.ic2.MachineAddRecipeAction;
|
||||
import stanhebben.zenscript.annotations.NotNull;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the IC2 macerator recipes. Recipes can be added but not
|
||||
* removed, due to IC2 API restrictions.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.ic2.Macerator")
|
||||
@ModOnly("IC2")
|
||||
public class Macerator {
|
||||
/**
|
||||
* Adds a new recipe to the macerator.
|
||||
*
|
||||
* The recipe input can be any pattern, as long as the stack size is determined.
|
||||
* The output can be any item stack.
|
||||
*
|
||||
* @param output recipe output
|
||||
* @param ingredient recipe input
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(
|
||||
@NotNull IItemStack output,
|
||||
@NotNull IIngredient ingredient) {
|
||||
if (ingredient.getAmount() < 0) {
|
||||
MineTweakerAPI.logWarning("invalid ingredient: " + ingredient + " - stack size not known");
|
||||
} else {
|
||||
MineTweakerAPI.apply(new MachineAddRecipeAction(
|
||||
"macerator",
|
||||
Recipes.macerator,
|
||||
getItemStacks(output),
|
||||
null,
|
||||
new IC2RecipeInput(ingredient)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the recipe output for the given input. Will return the output
|
||||
* of a single item, even if the stack contains multiple items.
|
||||
*
|
||||
* @param input recipe input
|
||||
* @return recipe output
|
||||
*/
|
||||
@ZenMethod
|
||||
public static IItemStack getOutput(
|
||||
@NotNull IItemStack input) {
|
||||
RecipeOutput output = Recipes.macerator.getOutputFor(getItemStack(input), false);
|
||||
if (output == null || output.items.isEmpty()) return null;
|
||||
return getIItemStack(output.items.get(0));
|
||||
}
|
||||
}
|
||||
+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.apply(new MachineAddRecipeAction("matter amplifier", Recipes.matterAmplifier, new ItemStack[0], data, new IC2RecipeInput(item)));
|
||||
}
|
||||
}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* 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.RecipeOutput;
|
||||
import ic2.api.recipe.Recipes;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getIItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStacks;
|
||||
import minetweaker.mods.ic2.IC2RecipeInput;
|
||||
import minetweaker.mods.ic2.MachineAddRecipeAction;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.ic2.MetalFormer")
|
||||
@ModOnly("IC2")
|
||||
public class MetalFormer {
|
||||
/**
|
||||
* Adds an extruding recipe to the metal former.
|
||||
*
|
||||
* @param output output item
|
||||
* @param input input item
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addExtrudingRecipe(IItemStack output, IIngredient input) {
|
||||
MineTweakerAPI.apply(new MachineAddRecipeAction(
|
||||
"metal former - extruding",
|
||||
Recipes.metalformerExtruding,
|
||||
getItemStacks(output),
|
||||
null,
|
||||
new IC2RecipeInput(input)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the extruding output for the given input.
|
||||
*
|
||||
* @param input input item
|
||||
* @return output item, or null
|
||||
*/
|
||||
@ZenMethod
|
||||
public static IItemStack getExtrudingOutput(IItemStack input) {
|
||||
RecipeOutput output = Recipes.metalformerExtruding.getOutputFor(getItemStack(input), false);
|
||||
if (output == null || output.items.isEmpty()) return null;
|
||||
return getIItemStack(output.items.get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a rolling recipe to the metal former.
|
||||
*
|
||||
* @param output output item
|
||||
* @param input input item
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRollingRecipe(IItemStack output, IIngredient input) {
|
||||
MineTweakerAPI.apply(new MachineAddRecipeAction(
|
||||
"metal former - rolling",
|
||||
Recipes.metalformerRolling,
|
||||
getItemStacks(output),
|
||||
null,
|
||||
new IC2RecipeInput(input)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the extruding output for the given input.
|
||||
*
|
||||
* @param input input item
|
||||
* @return output item, or null
|
||||
*/
|
||||
@ZenMethod
|
||||
public static IItemStack getRollingOutput(IItemStack input) {
|
||||
RecipeOutput output = Recipes.metalformerRolling.getOutputFor(getItemStack(input), false);
|
||||
if (output == null || output.items.isEmpty()) return null;
|
||||
return getIItemStack(output.items.get(0));
|
||||
}
|
||||
/**
|
||||
* Adds a extruding recipe to the metal former.
|
||||
*
|
||||
* @param output output item
|
||||
* @param input input item
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addCuttingRecipe(IItemStack output, IIngredient input) {
|
||||
MineTweakerAPI.apply(new MachineAddRecipeAction(
|
||||
"metal former - cutting",
|
||||
Recipes.metalformerCutting,
|
||||
getItemStacks(output),
|
||||
null,
|
||||
new IC2RecipeInput(input)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cutting output for the given input.
|
||||
*
|
||||
* @param input input item
|
||||
* @return output item, or null
|
||||
*/
|
||||
@ZenMethod
|
||||
public static IItemStack getCuttingOutput(IItemStack input) {
|
||||
RecipeOutput output = Recipes.metalformerCutting.getOutputFor(getItemStack(input), false);
|
||||
if (output == null || output.items.isEmpty()) return null;
|
||||
return getIItemStack(output.items.get(0));
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package minetweaker.mods.ic2.machines;
|
||||
|
||||
import ic2.api.recipe.RecipeOutput;
|
||||
import ic2.api.recipe.Recipes;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getIItemStacks;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStacks;
|
||||
import minetweaker.mods.ic2.IC2RecipeInput;
|
||||
import minetweaker.mods.ic2.MachineAddRecipeAction;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.ic2.OreWasher")
|
||||
@ModOnly("IC2")
|
||||
public class OreWasher {
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack[] output, IIngredient input, int millibuckets) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setInteger("amount", millibuckets);
|
||||
MineTweakerAPI.apply(new MachineAddRecipeAction(
|
||||
"ore washer",
|
||||
Recipes.oreWashing,
|
||||
getItemStacks(output),
|
||||
nbt,
|
||||
new IC2RecipeInput(input)));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static IItemStack[] getOutput(IItemStack input) {
|
||||
RecipeOutput output = Recipes.oreWashing.getOutputFor(getItemStack(input), false);
|
||||
if (output == null || output.items.isEmpty()) return null;
|
||||
return getIItemStacks(output.items);
|
||||
}
|
||||
}
|
||||
@@ -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.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.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;
|
||||
|
||||
/**
|
||||
* Add a fluid to the semi-fluid generator
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenClass("mods.ic2.SemiFluidGenerator")
|
||||
@ModOnly("IC2")
|
||||
public class SemiFluidGenerator {
|
||||
@ZenMethod
|
||||
public static void addFluid(ILiquidStack liquidPerTick, int energyPerTick) {
|
||||
MineTweakerAPI.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
package minetweaker.mods.ic2.machines;
|
||||
|
||||
import ic2.api.recipe.RecipeOutput;
|
||||
import ic2.api.recipe.Recipes;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getIItemStacks;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStacks;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import minetweaker.mods.ic2.IC2RecipeInput;
|
||||
import minetweaker.mods.ic2.MachineAddRecipeAction;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Provides access to the IC2 compressor recipes. Recipes can be added but not
|
||||
* removed, due to IC2 API restrictions.
|
||||
*
|
||||
* @author Stan Hebben
|
||||
*/
|
||||
@ZenClass("mods.ic2.ThermalCentrifuge")
|
||||
@ModOnly("IC2")
|
||||
public class ThermalCentrifuge {
|
||||
/**
|
||||
* Adds a new recipe to the centrifuge.
|
||||
*
|
||||
* The recipe input can be any ingredient, as long as the stack size is determined.
|
||||
* The output is an array of item stacks.
|
||||
*
|
||||
* @param output recipe outputs
|
||||
* @param ingredient recipe input
|
||||
* @param minHeat minimum centrifuge heat level
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack[] output, IIngredient ingredient, int minHeat) {
|
||||
if (ingredient.getAmount() < 0) {
|
||||
MineTweakerAPI.logWarning("invalid ingredient: " + ingredient + " - stack size not known");
|
||||
} else {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setInteger("minHeat", minHeat);
|
||||
MineTweakerAPI.apply(new MachineAddRecipeAction(
|
||||
"thermal centrifuge",
|
||||
Recipes.centrifuge,
|
||||
getItemStacks(output),
|
||||
tag,
|
||||
new IC2RecipeInput(ingredient)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new recipe to the centrifuge.
|
||||
*
|
||||
* The recipe input can be any ingredient, as long as the stack size is determined.
|
||||
* The output can be any item stack.
|
||||
*
|
||||
* @param output recipe output
|
||||
* @param ingredient recipe input
|
||||
* @param minHeat minimum centrifuge heat level
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IIngredient ingredient, int minHeat) {
|
||||
addRecipe(new IItemStack[] { output }, ingredient, minHeat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the recipe output for the given input. Will return the output
|
||||
* of a single item, even if the stack contains multiple items.
|
||||
*
|
||||
* @param input recipe input
|
||||
* @return recipe output
|
||||
*/
|
||||
@ZenMethod
|
||||
public static IItemStack[] getOutput(IItemStack input) {
|
||||
RecipeOutput output = Recipes.centrifuge.getOutputFor(getItemStack(input), false);
|
||||
if (output == null || output.items.isEmpty()) return null;
|
||||
return getIItemStacks(output.items);
|
||||
}
|
||||
}
|
||||
@@ -49,5 +49,6 @@ ext.projects18 = [
|
||||
ext.forgeVersion1102 = "1.10.2-12.18.0.2005-1.10.0"
|
||||
ext.projects1102 = [
|
||||
'MineTweaker3-MC1102-Main',
|
||||
'MineTweaker3-MC1102-Mod-JEI'
|
||||
'MineTweaker3-MC1102-Mod-JEI',
|
||||
'MineTweaker3-MC1102-Mod-IC2'
|
||||
]
|
||||
Reference in new issue
Block a user