Class VanillaAttachment

java.lang.Object
net.ixdarklord.coolcatcanvas.api.client.armature.vanilla.VanillaAttachment

public final class VanillaAttachment extends Object
An armature worn on a part of a vanilla model: wings on a zombie's body, a tail on a player, a hat on a villager's head. It moves with the part (vanilla's animation, clips, VanillaPose changes), and has its own animator, so it can play clips, swing on springs and react to the entity. Model it in Blockbench with its origin where it meets the part; then move it with offset.
VanillaModels.player().attach("body", Armature.of("mymod", "wings"))
        .offset(0, -2, 2)
        .animate(animator -> animator.layer("base").drive(ctx -> ctx.living().isFallFlying() ? GLIDE : FOLD))
        .when(player -> player.getItemBySlot(EquipmentSlot.CHEST).is(MyItems.WING_HARNESS));
  • Method Details

    • offset

      public VanillaAttachment offset(float x, float y, float z)
      Moves it from the part's pivot, in pixels (Y up, the model's front north, as in Blockbench).
    • rotate

      public VanillaAttachment rotate(float x, float y, float z)
      Turns it on the part, in degrees.
    • scale

      public VanillaAttachment scale(float scale)
    • animate

      public VanillaAttachment animate(Consumer<Animator> setup)
      Sets up its animator when it is first worn by an entity.
    • when

      public VanillaAttachment when(Predicate<net.minecraft.world.entity.LivingEntity> filter)
      Wears it only on entities that pass, asked every frame.
    • texture

      public VanillaAttachment texture(Function<net.minecraft.world.entity.LivingEntity, @Nullable net.minecraft.resources.Identifier> texture)
      Swaps its first texture per entity; null keeps the armature's.
    • part

      @Internal public String part()
    • armature

      @Internal public Armature armature()
    • setups

      @Internal public List<Consumer<Animator>> setups()
    • test

      @Internal public boolean test(net.minecraft.world.entity.LivingEntity entity)
    • texture

      @Internal @Nullable public @Nullable net.minecraft.resources.Identifier texture(net.minecraft.world.entity.LivingEntity entity)
    • transform

      @Internal public void transform(com.mojang.blaze3d.vertex.PoseStack poseStack)
      Its offset, turn and scale, from the part's pivot (blocks, Blockbench's axes).
    • transform

      @Internal public org.joml.Matrix4f transform(org.joml.Matrix4f matrix)