Can't test for null IItemStack
Timeslice42 opened this issue ยท 2 comments
- Minecraft: 1.12.2
- Forge: 2515
- Crafttweaker: 4.0.8
ICraftingInventory.getStack(integer) can return a null value, but you cannot test for a null value.
Consider the following snippet: (cInfo is an ICraftingInfo):
for i in 0 to cInfo.inventory.size {
var item = cInfo.inventory.getStack(i);
if (item != null) {
print(item.displayName);
}
}
With the if
conditional an "operator not supported" error occurs when the script is parsed.
Without the if
conditional execution of the for
loop silently aborts on trying to print the display name if getStack
returns a null value (i.e. if the slot in the crafting inventory was empty).
So there isn't really a proper fix for this unfortunately, however I did add a isNull(<minecraft:dirt>)
which should help you solve the issue :)