Java Code Examples for net.minecraft.client.render.BufferBuilder#begin()

The following examples show how to use net.minecraft.client.render.BufferBuilder#begin() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HallowedLoadingScreen.java    From the-hallow with MIT License 6 votes vote down vote up
@Override
public void renderDirtBackground(int i) {
	// Copied mostly from renderDirtBackground()
	RenderSystem.disableLighting();
	RenderSystem.disableFog();
	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder builder = tessellator.getBuffer();
	minecraft.getTextureManager().bindTexture(backgroundTexture);
	int brightness = 130;
	RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
	builder.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
	builder.vertex(0, height, 0).texture(0, height / 32.0F + i).color(brightness, brightness, brightness, 255).next();
	builder.vertex(width, height, 0).texture(width / 32.0F, height / 32.0F + i).color(brightness, brightness, brightness, 255).next();
	builder.vertex(width, 0, 0).texture(width / 32.0F, i).color(brightness, brightness, brightness, 255).next();
	builder.vertex(0, 0, 0).texture(0, i).color(brightness, brightness, brightness, 255).next();
	tessellator.draw();
}
 
Example 2
Source File: RenderUtilsLiving.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
public static void drawText(String str, double x, double y, double z, double scale) {
	glSetup(x, y, z);
	
	GL11.glScaled(-0.025*scale, -0.025*scale, 0.025*scale);
      
	int i = mc.textRenderer.getStringWidth(str) / 2;
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferbuilder = tessellator.getBuffer();
    bufferbuilder.begin(7, VertexFormats.POSITION_COLOR);
    float f = mc.options.getTextBackgroundOpacity(0.25F);
    bufferbuilder.vertex(-i - 1, -1, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    bufferbuilder.vertex(-i - 1, 8, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    bufferbuilder.vertex(i + 1, 8, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    bufferbuilder.vertex(i + 1, -1, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    tessellator.draw();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
      
    mc.textRenderer.draw(str, -i, 0, 553648127);
    mc.textRenderer.draw(str, -i, 0, -1);
      
    glCleanup();
}
 
Example 3
Source File: RenderUtilsLiving.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
public static void drawText(String str, double x, double y, double z, double scale) {
	glSetup(x, y, z);
	
	GL11.glScaled(-0.025*scale, -0.025*scale, 0.025*scale);
      
	int i = mc.textRenderer.getWidth(str) / 2;
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferbuilder = tessellator.getBuffer();
    bufferbuilder.begin(7, VertexFormats.POSITION_COLOR);
    float f = mc.options.getTextBackgroundOpacity(0.25F);
    bufferbuilder.vertex(-i - 1, -1, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    bufferbuilder.vertex(-i - 1, 8, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    bufferbuilder.vertex(i + 1, 8, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    bufferbuilder.vertex(i + 1, -1, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    tessellator.draw();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
      
    mc.textRenderer.draw(new MatrixStack(), str, -i, 0, 553648127);
    mc.textRenderer.draw(new MatrixStack(), str, -i, 0, -1);
      
    glCleanup();
}
 
Example 4
Source File: RenderUtilsLiving.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
public static void drawText(String str, double x, double y, double z, double scale) {
	glSetup(x, y, z);
	
	GL11.glScaled(-0.025*scale, -0.025*scale, 0.025*scale);
      
	int i = mc.textRenderer.getStringWidth(str) / 2;
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferbuilder = tessellator.getBufferBuilder();
    bufferbuilder.begin(7, VertexFormats.POSITION_COLOR);
    float f = mc.options.getTextBackgroundOpacity(0.25F);
    bufferbuilder.vertex(-i - 1, -1, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    bufferbuilder.vertex(-i - 1, 8, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    bufferbuilder.vertex(i + 1, 8, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    bufferbuilder.vertex(i + 1, -1, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    tessellator.draw();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
      
    mc.textRenderer.draw(str, -i, 0, 553648127);
    mc.textRenderer.draw(str, -i, 0, -1);
      
    glCleanup();
}
 
Example 5
Source File: RenderUtils.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
public static void drawLine(double x1,double y1,double z1,double x2,double y2,double z2, float r, float g, float b, float t) {
	gl11Setup();
	GL11.glLineWidth(t);
       
	Vec3d ren = renderPos();
       
       Tessellator tessellator = Tessellator.getInstance();
       BufferBuilder buffer = tessellator.getBufferBuilder();
       buffer.begin(3, VertexFormats.POSITION_COLOR);
       buffer.vertex(x1 - ren.x, y1 - ren.y, z1 - ren.z).color(r, g, b, 0.0F).next();
       buffer.vertex(x1 - ren.x, y1 - ren.y, z1 - ren.z).color(r, g, b, 1.0F).next();
       buffer.vertex(x2 - ren.x, y2 - ren.y, z2 - ren.z).color(r, g, b, 1.0F).next();
       tessellator.draw();
       
	gl11Cleanup();
       
}
 
Example 6
Source File: WTextField.java    From LibGui with MIT License 6 votes vote down vote up
@Environment(EnvType.CLIENT)
private void invertedRect(int x, int y, int width, int height) {
	Tessellator tessellator_1 = Tessellator.getInstance();
	BufferBuilder bufferBuilder_1 = tessellator_1.getBuffer();
	RenderSystem.color4f(0.0F, 0.0F, 255.0F, 255.0F);
	RenderSystem.disableTexture();
	RenderSystem.enableColorLogicOp();
	RenderSystem.logicOp(GlStateManager.LogicOp.OR_REVERSE);
	bufferBuilder_1.begin(GL11.GL_QUADS, VertexFormats.POSITION);
	bufferBuilder_1.vertex(x,       y+height, 0.0D).next();
	bufferBuilder_1.vertex(x+width, y+height, 0.0D).next();
	bufferBuilder_1.vertex(x+width, y,        0.0D).next();
	bufferBuilder_1.vertex(x,       y,        0.0D).next();
	tessellator_1.draw();
	RenderSystem.disableColorLogicOp();
	RenderSystem.enableTexture();
}
 
Example 7
Source File: ScreenDrawing.java    From LibGui with MIT License 6 votes vote down vote up
/**
 * Draws an untextured rectangle of the specified RGB color.
 */
public static void coloredRect(int left, int top, int width, int height, int color) {
	if (width <= 0) width = 1;
	if (height <= 0) height = 1;

	float a = (color >> 24 & 255) / 255.0F;
	float r = (color >> 16 & 255) / 255.0F;
	float g = (color >> 8 & 255) / 255.0F;
	float b = (color & 255) / 255.0F;
	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder buffer = tessellator.getBuffer();
	RenderSystem.enableBlend();
	RenderSystem.disableTexture();
	RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO);
	buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_COLOR); //I thought GL_QUADS was deprecated but okay, sure.
	buffer.vertex(left,         top + height, 0.0D).color(r, g, b, a).next();
	buffer.vertex(left + width, top + height, 0.0D).color(r, g, b, a).next();
	buffer.vertex(left + width, top,          0.0D).color(r, g, b, a).next();
	buffer.vertex(left,         top,          0.0D).color(r, g, b, a).next();
	tessellator.draw();
	RenderSystem.enableTexture();
	RenderSystem.disableBlend();
}
 
Example 8
Source File: ListWidget.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
protected void renderHoleBackground(int top, int bottom, int topAlpha,
	int bottomAlpha)
{
	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder bufferBuilder = tessellator.getBuffer();
	client.getTextureManager()
		.bindTexture(DrawableHelper.BACKGROUND_TEXTURE);
	RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
	bufferBuilder.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
	bufferBuilder.vertex(left, bottom, 0.0D).texture(0.0F, bottom / 32.0F)
		.color(64, 64, 64, bottomAlpha).next();
	bufferBuilder.vertex(left + width, bottom, 0.0D)
		.texture(width / 32.0F, bottom / 32.0F)
		.color(64, 64, 64, bottomAlpha).next();
	bufferBuilder.vertex(left + width, top, 0.0D)
		.texture(width / 32.0F, top / 32.0F).color(64, 64, 64, topAlpha)
		.next();
	bufferBuilder.vertex(left, top, 0.0D).texture(0.0F, top / 32.0F)
		.color(64, 64, 64, topAlpha).next();
	tessellator.draw();
}
 
Example 9
Source File: ShapesRenderer.java    From fabric-carpet with MIT License 5 votes vote down vote up
public static void drawSphereFaces(Tessellator tessellator, BufferBuilder builder,
                                       float cx, float cy, float cz,
                                       float r, int subd,
                                       float red, float grn, float blu, float alpha)
{

    float step = (float)Math.PI / (subd/2);
    int num_steps180 = (int)(Math.PI / step)+1;
    int num_steps360 = (int)(2*Math.PI / step);
    for (int i = 0; i <= num_steps360; i++)
    {
        float theta = i * step;
        float thetaprime = theta+step;
        builder.begin(GL11.GL_QUAD_STRIP, VertexFormats.POSITION_COLOR);
        for (int j = 0; j <= num_steps180; j++)
        {
            float phi = j * step;
            float x = r * MathHelper.sin(phi) * MathHelper.cos(theta);
            float z = r * MathHelper.sin(phi) * MathHelper.sin(theta);
            float y = r * MathHelper.cos(phi);
            float xp = r * MathHelper.sin(phi) * MathHelper.cos(thetaprime);
            float zp = r * MathHelper.sin(phi) * MathHelper.sin(thetaprime);
            builder.vertex(x + cx, y + cy, z + cz).color(red, grn, blu, alpha).next();
            builder.vertex(xp + cx, y + cy, zp + cz).color(red, grn, blu, alpha).next();
        }
        tessellator.draw();
    }
}
 
Example 10
Source File: RenderUtils.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public static void drawFilledBox(Box box, float r, float g, float b, float a) {
gl11Setup();

Vec3d ren = renderPos();

      /* Fill */
      Tessellator tessellator = Tessellator.getInstance();
      BufferBuilder buffer = tessellator.getBufferBuilder();
      buffer.begin(5, VertexFormats.POSITION_COLOR);
      WorldRenderer.buildBox(buffer,
      		box.minX - ren.x, box.minY - ren.y, box.minZ - ren.z,
      		box.maxX - ren.x, box.maxY - ren.y, box.maxZ - ren.z, r, g, b, a/2f);
      tessellator.draw();
      
      /* Outline */
      WorldRenderer.drawBoxOutline(new Box(
      		box.minX - ren.x, box.minY - ren.y, box.minZ - ren.z,
      		box.maxX - ren.x, box.maxY - ren.y, box.maxZ - ren.z), r, g, b, a);

      gl11Cleanup();
  }
 
Example 11
Source File: Window.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
private void fillGradient(int x1, int y1, int x2, int y2, int color1, int color2) {
	float float_1 = (float)(color1 >> 24 & 255) / 255.0F;
	float float_2 = (float)(color1 >> 16 & 255) / 255.0F;
	float float_3 = (float)(color1 >> 8 & 255) / 255.0F;
	float float_4 = (float)(color1 & 255) / 255.0F;
	float float_5 = (float)(color2 >> 24 & 255) / 255.0F;
	float float_6 = (float)(color2 >> 16 & 255) / 255.0F;
	float float_7 = (float)(color2 >> 8 & 255) / 255.0F;
	float float_8 = (float)(color2 & 255) / 255.0F;
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glEnable(GL11.GL_BLEND);
	GL11.glDisable(GL11.GL_ALPHA_TEST);
	GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
	GL11.glShadeModel(7425);
	Tessellator tessellator_1 = Tessellator.getInstance();
	BufferBuilder bufferBuilder_1 = tessellator_1.getBufferBuilder();
	bufferBuilder_1.begin(7, VertexFormats.POSITION_COLOR);
	bufferBuilder_1.vertex((double)x1, (double)y1, 0).color(float_2, float_3, float_4, float_1).next();
	bufferBuilder_1.vertex((double)x1, (double)y2, 0).color(float_2, float_3, float_4, float_1).next();
	bufferBuilder_1.vertex((double)x2, (double)y2, 0).color(float_6, float_7, float_8, float_5).next();
	bufferBuilder_1.vertex((double)x2, (double)y1, 0).color(float_6, float_7, float_8, float_5).next();
	tessellator_1.draw();
	GL11.glShadeModel(7424);
	GL11.glDisable(GL11.GL_BLEND);
	GL11.glEnable(GL11.GL_ALPHA_TEST);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
}
 
Example 12
Source File: Window.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
protected void fillGradient(MatrixStack matrix, int x1, int y1, int x2, int y2, int color1, int color2) {
	float float_1 = (float)(color1 >> 24 & 255) / 255.0F;
	float float_2 = (float)(color1 >> 16 & 255) / 255.0F;
	float float_3 = (float)(color1 >> 8 & 255) / 255.0F;
	float float_4 = (float)(color1 & 255) / 255.0F;
	float float_5 = (float)(color2 >> 24 & 255) / 255.0F;
	float float_6 = (float)(color2 >> 16 & 255) / 255.0F;
	float float_7 = (float)(color2 >> 8 & 255) / 255.0F;
	float float_8 = (float)(color2 & 255) / 255.0F;
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glEnable(GL11.GL_BLEND);
	GL11.glDisable(GL11.GL_ALPHA_TEST);
	GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
	GL11.glShadeModel(7425);
	Tessellator tessellator_1 = Tessellator.getInstance();
	BufferBuilder bufferBuilder_1 = tessellator_1.getBuffer();
	bufferBuilder_1.begin(7, VertexFormats.POSITION_COLOR);
	bufferBuilder_1.vertex((double)x1, (double)y1, 0).color(float_2, float_3, float_4, float_1).next();
	bufferBuilder_1.vertex((double)x1, (double)y2, 0).color(float_2, float_3, float_4, float_1).next();
	bufferBuilder_1.vertex((double)x2, (double)y2, 0).color(float_6, float_7, float_8, float_5).next();
	bufferBuilder_1.vertex((double)x2, (double)y1, 0).color(float_6, float_7, float_8, float_5).next();
	tessellator_1.draw();
	GL11.glShadeModel(7424);
	GL11.glDisable(GL11.GL_BLEND);
	GL11.glEnable(GL11.GL_ALPHA_TEST);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
}
 
Example 13
Source File: RenderUtils.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public static void drawFilledBox(Box box, float r, float g, float b, float a) {
gl11Setup();

      // Fill
      Tessellator tessellator = Tessellator.getInstance();
      BufferBuilder buffer = tessellator.getBuffer();
      buffer.begin(5, VertexFormats.POSITION_COLOR);
      WorldRenderer.drawBox(buffer,
      		box.x1, box.y1, box.z1,
      		box.x2, box.y2, box.z2, r, g, b, a/2f);
      tessellator.draw();
      
      // Outline
      buffer.begin(3, VertexFormats.POSITION_COLOR);
      buffer.vertex(box.x1, box.y1, box.z1).color(r, b, b, a/2f).next();
      buffer.vertex(box.x1, box.y1, box.z2).color(r, b, b, a/2f).next();
      buffer.vertex(box.x2, box.y1, box.z2).color(r, b, b, a/2f).next();
      buffer.vertex(box.x2, box.y1, box.z1).color(r, b, b, a/2f).next();
      buffer.vertex(box.x1, box.y1, box.z1).color(r, b, b, a/2f).next();
      buffer.vertex(box.x1, box.y2, box.z1).color(r, b, b, a/2f).next();
      buffer.vertex(box.x2, box.y2, box.z1).color(r, b, b, a/2f).next();
      buffer.vertex(box.x2, box.y2, box.z2).color(r, b, b, a/2f).next();
      buffer.vertex(box.x1, box.y2, box.z2).color(r, b, b, a/2f).next();
      buffer.vertex(box.x1, box.y2, box.z1).color(r, b, b, a/2f).next();
      buffer.vertex(box.x1, box.y1, box.z2).color(r, b, b, 0f).next();
      buffer.vertex(box.x1, box.y2, box.z2).color(r, b, b, a/2f).next();
      buffer.vertex(box.x2, box.y1, box.z2).color(r, b, b, 0f).next();
      buffer.vertex(box.x2, box.y2, box.z2).color(r, b, b, a/2f).next();
      buffer.vertex(box.x2, box.y1, box.z1).color(r, b, b, 0f).next();
      buffer.vertex(box.x2, box.y2, box.z1).color(r, b, b, a/2f).next();
      tessellator.draw();
      
      gl11Cleanup();
  }
 
Example 14
Source File: RenderUtils.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public static void drawLine(double x1,double y1,double z1,double x2,double y2,double z2, float r, float g, float b, float t) {
	gl11Setup();
	GL11.glLineWidth(t);
       
       Tessellator tessellator = Tessellator.getInstance();
       BufferBuilder buffer = tessellator.getBuffer();
       buffer.begin(3, VertexFormats.POSITION_COLOR);
       buffer.vertex(x1, y1, z1).color(r, g, b, 0.0F).next();
       buffer.vertex(x1, y1, z1).color(r, g, b, 1.0F).next();
       buffer.vertex(x2, y2, z2).color(r, g, b, 1.0F).next();
       tessellator.draw();
       
	gl11Cleanup();
       
}
 
Example 15
Source File: SpaceRaceScreen.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
private static void fillSolid(Matrix4f matrix, int x1, int y1, int x2, int y2, int color) {
    int j;
    if (x1 < x2) {
        j = x1;
        x1 = x2;
        x2 = j;
    }

    if (y1 < y2) {
        j = y1;
        y1 = y2;
        y2 = j;
    }

    float f = (float) (color >> 24 & 255) / 255.0F;
    float g = (float) (color >> 16 & 255) / 255.0F;
    float h = (float) (color >> 8 & 255) / 255.0F;
    float k = (float) (color & 255) / 255.0F;
    BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
    RenderSystem.disableBlend();
    RenderSystem.disableTexture();
    RenderSystem.defaultBlendFunc();
    bufferBuilder.begin(7, VertexFormats.POSITION_COLOR);
    bufferBuilder.vertex(matrix, (float) x1, (float) y2, 0.0F).color(g, h, k, f).next();
    bufferBuilder.vertex(matrix, (float) x2, (float) y2, 0.0F).color(g, h, k, f).next();
    bufferBuilder.vertex(matrix, (float) x2, (float) y1, 0.0F).color(g, h, k, f).next();
    bufferBuilder.vertex(matrix, (float) x1, (float) y1, 0.0F).color(g, h, k, f).next();
    bufferBuilder.end();
    BufferRenderer.draw(bufferBuilder);
    RenderSystem.enableTexture();
}
 
Example 16
Source File: Window.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
protected void fillGradient(int x1, int y1, int x2, int y2, int color1, int color2) {
	float float_1 = (float)(color1 >> 24 & 255) / 255.0F;
	float float_2 = (float)(color1 >> 16 & 255) / 255.0F;
	float float_3 = (float)(color1 >> 8 & 255) / 255.0F;
	float float_4 = (float)(color1 & 255) / 255.0F;
	float float_5 = (float)(color2 >> 24 & 255) / 255.0F;
	float float_6 = (float)(color2 >> 16 & 255) / 255.0F;
	float float_7 = (float)(color2 >> 8 & 255) / 255.0F;
	float float_8 = (float)(color2 & 255) / 255.0F;
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glEnable(GL11.GL_BLEND);
	GL11.glDisable(GL11.GL_ALPHA_TEST);
	GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
	GL11.glShadeModel(7425);
	Tessellator tessellator_1 = Tessellator.getInstance();
	BufferBuilder bufferBuilder_1 = tessellator_1.getBuffer();
	bufferBuilder_1.begin(7, VertexFormats.POSITION_COLOR);
	bufferBuilder_1.vertex((double)x1, (double)y1, 0).color(float_2, float_3, float_4, float_1).next();
	bufferBuilder_1.vertex((double)x1, (double)y2, 0).color(float_2, float_3, float_4, float_1).next();
	bufferBuilder_1.vertex((double)x2, (double)y2, 0).color(float_6, float_7, float_8, float_5).next();
	bufferBuilder_1.vertex((double)x2, (double)y1, 0).color(float_6, float_7, float_8, float_5).next();
	tessellator_1.draw();
	GL11.glShadeModel(7424);
	GL11.glDisable(GL11.GL_BLEND);
	GL11.glEnable(GL11.GL_ALPHA_TEST);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
}
 
Example 17
Source File: ShapesRenderer.java    From fabric-carpet with MIT License 4 votes vote down vote up
public static void drawBoxFaces(
        Tessellator tessellator, BufferBuilder builder,
        float x1, float y1, float z1,
        float x2, float y2, float z2,
        boolean xthick, boolean ythick, boolean zthick,
        float red1, float grn1, float blu1, float alpha)
{
    builder.begin(GL11.GL_QUADS, VertexFormats.POSITION_COLOR);

    if (xthick && ythick)
    {
        builder.vertex(x1, y1, z1).color(red1, grn1, blu1, alpha).next();
        builder.vertex(x2, y1, z1).color(red1, grn1, blu1, alpha).next();
        builder.vertex(x2, y2, z1).color(red1, grn1, blu1, alpha).next();
        builder.vertex(x1, y2, z1).color(red1, grn1, blu1, alpha).next();
        if (zthick)
        {
            builder.vertex(x1, y1, z2).color(red1, grn1, blu1, alpha).next();
            builder.vertex(x1, y2, z2).color(red1, grn1, blu1, alpha).next();
            builder.vertex(x2, y2, z2).color(red1, grn1, blu1, alpha).next();
            builder.vertex(x2, y1, z2).color(red1, grn1, blu1, alpha).next();
        }
    }


    if (zthick && ythick)
    {
        builder.vertex(x1, y1, z1).color(red1, grn1, blu1, alpha).next();
        builder.vertex(x1, y2, z1).color(red1, grn1, blu1, alpha).next();
        builder.vertex(x1, y2, z2).color(red1, grn1, blu1, alpha).next();
        builder.vertex(x1, y1, z2).color(red1, grn1, blu1, alpha).next();

        if (xthick)
        {
            builder.vertex(x2, y1, z1).color(red1, grn1, blu1, alpha).next();
            builder.vertex(x2, y1, z2).color(red1, grn1, blu1, alpha).next();
            builder.vertex(x2, y2, z2).color(red1, grn1, blu1, alpha).next();
            builder.vertex(x2, y2, z1).color(red1, grn1, blu1, alpha).next();
        }
    }

    // now at least drawing one
    if (zthick && xthick)
    {
        builder.vertex(x1, y1, z1).color(red1, grn1, blu1, alpha).next();
        builder.vertex(x2, y1, z1).color(red1, grn1, blu1, alpha).next();
        builder.vertex(x2, y1, z2).color(red1, grn1, blu1, alpha).next();
        builder.vertex(x1, y1, z2).color(red1, grn1, blu1, alpha).next();


        if (ythick)
        {
            builder.vertex(x1, y2, z1).color(red1, grn1, blu1, alpha).next();
            builder.vertex(x2, y2, z1).color(red1, grn1, blu1, alpha).next();
            builder.vertex(x2, y2, z2).color(red1, grn1, blu1, alpha).next();
            builder.vertex(x1, y2, z2).color(red1, grn1, blu1, alpha).next();
        }
    }
    tessellator.draw();
}
 
Example 18
Source File: ShapesRenderer.java    From fabric-carpet with MIT License 4 votes vote down vote up
public static void drawBoxWireGLLines(
        Tessellator tessellator, BufferBuilder builder,
        float x1, float y1, float z1,
        float x2, float y2, float z2,
        boolean xthick, boolean ythick, boolean zthick,
        float red1, float grn1, float blu1, float alpha, float red2, float grn2, float blu2)
{
    builder.begin(GL11.GL_LINES, VertexFormats.POSITION_COLOR); // 3
    if (xthick)
    {
        builder.vertex(x1, y1, z1).color(red1, grn2, blu2, alpha).next();
        builder.vertex(x2, y1, z1).color(red1, grn2, blu2, alpha).next();

        builder.vertex(x2, y2, z1).color(red1, grn1, blu1, alpha).next();
        builder.vertex(x1, y2, z1).color(red1, grn1, blu1, alpha).next();

        builder.vertex(x1, y1, z2).color(red1, grn1, blu1, alpha).next();
        builder.vertex(x2, y1, z2).color(red1, grn1, blu1, alpha).next();

        builder.vertex(x1, y2, z2).color(red1, grn1, blu1, alpha).next();
        builder.vertex(x2, y2, z2).color(red1, grn1, blu1, alpha).next();
    }
    if (ythick)
    {
        builder.vertex(x1, y1, z1).color(red2, grn1, blu2, alpha).next();
        builder.vertex(x1, y2, z1).color(red2, grn1, blu2, alpha).next();

        builder.vertex(x2, y1, z1).color(red1, grn1, blu1, alpha).next();
        builder.vertex(x2, y2, z1).color(red1, grn1, blu1, alpha).next();

        builder.vertex(x1, y2, z2).color(red1, grn1, blu1, alpha).next();
        builder.vertex(x1, y1, z2).color(red1, grn1, blu1, alpha).next();

        builder.vertex(x2, y1, z2).color(red1, grn1, blu1, alpha).next();
        builder.vertex(x2, y2, z2).color(red1, grn1, blu1, alpha).next();
    }
    if (zthick)
    {
        builder.vertex(x1, y1, z1).color(red2, grn2, blu1, alpha).next();
        builder.vertex(x1, y1, z2).color(red2, grn2, blu1, alpha).next();

        builder.vertex(x1, y2, z1).color(red1, grn1, blu1, alpha).next();
        builder.vertex(x1, y2, z2).color(red1, grn1, blu1, alpha).next();

        builder.vertex(x2, y1, z2).color(red1, grn1, blu1, alpha).next();
        builder.vertex(x2, y1, z1).color(red1, grn1, blu1, alpha).next();

        builder.vertex(x2, y2, z1).color(red1, grn1, blu1, alpha).next();
        builder.vertex(x2, y2, z2).color(red1, grn1, blu1, alpha).next();
    }
    tessellator.draw();
}
 
Example 19
Source File: ShapesRenderer.java    From fabric-carpet with MIT License 4 votes vote down vote up
public static void drawLine(Tessellator tessellator, BufferBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2, float red1, float grn1, float blu1, float alpha) {
    builder.begin(GL11.GL_LINES, VertexFormats.POSITION_COLOR); // 3
    builder.vertex(x1, y1, z1).color(red1, grn1, blu1, alpha).next();
    builder.vertex(x2, y2, z2).color(red1, grn1, blu1, alpha).next();
    tessellator.draw();
}
 
Example 20
Source File: ListWidget.java    From Wurst7 with GNU General Public License v3.0 4 votes vote down vote up
protected void renderList(MatrixStack matrixStack, int i, int j, int k,
	int l, float f)
{
	int m = getItemCount();
	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder bufferBuilder = tessellator.getBuffer();
	
	for(int n = 0; n < m; ++n)
	{
		int o = j + n * itemHeight + headerHeight;
		int p = itemHeight - 4;
		if(o > bottom || o + p < top)
			updateItemPosition(n, i, o, f);
		
		if(renderSelection && isSelectedItem(n))
		{
			int q = left + width / 2 - getRowWidth() / 2;
			int r = left + width / 2 + getRowWidth() / 2;
			RenderSystem.disableTexture();
			float g = isFocused() ? 1.0F : 0.5F;
			RenderSystem.color4f(g, g, g, 1.0F);
			bufferBuilder.begin(7, VertexFormats.POSITION);
			bufferBuilder.vertex(q, o + p + 2, 0.0D).next();
			bufferBuilder.vertex(r, o + p + 2, 0.0D).next();
			bufferBuilder.vertex(r, o - 2, 0.0D).next();
			bufferBuilder.vertex(q, o - 2, 0.0D).next();
			tessellator.draw();
			RenderSystem.color4f(0.0F, 0.0F, 0.0F, 1.0F);
			bufferBuilder.begin(7, VertexFormats.POSITION);
			bufferBuilder.vertex(q + 1, o + p + 1, 0.0D).next();
			bufferBuilder.vertex(r - 1, o + p + 1, 0.0D).next();
			bufferBuilder.vertex(r - 1, o - 1, 0.0D).next();
			bufferBuilder.vertex(q + 1, o - 1, 0.0D).next();
			tessellator.draw();
			RenderSystem.enableTexture();
		}
		
		renderItem(matrixStack, n, i, o, p, k, l, f);
	}
	
}