@zardoy/flying-squid 0.0.124 → 0.0.126

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.
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The noise generator (minecraft-worldgen) only builds the 1.18+ overworld (384 blocks from y=-64) and throws for any other height range.
3
+ * Worlds of older versions have no generator then: their saved chunks load as they are and new chunks are empty.
4
+ */
5
+ export declare const generatorForWorldHeight: (name: string, minY: number, worldHeight: number) => string;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generatorForWorldHeight = void 0;
4
+ /**
5
+ * The noise generator (minecraft-worldgen) only builds the 1.18+ overworld (384 blocks from y=-64) and throws for any other height range.
6
+ * Worlds of older versions have no generator then: their saved chunks load as they are and new chunks are empty.
7
+ */
8
+ const generatorForWorldHeight = (name, minY, worldHeight) => {
9
+ return name === 'noise' && (minY !== -64 || worldHeight !== 384) ? 'empty' : name;
10
+ };
11
+ exports.generatorForWorldHeight = generatorForWorldHeight;
@@ -37,6 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.usedServerPathsV1 = exports.player = exports.server = void 0;
40
+ const generatorForWorldHeight_1 = require("../generatorForWorldHeight");
40
41
  const node_gzip_1 = require("node-gzip");
41
42
  const prismarine_nbt_1 = __importDefault(require("prismarine-nbt"));
42
43
  const util_1 = require("util");
@@ -105,6 +106,11 @@ const server = async function (serv, options) {
105
106
  generation.options ??= {};
106
107
  generation.options.worldHeight = serv.supportFeature('tallWorld') ? 384 : 256;
107
108
  generation.options.minY = serv.supportFeature('tallWorld') ? -64 : 0;
109
+ const requestedGenerator = generation.name;
110
+ generation.name = (0, generatorForWorldHeight_1.generatorForWorldHeight)(generation.name, generation.options.minY, generation.options.worldHeight);
111
+ if (generation.name !== requestedGenerator) {
112
+ console.warn(`The ${requestedGenerator} generator builds 1.18+ worlds only, using the ${generation.name} generator for ${version}: saved chunks load as they are, new ones are empty`);
113
+ }
108
114
  levelDatWriter(serv, options);
109
115
  const World = (0, prismarine_world_1.default)(version);
110
116
  const registry = (0, prismarine_registry_1.default)(version);
@@ -10,6 +10,8 @@ const DIMENSIONS = {
10
10
  const PRESET_SETTINGS = {
11
11
  default: 'minecraft:overworld', amplified: 'minecraft:amplified', large_biomes: 'minecraft:large_biomes', caves: 'minecraft:caves', floating_islands: 'minecraft:floating_islands'
12
12
  };
13
+ /** a light section of sky light 15 everywhere */
14
+ const FULL_SKY = new Uint8Array(2048).fill(0xff);
13
15
  /** Source version of the worldgen data / block names (all palette names are 26.3 names). */
14
16
  const SOURCE_VERSION = '26.3';
15
17
  /**
@@ -220,7 +222,20 @@ function generation(options = {}) {
220
222
  }
221
223
  }
222
224
  }
223
- // full-bright like the other generators: max sky + block light everywhere
225
+ // light computed by the generator (minecraft-worldgen >= the version with ChunkData.skyLight): sections of 2048 nibble bytes, from info.minY up
226
+ if (data.skyLight && data.blockLight && typeof chunk._loadSkyLightNibbles === 'function') {
227
+ const firstSection = info.minY >> 4;
228
+ const sections = Math.min(info.height, minY + worldHeight - info.minY) >> 4;
229
+ for (let s = Math.max(0, (minY - info.minY) >> 4); s < sections; s++) {
230
+ chunk._loadSkyLightNibbles(firstSection + s, data.skyLight.subarray(s * 2048, (s + 1) * 2048));
231
+ chunk._loadBlockLightNibbles(firstSection + s, data.blockLight.subarray(s * 2048, (s + 1) * 2048));
232
+ }
233
+ // the light section above the world (clients read it for the top faces): open sky
234
+ if (dimension === 'overworld')
235
+ chunk._loadSkyLightNibbles((minY + worldHeight) >> 4, FULL_SKY);
236
+ return chunk;
237
+ }
238
+ // an older generator without light: full-bright, max sky + block light everywhere
224
239
  for (let y = 0; y < worldHeight; y++) {
225
240
  pos.y = minY + y;
226
241
  for (let z = 0; z < 16; z++) {
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.124",
4
+ "version": "0.0.126",
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.0",
31
+ "minecraft-worldgen": "^0.1.2",
32
32
  "minecraft-data": "^3.95.0",
33
33
  "minecraft-protocol": "^1.60.1",
34
34
  "mkdirp": "^2.1.3",