Skip to content

Block behavior and rendering

These types give a mod’s blocks what vanilla blocks have: fire, stripping, composting, fuel, signs, render layers, tints, saplings that grow trees, and falling leaves. Call them during initialization, after the blocks are registered.

Type Summary Status Since Side Thread
BlockBehaviors Vanilla behaviors for blocks and items. Experimental 2.1.0 both setup
BlockRendering Client rendering setup for blocks and items. Experimental 2.1.0 client setup
BuiltinPacks Lists a resource pack from a mod’s jar in the client’s resource pack screen. Experimental 2.5.0 client setup
Colormap A texture read as a grid of colors. Experimental 2.3.0 client any
FallingLeaves Leaves that drift down from a block, as vanilla cherry leaves do. Experimental 2.4.0 both render
ParticleProviders Gives a particle type its client provider from a sprite set, including Stope’s falling leaves. Experimental 2.4.0 client setup
SaplingGrowers Growers for a mod’s saplings. Experimental 2.4.0 both setup

The examples on this page use the Registered handles a mod’s Registrar returns: MAPLE_LOG and STRIPPED_MAPLE_LOG (RotatedPillarBlock), MAPLE_PLANKS, MAPLE_LEAVES, and MAPLE_SAPLING. In your mod’s common initializer, after registering them:

Make a new wood burn, strip, and compost as vanilla wood does
BlockBehaviors.flammable(MAPLE_LOG, 5, 5);
BlockBehaviors.flammable(MAPLE_PLANKS, 5, 20);
BlockBehaviors.flammable(MAPLE_LEAVES, 30, 60);
BlockBehaviors.strippable(MAPLE_LOG, STRIPPED_MAPLE_LOG);
BlockBehaviors.compostable(MAPLE_LEAVES, 0.3f);
BlockBehaviors.compostable(MAPLE_SAPLING, 0.3f);

Experimental · Since 2.1.0 · Side: both · Thread: setup

BlockBehaviors gives a mod’s blocks and items the fire, stripping, composting, fuel, and sign behavior vanilla blocks have. With MAPLE_SIGN, MAPLE_WALL_SIGN, MAPLE_HANGING_SIGN, and MAPLE_WALL_HANGING_SIGN, the maple wood’s four sign blocks:

Let a wood's signs use vanilla's sign block entities
BlockBehaviors.sign(MAPLE_SIGN);
BlockBehaviors.sign(MAPLE_WALL_SIGN);
BlockBehaviors.sign(MAPLE_HANGING_SIGN);
BlockBehaviors.sign(MAPLE_WALL_HANGING_SIGN);
  • Flammability, stripping, and composting write vanilla’s own tables (FireBlock, AxeItem.STRIPPABLES, ComposterBlock.COMPOSTABLES), which Fabric API’s content registries and Forge read too, so other mods see the values.

Experimental · Since 2.1.0 · Side: client · Thread: setup

BlockRendering sets the render layer and tint color of a mod’s see-through or tinted blocks and items on the client.

Draw a sapling with holes, and tint the leaf item
// Client initialization:
BlockRendering.cutout(MAPLE_SAPLING);
BlockRendering.itemColor(MAPLE_LEAVES, (stack, tintIndex) -> 0x48B518);
  • A mod that sets a render layer here needs no render_type in its model JSON.
  • On Forge, a render_type in the model JSON wins over the layer set here.

Experimental · Since 2.3.0 · Side: client · Thread: any

Tint leaves from a colormap texture
// Client initialization:
Colormap leaves = Colormap.of(id("textures/colormap/leaves.png"), 0x48B518);
BlockRendering.blockColor(MAPLE_LEAVES, (state, level, pos, tint) ->
pos == null ? leaves.color(0, 0) : leaves.color(pos.getX(), pos.getZ()));
  • A resource pack can replace the texture, and chunks rebuild after each resource reload, so block colors follow the new texture at once.
  • A color that changes over time (by the day, say) shows only when a chunk section is next rebuilt; Stope does not rebuild sections for it.
  • The texture is decoded on the render thread during the reload, which costs little for a few small colormaps.

Experimental · Since 2.4.0 · Side: both · Thread: setup

The trees are configured features in the mod’s data, named by their keys. Vanilla’s SaplingBlock constructor is protected, and a mod’s common code compiles against vanilla, so the mod’s sapling is a subclass of its own that passes the grower to super. With REGISTRAR, the mod’s Registrar:

A sapling that grows a tree, or a giant from a 2 by 2 square
public final class MapleSaplingBlock extends SaplingBlock {
private static final ResourceKey<ConfiguredFeature<?, ?>> MAPLE =
ResourceKey.create(Registries.CONFIGURED_FEATURE, id("maple"));
private static final ResourceKey<ConfiguredFeature<?, ?>> GIANT_MAPLE =
ResourceKey.create(Registries.CONFIGURED_FEATURE, id("giant_maple"));
public MapleSaplingBlock(Properties properties) {
super(SaplingGrowers.withGiant(MAPLE, GIANT_MAPLE), properties);
}
}
// In the mod's block holder:
static final Registered<SaplingBlock> MAPLE_SAPLING = REGISTRAR.block("maple_sapling",
() -> new MapleSaplingBlock(BlockBehaviour.Properties.copy(Blocks.OAK_SAPLING)));

Experimental · Since 2.4.0 · Side: both · Thread: render

Register the particle type in common initialization with the mod’s REGISTRAR, then emit it from the leaf block. The field is public because the client code below reads it from the mod’s client package:

Register a falling-leaf particle type
public static final Registered<SimpleParticleType> MAPLE_LEAF =
REGISTRAR.register(Registries.PARTICLE_TYPE, "maple_leaf", FallingLeaves::newType);
Drop leaves from a leaf block
@Override
public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource random) {
super.animateTick(state, level, pos, random);
FallingLeaves.animateTick(level, pos, random, MAPLE_LEAF.get(), FallingLeaves.CHERRY_CHANCE);
}

Experimental · Since 2.4.0 · Side: client · Thread: setup

ParticleProviders tells the client how to draw a mod’s particle types; ParticleProviders#fallingLeaves draws a type made by FallingLeaves. With MAPLE_LEAF from the FallingLeaves example:

Draw the falling-leaf particle on the client
// Client initialization:
ParticleProviders.fallingLeaves(MAPLE_LEAF);
  • A falling leaf lasts 300 ticks (15 seconds).

Experimental · Since 2.5.0 · Side: client · Thread: setup

List a 32x resource pack from the mod's jar
// Client initialization; the jar holds resourcepacks/mymod_32x/ with pack.mcmeta, pack.png,
// and assets/:
BuiltinPacks.register("mymod", "mymod_32x", Component.translatable("pack.mymod.mymod_32x"));
  • Turned on, the pack sits above the mod’s own resources, so its textures replace the mod’s defaults.
  • The pack’s ID is <modId>:<folder> on every loader, so a choice saved on one loader names the same pack on the other.