attempt at fixing the item stack size issue

This commit is contained in:
modmuss50 2015-06-07 09:21:37 +01:00
parent 92af5a1537
commit 94803e88f3
23 changed files with 90 additions and 74 deletions

View file

@ -13,7 +13,7 @@ public abstract class BaseRecipe implements IBaseRecipeType , Cloneable {
public ArrayList<ItemStack> inputs;
public ArrayList<ItemStack> outputs;
private ArrayList<ItemStack> outputs;
public String name;
@ -31,11 +31,21 @@ public abstract class BaseRecipe implements IBaseRecipeType , Cloneable {
}
@Override
public List<ItemStack> getOutputs() {
return (List<ItemStack>) outputs.clone();
public ItemStack getOutput(int i) {
return outputs.get(i).copy();
}
@Override
@Override
public int getOutputsSize() {
return outputs.size();
}
public void addOutput(ItemStack stack){
outputs.add(stack);
}
@Override
public List<ItemStack> getInputs() {
return inputs;
}

View file

@ -18,11 +18,17 @@ public interface IBaseRecipeType {
public List<ItemStack> getInputs();
/**
* Use this to get all of the outputs
* This gets the output form the array list
*
* @return the List of outputs
* @return the output
*/
public List<ItemStack> getOutputs();
public ItemStack getOutput(int i);
/**
*
* @return The ammount of outputs
*/
public int getOutputsSize();
/**
* This is the name to check that the recipe is the one that should be used in

View file

@ -118,8 +118,8 @@ public class RecipeCrafter {
for (IBaseRecipeType recipe : RecipeHanderer.getRecipeClassFromName(recipeName)) {
if (recipe.canCraft(parentTile) && hasAllInputs(recipe)) {//This checks to see if it has all of the inputs
boolean canGiveInvAll = true;
for (int i = 0; i < recipe.getOutputs().size(); i++) {//This checks to see if it can fit all of the outputs
if (!canFitStack(recipe.getOutputs().get(i), outputSlots[i])) {
for (int i = 0; i < recipe.getOutputsSize(); i++) {//This checks to see if it can fit all of the outputs
if (!canFitStack(recipe.getOutput(i), outputSlots[i])) {
canGiveInvAll = false;
break;
}
@ -142,17 +142,17 @@ public class RecipeCrafter {
}
if (currentRecipe != null && currentTickTime >= currentNeededTicks) {//If it has reached the recipe tick time
boolean canGiveInvAll = true;
for (int i = 0; i < currentRecipe.getOutputs().size(); i++) {//Checks to see if it can fit the output
if (!canFitStack(currentRecipe.getOutputs().get(i), outputSlots[i])) {
for (int i = 0; i < currentRecipe.getOutputsSize(); i++) {//Checks to see if it can fit the output
if (!canFitStack(currentRecipe.getOutput(i), outputSlots[i])) {
canGiveInvAll = false;
}
}
ArrayList<Integer> filledSlots = new ArrayList<Integer>();//The slots that have been filled
if (canGiveInvAll && currentRecipe.onCraft(parentTile)) {
for (int i = 0; i < currentRecipe.getOutputs().size(); i++) {
System.out.println(currentRecipe.getOutputs().get(i).stackSize);
for (int i = 0; i < currentRecipe.getOutputsSize(); i++) {
System.out.println(currentRecipe.getOutput(i).stackSize);
if (!filledSlots.contains(outputSlots[i])) {//checks it has not been filled
fitStack(currentRecipe.getOutputs().get(i), outputSlots[i]);//fills the slot with the output stack
fitStack(currentRecipe.getOutput(i), outputSlots[i]);//fills the slot with the output stack
filledSlots.add(outputSlots[i]);
}
}

View file

@ -12,6 +12,6 @@ public class AlloySmelterRecipe extends BaseRecipe {
if (input2 != null)
inputs.add(input2);
if (output1 != null)
outputs.add(output1);
addOutput(output1);
}
}

View file

@ -12,6 +12,6 @@ public class AssemblingMachineRecipe extends BaseRecipe {
if (input2 != null)
inputs.add(input2);
if (output1 != null)
outputs.add(output1);
addOutput(output1);
}
}

View file

@ -12,12 +12,12 @@ public class CentrifugeRecipe extends BaseRecipe {
if (input2 != null)
inputs.add(input2);
if (output1 != null)
outputs.add(output1);
addOutput(output1);
if (output2 != null)
outputs.add(output2);
addOutput(output2);
if (output3 != null)
outputs.add(output3);
addOutput(output3);
if (output4 != null)
outputs.add(output4);
addOutput(output4);
}
}

View file

@ -12,6 +12,6 @@ public class ChemicalReactorRecipe extends BaseRecipe {
if (input2 != null)
inputs.add(input2);
if (output1 != null)
outputs.add(output1);
addOutput(output1);
}
}

View file

@ -18,13 +18,13 @@ public class GrinderRecipe extends BaseRecipe {
if( input2 != null)
inputs.add(input2);
if (output1 != null)
outputs.add(output1);
addOutput(output1);
if (output2 != null)
outputs.add(output2);
addOutput(output2);
if (output3 != null)
outputs.add(output3);
addOutput(output3);
if (output4 != null)
outputs.add(output4);
addOutput(output4);
this.fluidStack = fluidStack;
}

View file

@ -12,8 +12,8 @@ public class ImplosionCompressorRecipe extends BaseRecipe {
if (input2 != null)
inputs.add(input2);
if (output1 != null)
outputs.add(output1);
addOutput(output1);
if (output2 != null)
outputs.add(output2);
addOutput(output2);
}
}

View file

@ -12,10 +12,10 @@ public class IndustrialSawmillRecipe extends BaseRecipe {
if (input2 != null)
inputs.add(input2);
if (output1 != null)
outputs.add(output1);
addOutput(output1);
if (output2 != null)
outputs.add(output2);
addOutput(output2);
if (output3 != null)
outputs.add(output3);
addOutput(output3);
}
}

View file

@ -10,6 +10,6 @@ public class LatheRecipe extends BaseRecipe {
if (input1 != null)
inputs.add(input1);
if (output1 != null)
outputs.add(output1);
addOutput(output1);
}
}

View file

@ -10,6 +10,6 @@ public class PlateCuttingMachineRecipe extends BaseRecipe {
if (input1 != null)
inputs.add(input1);
if (output1 != null)
outputs.add(output1);
addOutput(output1);
}
}