-
Notifications
You must be signed in to change notification settings - Fork 132
feat: brand new default skybox with fog, better daycycle and colors #425
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ import { Vec3 } from 'vec3' | |
| import { BotEvents } from 'mineflayer' | ||
| import { proxy } from 'valtio' | ||
| import TypedEmitter from 'typed-emitter' | ||
| import { Biome } from 'minecraft-data' | ||
| import { delayedIterator } from '../../playground/shared' | ||
| import { chunkPos } from './simpleUtils' | ||
|
|
||
|
|
@@ -28,6 +29,8 @@ export type WorldDataEmitterEvents = { | |
| updateLight: (data: { pos: Vec3 }) => void | ||
| onWorldSwitch: () => void | ||
| end: () => void | ||
| biomeUpdate: (data: { biome: Biome }) => void | ||
| biomeReset: () => void | ||
| } | ||
|
|
||
| export class WorldDataEmitterWorker extends (EventEmitter as new () => TypedEmitter<WorldDataEmitterEvents>) { | ||
|
|
@@ -360,8 +363,37 @@ export class WorldDataEmitter extends (EventEmitter as new () => TypedEmitter<Wo | |
| delete this.debugChunksInfo[`${pos.x},${pos.z}`] | ||
| } | ||
|
|
||
| lastBiomeId: number | null = null | ||
|
|
||
| udpateBiome (pos: Vec3) { | ||
| try { | ||
| const biomeId = this.world.getBiome(pos) | ||
| if (biomeId !== this.lastBiomeId) { | ||
| this.lastBiomeId = biomeId | ||
| const biomeData = loadedData.biomes[biomeId] | ||
| if (biomeData) { | ||
| this.emitter.emit('biomeUpdate', { | ||
| biome: biomeData | ||
| }) | ||
| } else { | ||
| // unknown biome | ||
| this.emitter.emit('biomeReset') | ||
| } | ||
| } | ||
| } catch (e) { | ||
| console.error('error updating biome', e) | ||
| } | ||
| } | ||
|
Comment on lines
+366
to
+386
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Undefined identifier ‘loadedData’; biome lookup will throw. Also fix method name typo.
-lastBiomeId: number | null = null
-
-udpateBiome (pos: Vec3) {
+lastBiomeId: number | null = null
+
+updateBiome (pos: Vec3) {
try {
- const biomeId = this.world.getBiome(pos)
+ const biomeId = this.world.getBiome(pos)
if (biomeId !== this.lastBiomeId) {
this.lastBiomeId = biomeId
- const biomeData = loadedData.biomes[biomeId]
+ const biomeData =
+ // mineflayer registry varies by version
+ (bot as any)?.registry?.biomes?.[biomeId] ??
+ (bot as any)?.registry?.biomesById?.[biomeId]
if (biomeData) {
this.emitter.emit('biomeUpdate', {
biome: biomeData
})
} else {
// unknown biome
this.emitter.emit('biomeReset')
}
}
} catch (e) {
console.error('error updating biome', e)
}
}
🤖 Prompt for AI Agents |
||
|
|
||
| lastPosCheck: Vec3 | null = null | ||
| async updatePosition (pos: Vec3, force = false) { | ||
| if (!this.allowPositionUpdate) return | ||
| const posFloored = pos.floored() | ||
| if (!force && this.lastPosCheck && this.lastPosCheck.equals(posFloored)) return | ||
| this.lastPosCheck = posFloored | ||
|
|
||
| this.udpateBiome(pos) | ||
|
|
||
| const [lastX, lastZ] = chunkPos(this.lastPos) | ||
| const [botX, botZ] = chunkPos(pos) | ||
| if (lastX !== botX || lastZ !== botZ || force) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.