From ad16df32d75401bd60c3aa3262b37263b9d149da Mon Sep 17 00:00:00 2001 From: chromapid <67613147+chromapid@users.noreply.github.com> Date: Mon, 20 Dec 2021 23:50:17 -0700 Subject: [PATCH] Fixed crash when an empty item is cleared. --- .../java/net/simon987/mar/cubot/CubotInventory.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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; }