MineLittlePony/src/main/java/com/minelittlepony/render/DebugBoundingBoxRenderer.java

48 lines
1.6 KiB
Java

package com.minelittlepony.render;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.AxisAlignedBB;
import com.minelittlepony.pony.data.IPony;
import static net.minecraft.client.renderer.GlStateManager.*;
public class DebugBoundingBoxRenderer {
public static final DebugBoundingBoxRenderer instance = new DebugBoundingBoxRenderer();
private DebugBoundingBoxRenderer() {
}
public void render(IPony pony, EntityLivingBase entity, float ticks) {
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.player;
if (!mc.getRenderManager().isDebugBoundingBox() || entity.getDistanceSq(player) > 70) {
return;
}
AxisAlignedBB boundingBox = pony.getComputedBoundingBox(entity);
double renderPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)ticks;
double renderPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)ticks;
double renderPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)ticks;
enableBlend();
tryBlendFuncSeparate(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO);
glLineWidth(2.0F);
disableTexture2D();
depthMask(false);
RenderGlobal.drawSelectionBoundingBox(boundingBox.grow(0.003D).offset(-renderPosX, -renderPosY, -renderPosZ), 1, 1, 0, 1);
depthMask(true);
enableTexture2D();
disableBlend();
}
}