PulseLib Items
Items need a slightly different setup from entities and block entities. Minecraft creates one Item object for the item type, but the player can hold many ItemStacks of that type. If animation state lived directly on the item object, every stack would share the same animation.
PulseLib handles this by using AnimManagerKey and SingletonAnimationManager. The item implements PAnimatable, while its manager is resolved per key.
Item model definition
For Minecraft 26.2, register a SpecialModelRenderer.Unbaked codec and reference its registered type in the item definition under assets/<modid>/items/.
Item class
The important part here is getAnimationManager. Use the key passed into the method, not a single field shared by every stack.
public class WandItem extends Item implements PAnimatable<WandItem>
{
private static final PRawAnimation IDLE = PRawAnimation.begin().
thenLoop("idle").
build();
public WandItem(Properties properties)
{
super(properties);
}
@Override
public PAnimationManager<WandItem> getAnimationManager(AnimManagerKey key)
{
return SingletonAnimationManager.getManager(key, this);
}
@Override
public void registerAnimationControllers(PAnimationManager.PAnimationRegistrar<WandItem> registrar)
{
registrar.add("idle", () -> state ->
{
state.controller().play(IDLE);
return ControllerState.PLAY;
});
}
}
Renderer
The renderer implements Minecraft 26.2’s SpecialModelRenderer through PItemRenderer. It selects a PulseLib render type and creates a render state for each item submission.
public class WandRenderer extends PItemRenderer<WandItem, WandRenderState>
{
public WandRenderer(PModelData data)
{
super(data, PRenderTypes.RenderTypeProvider::trianglesSolid);
}
@Override
protected WandRenderState createRenderState()
{
return new WandRenderState();
}
}
public class WandRenderState extends PItemRenderState.Impl<WandItem>
{
}
Provide an Unbaked special-model wrapper that bakes this renderer:
public record Unbaked(PModelData data)
implements SpecialModelRenderer.Unbaked<WandRenderState>
{
public static final MapCodec<Unbaked> MAP_CODEC = PModelData.CODEC.xmap(Unbaked::new, Unbaked::data);
@Override
public WandRenderer bake(SpecialModelRenderer.BakingContext context)
{
return new WandRenderer(data);
}
@Override
public MapCodec<Unbaked> type()
{
return MAP_CODEC;
}
}
Register that codec during client initialization. NeoForge uses this mod-bus event:
@SubscribeEvent
public static void registerSpecialModels(RegisterSpecialModelRendererEvent event)
{
event.register(Identifier.fromNamespaceAndPath("examplemod", "wand"), Unbaked.MAP_CODEC);
}
On Fabric, register the same codec in Minecraft’s SpecialModelRenderers.ID_MAPPER during client initialization, before item JSON baking. Fabric API provides transitive access to the mapper.
SpecialModelRenderers.ID_MAPPER.put(
Identifier.fromNamespaceAndPath("examplemod", "wand"), Unbaked.MAP_CODEC);
SpecialModelRenderers is in net.minecraft.client.renderer.special. The PulseLib plugin registrar declares model resources. Register the Minecraft codec during loader client setup.
Reference the registered type from assets/examplemod/items/wand.json:
{
"model": {
"type": "minecraft:special",
"base": "examplemod:item/wand",
"model": {
"type": "examplemod:wand",
"model_id": "examplemod:item/wand"
}
}
}
The base model is the normal assets/examplemod/models/item/wand.json file that supplies display transforms. PModelData.CODEC accepts canonical model_id and optional model_loader; texture lists do not belong in this JSON. Item JSON is decoded after the registerModels(PModelRegistrar) callback, so it cannot pass that decoded PModelData instance to registrar.model(...). Create a separate static PModelData for registration and add its material textures there:
public static final PModelData WAND_RESOURCE =
PModelData.item(Identifier.fromNamespaceAndPath("examplemod", "wand"));
registrar.model(WAND_RESOURCE).
texture("body", Identifier.fromNamespaceAndPath("examplemod", "item/wand/body"));
The decoded PModelData is a separate object, but getModel() looks up its canonical ID in PModelCache; it therefore receives the model loaded by WAND_RESOURCE. If model_loader is present in JSON, use the same loader ID in the registration. PulseLib does not convert a legacy builtin/entity JSON into this renderer automatically.
Stack-specific state
AnimManagerKey.of(ItemStack) uses a transient client runtime ID assigned by ItemStackMixin to a nonempty stack whose item implements PAnimatable. Independently created identical stacks receive different keys and controllers. Count, durability and component mutations keep the same key. IDs are never stored in components, NBT or network packets; loading or receiving a stack starts a new identity.
copy() and copyWithCount() inherit the source identity, even before first rendering. A partial split() gives the detached part a fresh ID; a full split transfers the ID and clears the source. Ordinary items and ItemStack.EMPTY receive no ID. Runtime IDs do not change component equality or vanilla stacking. Independent copies of the same source intentionally share animation state; use genuinely independent stacks when independent playback is required.
Use PLibHelper.createManager(this) in an item field initializer and resolve contexts with PLibHelper.getManager(this, key) after construction. Creation defers controller registration until the first access. createInstanceManager and createSingletonManager explicitly choose ownership. The singleton cache separates both owner references and context keys. Identity assignment and copying do not allocate managers or controllers.
The item animation contract is PAnimatable; renderer registration is independent. Register the special renderer and item JSON as shown above. Identity is client-local; the mixin is not loaded on a dedicated server.
Classes used: