mcbe-leveldb 1.17.0 → 1.18.0-jsonly
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.
- package/Changelog.md +28 -0
- package/LevelUtils.d.ts +1 -1
- package/LevelUtils.js +118 -43
- package/LevelUtils.js.map +1 -1
- package/__biome_data__.d.ts +7 -1
- package/__biome_data__.js +12 -3
- package/__biome_data__.js.map +1 -1
- package/nbtSchemas.d.ts +727 -68
- package/nbtSchemas.js +438 -65
- package/nbtSchemas.js.map +1 -1
- package/package.json +5 -4
- package/DBUtils.ts +0 -261
- package/LevelUtils.ts +0 -4672
- package/SNBTUtils.ts +0 -2150
- package/__biome_data__.ts +0 -282
- package/index.ts +0 -14
- package/nbtSchemas.ts +0 -27754
- package/utils/JSONB.ts +0 -566
package/Changelog.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
# v1.18.0
|
|
2
|
+
|
|
3
|
+
## Breaking Changes
|
|
4
|
+
|
|
5
|
+
- The `dirty_columns` field of the `LegacyTerrain` NBT schema and parser/serializer has been renamed to `height_map`.
|
|
6
|
+
- The `Data2D` NBT schema and parser/serializer now includes a `version` field.
|
|
7
|
+
|
|
8
|
+
## Additions
|
|
9
|
+
|
|
10
|
+
- Added the `Item_ItemStackBase` NBT schema, which is equivalent to the old `Item_ItemStack` NBT schema.
|
|
11
|
+
- The `Item_ItemStack` NBT schema now references the `Item_GeneralTags` and `Item_EnchantmentTags` NBT schemas.
|
|
12
|
+
- Added the `Item_GeneralTags` NBT schema.
|
|
13
|
+
- Added the `Item_EnchantmentTags` NBT schema, which includes autocomplete and validation for enchantment IDs.
|
|
14
|
+
- The NBT schema to TypeScript interface converter now supports `anyOf`.
|
|
15
|
+
- Added support for the newer `Data2D` format version used in `v1.18.0+` which uses 16-bit little-endian integers for biome IDs instead of 8-bit integers.
|
|
16
|
+
- The package now has the [`type-fest`](https://www.npmjs.com/package/type-fest) package as a dependency.
|
|
17
|
+
|
|
18
|
+
## Changes
|
|
19
|
+
|
|
20
|
+
- Updated the `BiomeData` from `v1.21.110` to `v1.26.30` (also manually added definitions for the dappled forest, since that is not in `v1.26.30` and there is no newer definitions file available).
|
|
21
|
+
- The NBT schema to TypeScript interface converter now wraps generated `oneOf` types in the `ExclusifyUnion` generic type from the [`type-fest`](https://www.npmjs.com/package/type-fest) package, this makes the typings more accurate.
|
|
22
|
+
- The `Data2D` content type is no longer marked as deprecated as it is actually still written by the game for worlds using the Old world type or an older base game version.
|
|
23
|
+
|
|
24
|
+
## Fixes
|
|
25
|
+
|
|
26
|
+
- Fixed a bug where many properties of NBT schemas that were items did not have a reference to the `Item_ItemStack` NBT schema.
|
|
27
|
+
- Many fixes for the NBT schema to JSON schema converter.
|
|
28
|
+
|
|
1
29
|
# v1.17.0
|
|
2
30
|
|
|
3
31
|
## Additions
|
package/LevelUtils.d.ts
CHANGED
|
@@ -221,7 +221,7 @@ export declare const entryContentTypeToFormatMap: {
|
|
|
221
221
|
*
|
|
222
222
|
* Unlike {@link entryContentTypeToFormatMap.Data3D | Data3D}, this only stores biome data for xz coordinates, so in this format all y coordinates have the same biome.
|
|
223
223
|
*
|
|
224
|
-
*
|
|
224
|
+
* Only used in versions < 1.18.0, and for worlds using the Old world type or using an older base game version.
|
|
225
225
|
*/
|
|
226
226
|
readonly Data2D: {
|
|
227
227
|
/**
|
package/LevelUtils.js
CHANGED
|
@@ -678,7 +678,7 @@ export const entryContentTypeToFormatMap = {
|
|
|
678
678
|
*
|
|
679
679
|
* Unlike {@link entryContentTypeToFormatMap.Data3D | Data3D}, this only stores biome data for xz coordinates, so in this format all y coordinates have the same biome.
|
|
680
680
|
*
|
|
681
|
-
*
|
|
681
|
+
* Only used in versions < 1.18.0, and for worlds using the Old world type or using an older base game version.
|
|
682
682
|
*/
|
|
683
683
|
Data2D: {
|
|
684
684
|
/**
|
|
@@ -698,6 +698,11 @@ export const entryContentTypeToFormatMap = {
|
|
|
698
698
|
* @returns The parsed data.
|
|
699
699
|
*/
|
|
700
700
|
parse(data) {
|
|
701
|
+
const formatVersion = data.length === 768 ? 1
|
|
702
|
+
: data.length === 1024 ? 2
|
|
703
|
+
: -1;
|
|
704
|
+
if (formatVersion === -1)
|
|
705
|
+
throw new Error(`Unknown Data2D format, expected 768 or 1024 bytes, got ${data.length} bytes`);
|
|
701
706
|
const heightMap = Array.from({ length: 16 }, () => Array(16).fill(0));
|
|
702
707
|
for (let i = 0; i < 256; i++) {
|
|
703
708
|
const val = readInt16LE(data, i * 2);
|
|
@@ -706,37 +711,82 @@ export const entryContentTypeToFormatMap = {
|
|
|
706
711
|
heightMap[x][z] = val;
|
|
707
712
|
}
|
|
708
713
|
const biomeData = Array.from({ length: 16 }, () => Array(16).fill(0));
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
type: "list",
|
|
714
|
+
switch (formatVersion) {
|
|
715
|
+
case 1:
|
|
716
|
+
for (let i = 0; i < 256; i++) {
|
|
717
|
+
const val = data.readUInt8(512 + i);
|
|
718
|
+
const x = i % 16;
|
|
719
|
+
const z = Math.floor(i / 16);
|
|
720
|
+
biomeData[x][z] = val;
|
|
721
|
+
}
|
|
722
|
+
return {
|
|
723
|
+
type: "compound",
|
|
720
724
|
value: {
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
725
|
+
version: {
|
|
726
|
+
type: "byte",
|
|
727
|
+
value: formatVersion,
|
|
728
|
+
},
|
|
729
|
+
heightMap: {
|
|
730
|
+
type: "list",
|
|
731
|
+
value: {
|
|
732
|
+
type: "list",
|
|
733
|
+
value: heightMap.map((row) => ({
|
|
734
|
+
type: "short",
|
|
735
|
+
value: row,
|
|
736
|
+
})),
|
|
737
|
+
},
|
|
738
|
+
},
|
|
739
|
+
biomeData: {
|
|
740
|
+
type: "list",
|
|
741
|
+
value: {
|
|
742
|
+
type: "list",
|
|
743
|
+
value: biomeData.map((row) => ({
|
|
744
|
+
type: "byte",
|
|
745
|
+
value: row,
|
|
746
|
+
})),
|
|
747
|
+
},
|
|
748
|
+
},
|
|
726
749
|
},
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
|
|
750
|
+
};
|
|
751
|
+
case 2:
|
|
752
|
+
for (let i = 0; i < 256; i++) {
|
|
753
|
+
const val = data.readUInt16LE(512 + i * 2);
|
|
754
|
+
const x = i % 16;
|
|
755
|
+
const z = Math.floor(i / 16);
|
|
756
|
+
biomeData[x][z] = val;
|
|
757
|
+
}
|
|
758
|
+
return {
|
|
759
|
+
type: "compound",
|
|
730
760
|
value: {
|
|
731
|
-
|
|
732
|
-
value: biomeData.map((row) => ({
|
|
761
|
+
version: {
|
|
733
762
|
type: "byte",
|
|
734
|
-
value:
|
|
735
|
-
}
|
|
763
|
+
value: formatVersion,
|
|
764
|
+
},
|
|
765
|
+
heightMap: {
|
|
766
|
+
type: "list",
|
|
767
|
+
value: {
|
|
768
|
+
type: "list",
|
|
769
|
+
value: heightMap.map((row) => ({
|
|
770
|
+
type: "short",
|
|
771
|
+
value: row,
|
|
772
|
+
})),
|
|
773
|
+
},
|
|
774
|
+
},
|
|
775
|
+
biomeData: {
|
|
776
|
+
type: "list",
|
|
777
|
+
value: {
|
|
778
|
+
type: "list",
|
|
779
|
+
value: biomeData.map((row) => ({
|
|
780
|
+
type: "short",
|
|
781
|
+
value: row,
|
|
782
|
+
})),
|
|
783
|
+
},
|
|
784
|
+
},
|
|
736
785
|
},
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
|
|
786
|
+
};
|
|
787
|
+
default:
|
|
788
|
+
throw new Error(`Missing parser for Data2D format: ${formatVersion}`);
|
|
789
|
+
}
|
|
740
790
|
},
|
|
741
791
|
/**
|
|
742
792
|
* The function to serialize the data.
|
|
@@ -747,24 +797,49 @@ export const entryContentTypeToFormatMap = {
|
|
|
747
797
|
* @returns The serialized data, as a buffer.
|
|
748
798
|
*/
|
|
749
799
|
serialize(data) {
|
|
800
|
+
const formatVersion = data.value.version.value;
|
|
750
801
|
const heightMap = data.value.heightMap.value.value;
|
|
751
802
|
const biomeData = data.value.biomeData.value.value;
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
803
|
+
switch (formatVersion) {
|
|
804
|
+
case 1: {
|
|
805
|
+
const buffer = Buffer.alloc(512 + 256);
|
|
806
|
+
for (let z = 0; z < 16; z++) {
|
|
807
|
+
for (let x = 0; x < 16; x++) {
|
|
808
|
+
const i = z * 16 + x;
|
|
809
|
+
const val = heightMap[x].value[z];
|
|
810
|
+
buffer.writeInt16LE(val, i * 2);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
for (let z = 0; z < 16; z++) {
|
|
814
|
+
for (let x = 0; x < 16; x++) {
|
|
815
|
+
const i = z * 16 + x;
|
|
816
|
+
const val = biomeData[x].value[z];
|
|
817
|
+
buffer.writeUInt8(val, 512 + i);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
return buffer;
|
|
758
821
|
}
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
822
|
+
case 2: {
|
|
823
|
+
const buffer = Buffer.alloc(512 + 512);
|
|
824
|
+
for (let z = 0; z < 16; z++) {
|
|
825
|
+
for (let x = 0; x < 16; x++) {
|
|
826
|
+
const i = z * 16 + x;
|
|
827
|
+
const val = heightMap[x].value[z];
|
|
828
|
+
buffer.writeInt16LE(val, i * 2);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
for (let z = 0; z < 16; z++) {
|
|
832
|
+
for (let x = 0; x < 16; x++) {
|
|
833
|
+
const i = z * 16 + x;
|
|
834
|
+
const val = biomeData[x].value[z];
|
|
835
|
+
buffer.writeUInt16LE(val, 512 + i * 2);
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
return buffer;
|
|
765
839
|
}
|
|
840
|
+
default:
|
|
841
|
+
throw new TypeError(`Unknown Data2D format: ${formatVersion}`);
|
|
766
842
|
}
|
|
767
|
-
return buffer;
|
|
768
843
|
},
|
|
769
844
|
},
|
|
770
845
|
/**
|
|
@@ -1116,7 +1191,7 @@ export const entryContentTypeToFormatMap = {
|
|
|
1116
1191
|
const block_data = unpackNibbleArray(16384);
|
|
1117
1192
|
const sky_light = unpackNibbleArray(16384);
|
|
1118
1193
|
const block_light = unpackNibbleArray(16384);
|
|
1119
|
-
const
|
|
1194
|
+
const height_map = [...data.subarray(currentOffset, currentOffset + 256)];
|
|
1120
1195
|
currentOffset += 256;
|
|
1121
1196
|
const grass_color = [...data.subarray(currentOffset, currentOffset + 1024)];
|
|
1122
1197
|
currentOffset += 1024;
|
|
@@ -1125,7 +1200,7 @@ export const entryContentTypeToFormatMap = {
|
|
|
1125
1200
|
block_data: { type: "list", value: { type: "byte", value: block_data } },
|
|
1126
1201
|
sky_light: { type: "list", value: { type: "byte", value: sky_light } },
|
|
1127
1202
|
block_light: { type: "list", value: { type: "byte", value: block_light } },
|
|
1128
|
-
|
|
1203
|
+
height_map: { type: "list", value: { type: "byte", value: height_map } },
|
|
1129
1204
|
grass_color: { type: "list", value: { type: "byte", value: grass_color } },
|
|
1130
1205
|
});
|
|
1131
1206
|
},
|
|
@@ -1146,7 +1221,7 @@ export const entryContentTypeToFormatMap = {
|
|
|
1146
1221
|
Buffer.from(packNibbles(data.value.block_data.value.value)),
|
|
1147
1222
|
Buffer.from(packNibbles(data.value.sky_light.value.value)),
|
|
1148
1223
|
Buffer.from(packNibbles(data.value.block_light.value.value)),
|
|
1149
|
-
Buffer.from(data.value.
|
|
1224
|
+
Buffer.from(data.value.height_map.value.value),
|
|
1150
1225
|
Buffer.from(data.value.grass_color.value.value),
|
|
1151
1226
|
]);
|
|
1152
1227
|
},
|