remove instanceof NullValues fixes #1313
This commit is contained in:
1 parent
5c4e18ead1
commit
695b569977
11 files changed
+35
-30
No files matched your search
@@ -361,7 +361,7 @@ public class Auxiliary {
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Value nameValue = lv.get(0);
|
Value nameValue = lv.get(0);
|
||||||
name = nameValue instanceof NullValue ? "" : nameValue.getString();
|
name = nameValue.isNull() ? "" : nameValue.getString();
|
||||||
pointLocator = Vector3Argument.findIn(lv, 1, true, false);
|
pointLocator = Vector3Argument.findIn(lv, 1, true, false);
|
||||||
if (lv.size()>pointLocator.offset)
|
if (lv.size()>pointLocator.offset)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ public class Inventories {
|
|||||||
Value nbtValue = lv.get(inventoryLocator.offset()+3);
|
Value nbtValue = lv.get(inventoryLocator.offset()+3);
|
||||||
if (nbtValue instanceof NBTSerializableValue)
|
if (nbtValue instanceof NBTSerializableValue)
|
||||||
nbt = ((NBTSerializableValue)nbtValue).getCompoundTag();
|
nbt = ((NBTSerializableValue)nbtValue).getCompoundTag();
|
||||||
else if (nbtValue instanceof NullValue)
|
else if (nbtValue.isNull())
|
||||||
nbt = null;
|
nbt = null;
|
||||||
else
|
else
|
||||||
nbt = new NBTSerializableValue(nbtValue.getString()).getCompoundTag();
|
nbt = new NBTSerializableValue(nbtValue.getString()).getCompoundTag();
|
||||||
@@ -277,7 +277,7 @@ public class Inventories {
|
|||||||
if (lv.size() > inventoryLocator.offset())
|
if (lv.size() > inventoryLocator.offset())
|
||||||
{
|
{
|
||||||
Value secondArg = lv.get(inventoryLocator.offset()+0);
|
Value secondArg = lv.get(inventoryLocator.offset()+0);
|
||||||
if (!(secondArg instanceof NullValue))
|
if (!secondArg.isNull())
|
||||||
itemArg = NBTSerializableValue.parseItem(secondArg.getString());
|
itemArg = NBTSerializableValue.parseItem(secondArg.getString());
|
||||||
}
|
}
|
||||||
int startIndex = 0;
|
int startIndex = 0;
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ public class Scoreboards {
|
|||||||
int slot = Scoreboard.getDisplaySlotByName(location);
|
int slot = Scoreboard.getDisplaySlotByName(location);
|
||||||
if (slot < 0) throw new InternalExpressionException("Invalid objective slot: "+location);
|
if (slot < 0) throw new InternalExpressionException("Invalid objective slot: "+location);
|
||||||
Value target = lv.get(1);
|
Value target = lv.get(1);
|
||||||
if (target instanceof NullValue)
|
if (target.isNull())
|
||||||
{
|
{
|
||||||
scoreboard.setDisplayObjective(slot, null);
|
scoreboard.setDisplayObjective(slot, null);
|
||||||
return new NumericValue(slot);
|
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");
|
if (!playerBreak) throw new InternalExpressionException("tag is not necessary with 'destroy' with no item");
|
||||||
Value tagValue = lv.get(locator.offset+1);
|
Value tagValue = lv.get(locator.offset+1);
|
||||||
if (tagValue instanceof NullValue)
|
if (tagValue.isNull())
|
||||||
tag = null;
|
tag = null;
|
||||||
else if (tagValue instanceof NBTSerializableValue)
|
else if (tagValue instanceof NBTSerializableValue)
|
||||||
tag = ((NBTSerializableValue) tagValue).getCompoundTag();
|
tag = ((NBTSerializableValue) tagValue).getCompoundTag();
|
||||||
@@ -1294,7 +1294,7 @@ public class WorldAccess {
|
|||||||
if (lv.size() > locator.offset)
|
if (lv.size() > locator.offset)
|
||||||
{
|
{
|
||||||
Value requested = lv.get(locator.offset+0);
|
Value requested = lv.get(locator.offset+0);
|
||||||
if (!(requested instanceof NullValue))
|
if (!requested.isNull())
|
||||||
{
|
{
|
||||||
String reqString = requested.getString();
|
String reqString = requested.getString();
|
||||||
structure = Registry.STRUCTURE_FEATURE.getOptional(InputValidator.identifierOf(reqString))
|
structure = Registry.STRUCTURE_FEATURE.getOptional(InputValidator.identifierOf(reqString))
|
||||||
@@ -1389,7 +1389,7 @@ public class WorldAccess {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Value newValue = lv.get(locator.offset+1);
|
Value newValue = lv.get(locator.offset+1);
|
||||||
if (newValue instanceof NullValue) // remove structure
|
if (newValue.isNull()) // remove structure
|
||||||
{
|
{
|
||||||
StructureFeature<?> structure = configuredStructure.feature;
|
StructureFeature<?> structure = configuredStructure.feature;
|
||||||
if (!structures.containsKey(structure))
|
if (!structures.containsKey(structure))
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class BlockArgument extends Argument
|
|||||||
{
|
{
|
||||||
Value v1 = params.next();
|
Value v1 = params.next();
|
||||||
//add conditional from string name
|
//add conditional from string name
|
||||||
if (optional && v1 instanceof NullValue)
|
if (optional && v1.isNull())
|
||||||
{
|
{
|
||||||
return new BlockArgument(null, 1 + offset);
|
return new BlockArgument(null, 1 + offset);
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ public class BlockArgument extends Argument
|
|||||||
{
|
{
|
||||||
Value v1 = params.get(0 + offset);
|
Value v1 = params.get(0 + offset);
|
||||||
//add conditional from string name
|
//add conditional from string name
|
||||||
if (optional && v1 instanceof NullValue)
|
if (optional && v1.isNull())
|
||||||
{
|
{
|
||||||
return new BlockArgument(null, 1+offset);
|
return new BlockArgument(null, 1+offset);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -241,8 +241,8 @@ public class Sys {
|
|||||||
|
|
||||||
double result;
|
double result;
|
||||||
|
|
||||||
if (z instanceof NullValue)
|
if (z.isNull())
|
||||||
if (y instanceof NullValue)
|
if (y.isNull())
|
||||||
result = sampler.sample1d(NumericValue.asNumber(x).getDouble());
|
result = sampler.sample1d(NumericValue.asNumber(x).getDouble());
|
||||||
else
|
else
|
||||||
result = sampler.sample2d(NumericValue.asNumber(x).getDouble(), NumericValue.asNumber(y).getDouble());
|
result = sampler.sample2d(NumericValue.asNumber(x).getDouble(), NumericValue.asNumber(y).getDouble());
|
||||||
@@ -279,7 +279,7 @@ public class Sys {
|
|||||||
}
|
}
|
||||||
double result;
|
double result;
|
||||||
|
|
||||||
if (z instanceof NullValue)
|
if (z.isNull())
|
||||||
result = sampler.sample2d(NumericValue.asNumber(x).getDouble(), NumericValue.asNumber(y).getDouble());
|
result = sampler.sample2d(NumericValue.asNumber(x).getDouble(), NumericValue.asNumber(y).getDouble());
|
||||||
else
|
else
|
||||||
result = sampler.sample3d(
|
result = sampler.sample3d(
|
||||||
|
|||||||
@@ -1231,7 +1231,7 @@ public class EntityValue extends Value
|
|||||||
|
|
||||||
});
|
});
|
||||||
put("custom_name", (e, v) -> {
|
put("custom_name", (e, v) -> {
|
||||||
if (v instanceof NullValue)
|
if (v.isNull())
|
||||||
{
|
{
|
||||||
e.setCustomNameVisible(false);
|
e.setCustomNameVisible(false);
|
||||||
e.setCustomName(null);
|
e.setCustomName(null);
|
||||||
@@ -1326,7 +1326,7 @@ public class EntityValue extends Value
|
|||||||
PathfinderMob ec = (PathfinderMob)e;
|
PathfinderMob ec = (PathfinderMob)e;
|
||||||
if (v == null)
|
if (v == null)
|
||||||
throw new InternalExpressionException("'home' requires at least one position argument, and optional distance, or null to cancel");
|
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);
|
ec.restrictTo(BlockPos.ZERO, -1);
|
||||||
Map<String,Goal> tasks = ((MobEntityInterface)ec).getTemporaryTasks();
|
Map<String,Goal> tasks = ((MobEntityInterface)ec).getTemporaryTasks();
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class FormattedTextValue extends StringValue
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (left instanceof NullValue)
|
if (left.isNull())
|
||||||
return right;
|
return right;
|
||||||
text = new TextComponent(left.getString());
|
text = new TextComponent(left.getString());
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ public class FormattedTextValue extends StringValue
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (right instanceof NullValue)
|
if (right.isNull())
|
||||||
return left;
|
return left;
|
||||||
text.append(right.getString());
|
text.append(right.getString());
|
||||||
return new FormattedTextValue(text);
|
return new FormattedTextValue(text);
|
||||||
|
|||||||
@@ -389,7 +389,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
|
|||||||
{
|
{
|
||||||
if (v instanceof NBTSerializableValue)
|
if (v instanceof NBTSerializableValue)
|
||||||
return v;
|
return v;
|
||||||
if (v instanceof NullValue)
|
if (v.isNull())
|
||||||
return Value.NULL;
|
return Value.NULL;
|
||||||
return NBTSerializableValue.parseString(v.getString(), true);
|
return NBTSerializableValue.parseString(v.getString(), true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,11 @@ public class NullValue extends NumericValue // TODO check nonsingleton code
|
|||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object o)
|
public boolean equals(final Object o)
|
||||||
{
|
{
|
||||||
return o instanceof NullValue;
|
if (o instanceof Value value)
|
||||||
|
{
|
||||||
|
return value.isNull();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -58,7 +62,7 @@ public class NullValue extends NumericValue // TODO check nonsingleton code
|
|||||||
@Override
|
@Override
|
||||||
public int compareTo(Value o)
|
public int compareTo(Value o)
|
||||||
{
|
{
|
||||||
return o instanceof NullValue ? 0 : -1;
|
return o.isNull() ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ public class NumericValue extends Value
|
|||||||
@Override
|
@Override
|
||||||
public int compareTo(Value o)
|
public int compareTo(Value o)
|
||||||
{
|
{
|
||||||
if (o instanceof NullValue)
|
if (o.isNull())
|
||||||
{
|
{
|
||||||
return -o.compareTo(this);
|
return -o.compareTo(this);
|
||||||
}
|
}
|
||||||
@@ -187,17 +187,18 @@ public class NumericValue extends Value
|
|||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o)
|
public boolean equals(Object o)
|
||||||
{
|
{
|
||||||
if (o instanceof NullValue)
|
if (o instanceof Value value) {
|
||||||
{
|
if (value.isNull()) {
|
||||||
return o.equals(this);
|
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)
|
return false;
|
||||||
{
|
|
||||||
if (longValue != null && no.longValue != null)
|
|
||||||
return longValue.equals(no.longValue);
|
|
||||||
return !this.subtract(no).getBoolean();
|
|
||||||
}
|
|
||||||
return super.equals(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public NumericValue(double value)
|
public NumericValue(double value)
|
||||||
|
|||||||
Reference in new issue
Block a user