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> inputs;
public ArrayList<ItemStack> outputs; private ArrayList<ItemStack> outputs;
public String name; public String name;
@ -31,11 +31,21 @@ public abstract class BaseRecipe implements IBaseRecipeType , Cloneable {
} }
@Override @Override
public List<ItemStack> getOutputs() { public ItemStack getOutput(int i) {
return (List<ItemStack>) outputs.clone(); 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() { public List<ItemStack> getInputs() {
return inputs; return inputs;
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -9,8 +9,8 @@ public class EmcValues {
public static void init() public static void init()
{ {
for(IBaseRecipeType recipeType : RecipeHanderer.recipeList){ for(IBaseRecipeType recipeType : RecipeHanderer.recipeList){
if(recipeType.getOutputs().size() == 1){ if(recipeType.getOutputsSize() == 1){
RecipeRegistryProxy.addRecipe(recipeType.getOutputs().get(0), recipeType.getInputs()); RecipeRegistryProxy.addRecipe(recipeType.getOutput(0), recipeType.getInputs());
} }
} }
} }

View file

@ -18,7 +18,7 @@ public class AlloySmelterRecipeHandler extends GenericRecipeHander implements IN
PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 65 - offset, 17 - offset); PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 65 - offset, 17 - offset);
input.add(pStack2); input.add(pStack2);
PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 116 - offset, 35 - offset); PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 116 - offset, 35 - offset);
outputs.add(pStack3); outputs.add(pStack3);
} }

View file

@ -21,8 +21,8 @@ public class AssemblingMachineRecipeHandler extends GenericRecipeHander implemen
input.add(pStack2); input.add(pStack2);
} }
if (recipeType.getOutputs().size() > 0) { if (recipeType.getOutputsSize() > 0) {
PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 116 - offset, 35 - offset); PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 116 - offset, 35 - offset);
outputs.add(pStack3); outputs.add(pStack3);
} }

View file

@ -21,23 +21,23 @@ public class CentrifugeRecipeHandler extends GenericRecipeHander implements INei
input.add(pStack2); input.add(pStack2);
} }
if (recipeType.getOutputs().size() > 0) { if (recipeType.getOutputsSize() > 0) {
PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 80 - offset, 5 - offset); PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 80 - offset, 5 - offset);
outputs.add(pStack3); outputs.add(pStack3);
} }
if (recipeType.getOutputs().size() > 1) { if (recipeType.getOutputsSize() > 1) {
PositionedStack pStack4 = new PositionedStack(recipeType.getOutputs().get(1), 110 - offset, 35 - offset); PositionedStack pStack4 = new PositionedStack(recipeType.getOutput(1), 110 - offset, 35 - offset);
outputs.add(pStack4); outputs.add(pStack4);
} }
if (recipeType.getOutputs().size() > 2) { if (recipeType.getOutputsSize() > 2) {
PositionedStack pStack5 = new PositionedStack(recipeType.getOutputs().get(2), 80 - offset, 65 - offset); PositionedStack pStack5 = new PositionedStack(recipeType.getOutput(2), 80 - offset, 65 - offset);
outputs.add(pStack5); outputs.add(pStack5);
} }
if (recipeType.getOutputs().size() > 3) { if (recipeType.getOutputsSize() > 3) {
PositionedStack pStack6 = new PositionedStack(recipeType.getOutputs().get(3), 50 - offset, 35 - offset); PositionedStack pStack6 = new PositionedStack(recipeType.getOutput(3), 50 - offset, 35 - offset);
outputs.add(pStack6); outputs.add(pStack6);
} }
} }

View file

@ -22,8 +22,8 @@ public class ChemicalReactorRecipeHandler extends GenericRecipeHander implements
input.add(pStack2); input.add(pStack2);
} }
if (recipeType.getOutputs().size() > 0) { if (recipeType.getOutputsSize() > 0) {
PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 80 - offset, 51 - offset); PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 80 - offset, 51 - offset);
outputs.add(pStack3); outputs.add(pStack3);
} }
} }

View file

@ -113,11 +113,11 @@ public abstract class GenericRecipeHander extends TemplateRecipeHandler {
@Override @Override
public void loadCraftingRecipes(ItemStack result) { public void loadCraftingRecipes(ItemStack result) {
for (IBaseRecipeType recipeType : RecipeHanderer.getRecipeClassFromName(getNeiBaseRecipe().getRecipeName())) { for (IBaseRecipeType recipeType : RecipeHanderer.getRecipeClassFromName(getNeiBaseRecipe().getRecipeName())) {
for (ItemStack output : recipeType.getOutputs()) { for (int i = 0; i < recipeType.getOutputsSize(); i++) {
if (ItemUtils.isItemEqual(output, result, true, false, true)) { if (ItemUtils.isItemEqual(recipeType.getOutput(i), result, true, false, true)) {
addCached(recipeType); addCached(recipeType);
} }
} }
} }
} }

View file

@ -28,23 +28,23 @@ public class GrinderRecipeHandler extends GenericRecipeHander implements INeiBas
input.add(pStack2); input.add(pStack2);
} }
if (recipeType.getOutputs().size() > 0) { if (recipeType.getOutputsSize() > 0) {
PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 2 - offset, 77 - offset); PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 2 - offset, 77 - offset);
outputs.add(pStack3); outputs.add(pStack3);
} }
if (recipeType.getInputs().size() > 1) { if (recipeType.getOutputsSize() > 1) {
PositionedStack pStack4 = new PositionedStack(recipeType.getOutputs().get(1), 2 - offset, 95 - offset); PositionedStack pStack4 = new PositionedStack(recipeType.getOutput(1), 2 - offset, 95 - offset);
outputs.add(pStack4); outputs.add(pStack4);
} }
if (recipeType.getInputs().size() > 2) { if (recipeType.getOutputsSize() > 2) {
PositionedStack pStack5 = new PositionedStack(recipeType.getOutputs().get(2), 4 - offset, 113 - offset); PositionedStack pStack5 = new PositionedStack(recipeType.getOutput(2), 4 - offset, 113 - offset);
outputs.add(pStack5); outputs.add(pStack5);
} }
if (recipeType.getInputs().size() > 3) { if (recipeType.getOutputsSize() > 3) {
PositionedStack pStack6 = new PositionedStack(recipeType.getOutputs().get(3), 5 - offset, 131 - offset); PositionedStack pStack6 = new PositionedStack(recipeType.getOutput(3), 5 - offset, 131 - offset);
outputs.add(pStack6); outputs.add(pStack6);
} }

View file

@ -22,13 +22,13 @@ public class ImplosionCompressorRecipeHandler extends GenericRecipeHander implem
input.add(pStack2); input.add(pStack2);
} }
if (recipeType.getOutputs().size() > 0) { if (recipeType.getOutputsSize() > 0) {
PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 93 - offset, 35 - offset); PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 93 - offset, 35 - offset);
outputs.add(pStack3); outputs.add(pStack3);
} }
if (recipeType.getOutputs().size() > 1) { if (recipeType.getOutputsSize() > 1) {
PositionedStack pStack4 = new PositionedStack(recipeType.getOutputs().get(1), 111 - offset, 35 - offset); PositionedStack pStack4 = new PositionedStack(recipeType.getOutput(1), 111 - offset, 35 - offset);
outputs.add(pStack4); outputs.add(pStack4);
} }
} }

View file

@ -22,18 +22,18 @@ public class IndustrialSawmillRecipeHandler extends GenericRecipeHander implemen
input.add(pStack2); input.add(pStack2);
} }
if (recipeType.getOutputs().size() > 0) { if (recipeType.getOutputsSize() > 0) {
PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 84 - offset, 35 - offset); PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 84 - offset, 35 - offset);
outputs.add(pStack3); outputs.add(pStack3);
} }
if (recipeType.getOutputs().size() > 1) { if (recipeType.getOutputsSize() > 1) {
PositionedStack pStack4 = new PositionedStack(recipeType.getOutputs().get(1), 102 - offset, 35 - offset); PositionedStack pStack4 = new PositionedStack(recipeType.getOutput(1), 102 - offset, 35 - offset);
outputs.add(pStack4); outputs.add(pStack4);
} }
if (recipeType.getOutputs().size() > 2) { if (recipeType.getOutputsSize() > 2) {
PositionedStack pStack5 = new PositionedStack(recipeType.getOutputs().get(2), 120 - offset, 35 - offset); PositionedStack pStack5 = new PositionedStack(recipeType.getOutput(2), 120 - offset, 35 - offset);
outputs.add(pStack5); outputs.add(pStack5);
} }
} }

View file

@ -17,8 +17,8 @@ public class LatheRecipeHandler extends GenericRecipeHander implements INeiBaseR
input.add(pStack); input.add(pStack);
} }
if (recipeType.getOutputs().size() > 0) { if (recipeType.getOutputsSize() > 0) {
PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 116 - offset, 35 - offset); PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 116 - offset, 35 - offset);
outputs.add(pStack3); outputs.add(pStack3);
} }
} }

View file

@ -16,8 +16,8 @@ public class PlateCuttingMachineRecipeHandler extends GenericRecipeHander implem
PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 56 - offset, 17 - offset); PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 56 - offset, 17 - offset);
input.add(pStack); input.add(pStack);
} }
if (recipeType.getOutputs().size() > 0) { if (recipeType.getOutputsSize() > 0) {
PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 116 - offset, 35 - offset); PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 116 - offset, 35 - offset);
outputs.add(pStack3); outputs.add(pStack3);
} }
} }