All Downloads are FREE. Search and download functionalities are using the official Maven repository.

top.hendrixshen.magiclib.impl.event.minecraft.render.RenderEntityEvent Maven / Gradle / Ivy

There is a newer version: 0.6.59
Show newest version
package top.hendrixshen.magiclib.impl.event.minecraft.render;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import net.minecraft.class_1297;
import net.minecraft.class_310;
import net.minecraft.class_4587;
import org.jetbrains.annotations.NotNull;
import top.hendrixshen.magiclib.api.event.Event;
import top.hendrixshen.magiclib.api.event.minecraft.render.RenderEntityListener;
import top.hendrixshen.magiclib.api.render.context.RenderContext;

import java.util.List;

public class RenderEntityEvent {
    private static final class_310 mc = class_310.method_1551();

    @AllArgsConstructor(access = AccessLevel.PRIVATE)
    public static class EntityRenderContext {
        private final class_1297 entity;
        private final RenderContext renderContext;
        private final float partialTicks;

        public static @NotNull EntityRenderContext of(
                class_1297 entity,
                //#if MC > 11502
                class_4587 poseStack,
                //#endif
                float partialTicks
        ) {
            return new EntityRenderContext(entity, RenderContext.of(
                    //#if MC > 11502
                    poseStack
                    //#endif
            ), partialTicks);
        }
    }

    @AllArgsConstructor
    public static class PreRender implements Event {
        private final EntityRenderContext context;

        @Override
        public void dispatch(@NotNull List listeners) {
            RenderEntityEvent.mc.method_16011().method_15396("Magiclib#PreEntityRenderHook");


            for (RenderEntityListener listener : listeners) {
                listener.preRenderEntity(this.context.entity, this.context.renderContext, this.context.partialTicks);
            }

            RenderEntityEvent.mc.method_16011().method_15407();
        }

        @Override
        public Class getListenerType() {
            return RenderEntityListener.class;
        }
    }

    @AllArgsConstructor
    public static class PostRender implements Event {
        private final EntityRenderContext context;

        @Override
        public void dispatch(@NotNull List listeners) {
            RenderEntityEvent.mc.method_16011().method_15396("Magiclib#PostEntityRenderHook");

            for (RenderEntityListener listener : listeners) {
                listener.postRenderEntity(this.context.entity, this.context.renderContext, this.context.partialTicks);
            }

            RenderEntityEvent.mc.method_16011().method_15407();
        }

        @Override
        public Class getListenerType() {
            return RenderEntityListener.class;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy