Class RenderPipeline
java.lang.Object
kr.toxicity.model.api.data.renderer.RenderPipeline
- All Implemented Interfaces:
Iterable<RenderedBone>, BoneEventHandler
public final class RenderPipeline
extends Object
implements BoneEventHandler, Iterable<RenderedBone>
Represents the rendering pipeline for a specific model instance.
This class manages the hierarchy of RenderedBones, handles player visibility and packet bundling,
and coordinates animation updates and inverse kinematics (IK) solving.
- Since:
- 1.15.2
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassRepresents a player for whom the model has been spawned. -
Constructor Summary
ConstructorsConstructorDescriptionRenderPipeline(@NotNull ModelRenderer parent, @NotNull RenderSource<?> source, @NotNull RenderedBone[] bones) Creates a new render pipeline. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddGlobalRotModifier(@NotNull BonePredicate predicate, @NotNull Function<org.joml.Quaternionf, org.joml.Quaternionf> mapper) Adds a global rotation modifier to matching bones.booleanaddLocalRotModifier(@NotNull BonePredicate predicate, @NotNull Function<org.joml.Quaternionf, org.joml.Quaternionf> mapper) Adds a local rotation modifier to matching bones.booleanaddPositionModifier(@NotNull BonePredicate predicate, @NotNull Function<org.joml.Vector3f, org.joml.Vector3f> mapper) Adds a position modifier to matching bones.@NotNull Stream<PlayerChannelHandler> Returns a stream of all players viewing this model.@Nullable RenderedBoneRetrieves a bone by its name.@NotNull @Unmodifiable Collection<RenderedBone> bones()Returns a collection of all bones in this pipeline.@Nullable PlayerChannelHandlerRetrieves the channel handler for a specific player.@NotNull AnimationBundlerCreates an animation packet bundler based on configuration.@NotNull PacketBundlerCreates a packet bundler for this pipeline.voiddefaultPosition(@NotNull Function<org.joml.Vector3f, org.joml.Vector3f> movement) Sets the default position modifier for all bones.voiddespawn()Despawns the model for all players and clears internal state.voiddespawnPacketHandler(@NotNull Consumer<PacketBundler> despawnPacketHandler) Adds a handler for despawn packets.@NotNull BoneEventDispatcher<T> TfirstNotNull(@NotNull Function<RenderedBone, T> mapper) Finds the first non-null result of applying a mapper to all bones.voidforEach(@NotNull Consumer<? super RenderedBone> action) booleanhide(@NotNull PlatformPlayer player) Hides the model from a specific player.voidhideFilter(@NotNull Predicate<PlatformPlayer> filter) Adds a filter to determine if a player should be hidden from the model.voidhidePacketHandler(@NotNull Consumer<PacketBundler> despawnPacketHandler) Adds a handler for hide packets.hitboxes()Returns a stream of all hitboxes associated with this model.booleanisHide(@NotNull PlatformPlayer player) Checks if the model is hidden from a specific player.booleanChecks if the model is spawned for a specific player.@NotNull Iterator<RenderedBone> iterator()booleanmatchAnimation(@NotNull BiPredicate<RenderedBone, AnimationOverrideState> mapper) Applies a mapper to bones matching an animation predicate.booleanmatchTree(@NotNull Predicate<RenderedBone> predicate) Checks if any bones match a predicate.booleanmatchTree(@NotNull BonePredicate predicate, BiPredicate<RenderedBone, BonePredicate> mapper) Applies a mapper to bones matching a predicate.@NotNull Stringname()Returns the name of the model.@NotNull Stream<PlayerChannelHandler> Returns a stream of players who are not hidden and pass the view filter.intReturns the number of players currently viewing this model.booleanremove(@NotNull PlatformPlayer player) Removes the model for a player.booleanrotate(@NotNull ModelRotation rotation, @NotNull PacketBundler bundler) Rotates the model to a new orientation.@Nullable RunningAnimationRetrieves the currently running animation, if any.voidscale(@NotNull FloatSupplier scale) Scales the model.booleanshow(@NotNull PlatformPlayer player) Shows the model to a specific player (if previously hidden).voidshowPacketHandler(@NotNull Consumer<PacketBundler> despawnPacketHandler) Adds a handler for show packets.booleanspawn(@NotNull PlatformPlayer player, @NotNull PacketBundler bundler, @NotNull Consumer<RenderPipeline.SpawnedPlayer> consumer) Spawns the model for a player.voidspawnPacketHandler(@NotNull Consumer<PacketBundler> spawnPacketHandler) Adds a handler for spawn packets.@NotNull Spliterator<RenderedBone> @NotNull Stream<RenderedBone> stream()Returns a sequentialStreamwith the flattened bones as its source.booleantick(@NotNull UUID uuid, @NotNull AnimationBundler bundler) Ticks the model for a specific player (e.g., for per-player animations).booleantick(@NotNull AnimationBundler bundler) Ticks the model, updating animations and IK.@NotNull Stream<PlayerChannelHandler> Returns a stream of players who pass the view filter (regardless of hidden status).voidviewFilter(@NotNull Predicate<PlatformPlayer> filter) Adds a filter to restrict which players can view the model.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BoneEventHandler
extend
-
Constructor Details
-
RenderPipeline
public RenderPipeline(@NotNull @NotNull ModelRenderer parent, @NotNull @NotNull RenderSource<?> source, @NotNull @NotNull RenderedBone[] bones) Creates a new render pipeline.- Parameters:
parent- the parent model renderersource- the source of the rendering (entity or location)bones- the array of root bones- Since:
- 1.15.2
-
-
Method Details
-
createBundler
Creates a packet bundler for this pipeline.- Returns:
- a new packet bundler
- Since:
- 1.15.2
-
channel
Retrieves the channel handler for a specific player.- Parameters:
uuid- the UUID of the player- Returns:
- the channel handler, or null if not found
- Since:
- 1.15.2
-
createAnimationBundler
Creates an animation packet bundler based on configuration.- Returns:
- a new animation packet bundler
- Since:
- 2.2.1
-
eventDispatcher
- Specified by:
eventDispatcherin interfaceBoneEventHandler
-
viewFilter
Adds a filter to restrict which players can view the model.- Parameters:
filter- the predicate to filter players- Since:
- 1.15.2
-
hideFilter
Adds a filter to determine if a player should be hidden from the model.- Parameters:
filter- the predicate to hide players- Since:
- 1.15.2
-
spawnPacketHandler
Adds a handler for spawn packets.- Parameters:
spawnPacketHandler- the consumer to handle spawn packets- Since:
- 1.15.2
-
despawnPacketHandler
Adds a handler for despawn packets.- Parameters:
despawnPacketHandler- the consumer to handle despawn packets- Since:
- 1.15.2
-
hidePacketHandler
Adds a handler for hide packets.- Parameters:
despawnPacketHandler- the consumer to handle hide packets- Since:
- 1.15.2
-
showPacketHandler
Adds a handler for show packets.- Parameters:
despawnPacketHandler- the consumer to handle show packets- Since:
- 1.15.2
-
isSpawned
Checks if the model is spawned for a specific player.- Parameters:
uuid- the UUID of the player- Returns:
- true if spawned, false otherwise
- Since:
- 1.15.2
-
runningAnimation
Retrieves the currently running animation, if any.- Returns:
- the running animation, or null if none
- Since:
- 1.15.2
-
name
Returns the name of the model.- Returns:
- the model name
- Since:
- 1.15.2
-
despawn
public void despawn()Despawns the model for all players and clears internal state.- Since:
- 1.15.2
-
rotate
public boolean rotate(@NotNull @NotNull ModelRotation rotation, @NotNull @NotNull PacketBundler bundler) Rotates the model to a new orientation.- Parameters:
rotation- the new rotationbundler- the packet bundler to use- Returns:
- true if the rotation changed, false otherwise
- Since:
- 1.15.2
-
tick
Ticks the model, updating animations and IK.- Parameters:
bundler- the packet bundler to use- Returns:
- true if any updates occurred
- Since:
- 1.15.2
-
tick
Ticks the model for a specific player (e.g., for per-player animations).- Parameters:
uuid- the UUID of the playerbundler- the packet bundler to use- Returns:
- true if any updates occurred
- Since:
- 1.15.2
-
defaultPosition
public void defaultPosition(@NotNull @NotNull Function<org.joml.Vector3f, org.joml.Vector3f> movement) Sets the default position modifier for all bones.- Parameters:
movement- the movement function- Since:
- 1.15.2
-
scale
Scales the model.- Parameters:
scale- the scale supplier- Since:
- 1.15.2
-
addLocalRotModifier
public boolean addLocalRotModifier(@NotNull @NotNull BonePredicate predicate, @NotNull @NotNull Function<org.joml.Quaternionf, org.joml.Quaternionf> mapper) Adds a local rotation modifier to matching bones.- Parameters:
predicate- the predicate to select bonesmapper- the rotation mapping function- Returns:
- true if any bones were modified
- Since:
- 3.0.0
-
addGlobalRotModifier
public boolean addGlobalRotModifier(@NotNull @NotNull BonePredicate predicate, @NotNull @NotNull Function<org.joml.Quaternionf, org.joml.Quaternionf> mapper) Adds a global rotation modifier to matching bones.- Parameters:
predicate- the predicate to select bonesmapper- the rotation mapping function- Returns:
- true if any bones were modified
- Since:
- 3.0.0
-
addPositionModifier
public boolean addPositionModifier(@NotNull @NotNull BonePredicate predicate, @NotNull @NotNull Function<org.joml.Vector3f, org.joml.Vector3f> mapper) Adds a position modifier to matching bones.- Parameters:
predicate- the predicate to select bonesmapper- the position mapping function- Returns:
- true if any bones were modified
- Since:
- 1.15.2
-
bones
Returns a collection of all bones in this pipeline.- Returns:
- the collection of bones
- Since:
- 1.15.2
-
hitboxes
-
boneOf
Retrieves a bone by its name.- Parameters:
name- the name of the bone- Returns:
- the rendered bone, or null if not found
- Since:
- 1.15.2
-
spawn
@Internal public boolean spawn(@NotNull @NotNull PlatformPlayer player, @NotNull @NotNull PacketBundler bundler, @NotNull @NotNull Consumer<RenderPipeline.SpawnedPlayer> consumer) Spawns the model for a player.- Parameters:
player- the player to spawn forbundler- the packet bundler to useconsumer- a consumer for the spawned player object- Returns:
- true if spawned successfully
- Since:
- 1.15.2
-
remove
Removes the model for a player.- Parameters:
player- the player to remove for- Returns:
- true if removed successfully
- Since:
- 1.15.2
-
matchTree
public boolean matchTree(@NotNull @NotNull BonePredicate predicate, BiPredicate<RenderedBone, BonePredicate> mapper) Applies a mapper to bones matching a predicate.- Parameters:
predicate- the bone predicatemapper- the mapper function- Returns:
- true if any bones matched
- Since:
- 1.15.2
-
matchAnimation
public boolean matchAnimation(@NotNull @NotNull BiPredicate<RenderedBone, AnimationOverrideState> mapper) Applies a mapper to bones matching an animation predicate.- Parameters:
mapper- the mapper function- Returns:
- true if any bones matched
- Since:
- 1.15.2
-
matchTree
Checks if any bones match a predicate.- Parameters:
predicate- the predicate- Returns:
- true if any bones matched
- Since:
- 1.15.2
-
firstNotNull
Finds the first non-null result of applying a mapper to all bones.- Type Parameters:
T- the result type- Parameters:
mapper- the mapper function- Returns:
- the first non-null result, or null
- Since:
- 1.15.2
-
playerCount
public int playerCount()Returns the number of players currently viewing this model.- Returns:
- the player count
- Since:
- 1.15.2
-
allPlayer
Returns a stream of all players viewing this model.- Returns:
- the stream of players
- Since:
- 1.15.2
-
nonHidePlayer
Returns a stream of players who are not hidden and pass the view filter.- Returns:
- the stream of visible players
- Since:
- 1.15.2
-
viewedPlayer
Returns a stream of players who pass the view filter (regardless of hidden status).- Returns:
- the stream of viewed players
- Since:
- 1.15.2
-
hide
Hides the model from a specific player.- Parameters:
player- the player to hide from- Returns:
- true if the player was successfully hidden
- Since:
- 1.15.2
-
isHide
Checks if the model is hidden from a specific player.- Parameters:
player- the player to check- Returns:
- true if hidden
- Since:
- 1.15.2
-
show
Shows the model to a specific player (if previously hidden).- Parameters:
player- the player to show to- Returns:
- true if the player was successfully shown
- Since:
- 1.15.2
-
forEach
- Specified by:
forEachin interfaceIterable<RenderedBone>
-
iterator
- Specified by:
iteratorin interfaceIterable<RenderedBone>
-
spliterator
- Specified by:
spliteratorin interfaceIterable<RenderedBone>
-
stream
Returns a sequentialStreamwith the flattened bones as its source.- Returns:
- a stream of all bones in this pipeline
- Since:
- 2.2.0
-