Class BaseRenderState

java.lang.Object
net.neoforged.neoforge.client.renderstate.BaseRenderState
All Implemented Interfaces:
IRenderStateExtension
Direct Known Subclasses:
EntityRenderState, LevelRenderState, MapRenderState, MapRenderState.MapDecorationRenderState, PlayerRenderState

public abstract class BaseRenderState extends Object implements IRenderStateExtension
Extension class for RenderState objects (ie EntityRenderState). Allows modders to add arbitrary data onto render states for use in custom rendering.
  • Field Details

    • MODEL_PART_VISIBILITY

      private static final ContextKey<it.unimi.dsi.fastutil.objects.Object2BooleanMap<String>> MODEL_PART_VISIBILITY
    • extensions

      protected final Map<ContextKey<?>, Object> extensions
  • Constructor Details

    • BaseRenderState

      public BaseRenderState()
  • Method Details

    • getRenderData

      public <T> @Nullable T getRenderData(ContextKey<T> key)
      Description copied from interface: IRenderStateExtension
      Gets the object associated with the given key.
      Specified by:
      getRenderData in interface IRenderStateExtension
      Type Parameters:
      T - Type of render data
      Parameters:
      key - Static key reference object
      Returns:
      The object associated with the key or null if the key is not present.
    • setRenderData

      public <T> void setRenderData(ContextKey<T> key, @Nullable T data)
      Description copied from interface: IRenderStateExtension
      Sets the object associated with the given key. Key should be stored statically for later retrieval of the object.
      Specified by:
      setRenderData in interface IRenderStateExtension
      Type Parameters:
      T - Type of render data
      Parameters:
      key - Static key reference object
      data - Object to store for custom rendering
    • resetRenderData

      @Internal public void resetRenderData()
    • overrideModelPartVisibility

      public void overrideModelPartVisibility(String modelPart, boolean visible)
      Changes the visibility of a specific model part after Model.setupAnim(java.lang.Object) is called, but before rendering is performed. This allows for hiding parts that are not normally configurable by the render state, for example hiding the player's head.
      Parameters:
      modelPart - Name of the model part. This will be looked up from Model.root() via ModelPart.getChild(String)
      visible - false to disable rendering of the part.
      See Also:
    • getModelPartVisibility

      @Internal public @Nullable it.unimi.dsi.fastutil.objects.Object2BooleanMap<String> getModelPartVisibility()
      Returns the model part visibility or null if all parts have their default visibility.
      Returns:
      the model part visibility or null if all parts have their default visibility