fix drawTest and change input parameters

This commit is contained in:
BuildTools
2020-04-17 23:12:30 -05:00
parent 06fd139759
commit f24db03c8b
@@ -2,27 +2,85 @@ package backsun.lod.util;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.AxisAlignedBB;
public class CustomRenderer
{
public static void drawTest(double x, double y, double z)
public static void drawTest(Minecraft mc, float partialTicks)
{
// renders a red x at the coordinates 9 9 9
double doubleX = x;//mc.player.posX - 0.5;
double doubleY = y;//mc.player.posY + 0.1;
double doubleZ = z;//mc.player.posZ - 0.5;
GL11.glPushMatrix();
GL11.glTranslated(-doubleX, -doubleY, -doubleZ);
GL11.glColor3ub((byte)255,(byte)0,(byte)0);
float mx = 9;
float my = 9;
float mz = 9;
GL11.glBegin(GL11.GL_LINES);
GL11.glVertex3f(mx+0.4f,my,mz+0.4f);
GL11.glVertex3f(mx-0.4f,my,mz-0.4f);
GL11.glVertex3f(mx+0.4f,my,mz-0.4f);
GL11.glVertex3f(mx-0.4f,my,mz+0.4f);
GL11.glEnd();
GL11.glPopMatrix();
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glLineWidth(2.0f);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_CULL_FACE);
// get the camera location
// Entity entity = mc.getRenderViewEntity();
Entity entity = mc.player;
double x = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks;
double y = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks;
double z = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks;
int bbx = 9;
int bby = 9;
int bbz = 9;
// x y z
AxisAlignedBB bb = new AxisAlignedBB(bbx, bby, bbz, bbx-1, bby-1, bbz-1).offset(-x, -y, -z);
GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
GL11.glEnable(GL11.GL_BLEND);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder worldRenderer = tessellator.getBuffer();
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
worldRenderer.pos(bb.minX, bb.minY, bb.minZ).color(255, 255, 255, 255).endVertex();
worldRenderer.pos(bb.maxX, bb.minY, bb.minZ).color(255, 255, 255, 255).endVertex();
worldRenderer.pos(bb.maxX, bb.minY, bb.maxZ).color(255, 255, 255, 255).endVertex();
worldRenderer.pos(bb.minX, bb.minY, bb.maxZ).color(255, 255, 255, 255).endVertex();
if (bb.minY != bb.maxY)
{
worldRenderer.pos(bb.minX, bb.maxY, bb.minZ).color(255, 255, 255, 255).endVertex();
worldRenderer.pos(bb.maxX, bb.maxY, bb.minZ).color(255, 255, 255, 255).endVertex();
worldRenderer.pos(bb.maxX, bb.maxY, bb.maxZ).color(255, 255, 255, 255).endVertex();
worldRenderer.pos(bb.minX, bb.maxY, bb.maxZ).color(255, 255, 255, 255).endVertex();
worldRenderer.pos(bb.minX, bb.minY, bb.maxZ).color(255, 255, 255, 255).endVertex();
worldRenderer.pos(bb.minX, bb.maxY, bb.maxZ).color(255, 255, 255, 255).endVertex();
worldRenderer.pos(bb.maxX, bb.maxY, bb.maxZ).color(255, 255, 255, 255).endVertex();
worldRenderer.pos(bb.maxX, bb.minY, bb.maxZ).color(255, 255, 255, 255).endVertex();
worldRenderer.pos(bb.minX, bb.minY, bb.minZ).color(255, 255, 255, 255).endVertex();
worldRenderer.pos(bb.minX, bb.maxY, bb.minZ).color(255, 255, 255, 255).endVertex();
worldRenderer.pos(bb.maxX, bb.maxY, bb.minZ).color(255, 255, 255, 255).endVertex();
worldRenderer.pos(bb.maxX, bb.minY, bb.minZ).color(255, 255, 255, 255).endVertex();
worldRenderer.pos(bb.minX, bb.minY, bb.minZ).color(255, 255, 255, 255).endVertex();
worldRenderer.pos(bb.minX, bb.minY, bb.maxZ).color(255, 255, 255, 255).endVertex();
worldRenderer.pos(bb.minX, bb.maxY, bb.maxZ).color(255, 255, 255, 255).endVertex();
worldRenderer.pos(bb.minX, bb.maxY, bb.minZ).color(255, 255, 255, 255).endVertex();
worldRenderer.pos(bb.maxX, bb.minY, bb.minZ).color(255, 255, 255, 255).endVertex();
worldRenderer.pos(bb.maxX, bb.minY, bb.maxZ).color(255, 255, 255, 255).endVertex();
worldRenderer.pos(bb.maxX, bb.maxY, bb.maxZ).color(255, 255, 255, 255).endVertex();
worldRenderer.pos(bb.maxX, bb.maxY, bb.minZ).color(255, 255, 255, 255).endVertex();
}
tessellator.draw();
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_POLYGON_OFFSET_LINE);
GL11.glPolygonOffset(-1.f, -1.f);
GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
}