Cog wheels

This commit is contained in:
2026-10-15 12:01:46 -03:00
parent a0596ed0ef
commit 74c315bdfc
14 changed files with 331 additions and 88 deletions
+20 -15
View File
@@ -5,8 +5,9 @@ redstone, contraptions, trains, equipment, decoration and schematics. It aims to
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, S7, S12, stonecutting from S9, and the start of P1's kinetics: shafts turned by a hand crank. Facts about Create
come from reading `ports/create1.21.1` and `ports/create1.19.3`, and facts about bworld from its source.
R8, S0, S7, S12, stonecutting from S9, and the start of P1's kinetics: shafts and cogwheels turned by a hand crank.
Facts about Create come from reading `ports/create1.21.1` and `ports/create1.19.3`, and facts about bworld from its
source.
## Sources
@@ -466,19 +467,23 @@ visual makes a `rotating` instance with the axis, rpm and an offset that keeps c
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 and the hand crank). `create:kinetic` takes `axis` (the state with x, y or
z) or `facing` (the state with the 6 faces) and `shaft` (`both`, `front` or `back`), and its shared rules place blocks
like `RotatedPillarKineticBlock` and `DirectionalKineticBlock`, lining up with an axle beside them. Connections are only
axle to axle so far. 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`. The crank doesn't pop off when its block is taken away yet. It needed three engine additions:
`looking` in `state_for_placement` (`getNearestLookingDirection`), `ctx.blocks` in shared scripts, and
`ctx.world.get_block_ref` for changing another block's data (`getBlockEntity`).
**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.