minecraft-renderer 0.1.79 → 0.1.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/README.md +66 -26
  2. package/dist/mesher.js +36 -36
  3. package/dist/mesher.js.map +4 -4
  4. package/dist/mesherWasm.js +217 -217
  5. package/dist/minecraft-renderer.js +66 -66
  6. package/dist/minecraft-renderer.js.meta.json +1 -1
  7. package/dist/threeWorker.js +450 -450
  8. package/package.json +5 -2
  9. package/src/bundler/bundlePrepare.ts +3 -8
  10. package/src/graphicsBackend/appViewer.ts +10 -7
  11. package/src/graphicsBackend/config.ts +1 -5
  12. package/src/graphicsBackend/playerState.ts +35 -34
  13. package/src/graphicsBackend/preloadWorkers.ts +43 -41
  14. package/src/graphicsBackend/rendererDefaultOptions.ts +68 -70
  15. package/src/graphicsBackend/rendererOptionsSync.ts +24 -50
  16. package/src/graphicsBackend/types.ts +2 -2
  17. package/src/index.ts +6 -27
  18. package/src/lib/DebugGui.ts +34 -31
  19. package/src/lib/animationController.ts +9 -9
  20. package/src/lib/bakeLegacyLight.ts +1 -6
  21. package/src/lib/bindAbortableListener.test.ts +32 -12
  22. package/src/lib/bindAbortableListener.ts +14 -6
  23. package/src/lib/blockEntityLightRegistry.ts +11 -20
  24. package/src/lib/blockEntityLighting.test.ts +1 -6
  25. package/src/lib/blockEntityLighting.ts +5 -5
  26. package/src/lib/buildSharedConfig.mjs +4 -4
  27. package/src/lib/buildWorkerMcDataIndexes.test.ts +4 -4
  28. package/src/lib/buildWorkerMcDataIndexes.ts +11 -19
  29. package/src/lib/cameraBobbing.ts +1 -1
  30. package/src/lib/canvas2DOverlay.example.ts +13 -33
  31. package/src/lib/canvas2DOverlay.quickstart.ts +24 -54
  32. package/src/lib/canvas2DOverlay.ts +28 -47
  33. package/src/lib/cleanupDecorator.ts +2 -2
  34. package/src/lib/createPlayerObject.test.ts +2 -7
  35. package/src/lib/createPlayerObject.ts +18 -25
  36. package/src/lib/frameTimingCollector.ts +2 -5
  37. package/src/lib/guiRenderer.ts +57 -42
  38. package/src/lib/items.ts +15 -9
  39. package/src/lib/mesherlogReader.ts +5 -6
  40. package/src/lib/simpleUtils.ts +5 -5
  41. package/src/lib/skyLight.ts +3 -3
  42. package/src/lib/smoothSwitcher.ts +11 -18
  43. package/src/lib/ui/newStats.ts +10 -12
  44. package/src/lib/utils/proxy.ts +7 -1
  45. package/src/lib/utils/skins.ts +4 -4
  46. package/src/lib/utils.ts +1 -1
  47. package/src/lib/workerMessageSanitize.ts +5 -12
  48. package/src/lib/workerProxy.ts +52 -42
  49. package/src/lib/workerSyncOps.test.ts +58 -41
  50. package/src/lib/worldrendererCommon.reconfigure.test.ts +24 -21
  51. package/src/lib/worldrendererCommon.removeColumn.test.ts +11 -13
  52. package/src/lib/worldrendererCommon.ts +349 -211
  53. package/src/mesher-legacy/mesher.ts +9 -4
  54. package/src/mesher-legacy/test/a.ts +1 -1
  55. package/src/mesher-legacy/test/mesherTester.ts +2 -2
  56. package/src/mesher-legacy/test/playground.ts +1 -1
  57. package/src/mesher-legacy/test/run/test-js.ts +1 -1
  58. package/src/mesher-legacy/test/snapshotUtils.ts +3 -8
  59. package/src/mesher-legacy/test/test-perf.ts +1 -1
  60. package/src/mesher-legacy/test/tests.test.ts +2 -2
  61. package/src/mesher-shared/blockEntityMetadata.test.ts +7 -5
  62. package/src/mesher-shared/blockEntityMetadata.ts +28 -19
  63. package/src/mesher-shared/blockPropertiesForMeshing.ts +2 -2
  64. package/src/mesher-shared/computeHeightmap.ts +2 -4
  65. package/src/mesher-shared/exportedGeometryTypes.ts +3 -3
  66. package/src/mesher-shared/faceOcclusion.ts +324 -0
  67. package/src/mesher-shared/models.ts +80 -131
  68. package/src/mesher-shared/modelsGeometryCommon.ts +30 -15
  69. package/src/mesher-shared/shared.ts +46 -46
  70. package/src/mesher-shared/standaloneRenderer.ts +40 -44
  71. package/src/mesher-shared/tests/faceOcclusion.test.ts +179 -0
  72. package/src/mesher-shared/tests/liquidQuadInvariant.test.ts +12 -8
  73. package/src/mesher-shared/vertexShading.ts +2 -11
  74. package/src/mesher-shared/world.ts +19 -19
  75. package/src/mesher-shared/worldLighting.test.ts +2 -2
  76. package/src/performanceMonitor/PerformanceMonitor.ts +4 -13
  77. package/src/performanceMonitor/formatPerformanceFactorsDebug.ts +2 -2
  78. package/src/performanceMonitor/index.ts +1 -5
  79. package/src/performanceMonitor/types.ts +1 -1
  80. package/src/playerState/playerState.ts +55 -50
  81. package/src/playerState/types.ts +2 -8
  82. package/src/playground/allEntitiesDebug.ts +19 -16
  83. package/src/playground/baseScene.ts +29 -32
  84. package/src/playground/mobileControls.tsx +133 -129
  85. package/src/playground/playground.html +76 -73
  86. package/src/playground/playground.ts +14 -1
  87. package/src/playground/playgroundUi.tsx +100 -74
  88. package/src/playground/reactUtils.ts +3 -7
  89. package/src/playground/scenes/entities.ts +10 -7
  90. package/src/playground/scenes/frequentUpdates.ts +5 -5
  91. package/src/playground/scenes/geometryExport.ts +6 -20
  92. package/src/playground/scenes/highPosEntityUpdates.ts +2 -10
  93. package/src/playground/scenes/index.ts +1 -1
  94. package/src/playground/scenes/lightingStarfield.ts +18 -12
  95. package/src/playground/scenes/main.ts +15 -11
  96. package/src/playground/scenes/partialBlockCulling.ts +31 -0
  97. package/src/playground/scenes/railsCobweb.ts +1 -1
  98. package/src/playground/scenes/rotationIssue.ts +1 -1
  99. package/src/playground/scenes/slabsOptimization.ts +1 -2
  100. package/src/playground/scenes/transparencyIssue.ts +1 -1
  101. package/src/playground/shared.ts +2 -2
  102. package/src/resourcesManager/resourcesManager.ts +29 -54
  103. package/src/resourcesManager/resourcesManager.worker.test.ts +6 -10
  104. package/src/shims/minecraftData.ts +70 -24
  105. package/src/sign-renderer/index.html +10 -12
  106. package/src/sign-renderer/index.ts +29 -29
  107. package/src/sign-renderer/playground.ts +22 -15
  108. package/src/sign-renderer/tests.test.ts +16 -13
  109. package/src/sign-renderer/vite.config.ts +2 -2
  110. package/src/three/appShared.ts +46 -25
  111. package/src/three/bannerRenderer.ts +33 -61
  112. package/src/three/cameraCollisionBlockCache.ts +156 -0
  113. package/src/three/cameraCollisionSolidity.ts +50 -0
  114. package/src/three/cameraShake.ts +15 -6
  115. package/src/three/chunkMeshManager.ts +223 -390
  116. package/src/three/cinimaticScript.ts +26 -15
  117. package/src/three/cubeDrawSpans.ts +27 -37
  118. package/src/three/cubeMultiDraw.ts +9 -22
  119. package/src/three/documentRenderer.ts +15 -18
  120. package/src/three/entities.ts +175 -150
  121. package/src/three/entity/EntityMesh.ts +114 -108
  122. package/src/three/entity/animations.js +3 -3
  123. package/src/three/entity/armorModels.ts +15 -15
  124. package/src/three/entity/gltfAnimationUtils.ts +2 -5
  125. package/src/three/fireworks.ts +34 -32
  126. package/src/three/fireworksRenderer.ts +32 -29
  127. package/src/three/globalBlockBuffer.ts +167 -100
  128. package/src/three/globalLegacyBuffer.ts +248 -264
  129. package/src/three/graphicsBackendBase.ts +19 -25
  130. package/src/three/graphicsBackendOffThread.ts +12 -15
  131. package/src/three/hand.ts +21 -21
  132. package/src/three/handLegacy.ts +3 -13
  133. package/src/three/holdingBlock.ts +116 -79
  134. package/src/three/holdingBlockFactory.ts +1 -4
  135. package/src/three/holdingBlockItemIdentity.test.ts +25 -17
  136. package/src/three/holdingBlockItemIdentity.ts +9 -6
  137. package/src/three/holdingBlockLegacy.ts +113 -132
  138. package/src/three/itemMesh.ts +20 -29
  139. package/src/three/legacyMultiDraw.ts +10 -16
  140. package/src/three/legacySectionCull.ts +8 -14
  141. package/src/three/menuBackground/activeView.ts +1 -4
  142. package/src/three/menuBackground/assetUrl.ts +1 -1
  143. package/src/three/menuBackground/classic.ts +4 -12
  144. package/src/three/menuBackground/gpuPreference.ts +1 -3
  145. package/src/three/menuBackground/index.ts +2 -11
  146. package/src/three/menuBackground/renderer.ts +1 -5
  147. package/src/three/menuBackground/types.ts +1 -4
  148. package/src/three/menuBackground/v2.ts +196 -96
  149. package/src/three/menuBackground/v2Meta.ts +3 -3
  150. package/src/three/menuBackground/worldBlocks.ts +37 -35
  151. package/src/three/modules/blockBreakParticles.ts +59 -28
  152. package/src/three/modules/cameraBobbing.ts +3 -6
  153. package/src/three/modules/index.ts +1 -1
  154. package/src/three/modules/rain.ts +10 -23
  155. package/src/three/modules/sciFiWorldReveal.ts +11 -25
  156. package/src/three/modules/starfield.ts +7 -13
  157. package/src/three/renderSlot.ts +28 -16
  158. package/src/three/rendererModuleSystem.ts +1 -3
  159. package/src/three/sceneOrigin.ts +96 -33
  160. package/src/three/sectionRaycastAabb.ts +24 -110
  161. package/src/three/shaderCubeMesh.ts +6 -17
  162. package/src/three/shaders/cubeBlockShader.ts +85 -96
  163. package/src/three/shaders/legacyBlockShader.ts +21 -43
  164. package/src/three/shaders/textureIndexMapping.ts +89 -95
  165. package/src/three/shaders/tintPalette.ts +156 -170
  166. package/src/three/signTextureCache.ts +9 -12
  167. package/src/three/skyboxRenderer.ts +62 -70
  168. package/src/three/tests/chunkMeshManagerLegacy.test.ts +34 -64
  169. package/src/three/tests/cubeDrawSpans.test.ts +55 -25
  170. package/src/three/tests/globalBlockBuffer.test.ts +217 -0
  171. package/src/three/tests/globalLegacyBuffer.test.ts +300 -41
  172. package/src/three/tests/legacyMultiDraw.test.ts +8 -29
  173. package/src/three/tests/pr3PerFrameCpuCuts.test.ts +106 -29
  174. package/src/three/tests/signTextureCache.test.ts +4 -4
  175. package/src/three/thirdPersonVoxelRaycast.ts +120 -0
  176. package/src/three/threeJsMedia.ts +55 -72
  177. package/src/three/threeJsParticles.ts +32 -41
  178. package/src/three/threeJsSound.ts +3 -3
  179. package/src/three/threeJsUtils.ts +3 -3
  180. package/src/three/threeWorker.ts +2 -2
  181. package/src/three/waypointSprite.ts +55 -82
  182. package/src/three/waypoints.ts +20 -23
  183. package/src/three/world/cursorBlock.ts +25 -12
  184. package/src/three/world/vr.ts +11 -17
  185. package/src/three/worldGeometryExport.ts +15 -34
  186. package/src/three/worldRendererThree.ts +144 -166
  187. package/src/wasm-mesher/bridge/convertChunk.ts +3 -9
  188. package/src/wasm-mesher/bridge/render-from-wasm.ts +204 -229
  189. package/src/wasm-mesher/bridge/shaderCubeBridge.ts +26 -67
  190. package/src/wasm-mesher/tests/cameraCollisionBlockCache.test.ts +82 -0
  191. package/src/wasm-mesher/tests/cullingRegression.test.ts +307 -0
  192. package/src/wasm-mesher/tests/heightmapParity.test.ts +8 -18
  193. package/src/wasm-mesher/tests/mesherWasmConversionCache.test.ts +2 -2
  194. package/src/wasm-mesher/tests/sectionRaycastAabb.test.ts +1 -93
  195. package/src/wasm-mesher/tests/shaderCubeInstances.test.ts +103 -141
  196. package/src/wasm-mesher/tests/splitColumnWasmOutput.test.ts +14 -22
  197. package/src/wasm-mesher/tests/thirdPersonVoxelRaycast.test.ts +63 -0
  198. package/src/wasm-mesher/worker/mesherWasm.ts +150 -141
  199. package/src/wasm-mesher/worker/mesherWasmConversionCache.ts +2 -8
  200. package/src/wasm-mesher/worker/mesherWasmLightDirty.test.ts +1 -3
  201. package/src/wasm-mesher/worker/mesherWasmLightDirty.ts +1 -5
  202. package/src/wasm-mesher/worker/mesherWasmRequestTracker.ts +42 -42
  203. package/src/worldView/worldView.spiral.test.ts +1 -1
  204. package/src/worldView/worldView.ts +34 -39
  205. package/src/worldView/worldViewWorkerBridge.test.ts +4 -4
@@ -4,8 +4,6 @@ import { sectionYsForLightColumnDirty } from './mesherWasmLightDirty'
4
4
 
5
5
  describe('sectionYsForLightColumnDirty', () => {
6
6
  it('covers every section in a 256-high overworld column', () => {
7
- expect(sectionYsForLightColumnDirty(0, 256)).toEqual(
8
- Array.from({ length: 16 }, (_, i) => i * 16),
9
- )
7
+ expect(sectionYsForLightColumnDirty(0, 256)).toEqual(Array.from({ length: 16 }, (_, i) => i * 16))
10
8
  })
11
9
  })
@@ -2,11 +2,7 @@
2
2
  import { SECTION_HEIGHT } from '../../mesher-shared/shared'
3
3
 
4
4
  /** Section Y values to dirty for a column after `update_light` updates the light cache. */
5
- export function sectionYsForLightColumnDirty (
6
- worldMinY: number,
7
- worldMaxY: number,
8
- sectionHeight = SECTION_HEIGHT,
9
- ): number[] {
5
+ export function sectionYsForLightColumnDirty(worldMinY: number, worldMaxY: number, sectionHeight = SECTION_HEIGHT): number[] {
10
6
  const ys: number[] = []
11
7
  for (let y = worldMinY; y < worldMaxY; y += sectionHeight) {
12
8
  ys.push(y)
@@ -13,54 +13,54 @@
13
13
  // counter semantics of `dirtySections`.
14
14
 
15
15
  export class SectionRequestTracker {
16
- private readonly counts = new Map<string, number>()
16
+ private readonly counts = new Map<string, number>()
17
17
 
18
- /** Register one pending request for `key` (called per dirty-section ingest). */
19
- addRequest (key: string): void {
20
- this.counts.set(key, (this.counts.get(key) ?? 0) + 1)
21
- }
18
+ /** Register one pending request for `key` (called per dirty-section ingest). */
19
+ addRequest(key: string): void {
20
+ this.counts.set(key, (this.counts.get(key) ?? 0) + 1)
21
+ }
22
22
 
23
- /** True if at least one request for `key` is still pending. */
24
- hasPending (key: string): boolean {
25
- return (this.counts.get(key) ?? 0) > 0
26
- }
23
+ /** True if at least one request for `key` is still pending. */
24
+ hasPending(key: string): boolean {
25
+ return (this.counts.get(key) ?? 0) > 0
26
+ }
27
27
 
28
- /** Pending request count for `key` (0 if none). */
29
- pendingCount (key: string): number {
30
- return this.counts.get(key) ?? 0
31
- }
28
+ /** Pending request count for `key` (0 if none). */
29
+ pendingCount(key: string): number {
30
+ return this.counts.get(key) ?? 0
31
+ }
32
32
 
33
- /**
34
- * Consume one pending request for `key`. Returns true if a request was
35
- * consumed, false if there was nothing pending. Callers in the column
36
- * path must treat `false` as a contract violation (the main thread did
37
- * not request this key).
38
- */
39
- consumeOne (key: string): boolean {
40
- const c = this.counts.get(key) ?? 0
41
- if (c <= 0) return false
42
- if (c === 1) this.counts.delete(key)
43
- else this.counts.set(key, c - 1)
44
- return true
45
- }
33
+ /**
34
+ * Consume one pending request for `key`. Returns true if a request was
35
+ * consumed, false if there was nothing pending. Callers in the column
36
+ * path must treat `false` as a contract violation (the main thread did
37
+ * not request this key).
38
+ */
39
+ consumeOne(key: string): boolean {
40
+ const c = this.counts.get(key) ?? 0
41
+ if (c <= 0) return false
42
+ if (c === 1) this.counts.delete(key)
43
+ else this.counts.set(key, c - 1)
44
+ return true
45
+ }
46
46
 
47
- /** Clear all pending requests (used on worker reset). */
48
- clear (): void {
49
- this.counts.clear()
50
- }
47
+ /** Clear all pending requests (used on worker reset). */
48
+ clear(): void {
49
+ this.counts.clear()
50
+ }
51
51
 
52
- /** Drop all pending requests for one column (`cx`,`cz` = column origin in block coords). */
53
- clearColumn (cx: number, cz: number): void {
54
- for (const key of [...this.counts.keys()]) {
55
- const [x, , z] = key.split(',').map(Number)
56
- if (x === cx && z === cz) {
57
- this.counts.delete(key)
58
- }
59
- }
52
+ /** Drop all pending requests for one column (`cx`,`cz` = column origin in block coords). */
53
+ clearColumn(cx: number, cz: number): void {
54
+ for (const key of [...this.counts.keys()]) {
55
+ const [x, , z] = key.split(',').map(Number)
56
+ if (x === cx && z === cz) {
57
+ this.counts.delete(key)
58
+ }
60
59
  }
60
+ }
61
61
 
62
- /** Number of distinct keys with pending requests. */
63
- size (): number {
64
- return this.counts.size
65
- }
62
+ /** Number of distinct keys with pending requests. */
63
+ size(): number {
64
+ return this.counts.size
65
+ }
66
66
  }
@@ -7,7 +7,7 @@ describe('WorldView._loadChunks spiral guard', () => {
7
7
  it('does not let a superseded spiral reset inLoading or panic state', async () => {
8
8
  const world = {
9
9
  getColumnAt: () => null,
10
- setBlockStateId: vi.fn(),
10
+ setBlockStateId: vi.fn()
11
11
  }
12
12
  const view = new WorldView(world, 8, new Vec3(0, 64, 0))
13
13
  view.addWaitTime = 0
@@ -30,12 +30,7 @@ export const sectionPos = (pos: { x: number; y: number; z: number }): [number, n
30
30
  /**
31
31
  * Delayed iterator for chunk loading with configurable delay.
32
32
  */
33
- export const delayedIterator = async <T>(
34
- arr: T[],
35
- delay: number,
36
- exec: (item: T, index: number) => Promise<void>,
37
- chunkSize = 1
38
- ): Promise<void> => {
33
+ export const delayedIterator = async <T>(arr: T[], delay: number, exec: (item: T, index: number) => Promise<void>, chunkSize = 1): Promise<void> => {
39
34
  for (let i = 0; i < arr.length; i += chunkSize) {
40
35
  if (delay) {
41
36
  await new Promise(resolve => setTimeout(resolve, delay))
@@ -118,7 +113,7 @@ export interface WorldProvider {
118
113
  export class WorldView extends (EventEmitter as new () => TypedEmitter<WorldViewEvents>) {
119
114
  spiralNumber = 0
120
115
  gotPanicLastTime = false
121
- panicChunksReload = () => { }
116
+ panicChunksReload = () => {}
122
117
  loadedChunks: Record<ChunkPosKey, boolean> = {}
123
118
  inLoading = false
124
119
  chunkReceiveTimes: number[] = []
@@ -127,13 +122,16 @@ export class WorldView extends (EventEmitter as new () => TypedEmitter<WorldView
127
122
  panicTimeout?: ReturnType<typeof setTimeout>
128
123
  readonly lastPos: Vec3
129
124
  eventListeners: Record<string, any> = {}
130
- debugChunksInfo: Record<ChunkPosKey, {
131
- loads: Array<{
132
- dataLength: number
133
- reason: string
134
- time: number
135
- }>
136
- }> = {}
125
+ debugChunksInfo: Record<
126
+ ChunkPosKey,
127
+ {
128
+ loads: Array<{
129
+ dataLength: number
130
+ reason: string
131
+ time: number
132
+ }>
133
+ }
134
+ > = {}
137
135
 
138
136
  waitingSpiralChunksLoad: Record<ChunkPosKey, (value: boolean) => void> = {}
139
137
 
@@ -163,12 +161,12 @@ export class WorldView extends (EventEmitter as new () => TypedEmitter<WorldView
163
161
  class: WorldViewWorker.restorerName,
164
162
  type: 'event',
165
163
  eventName,
166
- args: sanitizeWorkerEventArgs(args),
164
+ args: sanitizeWorkerEventArgs(args)
167
165
  })
168
166
  }) as any
169
167
  }
170
168
  return {
171
- __restorer: WorldViewWorker.restorerName,
169
+ __restorer: WorldViewWorker.restorerName
172
170
  }
173
171
  }
174
172
 
@@ -211,9 +209,7 @@ export class WorldView extends (EventEmitter as new () => TypedEmitter<WorldView
211
209
  this.emitterGotConnected(bot)
212
210
 
213
211
  const [botX, botZ] = chunkPos(pos)
214
- const positions = generateSpiralMatrix(this.viewDistance).map(
215
- ([x, z]) => new Vec3((botX + x) * 16, 0, (botZ + z) * 16)
216
- )
212
+ const positions = generateSpiralMatrix(this.viewDistance).map(([x, z]) => new Vec3((botX + x) * 16, 0, (botZ + z) * 16))
217
213
 
218
214
  this.lastPos.update(pos)
219
215
  await this._loadChunks(positions, pos)
@@ -251,7 +247,7 @@ export class WorldView extends (EventEmitter as new () => TypedEmitter<WorldView
251
247
  let continueLoading = true
252
248
  this.inLoading = true
253
249
 
254
- await delayedIterator(positions, this.addWaitTime, async (pos) => {
250
+ await delayedIterator(positions, this.addWaitTime, async pos => {
255
251
  if (!continueLoading || this.loadedChunks[`${pos.x},${pos.z}`]) return
256
252
 
257
253
  // Wait for chunk to be available from server
@@ -277,25 +273,19 @@ export class WorldView extends (EventEmitter as new () => TypedEmitter<WorldView
277
273
  /**
278
274
  * Load a chunk at the given position.
279
275
  */
280
- async loadChunk(
281
- pos: { x: number; z: number; y?: number },
282
- isLightUpdate = false,
283
- reason = 'spiral'
284
- ): Promise<void> {
276
+ async loadChunk(pos: { x: number; z: number; y?: number }, isLightUpdate = false, reason = 'spiral'): Promise<void> {
285
277
  const [botX, botZ] = chunkPos(this.lastPos)
286
278
  const dx = Math.abs(botX - Math.floor(pos.x / 16))
287
279
  const dz = Math.abs(botZ - Math.floor(pos.z / 16))
288
280
 
289
281
  if (dx <= this.viewDistance && dz <= this.viewDistance) {
290
- const column = await this.world.getColumnAt(
291
- pos.y !== undefined ? (pos as Vec3) : new Vec3(pos.x, 0, pos.z)
292
- )
282
+ const column = await this.world.getColumnAt(pos.y !== undefined ? (pos as Vec3) : new Vec3(pos.x, 0, pos.z))
293
283
 
294
284
  if (column) {
295
285
  const chunk = column.toJson()
296
286
  const worldConfig: WorldSizeParams = {
297
287
  minY: column.minY ?? 0,
298
- worldHeight: column.worldHeight ?? 256,
288
+ worldHeight: column.worldHeight ?? 256
299
289
  }
300
290
 
301
291
  this.emit('loadChunk', {
@@ -312,7 +302,7 @@ export class WorldView extends (EventEmitter as new () => TypedEmitter<WorldView
312
302
  this.debugChunksInfo[`${pos.x},${pos.z}`].loads.push({
313
303
  dataLength: chunk.length,
314
304
  reason,
315
- time: Date.now(),
305
+ time: Date.now()
316
306
  })
317
307
  } else if (this.isPlayground) {
318
308
  this.emit('markAsLoaded', { x: pos.x, z: pos.z })
@@ -356,18 +346,23 @@ export class WorldView extends (EventEmitter as new () => TypedEmitter<WorldView
356
346
  */
357
347
  emitterGotConnected(bot?: any): void {
358
348
  // Skip if in offscreen/worker context
359
- const isOffscreen = typeof (globalThis as any).WorkerGlobalScope !== 'undefined' &&
360
- globalThis instanceof (globalThis as any).WorkerGlobalScope
349
+ const isOffscreen = typeof (globalThis as any).WorkerGlobalScope !== 'undefined' && globalThis instanceof (globalThis as any).WorkerGlobalScope
361
350
 
362
351
  if (isOffscreen || !bot) return
363
352
 
364
- this.emit('blockEntities', new Proxy({}, {
365
- get(_target, posKey, receiver) {
366
- if (typeof posKey !== 'string') return
367
- const [x, y, z] = posKey.split(',').map(Number)
368
- return bot.world.getBlock(new Vec3(x, y, z))?.entity
369
- },
370
- }))
353
+ this.emit(
354
+ 'blockEntities',
355
+ new Proxy(
356
+ {},
357
+ {
358
+ get(_target, posKey, receiver) {
359
+ if (typeof posKey !== 'string') return
360
+ const [x, y, z] = posKey.split(',').map(Number)
361
+ return bot.world.getBlock(new Vec3(x, y, z))?.entity
362
+ }
363
+ }
364
+ )
365
+ )
371
366
  }
372
367
 
373
368
  lastBiomeId: number | null = null
@@ -7,7 +7,7 @@ describe('WorldViewWorker.restoreTransferred bridge', () => {
7
7
  const addSpy = vi.fn()
8
8
  const worker = {
9
9
  addEventListener: addSpy,
10
- removeEventListener: vi.fn(),
10
+ removeEventListener: vi.fn()
11
11
  } as unknown as Worker
12
12
 
13
13
  WorldViewWorker.restoreTransferred({}, worker)
@@ -26,7 +26,7 @@ describe('WorldViewWorker.restoreTransferred bridge', () => {
26
26
  addEventListener: (_type: string, handler: (event: MessageEvent) => void) => {
27
27
  listeners.push(handler)
28
28
  },
29
- removeEventListener: () => {},
29
+ removeEventListener: () => {}
30
30
  } as unknown as Worker
31
31
 
32
32
  const first = WorldViewWorker.restoreTransferred({}, worker)
@@ -47,8 +47,8 @@ describe('WorldViewWorker.restoreTransferred bridge', () => {
47
47
  class: WorldViewWorker.restorerName,
48
48
  type: 'event',
49
49
  eventName: 'loadChunk',
50
- args: [{ x: 0, z: 0, chunk: {}, worldConfig: {}, isLightUpdate: false }],
51
- },
50
+ args: [{ x: 0, z: 0, chunk: {}, worldConfig: {}, isLightUpdate: false }]
51
+ }
52
52
  } as MessageEvent)
53
53
 
54
54
  expect(firstCalls).toBe(0)