prevent from missing keys causing NPE

This commit is contained in:
gnembon committed 2019-12-28 16:09:32 -04:00
1 parent 7a4f3361b2
commit 8d17abfbe8
1 file changed
+4 -2
@@ -218,11 +218,13 @@ public class CarpetExpression
Value v0 = params.get(0).evalValue(c);
if (v0 instanceof BlockValue)
{
Value retval = new StringValue(test.apply( ((BlockValue) v0).getBlockState(), ((BlockValue) v0).getPos()));
String strVal = test.apply( ((BlockValue) v0).getBlockState(), ((BlockValue) v0).getPos());
Value retval = strVal != null ? new StringValue(strVal) : Value.NULL;
return (c_, t_) -> retval;
}
BlockValue block = BlockValue.fromParams(cc, params, 0).block;
Value retval = new StringValue(test.apply(block.getBlockState(), block.getPos()));
String strVal = test.apply(block.getBlockState(), block.getPos());
Value retval = strVal != null ? new StringValue(strVal) : Value.NULL;
return (c_, t_) -> retval;
}