├── .gitignore
├── .travis.yml
├── LICENSE.md
├── README.md
├── app.js
├── bin
├── libleveldb.dll
└── libleveldb.so
├── bindings
└── LevelDbWrapper.js
├── build.js
├── db
├── NbtParse.js
├── readChunk.js
└── trimChunk.js
├── downloadTextures.js
├── html
└── buildHTML.js
├── lookup_tables
├── monochrome-textures_table.json
├── patch-textures_table.json
├── runtimeid_table.json
└── transparent-blocks_table.json
├── package.json
├── palettes
├── chunk.js
├── missingDefinitions.js
├── palette_persistance.js
└── textureCache.js
├── render
├── loadTexture.js
├── renderChunk.js
└── renderZoomLevel.js
└── updateCheck.js
/.gitignore:
--------------------------------------------------------------------------------
1 | /.vscode/
2 | /.vs/
3 | /build/
4 | /node_modules/
5 | npm-debug.log
6 | /dist/
7 | package-lock.json
8 | /textures/
9 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | os:
2 | - linux
3 | - windows
4 | matrix:
5 | allow_failures:
6 | - os: windows
7 | language: node_js
8 | node_js:
9 | - 12
10 | compiler:
11 | - gcc
12 | after_success: npm run-script build
13 | before_deploy:
14 | - cd "./dist/release/"
15 | - zip -r papyrusjs-$TRAVIS_OS_NAME_$TRAVIS_TAG-$TRAVIS_BUILD_NUMBER.zip ./
16 | deploy:
17 | provider: releases
18 | overwrite: true
19 | token:
20 | secure: LyAqf85pZBfMZIrqgXGrdjhfrN43OY2j3Iwi3+u4QCJYs8aG9vodjmBQGTCqKeqEtigq5/xZ0HwaTl/y2LplD3vd3/1lWgQvWCm9er+FX74qegZC4qYNg0eUKGsVcoXNPIVGblVfUW/C8jaSvHDxAqFJM4Ie6spWhqfq2Oox/sZzB/s1R0A4Qn6TbVU/Mppp2YrToRryo5otbFsLvMBbtRRa3g8AXOWdf0G/sVbns/7NIZnwN6hbnjCNhVUghm9mf0/lO12enfGeVh9f1iLrSFZ98d9IHLGsHaLd+3TRRGHxH+NhMd+U+LlHLANMIvu2OfDAdyYAMdrWZsNkNxeCBEYcGAxZ/f35XrwFSua9XuRrLsODkmhuZ2s7AEbaiypZg0eSilVLzi7/fTiDB2xkG2WYuJ5yuFNGfFZZ2JZ5XjOpNH+w9JVwOUZbLa9fIR04J6yzVNCdqzc297rN5P0h2YUnAMlNRmAv8xdBR8IAyP8tpyQAAtPZdZhtMvmXzgy8dfBILKyUgaegjSK72/uj5ogOAea/PP/aJkq6CktEioA61VmN0C6h7UohiNUM/xHK7eUG+B7kflWz6/i/uMXLu9NWb+O+W7mIvTShMAla+BDJ74qoMbIbzOoC91nTCDTn+IDTn5Y9gpBMtGM4DAKFhQtPZcdetTrmnBswXtSICGU=
21 | file: papyrusjs-$TRAVIS_OS_NAME_$TRAVIS_TAG-$TRAVIS_BUILD_NUMBER.zip
22 | skip_cleanup: true
23 | on:
24 | repo: clarkx86/papyrusjs
25 | tags: true
26 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
This tool is very unstable and in it's alpha-state!
5 |
I recommend taking a look at PapyrusCS instead!
6 |
7 |
8 |
9 |
10 |
11 | [](https://travis-ci.com/clarkx86/papyrusjs) [](https://discord.gg/J2sBaXa)
12 | # papyrus.js
13 | Papyrus is a tool to render Minecraft: Bedrock Edition (from now on referenced as "MCBE") worlds using Leaflet. It is written in JavaScript and powered by node.js.
14 |
15 | You can view an example [here](http://map.bedrock.clarkx86.com/demo).
16 |
17 | **Please also check out papyrus.js' sister-project: [papyrus.cs](https://github.com/mjungnickel18/papyruscs/)!**
18 |
19 | ## Introduction
20 | Since MCBE worlds don't use the Anvil format like in the Java Edition, but rather a by Mojang [modified version](https://github.com/Mojang/leveldb-mcpe) of Google's [LevelDB](https://github.com/google/leveldb) to save, the goal of Papyrus is to read these worlds and assemble a render of every pre-generated chunk.
21 |
22 | ## Features
23 | - Render a top-down map of every already explored chunk
24 | ##### Planned
25 | - Windows support
26 | - Isometric renders
27 | - Auto-Updating renders
28 | - Live-View of currently online players on map (and their respective statistics)
29 | - Nether/ The End support
30 |
31 | ## Installation
32 | Do you just want to *use* papyrus.js (or don't want to build it from scratch)? You may be looking for the [pre-built binaries](https://github.com/clarkx86/papyrusjs/releases).
33 |
34 | Before installing, you may also need to install additional dependencies:
35 | ```sudo apt install g++ zlib1g-dev```
36 |
37 | Assuming you have node.js (>= 12) already installed, simply clone this repository and run the following command in your favourite terminal:
38 | ```npm install```
39 |
40 | ## Usage
41 | ```
42 | node app.js --world="./My World/" --textures="./Vanilla_Resource_Pack" --output="./output" --mode="topdown_shaded"
43 | ```
44 | - For pre-built binaries use this syntax
45 | ```
46 | ./papyrusjs --world="./My World/" --textures="./Vanilla_Resource_Pack" --output="./output" --mode="topdown_shaded"
47 | ```
48 |
49 | You are able to define a path to the texture pack that you want to use for the final render. Vanilla textures will automatically be downloaded if no textures are found. You can also force papyrus.js to download the latest textures with the option `--force-download`. If you want to download the vanilla resourcepack manually, you can get it [here](https://aka.ms/resourcepacktemplate).
50 |
51 | **Please note:** Only 16x16px *Bedrock Edition* texture packs are supported!
52 |
53 | In some cases, high world size and low amount of ram (example: server with 2GB of ram), it is possible that the program crashes with an 'OutOfMemory' error. In this case, you can add the ```--expose-gc``` option to the command line.
54 | ```
55 | node --expose-gc app.js --world="./My World/" --textures="./Vanilla_Resource_Pack" --output="./output" --mode="topdown_shaded"
56 | ```
57 |
58 | Pre-built-binaries are not using this option at the moment.
59 |
60 | ## Contribute xor support
61 | If you want to help improve papyurs.js, please consider forking the repository.
62 |
63 | Want to buy me a coffee (I love coffee)? [Donate via PayPal ♥](https://paypal.me/clarkstuehmer)
64 |
65 | ## Special thanks to...
66 | ... [DeepBlue4200](https://github.com/mjungnickel18), [mhsjlw](https://github.com/mhsjlw) and all the contributors.
67 |
68 | ## Disclaimer
69 | papyrus.js, as well as papyrus.cs are in no way affiliated with Mojang or Minecraft.
70 |
71 | Contact: [clarkx86@outlook.com](mailto:clarkx86@outlook.com?subject=GitHub%20papyrus)
72 |
--------------------------------------------------------------------------------
/app.js:
--------------------------------------------------------------------------------
1 | const json_package = require('./package.json'),
2 | fs = require('fs'),
3 | path = require('path'),
4 | colors = require('colors'),
5 | stripJsonComments = require('strip-json-comments'),
6 | ProgressBar = require('progress'),
7 | Chunk = require('./palettes/chunk.js'),
8 | cluster = require('cluster'),
9 | os = require('os');
10 | const argv = require('yargs')
11 | .version(json_package.version + json_package.version_stage.charAt(0))
12 | .option('output', {
13 | alias: 'o',
14 | default: './output/'
15 | })
16 | .option('world', {
17 | alias: 'w'
18 | })
19 | .option('textures', {
20 | alias: 't',
21 | default: './textures/'
22 | })
23 | .option('threads', {
24 | default: os.cpus().length
25 | })
26 | .option('mode', {
27 | alias: 'm'
28 | })
29 | .option('threshold', {
30 | alias: 'y',
31 | default: 256
32 | })
33 | .option('force-download', {
34 | default: false,
35 | type: 'boolean'
36 | })
37 | .option("force-render", {
38 | default: false,
39 | type: "boolean"
40 | })
41 | .option('verbose', {
42 | alias: 'v',
43 | default: false,
44 | type: 'boolean'
45 | })
46 | .demandOption(['world', 'textures', 'output'])
47 | .argv;
48 |
49 | const LOG_ERR = (colors.red.bold("[ERROR]") + " "),
50 | LOG_WARN = (colors.yellow("[WARNING]") + " "),
51 | LOG_VERBOSE = (colors.blue("[VERBOSE]") + " ");
52 |
53 | let path_output = path.normalize(argv.output),
54 | path_resourcepack = path.normalize(argv.textures),
55 | zoomLevelMax = process.env['zoomLevelMax'],
56 | renderMode = argv.mode;
57 |
58 | let transparentBlocks = require('./lookup_tables/transparent-blocks_table.json'),
59 | runtimeIDTable = require('./lookup_tables/runtimeid_table.json'),
60 | monoTable = require('./lookup_tables/monochrome-textures_table.json'),
61 | patchTable = require('./lookup_tables/patch-textures_table.json');
62 | if (fs.existsSync(argv.textures + 'blocks.json')) {
63 | textureTable = JSON.parse(stripJsonComments(fs.readFileSync(path.normalize(argv.textures + '/textures/terrain_texture.json')).toString())),
64 | blockTable = JSON.parse(stripJsonComments(fs.readFileSync(path.normalize(argv.textures + 'blocks.json')).toString()));
65 | } else {
66 | textureTable = null;
67 | blockTable = null;
68 | }
69 |
70 | module.exports = { argv, renderMode, transparentBlocks, runtimeIDTable, monoTable, patchTable, textureTable, blockTable, path_output, path_resourcepack };
71 |
72 | if (cluster.isMaster) {
73 | console.log(colors.bold(json_package.name.charAt(0) + json_package.name.slice(1, json_package.name.length - 2) + "." + json_package.name.slice(json_package.name.length - 2) + " v" + json_package.version + json_package.version_stage.charAt(0)) + colors.reset(" by ") + json_package.author + " and contributors");
74 |
75 | // Check for latest version
76 | require('./updateCheck.js')();
77 |
78 | if (argv.verbose === true) {
79 | console.log(colors.bold("Verbose mode") + " is on! You will see debug console output.");
80 | }
81 | if (argv.output === "./output/") {
82 | console.log(LOG_WARN + " No output path specified. The default path \"./output/\" will be used.");
83 | }
84 | if (argv.output === "./textures/") {
85 | console.log(LOG_WARN + " No texture path specified. The default path \"./textures/\" will be used.");
86 | }
87 |
88 | console.log('Threads: ' + argv.threads);
89 |
90 | // Download textures if textures can't be found
91 | new Promise((resolve, reject) => {
92 | if ((argv['force-download'] === true) || (!fs.existsSync(path.normalize(argv.textures + 'blocks.json')))) {
93 | console.log('Texture directory is missing or ' + colors.italic('--force-download') + ' has been specified. Downloading...');
94 | require('./downloadTextures.js')(path.resolve(argv.textures))
95 | .then(() => { resolve(); })
96 | .catch((err) => { throw err; });
97 | } else {
98 | resolve();
99 | }
100 | }).then(() => {
101 | // Run
102 | init(path.normalize(argv.world), path.normalize(argv.output));
103 | });
104 |
105 | function init(path_world, path_output) {
106 | let path_leveldat = path.normalize(path_world);
107 | if (fs.existsSync(path_leveldat) != 1) {
108 | console.log(LOG_ERR + " Invalid world path.");
109 | return;
110 | }
111 | let db_keys = [],
112 | chunksTotal = [];
113 |
114 | chunksTotal[0] = 0; // SubChunks
115 |
116 | // Open database
117 | console.log("Attempting to open database...");
118 | let LevelDbWrapper = new (require("./bindings/LevelDbWrapper.js"))("./bin/libleveldb");
119 | LevelDbWrapper.open(path_leveldat + '/db/', () => {
120 | console.log("Success!");
121 | });
122 |
123 | // Iterate through database to store a dictionary of SubChunks
124 | console.log("Reading database. This can take a couple of seconds up to a couple of minutes.");
125 | LevelDbWrapper.iterate((data, value) => {
126 | // Only read adequate keys which are specifically SubChunks
127 | if (data.length > 8 && data.readInt8(8) === 47) {
128 | // Dump pointers to the subchunk keys
129 | let subChunkIndex = data.slice(0, 8).toString("hex");
130 | if (db_keys[subChunkIndex] == null) {
131 | db_keys[subChunkIndex] = [];
132 | }
133 | db_keys[subChunkIndex].push(data); // = data;
134 | chunksTotal[0]++;
135 | }
136 | });
137 |
138 | (() => {
139 | if (argv.verbose) {
140 | console.log(LOG_VERBOSE + 'Allocated ' +
141 | Math.round((process.memoryUsage().heapUsed / Math.pow(1024, 2))) +
142 | ' MB of memory when iterating through the database.'
143 | );
144 | }
145 |
146 | let chunkX = [0, 0],
147 | chunkZ = [0, 0];
148 |
149 | // Count chunks
150 | Object.keys(db_keys).forEach(function (key) {
151 | // Update XZ-Distance
152 | if (db_keys[key][0].readInt32LE(0) <= chunkX[0]) { chunkX[0] = db_keys[key][0].readInt32LE(0) }
153 | if (db_keys[key][0].readInt32LE(0) >= chunkX[1]) { chunkX[1] = db_keys[key][0].readInt32LE(0) }
154 | if (db_keys[key][0].readInt32LE(4) <= chunkZ[0]) { chunkZ[0] = db_keys[key][0].readInt32LE(4) }
155 | if (db_keys[key][0].readInt32LE(4) >= chunkZ[1]) { chunkZ[1] = db_keys[key][0].readInt32LE(4) }
156 | });
157 |
158 | let zoomLevelMax = null;
159 |
160 | if ((chunkX[1] - chunkX[0]) >= (chunkZ[1] - chunkZ[0])) {
161 | // console.log( 'X is bigger: ' + ( chunkX[ 1 ] - chunkX[ 0 ] ) + 1 );
162 | zoomLevelMax = Math.round(Math.log2((chunkX[1] - chunkX[0])));
163 | } else {
164 | // console.log( 'Z is bigger: ' + ( chunkZ[ 1 ] - chunkZ[ 0 ] ) );
165 | zoomLevelMax = Math.round(Math.log2((chunkZ[1] - chunkZ[0]) + 1));
166 | }
167 |
168 | // Prepare output directory
169 | prepareOutput();
170 |
171 | console.log('World reaches from chunks\tX:\t' + chunkX[0] + ",\t" + "Z:\t" + chunkZ[0] + "\t" + colors.bold("to") + "\tX:\t" + "+" + chunkX[1] + ",\t" + "Z:\t" + "+" + chunkZ[1]);
172 | console.log('Processing and rendering ' + colors.bold(Object.keys(db_keys).length) + ' Chunks, which ' + colors.bold(chunksTotal[0]) + ' of them are valid SubChunks...');
173 |
174 | let bar = new ProgressBar(colors.bold('[') + ':bar' + colors.bold(']') + ' :percent\tProcessing chunk :current/ :total\t:rate chunks/Second', {
175 | total: Object.keys(db_keys).length,
176 | complete: colors.inverse('='),
177 | width: 32
178 | });
179 |
180 | let workers = [],
181 | chunksPerThread = Math.floor(Object.keys(db_keys).length / argv.threads),
182 | start = 0,
183 | finishedWorkers = 0;
184 |
185 | // Compute the number of chunks not allocated to workers.
186 | let extra_chunks = Object.keys(db_keys).length - (chunksPerThread * argv.threads);
187 | // Create worker for each thread
188 | for (let i = 0; i < argv.threads; i++) {
189 | let workerArgs = {};
190 | workerArgs['ID'] = i;
191 | workerArgs['start'] = start;
192 | workerArgs['end'] = start + chunksPerThread - 1;
193 | workerArgs['worldOffset'] = JSON.stringify({ 'x': chunkX, 'z': chunkZ });
194 | workerArgs['chunksTotal'] = Object.keys(db_keys).length;
195 | workerArgs['zoomLevelMax'] = zoomLevelMax;
196 | workerArgs['yThreshold'] = argv.threshold;
197 |
198 | // Evenly allocate the extra chunks
199 | if (extra_chunks > 0) {
200 | workerArgs['end'] += 1;
201 | start += chunksPerThread + 1;
202 | extra_chunks--;
203 | } else {
204 | start += chunksPerThread;
205 | }
206 |
207 | // Fork new worker
208 | workers.push(cluster.fork(workerArgs));
209 | }
210 |
211 | // WORKER EVENT HANDLER
212 | cluster.on('message', (worker, msg) => {
213 | //console.log( 'Got message from: ' + worker[ 'id' ] + );
214 | switch (msg['msgid']) {
215 | // Worker requested a chunk
216 | case 0:
217 | try {
218 | bar.tick();
219 |
220 | let readPromises = [],
221 | db_data = [];
222 |
223 | let keyPointerArray = db_keys[Object.keys(db_keys)[msg['msg']]];
224 |
225 | // console.log("\nSecond try:");
226 | // LevelDbWrapper.get(db_keys[Object.keys(db_keys)[0]][0], (err, value) => {
227 | // console.log(value);
228 | // });
229 |
230 | for (let i = 0; i < keyPointerArray.length; i++) {
231 | // console.log(keyPointerArray[i]);
232 |
233 | readPromises.push(new Promise((resolve, reject) => {
234 | LevelDbWrapper.get(keyPointerArray[i], (err, data) => {
235 | // console.log(data);
236 | db_data.push(data);
237 | resolve();
238 | });
239 | }));
240 | }
241 |
242 | Promise.all(readPromises)
243 | .then(function () {
244 | workers[worker["id"] - 1].send({ msgid: 0, msg: { xz: keyPointerArray[0].slice(0, 8), data: db_data } });
245 | });
246 | } catch (err) {
247 | throw err;
248 | }
249 | break;
250 |
251 | // Worker finished rendering
252 | case 1:
253 | finishedWorkers++;
254 | // if (argv.verbose) { console.log('Thread ' + (worker['id'] - 1) + ' is done rendering.'); };
255 | if (finishedWorkers === argv.threads) {
256 | if (argv.verbose) { console.log('All threads are done rendering.'); }
257 | processLeafletMap();
258 | }
259 | break;
260 | }
261 | });
262 |
263 | async function processLeafletMap() {
264 | // Generate additional zoom levels for Leaflet map
265 | const renderZoomLevel = require('./render/renderZoomLevel.js');
266 |
267 | let progressBars = {
268 | zoomLevels: new ProgressBar(colors.bold('[') + ':bar' + colors.bold(']') + ' :percent\tRendering zoom levels\tCurrent zoom level:\t', {
269 | total: Object.keys(db_keys).length,
270 | complete: colors.inverse('='),
271 | width: 32
272 | })
273 | };
274 |
275 | renderZoomLevel(16, zoomLevelMax, chunkX, chunkZ)
276 | .then(() => {
277 | console.log('Successfully rendered all zoom levels!');
278 | process.exit();
279 | });
280 | }
281 |
282 | function prepareOutput() {
283 | if (!fs.existsSync(path_output)) {
284 | fs.mkdirSync(path_output)
285 | }
286 | if (!fs.existsSync(path_output + '/map/')) {
287 | fs.mkdirSync(path_output + '/map/');
288 | }
289 |
290 | // Create index.html
291 | // console.log('Preparing output directory...');
292 | let levelname = fs.readFileSync(path_leveldat + '/levelname.txt');
293 |
294 | const buildHTML = require('./html/buildHTML.js');
295 | buildHTML(path.normalize(path_output), 0, zoomLevelMax, 0, 0, levelname);
296 | }
297 | })();
298 |
299 | /*
300 | LevelDbWrapper.close(() => {
301 |
302 | });
303 | */
304 | }
305 | } else {
306 | const convert = require('color-convert');
307 | const mapnik = require('mapnik');
308 | const PNG = require('pngjs').PNG;
309 | const readChunk = require('./db/readChunk.js');
310 | const renderChunk = require('./render/renderChunk.js');
311 | const Cache = require('./palettes/textureCache');
312 |
313 | let pos = process.env['start'],
314 | cache = new Cache(),
315 | worldOffset = JSON.parse(process.env['worldOffset']);
316 |
317 | initPromises = [];
318 | // Prepare essential images for cache
319 | // Monochrome textures blending colour
320 | initPromises.push(new Promise((resolve, reject) => {
321 | let img = new mapnik.Image(16, 16),
322 | color = convert.hex.rgb('#79c05a');
323 | img.fillSync(new mapnik.Color(color[0], color[1], color[2], 255, true));
324 | cache.save('mono_default', 0, img);
325 |
326 | img = new PNG({ width: 1, height: 1 });
327 | cache.save('placeholder', 0, PNG.sync.write(img));
328 |
329 | img = new mapnik.Image(16, 16);
330 | img.fillSync(new mapnik.Color(255, 255, 255, 255, true));
331 | cache.save('blend_white', 0, img);
332 |
333 | img = new mapnik.Image(16, 16);
334 | img.fillSync(new mapnik.Color(0, 0, 0, 255, true));
335 | cache.save('blend_black', 0, img);
336 |
337 | resolve();
338 | }));
339 |
340 | Promise.all(initPromises)
341 | .then(() => {
342 | // Initial chunk request
343 | process.send({ msgid: 0, msg: pos });
344 | })
345 | .catch((err) => {
346 | });
347 |
348 | // console.log( "I'm worker " + process.env[ 'ID' ] + ' and I render from ' + process.env[ 'start' ] + ' to ' + process.env[ 'end' ] );
349 |
350 | process.on('message', (msg) => {
351 | switch (msg['msgid']) {
352 | case 0: // Received requested chunk
353 | let chunk = new Chunk(Buffer.from(msg['msg']['xz']));
354 | // console.log( Buffer.from( msg[ 'msg' ][ 'xz' ] ) );
355 |
356 | for (let i = 0; i < msg['msg']['data'].length; i++) {
357 | readChunk(Buffer.from(msg['msg']['data'][i]), chunk, i, process.env['yThreshold']);
358 | }
359 |
360 | renderChunk(chunk, cache, 16, worldOffset, zoomLevelMax)
361 | .then(function () {
362 | // Increment position counter
363 | pos++;
364 | // console.log( 'Thread ' + process.env[ 'ID' ] + ' ' + pos + '/' + process.env[ 'end' ] )
365 |
366 | if (pos <= process.env['end']) {
367 | process.send({ msgid: 0, msg: pos });
368 | } else if (pos >= process.env['end']) {
369 | process.send({ msgid: 1, msg: true }); // Process is done rendering their chunks
370 | }
371 |
372 | });
373 | break;
374 | }
375 | });
376 | }
--------------------------------------------------------------------------------
/bin/libleveldb.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/papyrus-mc/papyrusjs/312799d9f36985b6a68913680bcc1712d13e962b/bin/libleveldb.dll
--------------------------------------------------------------------------------
/bin/libleveldb.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/papyrus-mc/papyrusjs/312799d9f36985b6a68913680bcc1712d13e962b/bin/libleveldb.so
--------------------------------------------------------------------------------
/bindings/LevelDbWrapper.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Extremely basic and stripped-down wrapper class to directly call LevelDB library.
3 | *
4 | * This class is able to call an external LevelDB library using the "Foreign Function Interface" module.
5 | * It supports synchronously iterating through a database and reading data. Writing isn't implemented yet.
6 | * @author clarkx86
7 | */
8 |
9 | const ffi = require("ffi"),
10 | ref = require("ref");
11 |
12 | module.exports = class LevelDbWrapper {
13 | constructor(libPath) {
14 | this.leveldb_db = ref.refType(ref.types.Object);
15 | this.leveldb_options = ref.refType(ref.types.void);
16 | this.leveldb_comparator = ref.refType(ref.types.void);
17 | this.leveldb_snapshot = ref.refType(ref.types.Object);
18 | this.leveldb_options_set_comparator = this.leveldb_comparator;
19 | this.leveldb_options_create_if_missing = ref.types.bool;
20 | this.leveldb_options_paranoid_checks = ref.types.bool;
21 |
22 | this.leveldb_readoptions = ref.refType(ref.types.Object);
23 | this.leveldb_readoptions_verify_checksums = ref.types.bool;
24 | this.leveldb_readoptions_fill_cache = ref.types.bool;
25 |
26 | this.leveldb_iterator = ref.refType(ref.types.Object);
27 | this.KeyType = ref.refType(ref.types.Object);
28 | this.ValueType = ref.refType(ref.types.Object);
29 |
30 | this._db = null;
31 | this._options = null;
32 | this._readoptions = null;
33 | this._ite = null;
34 |
35 | this.KeyPointer = ref.refType(ref.types.Object);
36 | this.ErrPointer = ref.refType(ref.types.CString);
37 | this.keySizePointer = null;
38 | this.valueSizePointer = null;
39 |
40 | this.levelDbLib = ffi.Library(require("path").resolve(libPath), {
41 | "leveldb_open": [this.leveldb_db, [this.leveldb_options, "string"]],
42 | "leveldb_close": [ref.types.void, [this.leveldb_db]],
43 | "leveldb_get": [this.ValueType, [this.leveldb_db, this.leveldb_readoptions, this.KeyPointer, ref.types.size_t, ref.refType(ref.types.size_t), this.ErrPointer]],
44 | "leveldb_create_iterator": [this.leveldb_iterator, [this.leveldb_db, this.leveldb_readoptions]],
45 | "leveldb_iter_destroy": [ref.types.void, [this.leveldb_iterator]],
46 | "leveldb_iter_valid": [ref.types.byte, [this.leveldb_iterator]],
47 | "leveldb_iter_seek_to_first": [ref.types.void, [this.leveldb_iterator]],
48 | "leveldb_iter_seek_to_last": [ref.types.void, [this.leveldb_iterator]],
49 | "leveldb_iter_next": [ref.types.void, [this.leveldb_iterator]],
50 | "leveldb_iter_prev": [ref.types.void, [this.leveldb_iterator]],
51 | "leveldb_iter_key": [this.KeyType, [this.leveldb_iterator, ref.refType(ref.types.size_t)]],
52 | "leveldb_iter_value": [this.ValueType, [this.leveldb_iterator, ref.refType(ref.types.size_t)]],
53 | "leveldb_options_create": [this.leveldb_options, []],
54 | "leveldb_options_set_create_if_missing": ["void", [this.leveldb_options, this.leveldb_options_create_if_missing]],
55 | "leveldb_options_set_compression": ["void", [this.leveldb_options, ref.types.int]],
56 | "leveldb_options_destroy": ["void", [this.leveldb_options]],
57 | "leveldb_readoptions_create": [this.leveldb_readoptions, []],
58 | "leveldb_readoptions_destroy": [ref.types.void, [this.leveldb_readoptions]],
59 | "leveldb_readoptions_set_verify_checksums": [ref.types.void, [this.leveldb_readoptions, ref.types.bool]],
60 | "leveldb_readoptions_set_fill_cache": [ref.types.void, [this.leveldb_readoptions, ref.types.bool]],
61 | "leveldb_readoptions_set_snapshot": [ref.types.void, [this.leveldb_readoptions, this.leveldb_snapshot]]
62 | });
63 | }
64 |
65 | open(path, callback) {
66 | this._options = this.levelDbLib.leveldb_options_create();
67 | this._readoptions = this.levelDbLib.leveldb_readoptions_create();
68 |
69 | this.levelDbLib.leveldb_options_set_compression(this._options, 4);
70 | this._db = this.levelDbLib.leveldb_open(this._options, path);
71 |
72 | // Create iterator
73 | this._ite = this.levelDbLib.leveldb_create_iterator(this._db, this._readoptions);
74 |
75 | callback();
76 | }
77 |
78 | close(callback) {
79 | this.levelDbLib.leveldb_readoptions_destroy(this._readoptions);
80 | this.levelDbLib.leveldb_options_destroy(this._options);
81 | this.levelDbLib.leveldb_iter_destroy(this._ite);
82 | this.levelDbLib.leveldb_close(this._db);
83 |
84 | callback();
85 | }
86 |
87 | iterate(callback) {
88 | // Iterate through every entry
89 | for (this.levelDbLib.leveldb_iter_seek_to_first(this._ite); this.levelDbLib.leveldb_iter_valid(this._ite) !== 0; this.levelDbLib.leveldb_iter_next(this._ite)) {
90 | // Allocate a key- and value size address of size_t to pass onto the LevelDB function
91 | this.keySizePointer = ref.alloc(ref.types.size_t, 0);
92 | this.valueSizePointer = ref.alloc(ref.types.size_t, 0);
93 |
94 | /*
95 | * TODO: Find a solution for duplicate entry calling.
96 | */
97 |
98 | this.levelDbLib.leveldb_iter_key(this._ite, this.keySizePointer);
99 | this.levelDbLib.leveldb_iter_value(this._ite, this.valueSizePointer);
100 |
101 | this.KeyType.size = this.keySizePointer.readInt32LE(0);
102 | this.ValueType.size = this.valueSizePointer.readInt32LE(0);
103 |
104 | let key = Buffer.alloc(this.KeyType.size, this.levelDbLib.leveldb_iter_key(this._ite, this.keySizePointer)),
105 | value = Buffer.alloc(this.ValueType.size, this.levelDbLib.leveldb_iter_value(this._ite, this.valueSizePointer));
106 |
107 | callback(key, value);
108 | }
109 | }
110 |
111 | get(key, callback) {
112 | this.valueSizePointer = ref.alloc(ref.types.size_t, 0);
113 | this.ErrPointer = ref.allocCString(null, "utf-8");
114 |
115 | this.levelDbLib.leveldb_get(this._db, this._readoptions, key, key.length, this.valueSizePointer, this.ErrPointer);
116 | this.ValueType.size = this.valueSizePointer.readInt32LE(0);
117 | let data = Buffer.alloc(this.ValueType.size, this.levelDbLib.leveldb_get(this._db, this._readoptions, key, key.length, this.valueSizePointer, this.ErrPointer));
118 |
119 | callback(ref.isNull(this.ErrPointer) ? null : this.ErrPointer, data);
120 | }
121 | };
122 |
--------------------------------------------------------------------------------
/build.js:
--------------------------------------------------------------------------------
1 | const json_package = require('./package.json');
2 | const { exec } = require('pkg')
3 | const colors = require('colors');
4 | const path = require('path');
5 | const fs = require('fs-extra');
6 |
7 | (async () => {
8 |
9 | var destinationDir = (__dirname + '/dist/release/'),
10 | copyDir = '';
11 |
12 | console.log('Building ' + colors.bold(json_package.name.charAt(0) + json_package.name.slice(1, json_package.name.length - 2) + '.' + json_package.name.slice(json_package.name.length - 2) + ' v' + json_package.version + '-' + json_package.version_stage));
13 |
14 | /*
15 | console.log('Patching modules...');
16 |
17 | let patchContent = fs.readFileSync('./node_modules/mapnik/lib/mapnik.js').toString();
18 | patchContent = patchContent.replace("var binding_path = binary.find(path.resolve(path.join(__dirname,'../package.json')));", "var binding_path = binary.find(path.resolve(path.join('./node_modules/mapnik/package.json')));");
19 | fs.writeFileSync('./node_modules/mapnik/lib/mapnik.js', patchContent);
20 | */
21 |
22 | console.log('Packing application using pkg...');
23 |
24 | await exec(['package.json', '--target=node12-linux-x64', '--output', path.resolve(destinationDir + 'papyrusjs')]);
25 |
26 | console.log('Copying native modules to destination directory...');
27 |
28 | if (!fs.existsSync(destinationDir + 'node_modules/')) {
29 | fs.mkdirSync(destinationDir + 'node_modules/');
30 | }
31 |
32 | let currentModule;
33 |
34 | currentModule = 'ffi';
35 | console.log('Module:\t' + currentModule);
36 | if (!fs.existsSync(destinationDir + 'node_modules/' + currentModule + '/node_modules/ref/build/Release/')) {
37 | fs.mkdirSync(destinationDir + 'node_modules/' + currentModule + '/node_modules/ref/build/Release/', { recursive: true });
38 | }
39 | if (!fs.existsSync(destinationDir + 'node_modules/' + currentModule + '/build/Release/')) {
40 | fs.mkdirSync(destinationDir + 'node_modules/' + currentModule + '/build/Release/', { recursive: true });
41 | }
42 | copyDir = '/node_modules/' + currentModule + '/node_modules/ref/build/Release/' + 'binding.node';
43 | fs.copyFileSync(__dirname + copyDir, destinationDir + copyDir, );
44 | //
45 | copyDir = '/node_modules/' + currentModule + '/build/Release/' + 'ffi_bindings.node';
46 | fs.copyFileSync(__dirname + copyDir, destinationDir + copyDir, );
47 |
48 | currentModule = 'ref';
49 | console.log('Module:\t' + currentModule);
50 | if (!fs.existsSync(destinationDir + 'node_modules/' + currentModule + '/build/Release/')) {
51 | fs.mkdirSync(destinationDir + 'node_modules/' + currentModule + '/build/Release/', { recursive: true });
52 | }
53 | copyDir = '/node_modules/' + currentModule + '/build/Release/' + 'binding.node';
54 | fs.copyFileSync(__dirname + copyDir, destinationDir + copyDir);
55 |
56 | currentModule = 'ref-struct';
57 | console.log('Module:\t' + currentModule);
58 | if (!fs.existsSync(destinationDir + 'node_modules/' + currentModule + '/node_modules/ref/build/Release/')) {
59 | fs.mkdirSync(destinationDir + 'node_modules/' + currentModule + '/node_modules/ref/build/Release/', { recursive: true });
60 | }
61 | copyDir = '/node_modules/' + currentModule + '/node_modules/ref/build/Release/' + 'binding.node';
62 | fs.copyFileSync(__dirname + copyDir, destinationDir + copyDir);
63 |
64 | // Mapnik
65 | currentModule = 'mapnik';
66 | console.log('Module:\t' + currentModule);
67 | if (!fs.existsSync(destinationDir + 'node_modules/' + currentModule + '/lib/binding/lib/')) {
68 | fs.mkdirSync(destinationDir + 'node_modules/' + currentModule + '/lib/binding/lib/', { recursive: true });
69 | }
70 | copyDir = '/node_modules/' + currentModule + '/lib/binding/mapnik.node';
71 | fs.copyFileSync(__dirname + copyDir, destinationDir + copyDir);
72 | copyDir = '/node_modules/' + currentModule + '/lib/binding/lib/libmapnik.so';
73 | fs.copyFileSync(__dirname + copyDir, destinationDir + copyDir);
74 |
75 | console.log('Copying libraries...');
76 | if (!fs.existsSync(destinationDir + 'bin/')) {
77 | fs.mkdirSync(destinationDir + 'bin/');
78 | }
79 | copyDir = (process.platform === "win32") ? ('/bin/' + '/libleveldb.dll') : ('/bin/' + '/libleveldb.so');
80 | fs.copyFileSync(__dirname + copyDir, destinationDir + copyDir);
81 |
82 | console.log('Done. Ready for deployment!');
83 | })();
--------------------------------------------------------------------------------
/db/NbtParse.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Simple NBT Parser
3 | * @author clarkx86
4 | */
5 |
6 | const typeIds = {
7 | TAG_End: 0,
8 | TAG_Byte: 1,
9 | TAG_Short: 2,
10 | TAG_Int: 3,
11 | TAG_Long: 4,
12 | TAG_Float: 5,
13 | TAG_Double: 6,
14 | TAG_Byte_Array: 7,
15 | TAG_String: 8,
16 | TAG_List: 9,
17 | TAG_Compound: 10,
18 | TAG_Int_Array: 11,
19 | TAG_Long_Array: 12
20 | };
21 |
22 |
23 | function parse(data, callback) {
24 | let _serialized = {},
25 | _refStack = [],
26 | _o = 0,
27 | _valid = true;
28 |
29 | while (_valid) {
30 | let _tagId = data.readInt8(_o); _o += 1;
31 | let _nameLength = 0;
32 | let _name = "";
33 |
34 | if (_tagId !== typeIds.TAG_End) {
35 | _nameLength = data.readInt16LE(_o); _o += 2;
36 | _name = data.slice(_o, _o + _nameLength); _o += _nameLength;
37 | }
38 |
39 | let _value;
40 |
41 | switch (_tagId) {
42 | case typeIds.TAG_End:
43 | _refStack.pop();
44 | _valid = _refStack.length > 0;
45 | break;
46 |
47 | case typeIds.TAG_Byte:
48 | _value = data.readInt8(_o); _o += 1;
49 | break;
50 |
51 | case typeIds.TAG_Short:
52 | _value = data.readInt16LE(_o); _o += 2;
53 | break;
54 |
55 | case typeIds.TAG_Int:
56 | _value = data.readInt32LE(_o); _o += 4;
57 | break;
58 |
59 | case typeIds.TAG_Long:
60 | break;
61 |
62 | case typeIds.TAG_Float:
63 | break;
64 |
65 | case typeIds.TAG_Double:
66 | break;
67 |
68 | case typeIds.TAG_Byte_Array:
69 | break;
70 |
71 | case typeIds.TAG_String:
72 | let _length = data.readInt16LE(_o); _o += 2;
73 | _value = data.slice(_o, _o + _length).toString(); _o += _length;
74 | break;
75 |
76 | case typeIds.TAG_List:
77 | break;
78 |
79 | case typeIds.TAG_Compound:
80 | if (_refStack.length === 0) {
81 | _serialized[_name] = {};
82 | _refStack.push(_serialized[_name]);
83 | } else {
84 | _refStack[_refStack.length-1][_name] = {};
85 | _refStack.push(_refStack[_refStack.length-1][_name]);
86 | }
87 | break;
88 |
89 | case typeIds.TAG_Int_Array:
90 | break;
91 |
92 | case typeIds.TAG_Long_Array:
93 | break;
94 | }
95 |
96 | // Serialize Tag
97 | if ((_tagId !== typeIds.TAG_End) && (_tagId !== typeIds.TAG_Compound)) {
98 | // console.log(_value);
99 | _refStack[_refStack.length-1][_name] = _value;
100 | }
101 | }
102 |
103 | _serialized["bufferSize"] = _o;
104 | callback(_serialized);
105 | }
106 |
107 | module.exports = { parse };
108 |
--------------------------------------------------------------------------------
/db/readChunk.js:
--------------------------------------------------------------------------------
1 | const argv = require("../app.js").argv;
2 | const colors = require('colors');
3 | const nbtParse = require("../db/NbtParse.js");
4 |
5 | const Palette_Persistance = require('../palettes/palette_persistance.js');
6 | const runtimeIDTable = require('../app.js').runtimeIDTable;
7 |
8 | module.exports = function (value, chunk, yOffset, yThreshold) {
9 | return new Promise((resolve, reject) => {
10 |
11 | let _offset = 0;
12 | let SubChunkVersion = value.readInt8(_offset); _offset++;
13 | let SubChunkYOffset = 16 * yOffset;
14 | let localPalette;
15 | let storages = 1;
16 |
17 | switch (SubChunkVersion) {
18 | case 0:
19 | let dataArray = value.slice(4097);
20 | for (let position = 0; position < 4096; position++) {
21 | let blockID = value.readInt8(position + 1);
22 | let blockData = getData(dataArray, position);
23 |
24 | let x = (position >> 8) & 0xF,
25 | y = position & 0xF,
26 | z = (position >> 4) & 0xF;
27 |
28 | try {
29 | if (runtimeIDTable[blockID]['name'] !== 'minecraft:air') {
30 | chunk.set(x, y + SubChunkYOffset, z, runtimeIDTable[blockID]['name'], blockData, yThreshold);
31 | // console.log( runtimeIDTable[ blockID ] );
32 | }
33 | } catch (err) {
34 | // console.log( blockID + ' ' + err );
35 | }
36 | // console.log( blockID );
37 | }
38 | function getData(dataArray, pos) {
39 | let slot = pos >> 1;
40 | let part = pos & 1;
41 |
42 | if (part === 0) {
43 | return (dataArray[slot]) & 0xf;
44 | }
45 | return (dataArray[slot] >> 4) & 0xf;
46 | }
47 | break;
48 |
49 | case 8:
50 | // valid
51 | storages = value.readInt8(_offset); _offset++;
52 |
53 | case 1:
54 | // valid
55 |
56 | for (let storage = 0; storage < storages; storage++) {
57 | let paletteAndFlag = value.readInt8(_offset); _offset++;
58 | let isRuntime = (paletteAndFlag & 1) !== 0;
59 | let bitsPerBlock = paletteAndFlag >> 1;
60 | let blocksPerWord = Math.floor(32 / bitsPerBlock);
61 | let wordCount = Math.ceil(4096 / blocksPerWord);
62 |
63 | // console.log( 'SubChunk Version:\t' + SubChunkVersion + '\tSize:\t\t' + value.length + '\t Skip to:\t' + ( _offset + ( wordCount * 4 ) ) + '\nRuntime:\t\t' + isRuntime + '\tbits per block:\t' + bitsPerBlock + '\nblocks per word:\t' + blocksPerWord + '\tword count:\t' + wordCount + '\n' );
64 |
65 | let index_blocks = _offset;
66 | _offset += (wordCount * 4);
67 |
68 | if (!isRuntime) {
69 | // NBT TAG SERIALIZER
70 | localPalette = new Palette_Persistance(value.readInt32LE(_offset)); _offset += 4;
71 | // console.log("\n" + localPalette.size());
72 |
73 | for (let paletteID = 0; paletteID < localPalette.size(); paletteID++) {
74 | nbtParse.parse(value.slice(_offset), (data) => {
75 | localPalette.put(paletteID, data[Object.keys(data)[0]].name, 0);
76 | _offset += data.bufferSize;
77 | });
78 | }
79 | }
80 |
81 | let _offset_new = index_blocks;
82 |
83 | let position = 0;
84 |
85 | for (let wordi = 0; wordi < wordCount; wordi++) {
86 | let word = value.readInt32LE(_offset_new); _offset_new += 4;
87 |
88 | for (let block = 0; block < blocksPerWord; block++) {
89 | let state = (word >> ((position % blocksPerWord) * bitsPerBlock)) & ((1 << bitsPerBlock) - 1);
90 | let x = (position >> 8) & 0xF,
91 | y = position & 0xF,
92 | z = (position >> 4) & 0xF;
93 |
94 | // console.log( 'State:\t' + state + '\tX:\t' + x + '\tY:\t' + y + '\tZ:\t' + z );
95 | // console.log( localPalette.get( state ).name );
96 |
97 | try {
98 | if (localPalette.get(state).name !== 'minecraft:air') {
99 | chunk.set(x, y + SubChunkYOffset, z, localPalette.get(state).name, localPalette.get(state).value, yThreshold);
100 | // console.log( localPalette.get( state ).value );
101 | }
102 | } catch (err) {
103 | if (argv.verbose === true) {
104 | console.log(colors.yellow('\n[WARNING]') + ' Palette ID out of bounds!\t' + state + '\t:\t' + localPalette.size());
105 | }
106 | }
107 |
108 | position++;
109 | }
110 | }
111 | }
112 | break;
113 | }
114 | resolve();
115 | });
116 | };
--------------------------------------------------------------------------------
/db/trimChunk.js:
--------------------------------------------------------------------------------
1 | const Chunk = require('../palettes/chunk.js');
2 |
3 | module.exports = function (srcChunk, Table) {
4 | var chunk = [],
5 | trimArray = [],
6 | blockName = null,
7 | blockValue = null,
8 | count = 0,
9 | table = Table;
10 |
11 | chunk[0] = srcChunk;
12 | chunk[1] = new Chunk(chunk[0].getXZ());
13 |
14 | // Create 2D array
15 | for (i = 0; i < 16; i++) {
16 | trimArray[i] = new Array();
17 |
18 | for (j = 0; j < 16; j++) {
19 | trimArray[i][j] = 0;
20 | };
21 | };
22 |
23 | for (iy = 255; iy >= 0; iy--) {
24 | for (ix = 0; ix < 16; ix++) {
25 | for (iz = 0; iz < 16; iz++) {
26 | trim();
27 | };
28 | trim();
29 | };
30 | };
31 |
32 | function trim() {
33 | blockName = chunk[0].get(ix, iy, iz).name;
34 | blockValue = chunk[0].get(ix, iy, iz).value;
35 |
36 | if ((trimArray[ix][iz] === 0) && (blockName != 'minecraft:air')) {
37 | if (isTransparent(blockName) !== true) {
38 | trimArray[ix][iz] = 1;
39 | };
40 | chunk[1].set(ix, iy, iz, blockName, blockValue);
41 | };
42 | };
43 |
44 | // console.log( chunk[ 1 ].list() );
45 |
46 | Object.keys(chunk[1].list()).forEach(function () {
47 | count++;
48 | });
49 |
50 | function isTransparent(name) {
51 | if (table[name] == true) {
52 | return true;
53 | } else {
54 | return false;
55 | };
56 | };
57 |
58 | // Update chunk
59 | return chunk[1];
60 |
61 | // console.log( 'Trimmed chunk contains ' + count + ' blocks.' );
62 | };
--------------------------------------------------------------------------------
/downloadTextures.js:
--------------------------------------------------------------------------------
1 | const fetch = require('node-fetch');
2 | const lib_fs = require('fs-extra');
3 | const lib_path = require('path');
4 | const lib_extract = require('extract-zip');
5 | const ProgressBar = require('progress');
6 | const colors = require('colors');
7 |
8 | const textures_address = 'https://aka.ms/resourcepacktemplate';
9 | const tmp_textures_address = 'textures.tmp.zip';
10 |
11 | function exists(val) { return val !== null && val !== undefined }
12 |
13 | module.exports = function (extract_address) {
14 | const zip_address = lib_path.join(extract_address, tmp_textures_address);
15 | console.log(zip_address);
16 | return (new Promise((resolve, reject) => {
17 | lib_fs.mkdir(extract_address, { recursive: true }, err => {
18 | if (exists(err)) reject(err);
19 | resolve();
20 | });
21 | }))
22 | .catch(err => { throw err.toString() + "\nFailed to download textures, the specified texture folder already exists" })
23 |
24 | .then(() => { return fetch(textures_address) })
25 | .then(response => {
26 | if (!response.ok) throw "Failed to download textures, the address " + textures_address + " returned a non-ok response";
27 | return new Promise((resolve, reject) => {
28 | const write_stream = lib_fs.createWriteStream(zip_address);
29 | var bar = new ProgressBar(colors.bold('[') + ':bar' + colors.bold(']') + ' :percent\tDownloading...\t:current/ :total', {
30 | total: parseInt(response.headers.get('content-length')),
31 | complete: colors.inverse('='),
32 | width: 32
33 | });
34 | response.body.pipe(write_stream);
35 | response.body.on('data', (dataChunk) => { bar.tick(dataChunk.length) });
36 | response.body.on("end", resolve);
37 | response.body.on("error", err => reject(err.toString() + "\nFailed to download textures, the connection encountered an error"));
38 | write_stream.on("error", err => reject(err.toString() + "\nFailed to download textures, an error occured while writing to the disk"));
39 | });
40 | })
41 |
42 | .then(() => new Promise((resolve, reject) => {
43 | console.log('Extracting...');
44 | lib_extract(zip_address, { dir: lib_path.dirname(zip_address) }, err => {
45 | if (err !== null && err !== undefined) reject(err.toString() + "\nFailed to download textures, zip extraction failed");
46 | else resolve();
47 | });
48 | }))
49 |
50 | .catch(err => console.log(err))
51 | .finally(() => {
52 | return new Promise((resolve, reject) => {
53 | lib_fs.unlink(zip_address, err => {
54 | if (exists(err)) reject(err);
55 | resolve();
56 | })
57 | })
58 | })
59 | .catch(err => console.log(err.toString() + "\nFailed to cleanup after downloading textures"));
60 | }
--------------------------------------------------------------------------------
/html/buildHTML.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs');
2 | const path = require('path');
3 |
4 | module.exports = function (outPath, zoomLevelDefault, zoomLevelMax, posX, posZ, levelname = '') {
5 |
6 | fs.writeFileSync(path.normalize(outPath + '/index.html'),
7 | `
8 |
9 | papyrus.js `+ levelname + ` Map
10 |
13 |
16 |
17 |
18 |
21 |
22 |
32 |
33 | `, { encoding: 'utf8' });
34 | };
35 |
--------------------------------------------------------------------------------
/lookup_tables/monochrome-textures_table.json:
--------------------------------------------------------------------------------
1 | {
2 | "grass_top": true,
3 | "grass": true,
4 | "tallgrass": true,
5 | "leaves": true,
6 | "leaves2": true,
7 | "pumpkin_stem": true,
8 | "melon_stem": true,
9 | "reeds": true,
10 | "vine": true
11 | }
--------------------------------------------------------------------------------
/lookup_tables/patch-textures_table.json:
--------------------------------------------------------------------------------
1 | {
2 | "lava": {
3 | "textures": [
4 | "textures/blocks/water_placeholder" ] },
5 | "still_lava": {
6 | "textures": [
7 | "textures/blocks/lava_placeholder",
8 | "textures/blocks/lava_placeholder",
9 | "textures/blocks/lava_placeholder",
10 | "textures/blocks/lava_placeholder",
11 | "textures/blocks/lava_placeholder",
12 | "textures/blocks/lava_placeholder",
13 | "textures/blocks/lava_placeholder",
14 | "textures/blocks/lava_placeholder",
15 | "textures/blocks/lava_placeholder" ] },
16 | "flowing_lava": {
17 | "textures": [
18 | "textures/blocks/lava_placeholder" ] },
19 | "water": {
20 | "textures": [
21 | "textures/blocks/water_placeholder" ] },
22 | "still_water": {
23 | "textures": [
24 | "textures/blocks/water_placeholder" ] },
25 | "still_water_grey": {
26 | "textures": [
27 | "textures/blocks/water_placeholder",
28 | "textures/blocks/water_placeholder",
29 | "textures/blocks/water_placeholder",
30 | "textures/blocks/water_placeholder",
31 | "textures/blocks/water_placeholder",
32 | "textures/blocks/water_placeholder",
33 | "textures/blocks/water_placeholder",
34 | "textures/blocks/water_placeholder" ] },
35 | "flowing_water": {
36 | "textures": [
37 | "textures/blocks/water_placeholder" ] },
38 | "flowing_water_grey": {
39 | "textures": [
40 | "textures/blocks/water_placeholder" ] },
41 | "log_top": {
42 | "textures": [
43 | "textures/blocks/log_oak_top",
44 | "textures/blocks/log_spruce_top",
45 | "textures/blocks/log_birch_top",
46 | "textures/blocks/log_jungle_top",
47 | "textures/blocks/log_oak_top",
48 | "textures/blocks/log_spruce_top",
49 | "textures/blocks/log_birch_top",
50 | "textures/blocks/log_jungle_top",
51 | "textures/blocks/log_oak",
52 | "textures/blocks/log_spruce",
53 | "textures/blocks/log_birch",
54 | "textures/blocks/log_jungle" ] },
55 | "log_top2": {
56 | "textures": [
57 | "textures/blocks/log_acacia_top",
58 | "textures/blocks/log_big_oak_top",
59 | null,
60 | null,
61 | "textures/blocks/log_acacia_top",
62 | "textures/blocks/log_big_oak_top",
63 | null,
64 | null,
65 | "textures/blocks/log_acacia",
66 | "textures/blocks/log_big_oak",
67 | null,
68 | null ] },
69 | "double_plant_top": {
70 | "textures": [
71 | "textures/blocks/double_plant_sunflower_top",
72 | "textures/blocks/double_plant_syringa_top",
73 | "textures/blocks/double_plant_grass_top",
74 | "textures/blocks/double_plant_fern_top",
75 | "textures/blocks/double_plant_rose_top",
76 | "textures/blocks/double_plant_paeonia_top",
77 | null,
78 | null,
79 | "textures/blocks/double_plant_sunflower_front",
80 | "textures/blocks/double_plant_syringa_bottom",
81 | "textures/blocks/double_plant_grass_bottom",
82 | "textures/blocks/double_plant_fern_bottom",
83 | "textures/blocks/double_plant_rose_bottom",
84 | "textures/blocks/double_plant_paeonia_bottom" ] },
85 | "furnace_top": {
86 | "textures": [
87 | "textures/blocks/furnace_top",
88 | "textures/blocks/furnace_top",
89 | "textures/blocks/furnace_top",
90 | "textures/blocks/furnace_top" ] },
91 | "observer_top": {
92 | "textures": [
93 | "textures/blocks/observer_top",
94 | "textures/blocks/observer_top",
95 | "textures/blocks/observer_top",
96 | "textures/blocks/observer_top" ] },
97 | "piston_top_sticky": {
98 | "textures": [
99 | "textures/blocks/piston_bottom",
100 | "textures/blocks/piston_top_sticky",
101 | "textures/blocks/piston_side",
102 | "textures/blocks/piston_side",
103 | "textures/blocks/piston_side",
104 | "textures/blocks/piston_side" ] },
105 | "piston_top": {
106 | "textures": [
107 | "textures/blocks/piston_bottom",
108 | "textures/blocks/piston_top_normal",
109 | "textures/blocks/piston_side",
110 | "textures/blocks/piston_side",
111 | "textures/blocks/piston_side",
112 | "textures/blocks/piston_side" ] },
113 | "daylight_detector_top": {
114 | "textures": [
115 | null,
116 | null,
117 | null,
118 | null,
119 | null,
120 | null,
121 | null,
122 | null,
123 | null,
124 | null,
125 | null,
126 | null,
127 | null,
128 | null,
129 | null,
130 | "textures/blocks/daylight_detector_top",
131 | "textures/blocks/daylight_detector_inverted_top" ] },
132 | "composter_top": {
133 | "textures": [
134 | "textures/blocks/composter_top",
135 | "textures/blocks/composter_top",
136 | "textures/blocks/composter_top",
137 | "textures/blocks/composter_top",
138 | "textures/blocks/composter_top",
139 | "textures/blocks/composter_top",
140 | "textures/blocks/composter_top",
141 | "textures/blocks/compost",
142 | "textures/blocks/compost_ready"
143 | ]
144 | },
145 | "farmland": {
146 | "textures": [
147 | "textures/blocks/farmland_dry",
148 | "textures/blocks/farmland_dry",
149 | "textures/blocks/farmland_dry",
150 | "textures/blocks/farmland_dry",
151 | "textures/blocks/farmland_dry",
152 | "textures/blocks/farmland_dry",
153 | "textures/blocks/farmland_dry",
154 | "textures/blocks/farmland_wet" ] },
155 | "beetroot": {
156 | "textures": [
157 | "textures/blocks/beetroots_stage_0",
158 | "textures/blocks/beetroots_stage_0",
159 | "textures/blocks/beetroots_stage_1",
160 | "textures/blocks/beetroots_stage_1",
161 | "textures/blocks/beetroots_stage_2",
162 | "textures/blocks/beetroots_stage_2",
163 | "textures/blocks/beetroots_stage_2",
164 | "textures/blocks/beetroots_stage_3"
165 | ]
166 | },
167 | "carrots": {
168 | "textures": [
169 | "textures/blocks/carrots_stage_0",
170 | "textures/blocks/carrots_stage_0",
171 | "textures/blocks/carrots_stage_1",
172 | "textures/blocks/carrots_stage_1",
173 | "textures/blocks/carrots_stage_2",
174 | "textures/blocks/carrots_stage_2",
175 | "textures/blocks/carrots_stage_2",
176 | "textures/blocks/carrots_stage_3" ] },
177 | "potatoes": {
178 | "textures": [
179 | "textures/blocks/potatoes_stage_0",
180 | "textures/blocks/potatoes_stage_0",
181 | "textures/blocks/potatoes_stage_1",
182 | "textures/blocks/potatoes_stage_1",
183 | "textures/blocks/potatoes_stage_2",
184 | "textures/blocks/potatoes_stage_2",
185 | "textures/blocks/potatoes_stage_2",
186 | "textures/blocks/potatoes_stage_3"
187 | ]
188 | },
189 | "sapling": {
190 | "textures": [
191 | "textures/blocks/sapling_oak",
192 | "textures/blocks/sapling_spruce",
193 | "textures/blocks/sapling_birch",
194 | "textures/blocks/sapling_jungle",
195 | "textures/blocks/sapling_acacia",
196 | "textures/blocks/sapling_roofed_oak",
197 | null,
198 | null,
199 | "textures/blocks/sapling_oak",
200 | "textures/blocks/sapling_spruce",
201 | "textures/blocks/sapling_birch",
202 | "textures/blocks/sapling_jungle",
203 | "textures/blocks/sapling_acacia",
204 | "textures/blocks/sapling_roofed_oak",
205 | null,
206 | null ] },
207 | "pumpkin_top": {
208 | "textures": [
209 | "textures/blocks/pumpkin_top",
210 | "textures/blocks/pumpkin_top",
211 | "textures/blocks/pumpkin_top",
212 | "textures/blocks/pumpkin_top"
213 | ]
214 | },
215 | "pumpkin_stem": {
216 | "textures": [
217 | "textures/blocks/pumpkin_stem_disconnected",
218 | "textures/blocks/pumpkin_stem_disconnected",
219 | "textures/blocks/pumpkin_stem_disconnected",
220 | "textures/blocks/pumpkin_stem_disconnected",
221 | "textures/blocks/pumpkin_stem_disconnected",
222 | "textures/blocks/pumpkin_stem_disconnected",
223 | "textures/blocks/pumpkin_stem_disconnected",
224 | "textures/blocks/pumpkin_stem_connected"
225 | ]
226 | },
227 | "melon_top": {
228 | "textures": [
229 | "textures/blocks/melon_top",
230 | "textures/blocks/melon_top",
231 | "textures/blocks/melon_top",
232 | "textures/blocks/melon_top"
233 | ]
234 | },
235 | "melon_stem": {
236 | "textures": [
237 | "textures/blocks/melon_stem_disconnected",
238 | "textures/blocks/melon_stem_disconnected",
239 | "textures/blocks/melon_stem_disconnected",
240 | "textures/blocks/melon_stem_disconnected",
241 | "textures/blocks/melon_stem_disconnected",
242 | "textures/blocks/melon_stem_disconnected",
243 | "textures/blocks/melon_stem_disconnected",
244 | "textures/blocks/melon_stem_connected"
245 | ]
246 | },
247 | "chest_inventory_top": {
248 | "textures": [
249 | null,
250 | null,
251 | "textures/blocks/chest_top",
252 | "textures/blocks/chest_top",
253 | "textures/blocks/chest_top",
254 | "textures/blocks/chest_top" ] },
255 | "ender_chest_inventory_top": {
256 | "textures": [
257 | "textures/blocks/ender_chest_top",
258 | "textures/blocks/ender_chest_top",
259 | "textures/blocks/ender_chest_top",
260 | "textures/blocks/ender_chest_top" ] },
261 | "leaves": {
262 | "textures": [
263 | "textures/blocks/leaves_oak_opaque",
264 | "textures/blocks/leaves_spruce_opaque",
265 | "textures/blocks/leaves_birch_opaque",
266 | "textures/blocks/leaves_jungle_opaque",
267 | "textures/blocks/leaves_oak_opaque",
268 | "textures/blocks/leaves_spruce_opaque",
269 | "textures/blocks/leaves_birch_opaque",
270 | "textures/blocks/leaves_jungle_opaque",
271 | "textures/blocks/leaves_oak_opaque",
272 | "textures/blocks/leaves_spruce_opaque",
273 | "textures/blocks/leaves_birch_opaque",
274 | "textures/blocks/leaves_jungle_opaque",
275 | "textures/blocks/leaves_oak_opaque",
276 | "textures/blocks/leaves_spruce_opaque",
277 | "textures/blocks/leaves_birch_opaque",
278 | "textures/blocks/leaves_jungle_opaque" ] },
279 | "leaves2": {
280 | "textures": [
281 | "textures/blocks/leaves_acacia_opaque",
282 | "textures/blocks/leaves_big_oak_opaque",
283 | null,
284 | null,
285 | "textures/blocks/leaves_acacia_opaque",
286 | "textures/blocks/leaves_big_oak_opaque",
287 | null,
288 | null,
289 | "textures/blocks/leaves_acacia_opaque",
290 | "textures/blocks/leaves_big_oak_opaque",
291 | null,
292 | null,
293 | "textures/blocks/leaves_acacia_opaque",
294 | "textures/blocks/leaves_big_oak_opaque",
295 | null,
296 | null ] },
297 | "planks": {
298 | "textures": [
299 | "textures/blocks/planks_oak",
300 | "textures/blocks/planks_spruce",
301 | "textures/blocks/planks_birch",
302 | "textures/blocks/planks_jungle",
303 | "textures/blocks/planks_acacia",
304 | "textures/blocks/planks_big_oak",
305 | null,
306 | null,
307 | "textures/blocks/planks_oak",
308 | "textures/blocks/planks_spruce",
309 | "textures/blocks/planks_birch",
310 | "textures/blocks/planks_jungle",
311 | "textures/blocks/planks_acacia",
312 | "textures/blocks/planks_big_oak",
313 | null,
314 | null
315 | ]
316 | },
317 | "wood": {
318 | "textures": [
319 | "textures/blocks/log_oak",
320 | "textures/blocks/log_spruce",
321 | "textures/blocks/log_birch",
322 | "textures/blocks/log_jungle",
323 | "textures/blocks/log_acacia",
324 | "textures/blocks/log_big_oak",
325 | null,
326 | null,
327 | "textures/blocks/stripped_oak_log",
328 | "textures/blocks/stripped_spruce_log",
329 | "textures/blocks/stripped_birch_log",
330 | "textures/blocks/stripped_jungle_log",
331 | "textures/blocks/stripped_acacia_log",
332 | "textures/blocks/stripped_dark_oak_log",
333 | null,
334 | null ] },
335 | "stone_slab_top": {
336 | "textures": [
337 | "textures/blocks/stone_slab_top",
338 | "textures/blocks/sandstone_top",
339 | "textures/blocks/planks_oak",
340 | "textures/blocks/cobblestone",
341 | "textures/blocks/brick",
342 | "textures/blocks/stonebrick",
343 | "textures/blocks/quartz_block_top",
344 | "textures/blocks/nether_brick",
345 | "textures/blocks/stone_slab_top",
346 | "textures/blocks/sandstone_top",
347 | "textures/blocks/planks_oak",
348 | "textures/blocks/cobblestone",
349 | "textures/blocks/brick",
350 | "textures/blocks/stonebrick",
351 | "textures/blocks/quartz_block_top",
352 | "textures/blocks/nether_brick"
353 | ]
354 | },
355 | "stone_slab_top_2": {
356 | "textures": [
357 | "textures/blocks/red_sandstone_top",
358 | "textures/blocks/purpur_block",
359 | "textures/blocks/prismarine_rough",
360 | "textures/blocks/prismarine_bricks",
361 | "textures/blocks/prismarine_dark",
362 | "textures/blocks/cobblestone_mossy",
363 | "textures/blocks/sandstone_smooth",
364 | "textures/blocks/red_nether_brick",
365 | "textures/blocks/red_sandstone_top",
366 | "textures/blocks/purpur_block",
367 | "textures/blocks/prismarine_rough",
368 | "textures/blocks/prismarine_bricks",
369 | "textures/blocks/prismarine_dark",
370 | "textures/blocks/cobblestone_mossy",
371 | "textures/blocks/sandstone_smooth",
372 | "textures/blocks/red_nether_brick"
373 | ]
374 | },
375 | "stone_slab_top_3": {
376 | "textures": [
377 | "textures/blocks/end_bricks",
378 | "textures/blocks/red_sandstone_smooth",
379 | "textures/blocks/stone_andesite_smooth",
380 | "textures/blocks/stone_andesite",
381 | "textures/blocks/stone_diorite",
382 | "textures/blocks/stone_diorite_smooth",
383 | "textures/blocks/stone_granite",
384 | "textures/blocks/stone_granite_smooth",
385 | "textures/blocks/end_bricks",
386 | "textures/blocks/red_sandstone_smooth",
387 | "textures/blocks/stone_andesite_smooth",
388 | "textures/blocks/stone_andesite",
389 | "textures/blocks/stone_diorite",
390 | "textures/blocks/stone_diorite_smooth",
391 | "textures/blocks/stone_granite",
392 | "textures/blocks/stone_granite_smooth"
393 | ]
394 | },
395 | "stone_slab_top_4": {
396 | "textures": [
397 | "textures/blocks/stonebrick_mossy",
398 | "textures/blocks/quartz_block_top",
399 | "textures/blocks/stone",
400 | "textures/blocks/sandstone_carved",
401 | "textures/blocks/red_sandstone_carved",
402 | null,
403 | null,
404 | null,
405 | "textures/blocks/stonebrick_mossy",
406 | "textures/blocks/quartz_block_top",
407 | "textures/blocks/stone",
408 | "textures/blocks/sandstone_carved",
409 | "textures/blocks/red_sandstone_carved",
410 | null,
411 | null,
412 | null
413 | ]
414 | },
415 | "door_lower": {
416 | "textures": [
417 | null,
418 | null,
419 | null,
420 | null,
421 | null,
422 | null,
423 | null,
424 | null,
425 | "textures/blocks/door_wood_lower",
426 | "textures/blocks/door_spruce_lower",
427 | "textures/blocks/door_birch_lower",
428 | "textures/blocks/door_jungle_lower",
429 | "textures/blocks/door_acacia_lower",
430 | "textures/blocks/door_dark_oak_lower",
431 | "textures/blocks/door_iron_lower" ] }
432 | }
433 |
--------------------------------------------------------------------------------
/lookup_tables/transparent-blocks_table.json:
--------------------------------------------------------------------------------
1 | {
2 | "minecraft:air": true,
3 | "minecraft:ladder": true,
4 | "minecraft:double_plant": true,
5 | "minecraft:tallgrass": true,
6 | "minecraft:carrots": true,
7 | "minecraft:wheat": true,
8 | "minecraft:red_flower": true,
9 | "minecraft:yellow_flower": true,
10 | "minecraft:fence": true,
11 | "minecraft:vine": true,
12 | "minecraft:torch": true,
13 | "minecraft:redstone_torch": true,
14 | "minecraft:unlit_redstone_torch": true,
15 | "minecraft:cactus": true,
16 | "minecraft:golden_rail": true,
17 | "minecraft:detector_rail": true,
18 | "minecraft:rail": true,
19 | "minecraft:activator_rail": true,
20 | "minecraft:redstone_wire": true,
21 | "minecraft:lever": true,
22 | "minecraft:bamboo": true,
23 | "minecraft:bamboo_sapling": true,
24 | "minecraft:sapling": true,
25 | "minecraft:potatoes": true,
26 | "minecraft:trapdoor": true,
27 | "minecraft:acacia_trapdoor": true,
28 | "minecraft:dark_oak_trapdoor": true,
29 | "minecraft:jungle_trapdoor": true,
30 | "minecraft:spruce_trapdoor": true,
31 | "minecraft:iron_trapdoor": true,
32 | "minecraft:glass_pane": true,
33 | "minecraft:glass": true,
34 | "minecraft:stained_glass": true,
35 | "minecraft:stained_glass_pane": true,
36 | "minecraft:ice": true,
37 | "minecraft:packed_ice": true,
38 | "minecraft:blue_ice": true,
39 | "minecraft:frosted_ice": true,
40 | "minecraft:scaffolding": true,
41 | "minecraft:web": true,
42 | "minecraft:wooden_door": true,
43 | "minecraft:spruce_door": true,
44 | "minecraft:birch_door": true,
45 | "minecraft:jungle_door": true,
46 | "minecraft:acacia_door": true,
47 | "minecraft:dark_oak_door": true,
48 | "minecraft:iron_door": true,
49 | "minecraft:brewing_stand": true,
50 | "minecraft:melon_stem": true,
51 | "minecraft:pumpkin_stem": true,
52 | "minecraft:beetroot": true,
53 | "minecraft:reeds": true,
54 | "minecraft:mob_spawner": true
55 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "papyrusjs",
3 | "version": "1.1.0",
4 | "version_stage": "alpha",
5 | "description": "A tool to render Minecraft: Bedrock Edition worlds.",
6 | "main": "app.js",
7 | "scripts": {
8 | "build": "node ./build.js"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/clarkx86/papyrusjs.git"
13 | },
14 | "author": "clarkx86",
15 | "license": "ISC",
16 | "bugs": {
17 | "url": "https://github.com/clarkx86/papyrusjs/issues"
18 | },
19 | "homepage": "https://github.com/clarkx86/papyrusjs#readme",
20 | "dependencies": {
21 | "bindings": "^1.5.0",
22 | "color-convert": "^2.0.0",
23 | "colors": "^1.3.3",
24 | "extract-zip": "^1.6.7",
25 | "ffi": "github:clarkx86/node-ffi#node-12",
26 | "fs-extra": "^8.1.0",
27 | "mapnik": "^4.3.1",
28 | "nan": "^2.8.0",
29 | "node-fetch": "^2.4.1",
30 | "progress": "^2.0.3",
31 | "ref": "github:clarkx86/ref#node-12",
32 | "strip-json-comments": "^2.0.1",
33 | "tga2png": "^0.1.3",
34 | "vec3": "^0.1.3",
35 | "yargs": "^13.2.2"
36 | },
37 | "devDependencies": {
38 | "pkg": "^4.4.4"
39 | },
40 | "pkg": {
41 | "scripts": [
42 | "node_modules/mapnik/lib/binding/mapnik_settings.js"
43 | ]
44 | },
45 | "bin": "app.js"
46 | }
47 |
--------------------------------------------------------------------------------
/palettes/chunk.js:
--------------------------------------------------------------------------------
1 | const Vec3 = require('vec3');
2 |
3 | var transparentBlocks = require('../lookup_tables/transparent-blocks_table.json');
4 |
5 | module.exports = class Chunk {
6 | constructor(xz) {
7 | this.chunkData = {};
8 | this.XZ = xz;
9 | this.Y = 1;
10 | }
11 |
12 | set(x, y, z, name, value, yThreshold) {
13 | if (y < yThreshold) {
14 | if (transparentBlocks[name] != true) {
15 | this.chunkData[new Vec3(x, 0, z)] = { name: name, value: value, y: y };
16 | } else {
17 | var iy = 1;
18 | while (this.chunkData[new Vec3(x, iy, z)] != undefined) {
19 | iy++;
20 | }
21 | this.chunkData[new Vec3(x, iy, z)] = { name: name, value: value, y: y };
22 | // console.log( name + ' was transparent. Put it on Y: ' + iy );
23 | };
24 | };
25 | }
26 |
27 | get(x, y, z) {
28 | var getBlock = this.chunkData[new Vec3(x, y, z)];
29 |
30 | if (getBlock === undefined) {
31 | return { name: 'minecraft:air', value: 0 };
32 | } else {
33 | return getBlock;
34 | };
35 | }
36 |
37 | getXZ() {
38 | return this.XZ;
39 | }
40 |
41 | getHeight() {
42 | return this.Y;
43 | };
44 |
45 | list() {
46 | return chunkData;
47 | };
48 | };
--------------------------------------------------------------------------------
/palettes/missingDefinitions.js:
--------------------------------------------------------------------------------
1 | // FOR DEBUGGING
2 |
3 | module.exports = function() {
4 |
5 | var cache = { }
6 |
7 | this.save = function( name ) {
8 | cache[ JSON.stringify( { name: name } ) ] = name;
9 | };
10 |
11 | this.list = function() {
12 | return cache;
13 | };
14 |
15 | // return chunkLayer;
16 | };
--------------------------------------------------------------------------------
/palettes/palette_persistance.js:
--------------------------------------------------------------------------------
1 | module.exports = function (s) {
2 | var keys = [];
3 |
4 | var paletteSize = s;
5 |
6 | this.put = function (ID, name, val) {
7 | keys[ID] = {
8 | name: name,
9 | value: val
10 | };
11 | };
12 |
13 | this.get = function (ID) {
14 | return keys[ID];
15 | };
16 |
17 | this.size = function () {
18 | return paletteSize;
19 | };
20 | };
--------------------------------------------------------------------------------
/palettes/textureCache.js:
--------------------------------------------------------------------------------
1 | const argv = require('../app.js').argv;
2 |
3 | module.exports = function () {
4 |
5 | var cache = [];
6 |
7 | this.save = function (name, value, data, y) {
8 | // if ( argv.verbose == true ) { console.log( '\nSaving new texture to cache.\t' + name + ' ' + value ) };
9 | cache[JSON.stringify({ name: name, value: value, y: y })] = data;
10 | };
11 |
12 | this.get = function (name, value, y) {
13 | return cache[JSON.stringify({ name: name, value: value, y: y })];
14 | };
15 |
16 | this.list = function () {
17 | return cache;
18 | };
19 |
20 | // return chunkLayer;
21 | };
--------------------------------------------------------------------------------
/render/loadTexture.js:
--------------------------------------------------------------------------------
1 | const argv = require('../app.js').argv;
2 | const colors = require('colors');
3 | const fs = require('fs');
4 | const mapnik = require('mapnik');
5 | const path = require('path');
6 | const tga2png = require('tga2png');
7 |
8 | const patchTable = require('../app.js').patchTable;
9 | const blockTable = require('../app.js').blockTable;
10 | const textureTable = require('../app.js').textureTable;
11 | const monoTable = require('../app.js').monoTable;
12 | const path_resourcepack = require('../app.js').path_resourcepack;
13 |
14 | const renderMode = require('../app.js').renderMode;
15 |
16 | let file = null,
17 | fileExt = '.png';
18 |
19 | module.exports = async function loadTexture(name, value, x, y, z, blockY, cache) {
20 | let texture;
21 | // Is the texture in the cache already? No: Load texture from filesystem, Yes: Skip to compositing :)!
22 | if (cache.get(name, value, blockY) === undefined) {
23 | let imageBuffer = null;
24 | // Does the texture have multiple faces?
25 | if (blockTable[name.slice(10)] !== undefined) {
26 | // The default texture name for lookup
27 | texture = blockTable[name.slice(10)]["textures"];
28 | // Does the texture have an extra key for an "up"-texture (obviously looks better for top-down renders)
29 | if (blockTable[name.slice(10)]["textures"]["up"]) {
30 | texture = blockTable[name.slice(10)]["textures"]["up"];
31 | }
32 | }
33 |
34 | // Is the file in the patch lookup-table (e.g. for water and lava)
35 | if (patchTable[texture]) {
36 | file = path_resourcepack + patchTable[texture]['textures'][value];
37 | // console.log( colors.bold( 'Patched texture found!' ) + ' Block:\t' + name + '\tValue:\t' + chunk.get( x, y, z ).value + '\tTexture:' + texture + '\tPath:\t' + file );
38 | } else {
39 | // No? Then search for the texture in the block lookup-table
40 |
41 | // Get the correct "state" and path of the texture
42 | // Is the texture missing?
43 | if (textureTable["texture_data"][texture]["textures"][value] === undefined) {
44 | if (argv.verbose === true) {
45 | console.log(colors.yellow('\n[WARNING]') + ' Value not matching:\t' + texture + '\t(' + name + '\t' + value + ')');
46 | }
47 | cache.save(name, value, cache.get('placeholder', 0));
48 | } else {
49 | // Get the texture of it's current state
50 |
51 | // Is the texture group an array?
52 | let arr = textureTable["texture_data"][texture]["textures"];
53 | // Yes
54 | if (Array.isArray(arr)) {
55 | if (arr[value]['path']) {
56 | file = path_resourcepack + arr[value]['path'];
57 | } else {
58 | file = path_resourcepack + arr[value];
59 | }
60 | } else {
61 | // No
62 | if (arr['path']) {
63 | file = path_resourcepack + arr['path'];
64 | } else {
65 | file = path_resourcepack + arr;
66 | }
67 | }
68 | }
69 | }
70 |
71 | // TGA Loading
72 | if ((!fs.existsSync(path.normalize(file + fileExt))) && (file !== cache.get('placeholder', 0))) {
73 | try {
74 | await tga2png(fs.readFileSync(file + '.tga', (err) => { console.log('FILE WAS: ' + texture); }))
75 | .then((buff) => {
76 | imageBuffer = buff;
77 | })
78 | .catch((err) => {
79 | imageBuffer = cache.get('placeholder', 0);
80 | console.log(colors.yellow('\n[WARNING]') + ' Error when loading TGA: ' + err);
81 | });
82 | } catch (err) {
83 | imageBuffer = cache.get('placeholder', 0);
84 | if (argv.verbose === true) {
85 | console.log(colors.yellow('\n[WARNING]') + ' Failed to load TGA for\t' + colors.bold(name) + '\t' + value + '\t' + colors.bold(texture) + '\tError: ' + err);
86 | }
87 | }
88 | } else {
89 | // PNG (but not if the image is a buffer already)
90 | if (file !== cache.get('placeholder', 0)) {
91 | // cache.save( name, chunk.get( x, y, z ).value, fs.readFileSync( file + fileExt ) );
92 | imageBuffer = fs.readFileSync(file + fileExt);
93 | }
94 | }
95 |
96 | // Blend monochrome textures with colour and save to cache
97 | if (monoTable[texture] === true) {
98 | let img = new mapnik.Image.fromBytesSync(imageBuffer);
99 | img.premultiplySync();
100 | await new Promise((resolve, reject) => {
101 | img.composite(cache.get('mono_default', 0), {
102 | comp_op: mapnik.compositeOp['multiply'],
103 | }, function (err, buffer) {
104 | if (err) { reject(); throw err; }
105 | imageBuffer = buffer;
106 | resolve();
107 | });
108 | });
109 | }
110 |
111 | if (name !== 'minecraft:water') {
112 | switch (renderMode) {
113 | case 'topdown_shaded':
114 | if (imageBuffer['scaling'] === undefined) {
115 | imageBuffer = mapnik.Image.fromBytesSync(imageBuffer);
116 | }
117 | imageBuffer.premultiplySync();
118 |
119 | let opac = 0,
120 | blendImg = null;
121 |
122 | switch (true) {
123 | case (blockY < 64):
124 | blendImg = cache.get('blend_black', 0);
125 | opac = (64 - blockY) / (blockY * 64);
126 | break;
127 | case (blockY >= 64):
128 | blendImg = cache.get('blend_white', 0);
129 | opac = (-64 + blockY) / (blockY);
130 | break;
131 | }
132 |
133 | await imageBuffer.composite(blendImg, {
134 | comp_op: mapnik.compositeOp['overlay'], // comp_mode,
135 | opacity: opac
136 | }, (err, data) => {
137 | imageBuffer = data;
138 | });
139 | break;
140 | }
141 | }
142 | cache.save(name, value, imageBuffer, blockY);
143 | }
144 | };
145 |
--------------------------------------------------------------------------------
/render/renderChunk.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs');
2 | const mapnik = require('mapnik');
3 | const path = require('path');
4 |
5 | const loadTexture = require('./loadTexture.js');
6 |
7 | const renderMode = require('../app.js').renderMode;
8 | const path_output = require('../app.js').path_output;
9 |
10 | module.exports = function (Chunk, Cache, size_texture, worldOffset, ZoomLevelMax) {
11 |
12 | return new Promise((resolve, reject) => {
13 | var chunk = Chunk,
14 | cache = Cache,
15 | textureBuffer;
16 |
17 | var zoomLevelMax = ZoomLevelMax;
18 |
19 | var file = null,
20 | fileExt = '.png';
21 |
22 | render();
23 |
24 | async function render() {
25 | var ix = 0,
26 | iy = 0,
27 | iz = 0,
28 | chunkX = chunk.getXZ().readInt32LE(0),
29 | chunkZ = chunk.getXZ().readInt32LE(4);
30 |
31 | var composeArray = [];
32 |
33 | // Render chunk
34 | // Y-Axis
35 | for (iy = 0; iy <= chunk.getHeight(); iy++) {
36 | // Z-Axis
37 | for (iz = 0; iz < 16; iz++) {
38 | // X-Axis
39 | for (ix = 0; ix < 16; ix++) {
40 | if (chunk.get(ix, iy, iz).name !== 'minecraft:air') {
41 | if (renderMode) {
42 | switch (renderMode) {
43 | case 'topdown_shaded':
44 | await loadTexture(chunk.get(ix, iy, iz).name, chunk.get(ix, iy, iz).value, ix, iy, iz, chunk.get(ix, iy, iz).y, cache);
45 | textureBuffer = cache.get(chunk.get(ix, iy, iz).name, chunk.get(ix, iy, iz).value, chunk.get(ix, iy, iz).y);
46 | };
47 | } else {
48 | await loadTexture(chunk.get(ix, iy, iz).name, chunk.get(ix, iy, iz).value, ix, iy, iz, 0, cache);
49 | textureBuffer = cache.get(chunk.get(ix, iy, iz).name, chunk.get(ix, iy, iz).value, 0);
50 | };
51 |
52 | composeArray.push({
53 | buffer: textureBuffer,
54 | x: size_texture * ix,
55 | y: size_texture * iz
56 | });
57 | };
58 | };
59 | };
60 | };
61 |
62 | mapnik.blend(composeArray, { width: 256, height: 256 }, function (err, data) {
63 | // Zoomlevel Directory
64 | if (!fs.existsSync(path.normalize(path_output + '/map/' + zoomLevelMax))) {
65 | fs.mkdirSync(path.normalize(path_output + '/map/' + zoomLevelMax));
66 | };
67 | // X-Coordinate Directory
68 | if (!fs.existsSync(path.normalize(path_output + '/map/' + zoomLevelMax + '/' + (chunkX + Math.abs(worldOffset['x'][0]))))) {
69 | fs.mkdirSync(path.normalize(path_output + '/map/' + zoomLevelMax + '/' + (chunkX + Math.abs(worldOffset['x'][0]))));
70 | };
71 |
72 | fs.writeFile(path.normalize(path_output + '/map/' + zoomLevelMax + '/' + (chunkX + Math.abs(worldOffset['x'][0])) + '/' + (chunkZ + Math.abs(worldOffset['z'][0])) + fileExt), data, (err) => {
73 | if (err) { throw err };
74 | });
75 | resolve();
76 | });
77 | };
78 | });
79 | };
--------------------------------------------------------------------------------
/render/renderZoomLevel.js:
--------------------------------------------------------------------------------
1 | const colors = require('colors');
2 | const mapnik = require('mapnik');
3 | const fs = require('fs');
4 | const path = require('path');
5 | const path_output = require('../app.js').path_output;
6 |
7 | module.exports = function (chunkSize, zoomLevelMax, chunkX, chunkZ) {
8 | return new Promise(async function (resolve, reject) {
9 |
10 | let blendArray = [],
11 | zoomLevelCurrent,
12 | file,
13 | tileX = 0,
14 | tileZ = 0,
15 | tileImg;
16 |
17 | --zoomLevelMax;
18 | // for( ix = Math.floor( chunkX[ 0 ]/2 ); ix < ( Math.ceil( chunkX[ 1 ]/2 ) ); ix++ ) {
19 | for (zoomLevelCurrent = zoomLevelMax; zoomLevelCurrent >= 0; zoomLevelCurrent--) {
20 | console.log('Rendering zoom level ' + colors.bold(zoomLevelCurrent) + ' out of ' + zoomLevelMax);
21 | divide();
22 | for (let iz = 0; iz < chunkZ[1] + Math.abs(chunkZ[0]); iz++) {
23 | for (let ix = 0; ix < chunkX[1] + Math.abs(chunkX[0]); ix++) {
24 |
25 | blendArray = []; // Clear array
26 |
27 | if (!fs.existsSync(path_output + '/map/' + (zoomLevelCurrent) + '/')) {
28 | fs.mkdirSync(path_output + '/map/' + (zoomLevelCurrent) + '/');
29 | }
30 |
31 | file = path.normalize(path_output + '/map/' + (zoomLevelCurrent + 1) + '/' + (ix * 2) + '/' + (iz * 2) + '.png');
32 | if (fs.existsSync(file)) {
33 | blendArray.push({
34 | buffer: fs.readFileSync(file),
35 | x: 0,
36 | y: 0
37 | });
38 | }
39 |
40 | file = path.normalize(path_output + '/map/' + (zoomLevelCurrent + 1) + '/' + (ix * 2) + '/' + ((iz * 2) + 1) + '.png');
41 | if (fs.existsSync(file)) {
42 | blendArray.push({
43 | buffer: fs.readFileSync(file),
44 | x: 0,
45 | y: 256
46 | });
47 | }
48 |
49 | file = path.normalize(path_output + '/map/' + (zoomLevelCurrent + 1) + '/' + ((ix * 2) + 1) + '/' + (iz * 2) + '.png');
50 | if (fs.existsSync(file)) {
51 | blendArray.push({
52 | buffer: fs.readFileSync(file),
53 | x: 256,
54 | y: 0
55 | });
56 | }
57 |
58 | file = path.normalize(path_output + '/map/' + (zoomLevelCurrent + 1) + '/' + ((ix * 2) + 1) + '/' + ((iz * 2) + 1) + '.png');
59 | if (fs.existsSync(file)) {
60 | blendArray.push({
61 | buffer: fs.readFileSync(file),
62 | x: 256,
63 | y: 256
64 | });
65 | }
66 |
67 | if (blendArray.length !== 0) {
68 | await new Promise((resolve, reject) => {
69 | mapnik.blend(blendArray, {
70 | width: Math.pow(chunkSize, 2) * 2,
71 | height: Math.pow(chunkSize, 2) * 2
72 | }, function (err, buffer) {
73 | tileImg = mapnik.Image.fromBytesSync(buffer);
74 | tileImg = tileImg.resizeSync(Math.pow(chunkSize, 2), Math.pow(chunkSize, 2) /*, { 'scaling_method': mapnik.imageScaling.near } */);
75 | if (!fs.existsSync(path.normalize(path_output + '/map/' + (zoomLevelCurrent) + '/' + (ix) + '/'))) {
76 | fs.mkdirSync(path.normalize(path_output + '/map/' + (zoomLevelCurrent) + '/' + (ix) + '/'));
77 | }
78 | tileImg.saveSync(path.normalize(path_output + '/map/' + (zoomLevelCurrent) + '/' + (ix) + '/' + (iz) + '.png'));
79 | tileImp = null;
80 | if (global.gc)
81 | global.gc();
82 | resolve();
83 | }
84 | )
85 | });
86 | }
87 | }
88 | }
89 | }
90 | resolve();
91 | });
92 |
93 | function divide() {
94 | chunkX[0] = chunkX[0] / 2;
95 | chunkX[1] = chunkX[1] / 2;
96 | chunkZ[0] = chunkZ[0] / 2;
97 | chunkZ[1] = chunkZ[1] / 2;
98 | }
99 | };
100 |
--------------------------------------------------------------------------------
/updateCheck.js:
--------------------------------------------------------------------------------
1 | const json_package = require('./package.json');
2 | const colors = require('colors');
3 | const fetch = require('node-fetch');
4 |
5 | module.exports = function () {
6 | fetch('http://api.github.com/repos/clarkx86/papyrusjs/releases')
7 | .then((response) => {
8 | return response.json();
9 | })
10 | .then((json) => {
11 |
12 | var remoteVersion = json[0]['tag_name'].slice(1, json[0]['tag_name'].search('-')).replace('.', '').replace('.', '');
13 | remoteStage = json[0]['tag_name'].slice(json[0]['tag_name'].search('-') + 1),
14 | localStage = json_package.version_stage;
15 |
16 | switch (remoteStage) {
17 | case 'alpha':
18 | remoteStage = 0;
19 | break;
20 |
21 | case 'beta':
22 | remoteStage = 1;
23 | break;
24 |
25 | case 'release':
26 | remoteStage = 2;
27 | break;
28 | };
29 |
30 | switch (localStage) {
31 | case 'alpha':
32 | localStage = 0;
33 | break;
34 |
35 | case 'beta':
36 | localStage = 1;
37 | break;
38 |
39 | case 'release':
40 | localStage = 2;
41 | break;
42 | };
43 |
44 | if ((remoteStage > localStage) || (remoteVersion > (json_package.version.replace('.', '').replace('.', '')))) {
45 | console.log('\n' + colors.inverse(colors.green('New update available!')) + '\nRelease ' + json[0]['tag_name'] + ' is available. You have v' + json_package.version + '-' + json_package.version_stage + '. Get it here: https://github.com/clarkx86/papyrusjs/releases' + '\n');
46 | };
47 | })
48 | .catch((err) => {
49 | console.log('Could not check for updates...');
50 | });
51 | };
--------------------------------------------------------------------------------