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

top.hendrixshen.magiclib.mixin.minecraft.event.render.EntityRendererMixin Maven / Gradle / Ivy

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

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.class_1297;
import net.minecraft.class_4587;
import net.minecraft.class_4597;
import net.minecraft.class_897;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import top.hendrixshen.magiclib.impl.event.EventManager;
import top.hendrixshen.magiclib.impl.event.minecraft.render.RenderEntityEvent;

@Environment(EnvType.CLIENT)
@Mixin(class_897.class)
public class EntityRendererMixin {
    @Inject(
            method = "render",
            at = @At(
                    value = "HEAD"
            )
    )
    private void preRenderEntity(
            T entity,
            //#if MC < 11500
            //$$ double x,
            //$$ double y,
            //$$ double z,
            //#endif
            float yaw,
            float tickDelta,
            //#if MC > 11404
            class_4587 poseStack,
            class_4597 source,
            int light,
            //#endif
            CallbackInfo ci
    ) {
        EventManager.dispatch(new RenderEntityEvent.PreRender(RenderEntityEvent.EntityRenderContext.of(
                entity,
                //#if MC > 11502
                poseStack,
                //#endif
                tickDelta
        )));
    }

    @Inject(
            method = "render",
            at = @At(
                    value = "RETURN"
            )
    )
    private void postRenderEntity(
            T entity,
            //#if MC < 11500
            //$$ double x,
            //$$ double y,
            //$$ double z,
            //#endif
            float yaw,
            float tickDelta,
            //#if MC > 11404
            class_4587 poseStack,
            class_4597 source,
            int light,
            //#endif
            CallbackInfo ci
    ) {
        EventManager.dispatch(new RenderEntityEvent.PostRender(RenderEntityEvent.EntityRenderContext.of(
                entity,
                //#if MC > 11502
                poseStack,
                //#endif
                tickDelta
        )));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy