mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-20 04:09:43 +00:00
Still working some more.
This commit is contained in:
1 parent
b190296e3f
commit
b13cbdace0
14 files changed
+253
-175
No files matched your search
@@ -69,4 +69,8 @@ public class MachineRecipeInput {
|
||||
root.setInteger("slotNum", slotNumber);
|
||||
}
|
||||
|
||||
public boolean isFluid() {
|
||||
return fluid != null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -109,8 +109,14 @@ public class AlloyRecipeManager {
|
||||
}
|
||||
|
||||
IRecipe getRecipeForInputs(List<ItemStack> inputs) {
|
||||
MachineRecipeInput[] ins = new MachineRecipeInput[inputs.size()];
|
||||
|
||||
for (int i = 0; i < inputs.size(); i++) {
|
||||
ins[i] = new MachineRecipeInput(-1, inputs.get(i));
|
||||
}
|
||||
|
||||
for (IAlloyRecipe rec : recipes) {
|
||||
if(rec.isInputForRecipe(inputs)) {
|
||||
if(rec.isInputForRecipe(ins)) {
|
||||
return rec;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class BasicAlloyRecipe implements IAlloyRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidInput(ItemStack input) {
|
||||
public boolean isValidInput(int slot, ItemStack input) {
|
||||
if(input == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -228,16 +228,11 @@ public class BasicAlloyRecipe implements IAlloyRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInputForRecipe(List<ItemStack> test) {
|
||||
if(test == null) {
|
||||
public boolean isInputForRecipe(MachineRecipeInput... inputs) {
|
||||
if(inputs == null) {
|
||||
return false;
|
||||
}
|
||||
return recipe.isInputForRecipe(test);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInputForRecipe(List<ItemStack> test, List<FluidStack> testFluids) {
|
||||
return (testFluids == null || testFluids.isEmpty()) && isInputForRecipe(test);
|
||||
return recipe.isInputForRecipe(inputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,13 +2,13 @@ package crazypants.enderio.machine.crusher;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import crazypants.enderio.Config;
|
||||
import crazypants.enderio.Log;
|
||||
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;
|
||||
@@ -69,7 +69,7 @@ public class CrusherRecipeManager {
|
||||
return null;
|
||||
}
|
||||
for (Recipe recipe : recipes) {
|
||||
if(recipe.isInputForRecipe(Collections.singletonList(input))) {
|
||||
if(recipe.isInputForRecipe(new MachineRecipeInput(0, input))) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import crazypants.enderio.machine.MachineRecipeInput;
|
||||
|
||||
public interface IRecipe {
|
||||
|
||||
@@ -19,11 +20,13 @@ public interface IRecipe {
|
||||
|
||||
List<FluidStack> getInputFluidStacks();
|
||||
|
||||
boolean isInputForRecipe(List<ItemStack> test);
|
||||
// boolean isInputForRecipe(List<ItemStack> test);
|
||||
//
|
||||
// boolean isInputForRecipe(List<ItemStack> test, List<FluidStack> testFluids);
|
||||
|
||||
boolean isInputForRecipe(List<ItemStack> test, List<FluidStack> testFluids);
|
||||
boolean isInputForRecipe(MachineRecipeInput... inputs);
|
||||
|
||||
boolean isValidInput(ItemStack item);
|
||||
boolean isValidInput(int slotNumber, ItemStack item);
|
||||
|
||||
boolean isValidInput(FluidStack fluid);
|
||||
|
||||
|
||||
@@ -9,12 +9,12 @@ public class OreDictionaryRecipeInput extends RecipeInput {
|
||||
|
||||
private int oreId;
|
||||
|
||||
public OreDictionaryRecipeInput(ItemStack itemStack, int oreId) {
|
||||
this(itemStack, oreId, 1);
|
||||
public OreDictionaryRecipeInput(ItemStack itemStack, int oreId, int slot) {
|
||||
this(itemStack, oreId, 1, slot);
|
||||
}
|
||||
|
||||
public OreDictionaryRecipeInput(ItemStack stack, int oreId, float multiplier) {
|
||||
super(stack, true, multiplier);
|
||||
public OreDictionaryRecipeInput(ItemStack stack, int oreId, float multiplier, int slot) {
|
||||
super(stack, true, multiplier, slot);
|
||||
this.oreId = oreId;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import crazypants.enderio.machine.MachineRecipeInput;
|
||||
|
||||
public class Recipe implements IRecipe {
|
||||
|
||||
@@ -29,50 +30,36 @@ public class Recipe implements IRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInputForRecipe(List<ItemStack> test) {
|
||||
return isInputForRecipe(test, null);
|
||||
public boolean isInputForRecipe(MachineRecipeInput... inputs) {
|
||||
if(inputs == null || inputs.length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int numFound = 0;
|
||||
for (MachineRecipeInput input : inputs) {
|
||||
if(input.isFluid()) {
|
||||
RecipeInput ri = getInputForStack(input.fluid);
|
||||
if(ri == null || ri.getFluidInput() == null) {
|
||||
return false;
|
||||
}
|
||||
numFound++;
|
||||
} else {
|
||||
RecipeInput ri = getInputForStack(input.item);
|
||||
if(ri == null || ri.getInput() == null || ri.getSlotNumber() != input.slotNumber) {
|
||||
return false;
|
||||
}
|
||||
if(input.item.stackSize < ri.getInput().stackSize) {
|
||||
return false;
|
||||
}
|
||||
numFound++;
|
||||
}
|
||||
}
|
||||
|
||||
return numFound == 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInputForRecipe(List<ItemStack> test, List<FluidStack> testFluids) {
|
||||
if(test == null) {
|
||||
return false;
|
||||
}
|
||||
if(test.size() != inputs.length) {
|
||||
return false;
|
||||
}
|
||||
List<RecipeInput> recIns = new ArrayList<RecipeInput>(Arrays.asList(inputs));
|
||||
for (ItemStack input : test) {
|
||||
if(input != null) {
|
||||
RecipeInput ri = getInputForStack(input);
|
||||
if(ri == null || ri.getInput() == null) {
|
||||
return false;
|
||||
}
|
||||
if(input.stackSize < ri.getInput().stackSize) {
|
||||
return false;
|
||||
}
|
||||
recIns.remove(ri);
|
||||
}
|
||||
}
|
||||
if(testFluids != null) {
|
||||
for (FluidStack input : testFluids) {
|
||||
if(input != null) {
|
||||
RecipeInput ri = getInputForStack(input);
|
||||
if(ri == null || ri.getInput() == null) {
|
||||
return false;
|
||||
}
|
||||
if(input.amount < ri.getFluidInput().amount) {
|
||||
return false;
|
||||
}
|
||||
recIns.remove(ri);
|
||||
}
|
||||
}
|
||||
}
|
||||
return recIns.size() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidInput(ItemStack item) {
|
||||
public boolean isValidInput(int slot, ItemStack item) {
|
||||
return getInputForStack(item) != null;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ public class RecipeConfigParser extends DefaultHandler {
|
||||
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_SLOT = "slot";
|
||||
public static final String AT_CHANCE = "chance";
|
||||
public static final String AT_EXP = "exp";
|
||||
|
||||
@@ -331,7 +332,8 @@ public class RecipeConfigParser extends DefaultHandler {
|
||||
}
|
||||
ItemStack stack = ores.get(0).copy();
|
||||
stack.stackSize = stackSize;
|
||||
return new OreDictionaryRecipeInput(stack, OreDictionary.getOreID(oreDict), getFloatValue(AT_MULTIPLIER, attributes, 1));
|
||||
return new OreDictionaryRecipeInput(stack, OreDictionary.getOreID(oreDict), getFloatValue(AT_MULTIPLIER, attributes, 1), getIntValue(AT_SLOT, attributes,
|
||||
-1));
|
||||
}
|
||||
|
||||
boolean useMeta = true;
|
||||
@@ -363,7 +365,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, getFloatValue(AT_MULTIPLIER, attributes, 1));
|
||||
return new RecipeInput(res, useMeta, getFloatValue(AT_MULTIPLIER, attributes, 1), getIntValue(AT_SLOT, attributes, -1));
|
||||
}
|
||||
|
||||
public static boolean getBooleanValue(String qName, Attributes attributes, boolean def) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class RecipeInput {
|
||||
|
||||
private final int slot;
|
||||
private final ItemStack input;
|
||||
private final boolean useMeta;
|
||||
|
||||
@@ -17,26 +18,27 @@ public class RecipeInput {
|
||||
}
|
||||
|
||||
public RecipeInput(ItemStack input, boolean useMeta) {
|
||||
this(input, useMeta, null, 1);
|
||||
this(input, useMeta, null, 1, -1);
|
||||
}
|
||||
|
||||
public RecipeInput(FluidStack fluid) {
|
||||
this(null, false, fluid, 1f);
|
||||
this(null, false, fluid, 1f, -1);
|
||||
}
|
||||
|
||||
public RecipeInput(FluidStack fluidStack, float mulitplier) {
|
||||
this(null, true, fluidStack, mulitplier);
|
||||
this(null, true, fluidStack, mulitplier, -1);
|
||||
}
|
||||
|
||||
public RecipeInput(ItemStack item, boolean useMeta, float multiplier) {
|
||||
this(item, useMeta, null, multiplier);
|
||||
public RecipeInput(ItemStack item, boolean useMeta, float multiplier, int slot) {
|
||||
this(item, useMeta, null, multiplier, slot);
|
||||
}
|
||||
|
||||
protected RecipeInput(ItemStack input, boolean useMeta, FluidStack fluid, float mulitplier) {
|
||||
protected RecipeInput(ItemStack input, boolean useMeta, FluidStack fluid, float mulitplier, int slot) {
|
||||
this.input = input;
|
||||
this.useMeta = useMeta;
|
||||
this.fluid = fluid;
|
||||
this.mulitplier = mulitplier;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public boolean isFluid() {
|
||||
@@ -55,6 +57,10 @@ public class RecipeInput {
|
||||
return mulitplier;
|
||||
}
|
||||
|
||||
public int getSlotNumber() {
|
||||
return slot;
|
||||
}
|
||||
|
||||
public boolean isInput(ItemStack test) {
|
||||
if(test == null || input == null) {
|
||||
return false;
|
||||
|
||||
@@ -103,6 +103,8 @@ public class GuiStill extends GuiMachineBase {
|
||||
float fullness = (float) tank.getFluidAmount() / (float) tank.getCapacity();
|
||||
int height = Math.round(47 * fullness);
|
||||
|
||||
//System.out.println("GuiStill.renderTank: " + tank.getFluidAmount());
|
||||
|
||||
x = guiLeft + x;
|
||||
int y = guiTop + 12;
|
||||
y = y + (47 - height);
|
||||
|
||||
@@ -11,7 +11,6 @@ import crazypants.enderio.crafting.IRecipeComponent;
|
||||
import crazypants.enderio.crafting.IRecipeInput;
|
||||
import crazypants.enderio.crafting.IRecipeOutput;
|
||||
import crazypants.enderio.crafting.impl.EnderIoRecipe;
|
||||
import crazypants.enderio.crafting.impl.RecipeInput;
|
||||
import crazypants.enderio.machine.MachineRecipeInput;
|
||||
import crazypants.enderio.machine.recipe.AbstractMachineRecipe;
|
||||
import crazypants.enderio.machine.recipe.IRecipe;
|
||||
@@ -25,18 +24,7 @@ public class StillMachineRecipe extends AbstractMachineRecipe {
|
||||
|
||||
@Override
|
||||
public IRecipe getRecipeForInputs(MachineRecipeInput[] inputs) {
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
List<FluidStack> fluids = new ArrayList<FluidStack>();
|
||||
for (MachineRecipeInput mi : inputs) {
|
||||
if(mi != null) {
|
||||
if(mi.item != null) {
|
||||
items.add(mi.item);
|
||||
} else if(mi.fluid != null) {
|
||||
fluids.add(mi.fluid);
|
||||
}
|
||||
}
|
||||
}
|
||||
return StillRecipeManager.instance.getRecipeForInput(items, fluids);
|
||||
return StillRecipeManager.instance.getRecipeForInput(inputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,6 +40,38 @@ public class StillMachineRecipe extends AbstractMachineRecipe {
|
||||
return ModObject.blockStill.unlocalisedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MachineRecipeInput> getQuantitiesConsumed(MachineRecipeInput[] inputs) {
|
||||
|
||||
List<MachineRecipeInput> result = new ArrayList<MachineRecipeInput>();
|
||||
|
||||
StillRecipe rec = (StillRecipe) getRecipeForInputs(inputs);
|
||||
FluidStack inputFluidStack = rec.getRequiredFluidInput(inputs);
|
||||
result.add(new MachineRecipeInput(0, inputFluidStack));
|
||||
|
||||
for (MachineRecipeInput ri : inputs) {
|
||||
if(!ri.isFluid()) {
|
||||
ItemStack st = ri.item.copy();
|
||||
st.stackSize = rec.getNumConsumed(ri.item);
|
||||
result.add(new MachineRecipeInput(ri.slotNumber, st));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
|
||||
if(inputs == null || inputs.length <= 0) {
|
||||
return new ResultStack[0];
|
||||
}
|
||||
StillRecipe recipe = (StillRecipe) getRecipeForInputs(inputs);
|
||||
if(recipe == null || !recipe.isValid()) {
|
||||
return new ResultStack[0];
|
||||
}
|
||||
return new ResultStack[] { new ResultStack(recipe.getFluidOutput(inputs)) };
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IEnderIoRecipe> getAllRecipes() {
|
||||
List<IEnderIoRecipe> result = new ArrayList<IEnderIoRecipe>();
|
||||
@@ -60,7 +80,7 @@ public class StillMachineRecipe extends AbstractMachineRecipe {
|
||||
List<IRecipeComponent> components = new ArrayList<IRecipeComponent>();
|
||||
for (crazypants.enderio.machine.recipe.RecipeInput ri : cr.getInputs()) {
|
||||
if(ri.getInput() != null) {
|
||||
IRecipeInput input = new RecipeInput(ri.getInput(), -1, ri.getEquivelentInputs());
|
||||
IRecipeInput input = new crazypants.enderio.crafting.impl.RecipeInput(ri.getInput(), -1, ri.getEquivelentInputs());
|
||||
components.add(input);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
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.MachineRecipeInput;
|
||||
import crazypants.enderio.machine.recipe.IRecipe;
|
||||
import crazypants.enderio.machine.recipe.Recipe;
|
||||
import crazypants.enderio.machine.recipe.RecipeInput;
|
||||
@@ -22,26 +22,6 @@ public class StillRecipe implements IRecipe {
|
||||
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;
|
||||
//
|
||||
// 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()) {
|
||||
@@ -49,7 +29,6 @@ public class StillRecipe implements IRecipe {
|
||||
} else {
|
||||
inputFluidStack = null;
|
||||
}
|
||||
this.inputStacks = recipe.getInputStacks();
|
||||
|
||||
FluidStack os = null;
|
||||
for (RecipeOutput output : recipe.getOutputs()) {
|
||||
@@ -60,41 +39,30 @@ public class StillRecipe implements IRecipe {
|
||||
}
|
||||
outputFluidStack = os;
|
||||
|
||||
List<RecipeInput> inputList = new ArrayList<RecipeInput>(3);
|
||||
if(inputFluidStack != null) {
|
||||
inputList.add(new RecipeInput(inputFluidStack));
|
||||
}
|
||||
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) };
|
||||
this.inputStacks = recipe.getInputStacks();
|
||||
inputs = recipe.getInputs();
|
||||
|
||||
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);
|
||||
// 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.isEmpty() && inputStacks.size() < 3 && outputFluidStack != null;
|
||||
return inputFluidStack != null && inputStacks != null && !inputStacks.isEmpty() && inputStacks.size() > 2 && outputFluidStack != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,12 +86,12 @@ public class StillRecipe implements IRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidInput(ItemStack item) {
|
||||
public boolean isValidInput(int slot, ItemStack item) {
|
||||
if(item == null) {
|
||||
return false;
|
||||
}
|
||||
for (RecipeInput ri : inputs) {
|
||||
if(item != null && ri.isInput(item)) {
|
||||
if(item != null && ri.getSlotNumber() == slot && ri.isInput(item)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -144,35 +112,29 @@ public class StillRecipe implements IRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInputForRecipe(List<ItemStack> test) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInputForRecipe(List<ItemStack> test, List<FluidStack> testFluids) {
|
||||
if(!isValid() || test == null || test.size() != 2 || testFluids == null || testFluids.size() != 1 || testFluids.get(0) == null) {
|
||||
return false;
|
||||
}
|
||||
boolean validFluid = inputFluidStack.isFluidEqual(testFluids.get(0)) && inputFluidStack.amount <= testFluids.get(0).amount;
|
||||
if(!validFluid) {
|
||||
public boolean isInputForRecipe(MachineRecipeInput... inputs) {
|
||||
if(!isValid() || inputs == null || inputs.length < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
if(!inputs[i].isFluid() && !containsInput(inputs[i], test)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
int found = 0;
|
||||
for (MachineRecipeInput in : inputs) {
|
||||
if(in.isFluid()) {
|
||||
FluidStack needFluid = getRequiredFluidInput(inputs);
|
||||
boolean validFluid = needFluid.isFluidEqual(in.fluid);
|
||||
if(validFluid && needFluid.amount <= in.fluid.amount) {
|
||||
found++;
|
||||
}
|
||||
|
||||
private boolean containsInput(RecipeInput recipeInput, List<ItemStack> test) {
|
||||
for (ItemStack stack : test) {
|
||||
if(recipeInput.isInput(stack)) {
|
||||
return true;
|
||||
} else {
|
||||
if(isValidInput(in.slotNumber, in.item)) { //TODO: Check stack counts
|
||||
found++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
return found == 3;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -180,4 +142,61 @@ public class StillRecipe implements IRecipe {
|
||||
return Collections.singletonList(inputFluidStack);
|
||||
}
|
||||
|
||||
public float getMultiplierForInput(FluidStack item) {
|
||||
for (RecipeInput input : inputs) {
|
||||
if(input.isInput(item)) {
|
||||
return input.getMulitplier();
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public FluidStack getRequiredFluidInput(MachineRecipeInput[] inputs) {
|
||||
float inputFluidMul = 1;
|
||||
float outputFluidMul = 1;
|
||||
FluidStack inputFluidStack = null;
|
||||
for (MachineRecipeInput ri : inputs) {
|
||||
if(!ri.isFluid()) {
|
||||
inputFluidMul *= getMultiplierForInput(ri.item);
|
||||
} else {
|
||||
inputFluidStack = ri.fluid.copy();
|
||||
}
|
||||
}
|
||||
inputFluidStack.amount = Math.round(inputFluidMul * FluidContainerRegistry.BUCKET_VOLUME);
|
||||
return inputFluidStack;
|
||||
}
|
||||
|
||||
public FluidStack getFluidOutput(MachineRecipeInput... inputs) {
|
||||
FluidStack outFluid = getOutputFluid().copy();
|
||||
float outMul = 1;
|
||||
for (MachineRecipeInput ri : inputs) {
|
||||
outMul *= getMultiplierForInput(ri.item);
|
||||
outMul *= getMultiplierForInput(ri.fluid);
|
||||
}
|
||||
outFluid.amount = Math.round(outMul * FluidContainerRegistry.BUCKET_VOLUME);
|
||||
return outFluid;
|
||||
}
|
||||
|
||||
public float getMultiplierForInput(ItemStack item) {
|
||||
for (RecipeInput input : inputs) {
|
||||
if(input.isInput(item)) {
|
||||
return input.getMulitplier();
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int getNumConsumed(ItemStack item) {
|
||||
for (RecipeInput input : inputs) {
|
||||
if(input.isInput(item)) {
|
||||
return input.getInput().stackSize;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public FluidStack getOutputFluid() {
|
||||
return outputFluidStack;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,8 +46,14 @@ public class StillRecipeManager {
|
||||
|
||||
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)
|
||||
new RecipeInput(new ItemStack(Items.rotten_flesh), true, 2, 0),
|
||||
new RecipeInput(new ItemStack(Items.beef), true, 1, 0),
|
||||
new RecipeInput(new ItemStack(Items.chicken), true, 1, 0),
|
||||
new RecipeInput(new ItemStack(Items.porkchop), true, 1, 0),
|
||||
new RecipeInput(new ItemStack(Items.skull), false, 2.5f, 0),
|
||||
|
||||
new RecipeInput(new ItemStack(Items.nether_wart), true, 1.5f, 1),
|
||||
new RecipeInput(new ItemStack(Items.sugar), true, 1f, 1)
|
||||
};
|
||||
|
||||
FluidStack resStack = FluidRegistry.getFluidStack("nutrientdistillation", FluidContainerRegistry.BUCKET_VOLUME);
|
||||
@@ -75,12 +81,24 @@ public class StillRecipeManager {
|
||||
// processConfig(config);
|
||||
}
|
||||
|
||||
public IRecipe getRecipeForInput(List<ItemStack> input, List<FluidStack> inputFluids) {
|
||||
if(input == null || inputFluids == null) {
|
||||
// public IRecipe getRecipeForInput(List<ItemStack> input, List<FluidStack> inputFluids) {
|
||||
// if(input == null || inputFluids == null) {
|
||||
// return null;
|
||||
// }
|
||||
// for (IRecipe recipe : recipes) {
|
||||
// if(recipe.isInputForRecipe(input, inputFluids)) {
|
||||
// return recipe;
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
public IRecipe getRecipeForInput(MachineRecipeInput[] inputs) {
|
||||
if(inputs == null || inputs.length == 0) {
|
||||
return null;
|
||||
}
|
||||
for (IRecipe recipe : recipes) {
|
||||
if(recipe.isInputForRecipe(input, inputFluids)) {
|
||||
if(recipe.isInputForRecipe(inputs)) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
@@ -117,7 +135,7 @@ public class StillRecipeManager {
|
||||
|
||||
public boolean isValidInput(MachineRecipeInput input) {
|
||||
for (IRecipe recipe : recipes) {
|
||||
if(input.item != null && recipe.isValidInput(input.item)) {
|
||||
if(input.item != null && recipe.isValidInput(input.slotNumber, input.item)) {
|
||||
return true;
|
||||
} else if(input.fluid != null && recipe.isValidInput(input.fluid)) {
|
||||
return true;
|
||||
|
||||
@@ -135,13 +135,26 @@ public class TileStill extends AbstractPoweredTaskEntity implements IFluidHandle
|
||||
public void readCustomNBT(NBTTagCompound nbtRoot) {
|
||||
super.readCustomNBT(nbtRoot);
|
||||
|
||||
NBTTagCompound tankRoot = (NBTTagCompound) nbtRoot.getTag("inputTank");
|
||||
if(tankRoot != null) {
|
||||
inputTank.readFromNBT(tankRoot);
|
||||
if(nbtRoot.hasKey("inputTank")) {
|
||||
NBTTagCompound tankRoot = (NBTTagCompound) nbtRoot.getTag("inputTank");
|
||||
if(tankRoot != null) {
|
||||
inputTank.readFromNBT(tankRoot);
|
||||
} else {
|
||||
inputTank.setFluid(null);
|
||||
}
|
||||
} else {
|
||||
inputTank.setFluid(null);
|
||||
}
|
||||
tankRoot = (NBTTagCompound) nbtRoot.getTag("outputTank");
|
||||
if(tankRoot != null) {
|
||||
outputTank.readFromNBT(tankRoot);
|
||||
|
||||
if(nbtRoot.hasKey("inputTank")) {
|
||||
NBTTagCompound tankRoot = (NBTTagCompound) nbtRoot.getTag("outputTank");
|
||||
if(tankRoot != null) {
|
||||
outputTank.readFromNBT(tankRoot);
|
||||
} else {
|
||||
outputTank.setFluid(null);
|
||||
}
|
||||
} else {
|
||||
outputTank.setFluid(null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -149,13 +162,16 @@ public class TileStill extends AbstractPoweredTaskEntity implements IFluidHandle
|
||||
@Override
|
||||
public void writeCustomNBT(NBTTagCompound nbtRoot) {
|
||||
super.writeCustomNBT(nbtRoot);
|
||||
NBTTagCompound tankRoot = new NBTTagCompound();
|
||||
inputTank.writeToNBT(tankRoot);
|
||||
nbtRoot.setTag("inputTank", tankRoot);
|
||||
|
||||
tankRoot = new NBTTagCompound();
|
||||
outputTank.writeToNBT(tankRoot);
|
||||
nbtRoot.setTag("outputTank", tankRoot);
|
||||
if(inputTank.getFluidAmount() > 0) {
|
||||
NBTTagCompound tankRoot = new NBTTagCompound();
|
||||
inputTank.writeToNBT(tankRoot);
|
||||
nbtRoot.setTag("inputTank", tankRoot);
|
||||
}
|
||||
if(outputTank.getFluidAmount() > 0) {
|
||||
NBTTagCompound tankRoot = new NBTTagCompound();
|
||||
outputTank.writeToNBT(tankRoot);
|
||||
nbtRoot.setTag("outputTank", tankRoot);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user