Fixed crafting patterns crashing when item of an input or output no longer exists
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
# Refined Storage Changelog
|
# Refined Storage Changelog
|
||||||
|
|
||||||
|
### 0.6.11
|
||||||
|
**Bugfixes**
|
||||||
|
- Fixed crafting patterns crashing when item of an input or output no longer exists
|
||||||
|
|
||||||
### 0.6.10
|
### 0.6.10
|
||||||
**Bugfixes**
|
**Bugfixes**
|
||||||
- Fixed Processing Patterns not working
|
- Fixed Processing Patterns not working
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class GuiCrafter extends GuiBase {
|
|||||||
int x = 27;
|
int x = 27;
|
||||||
int y = 19 + (i * 18);
|
int y = 19 + (i * 18);
|
||||||
|
|
||||||
if (crafter.getStackInSlot(i) != null) {
|
if (crafter.getStackInSlot(i) != null && ItemPattern.isValid(crafter.getStackInSlot(i))) {
|
||||||
ItemStack pattern = crafter.getStackInSlot(i);
|
ItemStack pattern = crafter.getStackInSlot(i);
|
||||||
|
|
||||||
String text = t("gui.refinedstorage:crafter.processing");
|
String text = t("gui.refinedstorage:crafter.processing");
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class ItemPattern extends ItemBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static ItemStack[] get(ItemStack pattern, String type) {
|
private static ItemStack[] get(ItemStack pattern, String type) {
|
||||||
if (!isValid(pattern)) {
|
if (!pattern.hasTagCompound() || !pattern.getTagCompound().hasKey(type)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,10 +81,23 @@ public class ItemPattern extends ItemBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isValid(ItemStack pattern) {
|
public static boolean isValid(ItemStack pattern) {
|
||||||
return pattern.getTagCompound() != null &&
|
if (pattern.getTagCompound() == null || (!pattern.getTagCompound().hasKey(NBT_INPUTS) || !pattern.getTagCompound().hasKey(NBT_OUTPUTS) || !pattern.getTagCompound().hasKey(NBT_PROCESSING))) {
|
||||||
pattern.getTagCompound().hasKey(NBT_INPUTS) &&
|
return false;
|
||||||
pattern.getTagCompound().hasKey(NBT_OUTPUTS) &&
|
}
|
||||||
pattern.getTagCompound().hasKey(NBT_PROCESSING);
|
|
||||||
|
for (ItemStack input : getInputs(pattern)) {
|
||||||
|
if (input == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ItemStack output : getOutputs(pattern)) {
|
||||||
|
if (output == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setProcessing(ItemStack pattern, boolean processing) {
|
public static void setProcessing(ItemStack pattern, boolean processing) {
|
||||||
@@ -96,7 +109,7 @@ public class ItemPattern extends ItemBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isProcessing(ItemStack pattern) {
|
public static boolean isProcessing(ItemStack pattern) {
|
||||||
if (pattern.getTagCompound() == null) {
|
if (!pattern.hasTagCompound() || !pattern.getTagCompound().hasKey(NBT_PROCESSING)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
|
|||||||
TileCrafter crafter = (TileCrafter) machine;
|
TileCrafter crafter = (TileCrafter) machine;
|
||||||
|
|
||||||
for (int i = 0; i < TileCrafter.PATTERN_SLOTS; ++i) {
|
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);
|
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)));
|
patterns.add(new CraftingPattern(crafter.getPos().getX(), crafter.getPos().getY(), crafter.getPos().getZ(), ItemPattern.isProcessing(pattern), ItemPattern.getInputs(pattern), ItemPattern.getOutputs(pattern)));
|
||||||
@@ -502,17 +502,21 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
|
|||||||
for (int i = 0; i < taskList.tagCount(); ++i) {
|
for (int i = 0; i < taskList.tagCount(); ++i) {
|
||||||
NBTTagCompound taskTag = taskList.getCompoundTagAt(i);
|
NBTTagCompound taskTag = taskList.getCompoundTagAt(i);
|
||||||
|
|
||||||
|
CraftingPattern pattern = CraftingPattern.readFromNBT(taskTag.getCompoundTag(CraftingPattern.NBT));
|
||||||
|
|
||||||
|
if (pattern != null) {
|
||||||
switch (taskTag.getInteger("Type")) {
|
switch (taskTag.getInteger("Type")) {
|
||||||
case BasicCraftingTask.ID:
|
case BasicCraftingTask.ID:
|
||||||
addCraftingTask(new BasicCraftingTask(taskTag));
|
addCraftingTask(new BasicCraftingTask(taskTag, pattern));
|
||||||
break;
|
break;
|
||||||
case ProcessingCraftingTask.ID:
|
case ProcessingCraftingTask.ID:
|
||||||
addCraftingTask(new ProcessingCraftingTask(taskTag));
|
addCraftingTask(new ProcessingCraftingTask(taskTag, pattern));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbt) {
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
|
|||||||
@@ -80,14 +80,24 @@ public class CraftingPattern {
|
|||||||
|
|
||||||
NBTTagList inputsTag = tag.getTagList(ItemPattern.NBT_INPUTS, Constants.NBT.TAG_COMPOUND);
|
NBTTagList inputsTag = tag.getTagList(ItemPattern.NBT_INPUTS, Constants.NBT.TAG_COMPOUND);
|
||||||
ItemStack inputs[] = new ItemStack[inputsTag.tagCount()];
|
ItemStack inputs[] = new ItemStack[inputsTag.tagCount()];
|
||||||
|
|
||||||
for (int i = 0; i < inputsTag.tagCount(); ++i) {
|
for (int i = 0; i < inputsTag.tagCount(); ++i) {
|
||||||
inputs[i] = ItemStack.loadItemStackFromNBT(inputsTag.getCompoundTagAt(i));
|
inputs[i] = ItemStack.loadItemStackFromNBT(inputsTag.getCompoundTagAt(i));
|
||||||
|
|
||||||
|
if (inputs[i] == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NBTTagList outputsTag = tag.getTagList(ItemPattern.NBT_OUTPUTS, Constants.NBT.TAG_COMPOUND);
|
NBTTagList outputsTag = tag.getTagList(ItemPattern.NBT_OUTPUTS, Constants.NBT.TAG_COMPOUND);
|
||||||
ItemStack outputs[] = new ItemStack[outputsTag.tagCount()];
|
ItemStack outputs[] = new ItemStack[outputsTag.tagCount()];
|
||||||
|
|
||||||
for (int i = 0; i < outputsTag.tagCount(); ++i) {
|
for (int i = 0; i < outputsTag.tagCount(); ++i) {
|
||||||
outputs[i] = ItemStack.loadItemStackFromNBT(outputsTag.getCompoundTagAt(i));
|
outputs[i] = ItemStack.loadItemStackFromNBT(outputsTag.getCompoundTagAt(i));
|
||||||
|
|
||||||
|
if (outputs[i] == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CraftingPattern(cx, cy, cz, processing, inputs, outputs);
|
return new CraftingPattern(cx, cy, cz, processing, inputs, outputs);
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ public class BasicCraftingTask implements ICraftingTask {
|
|||||||
this.childTasks = new boolean[pattern.getInputs().length];
|
this.childTasks = new boolean[pattern.getInputs().length];
|
||||||
}
|
}
|
||||||
|
|
||||||
public BasicCraftingTask(NBTTagCompound tag) {
|
public BasicCraftingTask(NBTTagCompound tag, CraftingPattern pattern) {
|
||||||
this.pattern = CraftingPattern.readFromNBT(tag.getCompoundTag(CraftingPattern.NBT));
|
this.pattern = pattern;
|
||||||
this.satisfied = RefinedStorageUtils.readBooleanArray(tag, NBT_SATISFIED);
|
this.satisfied = RefinedStorageUtils.readBooleanArray(tag, NBT_SATISFIED);
|
||||||
this.checked = RefinedStorageUtils.readBooleanArray(tag, NBT_CHECKED);
|
this.checked = RefinedStorageUtils.readBooleanArray(tag, NBT_CHECKED);
|
||||||
this.childTasks = RefinedStorageUtils.readBooleanArray(tag, NBT_CHILD_TASKS);
|
this.childTasks = RefinedStorageUtils.readBooleanArray(tag, NBT_CHILD_TASKS);
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ public class ProcessingCraftingTask implements ICraftingTask {
|
|||||||
this.satisfied = new boolean[pattern.getOutputs().length];
|
this.satisfied = new boolean[pattern.getOutputs().length];
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProcessingCraftingTask(NBTTagCompound tag) {
|
public ProcessingCraftingTask(NBTTagCompound tag, CraftingPattern pattern) {
|
||||||
this.pattern = CraftingPattern.readFromNBT(tag.getCompoundTag(CraftingPattern.NBT));
|
this.pattern = pattern;
|
||||||
this.inserted = RefinedStorageUtils.readBooleanArray(tag, NBT_INSERTED);
|
this.inserted = RefinedStorageUtils.readBooleanArray(tag, NBT_INSERTED);
|
||||||
this.childTasks = RefinedStorageUtils.readBooleanArray(tag, NBT_CHILD_TASKS);
|
this.childTasks = RefinedStorageUtils.readBooleanArray(tag, NBT_CHILD_TASKS);
|
||||||
this.satisfied = RefinedStorageUtils.readBooleanArray(tag, NBT_SATISFIED);
|
this.satisfied = RefinedStorageUtils.readBooleanArray(tag, NBT_SATISFIED);
|
||||||
|
|||||||
Reference in New Issue
Block a user