@@ -7,6 +7,7 @@ import type { BlockId } from '../packages/core/src/types.ts'
77
88import { AuthoritativeWorld } from '../packages/core/src/server/authoritative-world.ts'
99import { BinaryWorldStorage } from '../packages/core/src/server/world-storage.ts'
10+ import { createTestStarterInventory } from './helpers/test-inventory.ts'
1011import { BLOCK_IDS , getDroppedItemIdForBlock } from '../packages/core/src/world/blocks.ts'
1112import { Chunk } from '../packages/core/src/world/chunk.ts'
1213import { CHUNK_SIZE , WORLD_SEA_LEVEL } from '../packages/core/src/world/constants.ts'
@@ -32,7 +33,7 @@ test('authoritative world keeps per-player state separate and persists it by pla
3233
3334 try {
3435 const worldRecord = await storage . createWorld ( 'Alpha' , 42 )
35- const world = new AuthoritativeWorld ( worldRecord , storage )
36+ const world = new AuthoritativeWorld ( worldRecord , storage , { createInventory : createTestStarterInventory } )
3637
3738 const joinedA = await world . joinPlayer ( PLAYER_A )
3839 expect ( joinedA . clientPlayer . name ) . toBe ( PLAYER_A )
@@ -77,7 +78,7 @@ test('authoritative world keeps per-player state separate and persists it by pla
7778
7879 const reloadedRecord = await storage . getWorld ( 'Alpha' )
7980 expect ( reloadedRecord ) . not . toBeNull ( )
80- const reloadedWorld = new AuthoritativeWorld ( reloadedRecord ! , storage )
81+ const reloadedWorld = new AuthoritativeWorld ( reloadedRecord ! , storage , { createInventory : createTestStarterInventory } )
8182
8283 const rejoinedA = await reloadedWorld . joinPlayer ( PLAYER_A )
8384 expect ( rejoinedA . clientPlayer . entityId ) . toBe ( joinedA . clientPlayer . entityId )
@@ -107,7 +108,7 @@ test('authoritative world spawns and persists dropped items until players pick t
107108
108109 try {
109110 const worldRecord = await storage . createWorld ( 'Drops' , 42 )
110- const world = new AuthoritativeWorld ( worldRecord , storage )
111+ const world = new AuthoritativeWorld ( worldRecord , storage , { createInventory : createTestStarterInventory } )
111112 const joined = await world . joinPlayer ( PLAYER_A )
112113
113114 const targetX = 1
@@ -136,7 +137,7 @@ test('authoritative world spawns and persists dropped items until players pick t
136137
137138 const reloadedRecord = await storage . getWorld ( 'Drops' )
138139 expect ( reloadedRecord ) . not . toBeNull ( )
139- const reloadedWorld = new AuthoritativeWorld ( reloadedRecord ! , storage )
140+ const reloadedWorld = new AuthoritativeWorld ( reloadedRecord ! , storage , { createInventory : createTestStarterInventory } )
140141 const rejoined = await reloadedWorld . joinPlayer ( PLAYER_A )
141142 expect ( rejoined . droppedItems ) . toHaveLength ( 1 )
142143 expect ( rejoined . droppedItems [ 0 ] ?. itemId ) . toBe ( droppedItemId ! )
@@ -151,7 +152,7 @@ test('authoritative world pregenerates and persists the startup chunk set', asyn
151152
152153 try {
153154 const worldRecord = await storage . createWorld ( 'Startup' , 42 )
154- const world = new AuthoritativeWorld ( worldRecord , storage )
155+ const world = new AuthoritativeWorld ( worldRecord , storage , { createInventory : createTestStarterInventory } )
155156 const expectedCoords = world . getStartupChunkCoords ( )
156157 const progress : Array < { completedChunks : number ; totalChunks : number } > = [ ]
157158
@@ -195,7 +196,7 @@ test('survival cannot break bedrock but creative can', async () => {
195196
196197 try {
197198 const worldRecord = await storage . createWorld ( 'Bedrock' , 42 )
198- const world = new AuthoritativeWorld ( worldRecord , storage )
199+ const world = new AuthoritativeWorld ( worldRecord , storage , { createInventory : createTestStarterInventory } )
199200 const joined = await world . joinPlayer ( PLAYER_A )
200201 const targetIndex = 1 + 1 * CHUNK_SIZE + 0 * CHUNK_SIZE * CHUNK_SIZE
201202
@@ -224,7 +225,7 @@ test('creative block mutations neither spawn drops nor consume held items', asyn
224225
225226 try {
226227 const worldRecord = await storage . createWorld ( 'CreativeItems' , 42 )
227- const world = new AuthoritativeWorld ( worldRecord , storage )
228+ const world = new AuthoritativeWorld ( worldRecord , storage , { createInventory : createTestStarterInventory } )
228229 const joined = await world . joinPlayer ( PLAYER_A )
229230 await world . setPlayerGamemode ( joined . clientPlayer . entityId , 1 )
230231
@@ -276,7 +277,7 @@ test('placing a solid block into water replaces the water cell', async () => {
276277
277278 try {
278279 const worldRecord = await storage . createWorld ( 'WaterReplace' , 42 )
279- const world = new AuthoritativeWorld ( worldRecord , storage )
280+ const world = new AuthoritativeWorld ( worldRecord , storage , { createInventory : createTestStarterInventory } )
280281 const joined = await world . joinPlayer ( PLAYER_A )
281282
282283 let targetX = 0
@@ -341,7 +342,7 @@ test('block mutations relight only the nearby loaded chunk neighborhood', async
341342
342343 try {
343344 const worldRecord = await storage . createWorld ( 'LocalRelight' , 42 )
344- const world = new AuthoritativeWorld ( worldRecord , storage )
345+ const world = new AuthoritativeWorld ( worldRecord , storage , { createInventory : createTestStarterInventory } )
345346 const joined = await world . joinPlayer ( PLAYER_A )
346347 const targetY = WORLD_SEA_LEVEL + 8
347348 const targetChunk = worldToChunkCoord ( 1 , targetY , 1 ) . chunk
0 commit comments