diff --git a/src/main/java/refinedstorage/api/storage/NBTStorage.java b/src/main/java/refinedstorage/api/storage/NBTStorage.java index 7ad8564a3..9438af661 100755 --- a/src/main/java/refinedstorage/api/storage/NBTStorage.java +++ b/src/main/java/refinedstorage/api/storage/NBTStorage.java @@ -14,6 +14,14 @@ import java.util.List; * A implementation of {@link IStorage} that stores storage items in NBT. */ public abstract class NBTStorage implements IStorage { + /** + * The current save protocol Refined Storage uses, is set to every NBTStorage to allow for + * safe backwards compatibility breaks. + */ + public static final int PROTOCOL = 1; + + public static final String NBT_PROTOCOL = "Protocol"; + public static final String NBT_ITEMS = "Items"; public static final String NBT_STORED = "Stored"; @@ -96,6 +104,7 @@ public abstract class NBTStorage implements IStorage { } tag.setTag(NBT_ITEMS, list); + tag.setInteger(NBT_PROTOCOL, PROTOCOL); } @Override diff --git a/src/main/java/refinedstorage/tile/TileInterface.java b/src/main/java/refinedstorage/tile/TileInterface.java index 72176f679..1088fced1 100755 --- a/src/main/java/refinedstorage/tile/TileInterface.java +++ b/src/main/java/refinedstorage/tile/TileInterface.java @@ -52,12 +52,10 @@ public class TileInterface extends TileMachine implements ICompareConfig { } else if (ticks % RefinedStorageUtils.getSpeed(upgrades) == 0) { int size = RefinedStorageUtils.hasUpgrade(upgrades, ItemUpgrade.TYPE_STACK) ? 64 : 1; - ItemStack remainder = controller.push(slot, size, false); + if (controller.push(slot, size, true) == null) { + controller.push(slot, size, false); - if (remainder == null) { importItems.extractItem(currentSlot, size, false); - } else { - importItems.extractItem(currentSlot, size - remainder.stackSize, false); } } diff --git a/src/main/java/refinedstorage/tile/controller/TileController.java b/src/main/java/refinedstorage/tile/controller/TileController.java index 48f7a3963..82df366ce 100755 --- a/src/main/java/refinedstorage/tile/controller/TileController.java +++ b/src/main/java/refinedstorage/tile/controller/TileController.java @@ -407,6 +407,10 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr } public ItemStack push(ItemStack stack, int size, boolean simulate) { + if (stack == null || stack.getItem() == null) { + return null; + } + ItemStack remainder = stack; for (IStorage storage : storages) {