@zardoy/flying-squid 0.0.125 → 0.0.127
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.
|
@@ -659,6 +659,26 @@ const player = function (player, serv, settings) {
|
|
|
659
659
|
});
|
|
660
660
|
}
|
|
661
661
|
};
|
|
662
|
+
/**
|
|
663
|
+
* Light arrays of the 1.18+ chunk packet in the vanilla byte order (nibbles, low nibble first). prismarine-chunk's dumpLight() writes every
|
|
664
|
+
* section with BitArray.writeBuffer (big-endian longs) while loadParsedLight() on the client reads vanilla bytes, so light reached the client
|
|
665
|
+
* scrambled inside every 16 cells along x (only 1/8 of the cells kept their value). The BitArray's Uint32Array already holds the vanilla layout
|
|
666
|
+
* on little-endian hosts: its bytes are copied as they are (also cheaper than the encoder).
|
|
667
|
+
*/
|
|
668
|
+
const LITTLE_ENDIAN = new Uint8Array(new Uint32Array([1]).buffer)[0] === 1;
|
|
669
|
+
const packetLightArrays = (chunk, dumped) => {
|
|
670
|
+
if (!LITTLE_ENDIAN || !chunk.skyLightSections || !chunk.blockLightSections)
|
|
671
|
+
return { skyLight: dumped.skyLight, blockLight: dumped.blockLight };
|
|
672
|
+
const bytes = (sections, mask) => {
|
|
673
|
+
const out = [];
|
|
674
|
+
sections.forEach((section, index) => {
|
|
675
|
+
if (section !== null && mask.get(index))
|
|
676
|
+
out.push(new Uint8Array(section.data.buffer, section.data.byteOffset, section.data.byteLength).slice());
|
|
677
|
+
});
|
|
678
|
+
return out;
|
|
679
|
+
};
|
|
680
|
+
return { skyLight: bytes(chunk.skyLightSections, chunk.skyLightMask), blockLight: bytes(chunk.blockLightSections, chunk.blockLightMask) };
|
|
681
|
+
};
|
|
662
682
|
player.sendChunk = async (chunkX, chunkZ, column) => {
|
|
663
683
|
await player.behavior('sendChunk', {
|
|
664
684
|
x: chunkX,
|
|
@@ -668,7 +688,7 @@ const player = function (player, serv, settings) {
|
|
|
668
688
|
serv._finishPlayerChunkLoading(chunkX, chunkZ, player);
|
|
669
689
|
const newLightsFormat = serv.supportFeature('newLightingDataFormat');
|
|
670
690
|
const dumpedLights = chunk.dumpLight();
|
|
671
|
-
const newLightsData = newLightsFormat ?
|
|
691
|
+
const newLightsData = newLightsFormat ? packetLightArrays(chunk, dumpedLights) : undefined;
|
|
672
692
|
const chunkBuffer = chunk.dump();
|
|
673
693
|
const bitMap = chunk.getMask();
|
|
674
694
|
player._client.write('map_chunk', {
|
|
@@ -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
|
-
//
|
|
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.
|
|
4
|
+
"version": "0.0.127",
|
|
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.
|
|
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",
|