Fixed crash when an empty item is cleared.

This commit is contained in:
chromapid 2021-12-20 23:50:17 -07:00
parent 292f737971
commit ad16df32d7

View File

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