fixed so modify(..,'effect',...) does what docs say.

This commit is contained in:
gnembon committed 2020-05-27 00:53:21 -03:00
1 parent 2c777ea3ad
commit a1200d4c37
1 file changed
+12
@@ -861,7 +861,10 @@ public class EntityValue extends Value
if (!(e instanceof LivingEntity)) return; if (!(e instanceof LivingEntity)) return;
LivingEntity le = (LivingEntity)e; LivingEntity le = (LivingEntity)e;
if (v == null) if (v == null)
{
le.clearStatusEffects(); le.clearStatusEffects();
return;
}
else if (v instanceof ListValue) else if (v instanceof ListValue)
{ {
List<Value> lv = ((ListValue) v).getItems(); List<Value> lv = ((ListValue) v).getItems();
@@ -895,6 +898,15 @@ public class EntityValue extends Value
return; return;
} }
} }
else
{
String effectName = v.getString();
StatusEffect effect = Registry.STATUS_EFFECT.get(new Identifier(effectName));
if (effect == null)
throw new InternalExpressionException("Wrong effect name: "+effectName);
le.removeStatusEffect(effect);
return;
}
throw new InternalExpressionException("'effect' needs either no arguments (clear) or effect name, duration, and optional amplifier, show particles and show icon"); throw new InternalExpressionException("'effect' needs either no arguments (clear) or effect name, duration, and optional amplifier, show particles and show icon");
}); });