Class ArmatureBlockRenderer<T extends net.minecraft.world.level.block.entity.BlockEntity>

java.lang.Object
net.ixdarklord.coolcatcanvas.api.client.armature.render.ArmatureBlockRenderer<T>
All Implemented Interfaces:
net.minecraft.client.renderer.blockentity.BlockEntityRenderer<T, ArmatureBlockRenderer.State>

public class ArmatureBlockRenderer<T extends net.minecraft.world.level.block.entity.BlockEntity> extends Object implements net.minecraft.client.renderer.blockentity.BlockEntityRenderer<T, ArmatureBlockRenderer.State>
Draws a block entity with an armature, standing on the bottom of its block and turned to the block's facing if it has one (the model's front, north in Blockbench, toward that side). Blockbench "Java Block" models, whose origin is a corner, are moved to fit by themselves. Give the block RenderShape.INVISIBLE so only the armature shows.
BlockEntityRendererRegistry.register(MyBlocks.TURRET_ENTITY, ArmatureBlockRenderer.of(Armature.of("mymod", "turret"), renderer -> renderer
        .animate(animator -> {
            animator.lookAt("barrel").range(12).smoothing(0.3F);
            animator.layer("base").drive(ctx -> ctx.<TurretEntity>owner().isFiring() ? FIRE : IDLE);
        })));
  • Constructor Details

    • ArmatureBlockRenderer

      public ArmatureBlockRenderer(net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider.Context context, Armature armature)
  • Method Details

    • of

      public static <T extends net.minecraft.world.level.block.entity.BlockEntity> net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider<T, ArmatureBlockRenderer.State> of(Armature armature, Consumer<ArmatureBlockRenderer<T>> configure)
    • of

      public static <T extends net.minecraft.world.level.block.entity.BlockEntity> net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider<T, ArmatureBlockRenderer.State> of(Armature armature)
    • armature

      public Armature armature()
    • animate

      public ArmatureBlockRenderer<T> animate(Consumer<Animator> setup)
    • texture

      public ArmatureBlockRenderer<T> texture(Function<T, @Nullable net.minecraft.resources.Identifier> texture)
    • scale

      public ArmatureBlockRenderer<T> scale(float scale)
    • facing

      public ArmatureBlockRenderer<T> facing(boolean facing)
      Whether the model turns to the block's facing; on by default.
    • viewDistance

      public ArmatureBlockRenderer<T> viewDistance(int blocks)
      How far away, in blocks, it is still drawn; 64 by default.
    • attach

      public ArmatureBlockRenderer<T> attach(String point, ArmatureAttachment attachment)
    • setupAnimator

      protected void setupAnimator(Animator animator, T blockEntity)
      Sets up a new animator, after the animate(Consumer) setups; for subclasses.
    • facing

      protected net.minecraft.core.Direction facing(T blockEntity, net.minecraft.world.level.block.state.BlockState state)
      Which way the model faces; by default the block's facing, or north.
    • createRenderState

      public ArmatureBlockRenderer.State createRenderState()
      Specified by:
      createRenderState in interface net.minecraft.client.renderer.blockentity.BlockEntityRenderer<T extends net.minecraft.world.level.block.entity.BlockEntity, ArmatureBlockRenderer.State>
    • extractRenderState

      public void extractRenderState(T blockEntity, ArmatureBlockRenderer.State state, float partialTicks, net.minecraft.world.phys.Vec3 cameraPosition, @Nullable net.minecraft.client.renderer.feature.ModelFeatureRenderer.CrumblingOverlay breakProgress)
      Specified by:
      extractRenderState in interface net.minecraft.client.renderer.blockentity.BlockEntityRenderer<T extends net.minecraft.world.level.block.entity.BlockEntity, ArmatureBlockRenderer.State>
    • submit

      public void submit(ArmatureBlockRenderer.State state, com.mojang.blaze3d.vertex.PoseStack poseStack, net.minecraft.client.renderer.SubmitNodeCollector collector, net.minecraft.client.renderer.state.level.CameraRenderState camera)
      Specified by:
      submit in interface net.minecraft.client.renderer.blockentity.BlockEntityRenderer<T extends net.minecraft.world.level.block.entity.BlockEntity, ArmatureBlockRenderer.State>
    • shouldRenderOffScreen

      public boolean shouldRenderOffScreen()
      Specified by:
      shouldRenderOffScreen in interface net.minecraft.client.renderer.blockentity.BlockEntityRenderer<T extends net.minecraft.world.level.block.entity.BlockEntity, ArmatureBlockRenderer.State>
    • getViewDistance

      public int getViewDistance()
      Specified by:
      getViewDistance in interface net.minecraft.client.renderer.blockentity.BlockEntityRenderer<T extends net.minecraft.world.level.block.entity.BlockEntity, ArmatureBlockRenderer.State>