Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added switchWorld event #3454

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@
- ["physicsTick" ()](#physicstick-)
- ["chat:name" (matches)](#chatname-matches)
- ["particle"](#particle)
- ["switchWorld"](#switchWorld)
- [Functions](#functions)
- [bot.blockAt(point, extraInfos=true)](#botblockatpoint-extrainfostrue)
- [bot.waitForChunksToLoad()](#botwaitforchunkstoload)
Expand Down Expand Up @@ -1551,6 +1552,11 @@ Fires when the all of a chat pattern's regexs have matches

Fires when a particle is created


#### "switchWorld"

Only fires when the world is being switched (unlike `respawn` which also fires after death)

### Functions

#### bot.blockAt(point, extraInfos=true)
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export interface BotEvents {
bossBarUpdated: (bossBar: BossBar) => Promise<void> | void
resourcePack: (url: string, hash?: string, uuid?: string) => Promise<void> | void
particle: (particle: Particle) => Promise<void> | void
switchWorld: () => void
}

export interface CommandBlockOptions {
Expand Down
1 change: 1 addition & 0 deletions lib/plugins/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ function inject (bot, { version, storageBuilder, hideErrors }) {
dimension = packet.dimension
worldName = packet.worldName
}
if (!packet.copyMetadata) bot.emit('switchWorld')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field doesn't exist in older versions

Please add a test

switchWorld()
})

Expand Down
Loading