This document outlines the end-to-end pipeline for the client-side fluid generator. The entire process is self-contained within the index.html file and runs exclusively in the user's web browser, requiring no backend server.
The process begins with the user providing all the necessary configuration through the HTML form:
- Fluid Properties: The user inputs the fluid's name (e.g., "Liquid Honey"), a unique namespaced ID (e.g.,
wiki:honey), and functional properties like the fog color and buoyancy. - Texture Uploads: The user uploads two
.pngimage files:- The texture for the fluid block itself.
- The texture for the fluid's bucket item.
- Initiation: The user clicks the "Generate Fluid Pack" button, which triggers the main JavaScript application logic embedded in the
index.htmlfile.
Once initiated, the application calls a series of functions from the generator.js script to create the core components of the addon in memory.
-
generateGeometries(): This function programmatically builds the contents offluid_geometry.json. It generates hundreds of unique 3D cube models that correspond to every possible fluid depth (1-8) and slope direction. This is the foundation of the fluid's visual appearance. -
generatePermutations(): This function creates the large array of block permutations. Each permutation is a Molang query that maps a specific combination of block states (e.g.,depth == 7andslope == 'n') to the corresponding 3D model generated in the previous step. -
getBlockJson(): This function assembles the finalminecraft:blockdefinition. It combines the user's configuration (ID, fog color) with the generated permutations to create the complete JSON file for the fluid block. -
getBucketItemJson(): This function creates the definition for the fluid's bucket. It uses the modernminecraft:block_placercomponent to handle the placement of the fluid block, including its initial "source block" states. -
getRegistrationScript(): This function generates the dynamicregister_fluids.jsscript. This critical file makes the in-game scripting engine aware of the new fluid by creating and exporting aFluidQueuefor it, ensuring its behavior is updated in-game. -
getManifestJson(): This function is called twice to generate themanifest.jsonfiles for both the behavior and resource packs, complete with unique UUIDs.
With all the file contents generated, the application uses the JSZip library to construct the addon's file structure within a zip archive in memory.
-
Directory Scaffolding: It creates the standard addon folder structure (
BP/,RP/,BP/scripts/generated/,RP/models/blocks/, etc.). -
File Population:
- The generated JSON files (manifests, block/item definitions, geometry, permutations) are placed in their correct locations.
- The user-uploaded textures are read from memory and added to the
RP/textures/subfolders. - The static in-game scripts (
API.js,fluids.js,queue.js,BlockUpdate.js), which are embedded as strings withinindex.html, are parsed and added to theBP/scripts/folder. - The dynamically generated
register_fluids.jsis placed inBP/scripts/generated/. - Finally, the necessary texture mapping files (
blocks.json,item_texture.json,terrain_texture.json) are created and added to the resource pack.
The final step delivers the completed addon to the user:
- Blob Creation: The
JSZiplibrary generates the complete zip archive as a single binary blob. - Download Trigger: The script creates a temporary, invisible
<a>element, sets itshrefto the blob, and programmatically clicks it. - Final Product: The browser initiates a download of the file, which is named with the
.mcaddonextension. The user can then simply open this file to import the complete, ready-to-use fluid addon into Minecraft.