Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lkwilson committed Aug 25, 2023
1 parent e74b76b commit e953fc6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
16 changes: 8 additions & 8 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,7 @@
- ["entityEquip" (entity)](#entityequip-entity)
- ["entitySleep" (entity)](#entitysleep-entity)
- ["entitySpawn" (entity)](#entityspawn-entity)
- ["entityUsedFireworkRocket" (fireworkEntity, attachedToTargetEntityId)](#entityusedfireworkrocket-fireworkentity-attachedtotargetentityid)
- ["entityElytraFlying" (entity)](#entityElytraFlying-entity)
- ["entityElytraLanded" (entity)](#entityElytraLanded-entity)
- ["entityElytraFlew" (entity)](#entityelytraflew-entity)
- ["itemDrop" (entity)](#itemdrop-entity)
- ["playerCollect" (collector, collected)](#playercollect-collector-collected)
- ["entityGone" (entity)](#entitygone-entity)
Expand All @@ -227,6 +225,7 @@
- ["blockBreakProgressEnd" (block, entity)](#blockbreakprogressend-block-entity)
- ["diggingCompleted" (block)](#diggingcompleted-block)
- ["diggingAborted" (block)](#diggingaborted-block)
- ["usedFirework"](#usedfirework)
- ["move"](#move)
- ["forcedMove"](#forcedmove)
- ["mount"](#mount)
Expand Down Expand Up @@ -1310,13 +1309,10 @@ Fires when an attribute of an entity changes.
#### "entityEquip" (entity)
#### "entitySleep" (entity)
#### "entitySpawn" (entity)
#### "entityUsedFireworkRocket" (fireworkEntity, attachedToTargetEntityId)
#### "entityElytraFlew" (entity)

* `fireworkEntity` - The firework entity
* `fireworkEntity` - The entity id of the player that used the firework
An entity started elytra flying.

#### "entityElytraFlying" (entity)
#### "entityElytraLanded" (entity)
#### "itemDrop" (entity)
#### "playerCollect" (collector, collected)

Expand Down Expand Up @@ -1433,6 +1429,10 @@ This occurs whether the process was completed or aborted.

* `block` - the block that still exists

#### "usedfirework"

Fires when the bot uses a firework while elytra flying

#### "move"

Fires when the bot moves. If you want the current position, use
Expand Down
8 changes: 8 additions & 0 deletions lib/plugins/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,9 @@ function inject (bot) {

bot.fireworkRocketDuration = 0
function setElytraFlyingState (entity, elytraFlying) {
let startedFlying = false
if (elytraFlying) {
startedFlying = !entity.elytraFlying
entity.elytraFlying = true
} else if (entity.elytraFlying) {
entity.elytraFlying = false
Expand All @@ -372,6 +374,10 @@ function inject (bot) {
bot.fireworkRocketDuration = 0
knownFireworks.splice(0, knownFireworks.length)
}

if (startedFlying) {
bot.emit('entityElytraFlew', entity)
}
}

const knownFireworks = []
Expand All @@ -394,6 +400,8 @@ function inject (bot) {
const baseDuration = 10 * flightDur
const randomDuration = Math.floor(Math.random() * 6) + Math.floor(Math.random() * 7)
bot.fireworkRocketDuration = baseDuration + randomDuration

bot.emit('usedFirework')
}

let fireworkEntityName
Expand Down
1 change: 0 additions & 1 deletion test/externalTests/elytra.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ module.exports = () => async (bot) => {

await bot.look(bot.entity.yaw, 0)
await bot.waitForTicks(5)
console.error('Flying')
await assert.doesNotReject(bot.elytraFly())
await bot.waitForTicks(20) // wait for server to accept
assert.ok(bot.entity.elytraFlying)
Expand Down

0 comments on commit e953fc6

Please sign in to comment.