Class CompositeBlockModel

java.lang.Object
net.neoforged.neoforge.client.model.block.CompositeBlockModel
All Implemented Interfaces:
net.minecraft.client.renderer.block.model.BlockStateModel, BlockStateModelExtension, DynamicBlockStateModel

public class CompositeBlockModel extends Object implements DynamicBlockStateModel
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static final record 
     
    static final record 
     

    Nested classes/interfaces inherited from interface net.minecraft.client.renderer.block.model.BlockStateModel

    net.minecraft.client.renderer.block.model.BlockStateModel.SimpleCachedUnbakedRoot, net.minecraft.client.renderer.block.model.BlockStateModel.UnbakedRoot
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final List<net.minecraft.client.renderer.block.model.BlockStateModel>
     
    private final net.minecraft.client.renderer.texture.TextureAtlasSprite
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    CompositeBlockModel(List<net.minecraft.client.renderer.block.model.BlockStateModel> models)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    collectParts(net.minecraft.world.level.BlockAndTintGetter level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.util.RandomSource random, List<net.minecraft.client.renderer.block.model.BlockModelPart> parts)
    Collects the parts of the model that should be rendered.
    @Nullable Object
    createGeometryKey(net.minecraft.world.level.BlockAndTintGetter level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.util.RandomSource random)
    Collects all the data used by the model to produce renderable geometry.
    net.minecraft.client.renderer.texture.TextureAtlasSprite
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.minecraft.client.renderer.block.model.BlockStateModel

    collectParts

    Methods inherited from interface net.neoforged.neoforge.client.extensions.BlockStateModelExtension

    collectParts, particleIcon

    Methods inherited from interface net.neoforged.neoforge.client.model.DynamicBlockStateModel

    collectParts
  • Field Details

    • models

      private final List<net.minecraft.client.renderer.block.model.BlockStateModel> models
    • particleIcon

      private final net.minecraft.client.renderer.texture.TextureAtlasSprite particleIcon
  • Constructor Details

    • CompositeBlockModel

      public CompositeBlockModel(List<net.minecraft.client.renderer.block.model.BlockStateModel> models)
  • Method Details

    • createGeometryKey

      @Nullable public @Nullable Object createGeometryKey(net.minecraft.world.level.BlockAndTintGetter level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.util.RandomSource random)
      Description copied from interface: BlockStateModelExtension
      Collects all the data used by the model to produce renderable geometry. The returned object encapsulates which parts of the world state the model depends on.

      This allows the geometry produced previously by a model to be reused, provided that the key matches. The key can be used to compare the geometry of different models. If this model forwards to a single other model, it can directly return its geometry key. Otherwise, it should use a custom type specific to the model.

      The passed in level, pos and random parameters should not be put directly into the returned key. Only the relevant information should be extracted so that the same key is yielded as often as possible.

      The default implementation returns null, meaning the model does not implement this method. A model that wishes to override this method must therefore not return null, even if the model does not use any passed in state.

      Specified by:
      createGeometryKey in interface BlockStateModelExtension
      Returns:
      an object collecting all the data that influences the geometry of this model; can be any object as long as it implements Object.hashCode() and Object.equals(Object) correctly.
    • collectParts

      public void collectParts(net.minecraft.world.level.BlockAndTintGetter level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.util.RandomSource random, List<net.minecraft.client.renderer.block.model.BlockModelPart> parts)
      Description copied from interface: BlockStateModelExtension
      Collects the parts of the model that should be rendered.

      Typically called on a meshing worker thread, with a snapshot of world state. To access block entity data, use IBlockGetterExtension.getModelData(BlockPos) on the passed level. Avoid accessing or manipulating the block entities directly as they are not thread safe. Other world state is safe to access.

      The parameters passed to this method might not be what the model expects. For example, the model data might be missing or coming from a different/outdated block entity, the block state in the level might be different from the one passed in, and so on... The model should handle these cases gracefully and return the best model it can (e.g. by returning a completely unconnected model, in the case of connected textures).

      Calling IBlockStateExtension.getAppearance(net.minecraft.world.level.BlockAndTintGetter, net.minecraft.core.BlockPos, net.minecraft.core.Direction, net.minecraft.world.level.block.state.BlockState, net.minecraft.core.BlockPos) before accessing the block state is recommended.

      Specified by:
      collectParts in interface BlockStateModelExtension
      Specified by:
      collectParts in interface DynamicBlockStateModel
      Parameters:
      level - a level to query block entity data or other world state
      pos - the position of the block being rendered
      state - the state of the block being rendered
      random - a random source for random model variations
      parts - the list that should receive all parts to be rendered
    • particleIcon

      public net.minecraft.client.renderer.texture.TextureAtlasSprite particleIcon()
      Specified by:
      particleIcon in interface net.minecraft.client.renderer.block.model.BlockStateModel