Structures

What is a structure?

A structure in the context of Masterful Machinery is the definition of what a machine needs to look like to start working running recipes.

Once a controller is placed in the world, it will start looking through defined structures to see if any match the blocks around it currently.

If a structure is found and all required blocks are in the correct locations, the controller then shows a confirmation in its GUI saying which structure has been formed. If no structure can be found the controller will say "Not Formed".

How to create a structure?

{
  "name": "My Machine",
  "controllerIds": "mm:controller_a",
  "layout": [
    [
      "  A  "
    ],
    [
      "1PCD2"
    ],
    [
      "1P D2"
    ]
  ],
  "key": {
    "A": {
      "block": "minecraft:glass"
    },
    "P": {
      "block": "mm:my_port_input"
    },
    "D": {
      "portType": "mm:item",
      "input": false
    },
    "1": {
      "port": "mm:my_port",
      "input": true
    },
    "2": {
      "port": "mm:my_port",
      "input": false
    }
  }
}

NOTE: the id of the structure is the datapack resource location to the file relative to the structures directory.

The "name" field is the English name of the structure. As of current, the name is not translatable.

The "controllerIds" field is either a single or list of controllerIds in which this structure can be formed by.


The "layout" field defines the block placement of the structure. each character used will have a corresponding object in the "key" field. Any whitespace is ignored as blank space in the structure.

The "key" is a map which matches up the characters within the "layout" to a requirement of in-world. See HERE for available requirements.


There are a few important considerations to remember when creating a structure in JSON.

In the layout lists, make sure the front of each layer is aligned to the bottom line of the array. As you can see in the example below, the controller character C is the front of the structure and is aligned to the bottom of the array.

"layout": [
    [
        "BBB",
        "ACB"
    ]
]

The reasoning behind this is down to some important assumptions the structure loader needs to make when reading the file. Structures are read layer-by-layer and assume that the top line of each layer is the north most row. So by making the controller point to the south most rows it is assumed that a character looking at the machine is looking north. This allows certain direction based properties like blockstates to be read and rotated consistently.

Last updated