remove instanceof NullValues fixes #1313

This commit is contained in:
gnembon committed 2022-02-06 00:18:42 +01:00
1 parent 5c4e18ead1
commit 695b569977
11 files changed
+35 -30

No files matched your search

@@ -1231,7 +1231,7 @@ public class EntityValue extends Value
});
put("custom_name", (e, v) -> {
if (v instanceof NullValue)
if (v.isNull())
{
e.setCustomNameVisible(false);
e.setCustomName(null);
@@ -1326,7 +1326,7 @@ public class EntityValue extends Value
PathfinderMob ec = (PathfinderMob)e;
if (v == null)
throw new InternalExpressionException("'home' requires at least one position argument, and optional distance, or null to cancel");
if (v instanceof NullValue)
if (v.isNull())
{
ec.restrictTo(BlockPos.ZERO, -1);
Map<String,Goal> tasks = ((MobEntityInterface)ec).getTemporaryTasks();
@@ -24,7 +24,7 @@ public class FormattedTextValue extends StringValue
}
else
{
if (left instanceof NullValue)
if (left.isNull())
return right;
text = new TextComponent(left.getString());
}
@@ -36,7 +36,7 @@ public class FormattedTextValue extends StringValue
}
else
{
if (right instanceof NullValue)
if (right.isNull())
return left;
text.append(right.getString());
return new FormattedTextValue(text);
@@ -389,7 +389,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
{
if (v instanceof NBTSerializableValue)
return v;
if (v instanceof NullValue)
if (v.isNull())
return Value.NULL;
return NBTSerializableValue.parseString(v.getString(), true);
}
@@ -37,7 +37,11 @@ public class NullValue extends NumericValue // TODO check nonsingleton code
@Override
public boolean equals(final Object o)
{
return o instanceof NullValue;
if (o instanceof Value value)
{
return value.isNull();
}
return false;
}
@Override
@@ -58,7 +62,7 @@ public class NullValue extends NumericValue // TODO check nonsingleton code
@Override
public int compareTo(Value o)
{
return o instanceof NullValue ? 0 : -1;
return o.isNull() ? 0 : -1;
}
@Override
@@ -172,7 +172,7 @@ public class NumericValue extends Value
@Override
public int compareTo(Value o)
{
if (o instanceof NullValue)
if (o.isNull())
{
return -o.compareTo(this);
}
@@ -187,17 +187,18 @@ public class NumericValue extends Value
@Override
public boolean equals(Object o)
{
if (o instanceof NullValue)
{
return o.equals(this);
if (o instanceof Value value) {
if (value.isNull()) {
return o.equals(this);
}
if (o instanceof NumericValue no) {
if (longValue != null && no.longValue != null)
return longValue.equals(no.longValue);
return !this.subtract(no).getBoolean();
}
return super.equals(o);
}
if (o instanceof NumericValue no)
{
if (longValue != null && no.longValue != null)
return longValue.equals(no.longValue);
return !this.subtract(no).getBoolean();
}
return super.equals(o);
return false;
}
public NumericValue(double value)