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.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();
|
2018-09-20 14:57:24 +02:00
|
|
|
|
2019-06-11 14:10:36 +02:00
|
|
|
if (!mc.getEntityRenderManager().shouldRenderHitboxes() || entity.squaredDistanceTo(mc.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
|
|
|
|
|
|
|
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-06-11 14:10:36 +02:00
|
|
|
WorldRenderer.drawBoxOutline(boundingBox.offset(mc.gameRenderer.getCamera().getPos().multiply(-1)), 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();
|
|
|
|
}
|
|
|
|
}
|