Path: blob/1.21.x/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java
7045 views
/*1* Copyright (c) Forge Development LLC and contributors2* SPDX-License-Identifier: LGPL-2.1-only3*/45package net.minecraftforge.client.event;67import com.mojang.blaze3d.vertex.PoseStack;8import net.minecraft.client.renderer.LightTexture;9import net.minecraft.client.renderer.MultiBufferSource;10import net.minecraft.client.renderer.entity.player.PlayerRenderer;11import net.minecraft.client.renderer.entity.state.PlayerRenderState;12import net.minecraftforge.common.MinecraftForge;13import net.minecraftforge.eventbus.api.bus.CancellableEventBus;14import net.minecraftforge.eventbus.api.bus.EventBus;15import net.minecraftforge.eventbus.api.event.InheritableEvent;16import net.minecraftforge.eventbus.api.event.MutableEvent;17import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;18import net.minecraftforge.fml.LogicalSide;19import org.jetbrains.annotations.ApiStatus;2021/**22* Fired when a player is being rendered.23* See the two subclasses for listening for before and after rendering.24*25* @see RenderPlayerEvent.Pre26* @see RenderPlayerEvent.Post27* @see PlayerRenderer28*/29public abstract sealed class RenderPlayerEvent extends MutableEvent implements InheritableEvent {30public static final EventBus<RenderPlayerEvent> BUS = EventBus.create(RenderPlayerEvent.class);3132private final PlayerRenderState state;33private final PlayerRenderer renderer;34private final PoseStack poseStack;35private final MultiBufferSource multiBufferSource;36private final int packedLight;3738@ApiStatus.Internal39protected RenderPlayerEvent(PlayerRenderState state, PlayerRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {40this.state = state;41this.renderer = renderer;42this.poseStack = poseStack;43this.multiBufferSource = multiBufferSource;44this.packedLight = packedLight;45}4647public PlayerRenderState getState() {48return this.state;49}5051/**52* {@return the player entity renderer}53*/54public PlayerRenderer getRenderer() {55return renderer;56}5758/**59* {@return the pose stack used for rendering}60*/61public PoseStack getPoseStack() {62return poseStack;63}6465/**66* {@return the source of rendering buffers}67*/68public MultiBufferSource getMultiBufferSource() {69return multiBufferSource;70}7172/**73* {@return the amount of packed (sky and block) light for rendering}74*75* @see LightTexture76*/77public int getPackedLight() {78return packedLight;79}8081/**82* Fired <b>before</b> the player is rendered.83* This can be used for rendering additional effects or suppressing rendering.84*85* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.86* If this event is cancelled, then the player will not be rendered and the corresponding87* {@link RenderPlayerEvent.Post} will not be fired.</p>88*89* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},90* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>91*/92public static final class Pre extends RenderPlayerEvent implements Cancellable {93public static final CancellableEventBus<Pre> BUS = CancellableEventBus.create(Pre.class);9495@ApiStatus.Internal96public Pre(PlayerRenderState state, PlayerRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {97super(state, renderer, poseStack, multiBufferSource, packedLight);98}99}100101/**102* Fired <b>after</b> the player is rendered, if the corresponding {@link RenderPlayerEvent.Pre} is not cancelled.103*104* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>105*106* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},107* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>108*/109public static final class Post extends RenderPlayerEvent {110public static final EventBus<Post> BUS = EventBus.create(Post.class);111112@ApiStatus.Internal113public Post(PlayerRenderState state, PlayerRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {114super(state, renderer, poseStack, multiBufferSource, packedLight);115}116}117}118119120