Interface PartRenderer<T extends MultiPart,S>

All Known Subinterfaces:
BlockStatePartBakedModelRenderer<T>
All Known Implementing Classes:
MicroblockPartRenderer

public interface PartRenderer<T extends MultiPart,S>
Responsible for all rendering related operations of a MultiPart.

Registered via MultipartClientRegistry.register(codechicken.multipart.api.MultipartType<? super T>, codechicken.multipart.api.part.render.PartRenderer<? super T, S>).

Created by covers1624 on 7/11/21.

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    collectParts(net.neoforged.neoforge.model.data.ModelData modelData, net.minecraft.world.level.BlockAndTintGetter level, net.minecraft.core.BlockPos pos, net.minecraft.util.RandomSource rand, List<net.minecraft.client.renderer.block.model.BlockModelPart> parts)
    Get the static quads for this part, this is synonymous to BlockStateModelExtension.collectParts(BlockAndTintGetter, BlockPos, BlockState, RandomSource, List)
    default @Nullable S
    Create the state instance used for dynamic BlockEntityRenderer based rendering.
    default boolean
    extractBlockHighlight(T part, PartRayTraceResult hit, net.minecraft.client.renderer.LevelRenderer levelRenderer, net.minecraft.client.renderer.state.LevelRenderState levelRenderState, net.minecraft.client.Camera camera, net.minecraft.world.phys.shapes.CollisionContext collisionCtx, boolean isInTranslucentPass, boolean isHighContrast, Consumer<net.neoforged.neoforge.client.CustomBlockOutlineRenderer> cons)
    Override the drawing of the selection box around this part.
    default void
    extractDynamicState(PartRenderer.BEState beState, S state, T part, float partialTick, net.minecraft.world.phys.Vec3 camera, @Nullable net.minecraft.client.renderer.feature.ModelFeatureRenderer.CrumblingOverlay breakProgress)
    Extract any state required to render this part.
    default void
    submitDynamic(PartRenderer.BEState beState, S state, com.mojang.blaze3d.vertex.PoseStack poseStack, net.minecraft.client.renderer.SubmitNodeCollector collector, net.minecraft.client.renderer.state.CameraRenderState cameraState)
    Submit your dynamic geometry.
  • Method Details

    • collectParts

      default void collectParts(net.neoforged.neoforge.model.data.ModelData modelData, net.minecraft.world.level.BlockAndTintGetter level, net.minecraft.core.BlockPos pos, net.minecraft.util.RandomSource rand, List<net.minecraft.client.renderer.block.model.BlockModelPart> parts)
      Get the static quads for this part, this is synonymous to BlockStateModelExtension.collectParts(BlockAndTintGetter, BlockPos, BlockState, RandomSource, List)

      This is method may be called on the chunk batching thread. World/state access should be performed in a thread-safe manner.

      It is highly recommended that parts do some form of caching for the data returned here.

      Parameters:
      modelData - The model data you returned from MultiPart.getModelData().
      level - The level.
      pos - The block position.
      rand - The RandomSource for this block position.
      parts - The output collector.
    • createDynamicState

      default @Nullable S createDynamicState()
      Create the state instance used for dynamic BlockEntityRenderer based rendering.
      Returns:
      The state. null will disable dynamic rendering.
    • extractDynamicState

      default void extractDynamicState(PartRenderer.BEState beState, S state, T part, float partialTick, net.minecraft.world.phys.Vec3 camera, @Nullable net.minecraft.client.renderer.feature.ModelFeatureRenderer.CrumblingOverlay breakProgress)
      Extract any state required to render this part.

      You should avoid binding your Part instance directly into the state, in the future extract and submit may not always run on the same thread.

      Parameters:
      beState - Useful information from the BE's own state.
      state - Your state to fill.
      part - Your part.
      partialTick - The current partial ticks.
      camera - The camera location.
      breakProgress - The breaking progress.
    • submitDynamic

      default void submitDynamic(PartRenderer.BEState beState, S state, com.mojang.blaze3d.vertex.PoseStack poseStack, net.minecraft.client.renderer.SubmitNodeCollector collector, net.minecraft.client.renderer.state.CameraRenderState cameraState)
      Submit your dynamic geometry.
      Parameters:
      beState - Useful information from the BE's own state.
      state - Your state with filled data.
      poseStack - The current pose stack.
      collector - The submission collector.
      cameraState - The camera state.
    • extractBlockHighlight

      default boolean extractBlockHighlight(T part, PartRayTraceResult hit, net.minecraft.client.renderer.LevelRenderer levelRenderer, net.minecraft.client.renderer.state.LevelRenderState levelRenderState, net.minecraft.client.Camera camera, net.minecraft.world.phys.shapes.CollisionContext collisionCtx, boolean isInTranslucentPass, boolean isHighContrast, Consumer<net.neoforged.neoforge.client.CustomBlockOutlineRenderer> cons)
      Override the drawing of the selection box around this part.

      This is called with the context of

      invalid reference
      RenderHighlightEvent.Block
      .
      Parameters:
      part - The MultiPart being rendered.
      hit - The PartRayTraceResult.
      camera - The Camera camera info.
      pStack - The PoseStack to apply.
      buffers - The MultiBufferSource storage.
      partialTicks - The game partial ticks.
      Returns:
      If any custom rendering was applied. false for default VoxelShape based rendering.