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

top.hendrixshen.magiclib.impl.event.minecraft.render.RenderLevelEvent 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_310;
import net.minecraft.class_4587;
import net.minecraft.class_638;
import org.jetbrains.annotations.NotNull;
import top.hendrixshen.magiclib.api.event.Event;
import top.hendrixshen.magiclib.api.event.minecraft.render.RenderLevelListener;
import top.hendrixshen.magiclib.api.render.context.RenderContext;

import java.util.List;

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

    @AllArgsConstructor(access = AccessLevel.PRIVATE)
    public static class LevelRenderContext {
        private final class_638 level;
        private final RenderContext renderContext;
        private final float partialTicks;

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

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

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

            for (RenderLevelListener listener : listeners) {
                listener.preRenderLevel(this.context.level, this.context.renderContext, this.context.partialTicks);
            }
            RenderLevelEvent.mc.method_16011().method_15407();
        }

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

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

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

            for (RenderLevelListener listener : listeners) {
                listener.postRenderLevel(this.context.level, this.context.renderContext, this.context.partialTicks);
            }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy