Placing schematics

This commit is contained in:
2026-11-15 19:01:40 -03:00
parent 59bfed58bf
commit 6bb2c87373
10 changed files with 464 additions and 50 deletions
+21
View File
@@ -18,8 +18,10 @@ import type {
} from "./shared.ts";
import type { ArgumentType, CommandNode } from "../commands.ts";
import type { LootTableJson } from "../loot.ts";
import type { Schematic } from "../schematic.ts";
export type { ArgumentType, CommandContext, CommandNode, Suggestion } from "../commands.ts";
export type { Schematic, SchematicBlock, SchematicEntity, SchematicPaletteEntry } from "../schematic.ts";
export type {
EventSignal,
@@ -577,6 +579,25 @@ export interface SchematicApi {
// the entities whose feet are in that box, written to a .cbsm file the host keeps in a temporary directory, like
// create's schematic and quill. resolves to where the file is. throws for a box of more than 1048576 blocks (2^20)
export(from: Position, to: Position): Promise<string>;
// adds a schematic for place, by an id in this mod's namespace, while the server phase runs. it's checked here:
// every block, state and entity in it has to be registered
register(id: Id, schematic: Schematic): void;
// puts a registered schematic in the world, all of it at once, replacing what was there, air too. replaced blocks
// get their on_break. blocks it has data for get that data as it is, the rest their on_create, then everything
// placed tells the blocks beside it. its entities come with new uuids. throws for an id nothing registered, or a
// placement that isn't one, before changing anything
place(id: Id, placement: SchematicPlacement): void;
}
export interface SchematicPlacement {
// where the schematic's lowest corner goes, before it's turned
position: Position;
// the block it turns and mirrors around, from its lowest corner. 0 0 0 by default
position_pivot?: Position;
// clockwise seen from above. turns positions, a state named facing and entities' yaw, see STRUCTURES.md
rotation?: 0 | 90 | 180 | 270;
// the axis that gets flipped, before it's turned
mirror?: "x" | "z";
}
export interface ItemApi {