Safety features
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user