Single module modding
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# Visuals
|
||||
|
||||
A visual draws a block with code, for blocks that move or show what's in them: a shaft that turns, a press coming down,
|
||||
the items and fluid in a machine. A client script registers one for a block, and every block of that kind in a shown
|
||||
the items and fluid in a machine. The client phase registers one for a block, and every block of that kind in a shown
|
||||
chunk gets its own. It's bworld's version of Minecraft's block entity renderers, shaped like the Flywheel visuals Create
|
||||
draws its machines with.
|
||||
|
||||
@@ -10,7 +10,7 @@ draws its machines with.
|
||||
```ts
|
||||
import type { ClientContext } from "cubi/client";
|
||||
|
||||
export function setup(ctx: ClientContext) {
|
||||
export function client(ctx: ClientContext) {
|
||||
ctx.render.register_visual("copper_tools:shaft", (block, instances) => {
|
||||
const shaft = instances.rotating();
|
||||
const turn = () => shaft.set_rotation("y", block.get_client_data<number>("speed") ?? 0);
|
||||
@@ -20,7 +20,7 @@ export function setup(ctx: ClientContext) {
|
||||
}
|
||||
```
|
||||
|
||||
- Visuals can only be registered during `setup`, and a block has at most one.
|
||||
- Visuals can only be registered while the client phase runs, and a block has at most one.
|
||||
- With `replaces_model: true`, the block's model is left out of the terrain, for a visual that draws all of the block,
|
||||
like the shaft above. Without it, the model is drawn as usual and the visual adds to it, like a press's head over its
|
||||
casing. The model is still what the block's item, its outline and the cracks on it while it's broken are drawn with.
|
||||
@@ -145,7 +145,7 @@ ctx.render.register_visual("copper_tools:crank", (block, instances) => {
|
||||
});
|
||||
```
|
||||
|
||||
Only visuals in chunks in view get `on_frame`, so keep anything that has to happen out of view in the server script.
|
||||
Only visuals in chunks in view get `on_frame`, so keep anything that has to happen out of view in the server phase.
|
||||
|
||||
## Cost
|
||||
|
||||
|
||||
Reference in New Issue
Block a user