Fixed crafting patterns crashing when item of an input or output no longer exists

This commit is contained in:
Raoul Van den Berge
2016-05-21 21:25:09 +02:00
parent e397f0b8ff
commit 2073a94fcf
7 changed files with 50 additions and 19 deletions

View File

@@ -226,7 +226,7 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
TileCrafter crafter = (TileCrafter) machine;
for (int i = 0; i < TileCrafter.PATTERN_SLOTS; ++i) {
if (crafter.getStackInSlot(i) != null) {
if (crafter.getStackInSlot(i) != null && ItemPattern.isValid(crafter.getStackInSlot(i))) {
ItemStack pattern = crafter.getStackInSlot(i);
patterns.add(new CraftingPattern(crafter.getPos().getX(), crafter.getPos().getY(), crafter.getPos().getZ(), ItemPattern.isProcessing(pattern), ItemPattern.getInputs(pattern), ItemPattern.getOutputs(pattern)));
@@ -502,13 +502,17 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
for (int i = 0; i < taskList.tagCount(); ++i) {
NBTTagCompound taskTag = taskList.getCompoundTagAt(i);
switch (taskTag.getInteger("Type")) {
case BasicCraftingTask.ID:
addCraftingTask(new BasicCraftingTask(taskTag));
break;
case ProcessingCraftingTask.ID:
addCraftingTask(new ProcessingCraftingTask(taskTag));
break;
CraftingPattern pattern = CraftingPattern.readFromNBT(taskTag.getCompoundTag(CraftingPattern.NBT));
if (pattern != null) {
switch (taskTag.getInteger("Type")) {
case BasicCraftingTask.ID:
addCraftingTask(new BasicCraftingTask(taskTag, pattern));
break;
case ProcessingCraftingTask.ID:
addCraftingTask(new ProcessingCraftingTask(taskTag, pattern));
break;
}
}
}
}