Class WrapperBlockStateModel
- All Implemented Interfaces:
FabricBlockStateModel, net.minecraft.client.renderer.block.model.BlockStateModel
-
Nested Class Summary
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.Unbaked, net.minecraft.client.renderer.block.model.BlockStateModel.UnbakedRoot -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected net.minecraft.client.renderer.block.model.BlockStateModel -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedWrapperBlockStateModel(net.minecraft.client.renderer.block.model.BlockStateModel wrapped) -
Method Summary
Modifier and TypeMethodDescriptionList<net.minecraft.client.renderer.block.model.BlockModelPart> collectParts(net.minecraft.util.RandomSource random) voidcollectParts(net.minecraft.util.RandomSource random, List<net.minecraft.client.renderer.block.model.BlockModelPart> parts) @Nullable ObjectcreateGeometryKey(net.minecraft.world.level.BlockAndTintGetter level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.util.RandomSource random) Creates a geometry key using the given context.voidemitQuads(QuadEmitter emitter, net.minecraft.world.level.BlockAndTintGetter level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.util.RandomSource random, Predicate<@Nullable net.minecraft.core.Direction> cullTest) Produces this model's geometry.net.minecraft.client.renderer.texture.TextureAtlasSpritenet.minecraft.client.renderer.texture.TextureAtlasSpriteparticleIcon(net.minecraft.world.level.BlockAndTintGetter level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state) Extension ofBlockStateModel.particleIcon()that accepts level state.
-
Field Details
-
wrapped
protected net.minecraft.client.renderer.block.model.BlockStateModel wrapped
-
-
Constructor Details
-
WrapperBlockStateModel
protected WrapperBlockStateModel() -
WrapperBlockStateModel
protected WrapperBlockStateModel(net.minecraft.client.renderer.block.model.BlockStateModel wrapped)
-
-
Method Details
-
collectParts
public void collectParts(net.minecraft.util.RandomSource random, List<net.minecraft.client.renderer.block.model.BlockModelPart> parts) - Specified by:
collectPartsin interfacenet.minecraft.client.renderer.block.model.BlockStateModel
-
collectParts
public List<net.minecraft.client.renderer.block.model.BlockModelPart> collectParts(net.minecraft.util.RandomSource random) - Specified by:
collectPartsin interfacenet.minecraft.client.renderer.block.model.BlockStateModel
-
particleIcon
public net.minecraft.client.renderer.texture.TextureAtlasSprite particleIcon()- Specified by:
particleIconin interfacenet.minecraft.client.renderer.block.model.BlockStateModel
-
emitQuads
public void emitQuads(QuadEmitter emitter, net.minecraft.world.level.BlockAndTintGetter level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.util.RandomSource random, Predicate<@Nullable net.minecraft.core.Direction> cullTest) Description copied from interface:FabricBlockStateModelProduces this model's geometry. This method must be called instead ofBlockStateModel.collectParts(RandomSource, List)orBlockStateModel.collectParts(RandomSource); the vanilla methods should be considered deprecated as they may not produce accurate results. However, it is acceptable for a custom model to only implement the vanilla methods as the default implementation of this method will delegate to one of the vanilla methods.Like
BlockStateModel.collectParts(RandomSource, List), this method may be called outside of chunk rebuilds. For example, some entities and block entities render blocks. In some such cases, the provided position may be the nearest position and not actual position. In others, the provided level may be empty.If multiple independent subtasks use the provided random, it is recommended that implementations reseed the random using a predetermined value before invoking each subtask, so that one subtask's operations do not affect the next subtask. For example, if a model collects geometry from multiple submodels, each submodel is considered a subtask and thus the random should be reseeded before collecting geometry from each submodel. See
MultiPartModel.collectParts(RandomSource, List)for an example implementation of this.Implementations should rely on pre-baked meshes as much as possible and keep dynamic transformations to a minimum for performance.
Implementations should generally also override
FabricBlockStateModel.createGeometryKey(BlockAndTintGetter, BlockPos, BlockState, RandomSource).- Specified by:
emitQuadsin interfaceFabricBlockStateModel- Parameters:
emitter- Accepts model output.level- Access to level state.pos- Position of block for model being rendered.state- Block state whose model was queried for geometry. This is not guaranteed to be the state corresponding tothismodel!random- Random object seeded per vanilla conventions. Do not cache or retain a reference.cullTest- A test that returnstruefor faces which will be culled andfalsefor faces which may or may not be culled. Meant to be used to cull groups of quads or expensive dynamic quads early for performance. Early culled quads will likely not be added the emitter, so callers of this method must account for this. In general, prefer usingMutableQuadView.cullFace(Direction)instead of this test.- See Also:
-
createGeometryKey
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:FabricBlockStateModelCreates a geometry key using the given context. A geometry key represents the exact geometry output fromFabricBlockStateModel.emitQuads(QuadEmitter, BlockAndTintGetter, BlockPos, BlockState, RandomSource, Predicate)when given the same parameters as this method and a cull test that always returnsfalse. Geometry keys are intended to be used in a cache to avoid recomputing expensive transformations applied to a certain model's geometry.The geometry key must implement
Object.equals(Object)andObject.hashCode(). The geometry key may be compared to the geometry key of any other model, not just those produced by this model instance, so care should be taken when selecting the type of the key. Generally, one class of model will want to make its own record class to use for geometry keys.A
nullkey means that a geometry key does exist for specifically the given context; a key may exist for a different context. It is always possible to create a key for any context, but some custom models may choose not to if doing so is too complex. Vanilla models correctly implement this method, but may returnnullwhen delegating to a submodel that returnsnull.- Specified by:
createGeometryKeyin interfaceFabricBlockStateModel- Parameters:
level- The level in which the block exists.pos- The position of the block in the level.state- The block state whose model was queried for a geometry key. This is not guaranteed to be the state corresponding tothismodel!random- Random object seeded per vanilla conventions.- Returns:
- the geometry key, or
nullif one does not exist for the given context - See Also:
-
particleIcon
public net.minecraft.client.renderer.texture.TextureAtlasSprite particleIcon(net.minecraft.world.level.BlockAndTintGetter level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state) Description copied from interface:FabricBlockStateModelExtension ofBlockStateModel.particleIcon()that accepts level state. This method will be invoked most of the time, but the vanilla method may still be invoked when no level context is available.If your model delegates to other
BlockStateModels, ensure that it also delegates invocations of this method to its submodels as appropriate!- Specified by:
particleIconin interfaceFabricBlockStateModel- Parameters:
level- The level in which the block exists.pos- The position of the block in the level.state- The block state whose model was queried for the particle sprite. This is not guaranteed to be the state corresponding tothismodel!- Returns:
- the particle sprite
-