remove instanceof NullValues fixes #1313
This commit is contained in:
1 parent
5c4e18ead1
commit
695b569977
11 files changed
+29
-24
No files matched your search
@@ -361,7 +361,7 @@ public class Auxiliary {
|
||||
try
|
||||
{
|
||||
Value nameValue = lv.get(0);
|
||||
name = nameValue instanceof NullValue ? "" : nameValue.getString();
|
||||
name = nameValue.isNull() ? "" : nameValue.getString();
|
||||
pointLocator = Vector3Argument.findIn(lv, 1, true, false);
|
||||
if (lv.size()>pointLocator.offset)
|
||||
{
|
||||
|
||||
@@ -248,7 +248,7 @@ public class Inventories {
|
||||
Value nbtValue = lv.get(inventoryLocator.offset()+3);
|
||||
if (nbtValue instanceof NBTSerializableValue)
|
||||
nbt = ((NBTSerializableValue)nbtValue).getCompoundTag();
|
||||
else if (nbtValue instanceof NullValue)
|
||||
else if (nbtValue.isNull())
|
||||
nbt = null;
|
||||
else
|
||||
nbt = new NBTSerializableValue(nbtValue.getString()).getCompoundTag();
|
||||
@@ -277,7 +277,7 @@ public class Inventories {
|
||||
if (lv.size() > inventoryLocator.offset())
|
||||
{
|
||||
Value secondArg = lv.get(inventoryLocator.offset()+0);
|
||||
if (!(secondArg instanceof NullValue))
|
||||
if (!secondArg.isNull())
|
||||
itemArg = NBTSerializableValue.parseItem(secondArg.getString());
|
||||
}
|
||||
int startIndex = 0;
|
||||
|
||||
@@ -231,7 +231,7 @@ public class Scoreboards {
|
||||
int slot = Scoreboard.getDisplaySlotByName(location);
|
||||
if (slot < 0) throw new InternalExpressionException("Invalid objective slot: "+location);
|
||||
Value target = lv.get(1);
|
||||
if (target instanceof NullValue)
|
||||
if (target.isNull())
|
||||
{
|
||||
scoreboard.setDisplayObjective(slot, null);
|
||||
return new NumericValue(slot);
|
||||
|
||||
@@ -820,7 +820,7 @@ public class WorldAccess {
|
||||
{
|
||||
if (!playerBreak) throw new InternalExpressionException("tag is not necessary with 'destroy' with no item");
|
||||
Value tagValue = lv.get(locator.offset+1);
|
||||
if (tagValue instanceof NullValue)
|
||||
if (tagValue.isNull())
|
||||
tag = null;
|
||||
else if (tagValue instanceof NBTSerializableValue)
|
||||
tag = ((NBTSerializableValue) tagValue).getCompoundTag();
|
||||
@@ -1294,7 +1294,7 @@ public class WorldAccess {
|
||||
if (lv.size() > locator.offset)
|
||||
{
|
||||
Value requested = lv.get(locator.offset+0);
|
||||
if (!(requested instanceof NullValue))
|
||||
if (!requested.isNull())
|
||||
{
|
||||
String reqString = requested.getString();
|
||||
structure = Registry.STRUCTURE_FEATURE.getOptional(InputValidator.identifierOf(reqString))
|
||||
@@ -1389,7 +1389,7 @@ public class WorldAccess {
|
||||
return;
|
||||
}
|
||||
Value newValue = lv.get(locator.offset+1);
|
||||
if (newValue instanceof NullValue) // remove structure
|
||||
if (newValue.isNull()) // remove structure
|
||||
{
|
||||
StructureFeature<?> structure = configuredStructure.feature;
|
||||
if (!structures.containsKey(structure))
|
||||
|
||||
@@ -51,7 +51,7 @@ public class BlockArgument extends Argument
|
||||
{
|
||||
Value v1 = params.next();
|
||||
//add conditional from string name
|
||||
if (optional && v1 instanceof NullValue)
|
||||
if (optional && v1.isNull())
|
||||
{
|
||||
return new BlockArgument(null, 1 + offset);
|
||||
}
|
||||
@@ -105,7 +105,7 @@ public class BlockArgument extends Argument
|
||||
{
|
||||
Value v1 = params.get(0 + offset);
|
||||
//add conditional from string name
|
||||
if (optional && v1 instanceof NullValue)
|
||||
if (optional && v1.isNull())
|
||||
{
|
||||
return new BlockArgument(null, 1+offset);
|
||||
}
|
||||
|
||||
@@ -241,8 +241,8 @@ public class Sys {
|
||||
|
||||
double result;
|
||||
|
||||
if (z instanceof NullValue)
|
||||
if (y instanceof NullValue)
|
||||
if (z.isNull())
|
||||
if (y.isNull())
|
||||
result = sampler.sample1d(NumericValue.asNumber(x).getDouble());
|
||||
else
|
||||
result = sampler.sample2d(NumericValue.asNumber(x).getDouble(), NumericValue.asNumber(y).getDouble());
|
||||
@@ -279,7 +279,7 @@ public class Sys {
|
||||
}
|
||||
double result;
|
||||
|
||||
if (z instanceof NullValue)
|
||||
if (z.isNull())
|
||||
result = sampler.sample2d(NumericValue.asNumber(x).getDouble(), NumericValue.asNumber(y).getDouble());
|
||||
else
|
||||
result = sampler.sample3d(
|
||||
|
||||
@@ -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,18 +187,19 @@ public class NumericValue extends Value
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (o instanceof NullValue)
|
||||
{
|
||||
if (o instanceof Value value) {
|
||||
if (value.isNull()) {
|
||||
return o.equals(this);
|
||||
}
|
||||
if (o instanceof NumericValue no)
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user