Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function placeBlock (slot, position, cb) {
bot.setQuickBarSlot(slot - 36)
// always place the block on the top of the block below it, i guess.
const referenceBlock = bot.blockAt(position.plus(new Vec3(0, -1, 0)))
bot.placeBlock(referenceBlock, new Vec3(0, 1, 0), cb)
}
function placeBlock (slot, position, cb) {
bot.setQuickBarSlot(slot - 36)
// always place the block on the top of the block below it, i guess.
const referenceBlock = bot.blockAt(position.plus(new Vec3(0, -1, 0)))
bot.placeBlock(referenceBlock, new Vec3(0, 1, 0), cb)
}
(cb) => {
// TODO: find a better way than this setTimeout(cb,200);
bot.test.placeBlock(36, bot.entity.position.plus(new Vec3(1, 0, 0)), () => {
setTimeout(cb, 200)
})
},
bot.test.clearInventory,
it("generate a portal", () => {
assert.deepEqual(generatePortal(new Vec3(2,1,1),new Vec3(1,0,0),4,5),{
bottom:generateLine(new Vec3(3,1,1),new Vec3(1,0,0),2),
left:generateLine(new Vec3(2,2,1),new Vec3(0,1,0),3),
right:generateLine(new Vec3(5,2,1),new Vec3(0,1,0),3),
top:generateLine(new Vec3(3,5,1),new Vec3(1,0,0),2),
air:generateLine(new Vec3(3,2,1),new Vec3(0,1,0),3).concat(generateLine(new Vec3(4,2,1),new Vec3(0,1,0),3))
})
});
});
it("generate a portal", () => {
assert.deepEqual(generatePortal(new Vec3(2,1,1),new Vec3(1,0,0),4,5),{
bottom:generateLine(new Vec3(3,1,1),new Vec3(1,0,0),2),
left:generateLine(new Vec3(2,2,1),new Vec3(0,1,0),3),
right:generateLine(new Vec3(5,2,1),new Vec3(0,1,0),3),
top:generateLine(new Vec3(3,5,1),new Vec3(1,0,0),2),
air:generateLine(new Vec3(3,2,1),new Vec3(0,1,0),3).concat(generateLine(new Vec3(4,2,1),new Vec3(0,1,0),3))
})
});
});
it("generate a portal", () => {
assert.deepEqual(generatePortal(new Vec3(2,1,1),new Vec3(1,0,0),4,5),{
bottom:generateLine(new Vec3(3,1,1),new Vec3(1,0,0),2),
left:generateLine(new Vec3(2,2,1),new Vec3(0,1,0),3),
right:generateLine(new Vec3(5,2,1),new Vec3(0,1,0),3),
top:generateLine(new Vec3(3,5,1),new Vec3(1,0,0),2),
air:generateLine(new Vec3(3,2,1),new Vec3(0,1,0),3).concat(generateLine(new Vec3(4,2,1),new Vec3(0,1,0),3))
})
});
});
it("can use /setblock",async() => {
await once(bot, 'chunkColumnLoad');
bot.chat('/setblock 1 2 3 95 0');
let [,newBlock]=await once(bot,'blockUpdate:'+new Vec3(1,2,3),{array:true});
assert.equal(newBlock.type,95);
});
it("can use /xp",async() => {
parse (str) {
const pars = str.split(' ')
if (pars.length !== 6) { return false }
let [x, y, z, direction, width, height] = pars;
[x, y, z] = [x, y, z].map((val, i) => serv.posFromString(val, player.position[['x', 'y', 'z'][i]]))
const bottomLeft = new Vec3(x, y, z)
if (direction !== 'x' && direction !== 'z') { throw new UserError('Wrong Direction') }
direction = direction === 'x' ? new Vec3(1, 0, 0) : new Vec3(0, 0, 1)
return { bottomLeft, direction, width, height }
},
async action ({ bottomLeft, direction, width, height }) {
bot._client.on('spawn_position', (packet) => {
bot.spawnPoint = new Vec3(packet.location.x, packet.location.y, packet.location.z)
bot.emit('game')
})
}
parse (str) {
const pars = str.split(' ')
if (pars.length !== 6) { return false }
let [x, y, z, direction, width, height] = pars;
[x, y, z] = [x, y, z].map((val, i) => serv.posFromString(val, player.position[['x', 'y', 'z'][i]]))
const bottomLeft = new Vec3(x, y, z)
if (direction !== 'x' && direction !== 'z') { throw new UserError('Wrong Direction') }
direction = direction === 'x' ? new Vec3(1, 0, 0) : new Vec3(0, 0, 1)
return { bottomLeft, direction, width, height }
},
async action ({ bottomLeft, direction, width, height }) {