Armor and Attachments
The attachment system is for cases where you do not want to replace the whole entity renderer. A player, zombie, cow, or custom living entity can keep its normal vanilla renderer, while PulseLib draws extra animated model parts on selected ModelPart anchors.
This is useful for custom armor, tails, backpacks, masks, equipment on arms, or other accessories. Definitions can be tied to an item stack, registered globally for living entities, hide vanilla armor for a slot, and render first-person arm attachments.
First-person arm attachments are rendered only by PulseLib's opt-in player-animation first-person pass. The local player needs an active definition with firstPerson(PPlayerFirstPersonSettings.ENABLED), a FIRST_PERSON_CAMERA anchor, and a sampled transform for that arm. See Player animations when an attachment must appear in first person.
Important classes:
PLivingAttachmentDefinitionPLivingAttachmentsPLivingAttachmentSourcePLivingAttachmentSourcesPAttachmentBindingPAttachmentAnchorPAttachmentAnchorResolversPTransformPHumanoidAnchorsPHumanoidBindingsPLivingAttachmentLayerPHumanoidAttachmentLayerPArmorClientExtensions
PulseLib adds attachment render layers for players and living entities automatically through PLibArmorHandler. Attachment definitions are contributed through IPulseClientPlugin.registerAttachments(PAttachmentRegistrar).
Before registering an attachment definition, register its model and material texture references in IPulseClientPlugin.registerModels(PModelRegistrar); otherwise that model is not loaded. See Resources.
Armor item example
Armor is the most direct use case: register a living attachment definition for the armor item, say which equipment slot owns it, and map PulseLib bones to humanoid anchors.
@PulsePlugin
public final class ExamplePulsePlugin implements IPulseClientPlugin
{
@Override
public Identifier getPluginId()
{
return Identifier.fromNamespaceAndPath(ExampleMod.MOD_ID, "attachments");
}
@Override
public void registerAttachments(PAttachmentRegistrar registrar)
{
registrar.registerLiving(MyItems.EXAMPLE_HELMET.get(),
new PLivingAttachmentDefinition(
PModelData.entity(
Identifier.fromNamespaceAndPath("examplemod", "armor/example_helmet")),
PLivingAttachmentSources.equipmentSlot(EquipmentSlot.HEAD),
List.of(PHumanoidBindings.head("helmet")),
PLivingMeshRenderResolvers.defaultLit(),
true));
}
}
For the default glTF loader this model path resolves to:
assets/examplemod/glmodels/entity/armor/example_helmet.glb
hideVanilla = true suppresses matching native armor geometry while the PulseLib attachment supplies its replacement. Shared extraction hooks select armor models on both loaders. PArmorClientExtensions is a NeoForge-only adapter; Common/Fabric code must not depend on that class.
General attachment item
Attachments are not limited to armor slots. A held item can render a tail, an amulet can render on the body, or a global definition can render on an entity even without a specific item stack.
registrar.registerLiving(MyItems.TAIL.get(),
new PLivingAttachmentDefinition(
PModelData.entity(
Identifier.fromNamespaceAndPath("examplemod", "attachment/tail")),
PLivingAttachmentSources.hand(),
List.of(PHumanoidBindings.bind(
PHumanoidAnchors.BODY,
"tail",
PTransform.of(
new Vector3f(0.0f, -0.2f, 0.4f),
new Vector3f(90.0f, 0.0f, 0.0f),
new Vector3f(1.0f, 1.0f, 1.0f)))),
PLivingMeshRenderResolvers.defaultLit(),
false));
PLivingAttachmentSource controls when a definition renders. Built-in factories:
PLivingAttachmentSources.anyEquipmentSlot();
PLivingAttachmentSources.equipmentSlot(EquipmentSlot.HEAD);
PLivingAttachmentSources.hand();
PLivingAttachmentSources.entityPredicate(entity -> entity.isCrouching());
PLivingAttachmentSources.equipmentSlotPredicate(EquipmentSlot.CHEST, entity -> entity.isAlive());
Global attachments use the same definition type:
registrar.registerGlobalLiving(new PLivingAttachmentDefinition(
MODEL_DATA,
PLivingAttachmentSources.entityPredicate(entity -> entity.isInvisible()),
List.of(PHumanoidBindings.body("aura")),
PLivingMeshRenderResolvers.defaultLit(),
false));
Humanoid anchors
Built-in anchors from PHumanoidAnchors:
HEADHATBODYRIGHT_ARMLEFT_ARMRIGHT_LEGLEFT_LEG
Use PHumanoidBindings for common bindings:
PHumanoidBindings.head("helmet");
PHumanoidBindings.body("chest");
PHumanoidBindings.rightArm("right_arm");
PHumanoidBindings.leftLeg("left_leg");
Use PHumanoidBindings.bind(anchor, bone, transform) when you need offset, rotation, or scale. PTransform.of accepts offset, Euler rotation in degrees, and scale vectors.
Custom anchors
Register anchors for custom vanilla EntityModel classes through PAttachmentAnchorResolvers:
public static final PAttachmentAnchor SHELL =
PAttachmentAnchor.of(Identifier.fromNamespaceAndPath("examplemod", "shell"));
public static void registerAnchors()
{
PAttachmentAnchorResolvers.register(MyEntityModel.class, SHELL,
(entity, model) -> ((MyEntityModel<?>) model).shell);
}
Custom mesh rendering
Each definition takes a PLivingMeshRenderResolver. The resolver receives the living entity, stack, baked bone, baked mesh, inherited render context, and partial tick.
PLivingMeshRenderResolver resolver = (entity, stack, bone, mesh, inherited, partialTick) ->
{
int color = stack.hasFoil() ? 0xFF80FFFF : inherited.color();
return inherited.withColor(color);
};
Use the context's with... methods so texture, emissive, alpha-mode, and deformation overrides from other resolvers are retained. Use PLivingMeshRenderResolvers.defaultLit() or inherited() when you do not need per-mesh overrides.
Animated attachments
PLivingAttachmentDefinition can supply standalone controllers. This is useful when the attachment is not itself an item/entity/block entity implementing PAnimatable.
PLivingAttachmentDefinition.ControllerProvider provider = (entity, stack, model, partialTick) ->
{
PAnimationController<MyAttachmentAnimatable> controller =
new PAnimationController<>("idle", state ->
{
state.controller().play(IDLE);
return ControllerState.PLAY;
});
controller.tick(MY_ATTACHMENT_ANIMATABLE, 1, model);
return List.of(controller);
};
Pass that provider as the sixth PLivingAttachmentDefinition constructor argument. The five-argument constructor uses ControllerProvider.EMPTY, so it provides no independent clips.
The provider above illustrates sampling a controller; creating it on every extraction would restart playback. Cache real controllers per entity/stack and tick them once through their owning client lifecycle, then return those controllers from the provider. The attachment layer evaluates their own clip pose and composes it with the selected vanilla anchor. Bindings, texture mappings and model-resource registration are still required.
Native extraction and armor providers
PulseLib installs compatible living/player layers on both loaders and extracts attachment entries into the native living render state. Bone matrices and render inputs are captured when queued; later controller mutations do not change matrices already submitted. Do not treat the returned controller collection as an immutable extraction snapshot or manually invoke a second automatic attachment pass.
PArmorModelProvider remains the shared customization point for armor models. On NeoForge, automatic client-extension registration preserves an item's existing external extension. When a mod explicitly composes its own extension, use PArmorClientExtensions.buildFor(item, base) to preserve unrelated font, arm, overlay, tint and other native callbacks. Use the shared provider for PulseLib model selection. Native equipment queries use EquipmentClientInfo.LayerType. The renderer captures the hidden-slot decision for each wearer and freezes shared model geometry for each deferred draw.
The old BEWLR getCustomRenderer() integration is retired. The legacy dimension-only renderHelmetOverlay(...) overload is a deprecated no-op; implement the native renderFirstPersonOverlay callback with GuiGraphicsExtractor in a NeoForge extension when an overlay is required.