@zardoy/flying-squid 0.0.130 → 0.0.131
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.
|
@@ -3,8 +3,8 @@ import { DataRegistry } from 'minecraft-worldgen/dist/data/registry';
|
|
|
3
3
|
* Vanilla game data the server needs at run time and `minecraft-data` does not have: loot tables and cooking recipes (smelting, blasting, smoking).
|
|
4
4
|
* It reads the datapack layers like minecraft-worldgen does (a `DataRegistry`):
|
|
5
5
|
* 1. the vanilla client jar (node: `MC_WORLDGEN_VANILLA_JAR` / `~/.cache/mc-worldgen/client.jar`, or `options.gameDataJars`),
|
|
6
|
-
* 2. zip URL(s) of `globalThis.__MC_GAMEDATA_URL` (browser hosts; a string, a list or a function returning one; a
|
|
7
|
-
* files is enough, it is not the worldgen pack),
|
|
6
|
+
* 2. zip URL(s) of `globalThis.__MC_GAMEDATA_URL` (browser hosts; a string, a list or a function returning one; a JSON bundle of `data/minecraft/loot_table/chests/*` and the cooking
|
|
7
|
+
* `data/minecraft/recipe/*` files (`{ "<path>": json }`, about 10 KB gzipped) or a zip of them is enough, it is not the worldgen pack),
|
|
8
8
|
* 3. datapack zips in `<worldFolder>/datapacks/`,
|
|
9
9
|
* 4. `options.lootTables` (`{ 'minecraft:chests/foo': {...} }` or a function) which wins over everything.
|
|
10
10
|
* Without any of them loot tables are unknown (chests with a `LootTable` stay as they are) and a built-in list of the vanilla cooking recipes is used.
|
|
@@ -54,8 +54,14 @@ class GameData {
|
|
|
54
54
|
for (const url of Array.isArray(urls) ? urls : urls ? [urls] : []) {
|
|
55
55
|
try {
|
|
56
56
|
const res = await fetch(url);
|
|
57
|
-
if (res.ok)
|
|
58
|
-
|
|
57
|
+
if (!res.ok)
|
|
58
|
+
continue;
|
|
59
|
+
const bytes = new Uint8Array(await res.arrayBuffer());
|
|
60
|
+
// a JSON bundle `{ "data/minecraft/loot_table/chests/x.json": {...}, ... }` (much smaller than a zip: the tables compress well together) or a datapack zip
|
|
61
|
+
if (bytes[0] === 0x7B)
|
|
62
|
+
this.registry.addVirtualFiles(`gamedata:${url}`.slice(0, 80), JSON.parse(new TextDecoder().decode(bytes)));
|
|
63
|
+
else
|
|
64
|
+
this.registry.addZipBuffer(`gamedata:${url}`.slice(0, 80), bytes);
|
|
59
65
|
}
|
|
60
66
|
catch { }
|
|
61
67
|
}
|