Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/test/externalTests/enchanting.js
Views: 789
const assert = require('assert')12module.exports = () => async (bot) => {3const Item = require('prismarine-item')(bot.registry)45const lapisId = bot.registry.itemsByName.lapis_lazuli ? bot.registry.itemsByName.lapis_lazuli.id : bot.registry.itemsByName.dye.id6const lapisData = bot.registry.itemsByName.lapis_lazuli ? 0 : 478const enchantSlot = 2910if (bot.registry.isNewerOrEqualTo('1.13')) {11bot.chat(`/xp set ${bot.username} 999 levels`)12} else {13bot.chat(`/xp 999L ${bot.username}`)14}15await bot.test.setInventorySlot(36, new Item(bot.registry.itemsByName.bookshelf.id, 15))16await bot.test.setInventorySlot(37, new Item(bot.registry.itemsByName.enchanting_table.id, 1))17await bot.test.setInventorySlot(38, new Item(bot.registry.itemsByName.diamond_sword.id, 1))18await bot.test.setInventorySlot(39, new Item(lapisId, enchantSlot + 1, lapisData))1920await bot.test.becomeSurvival()2122// Place enchanting table23await bot.test.placeBlock(37, bot.entity.position.offset(1, 0, 0))2425// Place bookshelfs26await bot.test.placeBlock(36, bot.entity.position.offset(3, 0, 2))27await bot.test.placeBlock(36, bot.entity.position.offset(3, 0, 1))28await bot.test.placeBlock(36, bot.entity.position.offset(3, 0, 0))29await bot.test.placeBlock(36, bot.entity.position.offset(3, 0, -1))30await bot.test.placeBlock(36, bot.entity.position.offset(3, 0, -2))31await bot.test.placeBlock(36, bot.entity.position.offset(2, 0, -2))32await bot.test.placeBlock(36, bot.entity.position.offset(1, 0, -2))33await bot.test.placeBlock(36, bot.entity.position.offset(0, 0, -2))34await bot.test.placeBlock(36, bot.entity.position.offset(-1, 0, -2))35await bot.test.placeBlock(36, bot.entity.position.offset(-1, 0, -1))36await bot.test.placeBlock(36, bot.entity.position.offset(-1, 0, 1))37await bot.test.placeBlock(36, bot.entity.position.offset(-1, 0, 2))38await bot.test.placeBlock(36, bot.entity.position.offset(0, 0, 2))39await bot.test.placeBlock(36, bot.entity.position.offset(1, 0, 2))40await bot.test.placeBlock(36, bot.entity.position.offset(2, 0, 2))4142const b = bot.findBlock({ matching: bot.registry.blocksByName.enchanting_table.id })43const enchantingTable = await bot.openEnchantmentTable(b)4445console.log('Opened enchanting table')4647const lapis = enchantingTable.findInventoryItem(lapisId)48await enchantingTable.putLapis(lapis)4950const sword = enchantingTable.findInventoryItem(bot.registry.itemsByName.diamond_sword.id)5152await enchantingTable.putTargetItem(sword)5354console.log('Table ready')55await enchantingTable.enchant(enchantSlot)56const result = await enchantingTable.takeTargetItem()5758assert.notStrictEqual(result.nbt, undefined)5960enchantingTable.close()61}626364