Safety features

This commit is contained in:
Raoul Van den Berge
2016-06-11 09:21:17 +02:00
parent 4e1abdb756
commit 56d8f21169
3 changed files with 15 additions and 4 deletions

View File

@@ -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

View File

@@ -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);
}
}

View File

@@ -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) {