注意:不要翻译这个页面的段落标题!
有很多页面通过段落标题链接到这个页面,翻译段落标题会导致链接混乱!
inventorySize():number
select([slot:number]):number
count([slot:number]):number
space([slot:number]):number
compareTo(otherSlot:number):boolean
transferTo(toSlot:number[, amount:number]):boolean
detect(side:number):boolean
side - 请参阅 sides API 以获取可能的面列表。
compareFluid(side:number):boolean
Compares fluid in the selected tank (requires a Tank upgrade) to fluid in the world or in an external tank on the specified side of the robot. drain(side:number[, count:number]):boolean
fill(side:number[, count:number]):boolean
name():string
swing(side:number):boolean[, string]
true
(可能需要时间,具体时间取决于与其交互的方块——例如黑曜石需要一些时间来挖掘)。如果执行失败则返回 false
同时返回失败的原因。use(side: number[, sneaky: boolean[, duration: number]]): boolean[, string]
true
,否则返回 false
。如果成功,第二个参数将会描述机器人与之交互的内容,并且将是 block_activated
、item_placed
、item_used
、item_interacted
、air
之一。
此函数用途非常广泛,因为机器人可以模拟大多数物品的单击右键。与玩家的唯一区别是机器人不能使用特别要求用户是实体的物品,因为机器人是一个方块。所以喝药水、吃食物或扔末影珍珠都会失败。
这个函数的次要返回值可以用来判断右键单击的结果是什么造成的。返回项目结果并不总是很明显,需要事先进行一些测试。另请注意,虽然机器人不受有害药水的影响,但它们可能会被爆炸摧毁,因此在使用此功能放置、投掷或激活任何形式的炸药时要小心。第二个返回值的可能值:block_activated
- 一个被激活的方块(例如拉杆、开关、门)item_interacted
- 用装备的工具与世界互动,例如在羊上使用剪刀。item_placed
- 某个东西被放置在世界中。这不仅仅是有可放置的方块引起的,但也可以通过方块或实体出现在世界中的物品(例如燧石或刷怪蛋)。item_used
- 装备物品被激活,如同喷溅药水一样。air
- 当前装备的物品(包括空手)需要对着一个目标物体才能使用。请注意如果你的机器人有天使方块升级,这个值将永远不会被返回,但是一些操作可能仍然无效果。place(side: number[, sneaky: boolean]): boolean[, string]
sneaky
设置为true
,那么机器人将会模拟潜行放置(Shift+点击)。如果成功放置,则返回 true
。
如果操作执行失败,则返回 false
。如果使用一个不被支持的值作为参数,则操作将会执行失败并说明失败的原因。getLightColor():number
setLightColor(value:number):number
tankCount():number
selectTank(tank:number)
tankLevel([tank:number]):number
selectTank()
).tankSpace([tank:number]):number
compareFluidTo(tank:number):boolean
transferFluidTo(tank:number[, count:number]):boolean
compare(side:number[, fuzzy:boolean=false]):boolean
Compares the block on the specified side of the robot with the item in the currently selected slot and returns whether they are the same or not. Blocks are considered identical if the type and metadata match; additional ItemStack information is not checked. Empty blocks are considered as air blocks, which cannot be compared to an empty inventory slot; the detect()
function can be used to determine if there is a block in front of the robot. For blocks that drop a different item, the compare()
method won't work (eg: Diamond block dropping diamond items); for these cases, use silk-touch to obtain a block for comparison. drop(side:number[, count:number]):boolean
true
if at least one item is dropped, false
otherwise. If the block in front of the robot is an inventory, the robot will try to place the item into the inventory. If the inventory doesn't accept the item, the item is not dropped into the world (the operation will fail and return false
). Robots themselves are considered blocks with an inventory, and items can be moved into them using the drop()
function. The drop()
function will not work on non-item inventories, such as fluid tanks (the use()
function works for these cases). suck(side:number[, count:number]):boolean
durability():number
move(direction:number):boolean
turn(clockwise:boolean):boolean
getStatusText():string
setStatusText(value:string):string
move(dx:number, dy:number, dz:number)
getOffset():number
getVelocity():number
getMaxVelocity():number
getAcceleration():number
setAcceleration(value:number):number