Merge branch 'master' into 1.15
This commit is contained in:
commit
51cbe4ac01
5 files changed
+47
-10
No files matched your search
@@ -7,6 +7,7 @@ import carpet.script.CarpetEventServer;
|
||||
import carpet.script.CarpetExpression;
|
||||
import carpet.script.Expression;
|
||||
import carpet.script.ExpressionInspector;
|
||||
import carpet.script.LazyValue;
|
||||
import carpet.script.Tokenizer;
|
||||
import carpet.script.exception.CarpetExpressionException;
|
||||
import carpet.script.value.FunctionValue;
|
||||
@@ -317,6 +318,13 @@ public class ScriptCommand
|
||||
Messenger.m(source, "lb Stored functions"+((host == CarpetServer.scriptServer.globalHost)?":":" in "+host.getName()+":"));
|
||||
host.globaFunctionNames(host.main, (str) -> all || !str.startsWith("__")).sorted().forEach( (s) -> {
|
||||
FunctionValue fun = host.getFunction(s);
|
||||
if (fun == null)
|
||||
{
|
||||
Messenger.m(source, "gb "+s, "g - unused import");
|
||||
Messenger.m(source, "gi ----------------");
|
||||
return;
|
||||
}
|
||||
CarpetSettings.LOG.error("printing function "+fun.getPrettyString());
|
||||
Expression expr = fun.getExpression();
|
||||
Tokenizer.Token tok = fun.getToken();
|
||||
List<String> snippet = ExpressionInspector.Expression_getExpressionSnippet(tok, expr);
|
||||
@@ -331,7 +339,15 @@ public class ScriptCommand
|
||||
Messenger.m(source, "w ");
|
||||
Messenger.m(source, "lb Global variables"+((host == CarpetServer.scriptServer.globalHost)?":":" in "+host.getName()+":"));
|
||||
host.globaVariableNames(host.main, (s) -> s.startsWith("global_")).sorted().forEach( (s) -> {
|
||||
Messenger.m(source, "wb "+s+": ", "w "+ host.getGlobalVariable(s).evalValue(null).getPrettyString());
|
||||
LazyValue variable = host.getGlobalVariable(s);
|
||||
if (variable == null)
|
||||
{
|
||||
Messenger.m(source, "gb "+s, "g - unused import");
|
||||
}
|
||||
else
|
||||
{
|
||||
Messenger.m(source, "wb "+s+": ", "w "+ variable.evalValue(null).getPrettyString());
|
||||
}
|
||||
});
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2072,11 +2072,12 @@ public class CarpetExpression
|
||||
* <h3><code>query(e,'trace', reach?, options?...)</code></h3>
|
||||
* <p>Returns the result of ray tracing from entity perspective, indicating what it is looking at. Default reach is 4.5
|
||||
* blocks (5 for creative players), and by default it traces for blocks and entities, identical to player attack tracing action.
|
||||
* This can be customized with <code>options</code>, use 'blocks' to trace for blocks only, 'liquids' to include liquid blocks
|
||||
* as possible results, and 'entities' to trace entities as well.</p>
|
||||
* This can be customized with <code>options</code>, use 'blocks' to trace for blocks, 'liquids' to include liquid blocks
|
||||
* as possible results, and 'entities' to trace entities. Any combination of the above is possible. When tracing
|
||||
* entities and blocks, blocks will take over the priority even if transparent or non-colliding (aka fighting chickens
|
||||
* in tall grass).</p>
|
||||
* <p>Regardless of the options selected, the result could be <code>null</code> if nothing is in reach, entity, if look
|
||||
* targets an antity, and block value if block is in reach. Tracing always hits blocks. Even if an entity tracing is requested
|
||||
* and there is a block in the way - the block will be returned.</p>
|
||||
* targets an entity, and block value if block is in reach.</p>
|
||||
* <h3><code>query(e,'nbt',path?)</code></h3>
|
||||
* <p>Returns full NBT of the entity. If path is specified, it fetches only that portion of the NBT,
|
||||
* that corresponds to the path. For specification of <code>path</code> attribute, consult
|
||||
@@ -2133,9 +2134,9 @@ public class CarpetExpression
|
||||
* <h3><code>modify(e, 'no_clip', boolean)</code></h3>
|
||||
* <p>Sets if the entity obeys any collisions, including collisions with the terrain and basic physics.
|
||||
* Not affecting players, since they are controlled client side</p>
|
||||
* <h3><code>modify(e, 'effect', name, duration, amplifier?, show_particles?, show_icon?)</code></h3>
|
||||
* <h3><code>modify(e, 'effect', name, duration?, amplifier?, show_particles?, show_icon?)</code></h3>
|
||||
* <p>Applies status effect to the living entity. Takes several optional parameters, which default to <code>0</code>,
|
||||
* <code>true</code> and <code>true</code>.</p>
|
||||
* <code>true</code> and <code>true</code>. If no duration is specified, or it is null or 0, the effect is removed.</p>
|
||||
* <h3><code>modify(e, 'home', null), modify(e, 'home', block, distance?), modify(e, 'home', x, y, z, distance?)</code></h3>
|
||||
* <p>Sets AI to stay around the home position, within <code>distance</code> blocks from it. <code>distance</code>
|
||||
* defaults to 16 blocks. <code>null</code> removes it. <i>May</i> not work fully with mobs that have this AI built in, like
|
||||
|
||||
@@ -45,6 +45,7 @@ public class CarpetScriptServer
|
||||
add(new BundledModule("camera", false));
|
||||
add(new BundledModule("event_test", false));
|
||||
add(new BundledModule("stats_test", false));
|
||||
add(new BundledModule("math", true));
|
||||
}};
|
||||
|
||||
public CarpetScriptServer()
|
||||
|
||||
@@ -385,6 +385,7 @@ public class EntityValue extends Value
|
||||
float reach = 4.5f;
|
||||
boolean entities = true;
|
||||
boolean liquids = false;
|
||||
boolean blocks = true;
|
||||
|
||||
if (a!=null)
|
||||
{
|
||||
@@ -401,12 +402,14 @@ public class EntityValue extends Value
|
||||
if (args.size() > 1)
|
||||
{
|
||||
entities = false;
|
||||
blocks = false;
|
||||
for (int i = 1; i < args.size(); i++)
|
||||
{
|
||||
String what = args.get(i).getString();
|
||||
if (what.equalsIgnoreCase("entities"))
|
||||
entities = true;
|
||||
else if (what.equalsIgnoreCase("blocks")) {}
|
||||
else if (what.equalsIgnoreCase("blocks"))
|
||||
blocks = true;
|
||||
else if (what.equalsIgnoreCase("liquids"))
|
||||
liquids = true;
|
||||
else throw new InternalExpressionException("Incorrect tracing: "+what);
|
||||
@@ -420,11 +423,14 @@ public class EntityValue extends Value
|
||||
}
|
||||
|
||||
HitResult hitres;
|
||||
if (entities)
|
||||
if (entities && !blocks)
|
||||
hitres = Tracer.rayTraceEntities(e, 1, reach, reach*reach);
|
||||
else if (entities)
|
||||
hitres = Tracer.rayTrace(e, 1, reach, liquids);
|
||||
else
|
||||
hitres = Tracer.rayTraceBlocks(e, 1, reach, liquids);
|
||||
|
||||
if (hitres == null) return Value.NULL;
|
||||
switch (hitres.getType())
|
||||
{
|
||||
case MISS: return Value.NULL;
|
||||
@@ -783,13 +789,23 @@ public class EntityValue extends Value
|
||||
else if (v instanceof ListValue)
|
||||
{
|
||||
List<Value> lv = ((ListValue) v).getItems();
|
||||
if (lv.size() >= 2 && lv.size() <= 5)
|
||||
if (lv.size() >= 1 && lv.size() <= 5)
|
||||
{
|
||||
String effectName = lv.get(0).getString();
|
||||
StatusEffect effect = Registry.STATUS_EFFECT.get(new Identifier(effectName));
|
||||
if (effect == null)
|
||||
throw new InternalExpressionException("Wrong effect name: "+effectName);
|
||||
if (lv.size() == 1)
|
||||
{
|
||||
le.removeStatusEffect(effect);
|
||||
return;
|
||||
}
|
||||
int duration = (int)NumericValue.asNumber(lv.get(1)).getLong();
|
||||
if (duration <= 0)
|
||||
{
|
||||
le.removeStatusEffect(effect);
|
||||
return;
|
||||
}
|
||||
int amplifier = 0;
|
||||
if (lv.size() > 2)
|
||||
amplifier = (int)NumericValue.asNumber(lv.get(2)).getLong();
|
||||
|
||||
Reference in new issue
Block a user