diff --git a/src/main/java/net/simon987/mar/cubot/CubotInventory.java b/src/main/java/net/simon987/mar/cubot/CubotInventory.java index d143118..2b69db7 100644 --- a/src/main/java/net/simon987/mar/cubot/CubotInventory.java +++ b/src/main/java/net/simon987/mar/cubot/CubotInventory.java @@ -55,14 +55,19 @@ public class CubotInventory extends HardwareModule { private void scanItem() { int x = getCpu().getRegisterSet().getRegister("X").getValue(); Item item = inventory.get(position); - item.digitize(unit.getCpu().getMemory(), x); + if (item != null) { + item.clear(unit); + inventory.remove(position); + item.digitize(unit.getCpu().getMemory(), x); + } } public Item clearItem() { Item item = inventory.get(position); - item.clear(unit); - inventory.remove(position); - + if (item != null) { + item.clear(unit); + inventory.remove(position); + } return item; }