@zardoy/flying-squid 0.0.131 → 0.0.132

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.
@@ -222,6 +222,34 @@ function generation(options = {}) {
222
222
  }
223
223
  }
224
224
  }
225
+ // block entities of the generator: loot tables of chests / dispensers (minecraft-worldgen >= the version with ChunkData.blockEntities); the containers module rolls the loot when one is opened
226
+ if (data.blockEntities?.length) {
227
+ const flattened = registry.supportFeature?.('theFlattening') !== false;
228
+ chunk.blockEntities ??= {};
229
+ for (const be of data.blockEntities) {
230
+ if (!be.lootTable || be.y < minY || be.y >= minY + worldHeight)
231
+ continue;
232
+ const name = be.id.replace(/^minecraft:/, '');
233
+ pos.set(be.x, be.y, be.z);
234
+ // the block of this version at the position has to be the container (blocks newer than the version are replaced by stone / air)
235
+ if (registry.blocksByStateId[chunk.getBlockStateId(pos)]?.name !== name)
236
+ continue;
237
+ const legacyId = { chest: 'Chest', dispenser: 'Trap' }[name];
238
+ if (!flattened && !legacyId)
239
+ continue;
240
+ const wx = chunkX * 16 + be.x;
241
+ const wz = chunkZ * 16 + be.z;
242
+ const seed = BigInt.asUintN(64, be.lootSeed ?? 0n);
243
+ chunk.blockEntities[`${wx},${be.y},${wz}`] = {
244
+ id: { type: 'string', value: flattened ? be.id : legacyId },
245
+ x: { type: 'int', value: wx },
246
+ y: { type: 'int', value: be.y },
247
+ z: { type: 'int', value: wz },
248
+ LootTable: { type: 'string', value: be.lootTable },
249
+ LootTableSeed: { type: 'long', value: [Number(BigInt.asIntN(32, seed >> 32n)), Number(BigInt.asIntN(32, seed))] }
250
+ };
251
+ }
252
+ }
225
253
  // light computed by the generator (minecraft-worldgen >= the version with ChunkData.skyLight): sections of 2048 nibble bytes, from info.minY up
226
254
  if (data.skyLight && data.blockLight && typeof chunk._loadSkyLightNibbles === 'function') {
227
255
  const firstSection = info.minY >> 4;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zardoy/flying-squid",
3
3
  "description": "A minecraft server written in TS",
4
- "version": "0.0.131",
4
+ "version": "0.0.132",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "bin": "dist/app.js",
@@ -28,7 +28,7 @@
28
28
  "flatmap": "^0.0.3",
29
29
  "long": "^5.1.0",
30
30
  "mc-bridge": "^0.1.1",
31
- "minecraft-worldgen": "^0.1.2",
31
+ "minecraft-worldgen": "^0.1.3",
32
32
  "minecraft-data": "^3.95.0",
33
33
  "minecraft-protocol": "^1.60.1",
34
34
  "mkdirp": "^2.1.3",