2019-03-23 20:49:34 +01:00
|
|
|
package com.minelittlepony.client.render;
|
2018-09-20 14:32:54 +02:00
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
import net.minecraft.client.MinecraftClient;
|
|
|
|
import net.minecraft.client.render.WorldRenderer;
|
|
|
|
import net.minecraft.entity.LivingEntity;
|
|
|
|
import net.minecraft.entity.player.PlayerEntity;
|
|
|
|
import net.minecraft.util.math.BoundingBox;
|
2018-09-20 14:32:54 +02:00
|
|
|
|
2019-03-23 20:58:50 +01:00
|
|
|
import com.minelittlepony.pony.IPony;
|
2018-09-20 14:32:54 +02:00
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
import static com.mojang.blaze3d.platform.GlStateManager.*;
|
2018-09-20 14:32:54 +02:00
|
|
|
|
|
|
|
public class DebugBoundingBoxRenderer {
|
|
|
|
|
|
|
|
public static final DebugBoundingBoxRenderer instance = new DebugBoundingBoxRenderer();
|
|
|
|
|
|
|
|
private DebugBoundingBoxRenderer() {
|
|
|
|
}
|
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
public void render(IPony pony, LivingEntity entity, float ticks) {
|
|
|
|
MinecraftClient mc = MinecraftClient.getInstance();
|
|
|
|
PlayerEntity player = mc.player;
|
2018-09-20 14:57:24 +02:00
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
if (!mc.getEntityRenderManager().shouldRenderHitboxes() || entity.squaredDistanceTo(player) > 70) {
|
2018-09-20 14:57:24 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
BoundingBox boundingBox = pony.getComputedBoundingBox(entity);
|
2018-09-20 14:32:54 +02:00
|
|
|
|
2018-09-20 14:57:24 +02:00
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
double renderPosX = player.prevX + (player.x - player.prevX) * (double)ticks;
|
|
|
|
double renderPosY = player.prevY + (player.y - player.prevY) * (double)ticks;
|
|
|
|
double renderPosZ = player.prevZ + (player.z - player.prevZ) * (double)ticks;
|
2018-09-20 14:32:54 +02:00
|
|
|
|
|
|
|
enableBlend();
|
2019-03-24 18:55:15 +01:00
|
|
|
blendFuncSeparate(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO);
|
|
|
|
lineWidth(2);
|
2019-05-27 17:59:15 +02:00
|
|
|
disableTexture();
|
2018-09-20 14:32:54 +02:00
|
|
|
depthMask(false);
|
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
WorldRenderer.drawBoxOutline(boundingBox.expand(0.003D).offset(-renderPosX, -renderPosY, -renderPosZ), 1, 1, 0, 1);
|
2018-09-20 14:32:54 +02:00
|
|
|
|
|
|
|
depthMask(true);
|
2019-05-27 17:59:15 +02:00
|
|
|
enableTexture();
|
2018-09-20 14:32:54 +02:00
|
|
|
disableBlend();
|
|
|
|
}
|
|
|
|
}
|