diff --git a/src/main/java/com/minelittlepony/client/render/DebugBoundingBoxRenderer.java b/src/main/java/com/minelittlepony/client/render/DebugBoundingBoxRenderer.java index aeed71fb..106809ed 100644 --- a/src/main/java/com/minelittlepony/client/render/DebugBoundingBoxRenderer.java +++ b/src/main/java/com/minelittlepony/client/render/DebugBoundingBoxRenderer.java @@ -5,29 +5,45 @@ import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.WorldRenderer; +import net.minecraft.client.render.entity.EntityRenderer; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.util.math.Vector3f; import net.minecraft.entity.LivingEntity; import net.minecraft.util.math.Box; +import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; -import net.minecraft.util.shape.VoxelShapes; import com.minelittlepony.pony.IPony; public final class DebugBoundingBoxRenderer { - public static void render(IPony pony, LivingEntity entity, MatrixStack stack, VertexConsumerProvider renderContext) { + public static void render(IPony pony, EntityRenderer renderer, T entity, MatrixStack stack, VertexConsumerProvider renderContext, float tickDelta) { MinecraftClient mc = MinecraftClient.getInstance(); if (!mc.getEntityRenderManager().shouldRenderHitboxes() || entity.squaredDistanceTo(mc.player) > 70) { return; } + Vec3d offset = renderer.getPositionOffset(entity, tickDelta); + + stack.push(); + stack.translate(-offset.x, -offset.y, -offset.z); + + float yaw = MathHelper.lerp(tickDelta, entity.prevBodyYaw, entity.bodyYaw); + + stack.multiply(Vector3f.NEGATIVE_Y.getDegreesQuaternion(yaw)); + Box boundingBox = pony.getComputedBoundingBox(entity); - Vec3d cam = mc.gameRenderer.getCamera().getPos(); + Vec3d pos = entity.getPos(); + + double x = - MathHelper.lerp(tickDelta, entity.lastRenderX, pos.x); + double y = - MathHelper.lerp(tickDelta, entity.lastRenderY, pos.y); + double z = - MathHelper.lerp(tickDelta, entity.lastRenderZ, pos.z); VertexConsumer vertices = renderContext.getBuffer(RenderLayer.getLines()); - WorldRenderer.method_22983(stack, vertices, VoxelShapes.cuboid(boundingBox), -cam.x, -cam.y, -cam.z, 1, 1, 1, 1); + WorldRenderer.drawBox(stack, vertices, boundingBox.offset(x, y, z), 1, 1, 0, 1); + stack.pop(); } } diff --git a/src/main/java/com/minelittlepony/client/render/entity/PlayerPonyRenderer.java b/src/main/java/com/minelittlepony/client/render/entity/PlayerPonyRenderer.java index 08511928..5e7e284d 100644 --- a/src/main/java/com/minelittlepony/client/render/entity/PlayerPonyRenderer.java +++ b/src/main/java/com/minelittlepony/client/render/entity/PlayerPonyRenderer.java @@ -83,7 +83,7 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements IPonyRen shadowSize = manager.getShadowScale(); super.render(entity, entityYaw, tickDelta, stack, renderContext, lightUv); - DebugBoundingBoxRenderer.render(manager.getPony(entity), entity, stack, renderContext); + DebugBoundingBoxRenderer.render(manager.getPony(entity), this, entity, stack, renderContext, tickDelta); // Translate the shadow position after everything is done // (shadows are drawn after us) diff --git a/src/main/java/com/minelittlepony/client/render/entity/PonyRenderer.java b/src/main/java/com/minelittlepony/client/render/entity/PonyRenderer.java index d5aceaa2..cd7dff68 100644 --- a/src/main/java/com/minelittlepony/client/render/entity/PonyRenderer.java +++ b/src/main/java/com/minelittlepony/client/render/entity/PonyRenderer.java @@ -62,7 +62,7 @@ public abstract class PonyRenderer super.render(entity, entityYaw, tickDelta, stack, renderContext, lightUv); - DebugBoundingBoxRenderer.render(manager.getPony(entity), entity, stack, renderContext); + DebugBoundingBoxRenderer.render(manager.getPony(entity), this, entity, stack, renderContext, tickDelta); } @Override