-
Notifications
You must be signed in to change notification settings - Fork 0
Player Renderer Event
liopyu edited this page Aug 20, 2024
·
5 revisions
The AnimationJS.playerRenderer Client Script provides a way to directly hook into the player renderer and execute custom rendering logic allowing modification to how player entities are rendered in-game. Here it shadows the client player tick event to give us the client player and other arguements.
- Renders an item on the body of a player with customizable position and rotation.
- Example Usage:
AnimationJS.playerRenderer(event => { event.renderBodyItem("minecraft:diamond_axe", 0, 0.5, 0.25, 180, 0, 0); })
-
itemStack: Object - The item stack to render (String (item ID), ResourceLocation, or ItemStack) -
xOffset: Float - The offset along the X-axis -
yOffset: Float - The offset along the Y-axis -
zOffset: Float - The offset along the Z-axis -
xRotation: Float - The rotation around the X-axis (in degrees) -
yRotation: Float - The rotation around the Y-axis (in degrees) -
zRotation: Float - The rotation around the Z-axis (in degrees)
-
- Renders an item on the body of a player with customizable position and rotation with item lighting overlay option.
- Example Usage:
AnimationJS.playerRenderer(event => { event.renderBodyItem("minecraft:diamond_axe", 0.25, 1, 0, 0, 90, 0, 15); })
-
itemStack: Object - The item stack to render (String (item ID), ResourceLocation, or ItemStack) -
xOffset: Float - The offset along the X-axis -
yOffset: Float - The offset along the Y-axis -
zOffset: Float - The offset along the Z-axis -
xRotation: Float - The rotation around the X-axis (in degrees) -
yRotation: Float - The rotation around the Y-axis (in degrees) -
zRotation: Float - The rotation around the Z-axis (in degrees) -
packedLight: int - The light level of the item's model
-
- Inside the
event.rendermethod, you can implement your custom rendering logic using the provided context.
AnimationJS.playerRenderer(event => {
event.render(context => {
const { renderer, entity, entityYaw, partialTicks, poseStack, buffer, packedLight } = context;
// Your custom rendering logic goes here
});
});- Retrieves the render context, providing access to various parameters for custom rendering.
- Example Usage:
This method returns a
AnimationJS.playerRenderer(event => { const { renderer, entity, entityYaw, partialTicks, poseStack, buffer, packedLight } = event.getRenderContext(); })
PlayerRenderContextobject containing:-
renderer: PlayerRenderer - The player renderer instance. -
entity: AbstractClientPlayer - The client player entity being rendered. -
entityYaw: float - The yaw rotation of the entity. -
partialTicks: float - The partial tick time. -
poseStack: PoseStack - The pose stack for applying transformations. -
buffer: MultiBufferSource - The buffer for rendering. -
packedLight: int - The packed light level.
-
- The event is cancellable with
event.cancel(). This halts the default Minecraft renderer method without disabling AnimationJS' animation render logic. - Example Usage:
AnimationJS.playerRenderer(event => { event.cancel(); })