Skip to content

Adding support for modded blocks using behavior

Dana edited this page Apr 3, 2026 · 14 revisions

Important

Make sure to familiarize yourself with the library's syntax: Attribute‐based Matching

Code part

Note

If your mod is purely content or your block uses VariantGroups for rotations, then skip to JSON part below.

Click here to see tutorial for code part

If block implements custom Block class, it should inherit from BlockGeneric, otherwise collisions, selections and decals won't work properly. For example:

public class MyBlock : BlockGeneric

BlockEntity class shouldn't override OnTesselation at all, or at least should do it the same way as BlockEntityDisplay does, which means, it should always call the following method in the end:

return base.OnTesselation(mesher, tessThreadTesselator);

[!Warning] For blocks with custom rotation that doesn't rotate shape with Shape.rotateY, you need to create your own behavior that inherits BlockBehaviorShapeTexturesFromAttributes, then override GetRotation (e.g. if your block has rotation like MeshAngle from BlockEntityGroundStorage).

JSON part

For all possible properties/attributes that can be used in the JSON part, see Attributes and properties.

Set the following class if you need custom hitboxes and proper rendering of decal mesh:

"class": "BlockGeneric"

Important

Make sure to add the following block entity behavior:

"entityBehaviors": [
    { "name": "AttributeRenderingLibrary.ShapeTexturesFromAttributes" }
]

Also add the following behavior:

"behaviors": [
    {
        "name": "AttributeRenderingLibrary.BlockShapeTexturesFromAttributes",
        "properties": {
            // add properties here
        }
    }
]

Warning

If block uses the following vanilla behaviors, you need to replace them with modded behaviors:

  • HorizontalOrientable => AttributeRenderingLibrary.HorizontalOrientable
  • HorizontalAttachable => AttributeRenderingLibrary.HorizontalAttachable
  • NWOrientable => AttributeRenderingLibrary.NWOrientable

They should be added before AttributeRenderingLibrary.BlockShapeTexturesFromAttributes, not after!

Example

Adding the block to creative inventory and handbook

Adding recipe for the block

Clone this wiki locally