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/digEverything.js
Views: 789
const { Vec3 } = require('vec3')1const assert = require('assert')23// this test takes about 20min45const excludedBlocks = [6// broken7'bed',8'double_stone_slab',9'wooden_door',10'iron_door',11'redstone_ore',12'lit_redstone_ore',13'trapdoor',14'double_wooden_slab',15'jungle_stairs',16'flower_pot',17'carrots',18'potatoes',19'skull',20'unpowered_comparator',21'standing_banner',22'wall_banner',23'daylight_detector',24'stone_slab2',25'spruce_door',26'birch_door',27'jungle_door',28'acacia_door',29'dark_oak_door',3031// cannot be placed32'piston_extension',33'fire',34'standing_sign',35'reeds',36'powered_repeater',37'pumpkin_stem',38'melon_stem',39'brewing_stand',40'cauldron',41'lit_redstone_lamp',42'tripwire',4344// cause problems45'mob_spawner',46'obsidian'47]4849module.exports = (version) => {50const registry = require('prismarine-registry')(version)5152const funcs = {}53for (const id in registry.blocks) {54if (registry.blocks[id] !== undefined) {55const block = registry.blocks[id]56if (block.diggable && excludedBlocks.indexOf(block.name) === -1) {57funcs[block.name] = (blockId => async (bot) => {58await digSomething(blockId, bot)59})(block.id)60}61}62}6364return funcs65}6667async function digSomething (blockId, bot) {68const Item = require('prismarine-item')(bot.registry)6970await bot.test.setInventorySlot(36, new Item(blockId, 1, 0))71await bot.test.placeBlock(36, bot.entity.position.plus(new Vec3(1, 0, 0)))72// TODO: find a better way than this bot.test.wait(200)73await bot.test.wait(200)74await bot.test.clearInventory()75await bot.test.setInventorySlot(36, new Item(bot.registry.itemsByName.diamond_pickaxe.id, 1, 0))76await bot.test.becomeSurvival()77// we are bare handed78await bot.dig(bot.blockAt(bot.entity.position.plus(new Vec3(1, 0, 0))))79// make sure that block is gone80assert.strictEqual(bot.blockAt(bot.entity.position.plus(new Vec3(1, 0, 0))).type, 0)81}828384