From 7ee313134e1aa20c9a2a9afd64749c45e9bc4345 Mon Sep 17 00:00:00 2001 From: gnembon Date: Fri, 11 Jun 2021 00:37:45 -0300 Subject: [PATCH] Pulling in from empty list container returns null like for other containers. Fixes #660 --- src/main/java/carpet/script/value/ListValue.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/carpet/script/value/ListValue.java b/src/main/java/carpet/script/value/ListValue.java index 886019d4..2b0abd56 100644 --- a/src/main/java/carpet/script/value/ListValue.java +++ b/src/main/java/carpet/script/value/ListValue.java @@ -437,7 +437,15 @@ public class ListValue extends AbstractListValue implements ContainerValueInterf public Value get(Value value) { long index = NumericValue.asNumber(value, "'address' to a list index").getLong(); - return items.get(normalizeIndex(index, items.size())); + try + { + return items.get(normalizeIndex(index, items.size())); + } + catch (ArithmeticException are) + { + if (items.isEmpty()) return Value.NULL; + throw are; + } } @Override