Skip to content

Block rendering and particles

These types decide how a mod’s blocks look on the client: their render layer and tint, a block drawn as another block’s state or from a value it keeps, leaves that fall from a leaf block, the client providers of a mod’s particle types, and a resource pack shipped in the mod’s jar. Most are registered in client initialization, and FallingLeaves registers its particle type in common code; what a block does in the world is on Block behavior.

Type Summary Status Since Side Thread
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
ClientWorldClock The time of day in the world the client is in. Experimental 2.10.0 client any
Colormap A texture read as a grid of colors. Experimental 2.3.0 client any
DataModel A block’s model drawn from a value read at its position, such as a cask’s fill level, for DataModels#register. Experimental 2.10.0 client any
DataModels A block drawn per position from a value its block entity keeps, with extra models baked for it. Experimental 2.10.0 client setup
FallingLeaves Leaves that drift down from a block, as vanilla cherry leaves do. Experimental 2.4.0 both render
FoliageColors Foliage colors for a leaf block’s and its item’s color providers. Experimental 2.10.0 client any
LeafFall The look and fall of a falling-leaf particle. Experimental 2.10.0 client any
MimicModels A block that draws, at each position, the block state a MimicSource gives. Experimental 2.10.0 client setup
MimicSource The block state a mimic block draws at a position, for MimicModels#register. Experimental 2.10.0 client any
ParticleProviders Gives a particle type its client provider from a sprite set, including Stope’s falling leaves. Experimental 2.4.0 client setup

The examples on this page use the Registered handles a mod’s Registrar returns: MAPLE_LEAVES and MAPLE_SAPLING. In your mod’s client initializer:

Draw a sapling with holes, and tint leaves by their biome
BlockRendering.cutout(MAPLE_SAPLING);
BlockRendering.blockColor(MAPLE_LEAVES, (state, level, pos, tintIndex) -> FoliageColors.at(level, pos));
BlockRendering.itemColor(MAPLE_LEAVES, (stack, tintIndex) -> FoliageColors.defaultColor());

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

ClientWorldClock: Experimental · Since 2.10.0 · Side: client · Thread: any

FoliageColors: Experimental · Since 2.10.0 · Side: client · Thread: any

BlockRendering sets the render layer and tint color of a mod’s see-through or tinted blocks and items on the client. The quick start shows the three calls.

  • FoliageColors gives a color provider the foliage color vanilla’s oak leaves take.

  • ClientWorldClock#dayTime gives a color provider the client world’s day time, for a color that changes by the day.

  • 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.

MimicModels: Experimental · Since 2.10.0 · Side: client · Thread: setup

MimicSource: Experimental · Since 2.10.0 · Side: client · Thread: any

MimicModels makes a block draw another block’s state, which a MimicSource gives per position. PaintedCableBlockEntity keeps the state a player painted the cable with in a volatile BlockState field, paint, and redraws from SyncedBlockEntity#onClientData as SyncedBlockEntity shows. With PAINTED_CABLE, its block:

Draw a painted cable as the block it was painted with
// Client initialization:
MimicModels.register(PAINTED_CABLE, MimicSource.fromBlockEntity(
PaintedCableBlockEntity.class, cable -> cable.paint));
  • Set paint only on the render thread, in readClientData, and read it once per call.

DataModel: Experimental · Since 2.10.0 · Side: client · Thread: any

DataModels: Experimental · Since 2.10.0 · Side: client · Thread: setup

DataModels draws a block from a value read at its position, with the chunk and no block entity renderer. CaskBlockEntity keeps its fill in a volatile CaskFill field, fill, an enum of EMPTY, HALF, and FULL, and redraws from SyncedBlockEntity#onClientData as SyncedBlockEntity shows. With CASK, its block, and id("block/cask_glass_half") and id("block/cask_glass_full") its glass models, HALF_GLASS and FULL_GLASS:

Draw a cask's sight glass at its fill
// Client initialization:
DataModels.extraModel(HALF_GLASS);
DataModels.extraModel(FULL_GLASS);
DataModels.register(CASK, new DataModel<CaskFill>() {
@Override
public CaskFill valueAt(BlockAndTintGetter level, BlockPos pos) {
return level.getBlockEntity(pos) instanceof CaskBlockEntity cask ? cask.fill : null;
}
@Override
public void parts(CaskFill fill, BlockState state, BakedModel base, Consumer<BakedModel> out) {
out.accept(base);
if (fill == CaskFill.HALF) out.accept(DataModels.model(HALF_GLASS));
if (fill == CaskFill.FULL) out.accept(DataModels.model(FULL_GLASS));
}
});

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

Register the particle type in common initialization with REGISTRAR, 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);
}

LeafFall: Experimental · Since 2.10.0 · Side: client · Thread: any

ParticleProviders: 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);

Leaves that should fall slower than cherry leaves, or share one gray sprite, take a LeafFall in place of the call above. With MAPLE_PETAL, a second type registered as MAPLE_LEAF is:

Draw pink petals that fall at half a cherry leaf's rate
// Client initialization:
ParticleProviders.fallingLeaves(MAPLE_PETAL, LeafFall.asCherry().tinted(0xFFB7C5).fallSpeed(0.5f));

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

BuiltinPacks lists a resource pack that ships inside the mod’s jar, off until the player turns it on. With the jar holding the folder BuiltinPacks#folder32x names, a whole pack with pack.mcmeta, pack.png, and assets/, and the lang file holding the key BuiltinPacks#titleKey32x gives, in client initialization:

List a 32x resource pack from the mod's jar
BuiltinPacks.register32x("mymod");

register32x shows the title in gold. For a title of another color, or a pack of another name, call BuiltinPacks#register with the folder and the title. In client initialization:

List the 32x pack under a title the mod styles itself
BuiltinPacks.register("mymod", BuiltinPacks.folder32x("mymod"),
Component.translatable(BuiltinPacks.titleKey32x("mymod")).withStyle(ChatFormatting.AQUA));
  • Turned on, the pack sits above the mod’s own resources, so its textures replace the mod’s defaults.
  • Block behavior: SyncedBlockEntity, which sends the data a mimic or data model draws from, and a wood’s fire, stripping, and sapling growers.
  • Registration and ids: registering the blocks, items, and particle types these calls take.
  • Lifecycle events: the F3 line example, which reads a Colormap.