TrainCarts/Commands/Selectors [zh]

From BergerHealer Wiki
Revision as of 03:46, 5 January 2026 by Eletronprocoress (talk | contribs)
Jump to navigation Jump to search
Other languages:

介绍

Traincarts增加了可用于列车或列车乘客的目标选择器,类似于原版Minecraft中的@e选择器的功能。除了通常基于位置的目标选择器参数外,还可以使用其他列车属性来选择符合特定条件的列车。这些选择器可以与其他插件一起使用。若一个选择器针对多个玩家或列车,那么整个命令会针对每个玩家或列车重复执行。

存在两个选择器:@train@ptrain。两者都使用相同的选择器条件,这将在下文详述。

要快速预览游戏中可用的条件,请使用/train info --train @ptrain[等Traincarts命令,该命令会显示支持的条件。

快速命令示例

实例 描述
/say hello @ptrain[distance=..5] 向5格及以内的列车上的乘客发送“hello”。
/kick @ptrain[name=train23] 踢出名为“train23”的列车上的乘客。
/train destroy --train @train[destination=InterState5] 销毁目的地为“InterState5”的列车。
/train eject --train @train[dx=-2..2,dy=-3..3,dz=-2..2] 在以命令执行者为中心设置的长方体范围内弹出列车。
/train launch 0.5 --options 2 --train @train[tag=express] 将带有“express”标签的列车在2格后启动到0.5的速度。

条件

可以指定多个条件,条件之间为逻辑。所有基于数值的条件都支持Minecraft范围语法:a..b。例如,-5..5(-5到5),..6(6或更小)和12..(12或更大)。在条件前面加上!会反转条件,检测某条件是否“不”满足。

在下面的所有示例中,若要针对列车上的乘客,可以将@train替换为@ptrain


长方体

x/y/z条件指定了世界上要选择的列车的位置,其指定的是一个长方体区域。也可以指定dx/dy/dz来扩大长方体。如果仅指定 dx/dy/dz,则使用命令执行者的 x/y/z 坐标。可以使用world(世界)条件在特定世界上运行,或从无法推断世界的服务器控制台运行。

@train[x=10..12,y=23..56,z=-100..-80] 选择所有在(10,23,-100)->(12,56,80)内部的列车。
@train[x=10,y=23,z=-100,dx=2,dy=33,dz=20] 同上,但使用dx/dy/dz来“扩大”长方体。
@train[x=10,y=10,z=10,dx=-2..2,dy=-10..10,dz=-2..2] 复杂用法:以点(10,10,10)为中心,在x和z轴的正方向和负方向上各延伸2格,在y轴的正方向和负方向上各延伸10格。将长方体变为(8,0,8)->(12,20,12)。
@train[dx=-10..10,dy=-5..5,dz=-10..10] 在命令执行者(命令方块或玩家)周围选择的长方体。
@train[world=world_the_end,x=10,y=89,z=-20,dx=-10..10,dy=-10..10,dz=-10..10] 指定世界名称可用于定位其他世界的列车。

距离

distance(距离)条件根据与命令执行者之间的距离(球面距离)或指定的长方体来选择列车。

@train[distance=..10] 距离命令执行者10格及以内的所有列车。
@train[distance=1000..] 距离命令执行者1000格及以外的所有列车。
@train[x=100,y=50,z=-100,distance=..5] 距离坐标(100, 50, -100)5格及以内的所有列车。
@train[x=10,y=10,z=10,dx=50,dz=50,distance=..10] 距离长方体(10, 10, 10)->(60, 10, 60)10格及以内的所有列车。


排序和限制

sort(排序)和limit(限制)条件可根据距离从多个结果中选取一个结果,或随机选取有限的结果。Sort支持nearest(最近)、furthest(最远)和random(随机)条件。Limit必须为一个自然整数。

@train[distance=..100,sort=random,limit=1] 随机选择100格及以内的1辆列车。
@train[distance=..100,sort=nearest,limit=2] 至多选择100格及以内的最近的2辆列车。
@train[distance=1000..,sort=furthest,limit=10] 至多选择1000格及以外的最远的10辆列车。


列车名称

name(名称)条件按名称或名称模式选择列车。支持远程控制语法中的通配符。

@train[name=train12] 选择名为“train12”的列车。
@train[name=Intercity*Express] 选择名称以“Intercity”开头且以“Express”结尾的列车。
@train[name=*] 选择世界上所有的列车。


列车标签

tag(标签)条件可以多次指定,可选择列车标签并对其进行筛选。与name(名称)条件相同,支持通配符。该条件只检测特定标签是否存在,而不是表示是否只存在某一标签。

@train[tag=mytag] 选择具有“mytag”标签的列车。
@train[tag=*fast,tag=!express] 选择标签以“fast”结尾,但没有“express”标签的列车。


乘客数量

passengers(乘客)和playerpassengers(玩家乘客)条件选择满足一定数量的(玩家)乘客的列车。支持范围命令来检测“至少”有几位乘客,例如@train[passengers=5..]

脱轨

The derailed condition selects trains that have derailed. For example: @train[derailed=1] or @train[derailed=true]

Unloaded

The unloaded condition selects trains that are inside unloaded chunks and are therefore no longer simulated. Example: @train[unloaded=1] or @train[unloaded=true]. Trains that keep chunks loaded do not unload.

Speed

The speed condition (alias: velocity) selects trains that move at a certain speed. This is the actual movement speed, which is at most the speed limit set for the train. Example: @train[speed=0] for trains that are not moving.

Miscellaneous Properties

More might be added in the future, but the additional properties can be used to filter the selection

destination Destination set for the train
friction Friction modifier of the train (default: 1)
gravity Gravity modifier of the train (default: 1)
keepchunksloaded Whether the train keeps nearby chunks loaded
speedlimit Speed limit set for the train
ticket Same checks as for tags, but for ticket names instead