Skip to content

Commit

Permalink
Ore dict support
Browse files Browse the repository at this point in the history
  • Loading branch information
Techlone committed Mar 7, 2016
1 parent 4bf022e commit 19dcfba
Show file tree
Hide file tree
Showing 43 changed files with 467 additions and 3,514 deletions.
99 changes: 17 additions & 82 deletions src/main/java/gttweaker/mods/gregtech/Fuels.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package gttweaker.mods.gregtech;

import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;

Expand All @@ -24,8 +22,8 @@ public class Fuels {
* Adds a Diesel Engine fuel. If the given item does not contain any liquid,
* it will generate the equivalent of 1000 millibuckets.
*
* @param output output item (optional, can be null)
* @param input input item
* @param output output item (optional, can be null)
* @param input input item
* @param euPerMillibucket eu production per millibucket
*/
@ZenMethod
Expand All @@ -37,8 +35,8 @@ public static void addDieselFuel(IItemStack output, IIngredient input, int euPer
* Adds a Gas Turbine fuel. If the given item does not contain any liquid,
* it will generate the equivalent of 1000 millibuckets.
*
* @param output output item (optional, can be null)
* @param input input item
* @param output output item (optional, can be null)
* @param input input item
* @param euPerMillibucket eu production per millibucket
*/
@ZenMethod
Expand All @@ -50,8 +48,8 @@ public static void addGasTurbineFuel(IItemStack output, IIngredient input, int e
* Adds a Thermal Generator fuel. If the given item does not contain any
* liquid, it will generate the equivalent of 1000 millibuckets.
*
* @param output output item (optional, can be null)
* @param input input item
* @param output output item (optional, can be null)
* @param input input item
* @param euPerMillibucket eu production per millibucket
*/
@ZenMethod
Expand All @@ -63,8 +61,8 @@ public static void addThermalGeneratorFuel(IItemStack output, IIngredient input,
* Adds a Dense Fluid Generator fuel. If the given item does not contain any
* liquid, it will generate the equivalent of 1000 millibuckets.
*
* @param output output item (optional, can be null)
* @param input input item
* @param output output item (optional, can be null)
* @param input input item
* @param euPerMillibucket eu production per millibucket
*/
@ZenMethod
Expand All @@ -76,8 +74,8 @@ public static void addDenseFluidFuel(IItemStack output, IIngredient input, int e
* Adds a Plasma Generator fuel. If the given item does not contain any
* liquid, it will generate the equivalent of 1000 millibuckets.
*
* @param output output item (optional, can be null)
* @param input input item
* @param output output item (optional, can be null)
* @param input input item
* @param euPerMillibucket eu production per millibucket
*/
@ZenMethod
Expand All @@ -89,8 +87,8 @@ public static void addPlasmaGeneratorFuel(IItemStack output, IIngredient input,
* Adds a Magic Generator fuel. If the given item does not contain any liquid,
* it will generate the equivalent of 1000 millibuckets.
*
* @param output output item (optional, can be null)
* @param input input item
* @param output output item (optional, can be null)
* @param input input item
* @param euPerMillibucket eu production per millibucket
*/
@ZenMethod
Expand All @@ -102,79 +100,16 @@ public static void addMagicGeneratorFuel(IItemStack output, IIngredient input, i
// ### Action classes ###
// ######################

private static class AddRecipeAction extends OneWayAction {
private static final String[] GENERATORS = {
"diesel",
"gas turbine",
"thermal",
"dense fluid",
"plasma",
"magic"
};

private final IItemStack output;
private final IIngredient input;
private final int euPerMillibucket;
private final int type;
private static class AddRecipeAction extends AddMultipleRecipeAction {
private static final String[] GENERATORS = {"diesel", "gas turbine", "thermal", "dense fluid", "plasma", "magic"};

public AddRecipeAction(IItemStack output, IIngredient input, int euPerMillibucket, int type) {
this.output = output;
this.input = input;
this.euPerMillibucket = euPerMillibucket;
this.type = type;
}

@Override
public void apply() {
RA.addFuel(
MineTweakerMC.getItemStack(input),
MineTweakerMC.getItemStack(output),
euPerMillibucket,
type);
}

@Override
public String describe() {
return "Adding " + GENERATORS[type] + " fuel " + input;
}

@Override
public Object getOverrideKey() {
return null;
}

@Override
public int hashCode() {
int hash = 5;
hash = 59 * hash + (this.output != null ? this.output.hashCode() : 0);
hash = 59 * hash + (this.input != null ? this.input.hashCode() : 0);
hash = 59 * hash + this.euPerMillibucket;
hash = 59 * hash + this.type;
return hash;
super("Adding " + GENERATORS[type] + " fuel " + input, input, output, euPerMillibucket, type);
}

@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AddRecipeAction other = (AddRecipeAction) obj;
if (this.output != other.output && (this.output == null || !this.output.equals(other.output))) {
return false;
}
if (this.input != other.input && (this.input == null || !this.input.equals(other.input))) {
return false;
}
if (this.euPerMillibucket != other.euPerMillibucket) {
return false;
}
if (this.type != other.type) {
return false;
}
return true;
protected void applySingleRecipe(ArgIterator i) {
RA.addFuel(i.nextItem(), i.nextItem(), i.nextInt(), i.nextInt());
}
}
}
38 changes: 10 additions & 28 deletions src/main/java/gttweaker/mods/gregtech/machines/AlloySmelter.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;

Expand All @@ -23,36 +22,19 @@ public class AlloySmelter {
/**
* Adds an alloy smelter recipe.
*
* @param output alloy smelter output
* @param input1 primary input
* @param input2 secondary input
* @param output alloy smelter output
* @param input1 primary input
* @param input2 secondary input
* @param durationTicks smelting time, in ticks
* @param euPerTick eu consumption per tick
* @param euPerTick eu consumption per tick
*/
@ZenMethod
public static void addRecipe(IItemStack output, IIngredient input1, IIngredient input2, int durationTicks, int euPerTick) {
MineTweakerAPI.apply(new AddRecipeAction(output, input1, input2, durationTicks, euPerTick));
}

// ######################
// ### Action classes ###
// ######################

private static class AddRecipeAction extends AddMultipleRecipeAction {
public AddRecipeAction(IItemStack output, IIngredient input1, IIngredient input2, int duration, int euPerTick) {
super("Adding alloy smelter recipe for " + output, input1, input2, output, duration, euPerTick);
}

@Override
protected void applySingleRecipe(Object[] args) {
int i = 0;
RA.addAlloySmelterRecipe(
(ItemStack) args[i++],
(ItemStack) args[i++],
(ItemStack) args[i++],
(Integer) args[i++],
(Integer) args[i++]
);
}
MineTweakerAPI.apply(new AddMultipleRecipeAction("Adding alloy smelter recipe for " + output, input1, input2, output, durationTicks, euPerTick) {
@Override
protected void applySingleRecipe(ArgIterator i) {
RA.addAlloySmelterRecipe(i.nextItem(), i.nextItem(), i.nextItem(), i.nextInt(), i.nextInt());
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import minetweaker.MineTweakerAPI;
import minetweaker.annotations.ModOnly;
import minetweaker.api.item.IIngredient;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;

Expand All @@ -22,33 +21,16 @@ public class Amplifabricator {
/**
* Adds a Amplifabricator recipe.
*
* @param input primary Input
* @param duration reaction time, in ticks
* @param amount amount in mb of Liquid UU Output
*
* @param input primary Input
* @param duration reaction time, in ticks
*/
@ZenMethod
public static void addRecipe(IIngredient input, int duration, int amount) {
MineTweakerAPI.apply(new AddRecipeAction(input, duration, amount));
}

// ######################
// ### Action classes ###
// ######################

private static class AddRecipeAction extends AddMultipleRecipeAction {
public AddRecipeAction(IIngredient input, int duration, int amount) {
super("Adding Amplifabricator recipe for " + input, input, duration, amount);
}

@Override
protected void applySingleRecipe(Object[] args) {
int i = 0;
RA.addAmplifier(
(ItemStack) args[i++],
(Integer) args[i++],
(Integer) args[i++]
);
}
public static void addRecipe(IIngredient input, int duration, int amount) {
MineTweakerAPI.apply(new AddMultipleRecipeAction("Adding Amplifabricator recipe for " + input, input, duration, amount) {
@Override
protected void applySingleRecipe(ArgIterator i) {
RA.addAmplifier(i.nextItem(), i.nextInt(), i.nextInt());
}
});
}
}
31 changes: 6 additions & 25 deletions src/main/java/gttweaker/mods/gregtech/machines/ArcFurnace.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;

Expand Down Expand Up @@ -39,29 +37,12 @@ public static void addRecipe(IItemStack[] outputs, IIngredient input, ILiquidSta
} else if (outputs.length != outChances.length) {
MineTweakerAPI.logError("Number of Outputs does not equal number of Chances");
} else {
MineTweakerAPI.apply(new AddRecipeAction(outputs, input, fluidInput, outChances, durationTicks, euPerTick));
}
}

// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends AddMultipleRecipeAction {
public AddRecipeAction(IItemStack[] output, IIngredient input, ILiquidStack fluidInput, int[] outChances, int duration, int euPerTick) {
super("Adding Arc Furnace recipe for " + input, input, fluidInput, output, outChances, duration, euPerTick);
}

@Override
public void applySingleRecipe(Object[] args) {
int i = 0;
RA.addSimpleArcFurnaceRecipe(
(ItemStack) args[i++],
(FluidStack) args[i++],
(ItemStack[]) args[i++],
(int[]) args[i++],
(Integer) args[i++],
(Integer) args[i++]
);
MineTweakerAPI.apply(new AddMultipleRecipeAction("Adding Arc Furnace recipe for " + input, input, fluidInput, outputs, outChances, durationTicks, euPerTick) {
@Override
protected void applySingleRecipe(ArgIterator i) {
RA.addSimpleArcFurnaceRecipe(i.nextItem(), i.nextFluid(), i.nextItemArr(), i.nextIntArr(), i.nextInt(), i.nextInt());
}
});
}
}
}
60 changes: 14 additions & 46 deletions src/main/java/gttweaker/mods/gregtech/machines/Assembler.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;

Expand All @@ -30,57 +28,27 @@ public class Assembler {
* @param output recipe output
* @param input1 primary input
* @param input2 secondary input (optional, can be null)
* @param fluidInput1 primary fluidInput
* @param fluidInput primary fluidInput
* @param durationTicks assembling duration, in ticks
* @param euPerTick eu consumption per tick
*/
@ZenMethod
public static void addRecipe(IItemStack output, IIngredient input1, IIngredient input2, ILiquidStack fluidInput1, int durationTicks, int euPerTick) {
MineTweakerAPI.apply(new AddFluidRecipeAction(output, input1, input2, fluidInput1, durationTicks, euPerTick));
public static void addRecipe(IItemStack output, IIngredient input1, IIngredient input2, ILiquidStack fluidInput, int durationTicks, int euPerTick) {
MineTweakerAPI.apply(new AddMultipleRecipeAction("Adding assembler recipe with fluid Support for " + output, input1, input2, fluidInput, output, durationTicks, euPerTick) {
@Override
protected void applySingleRecipe(ArgIterator i) {
RA.addAssemblerRecipe(i.nextItem(), i.nextItem(), i.nextFluid(), i.nextItem(), i.nextInt(), i.nextInt());
}
});
}

@ZenMethod
public static void addRecipe(IItemStack output, IIngredient input1, IIngredient input2, int durationTicks, int euPerTick) {
MineTweakerAPI.apply(new AddRecipeAction(output, input1, input2, durationTicks, euPerTick));
}

// ######################
// ### Action classes ###
// ######################
private static class AddRecipeAction extends AddMultipleRecipeAction {
public AddRecipeAction(IItemStack output, IIngredient input1, IIngredient input2, int duration, int euPerTick) {
super("Adding assembler recipe for " + output, input1, input2, output, duration, euPerTick);
}

@Override
protected void applySingleRecipe(Object[] args) {
int i = 0;
RA.addAssemblerRecipe(
(ItemStack) args[i++],
(ItemStack) args[i++],
(ItemStack) args[i++],
(Integer) args[i++],
(Integer) args[i++]
);
}
}

private static class AddFluidRecipeAction extends AddMultipleRecipeAction {
public AddFluidRecipeAction(IItemStack output, IIngredient input1, IIngredient input2, ILiquidStack fluidInput1, int duration, int euPerTick) {
super("Adding assembler recipe with fluid Support for " + output, input1, input2, fluidInput1, output, duration, euPerTick);
}

@Override
protected void applySingleRecipe(Object[] args) {
int i = 0;
RA.addAssemblerRecipe(
(ItemStack) args[i++],
(ItemStack) args[i++],
(FluidStack) args[i++],
(ItemStack) args[i++],
(Integer) args[i++],
(Integer) args[i++]
);
}
MineTweakerAPI.apply(new AddMultipleRecipeAction("Adding assembler recipe for " + output, input1, input2, output, durationTicks, euPerTick) {
@Override
protected void applySingleRecipe(ArgIterator i) {
RA.addAssemblerRecipe(i.nextItem(), i.nextItem(), i.nextItem(), i.nextInt(), i.nextInt());
}
});
}
}
Loading

0 comments on commit 19dcfba

Please sign in to comment.