My mind is blown :D Not sure whats up

This commit is contained in:
modmuss50 2015-06-06 21:41:41 +01:00
parent ee798923f5
commit 4d76a3071d
24 changed files with 110 additions and 23 deletions

View file

@ -9,7 +9,7 @@ import java.util.List;
/**
* Extend this to add a recipe
*/
public abstract class BaseRecipe implements IBaseRecipeType {
public abstract class BaseRecipe implements IBaseRecipeType , Cloneable {
public ArrayList<ItemStack> inputs;
@ -32,7 +32,7 @@ public abstract class BaseRecipe implements IBaseRecipeType {
@Override
public List<ItemStack> getOutputs() {
return outputs;
return (List<ItemStack>) outputs.clone();
}
@Override
@ -64,4 +64,9 @@ public abstract class BaseRecipe implements IBaseRecipeType {
public boolean onCraft(TileEntity tile) {
return true;
}
@Override
public Object clone()throws CloneNotSupportedException{
return super.clone();
}
}

View file

@ -57,4 +57,6 @@ public interface IBaseRecipeType {
* @return return true if fluid was taken and should craft
*/
public boolean onCraft(TileEntity tile);
public Object clone()throws CloneNotSupportedException;
}

View file

@ -125,7 +125,7 @@ public class RecipeCrafter {
}
}
if (canGiveInvAll) {
currentRecipe = recipe;//Sets the current recipe then syncs
setCurrentRecipe(recipe);//Sets the current recipe then syncs
this.currentNeededTicks = (int)(currentRecipe.tickTime() * (1.0 - speedMultiplier));
this.currentTickTime = 0;
syncIsActive();
@ -150,6 +150,7 @@ public class RecipeCrafter {
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);
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
filledSlots.add(outputSlots[i]);
@ -323,4 +324,12 @@ public class RecipeCrafter {
return new S35PacketUpdateTileEntity(this.parentTile.xCoord, this.parentTile.yCoord,
this.parentTile.zCoord, 1, nbtTag);
}
public void setCurrentRecipe(IBaseRecipeType recipe){
try {
this.currentRecipe = (IBaseRecipeType) recipe.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
}
}