refactor argument parsers
This commit is contained in:
1 parent
022addf4e1
commit
fb1a03b3f7
6 files changed
+317
-252
No files matched your search
@@ -18,6 +18,7 @@ import carpet.script.exception.ContinueStatement;
|
||||
import carpet.script.exception.ExitStatement;
|
||||
import carpet.script.exception.ExpressionException;
|
||||
import carpet.script.exception.InternalExpressionException;
|
||||
import carpet.script.utils.CarpetArgParser;
|
||||
import carpet.script.value.BlockValue;
|
||||
import carpet.script.value.EntityValue;
|
||||
import carpet.script.value.FunctionValue;
|
||||
@@ -132,7 +133,6 @@ import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static carpet.script.utils.WorldTools.canHasChunk;
|
||||
@@ -175,7 +175,7 @@ public class CarpetExpression
|
||||
Value retval = test.apply(((BlockValue) v0).getBlockState(), ((BlockValue) v0).getPos()) ? Value.TRUE : Value.FALSE;
|
||||
return (c_, t_) -> retval;
|
||||
}
|
||||
BlockValue block = BlockValue.fromParams(cc, params, 0).block;
|
||||
BlockValue block = CarpetArgParser.locateBlock(cc, params, 0).block;
|
||||
Value retval = test.apply(block.getBlockState(), block.getPos()) ? Value.TRUE : Value.FALSE;
|
||||
return (c_, t_) -> retval;
|
||||
}
|
||||
@@ -200,7 +200,7 @@ public class CarpetExpression
|
||||
Value retval = strVal != null ? new StringValue(strVal) : Value.NULL;
|
||||
return (c_, t_) -> retval;
|
||||
}
|
||||
BlockValue block = BlockValue.fromParams(cc, params, 0).block;
|
||||
BlockValue block = CarpetArgParser.locateBlock(cc, params, 0).block;
|
||||
String strVal = test.apply(block.getBlockState(), block.getPos());
|
||||
Value retval = strVal != null ? new StringValue(strVal) : Value.NULL;
|
||||
return (c_, t_) -> retval;
|
||||
@@ -231,7 +231,7 @@ public class CarpetExpression
|
||||
throw new InternalExpressionException("'" + name + "' function requires a block that is positioned in the world");
|
||||
}
|
||||
}
|
||||
BlockValue block = BlockValue.fromParams(cc, params, 0).block;
|
||||
BlockValue block = CarpetArgParser.locateBlock(cc, params, 0).block;
|
||||
Value retval = test.apply(block.getBlockState(), block.getPos(), cc.s.getWorld());
|
||||
return (c_, t_) -> retval;
|
||||
}
|
||||
@@ -400,7 +400,7 @@ public class CarpetExpression
|
||||
{
|
||||
throw new InternalExpressionException("Block requires at least one parameter");
|
||||
}
|
||||
BlockValue retval = BlockValue.fromParams(cc, lv, 0, true).block;
|
||||
BlockValue retval = CarpetArgParser.locateBlock(cc, lv, 0, true).block;
|
||||
// fixing block state and data
|
||||
retval.getBlockState();
|
||||
retval.getData();
|
||||
@@ -414,7 +414,7 @@ public class CarpetExpression
|
||||
{
|
||||
throw new InternalExpressionException("Block requires at least one parameter");
|
||||
}
|
||||
CompoundTag tag = BlockValue.fromParams(cc, lv, 0, true).block.getData();
|
||||
CompoundTag tag = CarpetArgParser.locateBlock(cc, lv, 0, true).block.getData();
|
||||
if (tag == null)
|
||||
return (c_, t_) -> Value.NULL;
|
||||
Value retval = new NBTSerializableValue(tag);
|
||||
@@ -426,7 +426,7 @@ public class CarpetExpression
|
||||
{
|
||||
CarpetContext cc = (CarpetContext) c;
|
||||
if (lv.size() == 0) throw new InternalExpressionException("'poi' requires at least one parameter");
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0, false);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock(cc, lv, 0, false);
|
||||
BlockPos pos = locator.block.getPos();
|
||||
PointOfInterestStorage store = cc.s.getWorld().getPointOfInterestStorage();
|
||||
if (lv.size() == locator.offset)
|
||||
@@ -492,7 +492,7 @@ public class CarpetExpression
|
||||
{
|
||||
CarpetContext cc = (CarpetContext) c;
|
||||
if (lv.size() == 0) throw new InternalExpressionException("'set_poi' requires at least one parameter");
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0, false);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock(cc, lv, 0, false);
|
||||
BlockPos pos = locator.block.getPos();
|
||||
if (lv.size() < locator.offset) throw new InternalExpressionException("'set_poi' requires the new poi type or null, after position argument");
|
||||
Value poi = lv.get(locator.offset+0).evalValue(c);
|
||||
@@ -559,7 +559,7 @@ public class CarpetExpression
|
||||
|
||||
this.expr.addLazyFunction("pos_offset", -1, (c, t, lv) ->
|
||||
{
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams((CarpetContext)c, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock((CarpetContext)c, lv, 0);
|
||||
BlockPos pos = locator.block.getPos();
|
||||
if (lv.size() <= locator.offset)
|
||||
throw new InternalExpressionException("'pos_offset' needs at least position, and direction");
|
||||
@@ -622,7 +622,7 @@ public class CarpetExpression
|
||||
|
||||
this.expr.addLazyFunction("in_slime_chunk", -1, (c, t, lv) ->
|
||||
{
|
||||
BlockPos pos = BlockValue.fromParams((CarpetContext)c, lv, 0).block.getPos();
|
||||
BlockPos pos = CarpetArgParser.locateBlock((CarpetContext)c, lv, 0).block.getPos();
|
||||
ChunkPos chunkPos = new ChunkPos(pos);
|
||||
Value ret = new NumericValue(ChunkRandom.create(
|
||||
chunkPos.x, chunkPos.z,
|
||||
@@ -646,7 +646,7 @@ public class CarpetExpression
|
||||
case "surface": htype = Heightmap.Type.WORLD_SURFACE; break;
|
||||
default: throw new InternalExpressionException("Unknown heightmap type: "+type);
|
||||
}
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams((CarpetContext)c, lv, 1);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock((CarpetContext)c, lv, 1);
|
||||
BlockPos pos = locator.block.getPos();
|
||||
int x = pos.getX();
|
||||
int z = pos.getZ();
|
||||
@@ -658,21 +658,21 @@ public class CarpetExpression
|
||||
|
||||
this.expr.addLazyFunction("loaded", -1, (c, t, lv) ->
|
||||
{
|
||||
Value retval = ((CarpetContext) c).s.getWorld().isChunkLoaded(BlockValue.fromParams((CarpetContext) c, lv, 0).block.getPos()) ? Value.TRUE : Value.FALSE;
|
||||
Value retval = ((CarpetContext) c).s.getWorld().isChunkLoaded(CarpetArgParser.locateBlock((CarpetContext) c, lv, 0).block.getPos()) ? Value.TRUE : Value.FALSE;
|
||||
return (c_, t_) -> retval;
|
||||
});
|
||||
|
||||
// Deprecated, use loaded_status as more indicative
|
||||
this.expr.addLazyFunction("loaded_ep", -1, (c, t, lv) ->
|
||||
{
|
||||
BlockPos pos = BlockValue.fromParams((CarpetContext)c, lv, 0).block.getPos();
|
||||
BlockPos pos = CarpetArgParser.locateBlock((CarpetContext)c, lv, 0).block.getPos();
|
||||
Value retval = ((CarpetContext)c).s.getWorld().getChunkManager().shouldTickChunk(new ChunkPos(pos))?Value.TRUE : Value.FALSE;
|
||||
return (c_, t_) -> retval;
|
||||
});
|
||||
|
||||
this.expr.addLazyFunction("loaded_status", -1, (c, t, lv) ->
|
||||
{
|
||||
BlockPos pos = BlockValue.fromParams((CarpetContext)c, lv, 0).block.getPos();
|
||||
BlockPos pos = CarpetArgParser.locateBlock((CarpetContext)c, lv, 0).block.getPos();
|
||||
WorldChunk chunk = ((CarpetContext)c).s.getWorld().getChunkManager().getWorldChunk(pos.getX()>>4, pos.getZ()>>4, false);
|
||||
if (chunk == null)
|
||||
return LazyValue.ZERO;
|
||||
@@ -682,7 +682,7 @@ public class CarpetExpression
|
||||
|
||||
this.expr.addLazyFunction("is_chunk_generated", -1, (c, t, lv) ->
|
||||
{
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams((CarpetContext)c, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock((CarpetContext)c, lv, 0);
|
||||
BlockPos pos = locator.block.getPos();
|
||||
boolean force = false;
|
||||
if (lv.size() > locator.offset)
|
||||
@@ -693,11 +693,11 @@ public class CarpetExpression
|
||||
|
||||
this.expr.addLazyFunction("generation_status", -1, (c, t, lv) ->
|
||||
{
|
||||
BlockValue.LocatorResult locatorResult = BlockValue.fromParams((CarpetContext)c, lv, 0);
|
||||
BlockPos pos = locatorResult.block.getPos();
|
||||
CarpetArgParser.BlockArgument blockArgument = CarpetArgParser.locateBlock((CarpetContext)c, lv, 0);
|
||||
BlockPos pos = blockArgument.block.getPos();
|
||||
boolean forceLoad = false;
|
||||
if (lv.size() > locatorResult.offset)
|
||||
forceLoad = lv.get(locatorResult.offset).evalValue(c, Context.BOOLEAN).getBoolean();
|
||||
if (lv.size() > blockArgument.offset)
|
||||
forceLoad = lv.get(blockArgument.offset).evalValue(c, Context.BOOLEAN).getBoolean();
|
||||
Chunk chunk = ((CarpetContext)c).s.getWorld().getChunk(pos.getX()>>4, pos.getZ()>>4, ChunkStatus.EMPTY, forceLoad);
|
||||
if (chunk == null)
|
||||
return LazyValue.NULL;
|
||||
@@ -731,8 +731,8 @@ public class CarpetExpression
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockValue.LocatorResult locatorResult = BlockValue.fromParams((CarpetContext) c, lv, 0);
|
||||
BlockPos pos = locatorResult.block.getPos();
|
||||
CarpetArgParser.BlockArgument blockArgument = CarpetArgParser.locateBlock((CarpetContext) c, lv, 0);
|
||||
BlockPos pos = blockArgument.block.getPos();
|
||||
SortedArraySet<ChunkTicket<?>> tickets = levelTickets.get(new ChunkPos(pos).toLong());
|
||||
if (tickets != null)
|
||||
{
|
||||
@@ -804,8 +804,8 @@ public class CarpetExpression
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
if (lv.size() < 2 || lv.size() % 2 == 1)
|
||||
throw new InternalExpressionException("'set' should have at least 2 params and odd attributes");
|
||||
BlockValue.LocatorResult targetLocator = BlockValue.fromParams(cc, lv, 0);
|
||||
BlockValue.LocatorResult sourceLocator = BlockValue.fromParams(cc, lv, targetLocator.offset, true);
|
||||
CarpetArgParser.BlockArgument targetLocator = CarpetArgParser.locateBlock(cc, lv, 0);
|
||||
CarpetArgParser.BlockArgument sourceLocator = CarpetArgParser.locateBlock(cc, lv, targetLocator.offset, true);
|
||||
BlockState sourceBlockState = sourceLocator.block.getBlockState();
|
||||
BlockState targetBlockState = world.getBlockState(targetLocator.block.getPos());
|
||||
if (sourceLocator.offset < lv.size())
|
||||
@@ -854,7 +854,7 @@ public class CarpetExpression
|
||||
{
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock(cc, lv, 0);
|
||||
BlockState state = locator.block.getBlockState();
|
||||
if (state.isAir())
|
||||
return (c_, t_) -> Value.FALSE;
|
||||
@@ -964,7 +964,7 @@ public class CarpetExpression
|
||||
if (!(e instanceof ServerPlayerEntity))
|
||||
return (c_, t_) -> Value.FALSE;
|
||||
ServerPlayerEntity player = (ServerPlayerEntity)e;
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 1);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock(cc, lv, 1);
|
||||
BlockPos where = locator.block.getPos();
|
||||
BlockState state = locator.block.getBlockState();
|
||||
Block block = state.getBlock();
|
||||
@@ -982,7 +982,7 @@ public class CarpetExpression
|
||||
throw new InternalExpressionException("'place_item' takes at least 2 parameters: item and block, or position, to place onto");
|
||||
CarpetContext cc = (CarpetContext) c;
|
||||
String itemString = lv.get(0).evalValue(c).getString();
|
||||
BlockValue.VectorLocator locator = BlockValue.locateVec(cc, lv, 1);
|
||||
CarpetArgParser.Vector3Argument locator = CarpetArgParser.locateVector(cc, lv, 1);
|
||||
ItemStackArgument stackArg = NBTSerializableValue.parseItem(itemString);
|
||||
BlockPos where = new BlockPos(locator.vec);
|
||||
String facing = "up";
|
||||
@@ -1038,7 +1038,7 @@ public class CarpetExpression
|
||||
|
||||
this.expr.addLazyFunction("property", -1, (c, t, lv) ->
|
||||
{
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams((CarpetContext) c, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock((CarpetContext) c, lv, 0);
|
||||
BlockState state = locator.block.getBlockState();
|
||||
if (lv.size() <= locator.offset)
|
||||
throw new InternalExpressionException("'property' requires to specify a property to query");
|
||||
@@ -1053,7 +1053,7 @@ public class CarpetExpression
|
||||
|
||||
this.expr.addLazyFunction("block_properties", -1, (c, t, lv) ->
|
||||
{
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams((CarpetContext) c, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock((CarpetContext) c, lv, 0);
|
||||
BlockState state = locator.block.getBlockState();
|
||||
StateManager<Block, BlockState> states = state.getBlock().getStateManager();
|
||||
Value res = ListValue.wrap(states.getProperties().stream().map(
|
||||
@@ -1064,7 +1064,7 @@ public class CarpetExpression
|
||||
|
||||
this.expr.addLazyFunction("biome", -1, (c, t, lv) -> {
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock(cc, lv, 0);
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
BlockPos pos = locator.block.getPos();
|
||||
Biome biome = world.getBiome(pos);
|
||||
@@ -1075,7 +1075,7 @@ public class CarpetExpression
|
||||
this.expr.addLazyFunction("set_biome", -1, (c, t, lv) ->
|
||||
{
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock(cc, lv, 0);
|
||||
if (lv.size() == locator.offset)
|
||||
throw new InternalExpressionException("'set_biome' needs a biome name as an argument");
|
||||
String biomeName = lv.get(locator.offset+0).evalValue(c).getString();
|
||||
@@ -1092,7 +1092,7 @@ public class CarpetExpression
|
||||
|
||||
this.expr.addLazyFunction("structure_references", -1, (c, t, lv) -> {
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock(cc, lv, 0);
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
BlockPos pos = locator.block.getPos();
|
||||
Map<String, LongSet> references = world.getChunk(pos).getStructureReferences();
|
||||
@@ -1117,7 +1117,7 @@ public class CarpetExpression
|
||||
|
||||
this.expr.addLazyFunction("structures", -1, (c, t, lv) -> {
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock(cc, lv, 0);
|
||||
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
BlockPos pos = locator.block.getPos();
|
||||
@@ -1159,7 +1159,7 @@ public class CarpetExpression
|
||||
this.expr.addLazyFunction("set_structure", -1, (c, t, lv) ->
|
||||
{
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock(cc, lv, 0);
|
||||
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
BlockPos pos = locator.block.getPos();
|
||||
@@ -1223,27 +1223,27 @@ public class CarpetExpression
|
||||
{
|
||||
List<Value> listVal = ((ListValue) first).getItems();
|
||||
int offset = 0;
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParamValues(cc, listVal, 0, false, false);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.fromParamValues(cc, listVal, 0, false, false);
|
||||
requestedChunks.add(new ChunkPos(locator.block.getPos()));
|
||||
while (listVal.size() > locator.offset)
|
||||
{
|
||||
locator = BlockValue.fromParamValues(cc, listVal, locator.offset, false, false);
|
||||
locator = CarpetArgParser.fromParamValues(cc, listVal, locator.offset, false, false);
|
||||
requestedChunks.add(new ChunkPos(locator.block.getPos()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParamValues(cc, Collections.singletonList(first), 0, false, false);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.fromParamValues(cc, Collections.singletonList(first), 0, false, false);
|
||||
requestedChunks.add(new ChunkPos(locator.block.getPos()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock(cc, lv, 0);
|
||||
ChunkPos from = new ChunkPos(locator.block.getPos());
|
||||
if (lv.size() > locator.offset)
|
||||
{
|
||||
locator = BlockValue.fromParams(cc, lv, locator.offset);
|
||||
locator = CarpetArgParser.locateBlock(cc, lv, locator.offset);
|
||||
ChunkPos to = new ChunkPos(locator.block.getPos());
|
||||
int xmax = Math.max(from.x, to.x);
|
||||
int zmax = Math.max(from.z, to.z);
|
||||
@@ -1285,7 +1285,7 @@ public class CarpetExpression
|
||||
this.expr.addLazyFunction("inhabited_time", -1, (c, t, lv) ->
|
||||
{
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock(cc, lv, 0);
|
||||
BlockPos pos = locator.block.getPos();
|
||||
Value ret = new NumericValue(cc.s.getWorld().getChunk(pos).getInhabitedTime());
|
||||
return (_c, _t) -> ret;
|
||||
@@ -1765,7 +1765,7 @@ public class CarpetExpression
|
||||
return LazyValue.NULL;
|
||||
}
|
||||
|
||||
BlockValue.VectorLocator position = BlockValue.locateVec(cc, lv, 1);
|
||||
CarpetArgParser.Vector3Argument position = CarpetArgParser.locateVector(cc, lv, 1);
|
||||
if (position.fromBlock)
|
||||
position.vec = position.vec.subtract(0, 0.5, 0);
|
||||
CompoundTag tag = new CompoundTag();
|
||||
@@ -2087,7 +2087,7 @@ public class CarpetExpression
|
||||
this.expr.addLazyFunction("neighbours", -1, (c, t, lv)->
|
||||
{
|
||||
|
||||
BlockPos center = BlockValue.fromParams((CarpetContext) c, lv,0).block.getPos();
|
||||
BlockPos center = CarpetArgParser.locateBlock((CarpetContext) c, lv,0).block.getPos();
|
||||
ServerWorld world = ((CarpetContext) c).s.getWorld();
|
||||
|
||||
List<Value> neighbours = new ArrayList<>();
|
||||
@@ -2381,12 +2381,30 @@ public class CarpetExpression
|
||||
|
||||
private static Map<String,SoundCategory> mixerMap = Arrays.stream(SoundCategory.values()).collect(Collectors.toMap(SoundCategory::getName, k -> k));
|
||||
|
||||
private void API_Interapperability()
|
||||
{
|
||||
//todo doc and test all
|
||||
this.expr.addLazyFunction("loaded_apps", 0, (c, t, lv) ->
|
||||
{
|
||||
// return a set of all loaded apps
|
||||
Value ret = new MapValue(((CarpetScriptHost) c.host).getScriptServer().modules.keySet().stream().map(StringValue::new).collect(Collectors.toSet()));
|
||||
return (cc, tt) -> ret;
|
||||
});
|
||||
|
||||
this.expr.addLazyFunction("is_app_loaded", 1, (c, t, lv) ->
|
||||
{
|
||||
Value ret = new NumericValue(((CarpetScriptHost) c.host).getScriptServer().modules.containsKey(lv.get(0).evalValue(c).getString()));
|
||||
return (cc, tt) -> ret;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void API_AuxiliaryAspects()
|
||||
{
|
||||
this.expr.addLazyFunction("sound", -1, (c, t, lv) -> {
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
Identifier soundName = new Identifier(lv.get(0).evalValue(c).getString());
|
||||
BlockValue.VectorLocator locator = BlockValue.locateVec(cc, lv, 1);
|
||||
CarpetArgParser.Vector3Argument locator = CarpetArgParser.locateVector(cc, lv, 1);
|
||||
if (Registry.SOUND_EVENT.get(soundName) == null)
|
||||
throw new InternalExpressionException("No such sound: "+soundName.getPath());
|
||||
float volume = 1.0F;
|
||||
@@ -2423,7 +2441,7 @@ public class CarpetExpression
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
MinecraftServer ms = cc.s.getMinecraftServer();
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
BlockValue.VectorLocator locator = BlockValue.locateVec(cc, lv, 1);
|
||||
CarpetArgParser.Vector3Argument locator = CarpetArgParser.locateVector(cc, lv, 1);
|
||||
String particleName = lv.get(0).evalValue(c).getString();
|
||||
int count = 10;
|
||||
double speed = 0;
|
||||
@@ -2471,8 +2489,8 @@ public class CarpetExpression
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
String particleName = lv.get(0).evalValue(c).getString();
|
||||
ParticleEffect particle = getParticleData(particleName);
|
||||
BlockValue.VectorLocator pos1 = BlockValue.locateVec(cc, lv, 1);
|
||||
BlockValue.VectorLocator pos2 = BlockValue.locateVec(cc, lv, pos1.offset);
|
||||
CarpetArgParser.Vector3Argument pos1 = CarpetArgParser.locateVector(cc, lv, 1);
|
||||
CarpetArgParser.Vector3Argument pos2 = CarpetArgParser.locateVector(cc, lv, pos1.offset);
|
||||
int offset = pos2.offset;
|
||||
double density = (lv.size() > offset)? NumericValue.asNumber(lv.get(offset).evalValue(c)).getDouble():1.0;
|
||||
if (density <= 0)
|
||||
@@ -2489,8 +2507,8 @@ public class CarpetExpression
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
String particleName = lv.get(0).evalValue(c).getString();
|
||||
ParticleEffect particle = getParticleData(particleName);
|
||||
BlockValue.VectorLocator pos1 = BlockValue.locateVec(cc, lv, 1);
|
||||
BlockValue.VectorLocator pos2 = BlockValue.locateVec(cc, lv, pos1.offset);
|
||||
CarpetArgParser.Vector3Argument pos1 = CarpetArgParser.locateVector(cc, lv, 1);
|
||||
CarpetArgParser.Vector3Argument pos2 = CarpetArgParser.locateVector(cc, lv, pos1.offset);
|
||||
int offset = pos2.offset;
|
||||
double density = 1.0;
|
||||
if (lv.size() > offset)
|
||||
@@ -2531,17 +2549,17 @@ public class CarpetExpression
|
||||
this.expr.addLazyFunction("create_marker", -1, (c, t, lv) ->{
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
BlockState targetBlock = null;
|
||||
BlockValue.VectorLocator pointLocator;
|
||||
CarpetArgParser.Vector3Argument pointLocator;
|
||||
boolean interactable = true;
|
||||
String name;
|
||||
try
|
||||
{
|
||||
Value nameValue = lv.get(0).evalValue(c);
|
||||
name = nameValue instanceof NullValue ? "" : nameValue.getString();
|
||||
pointLocator = BlockValue.locateVec(cc, lv, 1, true);
|
||||
pointLocator = CarpetArgParser.locateVector(cc, lv, 1, true);
|
||||
if (lv.size()>pointLocator.offset)
|
||||
{
|
||||
BlockValue.LocatorResult blockLocator = BlockValue.fromParams(cc, lv, pointLocator.offset, true, true);
|
||||
CarpetArgParser.BlockArgument blockLocator = CarpetArgParser.locateBlock(cc, lv, pointLocator.offset, true, true);
|
||||
if (blockLocator.block != null) targetBlock = blockLocator.block.getBlockState();
|
||||
if (lv.size() > blockLocator.offset)
|
||||
{
|
||||
@@ -2790,7 +2808,7 @@ public class CarpetExpression
|
||||
});
|
||||
|
||||
this.expr.addLazyFunction("plop", 4, (c, t, lv) ->{
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams((CarpetContext)c, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock((CarpetContext)c, lv, 0);
|
||||
if (lv.size() <= locator.offset)
|
||||
throw new InternalExpressionException("'plop' needs extra argument indicating what to plop");
|
||||
String what = lv.get(locator.offset).evalValue(c).getString();
|
||||
@@ -2946,6 +2964,7 @@ public class CarpetExpression
|
||||
API_IteratingOverAreasOfBlocks();
|
||||
API_AuxiliaryAspects();
|
||||
API_Scoreboard();
|
||||
API_Interapperability();
|
||||
}
|
||||
|
||||
public boolean fillAndScanCommand(ScriptHost host, int x, int y, int z)
|
||||
|
||||
Reference in new issue
Block a user