Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class HitboxRenderTools {
public static void drawOutlinedBoundingBox(AxisAlignedBB aa) {
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer wr = tessellator.getWorldRenderer();
wr.begin(2, DefaultVertexFormats.POSITION);
wr.pos(aa.minX, aa.minY, aa.minZ).endVertex();
wr.pos(aa.maxX, aa.minY, aa.minZ).endVertex();
wr.pos(aa.maxX, aa.minY, aa.maxZ).endVertex();
wr.pos(aa.minX, aa.minY, aa.maxZ).endVertex();
wr.pos(aa.minX, aa.minY, aa.minZ).endVertex();
tessellator.draw();
wr.begin(2, DefaultVertexFormats.POSITION);
wr.pos(aa.minX, aa.maxY, aa.minZ).endVertex();
wr.pos(aa.maxX, aa.maxY, aa.minZ).endVertex();
wr.pos(aa.maxX, aa.maxY, aa.maxZ).endVertex();
wr.pos(aa.minX, aa.maxY, aa.maxZ).endVertex();
wr.pos(aa.minX, aa.maxY, aa.minZ).endVertex();
tessellator.draw();
//connect top and bottom squares
wr.begin(1, DefaultVertexFormats.POSITION);
wr.pos(aa.minX, aa.minY, aa.minZ).endVertex();
wr.pos(aa.minX, aa.maxY, aa.minZ).endVertex();
tessellator.draw();
wr.begin(1, DefaultVertexFormats.POSITION);
wr.pos(aa.maxX, aa.minY, aa.minZ).endVertex();
wr.pos(aa.maxX, aa.maxY, aa.minZ).endVertex();
tessellator.draw();
wr.begin(1, DefaultVertexFormats.POSITION);
wr.pos(aa.minX, aa.minY, aa.maxZ).endVertex();
wr.pos(aa.minX, aa.maxY, aa.maxZ).endVertex();
tessellator.draw();
wr.begin(1, DefaultVertexFormats.POSITION);
wr.pos(aa.maxX, aa.minY, aa.maxZ).endVertex();
wr.pos(aa.maxX, aa.maxY, aa.maxZ).endVertex();
tessellator.draw();
// wr.begin(2, DefaultVertexFormats.POSITION);
// wr.pos(aa.minX, aa.minY, aa.minZ).endVertex();
// wr.pos(aa.minX, aa.maxY, aa.minZ).endVertex();
// wr.pos(aa.maxX, aa.minY, aa.minZ).endVertex();
// wr.pos(aa.maxX, aa.maxY, aa.minZ).endVertex();
// wr.pos(aa.maxX, aa.minY, aa.maxZ).endVertex();
// wr.pos(aa.maxX, aa.maxY, aa.maxZ).endVertex();
// wr.pos(aa.minX, aa.minY, aa.maxZ).endVertex();
// wr.pos(aa.minX, aa.maxY, aa.maxZ).endVertex();
// tessellator.draw();
}
public static void drawArrowHitbox(double x, double y, double z, double width, double height, float red, float green, float blue, float alpha) {
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(770, 771);
// GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_LINE_SMOOTH);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDepthMask(false);
GL11.glColor4f(red, green, blue, alpha);
drawOutlinedBoundingBox(new AxisAlignedBB(x - width, y-height, z - width, x + width , y + height, z + width));
GL11.glDisable(GL11.GL_LINE_SMOOTH);
GL11.glEnable(GL11.GL_TEXTURE_2D);
// GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDepthMask(true);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.