mca-json 1.0.0
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/.editorconfig +14 -0
- package/.prettierrc +4 -0
- package/README.md +373 -0
- package/dist/bin/mca-chunks.d.ts +3 -0
- package/dist/bin/mca-chunks.d.ts.map +1 -0
- package/dist/bin/mca-chunks.js +43 -0
- package/dist/bin/mca-chunks.js.map +1 -0
- package/dist/bin/mca-find-chunks-with-signs.d.ts +3 -0
- package/dist/bin/mca-find-chunks-with-signs.d.ts.map +1 -0
- package/dist/bin/mca-find-chunks-with-signs.js +79 -0
- package/dist/bin/mca-find-chunks-with-signs.js.map +1 -0
- package/dist/bin/mca-json.d.ts +3 -0
- package/dist/bin/mca-json.d.ts.map +1 -0
- package/dist/bin/mca-json.js +73 -0
- package/dist/bin/mca-json.js.map +1 -0
- package/dist/bin/mca-trim-chunks-without-signs.d.ts +3 -0
- package/dist/bin/mca-trim-chunks-without-signs.d.ts.map +1 -0
- package/dist/bin/mca-trim-chunks-without-signs.js +117 -0
- package/dist/bin/mca-trim-chunks-without-signs.js.map +1 -0
- package/dist/bin/nbt-get-player-location.d.ts +3 -0
- package/dist/bin/nbt-get-player-location.d.ts.map +1 -0
- package/dist/bin/nbt-get-player-location.js +83 -0
- package/dist/bin/nbt-get-player-location.js.map +1 -0
- package/dist/bin/nbt-json.d.ts +3 -0
- package/dist/bin/nbt-json.d.ts.map +1 -0
- package/dist/bin/nbt-json.js +64 -0
- package/dist/bin/nbt-json.js.map +1 -0
- package/dist/block/banner.d.ts +13 -0
- package/dist/block/banner.d.ts.map +1 -0
- package/dist/block/banner.js +28 -0
- package/dist/block/banner.js.map +1 -0
- package/dist/block/barrel.d.ts +17 -0
- package/dist/block/barrel.d.ts.map +1 -0
- package/dist/block/barrel.js +21 -0
- package/dist/block/barrel.js.map +1 -0
- package/dist/block/beacon.d.ts +14 -0
- package/dist/block/beacon.d.ts.map +1 -0
- package/dist/block/beacon.js +14 -0
- package/dist/block/beacon.js.map +1 -0
- package/dist/block/bed.d.ts +4 -0
- package/dist/block/bed.d.ts.map +1 -0
- package/dist/block/bed.js +4 -0
- package/dist/block/bed.js.map +1 -0
- package/dist/block/beehive.d.ts +9 -0
- package/dist/block/beehive.d.ts.map +1 -0
- package/dist/block/beehive.js +10 -0
- package/dist/block/beehive.js.map +1 -0
- package/dist/block/bell.d.ts +4 -0
- package/dist/block/bell.d.ts.map +1 -0
- package/dist/block/bell.js +4 -0
- package/dist/block/bell.js.map +1 -0
- package/dist/block/block.d.ts +23 -0
- package/dist/block/block.d.ts.map +1 -0
- package/dist/block/block.js +49 -0
- package/dist/block/block.js.map +1 -0
- package/dist/block/generic.d.ts +10 -0
- package/dist/block/generic.d.ts.map +1 -0
- package/dist/block/generic.js +14 -0
- package/dist/block/generic.js.map +1 -0
- package/dist/block/has-entity-data.d.ts +8 -0
- package/dist/block/has-entity-data.d.ts.map +1 -0
- package/dist/block/has-entity-data.js +12 -0
- package/dist/block/has-entity-data.js.map +1 -0
- package/dist/block/mixins/custom-name.d.ts +5 -0
- package/dist/block/mixins/custom-name.d.ts.map +1 -0
- package/dist/block/mixins/custom-name.js +7 -0
- package/dist/block/mixins/custom-name.js.map +1 -0
- package/dist/block/mixins/lock.d.ts +5 -0
- package/dist/block/mixins/lock.d.ts.map +1 -0
- package/dist/block/mixins/lock.js +7 -0
- package/dist/block/mixins/lock.js.map +1 -0
- package/dist/block/mixins/mixin.d.ts +27 -0
- package/dist/block/mixins/mixin.d.ts.map +1 -0
- package/dist/block/mixins/mixin.js +36 -0
- package/dist/block/mixins/mixin.js.map +1 -0
- package/dist/block/sign.d.ts +15 -0
- package/dist/block/sign.d.ts.map +1 -0
- package/dist/block/sign.js +91 -0
- package/dist/block/sign.js.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/anvil.d.ts +54 -0
- package/dist/lib/anvil.d.ts.map +1 -0
- package/dist/lib/anvil.js +141 -0
- package/dist/lib/anvil.js.map +1 -0
- package/dist/lib/binary-data.d.ts +48 -0
- package/dist/lib/binary-data.d.ts.map +1 -0
- package/dist/lib/binary-data.js +188 -0
- package/dist/lib/binary-data.js.map +1 -0
- package/dist/lib/bit-data.d.ts +16 -0
- package/dist/lib/bit-data.d.ts.map +1 -0
- package/dist/lib/bit-data.js +75 -0
- package/dist/lib/bit-data.js.map +1 -0
- package/dist/lib/block-data.d.ts +20 -0
- package/dist/lib/block-data.d.ts.map +1 -0
- package/dist/lib/block-data.js +125 -0
- package/dist/lib/block-data.js.map +1 -0
- package/dist/lib/chunk.d.ts +112 -0
- package/dist/lib/chunk.d.ts.map +1 -0
- package/dist/lib/chunk.js +299 -0
- package/dist/lib/chunk.js.map +1 -0
- package/dist/nbt/nbt-base.d.ts +20 -0
- package/dist/nbt/nbt-base.d.ts.map +1 -0
- package/dist/nbt/nbt-base.js +30 -0
- package/dist/nbt/nbt-base.js.map +1 -0
- package/dist/nbt/nbt-byte-array.d.ts +13 -0
- package/dist/nbt/nbt-byte-array.d.ts.map +1 -0
- package/dist/nbt/nbt-byte-array.js +30 -0
- package/dist/nbt/nbt-byte-array.js.map +1 -0
- package/dist/nbt/nbt-byte.d.ts +13 -0
- package/dist/nbt/nbt-byte.d.ts.map +1 -0
- package/dist/nbt/nbt-byte.js +25 -0
- package/dist/nbt/nbt-byte.js.map +1 -0
- package/dist/nbt/nbt-compound.d.ts +15 -0
- package/dist/nbt/nbt-compound.d.ts.map +1 -0
- package/dist/nbt/nbt-compound.js +68 -0
- package/dist/nbt/nbt-compound.js.map +1 -0
- package/dist/nbt/nbt-double.d.ts +13 -0
- package/dist/nbt/nbt-double.d.ts.map +1 -0
- package/dist/nbt/nbt-double.js +25 -0
- package/dist/nbt/nbt-double.js.map +1 -0
- package/dist/nbt/nbt-end.d.ts +11 -0
- package/dist/nbt/nbt-end.d.ts.map +1 -0
- package/dist/nbt/nbt-end.js +22 -0
- package/dist/nbt/nbt-end.js.map +1 -0
- package/dist/nbt/nbt-float.d.ts +13 -0
- package/dist/nbt/nbt-float.d.ts.map +1 -0
- package/dist/nbt/nbt-float.js +25 -0
- package/dist/nbt/nbt-float.js.map +1 -0
- package/dist/nbt/nbt-int-array.d.ts +13 -0
- package/dist/nbt/nbt-int-array.d.ts.map +1 -0
- package/dist/nbt/nbt-int-array.js +30 -0
- package/dist/nbt/nbt-int-array.js.map +1 -0
- package/dist/nbt/nbt-int.d.ts +13 -0
- package/dist/nbt/nbt-int.d.ts.map +1 -0
- package/dist/nbt/nbt-int.js +25 -0
- package/dist/nbt/nbt-int.js.map +1 -0
- package/dist/nbt/nbt-list.d.ts +17 -0
- package/dist/nbt/nbt-list.d.ts.map +1 -0
- package/dist/nbt/nbt-list.js +70 -0
- package/dist/nbt/nbt-list.js.map +1 -0
- package/dist/nbt/nbt-long-array.d.ts +13 -0
- package/dist/nbt/nbt-long-array.d.ts.map +1 -0
- package/dist/nbt/nbt-long-array.js +32 -0
- package/dist/nbt/nbt-long-array.js.map +1 -0
- package/dist/nbt/nbt-long.d.ts +13 -0
- package/dist/nbt/nbt-long.d.ts.map +1 -0
- package/dist/nbt/nbt-long.js +25 -0
- package/dist/nbt/nbt-long.js.map +1 -0
- package/dist/nbt/nbt-short.d.ts +13 -0
- package/dist/nbt/nbt-short.d.ts.map +1 -0
- package/dist/nbt/nbt-short.js +25 -0
- package/dist/nbt/nbt-short.js.map +1 -0
- package/dist/nbt/nbt-string.d.ts +13 -0
- package/dist/nbt/nbt-string.d.ts.map +1 -0
- package/dist/nbt/nbt-string.js +27 -0
- package/dist/nbt/nbt-string.js.map +1 -0
- package/dist/nbt/nbt-tag-type.d.ts +16 -0
- package/dist/nbt/nbt-tag-type.d.ts.map +1 -0
- package/dist/nbt/nbt-tag-type.js +17 -0
- package/dist/nbt/nbt-tag-type.js.map +1 -0
- package/dist/nbt/nbt.d.ts +11 -0
- package/dist/nbt/nbt.d.ts.map +1 -0
- package/dist/nbt/nbt.js +57 -0
- package/dist/nbt/nbt.js.map +1 -0
- package/dist/nbt/snbt-data.d.ts +18 -0
- package/dist/nbt/snbt-data.d.ts.map +1 -0
- package/dist/nbt/snbt-data.js +34 -0
- package/dist/nbt/snbt-data.js.map +1 -0
- package/dist/nbt/snbt-parse.d.ts +3 -0
- package/dist/nbt/snbt-parse.d.ts.map +1 -0
- package/dist/nbt/snbt-parse.js +201 -0
- package/dist/nbt/snbt-parse.js.map +1 -0
- package/dist/nbt/snbt-to-nbt.d.ts +7 -0
- package/dist/nbt/snbt-to-nbt.d.ts.map +1 -0
- package/dist/nbt/snbt-to-nbt.js +178 -0
- package/dist/nbt/snbt-to-nbt.js.map +1 -0
- package/dist/types/coords.d.ts +3 -0
- package/dist/types/coords.d.ts.map +1 -0
- package/dist/types/coords.js +2 -0
- package/dist/types/coords.js.map +1 -0
- package/package.json +28 -0
- package/src/bin/mca-chunks.ts +54 -0
- package/src/bin/mca-find-chunks-with-signs.ts +109 -0
- package/src/bin/mca-json.ts +96 -0
- package/src/bin/mca-trim-chunks-without-signs.ts +146 -0
- package/src/bin/nbt-get-player-location.ts +102 -0
- package/src/bin/nbt-json.ts +85 -0
- package/src/block/banner.ts +50 -0
- package/src/block/barrel.ts +34 -0
- package/src/block/beacon.ts +20 -0
- package/src/block/bed.ts +3 -0
- package/src/block/beehive.ts +17 -0
- package/src/block/bell.ts +3 -0
- package/src/block/block.ts +62 -0
- package/src/block/generic.ts +14 -0
- package/src/block/has-entity-data.ts +20 -0
- package/src/block/mixins/custom-name.ts +8 -0
- package/src/block/mixins/lock.ts +8 -0
- package/src/block/mixins/mixin.ts +53 -0
- package/src/block/sign.ts +121 -0
- package/src/index.ts +38 -0
- package/src/lib/anvil.ts +178 -0
- package/src/lib/binary-data.ts +247 -0
- package/src/lib/bit-data.ts +101 -0
- package/src/lib/block-data.ts +180 -0
- package/src/lib/chunk.ts +389 -0
- package/src/nbt/nbt-base.ts +38 -0
- package/src/nbt/nbt-byte-array.ts +38 -0
- package/src/nbt/nbt-byte.ts +31 -0
- package/src/nbt/nbt-compound.ts +95 -0
- package/src/nbt/nbt-double.ts +31 -0
- package/src/nbt/nbt-end.ts +27 -0
- package/src/nbt/nbt-float.ts +31 -0
- package/src/nbt/nbt-int-array.ts +38 -0
- package/src/nbt/nbt-int.ts +31 -0
- package/src/nbt/nbt-list.ts +103 -0
- package/src/nbt/nbt-long-array.ts +40 -0
- package/src/nbt/nbt-long.ts +31 -0
- package/src/nbt/nbt-short.ts +31 -0
- package/src/nbt/nbt-string.ts +35 -0
- package/src/nbt/nbt-tag-type.ts +15 -0
- package/src/nbt/nbt.ts +70 -0
- package/src/nbt/snbt-data.ts +70 -0
- package/src/nbt/snbt-parse.ts +256 -0
- package/src/nbt/snbt-to-nbt.ts +219 -0
- package/src/types/coords.ts +2 -0
- package/src/types/neodoc.d.ts +28 -0
- package/tsconfig.json +25 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { Nbt } from './nbt';
|
|
3
|
+
import { NbtBase } from './nbt-base';
|
|
4
|
+
import { NbtTagType } from './nbt-tag-type';
|
|
5
|
+
const debugLogFromBinaryData = debug('nbt:compound:from-binary-data');
|
|
6
|
+
const debugLogFindChild = debug('nbt:compound:find-child');
|
|
7
|
+
export class NbtCompound extends NbtBase {
|
|
8
|
+
static fromBinaryData(bd, name) {
|
|
9
|
+
name ??= NbtCompound.readName(bd);
|
|
10
|
+
const data = [];
|
|
11
|
+
debugLogFromBinaryData(`COMPOUND, name ${name}, starting`);
|
|
12
|
+
// Careful - this does not store the END tag
|
|
13
|
+
let tag = Nbt.getTag(bd);
|
|
14
|
+
debugLogFromBinaryData(`COMPOUND, name ${name}, tag ${tag.type} was retrieved`);
|
|
15
|
+
while (tag && tag.type !== NbtTagType.END) {
|
|
16
|
+
data.push(tag);
|
|
17
|
+
tag = Nbt.getTag(bd);
|
|
18
|
+
debugLogFromBinaryData(`COMPOUND, name ${name}, tag ${tag.type} was retrieved`);
|
|
19
|
+
}
|
|
20
|
+
debugLogFromBinaryData(`COMPOUND, name ${name}, finished`);
|
|
21
|
+
return new NbtCompound(data, name);
|
|
22
|
+
}
|
|
23
|
+
constructor(data, name) {
|
|
24
|
+
super(NbtTagType.COMPOUND, data, name);
|
|
25
|
+
}
|
|
26
|
+
findChild(path) {
|
|
27
|
+
const pathSegments = path.split('/');
|
|
28
|
+
const currentSegment = pathSegments.shift();
|
|
29
|
+
const result = this.data.find((item) => item.name === currentSegment);
|
|
30
|
+
debugLogFindChild(`COMPOUND, name ${this.name}, path ${path}, found? ${!!result}`);
|
|
31
|
+
if (!result) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (pathSegments.length) {
|
|
35
|
+
return result.findChild(pathSegments.join('/'));
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
isCompound(name) {
|
|
40
|
+
if (name !== undefined && this.name !== name) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
toObject() {
|
|
46
|
+
const compound = {};
|
|
47
|
+
for (const item of this.data) {
|
|
48
|
+
const name = item.name;
|
|
49
|
+
if (compound[name]) {
|
|
50
|
+
console.error('Corrupt chunk - duplicate key found', name);
|
|
51
|
+
}
|
|
52
|
+
compound[name] = item.toObject();
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
type: this.type,
|
|
56
|
+
compound,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
toSnbt() {
|
|
60
|
+
const compound = [];
|
|
61
|
+
for (const item of this.data) {
|
|
62
|
+
const itemSnbt = item.toSnbt();
|
|
63
|
+
compound.push(`${item.name}:${itemSnbt}`);
|
|
64
|
+
}
|
|
65
|
+
return `{${compound.join(',')}}`;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=nbt-compound.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nbt-compound.js","sourceRoot":"","sources":["../../src/nbt/nbt-compound.ts"],"names":[],"mappings":"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","sourcesContent":["import debug from 'debug';\nimport { BinaryData } from '../lib/binary-data';\nimport { Nbt } from './nbt';\nimport { NbtBase } from './nbt-base';\nimport { NbtTagType } from './nbt-tag-type';\n\nconst debugLogFromBinaryData = debug('nbt:compound:from-binary-data');\nconst debugLogFindChild = debug('nbt:compound:find-child');\n\nexport class NbtCompound extends NbtBase<NbtBase<any>[]> {\n static fromBinaryData<T>(bd: BinaryData, name?: string): NbtCompound {\n name ??= NbtCompound.readName(bd);\n const data: NbtBase<T>[] = [];\n debugLogFromBinaryData(`COMPOUND, name ${name}, starting`);\n\n // Careful - this does not store the END tag\n let tag = Nbt.getTag(bd);\n debugLogFromBinaryData(\n `COMPOUND, name ${name}, tag ${tag.type} was retrieved`\n );\n\n while (tag && tag.type !== NbtTagType.END) {\n data.push(tag);\n tag = Nbt.getTag(bd);\n debugLogFromBinaryData(\n `COMPOUND, name ${name}, tag ${tag.type} was retrieved`\n );\n }\n\n debugLogFromBinaryData(`COMPOUND, name ${name}, finished`);\n\n return new NbtCompound(data, name);\n }\n\n constructor(data: NbtBase<any>[], name?: string) {\n super(NbtTagType.COMPOUND, data, name);\n }\n\n override findChild<RESULT extends NbtBase<any>>(path: string) {\n const pathSegments = path.split('/');\n const currentSegment = pathSegments.shift();\n const result = this.data.find((item) => item.name === currentSegment);\n debugLogFindChild(\n `COMPOUND, name ${this.name}, path ${path}, found? ${!!result}`\n );\n\n if (!result) {\n return;\n }\n\n if (pathSegments.length) {\n return result.findChild<RESULT>(pathSegments.join('/'));\n }\n\n return result as RESULT;\n }\n\n override isCompound(name?: string) {\n if (name !== undefined && this.name !== name) {\n return false;\n }\n\n return true;\n }\n\n toObject() {\n const compound: Record<string, any> = {};\n\n for (const item of this.data) {\n const name = item.name;\n\n if (compound[name]) {\n console.error('Corrupt chunk - duplicate key found', name);\n }\n\n compound[name] = item.toObject();\n }\n\n return {\n type: this.type,\n compound,\n };\n }\n\n toSnbt() {\n const compound: string[] = [];\n\n for (const item of this.data) {\n const itemSnbt = item.toSnbt();\n compound.push(`${item.name}:${itemSnbt}`);\n }\n\n return `{${compound.join(',')}}`;\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BinaryData } from '../lib/binary-data';
|
|
2
|
+
import { NbtBase } from './nbt-base';
|
|
3
|
+
import { NbtTagType } from './nbt-tag-type';
|
|
4
|
+
export declare class NbtDouble extends NbtBase<number> {
|
|
5
|
+
static fromBinaryData(bd: BinaryData, name?: string): NbtDouble;
|
|
6
|
+
constructor(data: number, name?: string);
|
|
7
|
+
toObject(): {
|
|
8
|
+
type: NbtTagType;
|
|
9
|
+
double: number;
|
|
10
|
+
};
|
|
11
|
+
toSnbt(): string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=nbt-double.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nbt-double.d.ts","sourceRoot":"","sources":["../../src/nbt/nbt-double.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI5C,qBAAa,SAAU,SAAQ,OAAO,CAAC,MAAM,CAAC;IAC1C,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS;gBAQnD,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAIvC,QAAQ;;;;IAOR,MAAM;CAGT"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { NbtBase } from './nbt-base';
|
|
3
|
+
import { NbtTagType } from './nbt-tag-type';
|
|
4
|
+
const debugLogFromBinaryData = debug('nbt:double:from-binary-data');
|
|
5
|
+
export class NbtDouble extends NbtBase {
|
|
6
|
+
static fromBinaryData(bd, name) {
|
|
7
|
+
name ??= NbtDouble.readName(bd);
|
|
8
|
+
const data = bd.getDouble();
|
|
9
|
+
debugLogFromBinaryData(`DOUBLE, name ${name}, data ${data}`);
|
|
10
|
+
return new NbtDouble(data, name);
|
|
11
|
+
}
|
|
12
|
+
constructor(data, name) {
|
|
13
|
+
super(NbtTagType.DOUBLE, data, name);
|
|
14
|
+
}
|
|
15
|
+
toObject() {
|
|
16
|
+
return {
|
|
17
|
+
type: this.type,
|
|
18
|
+
double: this.data,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
toSnbt() {
|
|
22
|
+
return `${this.data}d`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=nbt-double.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nbt-double.js","sourceRoot":"","sources":["../../src/nbt/nbt-double.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,sBAAsB,GAAG,KAAK,CAAC,6BAA6B,CAAC,CAAC;AAEpE,MAAM,OAAO,SAAU,SAAQ,OAAe;IAC1C,MAAM,CAAC,cAAc,CAAC,EAAc,EAAE,IAAa;QAC/C,IAAI,KAAK,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAChC,MAAM,IAAI,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC;QAC5B,sBAAsB,CAAC,gBAAgB,IAAI,UAAU,IAAI,EAAE,CAAC,CAAC;QAE7D,OAAO,IAAI,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,YAAY,IAAY,EAAE,IAAa;QACnC,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,QAAQ;QACJ,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,IAAI,CAAC,IAAI;SACpB,CAAC;IACN,CAAC;IAED,MAAM;QACF,OAAO,GAAG,IAAI,CAAC,IAAI,GAAG,CAAC;IAC3B,CAAC;CACJ","sourcesContent":["import debug from 'debug';\nimport { BinaryData } from '../lib/binary-data';\nimport { NbtBase } from './nbt-base';\nimport { NbtTagType } from './nbt-tag-type';\n\nconst debugLogFromBinaryData = debug('nbt:double:from-binary-data');\n\nexport class NbtDouble extends NbtBase<number> {\n static fromBinaryData(bd: BinaryData, name?: string): NbtDouble {\n name ??= NbtDouble.readName(bd);\n const data = bd.getDouble();\n debugLogFromBinaryData(`DOUBLE, name ${name}, data ${data}`);\n\n return new NbtDouble(data, name);\n }\n\n constructor(data: number, name?: string) {\n super(NbtTagType.DOUBLE, data, name);\n }\n\n toObject() {\n return {\n type: this.type,\n double: this.data,\n };\n }\n\n toSnbt() {\n return `${this.data}d`;\n }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NbtBase } from './nbt-base';
|
|
2
|
+
import { NbtTagType } from './nbt-tag-type';
|
|
3
|
+
export declare class NbtEnd extends NbtBase<null> {
|
|
4
|
+
static fromBinaryData(): NbtEnd;
|
|
5
|
+
constructor();
|
|
6
|
+
toObject(): {
|
|
7
|
+
type: NbtTagType;
|
|
8
|
+
};
|
|
9
|
+
toSnbt(): string;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=nbt-end.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nbt-end.d.ts","sourceRoot":"","sources":["../../src/nbt/nbt-end.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI5C,qBAAa,MAAO,SAAQ,OAAO,CAAC,IAAI,CAAC;IACrC,MAAM,CAAC,cAAc,IAAI,MAAM;;IAU/B,QAAQ;;;IAMR,MAAM,IAAI,MAAM;CAGnB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { NbtBase } from './nbt-base';
|
|
3
|
+
import { NbtTagType } from './nbt-tag-type';
|
|
4
|
+
const debugLogFromBinaryData = debug('nbt:end:from-binary-data');
|
|
5
|
+
export class NbtEnd extends NbtBase {
|
|
6
|
+
static fromBinaryData() {
|
|
7
|
+
debugLogFromBinaryData('END');
|
|
8
|
+
return new NbtEnd();
|
|
9
|
+
}
|
|
10
|
+
constructor() {
|
|
11
|
+
super(NbtTagType.END, null, '');
|
|
12
|
+
}
|
|
13
|
+
toObject() {
|
|
14
|
+
return {
|
|
15
|
+
type: this.type,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
toSnbt() {
|
|
19
|
+
throw new Error('END tag cannot be converted to SNBT');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=nbt-end.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nbt-end.js","sourceRoot":"","sources":["../../src/nbt/nbt-end.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,sBAAsB,GAAG,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAEjE,MAAM,OAAO,MAAO,SAAQ,OAAa;IACrC,MAAM,CAAC,cAAc;QACjB,sBAAsB,CAAC,KAAK,CAAC,CAAC;QAE9B,OAAO,IAAI,MAAM,EAAE,CAAC;IACxB,CAAC;IAED;QACI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IACpC,CAAC;IAED,QAAQ;QACJ,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,IAAI;SAClB,CAAC;IACN,CAAC;IAED,MAAM;QACF,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IAC3D,CAAC;CACJ","sourcesContent":["import debug from 'debug';\nimport { NbtBase } from './nbt-base';\nimport { NbtTagType } from './nbt-tag-type';\n\nconst debugLogFromBinaryData = debug('nbt:end:from-binary-data');\n\nexport class NbtEnd extends NbtBase<null> {\n static fromBinaryData(): NbtEnd {\n debugLogFromBinaryData('END');\n\n return new NbtEnd();\n }\n\n constructor() {\n super(NbtTagType.END, null, '');\n }\n\n toObject() {\n return {\n type: this.type,\n };\n }\n\n toSnbt(): string {\n throw new Error('END tag cannot be converted to SNBT');\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BinaryData } from '../lib/binary-data';
|
|
2
|
+
import { NbtBase } from './nbt-base';
|
|
3
|
+
import { NbtTagType } from './nbt-tag-type';
|
|
4
|
+
export declare class NbtFloat extends NbtBase<number> {
|
|
5
|
+
static fromBinaryData(bd: BinaryData, name?: string): NbtFloat;
|
|
6
|
+
constructor(data: number, name?: string);
|
|
7
|
+
toObject(): {
|
|
8
|
+
type: NbtTagType;
|
|
9
|
+
float: number;
|
|
10
|
+
};
|
|
11
|
+
toSnbt(): string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=nbt-float.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nbt-float.d.ts","sourceRoot":"","sources":["../../src/nbt/nbt-float.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI5C,qBAAa,QAAS,SAAQ,OAAO,CAAC,MAAM,CAAC;IACzC,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ;gBAQlD,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAIvC,QAAQ;;;;IAOR,MAAM;CAGT"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { NbtBase } from './nbt-base';
|
|
3
|
+
import { NbtTagType } from './nbt-tag-type';
|
|
4
|
+
const debugLogFromBinaryData = debug('nbt:float:from-binary-data');
|
|
5
|
+
export class NbtFloat extends NbtBase {
|
|
6
|
+
static fromBinaryData(bd, name) {
|
|
7
|
+
name ??= NbtFloat.readName(bd);
|
|
8
|
+
const data = bd.getFloat();
|
|
9
|
+
debugLogFromBinaryData(`FLOAT, name ${name}, data ${data}`);
|
|
10
|
+
return new NbtFloat(data, name);
|
|
11
|
+
}
|
|
12
|
+
constructor(data, name) {
|
|
13
|
+
super(NbtTagType.FLOAT, data, name);
|
|
14
|
+
}
|
|
15
|
+
toObject() {
|
|
16
|
+
return {
|
|
17
|
+
type: this.type,
|
|
18
|
+
float: this.data,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
toSnbt() {
|
|
22
|
+
return `${this.data}f`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=nbt-float.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nbt-float.js","sourceRoot":"","sources":["../../src/nbt/nbt-float.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,sBAAsB,GAAG,KAAK,CAAC,4BAA4B,CAAC,CAAC;AAEnE,MAAM,OAAO,QAAS,SAAQ,OAAe;IACzC,MAAM,CAAC,cAAc,CAAC,EAAc,EAAE,IAAa;QAC/C,IAAI,KAAK,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC/B,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;QAC3B,sBAAsB,CAAC,eAAe,IAAI,UAAU,IAAI,EAAE,CAAC,CAAC;QAE5D,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,YAAY,IAAY,EAAE,IAAa;QACnC,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,QAAQ;QACJ,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,IAAI;SACnB,CAAC;IACN,CAAC;IAED,MAAM;QACF,OAAO,GAAG,IAAI,CAAC,IAAI,GAAG,CAAC;IAC3B,CAAC;CACJ","sourcesContent":["import debug from 'debug';\nimport { BinaryData } from '../lib/binary-data';\nimport { NbtBase } from './nbt-base';\nimport { NbtTagType } from './nbt-tag-type';\n\nconst debugLogFromBinaryData = debug('nbt:float:from-binary-data');\n\nexport class NbtFloat extends NbtBase<number> {\n static fromBinaryData(bd: BinaryData, name?: string): NbtFloat {\n name ??= NbtFloat.readName(bd);\n const data = bd.getFloat();\n debugLogFromBinaryData(`FLOAT, name ${name}, data ${data}`);\n\n return new NbtFloat(data, name);\n }\n\n constructor(data: number, name?: string) {\n super(NbtTagType.FLOAT, data, name);\n }\n\n toObject() {\n return {\n type: this.type,\n float: this.data,\n };\n }\n\n toSnbt() {\n return `${this.data}f`;\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BinaryData } from '../lib/binary-data';
|
|
2
|
+
import { NbtBase } from './nbt-base';
|
|
3
|
+
import { NbtTagType } from './nbt-tag-type';
|
|
4
|
+
export declare class NbtIntArray extends NbtBase<number[]> {
|
|
5
|
+
static fromBinaryData(bd: BinaryData, name?: string): NbtIntArray;
|
|
6
|
+
constructor(data: number[], name?: string);
|
|
7
|
+
toObject(): {
|
|
8
|
+
type: NbtTagType;
|
|
9
|
+
intArray: number[];
|
|
10
|
+
};
|
|
11
|
+
toSnbt(): string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=nbt-int-array.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nbt-int-array.d.ts","sourceRoot":"","sources":["../../src/nbt/nbt-int-array.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI5C,qBAAa,WAAY,SAAQ,OAAO,CAAC,MAAM,EAAE,CAAC;IAC9C,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW;gBAerD,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,MAAM;IAIzC,QAAQ;;;;IAOR,MAAM;CAGT"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { NbtBase } from './nbt-base';
|
|
3
|
+
import { NbtTagType } from './nbt-tag-type';
|
|
4
|
+
const debugLogFromBinaryData = debug('nbt:int-array:from-binary-data');
|
|
5
|
+
export class NbtIntArray extends NbtBase {
|
|
6
|
+
static fromBinaryData(bd, name) {
|
|
7
|
+
name ??= NbtIntArray.readName(bd);
|
|
8
|
+
const data = [];
|
|
9
|
+
const length = bd.getInt();
|
|
10
|
+
debugLogFromBinaryData(`INT_ARRAY, name ${name}, length ${length}`);
|
|
11
|
+
for (let i = 0; i < length; i++) {
|
|
12
|
+
data.push(bd.getInt());
|
|
13
|
+
}
|
|
14
|
+
debugLogFromBinaryData(`INT_ARRAY, name ${name}, data ${data}`);
|
|
15
|
+
return new NbtIntArray(data, name);
|
|
16
|
+
}
|
|
17
|
+
constructor(data, name) {
|
|
18
|
+
super(NbtTagType.INT_ARRAY, data, name);
|
|
19
|
+
}
|
|
20
|
+
toObject() {
|
|
21
|
+
return {
|
|
22
|
+
type: this.type,
|
|
23
|
+
intArray: this.data,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
toSnbt() {
|
|
27
|
+
return `[I;${this.data.join(', ')}]`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=nbt-int-array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nbt-int-array.js","sourceRoot":"","sources":["../../src/nbt/nbt-int-array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,sBAAsB,GAAG,KAAK,CAAC,gCAAgC,CAAC,CAAC;AAEvE,MAAM,OAAO,WAAY,SAAQ,OAAiB;IAC9C,MAAM,CAAC,cAAc,CAAC,EAAc,EAAE,IAAa;QAC/C,IAAI,KAAK,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAClC,MAAM,IAAI,GAAa,EAAE,CAAC;QAC1B,MAAM,MAAM,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC;QAC3B,sBAAsB,CAAC,mBAAmB,IAAI,YAAY,MAAM,EAAE,CAAC,CAAC;QAEpE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC9B,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3B,CAAC;QAED,sBAAsB,CAAC,mBAAmB,IAAI,UAAU,IAAI,EAAE,CAAC,CAAC;QAEhE,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,YAAY,IAAc,EAAE,IAAa;QACrC,KAAK,CAAC,UAAU,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED,QAAQ;QACJ,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,QAAQ,EAAE,IAAI,CAAC,IAAI;SACtB,CAAC;IACN,CAAC;IAED,MAAM;QACF,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;IACzC,CAAC;CACJ","sourcesContent":["import debug from 'debug';\nimport { BinaryData } from '../lib/binary-data';\nimport { NbtBase } from './nbt-base';\nimport { NbtTagType } from './nbt-tag-type';\n\nconst debugLogFromBinaryData = debug('nbt:int-array:from-binary-data');\n\nexport class NbtIntArray extends NbtBase<number[]> {\n static fromBinaryData(bd: BinaryData, name?: string): NbtIntArray {\n name ??= NbtIntArray.readName(bd);\n const data: number[] = [];\n const length = bd.getInt();\n debugLogFromBinaryData(`INT_ARRAY, name ${name}, length ${length}`);\n\n for (let i = 0; i < length; i++) {\n data.push(bd.getInt());\n }\n\n debugLogFromBinaryData(`INT_ARRAY, name ${name}, data ${data}`);\n\n return new NbtIntArray(data, name);\n }\n\n constructor(data: number[], name?: string) {\n super(NbtTagType.INT_ARRAY, data, name);\n }\n\n toObject() {\n return {\n type: this.type,\n intArray: this.data,\n };\n }\n\n toSnbt() {\n return `[I;${this.data.join(', ')}]`;\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BinaryData } from '../lib/binary-data';
|
|
2
|
+
import { NbtBase } from './nbt-base';
|
|
3
|
+
import { NbtTagType } from './nbt-tag-type';
|
|
4
|
+
export declare class NbtInt extends NbtBase<number> {
|
|
5
|
+
static fromBinaryData(bd: BinaryData, name?: string): NbtInt;
|
|
6
|
+
constructor(data: number, name?: string);
|
|
7
|
+
toObject(): {
|
|
8
|
+
type: NbtTagType;
|
|
9
|
+
int: number;
|
|
10
|
+
};
|
|
11
|
+
toSnbt(): string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=nbt-int.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nbt-int.d.ts","sourceRoot":"","sources":["../../src/nbt/nbt-int.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI5C,qBAAa,MAAO,SAAQ,OAAO,CAAC,MAAM,CAAC;IACvC,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM;gBAQhD,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAIvC,QAAQ;;;;IAOR,MAAM;CAGT"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { NbtBase } from './nbt-base';
|
|
3
|
+
import { NbtTagType } from './nbt-tag-type';
|
|
4
|
+
const debugLogFromBinaryData = debug('nbt:int:from-binary-data');
|
|
5
|
+
export class NbtInt extends NbtBase {
|
|
6
|
+
static fromBinaryData(bd, name) {
|
|
7
|
+
name ??= NbtInt.readName(bd);
|
|
8
|
+
const data = bd.getInt();
|
|
9
|
+
debugLogFromBinaryData(`INT, name ${name}, data ${data}`);
|
|
10
|
+
return new NbtInt(data, name);
|
|
11
|
+
}
|
|
12
|
+
constructor(data, name) {
|
|
13
|
+
super(NbtTagType.INT, data, name);
|
|
14
|
+
}
|
|
15
|
+
toObject() {
|
|
16
|
+
return {
|
|
17
|
+
type: this.type,
|
|
18
|
+
int: this.data,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
toSnbt() {
|
|
22
|
+
return `${this.data}`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=nbt-int.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nbt-int.js","sourceRoot":"","sources":["../../src/nbt/nbt-int.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,sBAAsB,GAAG,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAEjE,MAAM,OAAO,MAAO,SAAQ,OAAe;IACvC,MAAM,CAAC,cAAc,CAAC,EAAc,EAAE,IAAa;QAC/C,IAAI,KAAK,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC7B,MAAM,IAAI,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC;QACzB,sBAAsB,CAAC,aAAa,IAAI,UAAU,IAAI,EAAE,CAAC,CAAC;QAE1D,OAAO,IAAI,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,YAAY,IAAY,EAAE,IAAa;QACnC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,QAAQ;QACJ,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,IAAI;SACjB,CAAC;IACN,CAAC;IAED,MAAM;QACF,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC1B,CAAC;CACJ","sourcesContent":["import debug from 'debug';\nimport { BinaryData } from '../lib/binary-data';\nimport { NbtBase } from './nbt-base';\nimport { NbtTagType } from './nbt-tag-type';\n\nconst debugLogFromBinaryData = debug('nbt:int:from-binary-data');\n\nexport class NbtInt extends NbtBase<number> {\n static fromBinaryData(bd: BinaryData, name?: string): NbtInt {\n name ??= NbtInt.readName(bd);\n const data = bd.getInt();\n debugLogFromBinaryData(`INT, name ${name}, data ${data}`);\n\n return new NbtInt(data, name);\n }\n\n constructor(data: number, name?: string) {\n super(NbtTagType.INT, data, name);\n }\n\n toObject() {\n return {\n type: this.type,\n int: this.data,\n };\n }\n\n toSnbt() {\n return `${this.data}`;\n }\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BinaryData } from '../lib/binary-data';
|
|
2
|
+
import { NbtBase } from './nbt-base';
|
|
3
|
+
import { NbtTagType } from './nbt-tag-type';
|
|
4
|
+
export declare class NbtList<T extends NbtBase<any>> extends NbtBase<T[]> {
|
|
5
|
+
static fromBinaryData<SOURCE extends NbtBase<any>>(bd: BinaryData, name?: string): NbtList<SOURCE>;
|
|
6
|
+
subtype: NbtTagType;
|
|
7
|
+
constructor(data: T[], subtype: NbtTagType, name?: string);
|
|
8
|
+
findChild<RESULT extends NbtBase<any>>(path: string): RESULT | undefined;
|
|
9
|
+
isList(subtype?: NbtTagType): boolean;
|
|
10
|
+
toObject(): {
|
|
11
|
+
type: NbtTagType;
|
|
12
|
+
subtype: NbtTagType;
|
|
13
|
+
list: any[];
|
|
14
|
+
};
|
|
15
|
+
toSnbt(): string;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=nbt-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nbt-list.d.ts","sourceRoot":"","sources":["../../src/nbt/nbt-list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAK5C,qBAAa,OAAO,CAAC,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,CAAE,SAAQ,OAAO,CAAC,CAAC,EAAE,CAAC;IAC7D,MAAM,CAAC,cAAc,CAAC,MAAM,SAAS,OAAO,CAAC,GAAG,CAAC,EAC7C,EAAE,EAAE,UAAU,EACd,IAAI,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC;IA0BlB,OAAO,EAAE,UAAU,CAAC;gBAER,IAAI,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM;IAKhD,SAAS,CAAC,MAAM,SAAS,OAAO,CAAC,GAAG,CAAC,EAC1C,IAAI,EAAE,MAAM,GACb,MAAM,GAAG,SAAS;IAmCZ,MAAM,CAAC,OAAO,CAAC,EAAE,UAAU;IAQpC,QAAQ;;;;;IAQR,MAAM;CAGT"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { fromBinaryData } from './nbt';
|
|
3
|
+
import { NbtBase } from './nbt-base';
|
|
4
|
+
import { NbtTagType } from './nbt-tag-type';
|
|
5
|
+
const debugLogFromBinaryData = debug('nbt:list:from-binary-data');
|
|
6
|
+
const debugLogFindChild = debug('nbt:list:find-child');
|
|
7
|
+
export class NbtList extends NbtBase {
|
|
8
|
+
static fromBinaryData(bd, name) {
|
|
9
|
+
name ??= NbtList.readName(bd);
|
|
10
|
+
const subtype = bd.getByte();
|
|
11
|
+
const length = bd.getInt();
|
|
12
|
+
const data = [];
|
|
13
|
+
debugLogFromBinaryData(`LIST, name ${name}, subtype ${subtype}, length ${length}, start`);
|
|
14
|
+
const reader = fromBinaryData[subtype];
|
|
15
|
+
if (!reader) {
|
|
16
|
+
throw new Error(`Invalid NBT tag type ${subtype} for list tag`);
|
|
17
|
+
}
|
|
18
|
+
while (data.length < length) {
|
|
19
|
+
// All list items are unnamed
|
|
20
|
+
data.push(reader(bd, ''));
|
|
21
|
+
}
|
|
22
|
+
debugLogFromBinaryData(`LIST, name ${name}, subtype ${subtype}, element count ${data.length}, end`);
|
|
23
|
+
return new NbtList(data, subtype, name);
|
|
24
|
+
}
|
|
25
|
+
subtype;
|
|
26
|
+
constructor(data, subtype, name) {
|
|
27
|
+
super(NbtTagType.LIST, data, name);
|
|
28
|
+
this.subtype = subtype;
|
|
29
|
+
}
|
|
30
|
+
findChild(path) {
|
|
31
|
+
const pathSegments = path.split('/');
|
|
32
|
+
const currentSegment = pathSegments.shift();
|
|
33
|
+
if (!currentSegment) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const index = parseInt(currentSegment, 10);
|
|
37
|
+
if (isNaN(index)) {
|
|
38
|
+
debugLogFindChild(`LIST, name ${this.name}, subtype ${this.subtype}, path ${path}, segment ${currentSegment}, not a number`);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const result = this.data[index];
|
|
42
|
+
if (!result) {
|
|
43
|
+
debugLogFindChild(`LIST, name ${this.name}, subtype ${this.subtype}, path ${path}, segment ${currentSegment}, no child found at index ${index}`);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (pathSegments.length) {
|
|
47
|
+
debugLogFindChild(`LIST, name ${this.name}, subtype ${this.subtype}, path ${path}, segment ${currentSegment}, recurse`);
|
|
48
|
+
return result.findChild(pathSegments.join('/'));
|
|
49
|
+
}
|
|
50
|
+
debugLogFindChild(`LIST, name ${this.name}, subtype ${this.subtype}, path ${path}, segment ${currentSegment}, found`);
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
isList(subtype) {
|
|
54
|
+
if (subtype !== undefined && this.subtype !== subtype) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
toObject() {
|
|
60
|
+
return {
|
|
61
|
+
type: this.type,
|
|
62
|
+
subtype: this.subtype,
|
|
63
|
+
list: this.data.map((v) => v.toObject()),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
toSnbt() {
|
|
67
|
+
return this.data.map((v) => v.toSnbt()).join(',');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=nbt-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nbt-list.js","sourceRoot":"","sources":["../../src/nbt/nbt-list.ts"],"names":[],"mappings":"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","sourcesContent":["import debug from 'debug';\nimport { BinaryData } from '../lib/binary-data';\nimport { fromBinaryData } from './nbt';\nimport { NbtBase } from './nbt-base';\nimport { NbtTagType } from './nbt-tag-type';\n\nconst debugLogFromBinaryData = debug('nbt:list:from-binary-data');\nconst debugLogFindChild = debug('nbt:list:find-child');\n\nexport class NbtList<T extends NbtBase<any>> extends NbtBase<T[]> {\n static fromBinaryData<SOURCE extends NbtBase<any>>(\n bd: BinaryData,\n name?: string\n ): NbtList<SOURCE> {\n name ??= NbtList.readName(bd);\n const subtype = bd.getByte();\n const length = bd.getInt();\n const data: SOURCE[] = [];\n debugLogFromBinaryData(\n `LIST, name ${name}, subtype ${subtype}, length ${length}, start`\n );\n const reader = fromBinaryData[subtype];\n\n if (!reader) {\n throw new Error(`Invalid NBT tag type ${subtype} for list tag`);\n }\n\n while (data.length < length) {\n // All list items are unnamed\n data.push(reader(bd, '') as SOURCE);\n }\n\n debugLogFromBinaryData(\n `LIST, name ${name}, subtype ${subtype}, element count ${data.length}, end`\n );\n\n return new NbtList<SOURCE>(data, subtype, name);\n }\n\n subtype: NbtTagType;\n\n constructor(data: T[], subtype: NbtTagType, name?: string) {\n super(NbtTagType.LIST, data, name);\n this.subtype = subtype;\n }\n\n override findChild<RESULT extends NbtBase<any>>(\n path: string\n ): RESULT | undefined {\n const pathSegments = path.split('/');\n const currentSegment = pathSegments.shift();\n\n if (!currentSegment) {\n return;\n }\n\n const index = parseInt(currentSegment, 10);\n\n if (isNaN(index)) {\n debugLogFindChild(`LIST, name ${this.name}, subtype ${this.subtype}, path ${path}, segment ${currentSegment}, not a number`);\n\n return;\n }\n\n const result = this.data[index];\n\n if (!result) {\n debugLogFindChild(`LIST, name ${this.name}, subtype ${this.subtype}, path ${path}, segment ${currentSegment}, no child found at index ${index}`);\n\n return;\n }\n\n if (pathSegments.length) {\n debugLogFindChild(`LIST, name ${this.name}, subtype ${this.subtype}, path ${path}, segment ${currentSegment}, recurse`);\n\n return result.findChild<RESULT>(pathSegments.join('/'));\n }\n\n debugLogFindChild(`LIST, name ${this.name}, subtype ${this.subtype}, path ${path}, segment ${currentSegment}, found`);\n\n return result as unknown as RESULT;\n }\n\n override isList(subtype?: NbtTagType) {\n if (subtype !== undefined && this.subtype !== subtype) {\n return false;\n }\n\n return true;\n }\n\n toObject() {\n return {\n type: this.type,\n subtype: this.subtype,\n list: this.data.map((v) => v.toObject()),\n };\n }\n\n toSnbt() {\n return this.data.map((v) => v.toSnbt()).join(',');\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BinaryData } from '../lib/binary-data';
|
|
2
|
+
import { NbtBase } from './nbt-base';
|
|
3
|
+
import { NbtTagType } from './nbt-tag-type';
|
|
4
|
+
export declare class NbtLongArray extends NbtBase<bigint[]> {
|
|
5
|
+
static fromBinaryData(bd: BinaryData, name?: string): NbtLongArray;
|
|
6
|
+
constructor(data: bigint[], name?: string);
|
|
7
|
+
toObject(): {
|
|
8
|
+
type: NbtTagType;
|
|
9
|
+
longArray: string[];
|
|
10
|
+
};
|
|
11
|
+
toSnbt(): string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=nbt-long-array.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nbt-long-array.d.ts","sourceRoot":"","sources":["../../src/nbt/nbt-long-array.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI5C,qBAAa,YAAa,SAAQ,OAAO,CAAC,MAAM,EAAE,CAAC;IAC/C,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,YAAY;gBAiBtD,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,MAAM;IAIzC,QAAQ;;;;IAOR,MAAM;CAGT"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { NbtBase } from './nbt-base';
|
|
3
|
+
import { NbtTagType } from './nbt-tag-type';
|
|
4
|
+
const debugLogFromBinaryData = debug('nbt:long-array:from-binary-data');
|
|
5
|
+
export class NbtLongArray extends NbtBase {
|
|
6
|
+
static fromBinaryData(bd, name) {
|
|
7
|
+
name ??= NbtLongArray.readName(bd);
|
|
8
|
+
const data = [];
|
|
9
|
+
const length = bd.getInt();
|
|
10
|
+
debugLogFromBinaryData(`LONG_ARRAY, name ${name}, length ${length}`);
|
|
11
|
+
for (let i = 0; i < length; i++) {
|
|
12
|
+
// This needs to be able to be converted back to a bit stream in
|
|
13
|
+
// BitData. See BitData.fromLongArrayTag().
|
|
14
|
+
data.push(bd.getInt64LE());
|
|
15
|
+
}
|
|
16
|
+
debugLogFromBinaryData(`LONG_ARRAY, name ${name}, data ${data}`);
|
|
17
|
+
return new NbtLongArray(data, name);
|
|
18
|
+
}
|
|
19
|
+
constructor(data, name) {
|
|
20
|
+
super(NbtTagType.LONG_ARRAY, data, name);
|
|
21
|
+
}
|
|
22
|
+
toObject() {
|
|
23
|
+
return {
|
|
24
|
+
type: this.type,
|
|
25
|
+
longArray: this.data.map((v) => v.toString()),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
toSnbt() {
|
|
29
|
+
return `[L;${this.data.map((v) => v.toString()).join(', ')}]`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=nbt-long-array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nbt-long-array.js","sourceRoot":"","sources":["../../src/nbt/nbt-long-array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,sBAAsB,GAAG,KAAK,CAAC,iCAAiC,CAAC,CAAC;AAExE,MAAM,OAAO,YAAa,SAAQ,OAAiB;IAC/C,MAAM,CAAC,cAAc,CAAC,EAAc,EAAE,IAAa;QAC/C,IAAI,KAAK,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACnC,MAAM,IAAI,GAAa,EAAE,CAAC;QAC1B,MAAM,MAAM,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC;QAC3B,sBAAsB,CAAC,oBAAoB,IAAI,YAAY,MAAM,EAAE,CAAC,CAAC;QAErE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC9B,gEAAgE;YAChE,2CAA2C;YAC3C,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,CAAC;QAC/B,CAAC;QAED,sBAAsB,CAAC,oBAAoB,IAAI,UAAU,IAAI,EAAE,CAAC,CAAC;QAEjE,OAAO,IAAI,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,YAAY,IAAc,EAAE,IAAa;QACrC,KAAK,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED,QAAQ;QACJ,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;SAChD,CAAC;IACN,CAAC;IAED,MAAM;QACF,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;IAClE,CAAC;CACJ","sourcesContent":["import debug from 'debug';\nimport { BinaryData } from '../lib/binary-data';\nimport { NbtBase } from './nbt-base';\nimport { NbtTagType } from './nbt-tag-type';\n\nconst debugLogFromBinaryData = debug('nbt:long-array:from-binary-data');\n\nexport class NbtLongArray extends NbtBase<bigint[]> {\n static fromBinaryData(bd: BinaryData, name?: string): NbtLongArray {\n name ??= NbtLongArray.readName(bd);\n const data: bigint[] = [];\n const length = bd.getInt();\n debugLogFromBinaryData(`LONG_ARRAY, name ${name}, length ${length}`);\n\n for (let i = 0; i < length; i++) {\n // This needs to be able to be converted back to a bit stream in\n // BitData. See BitData.fromLongArrayTag().\n data.push(bd.getInt64LE());\n }\n\n debugLogFromBinaryData(`LONG_ARRAY, name ${name}, data ${data}`);\n\n return new NbtLongArray(data, name);\n }\n\n constructor(data: bigint[], name?: string) {\n super(NbtTagType.LONG_ARRAY, data, name);\n }\n\n toObject() {\n return {\n type: this.type,\n longArray: this.data.map((v) => v.toString()),\n };\n }\n\n toSnbt() {\n return `[L;${this.data.map((v) => v.toString()).join(', ')}]`;\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BinaryData } from '../lib/binary-data';
|
|
2
|
+
import { NbtBase } from './nbt-base';
|
|
3
|
+
import { NbtTagType } from './nbt-tag-type';
|
|
4
|
+
export declare class NbtLong extends NbtBase<bigint> {
|
|
5
|
+
static fromBinaryData(bd: BinaryData, name?: string): NbtLong;
|
|
6
|
+
constructor(data: bigint, name?: string);
|
|
7
|
+
toObject(): {
|
|
8
|
+
type: NbtTagType;
|
|
9
|
+
long: string;
|
|
10
|
+
};
|
|
11
|
+
toSnbt(): string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=nbt-long.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nbt-long.d.ts","sourceRoot":"","sources":["../../src/nbt/nbt-long.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI5C,qBAAa,OAAQ,SAAQ,OAAO,CAAC,MAAM,CAAC;IACxC,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO;gBAQjD,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAIvC,QAAQ;;;;IAOR,MAAM;CAGT"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { NbtBase } from './nbt-base';
|
|
3
|
+
import { NbtTagType } from './nbt-tag-type';
|
|
4
|
+
const debugLogFromBinaryData = debug('nbt:long:from-binary-data');
|
|
5
|
+
export class NbtLong extends NbtBase {
|
|
6
|
+
static fromBinaryData(bd, name) {
|
|
7
|
+
name ??= NbtLong.readName(bd);
|
|
8
|
+
const data = bd.getInt64LE();
|
|
9
|
+
debugLogFromBinaryData(`LONG, name ${name}, data ${data}`);
|
|
10
|
+
return new NbtLong(data, name);
|
|
11
|
+
}
|
|
12
|
+
constructor(data, name) {
|
|
13
|
+
super(NbtTagType.LONG, data, name);
|
|
14
|
+
}
|
|
15
|
+
toObject() {
|
|
16
|
+
return {
|
|
17
|
+
type: this.type,
|
|
18
|
+
long: this.data.toString(),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
toSnbt() {
|
|
22
|
+
return `${this.data}l`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=nbt-long.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nbt-long.js","sourceRoot":"","sources":["../../src/nbt/nbt-long.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,sBAAsB,GAAG,KAAK,CAAC,2BAA2B,CAAC,CAAC;AAElE,MAAM,OAAO,OAAQ,SAAQ,OAAe;IACxC,MAAM,CAAC,cAAc,CAAC,EAAc,EAAE,IAAa;QAC/C,IAAI,KAAK,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC9B,MAAM,IAAI,GAAG,EAAE,CAAC,UAAU,EAAE,CAAC;QAC7B,sBAAsB,CAAC,cAAc,IAAI,UAAU,IAAI,EAAE,CAAC,CAAC;QAE3D,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,YAAY,IAAY,EAAE,IAAa;QACnC,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,QAAQ;QACJ,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;SAC7B,CAAC;IACN,CAAC;IAED,MAAM;QACF,OAAO,GAAG,IAAI,CAAC,IAAI,GAAG,CAAC;IAC3B,CAAC;CACJ","sourcesContent":["import debug from 'debug';\nimport { BinaryData } from '../lib/binary-data';\nimport { NbtBase } from './nbt-base';\nimport { NbtTagType } from './nbt-tag-type';\n\nconst debugLogFromBinaryData = debug('nbt:long:from-binary-data');\n\nexport class NbtLong extends NbtBase<bigint> {\n static fromBinaryData(bd: BinaryData, name?: string): NbtLong {\n name ??= NbtLong.readName(bd);\n const data = bd.getInt64LE();\n debugLogFromBinaryData(`LONG, name ${name}, data ${data}`);\n\n return new NbtLong(data, name);\n }\n\n constructor(data: bigint, name?: string) {\n super(NbtTagType.LONG, data, name);\n }\n\n toObject() {\n return {\n type: this.type,\n long: this.data.toString(),\n };\n }\n\n toSnbt() {\n return `${this.data}l`;\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BinaryData } from '../lib/binary-data';
|
|
2
|
+
import { NbtBase } from './nbt-base';
|
|
3
|
+
import { NbtTagType } from './nbt-tag-type';
|
|
4
|
+
export declare class NbtShort extends NbtBase<number> {
|
|
5
|
+
static fromBinaryData(bd: BinaryData, name?: string): NbtShort;
|
|
6
|
+
constructor(data: number, name?: string);
|
|
7
|
+
toObject(): {
|
|
8
|
+
type: NbtTagType;
|
|
9
|
+
short: number;
|
|
10
|
+
};
|
|
11
|
+
toSnbt(): string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=nbt-short.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nbt-short.d.ts","sourceRoot":"","sources":["../../src/nbt/nbt-short.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI5C,qBAAa,QAAS,SAAQ,OAAO,CAAC,MAAM,CAAC;IACzC,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ;gBAQlD,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAIvC,QAAQ;;;;IAOR,MAAM;CAGT"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { NbtBase } from './nbt-base';
|
|
3
|
+
import { NbtTagType } from './nbt-tag-type';
|
|
4
|
+
const debugLogFromBinaryData = debug('nbt:short:from-binary-data');
|
|
5
|
+
export class NbtShort extends NbtBase {
|
|
6
|
+
static fromBinaryData(bd, name) {
|
|
7
|
+
name ??= NbtShort.readName(bd);
|
|
8
|
+
const data = bd.getShort();
|
|
9
|
+
debugLogFromBinaryData(`SHORT, name ${name}, data ${data}`);
|
|
10
|
+
return new NbtShort(data, name);
|
|
11
|
+
}
|
|
12
|
+
constructor(data, name) {
|
|
13
|
+
super(NbtTagType.SHORT, data, name);
|
|
14
|
+
}
|
|
15
|
+
toObject() {
|
|
16
|
+
return {
|
|
17
|
+
type: this.type,
|
|
18
|
+
short: this.data,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
toSnbt() {
|
|
22
|
+
return `${this.data}s`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=nbt-short.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nbt-short.js","sourceRoot":"","sources":["../../src/nbt/nbt-short.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,sBAAsB,GAAG,KAAK,CAAC,4BAA4B,CAAC,CAAC;AAEnE,MAAM,OAAO,QAAS,SAAQ,OAAe;IACzC,MAAM,CAAC,cAAc,CAAC,EAAc,EAAE,IAAa;QAC/C,IAAI,KAAK,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC/B,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;QAC3B,sBAAsB,CAAC,eAAe,IAAI,UAAU,IAAI,EAAE,CAAC,CAAC;QAE5D,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,YAAY,IAAY,EAAE,IAAa;QACnC,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,QAAQ;QACJ,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,IAAI;SACnB,CAAC;IACN,CAAC;IAED,MAAM;QACF,OAAO,GAAG,IAAI,CAAC,IAAI,GAAG,CAAC;IAC3B,CAAC;CACJ","sourcesContent":["import debug from 'debug';\nimport { BinaryData } from '../lib/binary-data';\nimport { NbtBase } from './nbt-base';\nimport { NbtTagType } from './nbt-tag-type';\n\nconst debugLogFromBinaryData = debug('nbt:short:from-binary-data');\n\nexport class NbtShort extends NbtBase<number> {\n static fromBinaryData(bd: BinaryData, name?: string): NbtShort {\n name ??= NbtShort.readName(bd);\n const data = bd.getShort();\n debugLogFromBinaryData(`SHORT, name ${name}, data ${data}`);\n\n return new NbtShort(data, name);\n }\n\n constructor(data: number, name?: string) {\n super(NbtTagType.SHORT, data, name);\n }\n\n toObject() {\n return {\n type: this.type,\n short: this.data,\n };\n }\n\n toSnbt() {\n return `${this.data}s`;\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BinaryData } from '../lib/binary-data';
|
|
2
|
+
import { NbtBase } from './nbt-base';
|
|
3
|
+
import { NbtTagType } from './nbt-tag-type';
|
|
4
|
+
export declare class NbtString extends NbtBase<string> {
|
|
5
|
+
static fromBinaryData(bd: BinaryData, name?: string): NbtString;
|
|
6
|
+
constructor(data: string, name?: string);
|
|
7
|
+
toObject(): {
|
|
8
|
+
type: NbtTagType;
|
|
9
|
+
string: string;
|
|
10
|
+
};
|
|
11
|
+
toSnbt(): string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=nbt-string.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nbt-string.d.ts","sourceRoot":"","sources":["../../src/nbt/nbt-string.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI5C,qBAAa,SAAU,SAAQ,OAAO,CAAC,MAAM,CAAC;IAC1C,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS;gBAWnD,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAIvC,QAAQ;;;;IAOR,MAAM;CAIT"}
|