Merge branch 'master' into 1.16
This commit is contained in:
commit
e64f6c87d4
6 files changed
+177
-6
No files matched your search
@@ -23,6 +23,7 @@ import carpet.script.exception.ExpressionException;
|
||||
import carpet.script.exception.InternalExpressionException;
|
||||
import carpet.script.value.BlockValue;
|
||||
import carpet.script.value.EntityValue;
|
||||
import carpet.script.value.FormattedTextValue;
|
||||
import carpet.script.value.FunctionValue;
|
||||
import carpet.script.value.LazyListValue;
|
||||
import carpet.script.value.ListValue;
|
||||
@@ -2676,17 +2677,33 @@ public class CarpetExpression
|
||||
{
|
||||
ServerCommandSource s = ((CarpetContext)c).s;
|
||||
Value res = lv.get(0).evalValue(c);
|
||||
if (s.getEntity() instanceof PlayerEntity)
|
||||
if (res instanceof FormattedTextValue)
|
||||
{
|
||||
Messenger.m((PlayerEntity) s.getEntity(), "w "+ res.getString());
|
||||
s.sendFeedback(((FormattedTextValue) res).getText(), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
Messenger.m(s, "w "+ res.getString());
|
||||
if (s.getEntity() instanceof PlayerEntity)
|
||||
{
|
||||
Messenger.m((PlayerEntity) s.getEntity(), "w " + res.getString());
|
||||
}
|
||||
else
|
||||
{
|
||||
Messenger.m(s, "w " + res.getString());
|
||||
}
|
||||
}
|
||||
return (_c, _t) -> res; // pass through for variables
|
||||
});
|
||||
|
||||
this.expr.addLazyFunction("format", -1, (c, t, lv) -> {
|
||||
if (lv.size() == 0 ) throw new InternalExpressionException("'format' requires at least one component");
|
||||
List<Value> values = lv.stream().map(lazy -> lazy.evalValue(c)).collect(Collectors.toList());
|
||||
if (values.get(0) instanceof ListValue && values.size()==1)
|
||||
values = ((ListValue) values.get(0)).getItems();
|
||||
Value ret = new FormattedTextValue(Messenger.c(values.stream().map(Value::getString).toArray()));
|
||||
return (cc, tt) -> ret;
|
||||
});
|
||||
|
||||
//"overidden" native call to cancel if on main thread
|
||||
this.expr.addLazyFunction("task_join", 1, (c, t, lv) -> {
|
||||
if (((CarpetContext)c).s.getMinecraftServer().isOnThread())
|
||||
|
||||
Reference in new issue
Block a user