Export schematics

This commit is contained in:
2026-11-15 18:41:22 -03:00
parent 2fa109026c
commit 59bfed58bf
18 changed files with 511 additions and 26 deletions
+14
View File
@@ -49,6 +49,7 @@ export interface ServerContext {
world: ServerWorld;
players: PlayerList;
containers: ContainerApi;
schematics: SchematicApi;
items: ItemApi;
blocks: BlockApi;
// every fluid, named and colored by its rules, and fluid handlers, see docs/modding/resources/fluids.md
@@ -118,6 +119,11 @@ export interface BlockComponent<P = any> {
// particular when it's undefined, like neoforge's Capabilities.FluidHandler.BLOCK. undefined when it has none
// there. see ServerFluidApi.block_handler
fluid_handler?(block: BlockRef, params: P, face: Face | undefined): FluidHandler | undefined;
// its tile data the way it's kept outside the world, in a schematic, like neoforge's
// BlockEntity.saveWithoutMetadata: what lives elsewhere written in, like its container's items in place of the
// container's id. any json value. the first of its components that returns something other than undefined gives
// it, and a block without any keeps its data as it is
export_data?(block: BlockRef, params: P): unknown;
// placing and neighbor rules are in shared phases, see BlockRules in cubi/shared
}
@@ -565,6 +571,14 @@ export interface ContainerApi {
delete(id: string): void;
}
// see docs/modding/misc/schematics.md
export interface SchematicApi {
// the blocks between two corners, both of them in it, with their tile data (see BlockComponent.export_data) and
// 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>;
}
export interface ItemApi {
exists(id: Id): boolean;
// every item, in load order