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/elytra.js
Views: 789
const assert = require('assert')12module.exports = () => async (bot) => {3// don't continue unless this version supports elytra4if (!bot.supportFeature('hasElytraFlying')) return5const supportsFireworkRockets = bot.supportFeature('fireworkNamePlural') || bot.supportFeature('fireworkNameSingular')67const Item = require('prismarine-item')(bot.registry)89await bot.test.setInventorySlot(6, new Item(bot.registry.itemsByName.elytra.id, 1))10if (supportsFireworkRockets) {11const fireworkItem = bot.registry.itemsArray.find(item => item.displayName === 'Firework Rocket')12assert.ok(fireworkItem !== undefined)13await bot.test.setInventorySlot(36, new Item(fireworkItem.id, 64))14}15await bot.test.teleport(bot.entity.position.offset(0, 100, 0))16await bot.test.becomeSurvival()17await bot.creative.stopFlying()1819await bot.look(bot.entity.yaw, 0)20await bot.waitForTicks(5)21await assert.doesNotReject(bot.elytraFly())22await bot.waitForTicks(20) // wait for server to accept23assert.ok(bot.entity.elytraFlying)2425if (!supportsFireworkRockets) return2627// use rocket28await bot.look(bot.entity.yaw, 30 * Math.PI / 180)29const activationTicks = 2030for (let i = 0; i < 20; i++) {31bot.activateItem()32assert.ok(bot.entity.elytraFlying)33await bot.waitForTicks(1)34}35await bot.waitForTicks(3)36let lateActivations = 037assert.ok(bot.fireworkRocketDuration > 0)38for (let i = bot.fireworkRocketDuration; i > 0; --i) {39await bot.waitForTicks(1)40assert.ok(bot.entity.elytraFlying)41if (bot.fireworkRocketDuration > i) {42i = bot.fireworkRocketDuration43++lateActivations44}45assert.ok(lateActivations <= activationTicks)46}47assert.ok(bot.fireworkRocketDuration === 0)48}495051