Path: blob/master/test/externalTests/commandBlock.js
9427 views
const assert = require('assert')1const { Vec3 } = require('vec3')2const { once, onceWithCleanup } = require('../../lib/promise_utils')34module.exports = () => async (bot) => {5const command = `/say ${Math.floor(Math.random() * 1000)}`6const commandBlockPos = new Vec3(1, 5, 1)7const commandBlockPosText = commandBlockPos.toArray().join(' ')89// Put and activate the command block10const p = once(bot.world, `blockUpdate:(${commandBlockPos.x}, ${commandBlockPos.y}, ${commandBlockPos.z})`)11bot.test.sayEverywhere(`/setblock ${commandBlockPosText} minecraft:command_block`)12await p13bot.setCommandBlock(commandBlockPos, command, false)1415const [message] = await onceWithCleanup(bot, 'message', {16timeout: 5000,17checkCondition: (message) => message.json.with[0] === command18})19assert(message.json.translate === 'advMode.setCommand.success')20}212223