Files
bworld/CREATE.md
T
2026-10-22 20:07:00 -03:00

669 lines
53 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Create
A plan for porting all of Create to bworld as a mod, `mods/create`: its kinetics, processing, logistics, fluids,
redstone, contraptions, trains, equipment, decoration and schematics. It aims to do this with as little hand work as
possible, and to stay fast on both the server and the client when a world has thousands of moving parts.
Built so far: the importer and Create's imported blocks and items, R1, R2, R3 (`transformed` and `rotating`), R4, R5,
R8, S0, S4, S7, S12, stonecutting from S9, the start of P1's kinetics (shafts and cogwheels turned by a hand crank),
Create's pressing recipes, and the mechanical press pressing items on the ground. Facts about Create come from reading
`ports/create1.21.1` and `ports/create1.19.3`, and facts about bworld from its source.
## Sources
| Copy | Version | Used for |
| -------------------- | ------- | -------------------------------------------------------------------------------------------------------------------- |
| `ports/create1.21.1` | 6.0.11 | **All code and data**: mechanics, numbers, recipes, tags, worldgen, ponder scripts |
| `ports/create1.19.3` | 0.5.0.j | **Textures, models, blockstates, sounds and ponder scenes** from its `assets/` and `src/generated/resources/assets/` |
0.5.0.j shipped with only an MIT `LICENSE`, so its assets are used under that, with the MIT notice in
`mods/create/CREDITS.md`. 6.0.11's `assets/` folder isn't in the copy and isn't used.
**Keep the art removable.** Everything from 0.5.0.j's assets is written by the importer (below) into
`mods/create/textures/` and `mods/create/models/`, and nothing else in the mod depends on a specific file being there.
Removing the art is then deleting those two folders and re-running the importer with `--no-assets`. That writes
placeholder models (a plain cube, or the block's shape) and a placeholder texture, and the mod still loads and plays.
**Content newer than 0.5.0.j has no art to take**, so it needs new art either way. These are the blocks and items 6.0.11
registers that 0.5.0.j doesn't: the package logistics (`packager`, `repackager`, `package_frogport`, `stock_ticker`,
`stock_link`, `redstone_requester`, `factory_gauge`, `package_filter`, `item_hatch`, `chain_conveyor`, cardboard and its
blocks and armor, table cloths, `shopping_list`), `large_water_wheel`, `elevator_pulley`, `elevator_contact`,
`contraption_controls`, `mechanical_roller`, the copycats, `clipboard`, `desk_bell`, `pulse_timer`, metal doors and
scaffolding, `andesite_alloy_block`, `industrial_iron_block`, `weathered_iron_block`, `experience_block`, netherite
diving gear. The importer lists them in its report.
## How Big Create Is
6.0.11 is 2017 Java files, about 275,000 lines. By part:
| Part | Lines | What |
| --------------------------- | ------ | ------------------------------------------------------------------------------- |
| `content/kinetics` | 36,000 | Shafts, cogs, gearboxes, generators, belts, and the machines that use rotation |
| `infrastructure` | 33,000 | Config, datagen, ponder scenes, commands |
| `content/trains` | 30,000 | Tracks, the track graph, signals, stations, schedules, train entities |
| `content/logistics` | 30,000 | Funnels, tunnels, chutes, depots, vaults, filters, and 6.0's packages |
| `content/contraptions` | 27,000 | Moving block structures: bearings, pistons, pulleys, gantries, actors |
| `content/equipment` | 17,000 | Wrench, goggles, potato cannon, backtank, toolbox, symmetry wand |
| `content/redstone` | 12,000 | Links, nixie tubes, display links, threshold switch, diodes |
| `content/fluids` | 12,000 | Pipes, pumps, tanks, spouts, drains, hose pulley, boilers |
| `compat` | 10,000 | Other mods. Only the JEI part matters, for the recipe viewer |
| `content/decoration` | 7,000 | Palettes, copycats, girders, sliding doors, placards |
| `content/schematics` | 7,000 | Schematic table, schematicannon |
| `content/processing` | 5,000 | Basin, blaze burner, sequenced assembly, the processing recipe base |
| `foundation`, `api`, `impl` | 40,000 | Block entity behaviours, connected textures, GUI, networking, rendering helpers |
Data in 6.0.11: 188 blocks and 60 items registered one by one (plus generated families like palettes), and 1881 recipes
in 19 types. Art in 0.5.0.j: 1043 generated and 573 hand-made block models, 1006 textures, 92 connected texture sheets,
153 ponder scenes.
A straight line-by-line translation would be most of a year of work and would carry over things bworld doesn't need,
like datagen, mixins, compat and Forge plumbing. The plan below is built to avoid that.
## Strategy
Six rules that keep the work small:
1. **Import data, don't hand-write it.** One tool converts Create's models, textures, blockstates, recipes, tags, loot,
names and worldgen into bworld's formats, and reports what it couldn't convert. Hundreds of blocks then cost the same
as one, and re-running it after a fix redoes all of them. This replaces Create's datagen entirely.
2. **Port Create's architecture onto bworld's, not its classes.** Create builds every machine from a few shared pieces
(block entity behaviours, a rotation network, processing recipes, instance types). Each piece becomes one bworld
piece, and then the machines are mostly data plus a little code (see [Architecture](#architecture)).
3. **Put general features in the engine, once.** Block capabilities, fluids, redstone, instanced rendering and moving
block structures are things any mod could use. They go in the engine shaped like NeoForge's (check `ports/neoforge`),
and Create is their first user.
4. **Change-driven server work.** Rotation, pipes and belts are networks that only recompute when something in them
changes. Blocks that have nothing to do don't tick.
5. **GPU-driven animation.** A turning part is uploaded once with its axis, speed and offset, and the vertex shader
turns it from the time, like Create's `rotating` instance type. Nothing is sent or computed per frame for something
that turns at a steady speed.
6. **Playable in phases.** Each phase ends with something to use in a world and tests passing, in an order where every
phase only needs the ones before it.
## The Importer
A generic tool for any Minecraft Java mod, `tools/importer.ts`, not one for Create. It converts one kind of resource at
a time, from a single file or a whole folder:
```sh
deno run -A tools/importer.ts model MODEL.json --output PATH # one model, printed without --output
deno run -A tools/importer.ts model path/to/resources --output DIR # every assets/<namespace>/models in it
```
A folder can be a mod's whole resources, one `assets/<namespace>/models`, or a folder inside one, and the output keeps
the same folders. `--parents FOLDER` adds other resources to follow parents through (to tell sprites and OBJ models
apart), and `--remap FILE` renames locations before they become ids. Every kind reports what it converted, what it
skipped and why, and what's wrong, and exits with an error when anything is.
**Ids.** A resource location becomes a bworld id by joining its folders with `_`, the same rule `check-mods` uses for
textures in subfolders: `create:block/cogwheel` is `create:block_cogwheel`, for its model and its texture alike. It's a
pure function of the location, so every kind agrees on ids without sharing state: a blockstate pointing at a model
writes the same id the model was written with. Two locations that join to the same id are an error, fixed with
`--remap`.
**Remaps** are prefix rules, longest first, and a `skip` list of patterns for locations to leave out of every kind:
`{ "textures": { "minecraft:block/": "bworld:" }, "models": {}, "ids": {}, "tags": {} }`. The defaults map Minecraft's
block and item textures, its blocks and items (`ids`) and its tags to the base game's of the same name, and Forge's
shared tags to `c`, which is what bworld calls them. A mod's remap file is where its other vanilla ids go.
**Kinds:**
| Kind | Java | bworld | Status |
| ------------ | -------------------------------------------- | ----------------------------------------------------------------------- | ------ |
| `model` | `assets/*/models/**.json` | `models/`, parents kept, faces renamed, Blockbench extras dropped | Built |
| `texture` | `assets/*/textures/**.png` and `.png.mcmeta` | `textures/`, with animations | Built |
| `blockstate` | `assets/*/blockstates/*.json` | `blocks/*.json` with `variants` or `parts`, string states made numeric | Built |
| `item` | `assets/*/models/item/*.json` | `items/*.json` for items that aren't a block's, with their sprite | Built |
| `lang` | `assets/*/lang/en_us.json` | item and block names | |
| `recipe` | `data/*/recipe(s)/**.json` | `recipes/`: vanilla types to bworld's. Stonecutting and pressing so far | Built |
| `tag` | `data/*/tags/**.json` | `tags/`, Forge's shared tags as `c:`, missing entries optional | Built |
| `loot` | `data/*/loot_table(s)/**.json` | `drops`, or loot tables | |
| `worldgen` | `data/*/worldgen/**.json` | `worldgen/`: ores, and features where bworld has them | |
| `sound` | `assets/*/sounds.json`, `sounds/**.ogg` | sounds, once the engine has them (S8) | |
| `mod` | all of the above | a whole mod folder with a manifest, and one report | |
Block properties (shape, tool, toughness) aren't in any data file: Java mods set them in code. `mod` writes a block for
each blockstate with placeholder properties, and a per-mod table fills them in. For Create that table is
`mods/create/import/blocks.json`. Built for `blockstate` as `--blocks FILE`: each block's fields in it, like its
`components`, replace the ones the importer would write, and a block it names that isn't made is an error.
**What `model` does today.** It keeps `parent`, since the engine merges parents in when it loads (see
[Parents](docs/modding/resources/models.md#parents)), and remaps it like any id. Minecraft's template parents (`cube`,
`cube_all`, `cube_column`, `orientable`, slabs, stairs, walls, glass panes) become the base game's models of the same
name in `mods/bworld/models/templates/`, and the default remap is read from that folder. A parent that holds nothing
bworld uses, like `block/block` (bworld has its own way of drawing blocks' items), is left out. It drops Blockbench's
extras and the `display` transforms of places bworld doesn't draw items (third person, the left hand, the head), keeps
every texture variable (some models draw faces with `#particle`), skips item sprites (`item/generated`) and `loader`
models (OBJ, composite) anywhere up a model's parents, and says why.
Run over Create 0.5.0.j's 2237 model files it converts 2091, and with its textures they make a mod `check-mods` accepts.
The rest are the 16 crimson and warped ones the remap file skips, 79 item sprites, 50 OBJ or composite models and one
with only third person transforms, and 3 name clashes were fixed with one remap line. Merged the way the game merges
them, the 2099 models with boxes come out identical to flattening them, and the files are 1.5 MB instead of 3.4 MB. 26
vanilla textures they use (pistons, redstone torches, rails) aren't in bworld yet.
**What `texture` does today.** It copies PNGs keeping their folders, since bworld already names a texture in a subfolder
by joining the folders with `_`, which is the same id the converted models use. A `.png.mcmeta` becomes the `.json` next
to the png, keeping only its `animation` section: bworld reads the same format. It checks every texture against the
limits a `.bmod` checks, skips Minecraft's own textures (the remap points at bworld's), and needs `--namespace` when a
folder holds textures of more than one mod, since a texture's namespace comes from the mod it ends up in. For Create
0.5.0.j it copies 989 textures and 11 animations, and skips the six 512×512 title screen panoramas. Its textures and
models together make a mod `check-mods` accepts, with warnings only for the 27 missing textures.
**What `blockstate` and `item` do today.** `blockstate` writes a block for each blockstate: each property becomes a
numbered state with the fewest bits that fit (booleans as false and true, facing as north, east, south, west, up and
down so a 2 bit facing still faces its placer), properties that never change the look (like `waterlogged`) are left out,
`variants` keep their models, `x` and `y` turns and `uvlock`, and a `multipart` becomes `parts`, one for each way a part
can be drawn. Blocks that aren't full cubes are `cutout`, or `translucent` when their model asks for it. A model that
can't be imported (OBJ, composite) is drawn as a placeholder cube. Every block gets the same placeholder mining (a
second, any tool) and drops itself, since Java mods set those in code. A block has an item when Java has an item model
for it, drawn with that model, or flat as its sprite. `item` writes the items that aren't a block's, with their sprite,
or with their model for the 9 Java draws in 3D from boxes (wrench, potato cannon, extendo grip), whose texture is the
model's `particle`. The empty blaze burner's model is OBJ, so it's flat.
`mods/create` is the result: 556 blocks and 81 items from 0.5.0.j (the crimson and warped windows are left out with the
remap file's `skip`) that can be placed and look like Create's, with no behavior. `check-mods` accepts it, warning only
about 31 vanilla textures bworld doesn't have yet. The 132 blockstates that use `uvlock` keep it.
**What `tag` and `recipe` do today.** Tags and recipes are checked against the mods next to `--output`, read the way
`check-mods` reads them. `tag` writes each item, block, entity and biome tag in bworld's format, which is Java's,
keeping folders in tag ids. An entry that doesn't exist here becomes optional (`required: false`), so the tag loads now
and picks it up once it's added, and what the remaps skip is left out. `recipe` converts each type bworld has an
equivalent for and reports the rest by type. A recipe naming an item or tag that doesn't exist here, or that only loads
under a condition (another mod installed), is skipped, since bworld's recipes have to be complete. So far
`minecraft:stonecutting` is converted to `bworld:stonecutting`, and `create:pressing` keeps its type in the shape in
[Recipes](#recipes), from 0.5's and 6.0's JSON alike.
Create 0.5.0.j's data gives 89 tags: 45 of Create's and 44 of Forge's shared ones, which are `c:` here. Fluid tags are
skipped. Of its 531 stonecutting recipes, 423 are converted. The other 108 cut granite, diorite, deepslate, calcite,
tuff and dripstone, which bworld doesn't have yet. Re-importing once it does brings them in. Of its 6 pressing recipes,
4 are converted, ingots into sheets. Sugar cane into paper and grass into dirt paths wait for those items.
**For Create**, `mods/create/import/` keeps the remap file, the block table and the commands. Re-running the import is
one command, and hand-written files are never in the folders it writes.
**Vanilla ids in recipes.** Create's recipes use 447 distinct Minecraft ids, like dyes, `minecraft:cobblestone` and
`minecraft:netherrack`. Each becomes the bworld id of the same name, or another with the remap file's `ids`. A recipe
using one bworld doesn't have is skipped and listed in the report, so the report always says how much of Create is
missing because bworld lacks something.
## Architecture
How each of Create's shared pieces lands in bworld:
| Create | bworld |
| --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `SmartBlockEntity` and its `BlockEntityBehaviour`s | A block with several components. Each behaviour (filtering, scroll value, inventory, fluid tank, transported items) is one reusable `create:` component with params |
| `lazyTick` (every N ticks) | A counter in the component, or `on_second` |
| `sendData` / `getUpdateTag` | Client-visible tile data (R1) |
| `BlockEntityRenderer` and Flywheel `Visual`s | Block visuals (R2) drawing instances (R3) |
| `AllPartialModels` | Models in `models/` used by visuals, not blocks (R4) |
| `AllInstanceTypes`: rotating, scrolling, scrolling transformed, fluid | Engine instance types (R3) |
| `RotationPropagator`, `KineticNetwork` | `scripts/kinetics/` |
| NeoForge capabilities (`IItemHandler`, `IFluidHandler`) | Block capabilities (S1, S2) |
| `ProcessingRecipe` and its 19 types | Custom recipe types parsed in one place (`scripts/recipes/`) |
| `AbstractContraptionEntity`, `Contraption` | Engine block structure entities (S6) and the mod's assembly code |
| `AllPackets` | Mod channels |
| Menus and screens | Menus and screens, which bworld has |
| `AllConfigs` | `mods/create/config.json`, read in `setup` (S12) |
| Registrate, datagen | The importer |
| Mixins | Engine hooks, only where an engine feature isn't worth adding |
| Ponder | A scene player (P13) |
| `compat/jei` | Recipe viewer categories (R11) |
Server code is laid out by subsystem, each a folder with no `ctx` in its core logic so tests can call it directly:
```
mods/create/scripts/
server.ts shared.ts client.ts worldgen.ts
kinetics/ connections, spreading, stress, generators
processing/ press, mixer, millstone, crushing, saw, fan, deployer, crafter, basin, burner, sequenced assembly
logistics/ belts, funnels, tunnels, chutes, depots, arm, vaults, filters, packages
fluids/ pipes, pumps, tanks, spouts, drains, hose pulley, boilers
redstone/ links, nixie tubes, display links, diodes, observers
contraptions/ assembly, movement, actors, controls
trains/ track graph, signals, stations, schedules, train movement
equipment/ wrench, goggles, potato cannon, backtank, toolbox, symmetry wand
recipes/ parsing every Create recipe type
visuals/ client visuals for each block that moves
```
## Engine Work
Everything here is general, and none of it mentions Create. Each line says which phase first needs it.
### Rendering
**R1. Client-visible tile data** (P1, built). `block.set_client_data(field, value)` keeps a field of a block's data that
clients see too, apart from its server-only `data`. Players get every field with the chunk, then each field again when
it's set to something else, like NeoForge's `getUpdateTag` but per field, so a fast-changing field doesn't resend the
rest. It's saved, goes with the block, and client scripts read it with `ctx.world.get_client_data`. The display item is
its `item` field now, so there's one way to sync block data. R2's visuals will be told when a field changes.
**R2. Block visuals** (P1, built). `ctx.render.register_visual(block_id, create, { replaces_model })` in client scripts,
like Flywheel's `Visual`. The chunk mesher lists the blocks with visuals in each chunk it meshes, and leaves out the
models of the ones whose visual replaces it, like `ENTITYBLOCK_ANIMATED`. A visual is made from that list, `update`d
when a client data field changes, made again when the block's states change, and deleted with the block or chunk. It
draws `rotating` and `transformed` instances of its block's model or of any model in `models/` by id, turned like a
variant. A visual that has to move on the CPU (a crank easing in, a press head) gets `on_frame`, like `DynamicVisual`.
Visuals are kept per chunk, and only the ones in chunks in view get `on_frame`.
**R3. Instanced drawing** (P1, `transformed` and `rotating` built). A WebGPU pipeline that draws one model many times
from an instance buffer (`vs_instance` in `client/renderer/core.ts`, cut out like cutout terrain). The instance types,
matching Create's:
| Type | Per instance | Shader |
| ------------- | ------------------------------------------ | ----------------------------------------------------------------------- |
| `transformed` | a matrix, light, tint | moves the model |
| `rotating` | position, axis, rpm, offset, light, tint | turns the model around its axis by `ticks × rpm × 0.3 + offset` degrees |
| `scrolling` | position, rotation, uv scroll speed, light | scrolls the texture coordinates, for belts |
| `fluid` | box, fluid texture, fill, light | a box of a fluid's texture, for tanks and pipes |
Instances are grouped by model and type, and each group is one draw call. Light is packed per instance from the block's
light, updated when that light changes. `rotating` is the important one: thousands of shafts at a steady speed cost
nothing per frame. See `ports/sodium` for how to keep buffer updates cheap.
As built, `transformed` and `rotating` share one instance layout (a placement matrix, an axis, rpm, offset and light, 96
bytes): a rotating instance is placed at its block and spins, a transformed one is placed by its matrix and doesn't. So
instances are grouped by model alone. Each group keeps its instances on the CPU too, changes them there, and writes the
range from the first changed instance to the last once a frame. A deleted instance's place is taken by the last one, so
a group's instances are always its first ones. Light comes with each chunk mesh. Every instance is drawn each frame,
with no culling by chunk, since a draw call per model is cheaper than one per model per chunk until there are far more
instances than P1 has. Faces are shaded on the GPU by the way they face after turning. `scrolling` comes with belts (P4)
and `fluid` with tanks (P5).
**R4. Models without blocks** (P1). Any model in `models/` can be loaded by id for visuals, baked once into a GPU
buffer, and turned for whatever axis it's used on. Built: each model is baked the first time a visual uses it and
uploaded the first time it's drawn, once per level. Every model is packed and sent to clients whether a block uses it or
not, and the partials P1's visuals use are all imported with their textures: `shaft`, `shaft_half`, `cogwheel_shaft`,
`cogwheel_shaftless`, `large_cogwheel_shaftless`, `hand_crank/handle`, `gauge/dial`, `gauge/indicator`, both gauge heads
and `rotation_speed_controller/bracket` (as `create:block_shaft_half` and so on). 0.5.0.j's water wheel is its block's
own model. 6.0's wheels that take the wood they're made of swap the oak textures in their model, which needs their new
art and a texture override on a model reference, so it waits for that art.
**R5. The model format** (P0, built). Everything Create's static models use: `parent`, `x` turns, `uvlock` on variants
and parts, element `rotation` at any angle around one axis, and items drawn with models. An item's `model` draws it in
3D like a block's `item_model`, and a model's `display` places it in slots, in the hand, on the ground and on blocks
(`gui`, `firstperson_righthand`, `ground`, `fixed`) from the same starting places as Minecraft's, so Create's transforms
look the same. The wrench, potato cannon and extendo grip are drawn with theirs. Third person and left hand transforms
are dropped until bworld draws items there.
**R6. Connected textures** (P2). Create's casings, windows and vaults pick a tile from a sheet depending on which
neighbours are the same block (`foundation/block/connected/`: rectangle, horizontal, vertical and omni). It's done in
the chunk mesher, from a `connected` field on a block's textures that names the sheet and the kind. Generic: any mod's
glass can use it.
**R7. Block structure rendering** (P7). A contraption's blocks are meshed once by the chunk worker, as a small chunk of
their own, and drawn with the contraption's matrix each frame. Its moving parts (a drill on it, a bearing's shaft) are
instances drawn relative to it. A block change on it remeshes only it.
**R8. Render time** (P1, built). World ticks plus the partial tick, as a shader uniform and for client scripts. It's
`ClientLevel.ticks`, which doesn't jump with `/time`. Visuals get it in `on_frame`, and the shaders as `uniforms.time`
(`set_render_time`), wrapped every 24000 ticks so a 32 bit float stays precise. That's a whole number of turns at any
speed in steps of 0.05 rpm, so those don't jump when it wraps.
**R9. Particles** (P3). A simple GPU particle system: sprite, velocity, gravity, lifetime. Used for rotation indicators,
crushing, fan processing, steam, fluid splashes. Optional for gameplay, so it can come late.
**R10. In-world text and boxes** (P3). Create's value boxes (the number on a scroll value, filter slots on a block's
side) and goggles' overlay. A small API for drawing a label or an item at a point in the world, and a HUD element API,
which is in bworld's types but throws today. Setting a scroll value is built, the way 0.5.0.j does it: a block with
`"scrollable": true` gets the mouse wheel as `on_scroll`, and `send_message(text, { overlay: true })` shows the value
above the hotbar until the box can show it (see [Scrolling](docs/modding/blocks/components.md#scrolling)).
**R11. 3D in GUIs** (P3). Drawing a model or block in a screen, turned and animated, for the recipe viewer's Create
categories (a press pressing over its recipe, like `compat/jei`), goggles and ponder.
### Server and Gameplay
**S0. Ticking only what ticks** (P1, built). `ServerWorld` keeps the tiles that tick per chunk, so `GameServer.tick`
only looks at the chunks near players instead of every tile in the world. A component turns ticking off and on for one
block with `block.set_ticking(false)`, or `ctx.world.set_block_ticking(x, y, z, true)` from elsewhere, like returning no
ticker in NeoForge, and it stays off through saving. A shaft has tile data and never ticks. A press only ticks while
pressing.
**S1. Block capabilities** (P3). `ctx.capabilities.register_block("items", block_id, (block, side) => handler)` and
`ctx.world.capability("items", x, y, z, side)`, like NeoForge's `BlockCapability`. Handlers insert, extract, report
slots, and simulate. Chests and furnaces get them in `mods/bworld`. Funnels, chutes, arms, deployers, belts and vaults
all move items only through this.
**S2. Fluids** (P5). A fluid registry (bworld's liquids are fluids, plus mods' own like Create's honey and chocolate),
fluid stacks with amounts in millibuckets, a `"fluids"` capability, and fluid containers in items (buckets, bottles).
**S3. Redstone** (P6, or earlier for clutches). A signal API in the engine (each block side has a power level 0 to 15,
`get_signal`, `has_neighbor_signal`, updates to neighbours) and the basic blocks in `mods/bworld`: lever, button, dust,
torch, repeater, comparator, lamp. Create reads and makes signals in about 40 blocks, and bworld has no redstone at all
today.
**S4. Machines acting on the world** (P3, built).
- `liquid_flow(x, y, z)` (wraps `common/physics.ts`), for water wheels and fans.
- Item entities in a box, which can be changed and removed, for the press, fans and belts picking items up.
- Pushing entities, for fans.
- Breaking a block over time with progress shown, and its drops, for drills and saws.
- A fake player using an item on a block, for the deployer (`DeployerFakePlayer`).
As built, all in `ctx.world` (see the modding docs for each): `liquid_flow`, `entities_in(from, to, type?)` with
`EntityRef.get_item`, `set_item`, `velocity` and `push`, `spawn_item` for an item lying still where it's put (the
press's extra results), and `player.push`, which is sent to their client since it moves them. `set_break_progress` shows
cracks to the players who have the chunk, sending only a change of stage, and `ctx.blocks.toughness` gives what breaking
time is measured against. `break_block` takes `harvest` (drops what the right tool would, like
`BlockHelper.destroyBlockAs` ignoring tool requirements) and `collect` (returns the drops without dropping them), and
returns the drops. `use_item_on(item, x, y, z, face)` runs a player's whole right click (the block's `on_interact`, the
item's `on_use`, placing) as one `[machine]` player that's never online, standing in front of the face, and returns what
it holds after and anything it was given. The deployer's left click (punching and breaking) isn't there yet, and neither
is a fan pushing players on their client every tick, which Create does on both sides.
**S5. Scripted entities** (P7). Mods can define an entity's behaviour in server scripts (tick, data, interaction) and
how it's drawn in client scripts. Needed for the contraption entity, seats, potato cannon projectiles, trains and
packages.
**S6. Block structure entities** (P7). An entity that carries a grid of blocks with their states and tile data, moved
and turned as a whole: assembled from the world and put back, saved, and synced. Players and mobs stand on it and bump
into it as it moves (Create's `ContraptionCollider`, about 1000 lines, is the hardest part), and they can point at and
use its blocks. Generic: boats with decks, falling structures and elevators would all use it.
**S7. Player API additions** (P1, built). `player.is_sneaking()` on the server and in client scripts, and `sneaking` in
placement and interaction rules, for blocks like `DirectionalKineticBlock` that sneaking places the other way round.
Like Minecraft's secondary use, sneaking with an item in hand skips the clicked block's interactions and uses or places
the item, and an item's `on_use` gets the block it was used on, for the wrench's pickup. Reach is the
`bworld:block_interaction_range` and `bworld:entity_interaction_range` attributes, which clients aim with, so the
extendo grip is a modifier while it's held. `player.start_using(ticks)` uses an item over time, with `on_use_tick`,
`on_release_using` and `on_finish_using`, for the sand paper, builder's tea and packages. The potato cannon and wands
are plain uses, but their reload needs item cooldowns (Minecraft's `getCooldowns`, shown on the hotbar), which aren't
built.
**S8. Sound** (P3). Web Audio, positional, with sound events defined in data. bworld has no sound at all yet. Create's
whistles, presses, cranks and trains want it, but nothing breaks without it.
**S9. More recipe types in bworld** (P0). `shapeless` crafting (Create's cogwheels and many others), stonecutting
(palettes have hundreds of stonecutting recipes, and the mechanical saw uses them), and smoking and blasting for fans.
Stonecutting is built, as `bworld:stonecutting` with the stonecutter, and the saw reads the same recipes with
`ctx.recipes.list("bworld:stonecutting")`.
**S10. Block shape families in bworld** (P10). Stairs, slabs and walls don't exist in bworld yet, and Create's palettes
are mostly those. They're components with placement rules in `mods/bworld`, like the fence and trapdoor.
**S11. Layered ore features** (P2). Create's striated ores are bands of stone types, not blobs. A worldgen feature in
`mods/create/scripts/worldgen.ts`, or a data feature if STRUCTURES.md's data features exist by then. Zinc is a plain ore
in `ores.json`.
**S12. Mod config** (P1, built). A mod's settings and their defaults in its `config.json`, which the server script reads
as `ctx.config` from `setup` on, like NeoForge's server configs. A server changes them in `config/<mod id>.json` next to
`server_mods/`, setting by setting, and a setting the mod doesn't have or a value of the wrong kind stops it from
starting. Players' copies of a mod leave the config out, so what clients need is sent like any other server data. Tests
change settings with `test_game`'s fourth argument. Create's stress values, speed limits and processing times go there
as the machines that use them are built.
**S13. NBT** (P11). Reading and writing structure NBT, shared with STRUCTURES.md's `common/nbt.ts`, for schematics and
ponder scenes.
**S14. Uploading files** (P11). A client sending a file to the server in pieces over a mod channel, for schematics.
## Recipes
All 19 of Create's types, plus the vanilla types its data uses:
| Type | Count | Made by | Phase |
| ----------------------------------------------------- | ----- | ------------------------------------------- | ----------------------- |
| `crafting` (shaped/shapeless) | 369 | crafting grid | P0 |
| `stonecutting` | 327 | stonecutter (S9), mechanical saw | P3 |
| `smelting`, `blasting`, `smoking`, `campfire_cooking` | 64 | furnace, fans | P3 |
| `pressing` | 43 | mechanical press | P3 |
| `milling` | 246 | millstone | P3 |
| `crushing` | 211 | crushing wheels | P3 |
| `cutting` | 32 | mechanical saw | P3 |
| `splashing`, `haunting` | 73 | encased fan through water or soul fire | P3 |
| `deploying` | 167 | deployer | P3 |
| `item_application` | 8 | using an item on a block | P3 |
| `sandpaper_polishing` | 1 | sand paper | P3 |
| `mixing`, `compacting` | 21 | mixer and press over a basin | P3 (items), P5 (fluids) |
| `mechanical_crafting` | 4 | mechanical crafters | P3 |
| `sequenced_assembly` | 3 | belts with presses, deployers, spouts, saws | P4 |
| `filling`, `emptying` | 24 | spout, item drain | P5 |
| `toolbox_dyeing`, `item_copying`, `conversion` | — | built-in, special | P9 |
Create's own types keep Create's shape inside bworld's envelope, but with bworld's item choices (an id, a `#tag`, or a
list of those any of which fits) in place of Java's `{ item }` and `{ tag }`, like every other recipe here:
```json
{
"format_version": 1,
"recipe": {
"type": "create:pressing",
"ingredients": ["#c:ingots/iron"],
"results": [{ "id": "create:iron_sheet", "count": 1 }]
}
}
```
`scripts/recipes/` parses all of them in one place: ingredients as item choices, or sized fluid ingredients; results as
`{ id, count, chance }` or fluid stacks; `processing_time` and `heat_requirement`. Built for pressing, without fluids,
durations or heat yet, in `scripts/recipes/processing.ts`, which the server script runs in `setup`. It checks each
type's input and output limits, which come from each recipe class's `getMaxInputCount` and `getMaxOutputCount`. The
recipe viewer gets one reader for this shape, so every Create type shows with no per-type code, and animated categories
(R11) are added per machine on top.
## Kinetics
The core of everything, so its rules are written out here.
**What turns.** One component, `create:kinetic`, with params for which state holds the axis (`axis`, `facing`,
`horizontal_facing`), which ends have an axle, whether it's a small or large cog, and its stress impact. Generators add
`create:generator` with a capacity. Special connections (gearbox, chain drive, belt, speed controller) are named
handlers in `kinetics/connections.ts`.
**Connections**, with the ratio speed is multiplied by on the way across:
| Pair | Where | Ratio |
| -------------------- | --------------------------------------------------------------------------------- | ------------------------ |
| Axle to axle | Face neighbours along the axis, both with an axle toward each other | 1 |
| Small cog, small cog | Face neighbours, same axis, not along it | −1 |
| Large cog to small | Same axis, level along it, ±1 on both other axes | −2 (−0.5 the other way) |
| Large cog, large cog | Different axes, ±1 along both their axes, 0 on the third | ±1 by the offsets' signs |
| Gearbox | Turns each side, reversing by side, see `getAxisModifier` in `RotationPropagator` | ±1 |
| Chain drive | Along a line of chain drives, with the adjustable one's ratio | per block |
| Belt | Every segment of a belt turns with its two ends | 1 |
A large cog also looks at the 12 blocks diagonal to it along an edge. Cog placement rules (no large cog face to face
with any cog off its axis) and the axis a cog picks when placed are in `CogWheelBlock`.
**Spreading.** When a kinetic block is placed or a generator's speed changes, its speed spreads to what it's connected
to. If a neighbour already turns the other way, or the speed passes 256 rpm, the changed block breaks. A faster
neighbour takes over this block, and a faster block takes over its neighbour's tree. In a loop, a speed that doesn't
match breaks the block. Removing a block clears the tree it was the source of and spreads again from what's left powered
at its edge. Both walks use a queue, not recursion. Rules from `RotationPropagator`.
**Stress.** A network's capacity is the sum of each generator's capacity × |rpm|, and its stress the sum of each block's
impact × |rpm|. When stress is more than capacity, every block in it acts still and is drawn still. The network is found
by walking connections when something changes, never per tick. Values come from `BlockStressValues` and config defaults,
into `config.json`.
**What the client gets.** Each kinetic block's rpm and whether its network is overstressed, in client data (R1). Its
visual makes a `rotating` instance with the axis, rpm and an offset that keeps cog teeth meshed. The offset is 22.5°
when the block's coordinates on the two axes that aren't its axis add up to an even number, otherwise 11.25° for large
cogs and 0 for the rest. A speed change updates one instance, and nothing else happens per frame.
**As built** (`scripts/kinetics/`: the shaft, both cogwheels and the hand crank). `create:kinetic` takes `axis` (the
state with x, y or z) or `facing` (the state with the 6 faces), `shaft` (`both`, `front` or `back`) and `cog` (`small`
or `large`), and its shared rules place blocks like `RotatedPillarKineticBlock`, `DirectionalKineticBlock` and
`CogWheelBlock`, lining up with an axle or cog beside them. A cog that would cut into another isn't placed, like
`isValidCogwheelPosition`, by `state_for_placement` returning `false`. Connections are the table's first four rows.
Spreading is `RotationPropagator`'s, with queues: a block's speed is its `speed` client data, and the block it gets it
from and the generator it comes from (`source` and `network`) are tile data. Two things differ: on_break runs while the
block is still there, so the walk after a removal treats its place as empty, and generators that stop with what turned
them start again right after the walk instead of a tick later (`reActivateSource`). Create's flicker score and its
periodic `validateKinetics` aren't ported, since shafts don't tick. `create:hand_crank` turns while it's clicked, for 10
ticks after each click, the other way while sneaking, and costs hunger by the config's `crank_hunger`. Its visual turns
the half shaft as a `rotating` instance and eases the handle in `on_frame`, like `HandCrankVisual`. A large cog is drawn
as its shaftless model and a separate shaft, offset apart, like `LargeCogVisual`. The crank doesn't pop off when its
block is taken away yet, and cogs have no placement helper (`CogwheelBlockItem`'s ghost offsets). It needed four engine
additions: `looking` in `state_for_placement` (`getNearestLookingDirection`), `false` from it to not place
(`getStateForPlacement` returning null), `ctx.blocks` in shared scripts, and `ctx.world.get_block_ref` for changing
another block's data (`getBlockEntity`).
**Chunk borders.** Tile data keeps speeds across unloading. Create tracks unloaded members' stress separately
(`KineticNetwork`'s unloaded stress). Do the same, so a network across an unloaded chunk counts right.
## Phases
Each phase ends with every test passing and something to see and use in a world. Engine work (R and S) is listed where
it's first needed.
### P0: Importer and Skeleton
- S9 (`shapeless`), R5.
- The importer's other kinds, up to `mod`, and Create's remap file and block table in `mods/create/import/`.
- `mods/create` with every block and item imported, static models, names, recipes that only need crafting, tags.
Check: every Create block can be placed and looks right standing still, crafting recipes work, and the report lists
what's missing.
### P1: Kinetics
- S0, S7, S12, R1, R2, R3 (`transformed` and `rotating`), R4, R8.
- Shaft, cogwheel, large cogwheel, gearbox, vertical gearbox, encased shafts and cogs, clutch and gearshift (with a
placeholder signal until S3), chain drive and adjustable chain gearshift, rotation speed controller, speedometer and
stressometer.
- Generators: hand crank, valve handle, water wheel, large water wheel, creative motor.
- Kinetic network, stress and overstress.
Check: a water wheel drives a long shaft line through gearboxes and cog ratios, all turning smoothly on the GPU, and
1000 shafts cost nothing per frame and only a little per tick.
### P2: Materials and World
- S11, R6.
- Zinc ore, striated stone bands, andesite alloy, brass (made in P3's mixer), casings with connected textures.
Check: new worlds have zinc and Create's stones, and casings join up.
### P3: Processing
- S1, S4, S8, R9, R10, R11, and smoking and blasting from S9.
- Mechanical press, millstone, crushing wheels, mechanical saw, encased fan with its processing (washing, smoking,
blasting, haunting from `AllFanProcessingTypes`), deployer, mechanical crafters, item application, sand paper, depot,
basin, mixer and compacting (items only), blaze burner and its heat.
- Recipe viewer: Create's recipe format, catalysts, and animated categories.
Check: ores go through crushing, washing and smelting into more ingots than a furnace alone gives, and brass is mixed in
a heated basin.
As built so far: the mechanical press, pressing items lying on the ground under it (`PressingBehaviour`'s world mode, in
`scripts/processing/press.ts` and the server script). While it turns it looks for an item with a pressing recipe every
10 ticks, then runs its 240 step cycle at Create's speed for its rpm and presses at the bottom: a lone item turns into
its result, and from a stack one is pressed and its results land beside it, like `bulkPressing` off. It stops ticking
while it's still, and a kinetic block that starts turning ticks again. Clients get the step the cycle was at and its
rate as `press` client data whenever the rate changes, and the visual moves the head from those, so nothing is sent
while it runs at a steady speed. Pressing on belts, depots and basins, its stress impact, sound and particles come with
those.
### P4: Logistics
- R3's `scrolling` type.
- Belts. A belt is a line of segments, and only its controller (its first segment) ticks, moving every item on it
(`BeltInventory`), like `BeltBlockEntity.isController`. Items on belts are instances drawn by the controller's visual.
- Funnels, brass and andesite tunnels, chutes and smart chutes, mechanical arm, item vaults (multiblock), filters and
attribute filters, sequenced assembly on belts.
Check: a sorting line with funnels, filters and an arm, and a precision mechanism made by sequenced assembly.
### P5: Fluids
- S2, R3's `fluid` type.
- Fluid pipes, encased and glass pipes, mechanical pump, fluid tanks (multiblock), spout, item drain, hose pulley,
portable fluid interface, basins with fluids, mixing and compacting with fluids, filling and emptying.
- Pipes are networks found by walking pipes from a pump when something changes (`FluidPropagator`, `FluidNetwork`).
Fluid only moves while a pump runs, and a network with no running pump doesn't tick.
- Steam engine and boilers on tanks (`BoilerData`), which are fluids plus heat plus kinetics.
Check: a steam engine on a tank boiler, fed by a pump from water and heated by blaze burners, drives a factory.
### P6: Redstone
- S3, in `mods/bworld` first.
- Redstone link, nixie tube, display link and display board, threshold switch, smart observer, analog lever, pulse
extender and timer, powered latch and toggle latch, contact, desk bell, sequenced gearshift. The pulse repeater is
bworld's now. Clutch and gearshift switch to real signals.
Check: a factory that stops when a vault is full and shows its count on a display board.
### P7: Contraptions
- S5, S6, R7.
- Mechanical bearing, windmill bearing with sails, clockwork bearing, mechanical piston, rope pulley, elevator pulley
and contacts, gantry carriage, linear and radial chassis, super glue, contraption controls.
- Actors, which act as their contraption moves (`AllMovementBehaviours`): drill, saw, harvester, plough, roller,
deployer, seats, storage, portable interfaces.
- Minecart contraptions need minecarts and rails, which bworld doesn't have. They wait until bworld has them, and the
cart assembler with them.
Check: a windmill turns, a drill on a piston mines a wall, and a player rides an elevator.
### P8: Trains
- Train tracks and curved tracks, which are drawn as meshes made along their curves, not blocks.
- The track graph (`TrackGraph`, `GlobalRailwayManager`), saved with the world, and train movement along it.
- Bogeys, stations, assembly, signals and edge groups, schedules, train controls and HUD, train observers, displays.
- A train is a block structure entity (S6) that follows the graph instead of moving freely.
Check: a scheduled train runs between two stations through signals.
### P9: Equipment
- Wrench (turning blocks, and picking them up with sneaking), goggles and the overlay (R10), extendo grip, potato
cannon, symmetry wand, toolbox, copper backtank and diving gear (air under water), clipboard, blueprint, worldshaper,
and Create's armor.
### P10: Decoration
- S10.
- Palettes (stone types in cut, polished, bricks, small bricks, layered and pillar, each as block, stairs, slab and
wall), windows and panes (connected glass), girders and brackets, scaffolding, ladders, bars, doors, sliding and
framed doors, placards, table cloths, copycats.
- Copycats show another block's texture in their own shape, which needs a model built from tile data. They come last.
### P11: Schematics
- S13, S14.
- Schematic and quill, schematic table with uploads, schematicannon placing from a schematic with its fuel and
materials.
### P12: Package Logistics (6.0)
- Packager, repackager, frogport, chain conveyor, stock link and ticker, redstone requester, factory gauge, shop table
cloths, cardboard.
- All new art, see [Sources](#sources).
### P13: Ponder
- A scene player: a small world from a scene's NBT, drawn in a screen (R11), with Create's scene scripts
(`infrastructure/ponder/scenes/`) ported to run its steps. 0.5.0.j has 153 scene files.
- The `W` key over an item opens its scenes.
## Tests
`tests/create/`, a file per subsystem, with `test_game` from `tests/helpers.ts`. Each phase's check becomes tests:
- **Rules from plain functions:** connection ratios, recipe parsing, belt item movement, pipe flow.
- **Machines in a world:** an input goes in, the right output comes out, and nothing happens without power.
- **Networks:** placing and breaking in the middle of a line; two generators fighting; overstress.
- **Performance:** a tick with 10,000 shafts, and a frame's instance updates, stay under a budget. These are benchmarks
(`deno bench`), not tests, so a slow machine doesn't fail CI.
Following CLAUDE.md, tests check behaviour and not tuned numbers, except where the number is the point, like a 2:1 cog
ratio. Recipes come from the imported data, so tests use Create's recipes instead of copying them.
## Open Questions
- **Minecraft content Create assumes:** blazes (the blaze burner captures one), soul fire (haunting), the Nether and the
End (crushing and haunting recipes), minecarts and rails (cart contraptions, controller rails), honey and chocolate as
fluids, dyes. Add them to bworld, substitute them in Create's remap file, or drop what needs them?
- **Unloaded chunks:** blocks only tick within 6 chunks of a player. Do factories need a way to stay loaded, like chunk
loaders, or is "near a player" fine for bworld?
- **Contraption collision:** port `ContraptionCollider`'s approach, or write a simpler one for bworld's physics
(`common/physics.ts`) that handles turning structures differently?
- **Trains before or after contraptions:** trains reuse S6, but they're also the most-loved part of Create. Is P8 worth
moving earlier?
- **6.0's package logistics:** new art for about 20 blocks. Port them, or leave Create at 0.5's logistics?