Water wheel and creative motor

This commit is contained in:
2026-10-28 21:40:39 -03:00
parent 507e9aab24
commit 872db88066
9 changed files with 325 additions and 35 deletions
+22 -9
View File
@@ -13,20 +13,25 @@ import {
kinetic_shape,
type KineticParams,
type KineticShape,
OPPOSITE,
} from "./kinetics/connections.ts";
import { head_offset, type PressShown } from "./processing/press.ts";
// a model reaching north turned to reach each way
const facing_turns = (model: string): Record<Face, ModelRef> => ({
north: model,
east: { model, y: 90 },
south: { model, y: 180 },
west: { model, y: 270 },
top: { model, x: 270 },
bottom: { model, x: 90 },
});
// the crank's handle model has its hub on its south side and its grip reaching north, so it's turned to put north
// where the crank faces
const HANDLE = "create:block_hand_crank_handle";
const HANDLE_TURNS: Record<Face, ModelRef> = {
north: HANDLE,
east: { model: HANDLE, y: 90 },
south: { model: HANDLE, y: 180 },
west: { model: HANDLE, y: 270 },
top: { model: HANDLE, x: 270 },
bottom: { model: HANDLE, x: 90 },
};
const HANDLE_TURNS = facing_turns("create:block_hand_crank_handle");
// a half shaft reaching south, from the middle of the block to its side, turned to reach where a block faces
const HALF_SHAFT_TURNS = facing_turns("create:block_shaft_half");
const half_shaft = (facing: Face) => HALF_SHAFT_TURNS[OPPOSITE[facing]];
// how a model made along y is turned to an axis, the way the kinetic blocks' variants turn theirs
const AXIS_TURNS: Record<Axis, { x?: number; y?: number }> = { x: { x: 90, y: 90 }, y: {}, z: { x: 90, y: 180 } };
@@ -42,6 +47,14 @@ export function setup(ctx: ClientContext) {
});
ctx.render.register_visual("create:shaft", plain, { replaces_model: true });
ctx.render.register_visual("create:cogwheel", plain, { replaces_model: true });
// the whole wheel turns, paddles and all, like WaterWheelVisual
ctx.render.register_visual("create:water_wheel", plain, { replaces_model: true });
// its casing is its block's model, and the half shaft out of its front turns, like CreativeMotorRenderer
ctx.render.register_visual("create:creative_motor", (block, instances) => {
const shape = shape_of(block);
return { update: turning(block, instances, shape, half_shaft(shape.facing!)) };
});
// a large cog's teeth are half as far apart as a small one's, so on the blocks where small cogs aren't offset it's
// offset by half of one of its own teeth. its shaft is apart from it and offset like any other, so it lines up with