connected model - SlimeKnights/Mantle GitHub Wiki

This page details the Mantle connected model loader, registered as mantle:connected.

Loader

The connected model loader is used to allow connected textures on nearly any block.

Format

  • Object: Base object
    • All keys from vanilla block models
    • connection (object): Base object for all connected model keys.
      • textures (object): Object map of texture names to connection types. Each key must correspond to a texture either in the model or the parent.
        • A texture key (string): Key must be the same name as one of the textures in the model. Value is a connection type name.
      • predicate (string): Resource location of the (connection predicate)[#connection-predicates] to use for this block. A connection predicate determines when this block is considered connected to a neighbor.

Connection types

Connection types determine in what way the texture connects to a connected neighbor block. These also determine the list of texture names used in the model. By default, Mantle supports four connection types:

  • cornerless_full:
    • Texture connects to all four neighbors, but does not connect on diagonals. At this time Mantle does not support diagonally connected textures.
    • Extra textures: u, d, l, r, ud, ul, ur, dl, dr, lr, udl, udr, ulr, dlr, udlr. Names correspond to which sides connected to a block.
  • horizontal:
    • Texture connects to the left and right neighbors, does not connect vertically. Note that the connections orient based on the texture orientation.
    • Extra textures: left (left edge of pattern), middle (has block on both sides), right (right edge of the pattern).
  • vertical:
    • Texture connects to the top and bottom neighbors, does not connect horizontally. Note that the connections orient based on the texture orientation.
    • Extra textures: top (top edge of pattern), middle (has block on top and bottom), bottom (bottom edge of the pattern).
  • top:
    • Texture connects only to the block above the texture.
    • Extra textures: bottom (texture when a block is above).

Additional texture types can be registered using ConnectedModelRegistry#registerType()

Textures

For every key in the textures array, texture dependencies are generated in the model based on the connection type. The model will require textures for each of the extra textures listed under the type. The texture at the key will be treated as the texture for no connections, which is also used for item models.

A single texture can also be overridden by defining a texture with the same name as the base, suffixed with an underscore and one of the above names.

This model will automatically handle texture rotations and horizontal or vertical flips, but does not currently support UV lock.

Connection predicates

Connection predicates determines the conditions for a block to connect to its neighbors. By default, Mantle includes two predicates:

  • block: Connects if the two blocks are the same type.
  • pane: Connects if the two blocks are the same type, and either both or neither are just the center piece. Looks better when making a wall of glass panes.

Additional connection predicates can be registered by mods using ConnectedModelRegistry#registerPredicate(). To prevent conflicts, it is encouraged to prefix names with the mod ID.

Example

The following JSON:

{
  "loader": "mantle:connected",
  "parent": "block/cube_all",
  "textures": {
    "all": "tconstruct:block/clear_glass",
    "all_udlr": "tconstruct:block/invisible",
  },
  "connection": {
    "textures": { "all": "cornerless_full" }
  }
}

Defines a connected model based on the standard 6 sided cube block.

The texture all is listed as connected. Since the texture is located in assets/tconstruct/textures/block/clear_glass.png, connected children will be in the folder assets/tconstruct/textures/block/clear_glass/. For example, the texture for ul will be located at assets/tconstruct/textures/block/clear_glass/ul.png.

Since the texture all_udlr is defined, instead of loading the texture for udlr from assets/tconstruct/textures/block/clear_glass/udlr.png, it will use assets/tconstruct/textures/block/invisible.png.

Multipart

Due to a Forge bug, this model does not work on blocks using the multipart model without special support. This can be done on the mod side using IMultipartConnectedBlock. Any models that do not use multipart should work as expected. Within Tinkers Construct, the following multipart blocks were given special support to work with a connected model:

  • Clear Glass Pane
  • Stained Clear Glass Pane (all 16 colors)
  • Seared Glass Pane
⚠️ **GitHub.com Fallback** ⚠️