reduce size of registry data

This commit is contained in:
p2r3
2025-08-13 19:47:55 +03:00
parent fbeaf5c499
commit 94b3682f0a
2 changed files with 17 additions and 5 deletions

View File

@@ -203,8 +203,11 @@ const requiredRegistries = [
"pig_variant", "pig_variant",
"wolf_sound_variant", "wolf_sound_variant",
"wolf_variant", "wolf_variant",
"damage_type", "damage_type"
"worldgen/biome" ];
const biomes = [
"plains"
]; ];
async function convert () { async function convert () {
@@ -221,8 +224,17 @@ async function convert () {
console.error(`Missing required registry "${registry}"!`); console.error(`Missing required registry "${registry}"!`);
return; return;
} }
registryBuffers.push(serializeRegistry(registry, registries[registry])); if (registry.endsWith("variant")) {
// The mob "variants" only require one valid variant to be accepted
// Send the shortest one to save memory
const shortest = registries[registry].sort((a, b) => a.length - b.length)[0];
registryBuffers.push(serializeRegistry(registry, [shortest]));
} else {
registryBuffers.push(serializeRegistry(registry, registries[registry]));
}
} }
// Send biomes separately - only "plains" is actually required
registryBuffers.push(serializeRegistry("worldgen/biome", biomes));
const fullRegistryBuffer = Buffer.concat(registryBuffers); const fullRegistryBuffer = Buffer.concat(registryBuffers);
const itemsAndBlocks = await extractItemsAndBlocks(); const itemsAndBlocks = await extractItemsAndBlocks();
@@ -296,7 +308,7 @@ ${Object.keys(itemsAndBlocks.palette).map((c, i) => `#define B_${c} ${i}`).join(
${Object.entries(itemsAndBlocks.items).map(c => `#define I_${c[0]} ${c[1]}`).join("\n")} ${Object.entries(itemsAndBlocks.items).map(c => `#define I_${c[0]} ${c[1]}`).join("\n")}
// Biome identifiers // Biome identifiers
${registries["worldgen/biome"].map((c, i) => `#define W_${c} ${i}`).join("\n")} ${biomes.map((c, i) => `#define W_${c} ${i}`).join("\n")}
#endif #endif
`; `;

View File

@@ -310,7 +310,7 @@ int sc_chunkDataAndUpdateLight (int client_fd, int _x, int _z) {
} }
// biome data // biome data
writeByte(client_fd, 0); // bits per entry writeByte(client_fd, 0); // bits per entry
writeByte(client_fd, W_forest); // palette writeByte(client_fd, W_plains); // palette
} }
writeVarInt(client_fd, 0); // omit block entities writeVarInt(client_fd, 0); // omit block entities