diff --git a/Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java b/Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java index 8301f26..9621fd4 100644 --- a/Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java +++ b/Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java @@ -30,8 +30,6 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.scores.Team; -import org.joml.Quaternionf; - import java.text.DecimalFormat; import java.util.*; @@ -210,8 +208,8 @@ private static boolean shouldShowPlate(LivingEntity living, Entity cameraEntity) } public static void hookRender(Entity entity, PoseStack poseStack, MultiBufferSource buffers, - Camera camera, EntityRenderer entityRenderer, - float partialTicks, double x, double y, double z) { + Camera camera, EntityRenderer entityRenderer, + float partialTicks, double x, double y, double z) { final Minecraft mc = Minecraft.getInstance(); if (!(entity instanceof LivingEntity living)) { return; @@ -248,8 +246,6 @@ public static void hookRender(Entity entity, PoseStack poseStack, MultiBufferSou poseStack.pushPose(); poseStack.scale(-globalScale, -globalScale, globalScale); - - // Background if (NeatConfig.instance.drawBackground()) { float padding = NeatConfig.instance.backgroundPadding(); diff --git a/Xplat/src/main/java/vazkii/neat/mixin/EntityRenderDispatcherMixin.java b/Xplat/src/main/java/vazkii/neat/mixin/EntityRenderDispatcherMixin.java deleted file mode 100644 index 0e195ec..0000000 --- a/Xplat/src/main/java/vazkii/neat/mixin/EntityRenderDispatcherMixin.java +++ /dev/null @@ -1,39 +0,0 @@ -package vazkii.neat.mixin; - -import com.mojang.blaze3d.vertex.PoseStack; - -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.entity.EntityRenderDispatcher; -import net.minecraft.client.renderer.entity.EntityRenderer; -import net.minecraft.world.entity.Entity; - -import org.joml.Quaternionf; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import vazkii.neat.HealthBarRenderer; - -@Mixin(EntityRenderDispatcher.class) -public abstract class EntityRenderDispatcherMixin { - @Shadow - public abstract Quaternionf cameraOrientation(); - - /** - * Hooks right after the main entity renderer runs. - * Here we have a good GL state set up, the buffers are still available for fabulous mode, etc. - * It's a much better point to render our bars than something like RenderLevelLastEvent. - */ - @Inject( - method = "render", at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/renderer/entity/EntityRenderer;render(Lnet/minecraft/world/entity/Entity;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", - shift = At.Shift.AFTER - ) - ) - private void neat_renderHealthBar(Entity entity, double worldX, double worldY, double worldZ, float entityYRot, float partialTicks, PoseStack poseStack, MultiBufferSource buffers, int light, CallbackInfo ci) { - //HealthBarRenderer.hookRender(entity, poseStack, buffers, cameraOrientation()); - } -} diff --git a/Xplat/src/main/java/vazkii/neat/mixin/LevelRendererMixin.java b/Xplat/src/main/java/vazkii/neat/mixin/LevelRendererMixin.java index ff8809c..60716b7 100644 --- a/Xplat/src/main/java/vazkii/neat/mixin/LevelRendererMixin.java +++ b/Xplat/src/main/java/vazkii/neat/mixin/LevelRendererMixin.java @@ -1,36 +1,44 @@ package vazkii.neat.mixin; import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.Minecraft; + import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.EntityRenderDispatcher; import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; + import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + import vazkii.neat.HealthBarRenderer; @Mixin(LevelRenderer.class) public class LevelRendererMixin { - @Shadow @Final private EntityRenderDispatcher entityRenderDispatcher; + @Shadow + @Final + private EntityRenderDispatcher entityRenderDispatcher; - /** - * This hooks right after the EntityRenderDispatcher - * - */ - @Inject(method = "renderEntity(Lnet/minecraft/world/entity/Entity;DDDFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRenderDispatcher;render(Lnet/minecraft/world/entity/Entity;DDDFFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", - shift = At.Shift.AFTER)) - private void neat_renderHealthBar(Entity entity, double camX, double camY, double camZ, float partialTick, PoseStack poseStack, MultiBufferSource buffers, CallbackInfo ci) { - double d0 = Mth.lerp(partialTick, entity.xOld, entity.getX()); - double d1 = Mth.lerp(partialTick, entity.yOld, entity.getY()); - double d2 = Mth.lerp(partialTick, entity.zOld, entity.getZ()); - HealthBarRenderer.hookRender(entity, poseStack, buffers, entityRenderDispatcher.camera, entityRenderDispatcher.getRenderer(entity), partialTick, d0 - camX, d1 - camY, d2 - camZ); - } + /** + * This hooks right after the EntityRenderDispatcher + * + */ + @Inject( + method = "renderEntity(Lnet/minecraft/world/entity/Entity;DDDFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;)V", + at = @At( + value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRenderDispatcher;render(Lnet/minecraft/world/entity/Entity;DDDFFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", + shift = At.Shift.AFTER + ) + ) + private void neat_renderHealthBar(Entity entity, double camX, double camY, double camZ, float partialTick, PoseStack poseStack, MultiBufferSource buffers, CallbackInfo ci) { + double d0 = Mth.lerp(partialTick, entity.xOld, entity.getX()); + double d1 = Mth.lerp(partialTick, entity.yOld, entity.getY()); + double d2 = Mth.lerp(partialTick, entity.zOld, entity.getZ()); + HealthBarRenderer.hookRender(entity, poseStack, buffers, entityRenderDispatcher.camera, entityRenderDispatcher.getRenderer(entity), partialTick, d0 - camX, d1 - camY, d2 - camZ); + } }