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.
Files changed (231) hide show
  1. package/.editorconfig +14 -0
  2. package/.prettierrc +4 -0
  3. package/README.md +373 -0
  4. package/dist/bin/mca-chunks.d.ts +3 -0
  5. package/dist/bin/mca-chunks.d.ts.map +1 -0
  6. package/dist/bin/mca-chunks.js +43 -0
  7. package/dist/bin/mca-chunks.js.map +1 -0
  8. package/dist/bin/mca-find-chunks-with-signs.d.ts +3 -0
  9. package/dist/bin/mca-find-chunks-with-signs.d.ts.map +1 -0
  10. package/dist/bin/mca-find-chunks-with-signs.js +79 -0
  11. package/dist/bin/mca-find-chunks-with-signs.js.map +1 -0
  12. package/dist/bin/mca-json.d.ts +3 -0
  13. package/dist/bin/mca-json.d.ts.map +1 -0
  14. package/dist/bin/mca-json.js +73 -0
  15. package/dist/bin/mca-json.js.map +1 -0
  16. package/dist/bin/mca-trim-chunks-without-signs.d.ts +3 -0
  17. package/dist/bin/mca-trim-chunks-without-signs.d.ts.map +1 -0
  18. package/dist/bin/mca-trim-chunks-without-signs.js +117 -0
  19. package/dist/bin/mca-trim-chunks-without-signs.js.map +1 -0
  20. package/dist/bin/nbt-get-player-location.d.ts +3 -0
  21. package/dist/bin/nbt-get-player-location.d.ts.map +1 -0
  22. package/dist/bin/nbt-get-player-location.js +83 -0
  23. package/dist/bin/nbt-get-player-location.js.map +1 -0
  24. package/dist/bin/nbt-json.d.ts +3 -0
  25. package/dist/bin/nbt-json.d.ts.map +1 -0
  26. package/dist/bin/nbt-json.js +64 -0
  27. package/dist/bin/nbt-json.js.map +1 -0
  28. package/dist/block/banner.d.ts +13 -0
  29. package/dist/block/banner.d.ts.map +1 -0
  30. package/dist/block/banner.js +28 -0
  31. package/dist/block/banner.js.map +1 -0
  32. package/dist/block/barrel.d.ts +17 -0
  33. package/dist/block/barrel.d.ts.map +1 -0
  34. package/dist/block/barrel.js +21 -0
  35. package/dist/block/barrel.js.map +1 -0
  36. package/dist/block/beacon.d.ts +14 -0
  37. package/dist/block/beacon.d.ts.map +1 -0
  38. package/dist/block/beacon.js +14 -0
  39. package/dist/block/beacon.js.map +1 -0
  40. package/dist/block/bed.d.ts +4 -0
  41. package/dist/block/bed.d.ts.map +1 -0
  42. package/dist/block/bed.js +4 -0
  43. package/dist/block/bed.js.map +1 -0
  44. package/dist/block/beehive.d.ts +9 -0
  45. package/dist/block/beehive.d.ts.map +1 -0
  46. package/dist/block/beehive.js +10 -0
  47. package/dist/block/beehive.js.map +1 -0
  48. package/dist/block/bell.d.ts +4 -0
  49. package/dist/block/bell.d.ts.map +1 -0
  50. package/dist/block/bell.js +4 -0
  51. package/dist/block/bell.js.map +1 -0
  52. package/dist/block/block.d.ts +23 -0
  53. package/dist/block/block.d.ts.map +1 -0
  54. package/dist/block/block.js +49 -0
  55. package/dist/block/block.js.map +1 -0
  56. package/dist/block/generic.d.ts +10 -0
  57. package/dist/block/generic.d.ts.map +1 -0
  58. package/dist/block/generic.js +14 -0
  59. package/dist/block/generic.js.map +1 -0
  60. package/dist/block/has-entity-data.d.ts +8 -0
  61. package/dist/block/has-entity-data.d.ts.map +1 -0
  62. package/dist/block/has-entity-data.js +12 -0
  63. package/dist/block/has-entity-data.js.map +1 -0
  64. package/dist/block/mixins/custom-name.d.ts +5 -0
  65. package/dist/block/mixins/custom-name.d.ts.map +1 -0
  66. package/dist/block/mixins/custom-name.js +7 -0
  67. package/dist/block/mixins/custom-name.js.map +1 -0
  68. package/dist/block/mixins/lock.d.ts +5 -0
  69. package/dist/block/mixins/lock.d.ts.map +1 -0
  70. package/dist/block/mixins/lock.js +7 -0
  71. package/dist/block/mixins/lock.js.map +1 -0
  72. package/dist/block/mixins/mixin.d.ts +27 -0
  73. package/dist/block/mixins/mixin.d.ts.map +1 -0
  74. package/dist/block/mixins/mixin.js +36 -0
  75. package/dist/block/mixins/mixin.js.map +1 -0
  76. package/dist/block/sign.d.ts +15 -0
  77. package/dist/block/sign.d.ts.map +1 -0
  78. package/dist/block/sign.js +91 -0
  79. package/dist/block/sign.js.map +1 -0
  80. package/dist/index.d.ts +39 -0
  81. package/dist/index.d.ts.map +1 -0
  82. package/dist/index.js +39 -0
  83. package/dist/index.js.map +1 -0
  84. package/dist/lib/anvil.d.ts +54 -0
  85. package/dist/lib/anvil.d.ts.map +1 -0
  86. package/dist/lib/anvil.js +141 -0
  87. package/dist/lib/anvil.js.map +1 -0
  88. package/dist/lib/binary-data.d.ts +48 -0
  89. package/dist/lib/binary-data.d.ts.map +1 -0
  90. package/dist/lib/binary-data.js +188 -0
  91. package/dist/lib/binary-data.js.map +1 -0
  92. package/dist/lib/bit-data.d.ts +16 -0
  93. package/dist/lib/bit-data.d.ts.map +1 -0
  94. package/dist/lib/bit-data.js +75 -0
  95. package/dist/lib/bit-data.js.map +1 -0
  96. package/dist/lib/block-data.d.ts +20 -0
  97. package/dist/lib/block-data.d.ts.map +1 -0
  98. package/dist/lib/block-data.js +125 -0
  99. package/dist/lib/block-data.js.map +1 -0
  100. package/dist/lib/chunk.d.ts +112 -0
  101. package/dist/lib/chunk.d.ts.map +1 -0
  102. package/dist/lib/chunk.js +299 -0
  103. package/dist/lib/chunk.js.map +1 -0
  104. package/dist/nbt/nbt-base.d.ts +20 -0
  105. package/dist/nbt/nbt-base.d.ts.map +1 -0
  106. package/dist/nbt/nbt-base.js +30 -0
  107. package/dist/nbt/nbt-base.js.map +1 -0
  108. package/dist/nbt/nbt-byte-array.d.ts +13 -0
  109. package/dist/nbt/nbt-byte-array.d.ts.map +1 -0
  110. package/dist/nbt/nbt-byte-array.js +30 -0
  111. package/dist/nbt/nbt-byte-array.js.map +1 -0
  112. package/dist/nbt/nbt-byte.d.ts +13 -0
  113. package/dist/nbt/nbt-byte.d.ts.map +1 -0
  114. package/dist/nbt/nbt-byte.js +25 -0
  115. package/dist/nbt/nbt-byte.js.map +1 -0
  116. package/dist/nbt/nbt-compound.d.ts +15 -0
  117. package/dist/nbt/nbt-compound.d.ts.map +1 -0
  118. package/dist/nbt/nbt-compound.js +68 -0
  119. package/dist/nbt/nbt-compound.js.map +1 -0
  120. package/dist/nbt/nbt-double.d.ts +13 -0
  121. package/dist/nbt/nbt-double.d.ts.map +1 -0
  122. package/dist/nbt/nbt-double.js +25 -0
  123. package/dist/nbt/nbt-double.js.map +1 -0
  124. package/dist/nbt/nbt-end.d.ts +11 -0
  125. package/dist/nbt/nbt-end.d.ts.map +1 -0
  126. package/dist/nbt/nbt-end.js +22 -0
  127. package/dist/nbt/nbt-end.js.map +1 -0
  128. package/dist/nbt/nbt-float.d.ts +13 -0
  129. package/dist/nbt/nbt-float.d.ts.map +1 -0
  130. package/dist/nbt/nbt-float.js +25 -0
  131. package/dist/nbt/nbt-float.js.map +1 -0
  132. package/dist/nbt/nbt-int-array.d.ts +13 -0
  133. package/dist/nbt/nbt-int-array.d.ts.map +1 -0
  134. package/dist/nbt/nbt-int-array.js +30 -0
  135. package/dist/nbt/nbt-int-array.js.map +1 -0
  136. package/dist/nbt/nbt-int.d.ts +13 -0
  137. package/dist/nbt/nbt-int.d.ts.map +1 -0
  138. package/dist/nbt/nbt-int.js +25 -0
  139. package/dist/nbt/nbt-int.js.map +1 -0
  140. package/dist/nbt/nbt-list.d.ts +17 -0
  141. package/dist/nbt/nbt-list.d.ts.map +1 -0
  142. package/dist/nbt/nbt-list.js +70 -0
  143. package/dist/nbt/nbt-list.js.map +1 -0
  144. package/dist/nbt/nbt-long-array.d.ts +13 -0
  145. package/dist/nbt/nbt-long-array.d.ts.map +1 -0
  146. package/dist/nbt/nbt-long-array.js +32 -0
  147. package/dist/nbt/nbt-long-array.js.map +1 -0
  148. package/dist/nbt/nbt-long.d.ts +13 -0
  149. package/dist/nbt/nbt-long.d.ts.map +1 -0
  150. package/dist/nbt/nbt-long.js +25 -0
  151. package/dist/nbt/nbt-long.js.map +1 -0
  152. package/dist/nbt/nbt-short.d.ts +13 -0
  153. package/dist/nbt/nbt-short.d.ts.map +1 -0
  154. package/dist/nbt/nbt-short.js +25 -0
  155. package/dist/nbt/nbt-short.js.map +1 -0
  156. package/dist/nbt/nbt-string.d.ts +13 -0
  157. package/dist/nbt/nbt-string.d.ts.map +1 -0
  158. package/dist/nbt/nbt-string.js +27 -0
  159. package/dist/nbt/nbt-string.js.map +1 -0
  160. package/dist/nbt/nbt-tag-type.d.ts +16 -0
  161. package/dist/nbt/nbt-tag-type.d.ts.map +1 -0
  162. package/dist/nbt/nbt-tag-type.js +17 -0
  163. package/dist/nbt/nbt-tag-type.js.map +1 -0
  164. package/dist/nbt/nbt.d.ts +11 -0
  165. package/dist/nbt/nbt.d.ts.map +1 -0
  166. package/dist/nbt/nbt.js +57 -0
  167. package/dist/nbt/nbt.js.map +1 -0
  168. package/dist/nbt/snbt-data.d.ts +18 -0
  169. package/dist/nbt/snbt-data.d.ts.map +1 -0
  170. package/dist/nbt/snbt-data.js +34 -0
  171. package/dist/nbt/snbt-data.js.map +1 -0
  172. package/dist/nbt/snbt-parse.d.ts +3 -0
  173. package/dist/nbt/snbt-parse.d.ts.map +1 -0
  174. package/dist/nbt/snbt-parse.js +201 -0
  175. package/dist/nbt/snbt-parse.js.map +1 -0
  176. package/dist/nbt/snbt-to-nbt.d.ts +7 -0
  177. package/dist/nbt/snbt-to-nbt.d.ts.map +1 -0
  178. package/dist/nbt/snbt-to-nbt.js +178 -0
  179. package/dist/nbt/snbt-to-nbt.js.map +1 -0
  180. package/dist/types/coords.d.ts +3 -0
  181. package/dist/types/coords.d.ts.map +1 -0
  182. package/dist/types/coords.js +2 -0
  183. package/dist/types/coords.js.map +1 -0
  184. package/package.json +28 -0
  185. package/src/bin/mca-chunks.ts +54 -0
  186. package/src/bin/mca-find-chunks-with-signs.ts +109 -0
  187. package/src/bin/mca-json.ts +96 -0
  188. package/src/bin/mca-trim-chunks-without-signs.ts +146 -0
  189. package/src/bin/nbt-get-player-location.ts +102 -0
  190. package/src/bin/nbt-json.ts +85 -0
  191. package/src/block/banner.ts +50 -0
  192. package/src/block/barrel.ts +34 -0
  193. package/src/block/beacon.ts +20 -0
  194. package/src/block/bed.ts +3 -0
  195. package/src/block/beehive.ts +17 -0
  196. package/src/block/bell.ts +3 -0
  197. package/src/block/block.ts +62 -0
  198. package/src/block/generic.ts +14 -0
  199. package/src/block/has-entity-data.ts +20 -0
  200. package/src/block/mixins/custom-name.ts +8 -0
  201. package/src/block/mixins/lock.ts +8 -0
  202. package/src/block/mixins/mixin.ts +53 -0
  203. package/src/block/sign.ts +121 -0
  204. package/src/index.ts +38 -0
  205. package/src/lib/anvil.ts +178 -0
  206. package/src/lib/binary-data.ts +247 -0
  207. package/src/lib/bit-data.ts +101 -0
  208. package/src/lib/block-data.ts +180 -0
  209. package/src/lib/chunk.ts +389 -0
  210. package/src/nbt/nbt-base.ts +38 -0
  211. package/src/nbt/nbt-byte-array.ts +38 -0
  212. package/src/nbt/nbt-byte.ts +31 -0
  213. package/src/nbt/nbt-compound.ts +95 -0
  214. package/src/nbt/nbt-double.ts +31 -0
  215. package/src/nbt/nbt-end.ts +27 -0
  216. package/src/nbt/nbt-float.ts +31 -0
  217. package/src/nbt/nbt-int-array.ts +38 -0
  218. package/src/nbt/nbt-int.ts +31 -0
  219. package/src/nbt/nbt-list.ts +103 -0
  220. package/src/nbt/nbt-long-array.ts +40 -0
  221. package/src/nbt/nbt-long.ts +31 -0
  222. package/src/nbt/nbt-short.ts +31 -0
  223. package/src/nbt/nbt-string.ts +35 -0
  224. package/src/nbt/nbt-tag-type.ts +15 -0
  225. package/src/nbt/nbt.ts +70 -0
  226. package/src/nbt/snbt-data.ts +70 -0
  227. package/src/nbt/snbt-parse.ts +256 -0
  228. package/src/nbt/snbt-to-nbt.ts +219 -0
  229. package/src/types/coords.ts +2 -0
  230. package/src/types/neodoc.d.ts +28 -0
  231. package/tsconfig.json +25 -0
@@ -0,0 +1,117 @@
1
+ #!/usr/bin/env node
2
+ import debug from 'debug';
3
+ import neodoc from 'neodoc';
4
+ import { Anvil } from '../lib/anvil';
5
+ import { Sign } from '../block/sign';
6
+ import { readFile, writeFile } from 'node:fs/promises';
7
+ const debugLog = debug('mca-trim-chunks-without-signs');
8
+ const args = neodoc.run(`Usage: mca-trim-chunks-without-signs [OPTIONS] MCA_FILE...
9
+
10
+ Removes chunks from MCA files that do not contain a matching sign block. Signs
11
+ need to have at least one letter or number on them to differentiate them from
12
+ naturally generated signs.
13
+
14
+ This does not change the file size. Similar to deleting a file on a hard drive,
15
+ the space is marked as free but not overwritten.
16
+
17
+ Options:
18
+ -h, --help Show this message.
19
+ -n, --dry-run Do not write changes to the file.
20
+ --preserve CHUNK_COORDINATES...
21
+ Do not remove chunks with these coordinates. Coordinates
22
+ are in the format "x,z". May be specified multiple times.
23
+ -v, --verbose Show more information during processing.
24
+ `, {
25
+ argv: [...process.argv].slice(2),
26
+ laxPlacement: true,
27
+ });
28
+ if (!args.MCA_FILE?.length) {
29
+ console.error('No files specified.');
30
+ process.exit(1);
31
+ }
32
+ if (!args['--preserve']) {
33
+ args['--preserve'] = [];
34
+ }
35
+ if (args['--preserve'].length) {
36
+ console.log(`Preserving coordinates: ${args['--preserve'].join(' ')}`);
37
+ }
38
+ for (const file of args.MCA_FILE) {
39
+ try {
40
+ await processFile(file);
41
+ }
42
+ catch (e) {
43
+ console.error(`Error processing file ${file}: ${e}`);
44
+ process.exit(1);
45
+ }
46
+ }
47
+ async function processFile(filename) {
48
+ debugLog(`Reading file: ${filename}`);
49
+ if (args['--verbose']) {
50
+ console.log(`Reading file: ${filename}`);
51
+ }
52
+ const contents = await readFile(filename);
53
+ const anvil = Anvil.fromBuffer(contents.buffer);
54
+ const chunks = anvil.getAllChunks();
55
+ let changes = 0;
56
+ const preservedCoordinates = new Set(args['--preserve']);
57
+ for (const chunk of chunks) {
58
+ const chunkKey = chunk.chunkKey() || '';
59
+ if (preservedCoordinates.has(chunkKey)) {
60
+ debugLog(`Preserving chunk (via command-line): ${chunkKey}`);
61
+ if (args['--verbose']) {
62
+ console.log(`Preserving chunk (via command-line): ${chunkKey}`);
63
+ }
64
+ }
65
+ else if (processChunk(chunk)) {
66
+ debugLog(`Preserving chunk (sign detected): ${chunkKey}`);
67
+ if (args['--verbose']) {
68
+ console.log(`Preserving chunk (sign detected): ${chunkKey}`);
69
+ }
70
+ }
71
+ else {
72
+ debugLog(`Removing chunk: ${chunkKey}`);
73
+ anvil.deleteChunk(chunk);
74
+ changes += 1;
75
+ }
76
+ }
77
+ if (args['--verbose']) {
78
+ console.log(`Chunks removed: ${changes}/${chunks.length}`);
79
+ }
80
+ if (changes) {
81
+ if (args['--dry-run']) {
82
+ console.log(`DRY RUN: Would write changes to file: ${filename}`);
83
+ }
84
+ else {
85
+ console.log(`Writing changes to file: ${filename}`);
86
+ const modifiedBuffer = Buffer.from(anvil.buffer());
87
+ await writeFile(filename, modifiedBuffer);
88
+ }
89
+ }
90
+ }
91
+ function processChunk(chunk) {
92
+ const blockNames = chunk.uniqueBlockNames();
93
+ for (const blockName of blockNames) {
94
+ if (blockName.match(/^minecraft:.+_sign$/)) {
95
+ debugLog(`Found sign: ${blockName}`);
96
+ for (const coords of chunk.findBlocksByName(blockName)) {
97
+ const block = chunk.getBlock(coords);
98
+ if (!(block instanceof Sign)) {
99
+ throw new Error(`Block is supposed to be a sign: ${block.name}`);
100
+ }
101
+ const front = block.frontText();
102
+ const back = block.backText();
103
+ debugLog(`Front: ${JSON.stringify(front)}`);
104
+ debugLog(`Back: ${JSON.stringify(back)}`);
105
+ if ([...front, ...(back || [])].join('').match(/[a-z0-9]/i)) {
106
+ debugLog(`Found a user-created sign. Preserving chunk.`);
107
+ if (args['--verbose']) {
108
+ console.log(`Found a user-created sign: ${JSON.stringify(front)} and ${JSON.stringify(back)}`);
109
+ }
110
+ return true;
111
+ }
112
+ }
113
+ }
114
+ }
115
+ return false;
116
+ }
117
+ //# sourceMappingURL=mca-trim-chunks-without-signs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mca-trim-chunks-without-signs.js","source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C,IAAI,EAAE,CAAC,CAAC;gBACrE,CAAC;gBAED,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;gBAChC,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;gBAC9B,QAAQ,CAAC,UAAU,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBAC5C,QAAQ,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAE1C,IAAI,CAAC,GAAG,KAAK,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC;oBAC1D,QAAQ,CAAC,8CAA8C,CAAC,CAAC;oBAEzD,IAAI,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;wBACpB,OAAO,CAAC,GAAG,CAAC,8BAA8B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;oBACnG,CAAC;oBAED,OAAO,IAAI,CAAC;gBAChB,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport debug from 'debug';\nimport neodoc from 'neodoc';\nimport { Anvil } from '../lib/anvil';\nimport { Chunk } from '../lib/chunk';\nimport { Sign } from '../block/sign';\nimport { readFile, writeFile } from 'node:fs/promises';\n\nconst debugLog = debug('mca-trim-chunks-without-signs');\nconst args: {\n '--dry-run'?: boolean;\n '--preserve'?: string[];\n '--verbose'?: boolean;\n 'MCA_FILE'?: string[];\n} = neodoc.run(\n`Usage: mca-trim-chunks-without-signs [OPTIONS] MCA_FILE...\n\nRemoves chunks from MCA files that do not contain a matching sign block. Signs\nneed to have at least one letter or number on them to differentiate them from\nnaturally generated signs.\n\nThis does not change the file size. Similar to deleting a file on a hard drive,\nthe space is marked as free but not overwritten.\n\nOptions:\n -h, --help Show this message.\n -n, --dry-run Do not write changes to the file.\n --preserve CHUNK_COORDINATES...\n Do not remove chunks with these coordinates. Coordinates\n are in the format \"x,z\". May be specified multiple times.\n -v, --verbose Show more information during processing.\n`,\n {\n argv: [...process.argv].slice(2),\n laxPlacement: true,\n }\n);\n\nif (!args.MCA_FILE?.length) {\n console.error('No files specified.');\n process.exit(1);\n}\n\nif (!args['--preserve']) {\n args['--preserve'] = [];\n}\n\nif (args['--preserve'].length) {\n console.log(`Preserving coordinates: ${args['--preserve'].join(' ')}`);\n}\n\nfor (const file of args.MCA_FILE) {\n try {\n await processFile(file);\n } catch (e) {\n console.error(`Error processing file ${file}: ${e}`);\n\n process.exit(1);\n }\n}\n\nasync function processFile(filename: string) {\n debugLog(`Reading file: ${filename}`);\n\n if (args['--verbose']) {\n console.log(`Reading file: ${filename}`);\n }\n\n const contents = await readFile(filename);\n const anvil = Anvil.fromBuffer(contents.buffer);\n const chunks = anvil.getAllChunks();\n let changes = 0;\n const preservedCoordinates = new Set(args['--preserve']);\n\n for (const chunk of chunks) {\n const chunkKey = chunk.chunkKey() || '';\n\n if (preservedCoordinates.has(chunkKey)) {\n debugLog(`Preserving chunk (via command-line): ${chunkKey}`);\n\n if (args['--verbose']) {\n console.log(`Preserving chunk (via command-line): ${chunkKey}`);\n }\n } else if (processChunk(chunk)) {\n debugLog(`Preserving chunk (sign detected): ${chunkKey}`);\n\n if (args['--verbose']) {\n console.log(`Preserving chunk (sign detected): ${chunkKey}`);\n }\n } else {\n debugLog(`Removing chunk: ${chunkKey}`);\n anvil.deleteChunk(chunk);\n changes += 1;\n }\n }\n\n if (args['--verbose']) {\n console.log(`Chunks removed: ${changes}/${chunks.length}`);\n }\n\n if (changes) {\n if (args['--dry-run']) {\n console.log(`DRY RUN: Would write changes to file: ${filename}`);\n } else {\n console.log(`Writing changes to file: ${filename}`);\n const modifiedBuffer = Buffer.from(anvil.buffer());\n await writeFile(filename, modifiedBuffer);\n }\n }\n}\n\nfunction processChunk(chunk: Chunk): boolean {\n const blockNames = chunk.uniqueBlockNames();\n\n for (const blockName of blockNames) {\n if (blockName.match(/^minecraft:.+_sign$/)) {\n debugLog(`Found sign: ${blockName}`);\n\n for (const coords of chunk.findBlocksByName(blockName)) {\n const block = chunk.getBlock(coords);\n\n if (!(block instanceof Sign)) {\n throw new Error(`Block is supposed to be a sign: ${block.name}`);\n }\n\n const front = block.frontText();\n const back = block.backText();\n debugLog(`Front: ${JSON.stringify(front)}`);\n debugLog(`Back: ${JSON.stringify(back)}`);\n\n if ([...front, ...(back || [])].join('').match(/[a-z0-9]/i)) {\n debugLog(`Found a user-created sign. Preserving chunk.`);\n\n if (args['--verbose']) {\n console.log(`Found a user-created sign: ${JSON.stringify(front)} and ${JSON.stringify(back)}`);\n }\n\n return true;\n }\n }\n }\n }\n\n return false;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=nbt-get-player-location.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nbt-get-player-location.d.ts","sourceRoot":"","sources":["../../src/bin/nbt-get-player-location.ts"],"names":[],"mappings":""}
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env node
2
+ import debug from 'debug';
3
+ import getStdin from 'get-stdin';
4
+ import neodoc from 'neodoc';
5
+ import { inflate } from 'pako';
6
+ import { Nbt } from '../nbt/nbt';
7
+ import { readFile } from 'node:fs/promises';
8
+ const debugLog = debug('mca-trim-chunks-without-signs');
9
+ main();
10
+ async function main() {
11
+ const args = neodoc.run(`Usage: nbt-get-player-locations NBT_FILE...
12
+
13
+ Scans a player NBT data file for the player location and prints it to stdout.
14
+ NBT files can be compressed or uncompressed and this tool can handle both. If the filename is "-" or not provided, this will read from stdin.
15
+
16
+ The output shows the following tab delimited fields:
17
+
18
+ * Dimension: "minecraft:overworld", "minecraft:the_nether", or "minecraft:the_end"
19
+ * X: The player's X coordinate, rounded
20
+ * Y: The player's Y coordinate, rounded
21
+ * Z: The player's Z coordinate, rounded
22
+ * chunkX: The player's chunk X coordinate
23
+ * chunkZ: The player's chunk Z coordinate
24
+
25
+ Options:
26
+ -h, --help Show this message.
27
+ `, {
28
+ argv: [...process.argv].slice(2),
29
+ laxPlacement: true,
30
+ });
31
+ if (!args.NBT_FILE?.length) {
32
+ args.NBT_FILE = ['-'];
33
+ }
34
+ for (const file of args.NBT_FILE) {
35
+ try {
36
+ await processFile(file);
37
+ }
38
+ catch (e) {
39
+ console.error(`Error processing file ${file}: ${e}`);
40
+ process.exit(1);
41
+ }
42
+ }
43
+ }
44
+ async function readInput(filename) {
45
+ if (!filename || filename === '-') {
46
+ debugLog(`Reading from stdin`);
47
+ return await getStdin.buffer();
48
+ }
49
+ debugLog(`Reading file: ${filename}`);
50
+ return readFile(filename);
51
+ }
52
+ async function processFile(filename) {
53
+ const inputBuffer = await readInput(filename);
54
+ if (inputBuffer.length === 0) {
55
+ if (filename === '-') {
56
+ console.error('Input (stdin) is empty.');
57
+ }
58
+ else {
59
+ console.error(`Input file is empty: ${filename}`);
60
+ }
61
+ console.error('Aborting. Use --help for usage.');
62
+ process.exit(1);
63
+ }
64
+ let buffer = inputBuffer.buffer;
65
+ try {
66
+ buffer = inflate(inputBuffer).buffer;
67
+ }
68
+ catch (_ignore) { }
69
+ const nbt = Nbt.fromBuffer(buffer);
70
+ const dimension = nbt.findChild('Dimension')?.data;
71
+ const x = nbt.findChild('Pos/0')?.data;
72
+ const y = nbt.findChild('Pos/1')?.data;
73
+ const z = nbt.findChild('Pos/2')?.data;
74
+ if (typeof dimension !== 'string' || typeof x !== 'number' || typeof y !== 'number' || typeof z !== 'number') {
75
+ console.error(`NBT file ${filename} does not contain valid player location data.`);
76
+ process.exit(1);
77
+ }
78
+ const chunkX = Math.floor(x / 16);
79
+ const chunkZ = Math.floor(z / 16);
80
+ const output = [dimension, Math.round(x), Math.round(y), Math.round(z), chunkX, chunkZ];
81
+ console.log(output.join('\t'));
82
+ }
83
+ //# sourceMappingURL=nbt-get-player-location.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nbt-get-player-location.js","sourceRoot":"","sources":["../../src/bin/nbt-get-player-location.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,QAAQ,GAAG,KAAK,CAAC,+BAA+B,CAAC,CAAC;AACxD,IAAI,EAAE,CAAC;AAEP,KAAK,UAAU,IAAI;IACnB,MAAM,IAAI,GAEN,MAAM,CAAC,GAAG,CACd;;;;;;;;;;;;;;;;CAgBC,EACG;QACI,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QAChC,YAAY,EAAE,IAAI;KACrB,CACJ,CAAC;IAEE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC;YACD,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,OAAO,CAAC,KAAK,CAAC,yBAAyB,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC;YAErD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;IACL,CAAC;AACL,CAAC;AAED,KAAK,UAAU,SAAS,CAAC,QAA4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CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC;IAEvC,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC3G,OAAO,CAAC,KAAK,CAAC,YAAY,QAAQ,+CAA+C,CAAC,CAAC;QACnF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IAElC,MAAM,MAAM,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACxF,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACnC,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport debug from 'debug';\nimport getStdin from 'get-stdin';\nimport neodoc from 'neodoc';\nimport { inflate } from 'pako';\nimport { Nbt } from '../nbt/nbt';\nimport { readFile } from 'node:fs/promises';\n\nconst debugLog = debug('mca-trim-chunks-without-signs');\nmain();\n\nasync function main() {\nconst args: {\n 'NBT_FILE'?: string[];\n} = neodoc.run(\n`Usage: nbt-get-player-locations NBT_FILE...\n\nScans a player NBT data file for the player location and prints it to stdout.\nNBT files can be compressed or uncompressed and this tool can handle both. If the filename is \"-\" or not provided, this will read from stdin.\n\nThe output shows the following tab delimited fields:\n\n* Dimension: \"minecraft:overworld\", \"minecraft:the_nether\", or \"minecraft:the_end\"\n* X: The player's X coordinate, rounded\n* Y: The player's Y coordinate, rounded\n* Z: The player's Z coordinate, rounded\n* chunkX: The player's chunk X coordinate\n* chunkZ: The player's chunk Z coordinate\n\nOptions:\n -h, --help Show this message.\n`,\n {\n argv: [...process.argv].slice(2),\n laxPlacement: true,\n }\n);\n\n if (!args.NBT_FILE?.length) {\n args.NBT_FILE = ['-'];\n }\n\n for (const file of args.NBT_FILE) {\n try {\n await processFile(file);\n } catch (e) {\n console.error(`Error processing file ${file}: ${e}`);\n\n process.exit(1);\n }\n }\n}\n\nasync function readInput(filename: string | undefined) {\n if (!filename || filename === '-') {\n debugLog(`Reading from stdin`);\n return await getStdin.buffer();\n }\n\n debugLog(`Reading file: ${filename}`);\n\n return readFile(filename);\n}\n\nasync function processFile(filename: string) {\n const inputBuffer = await readInput(filename);\n\n if (inputBuffer.length === 0) {\n if (filename === '-') {\n console.error('Input (stdin) is empty.');\n } else {\n console.error(`Input file is empty: ${filename}`);\n }\n console.error('Aborting. Use --help for usage.');\n process.exit(1);\n }\n\n let buffer = inputBuffer.buffer as ArrayBufferLike;\n\n try {\n buffer = inflate(inputBuffer).buffer;\n } catch (_ignore) {}\n\n const nbt = Nbt.fromBuffer(buffer);\n\n const dimension = nbt.findChild('Dimension')?.data;\n const x = nbt.findChild('Pos/0')?.data;\n const y = nbt.findChild('Pos/1')?.data;\n const z = nbt.findChild('Pos/2')?.data;\n\n if (typeof dimension !== 'string' || typeof x !== 'number' || typeof y !== 'number' || typeof z !== 'number') {\n console.error(`NBT file ${filename} does not contain valid player location data.`);\n process.exit(1);\n }\n\n const chunkX = Math.floor(x / 16);\n const chunkZ = Math.floor(z / 16);\n\n const output = [dimension, Math.round(x), Math.round(y), Math.round(z), chunkX, chunkZ];\n console.log(output.join('\\t'));\n}\n"]}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=nbt-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nbt-json.d.ts","sourceRoot":"","sources":["../../src/bin/nbt-json.ts"],"names":[],"mappings":""}
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env node
2
+ import getStdin from 'get-stdin';
3
+ import neodoc from 'neodoc';
4
+ import { inflate } from 'pako';
5
+ import { Nbt } from '../nbt/nbt';
6
+ import { readFile, writeFile } from 'node:fs/promises';
7
+ async function readInput(filename) {
8
+ if (!filename || filename === '-') {
9
+ return await getStdin.buffer();
10
+ }
11
+ return readFile(filename);
12
+ }
13
+ const args = neodoc.run(`Usage: nbt-json [OPTIONS] [<input> [<output>]]
14
+
15
+ Shows NBT data in a JSON format. Both input and output are optional. If input
16
+ is not provided, this reads from stdin. If output is not provided, this writes
17
+ to stdout.
18
+
19
+ NBT files can be compressed or uncompressed. This tool can handle both. One
20
+ example NBT file is the player.dat file.
21
+
22
+ Options:
23
+ --compact Do not use pretty-printing in the JSON output.
24
+ --condense Condense arrays of bytes, ints, and longs to a single line.
25
+ This significantly cuts down on the size of the generated
26
+ JSON.
27
+ -h, --help Show this message.
28
+ `, {
29
+ argv: [...process.argv].slice(2),
30
+ laxPlacement: true,
31
+ });
32
+ readInput(args['<input>'])
33
+ .then((inputBuffer) => {
34
+ if (inputBuffer.length === 0) {
35
+ console.error('No input provided. Use --help for usage.');
36
+ process.exit(1);
37
+ }
38
+ let buffer = inputBuffer.buffer;
39
+ try {
40
+ buffer = inflate(inputBuffer).buffer;
41
+ }
42
+ catch (_ignore) { }
43
+ const nbt = Nbt.fromBuffer(buffer);
44
+ let jsonObject = nbt.toObject();
45
+ if (args['--compact']) {
46
+ return JSON.stringify(jsonObject);
47
+ }
48
+ let content = JSON.stringify(jsonObject, null, 4);
49
+ if (args['--condense']) {
50
+ content = content.replace(/: \[(\n\s*"?-?\d+"?,?)*\n\s*\]/g, (match) => {
51
+ return match.replace(/\n\s*/g, ' ');
52
+ });
53
+ }
54
+ return content;
55
+ })
56
+ .then((output) => {
57
+ if (args['<output>']) {
58
+ writeFile(args['<output>'], output);
59
+ }
60
+ else {
61
+ console.log(output);
62
+ }
63
+ });
64
+ //# sourceMappingURL=nbt-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nbt-json.js","sourceRoot":"","sources":["../../src/bin/nbt-json.ts"],"names":[],"mappings":";AAEA,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEvD,KAAK,UAAU,SAAS,CAAC,QAA4B;IACjD,IAAI,CAAC,QAAQ,IAAI,QAAQ,KAAK,GAAG,EAAE,CAAC;QAChC,OAAO,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAC;IACnC,CAAC;IAED,OAAO,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,IAAI,GAKN,MAAM,CAAC,GAAG,CACd;;;;;;;;;;;;;;;CAeC,EACG;IACI,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAChC,YAAY,EAAE,IAAI;CACrB,CACJ,CAAC;AAEF,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;KACrB,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE;IAClB,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED,IAAI,MAAM,GAAG,WAAW,CAAC,MAAyB,CAAC;IAEnD,IAAI,CAAC;QACD,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC;IACzC,CAAC;IAAC,OAAO,OAAO,EAAE,CAAC,CAAA,CAAC;IAEpB,MAAM,GAAG,GAAG,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAEnC,IAAI,UAAU,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;IAEhC,IAAI,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAElD,IAAI,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;QACrB,OAAO,GAAG,OAAO,CAAC,OAAO,CACrB,iCAAiC,EACjC,CAAC,KAAK,EAAE,EAAE;YACN,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QACxC,CAAC,CACJ,CAAC;IACN,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;KACD,IAAI,CAAC,CAAC,MAAc,EAAE,EAAE;IACrB,IAAI,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACnB,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;SAAM,CAAC;QACJ,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport getStdin from 'get-stdin';\nimport neodoc from 'neodoc';\nimport { inflate } from 'pako';\nimport { Nbt } from '../nbt/nbt';\nimport { readFile, writeFile } from 'node:fs/promises';\n\nasync function readInput(filename: string | undefined) {\n if (!filename || filename === '-') {\n return await getStdin.buffer();\n }\n\n return readFile(filename);\n}\n\nconst args: {\n '--compact'?: boolean;\n '--condense'?: boolean;\n '<input>'?: string;\n '<output>'?: string;\n} = neodoc.run(\n`Usage: nbt-json [OPTIONS] [<input> [<output>]]\n\nShows NBT data in a JSON format. Both input and output are optional. If input\nis not provided, this reads from stdin. If output is not provided, this writes\nto stdout.\n\nNBT files can be compressed or uncompressed. This tool can handle both. One\nexample NBT file is the player.dat file.\n\nOptions:\n --compact Do not use pretty-printing in the JSON output.\n --condense Condense arrays of bytes, ints, and longs to a single line.\n This significantly cuts down on the size of the generated\n JSON.\n -h, --help Show this message.\n`,\n {\n argv: [...process.argv].slice(2),\n laxPlacement: true,\n }\n);\n\nreadInput(args['<input>'])\n .then((inputBuffer) => {\n if (inputBuffer.length === 0) {\n console.error('No input provided. Use --help for usage.');\n process.exit(1);\n }\n\n let buffer = inputBuffer.buffer as ArrayBufferLike;\n\n try {\n buffer = inflate(inputBuffer).buffer;\n } catch (_ignore) {}\n\n const nbt = Nbt.fromBuffer(buffer);\n\n let jsonObject = nbt.toObject();\n\n if (args['--compact']) {\n return JSON.stringify(jsonObject);\n }\n\n let content = JSON.stringify(jsonObject, null, 4);\n\n if (args['--condense']) {\n content = content.replace(\n /: \\[(\\n\\s*\"?-?\\d+\"?,?)*\\n\\s*\\]/g,\n (match) => {\n return match.replace(/\\n\\s*/g, ' ');\n }\n );\n }\n\n return content;\n })\n .then((output: string) => {\n if (args['<output>']) {\n writeFile(args['<output>'], output);\n } else {\n console.log(output);\n }\n });\n"]}
@@ -0,0 +1,13 @@
1
+ import { HasEntityData } from './has-entity-data';
2
+ export interface BannerPatternDefinition {
3
+ asset_id: string;
4
+ translation_key: string;
5
+ }
6
+ export interface BannerPattern {
7
+ color: string;
8
+ pattern: string | BannerPatternDefinition;
9
+ }
10
+ export declare class Banner extends HasEntityData {
11
+ patterns(): BannerPattern[];
12
+ }
13
+ //# sourceMappingURL=banner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../../src/block/banner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAKlD,MAAM,WAAW,uBAAuB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,GAAG,uBAAuB,CAAC;CAC7C;AAED,qBAAa,MAAO,SAAQ,aAAa;IACrC,QAAQ,IAAI,aAAa,EAAE;CAiC9B"}
@@ -0,0 +1,28 @@
1
+ import { HasEntityData } from './has-entity-data';
2
+ import { NbtString } from '../nbt/nbt-string';
3
+ export class Banner extends HasEntityData {
4
+ patterns() {
5
+ const patterns = this.entityData.findChild('Patterns');
6
+ if (!patterns) {
7
+ throw new Error('Unable to find patterns in banner');
8
+ }
9
+ return patterns.data.map((compound) => {
10
+ const color = compound.findChild('Color');
11
+ const pattern = compound.findChild('Pattern');
12
+ if (!color || !pattern) {
13
+ throw new Error('Color or pattern not found in banner pattern');
14
+ }
15
+ if (pattern instanceof NbtString) {
16
+ return { color: color.data, pattern: pattern.data };
17
+ }
18
+ return {
19
+ color: color.data,
20
+ pattern: {
21
+ asset_id: pattern.findChild('Pattern')?.data ?? '',
22
+ translation_key: pattern.findChild('Pattern')?.data ?? '',
23
+ },
24
+ };
25
+ });
26
+ }
27
+ }
28
+ //# sourceMappingURL=banner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"banner.js","sourceRoot":"","sources":["../../src/block/banner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAY9C,MAAM,OAAO,MAAO,SAAQ,aAAa;IACrC,QAAQ;QACJ,MAAM,QAAQ,GACV,IAAI,CAAC,UAAU,CAAC,SAAS,CAAuB,UAAU,CAAC,CAAC;QAEhE,IAAI,CAAC,QAAQ,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACzD,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YAClC,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAY,OAAO,CAAC,CAAC;YACrD,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,CAC9B,SAAS,CACZ,CAAC;YAEF,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;gBACrB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;YACpE,CAAC;YAED,IAAI,OAAO,YAAY,SAAS,EAAE,CAAC;gBAC/B,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;YACxD,CAAC;YAED,OAAO;gBACH,KAAK,EAAE,KAAK,CAAC,IAAI;gBACjB,OAAO,EAAE;oBACL,QAAQ,EACJ,OAAO,CAAC,SAAS,CAAY,SAAS,CAAC,EAAE,IAAI,IAAI,EAAE;oBACvD,eAAe,EACX,OAAO,CAAC,SAAS,CAAY,SAAS,CAAC,EAAE,IAAI,IAAI,EAAE;iBAC1D;aACJ,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import { HasEntityData } from './has-entity-data';\nimport { NbtCompound } from '../nbt/nbt-compound';\nimport { NbtList } from '../nbt/nbt-list';\nimport { NbtString } from '../nbt/nbt-string';\n\nexport interface BannerPatternDefinition {\n asset_id: string;\n translation_key: string;\n}\n\nexport interface BannerPattern {\n color: string;\n pattern: string | BannerPatternDefinition;\n}\n\nexport class Banner extends HasEntityData {\n patterns(): BannerPattern[] {\n const patterns =\n this.entityData.findChild<NbtList<NbtCompound>>('Patterns');\n\n if (!patterns) {\n throw new Error('Unable to find patterns in banner');\n }\n\n return patterns.data.map((compound) => {\n const color = compound.findChild<NbtString>('Color');\n const pattern = compound.findChild<NbtString | NbtCompound>(\n 'Pattern'\n );\n\n if (!color || !pattern) {\n throw new Error('Color or pattern not found in banner pattern');\n }\n\n if (pattern instanceof NbtString) {\n return { color: color.data, pattern: pattern.data };\n }\n\n return {\n color: color.data,\n pattern: {\n asset_id:\n pattern.findChild<NbtString>('Pattern')?.data ?? '',\n translation_key:\n pattern.findChild<NbtString>('Pattern')?.data ?? '',\n },\n };\n });\n }\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import { CustomName } from './mixins/custom-name';
2
+ import { Lock } from './mixins/lock';
3
+ import { NbtCompound } from '../nbt/nbt-compound';
4
+ import { NbtList } from '../nbt/nbt-list';
5
+ declare const Barrel_base: new (name: string, coords: import("..").Coords3d, entityData?: NbtCompound | undefined) => CustomName & Lock & {
6
+ items(): NbtList<NbtCompound>;
7
+ lootTable(): string | undefined;
8
+ lootTableSeed(): bigint | undefined;
9
+ entityData: NbtCompound;
10
+ name: string;
11
+ coords: import("..").Coords3d;
12
+ components(): NbtCompound | undefined;
13
+ };
14
+ export declare class Barrel extends Barrel_base {
15
+ }
16
+ export {};
17
+ //# sourceMappingURL=barrel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"barrel.d.ts","sourceRoot":"","sources":["../../src/block/barrel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;;aASzB,OAAO,CAAC,WAAW,CAAC;iBAWhB,MAAM,GAAG,SAAS;qBAId,MAAM,GAAG,SAAS;;;;;;AApB3C,qBAAa,MAAO,SAAQ,WAwB3B;CAAG"}
@@ -0,0 +1,21 @@
1
+ import { HasEntityData } from './has-entity-data';
2
+ import { CustomName } from './mixins/custom-name';
3
+ import { Lock } from './mixins/lock';
4
+ import { Mixin } from './mixins/mixin';
5
+ export class Barrel extends Mixin(HasEntityData, CustomName, Lock, class extends HasEntityData {
6
+ items() {
7
+ const items = this.entityData.findChild('Items');
8
+ if (!items) {
9
+ throw new Error('Barrel is missing items tag');
10
+ }
11
+ return items;
12
+ }
13
+ lootTable() {
14
+ return this.entityData.findChild('LootTable')?.data;
15
+ }
16
+ lootTableSeed() {
17
+ return this.entityData.findChild('LootTableSeed')?.data;
18
+ }
19
+ }) {
20
+ }
21
+ //# sourceMappingURL=barrel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"barrel.js","sourceRoot":"","sources":["../../src/block/barrel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAMvC,MAAM,OAAO,MAAO,SAAQ,KAAK,CAC7B,aAAa,EACb,UAAU,EACV,IAAI,EACJ,KAAM,SAAQ,aAAa;IACvB,KAAK;QACD,MAAM,KAAK,GACP,IAAI,CAAC,UAAU,CAAC,SAAS,CAAuB,OAAO,CAAC,CAAC;QAE7D,IAAI,CAAC,KAAK,EAAE,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,SAAS;QACL,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAY,WAAW,CAAC,EAAE,IAAI,CAAC;IACnE,CAAC;IAED,aAAa;QACT,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAU,eAAe,CAAC,EAAE,IAAI,CAAC;IACrE,CAAC;CACJ,CACJ;CAAG","sourcesContent":["import { HasEntityData } from './has-entity-data';\nimport { CustomName } from './mixins/custom-name';\nimport { Lock } from './mixins/lock';\nimport { Mixin } from './mixins/mixin';\nimport { NbtCompound } from '../nbt/nbt-compound';\nimport { NbtList } from '../nbt/nbt-list';\nimport { NbtLong } from '../nbt/nbt-long';\nimport { NbtString } from '../nbt/nbt-string';\n\nexport class Barrel extends Mixin(\n HasEntityData,\n CustomName,\n Lock,\n class extends HasEntityData {\n items(): NbtList<NbtCompound> {\n const items =\n this.entityData.findChild<NbtList<NbtCompound>>('Items');\n\n if (!items) {\n throw new Error('Barrel is missing items tag');\n }\n\n return items;\n }\n\n lootTable(): string | undefined {\n return this.entityData.findChild<NbtString>('LootTable')?.data;\n }\n\n lootTableSeed(): bigint | undefined {\n return this.entityData.findChild<NbtLong>('LootTableSeed')?.data;\n }\n }\n) {}\n"]}
@@ -0,0 +1,14 @@
1
+ import { CustomName } from './mixins/custom-name';
2
+ import { Lock } from './mixins/lock';
3
+ declare const Beacon_base: new (name: string, coords: import("..").Coords3d, entityData?: import("..").NbtCompound | undefined) => CustomName & Lock & {
4
+ primaryEffect(): string | undefined;
5
+ secondaryEffect(): string | undefined;
6
+ entityData: import("..").NbtCompound;
7
+ name: string;
8
+ coords: import("..").Coords3d;
9
+ components(): import("..").NbtCompound | undefined;
10
+ };
11
+ export declare class Beacon extends Beacon_base {
12
+ }
13
+ export {};
14
+ //# sourceMappingURL=beacon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"beacon.d.ts","sourceRoot":"","sources":["../../src/block/beacon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;;qBASZ,MAAM,GAAG,SAAS;uBAIhB,MAAM,GAAG,SAAS;;;;;;AAT7C,qBAAa,MAAO,SAAQ,WAa3B;CAAG"}
@@ -0,0 +1,14 @@
1
+ import { CustomName } from './mixins/custom-name';
2
+ import { HasEntityData } from './has-entity-data';
3
+ import { Lock } from './mixins/lock';
4
+ import { Mixin } from './mixins/mixin';
5
+ export class Beacon extends Mixin(HasEntityData, CustomName, Lock, class extends HasEntityData {
6
+ primaryEffect() {
7
+ return this.entityData.findChild('LootTable')?.data;
8
+ }
9
+ secondaryEffect() {
10
+ return this.entityData.findChild('LootTableSeed')?.data;
11
+ }
12
+ }) {
13
+ }
14
+ //# sourceMappingURL=beacon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"beacon.js","sourceRoot":"","sources":["../../src/block/beacon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,MAAM,OAAO,MAAO,SAAQ,KAAK,CAC7B,aAAa,EACb,UAAU,EACV,IAAI,EACJ,KAAM,SAAQ,aAAa;IACvB,aAAa;QACT,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAY,WAAW,CAAC,EAAE,IAAI,CAAC;IACnE,CAAC;IAED,eAAe;QACX,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAY,eAAe,CAAC,EAAE,IAAI,CAAC;IACvE,CAAC;CACJ,CACJ;CAAG","sourcesContent":["import { CustomName } from './mixins/custom-name';\nimport { HasEntityData } from './has-entity-data';\nimport { Lock } from './mixins/lock';\nimport { Mixin } from './mixins/mixin';\nimport { NbtString } from '../nbt/nbt-string';\n\nexport class Beacon extends Mixin(\n HasEntityData,\n CustomName,\n Lock,\n class extends HasEntityData {\n primaryEffect(): string | undefined {\n return this.entityData.findChild<NbtString>('LootTable')?.data;\n }\n\n secondaryEffect(): string | undefined {\n return this.entityData.findChild<NbtString>('LootTableSeed')?.data;\n }\n }\n) {}\n"]}
@@ -0,0 +1,4 @@
1
+ import { HasEntityData } from './has-entity-data';
2
+ export declare class Bed extends HasEntityData {
3
+ }
4
+ //# sourceMappingURL=bed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bed.d.ts","sourceRoot":"","sources":["../../src/block/bed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,qBAAa,GAAI,SAAQ,aAAa;CAAG"}
@@ -0,0 +1,4 @@
1
+ import { HasEntityData } from './has-entity-data';
2
+ export class Bed extends HasEntityData {
3
+ }
4
+ //# sourceMappingURL=bed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bed.js","sourceRoot":"","sources":["../../src/block/bed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,OAAO,GAAI,SAAQ,aAAa;CAAG","sourcesContent":["import { HasEntityData } from './has-entity-data';\n\nexport class Bed extends HasEntityData {}\n"]}
@@ -0,0 +1,9 @@
1
+ import { Coords3d } from '../types/coords';
2
+ import { HasEntityData } from './has-entity-data';
3
+ import { NbtCompound } from '../nbt/nbt-compound';
4
+ import { NbtList } from '../nbt/nbt-list';
5
+ export declare class Beehive extends HasEntityData {
6
+ bees(): NbtList<NbtCompound> | undefined;
7
+ flowerPos(): Coords3d | undefined;
8
+ }
9
+ //# sourceMappingURL=beehive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"beehive.d.ts","sourceRoot":"","sources":["../../src/block/beehive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,qBAAa,OAAQ,SAAQ,aAAa;IACtC,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,SAAS;IAIxC,SAAS,IAAI,QAAQ,GAAG,SAAS;CAKpC"}
@@ -0,0 +1,10 @@
1
+ import { HasEntityData } from './has-entity-data';
2
+ export class Beehive extends HasEntityData {
3
+ bees() {
4
+ return this.entityData.findChild('bees');
5
+ }
6
+ flowerPos() {
7
+ return this.entityData.findChild('flower_pos')?.data;
8
+ }
9
+ }
10
+ //# sourceMappingURL=beehive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"beehive.js","sourceRoot":"","sources":["../../src/block/beehive.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAKlD,MAAM,OAAO,OAAQ,SAAQ,aAAa;IACtC,IAAI;QACA,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAuB,MAAM,CAAC,CAAC;IACnE,CAAC;IAED,SAAS;QACL,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAc,YAAY,CAAC,EAAE,IAE9C,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import { Coords3d } from '../types/coords';\nimport { HasEntityData } from './has-entity-data';\nimport { NbtCompound } from '../nbt/nbt-compound';\nimport { NbtIntArray } from '../nbt/nbt-int-array';\nimport { NbtList } from '../nbt/nbt-list';\n\nexport class Beehive extends HasEntityData {\n bees(): NbtList<NbtCompound> | undefined {\n return this.entityData.findChild<NbtList<NbtCompound>>('bees');\n }\n\n flowerPos(): Coords3d | undefined {\n return this.entityData.findChild<NbtIntArray>('flower_pos')?.data as\n | Coords3d\n | undefined;\n }\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import { HasEntityData } from './has-entity-data';
2
+ export declare class Bell extends HasEntityData {
3
+ }
4
+ //# sourceMappingURL=bell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bell.d.ts","sourceRoot":"","sources":["../../src/block/bell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,qBAAa,IAAK,SAAQ,aAAa;CAAG"}
@@ -0,0 +1,4 @@
1
+ import { HasEntityData } from './has-entity-data';
2
+ export class Bell extends HasEntityData {
3
+ }
4
+ //# sourceMappingURL=bell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bell.js","sourceRoot":"","sources":["../../src/block/bell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,OAAO,IAAK,SAAQ,aAAa;CAAG","sourcesContent":["import { HasEntityData } from './has-entity-data';\n\nexport class Bell extends HasEntityData {}\n"]}
@@ -0,0 +1,23 @@
1
+ import { Banner } from './banner';
2
+ import { Barrel } from './barrel';
3
+ import { Beacon } from './beacon';
4
+ import { Bed } from './bed';
5
+ import { Beehive } from './beehive';
6
+ import { Bell } from './bell';
7
+ import { Coords3d } from '../types/coords';
8
+ import { Generic } from './generic';
9
+ import { NbtCompound } from '../nbt/nbt-compound';
10
+ import { Sign } from './sign';
11
+ export type BlockInstance = Banner | Barrel | Beacon | Bed | Beehive | Bell | Generic | Sign;
12
+ export declare class Block {
13
+ static blockConstructor: Map<(name: string) => boolean, typeof Generic>;
14
+ static create(name: string, coords: Coords3d, entityData?: NbtCompound): Generic;
15
+ static isBanner(name: string): boolean;
16
+ static isBarrel(name: string): boolean;
17
+ static isBeacon(name: string): boolean;
18
+ static isBed(name: string): boolean;
19
+ static isBeehive(name: string): boolean;
20
+ static isBell(name: string): boolean;
21
+ static isSign(name: string): boolean;
22
+ }
23
+ //# sourceMappingURL=block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../src/block/block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,GAAG,GAAG,OAAO,GAAG,IAAI,GAAG,OAAO,GAAG,IAAI,CAAC;AAE7F,qBAAa,KAAK;IACd,MAAM,CAAC,gBAAgB,aAAkB,MAAM,KAAK,OAAO,kBAQxD;IAEH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,EAAE,WAAW,GAAG,OAAO;IAUhF,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAItC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAItC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAItC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAInC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIvC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIpC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAGvC"}
@@ -0,0 +1,49 @@
1
+ import { Banner } from './banner';
2
+ import { Barrel } from './barrel';
3
+ import { Beacon } from './beacon';
4
+ import { Bed } from './bed';
5
+ import { Beehive } from './beehive';
6
+ import { Bell } from './bell';
7
+ import { Generic } from './generic';
8
+ import { Sign } from './sign';
9
+ export class Block {
10
+ static blockConstructor = new Map([
11
+ [Block.isBanner, Banner],
12
+ [Block.isBarrel, Barrel],
13
+ [Block.isBeacon, Beacon],
14
+ [Block.isBed, Bed],
15
+ [Block.isBeehive, Beehive],
16
+ [Block.isBell, Bell],
17
+ [Block.isSign, Sign]
18
+ ]);
19
+ static create(name, coords, entityData) {
20
+ for (const [isBlock, blockConstructor] of Block.blockConstructor) {
21
+ if (isBlock(name)) {
22
+ return new blockConstructor(name, coords, entityData);
23
+ }
24
+ }
25
+ return new Generic(name, coords, entityData);
26
+ }
27
+ static isBanner(name) {
28
+ return !!name.match(/^minecraft:.+_banner$/);
29
+ }
30
+ static isBarrel(name) {
31
+ return name === 'minecraft:barrel';
32
+ }
33
+ static isBeacon(name) {
34
+ return name === 'minecraft:beacon';
35
+ }
36
+ static isBed(name) {
37
+ return !!name.match(/^minecraft:.+_bed$/);
38
+ }
39
+ static isBeehive(name) {
40
+ return name === 'minecraft:beehive' || name === 'minecraft:bee_nest';
41
+ }
42
+ static isBell(name) {
43
+ return name === 'minecraft:bell';
44
+ }
45
+ static isSign(name) {
46
+ return !!name.match(/^minecraft:.+_sign$/);
47
+ }
48
+ }
49
+ //# sourceMappingURL=block.js.map