Fix item loading issue, fixes #346 and #338

This commit is contained in:
Raoul Van den Berge
2016-09-16 01:56:48 +02:00
parent b1228ce435
commit 8e3dbadac8
2 changed files with 12 additions and 2 deletions

View File

@@ -1,5 +1,8 @@
# Refined Storage Changelog # Refined Storage Changelog
### 1.0.3
- Fixed item loading issue (raoulvdberge)
### 1.0.2 ### 1.0.2
- Fixed processing patterns not handling item insertion sometimes (raoulvdberge) - Fixed processing patterns not handling item insertion sometimes (raoulvdberge)
- Removed crafting task limit in crafting start GUI (raoulvdberge) - Removed crafting task limit in crafting start GUI (raoulvdberge)

View File

@@ -74,6 +74,13 @@ public abstract class ItemStorageNBT implements IItemStorage {
} }
} }
// ItemHandlerHelper#copyStackWithSize is not null-safe!
private ItemStack safeCopy(ItemStack stack, int size) {
ItemStack newStack = stack.copy();
newStack.stackSize = size;
return newStack;
}
/** /**
* Writes the items to the NBT tag. * Writes the items to the NBT tag.
*/ */
@@ -158,7 +165,7 @@ public abstract class ItemStorageNBT implements IItemStorage {
if (!simulate) { if (!simulate) {
tag.setInteger(NBT_STORED, getStored() + remainingSpace); tag.setInteger(NBT_STORED, getStored() + remainingSpace);
stacks.add(ItemHandlerHelper.copyStackWithSize(stack, remainingSpace)); stacks.add(safeCopy(stack, remainingSpace));
onStorageChanged(); onStorageChanged();
} }
@@ -168,7 +175,7 @@ public abstract class ItemStorageNBT implements IItemStorage {
if (!simulate) { if (!simulate) {
tag.setInteger(NBT_STORED, getStored() + size); tag.setInteger(NBT_STORED, getStored() + size);
stacks.add(ItemHandlerHelper.copyStackWithSize(stack, size)); stacks.add(safeCopy(stack, size));
onStorageChanged(); onStorageChanged();
} }