Diese Seite auf Deutsch

Your own schematics ​

Reading schematics is half of it: a program can also write them. This recipe draws a round tower and saves it as a schematic – for Litematica, for Create or for Axiom, whichever you use. The file lands in your folder schematics, where those mods find it to place it, and where you can pick it up to share it.

Functions: EXPORT_SCHEMATIC and SCHEMATIC_MATERIALS, with DRAW_CYLINDER

What you need

  • the mods c0de and c0de paint 0.2.0 or later, c0de paint also on your own computer, and the builder's desk as a start
  • a trigger block with a button on it, an empty sheet for the program and a laptop
  • to place the tower: Litematica, Create or Axiom – c0de paint can also build it with the desk
  • no blocks and no rights: the program only writes a file

The tower ​

c0de
PROGRAM export
NOOP
INCLUDE c0de_paint/cpaint
INCLUDE c0de_paint/schematics
NOOP
FUNCTION export
    PARAMETER format STRING "litematic"
BEGIN
    VARIABLE tower TYPE c0de_paint/cpaint/CANVAS
    VARIABLE center STRUCT c0de_paint/cpaint/POINT
    VARIABLE bricks STRUCT c0de_paint/cpaint/BLOCK
    VARIABLE walls TYPE c0de_paint/cpaint/STYLE
    VARIABLE inside TYPE c0de_paint/cpaint/STYLE
    VARIABLE file STRING
    VARIABLE items HASH INTEGER
    ASSIGN bricks.id "stone_bricks" ;
    CALL c0de_paint/cpaint/STYLE_SOLID
        PARAMETER block bricks ;
        RESULT result walls
    CALL c0de_paint/cpaint/STYLE_EMPTY
        RESULT result inside
    CALL c0de_paint/cpaint/DRAW_CYLINDER
        PARAMETER canvas tower ;
        PARAMETER center center ;
        PARAMETER r 2 ;
        PARAMETER h 6 ;
        PARAMETER direction "+y" ;
        PARAMETER side_style walls ;
        PARAMETER fill_style inside ;
    ASSIGN file "tower." ⊕ format ;
    CALL c0de_paint/schematics/EXPORT_SCHEMATIC
        PARAMETER canvas tower ;
        PARAMETER file file ;
        PARAMETER overwrite TRUE ;
    CALL c0de_paint/schematics/SCHEMATIC_MATERIALS
        PARAMETER file file ;
        RESULT result items
    CALL CLS
    CALL PRINT
        PARAMETER value file ⊕ " needs:" ;
    EACH id items
    BEGIN
        CALL PRINT
            PARAMETER value items[id] ⊕ " " ⊕ id ;
    END EACH
END FUNCTION

Running it ​

  1. Bind the laptop to export / export, set the trigger block to the same, and press the button.
  2. The laptop shows tower.litematic needs: and 58 minecraft:stone_bricks: the program has read its own file back.
  3. Look into your folder schematics: there is tower.litematic. Load it in Litematica to place it, or use the desk: put a STRING variable item file with tower.litematic into its trigger block and press build.

For Create, put a STRING variable item format with nbt into the trigger block: the tower becomes tower.nbt, which the schematic table of Create reads. With bp, you get tower.bp, a blueprint for Axiom: copy it into the blueprint folder of Axiom.

the round tower of stone bricks, 5 blocks across and 6 high, built from its schematic with the builder's desk, the laptop next to the trigger block showing "tower.litematic needs:" and "58 minecraft:stone_bricks"

How it works ​

  • The tower is a DRAW_CYLINDER of stone bricks, r 2 and 6 high. The side style covers the whole surface of the cylinder – its wall, its floor and its roof –, and STYLE_EMPTY makes the inside air.
  • EXPORT_SCHEMATIC writes the canvas as a schematic. The extension of the name chooses the format: .litematic, .nbt or .bp. The lowest corner of the canvas becomes the corner of the schematic. The blocks keep their states and data, and the file gets the data version of the server, so newer versions of Minecraft upgrade it.
  • Air and nothing. Voxels that aren't set stay empty in the schematic: where it is placed, the world stays as it is. Air is written as air – the inside of the tower clears whatever was there.
  • Writing goes to the client. Like reading, writing happens on the computer of the player who runs the process: the server sends the file, the client saves it. Every player decides whether their client writes files: allowSchematicWrites in config/c0de_paint-client.properties.
  • Only with overwrite. A file that exists is only replaced with overwrite TRUE; without it, EXPORT_SCHEMATIC raises SCHEMATIC_EXISTS, so a program can't destroy a schematic by accident. The tower is drawn the same way every time, so the program overwrites it.
  • Reading it back. SCHEMATIC_MATERIALS reads the new file: the 58 stone bricks show that it is all there.

Try it yourself ​

  1. Give the tower a door: an opening 1 block wide and 2 high in its wall at ground level. How many stone bricks does the schematic need now?
Solution

Draw a box of STYLE_EMPTY after the cylinder, from 2, 1, 0 to 2, 2, 0: the cylinder's center is 0, 0, 0, so its wall runs through x 2. The two voxels become air, and the laptop says 56 stone bricks.

  1. Save a copy of a building in the world as a schematic.
Solution

CANVAS_FROM_WORLD reads the building into a canvas, like the copy machine of Copying a building; EXPORT_SCHEMATIC writes that canvas. Signs keep their text, chests their contents.

  1. What happens to a name like "towers/tower.litematic"?
Solution

EXPORT_SCHEMATIC raises INVALID_ARGUMENT: schematics are only files directly in the folder schematics. Names with /, \ or : are refused, so a program can't write anywhere else on your computer.

Read more ​