mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-22 13:10:13 +00:00
started work on proper recipes for the still, probably to be renamed vat
This commit is contained in:
1 parent
21724f33b2
commit
b190296e3f
11 files changed
+149
-40
No files matched your search
@@ -2,7 +2,6 @@ package crazypants.enderio.machine.alloy;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -101,7 +100,7 @@ public class AlloyRecipeManager {
|
||||
Log.debug("Could not add invalid recipe: " + recipe);
|
||||
return;
|
||||
}
|
||||
IRecipe rec = getRecipeForInputs(Arrays.asList(recipe.getInputStacks()));
|
||||
IRecipe rec = getRecipeForInputs(recipe.getInputStacks());
|
||||
if(rec != null) {
|
||||
Log.warn("Not adding supplied recipe as a recipe already exists for the input: " + recipe);
|
||||
return;
|
||||
|
||||
@@ -223,7 +223,7 @@ public class BasicAlloyRecipe implements IAlloyRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getInputStacks() {
|
||||
public List<ItemStack> getInputStacks() {
|
||||
return recipe.getInputStacks();
|
||||
}
|
||||
|
||||
@@ -244,4 +244,9 @@ public class BasicAlloyRecipe implements IAlloyRecipe {
|
||||
public RecipeInput[] getInputs() {
|
||||
return recipe.getInputs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FluidStack> getInputFluidStacks() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,9 @@ public interface IRecipe {
|
||||
|
||||
RecipeInput[] getInputs();
|
||||
|
||||
ItemStack[] getInputStacks();
|
||||
List<ItemStack> getInputStacks();
|
||||
|
||||
List<FluidStack> getInputFluidStacks();
|
||||
|
||||
boolean isInputForRecipe(List<ItemStack> test);
|
||||
|
||||
|
||||
@@ -10,7 +10,11 @@ public class OreDictionaryRecipeInput extends RecipeInput {
|
||||
private int oreId;
|
||||
|
||||
public OreDictionaryRecipeInput(ItemStack itemStack, int oreId) {
|
||||
super(itemStack);
|
||||
this(itemStack, oreId, 1);
|
||||
}
|
||||
|
||||
public OreDictionaryRecipeInput(ItemStack stack, int oreId, float multiplier) {
|
||||
super(stack, true, multiplier);
|
||||
this.oreId = oreId;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package crazypants.enderio.machine.recipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -99,15 +100,30 @@ public class Recipe implements IRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getInputStacks() {
|
||||
public List<ItemStack> getInputStacks() {
|
||||
if(inputs == null) {
|
||||
return new ItemStack[0];
|
||||
return Collections.emptyList();
|
||||
}
|
||||
ItemStack[] res = new ItemStack[inputs.length];
|
||||
for (int i = 0; i < res.length; i++) {
|
||||
List<ItemStack> res = new ArrayList<ItemStack>(inputs.length);
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
RecipeInput in = inputs[i];
|
||||
if(in != null) {
|
||||
res[i] = in.getInput();
|
||||
if(in != null && in.getInput() != null) {
|
||||
res.add(in.getInput());
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FluidStack> getInputFluidStacks() {
|
||||
if(inputs == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<FluidStack> res = new ArrayList<FluidStack>(inputs.length);
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
RecipeInput in = inputs[i];
|
||||
if(in != null && in.getFluidInput() != null) {
|
||||
res.add(in.getFluidInput());
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
||||
@@ -43,11 +43,11 @@ public class RecipeConfigParser extends DefaultHandler {
|
||||
public static final String AT_DUMP_ITEMS = "modObjects";
|
||||
public static final String AT_ORE_DICT = "oreDictionary";
|
||||
public static final String AT_ENERGY_COST = "energyCost";
|
||||
public static final String AT_ITEM_ID = "itemID";
|
||||
public static final String AT_ITEM_META = "itemMeta";
|
||||
public static final String AT_ITEM_NAME = "itemName";
|
||||
public static final String AT_MOD_ID = "modID";
|
||||
public static final String AT_NUMBER = "number";
|
||||
public static final String AT_MULTIPLIER = "multiplier";
|
||||
public static final String AT_CHANCE = "chance";
|
||||
public static final String AT_EXP = "exp";
|
||||
|
||||
@@ -331,7 +331,7 @@ public class RecipeConfigParser extends DefaultHandler {
|
||||
}
|
||||
ItemStack stack = ores.get(0).copy();
|
||||
stack.stackSize = stackSize;
|
||||
return new OreDictionaryRecipeInput(stack, OreDictionary.getOreID(oreDict));
|
||||
return new OreDictionaryRecipeInput(stack, OreDictionary.getOreID(oreDict), getFloatValue(AT_MULTIPLIER, attributes, 1));
|
||||
}
|
||||
|
||||
boolean useMeta = true;
|
||||
@@ -341,13 +341,6 @@ public class RecipeConfigParser extends DefaultHandler {
|
||||
}
|
||||
int itemMeta = getIntValue(AT_ITEM_META, attributes, 0);
|
||||
|
||||
int itemID = getIntValue(AT_ITEM_ID, attributes, -1);
|
||||
if(itemID > 0) {
|
||||
|
||||
//TODO:1.7 do I want to support ID still?
|
||||
//return new RecipeInput(new ItemStack(itemID, stackSize, itemMeta), useMeta);
|
||||
return null;
|
||||
}
|
||||
ItemStack res = null;
|
||||
|
||||
String modId = getStringValue(AT_MOD_ID, attributes, null);
|
||||
@@ -370,7 +363,7 @@ public class RecipeConfigParser extends DefaultHandler {
|
||||
Log.debug("Could not create an item stack from the attributes " + toString(attributes));
|
||||
return null;
|
||||
}
|
||||
return new RecipeInput(res, useMeta);
|
||||
return new RecipeInput(res, useMeta, getFloatValue(AT_MULTIPLIER, attributes, 1));
|
||||
}
|
||||
|
||||
public static boolean getBooleanValue(String qName, Attributes attributes, boolean def) {
|
||||
|
||||
@@ -10,20 +10,33 @@ public class RecipeInput {
|
||||
|
||||
private final FluidStack fluid;
|
||||
|
||||
private final float mulitplier;
|
||||
|
||||
public RecipeInput(ItemStack input) {
|
||||
this(input, true);
|
||||
}
|
||||
|
||||
public RecipeInput(ItemStack input, boolean useMeta) {
|
||||
this.input = input;
|
||||
this.useMeta = useMeta;
|
||||
this.fluid = null;
|
||||
this(input, useMeta, null, 1);
|
||||
}
|
||||
|
||||
public RecipeInput(FluidStack fluid) {
|
||||
this.input = null;
|
||||
this.useMeta = false;
|
||||
this(null, false, fluid, 1f);
|
||||
}
|
||||
|
||||
public RecipeInput(FluidStack fluidStack, float mulitplier) {
|
||||
this(null, true, fluidStack, mulitplier);
|
||||
}
|
||||
|
||||
public RecipeInput(ItemStack item, boolean useMeta, float multiplier) {
|
||||
this(item, useMeta, null, multiplier);
|
||||
}
|
||||
|
||||
protected RecipeInput(ItemStack input, boolean useMeta, FluidStack fluid, float mulitplier) {
|
||||
this.input = input;
|
||||
this.useMeta = useMeta;
|
||||
this.fluid = fluid;
|
||||
this.mulitplier = mulitplier;
|
||||
}
|
||||
|
||||
public boolean isFluid() {
|
||||
@@ -38,6 +51,10 @@ public class RecipeInput {
|
||||
return fluid;
|
||||
}
|
||||
|
||||
public float getMulitplier() {
|
||||
return mulitplier;
|
||||
}
|
||||
|
||||
public boolean isInput(ItemStack test) {
|
||||
if(test == null || input == null) {
|
||||
return false;
|
||||
|
||||
@@ -1,31 +1,68 @@
|
||||
package crazypants.enderio.machine.still;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import crazypants.enderio.machine.recipe.IRecipe;
|
||||
import crazypants.enderio.machine.recipe.Recipe;
|
||||
import crazypants.enderio.machine.recipe.RecipeInput;
|
||||
import crazypants.enderio.machine.recipe.RecipeOutput;
|
||||
|
||||
public class StillRecipe implements IRecipe {
|
||||
|
||||
protected final FluidStack inputFluidStack;
|
||||
protected final ItemStack[] inputStacks;
|
||||
protected final List<ItemStack> inputStacks;
|
||||
protected final FluidStack outputFluidStack;
|
||||
|
||||
protected final RecipeInput[] inputs;
|
||||
protected final RecipeOutput[] output;
|
||||
protected final float energyRequired;
|
||||
|
||||
public StillRecipe(FluidStack inputFluid, FluidStack outputFluid, ItemStack... inputStacks) {
|
||||
this.inputFluidStack = inputFluid;
|
||||
this.inputStacks = inputStacks;
|
||||
this.outputFluidStack = outputFluid;
|
||||
// public StillRecipe(FluidStack inputFluid, FluidStack outputFluid, ItemStack... inputStacks) {
|
||||
// this.inputFluidStack = inputFluid;
|
||||
// this.inputStacks = inputStacks;
|
||||
// this.outputFluidStack = outputFluid;
|
||||
//
|
||||
// List<RecipeInput> inputList = new ArrayList<RecipeInput>(3);
|
||||
// if(inputFluidStack != null) {
|
||||
// inputList.add(new RecipeInput(inputFluid));
|
||||
// }
|
||||
// if(inputStacks != null) {
|
||||
// for (ItemStack in : inputStacks) {
|
||||
// if(in != null) {
|
||||
// inputList.add(new RecipeInput(in));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// inputs = inputList.toArray(new RecipeInput[inputList.size()]);
|
||||
// output = new RecipeOutput[] { new RecipeOutput(outputFluidStack) };
|
||||
// }
|
||||
|
||||
public StillRecipe(Recipe recipe) {
|
||||
List<FluidStack> fluids = recipe.getInputFluidStacks();
|
||||
if(fluids != null && !fluids.isEmpty()) {
|
||||
inputFluidStack = fluids.get(0).copy();
|
||||
} else {
|
||||
inputFluidStack = null;
|
||||
}
|
||||
this.inputStacks = recipe.getInputStacks();
|
||||
|
||||
FluidStack os = null;
|
||||
for (RecipeOutput output : recipe.getOutputs()) {
|
||||
if(output.isFluid()) {
|
||||
os = output.getFluidOutput().copy();
|
||||
break;
|
||||
}
|
||||
}
|
||||
outputFluidStack = os;
|
||||
|
||||
List<RecipeInput> inputList = new ArrayList<RecipeInput>(3);
|
||||
if(inputFluidStack != null) {
|
||||
inputList.add(new RecipeInput(inputFluid));
|
||||
inputList.add(new RecipeInput(inputFluidStack));
|
||||
}
|
||||
if(inputStacks != null) {
|
||||
for (ItemStack in : inputStacks) {
|
||||
@@ -36,16 +73,33 @@ public class StillRecipe implements IRecipe {
|
||||
}
|
||||
inputs = inputList.toArray(new RecipeInput[inputList.size()]);
|
||||
output = new RecipeOutput[] { new RecipeOutput(outputFluidStack) };
|
||||
|
||||
energyRequired = recipe.getEnergyRequired();
|
||||
|
||||
float inputFluidMul = 1;
|
||||
float outputFluidMul = 1;
|
||||
for (RecipeInput ri : recipe.getInputs()) {
|
||||
if(!ri.isFluid()) {
|
||||
inputFluidMul *= ri.getMulitplier();
|
||||
}
|
||||
outputFluidMul *= ri.getMulitplier();
|
||||
}
|
||||
inputFluidStack.amount = Math.round(inputFluidMul * FluidContainerRegistry.BUCKET_VOLUME);
|
||||
outputFluidStack.amount = Math.round(outputFluidMul * FluidContainerRegistry.BUCKET_VOLUME);
|
||||
|
||||
System.out.println("StillRecipe.StillRecipe: Input amount = " + inputFluidStack.amount);
|
||||
System.out.println("StillRecipe.StillRecipe: Output amount = " + outputFluidStack.amount);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return inputFluidStack != null && inputStacks != null && inputStacks.length > 0 && inputStacks.length < 3 && outputFluidStack != null;
|
||||
return inputFluidStack != null && inputStacks != null && !inputStacks.isEmpty() && inputStacks.size() < 3 && outputFluidStack != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEnergyRequired() {
|
||||
return 1000;
|
||||
return energyRequired;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,7 +113,7 @@ public class StillRecipe implements IRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getInputStacks() {
|
||||
public List<ItemStack> getInputStacks() {
|
||||
return inputStacks;
|
||||
}
|
||||
|
||||
@@ -121,4 +175,9 @@ public class StillRecipe implements IRecipe {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FluidStack> getInputFluidStacks() {
|
||||
return Collections.singletonList(inputFluidStack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,7 +13,10 @@ import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.MachineRecipeInput;
|
||||
import crazypants.enderio.machine.MachineRecipeRegistry;
|
||||
import crazypants.enderio.machine.recipe.IRecipe;
|
||||
import crazypants.enderio.machine.recipe.Recipe;
|
||||
import crazypants.enderio.machine.recipe.RecipeConfig;
|
||||
import crazypants.enderio.machine.recipe.RecipeInput;
|
||||
import crazypants.enderio.machine.recipe.RecipeOutput;
|
||||
|
||||
public class StillRecipeManager {
|
||||
|
||||
@@ -38,10 +41,22 @@ public class StillRecipeManager {
|
||||
// } else {
|
||||
// Log.error("Could not load recipes for SAG Mill.");
|
||||
// }
|
||||
FluidStack resStack = FluidRegistry.getFluidStack("nutrientdistillation", FluidContainerRegistry.BUCKET_VOLUME);
|
||||
|
||||
MachineRecipeRegistry.instance.registerRecipe(ModObject.blockStill.unlocalisedName, new StillMachineRecipe());
|
||||
addRecipe(new StillRecipe(new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME), resStack, new ItemStack(Items.rotten_flesh),
|
||||
new ItemStack(Items.nether_wart)));
|
||||
|
||||
RecipeInput[] ins = new RecipeInput[] {
|
||||
new RecipeInput(new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME), 0.5f),
|
||||
new RecipeInput(new ItemStack(Items.rotten_flesh), true, 2),
|
||||
new RecipeInput(new ItemStack(Items.nether_wart), true, 1.5f)
|
||||
};
|
||||
|
||||
FluidStack resStack = FluidRegistry.getFluidStack("nutrientdistillation", FluidContainerRegistry.BUCKET_VOLUME);
|
||||
RecipeOutput[] outs = new RecipeOutput[] {
|
||||
new RecipeOutput(resStack)
|
||||
};
|
||||
|
||||
Recipe rec = new Recipe(ins, outs, 1000);
|
||||
addRecipe(new StillRecipe(rec));
|
||||
}
|
||||
|
||||
public void addCustumRecipes(String xmlDef) {
|
||||
|
||||
@@ -89,7 +89,6 @@ public class TileStill extends AbstractPoweredTaskEntity implements IFluidHandle
|
||||
|
||||
@Override
|
||||
protected void drainInputFluid(MachineRecipeInput fluid) {
|
||||
System.out.println("TileStill.drainInputFluid: ");
|
||||
inputTank.drain(fluid.fluid.amount, true);
|
||||
tanksDirty = true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user