Search in sources :

Example 1 with Tessellator

use of net.minecraft.client.render.Tessellator in project Skyblocker by LifeIsAParadox.

the class RenderUtils method drawBoxOutline.

public static void drawBoxOutline(Box box, QuadColor color, float lineWidth, Direction... excludeDirs) {
    if (!FrustumUtils.isBoxVisible(box)) {
        return;
    }
    setup();
    MatrixStack matrices = matrixFrom(box.minX, box.minY, box.minZ);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    // Outline
    RenderSystem.disableCull();
    RenderSystem.setShader(GameRenderer::getRenderTypeLinesShader);
    RenderSystem.lineWidth(lineWidth);
    buffer.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES);
    Vertexer.vertexBoxLines(matrices, buffer, Boxes.moveToZero(box), color, excludeDirs);
    tessellator.draw();
    RenderSystem.enableCull();
    cleanup();
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) MatrixStack(net.minecraft.client.util.math.MatrixStack) BufferBuilder(net.minecraft.client.render.BufferBuilder) GameRenderer(net.minecraft.client.render.GameRenderer)

Example 2 with Tessellator

use of net.minecraft.client.render.Tessellator in project Polymorph by TheIllusiveC4.

the class SelectionWidget method drawGradientRect.

public static void drawGradientRect(Matrix4f mat, int zLevel, int left, int top, int right, int bottom, int startColor, int endColor) {
    float startAlpha = (float) (startColor >> 24 & 255) / 255.0F;
    float startRed = (float) (startColor >> 16 & 255) / 255.0F;
    float startGreen = (float) (startColor >> 8 & 255) / 255.0F;
    float startBlue = (float) (startColor & 255) / 255.0F;
    float endAlpha = (float) (endColor >> 24 & 255) / 255.0F;
    float endRed = (float) (endColor >> 16 & 255) / 255.0F;
    float endGreen = (float) (endColor >> 8 & 255) / 255.0F;
    float endBlue = (float) (endColor & 255) / 255.0F;
    RenderSystem.enableDepthTest();
    RenderSystem.disableTexture();
    RenderSystem.enableBlend();
    RenderSystem.defaultBlendFunc();
    RenderSystem.setShader(GameRenderer::getPositionColorShader);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
    buffer.vertex(mat, right, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).next();
    buffer.vertex(mat, left, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).next();
    buffer.vertex(mat, left, bottom, zLevel).color(endRed, endGreen, endBlue, endAlpha).next();
    buffer.vertex(mat, right, bottom, zLevel).color(endRed, endGreen, endBlue, endAlpha).next();
    tessellator.draw();
    RenderSystem.disableBlend();
    RenderSystem.enableTexture();
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) BufferBuilder(net.minecraft.client.render.BufferBuilder) GameRenderer(net.minecraft.client.render.GameRenderer)

Example 3 with Tessellator

use of net.minecraft.client.render.Tessellator in project jGui by ReplayMod.

the class MCVer method drawRect.

public static void drawRect(int right, int bottom, int left, int top) {
    // #if MC>=10800
    Tessellator tessellator = Tessellator.getInstance();
    // #else
    // $$ Tessellator tessellator = Tessellator.instance;
    // #endif
    // #if MC>=10904
    BufferBuilder vertexBuffer = tessellator.getBuffer();
    // #else
    // #if MC>=10800
    // $$ WorldRenderer vertexBuffer = tessellator.getWorldRenderer();
    // #else
    // $$ Tessellator vertexBuffer = tessellator;
    // #endif
    // #endif
    // #if MC>=10809
    // #if MC>=11700
    // $$ vertexBuffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
    // #else
    vertexBuffer.begin(GL11.GL_QUADS, VertexFormats.POSITION);
    // #endif
    vertexBuffer.vertex(right, top, 0).next();
    vertexBuffer.vertex(left, top, 0).next();
    vertexBuffer.vertex(left, bottom, 0).next();
    vertexBuffer.vertex(right, bottom, 0).next();
    // #else
    // $$ vertexBuffer.startDrawingQuads();
    // $$ vertexBuffer.addVertex(right, top, 0);
    // $$ vertexBuffer.addVertex(left, top, 0);
    // $$ vertexBuffer.addVertex(left, bottom, 0);
    // $$ vertexBuffer.addVertex(right, bottom, 0);
    // #endif
    tessellator.draw();
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) BufferBuilder(net.minecraft.client.render.BufferBuilder)

Example 4 with Tessellator

use of net.minecraft.client.render.Tessellator in project jGui by ReplayMod.

the class MCVer method drawRect.

public static void drawRect(int x, int y, int width, int height, ReadableColor tl, ReadableColor tr, ReadableColor bl, ReadableColor br) {
    // #if MC>=10800
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder vertexBuffer = tessellator.getBuffer();
    // #else
    // $$ Tessellator tessellator = Tessellator.instance;
    // $$ Tessellator vertexBuffer = tessellator;
    // #endif
    // #if MC>=10809
    // #if MC>=11700
    // $$ vertexBuffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
    // #else
    vertexBuffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_COLOR);
    // #endif
    vertexBuffer.vertex(x, y + height, 0).color(bl.getRed(), bl.getGreen(), bl.getBlue(), bl.getAlpha()).next();
    vertexBuffer.vertex(x + width, y + height, 0).color(br.getRed(), br.getGreen(), br.getBlue(), br.getAlpha()).next();
    vertexBuffer.vertex(x + width, y, 0).color(tr.getRed(), tr.getGreen(), tr.getBlue(), tr.getAlpha()).next();
    vertexBuffer.vertex(x, y, 0).color(tl.getRed(), tl.getGreen(), tl.getBlue(), tl.getAlpha()).next();
    // #else
    // $$ vertexBuffer.startDrawingQuads();
    // $$ vertexBuffer.setColorRGBA(bl.getRed(), bl.getGreen(), bl.getBlue(), bl.getAlpha());
    // $$ vertexBuffer.addVertex(x, y + height, 0);
    // $$ vertexBuffer.setColorRGBA(br.getRed(), br.getGreen(), br.getBlue(), br.getAlpha());
    // $$ vertexBuffer.addVertex(x + width, y + height, 0);
    // $$ vertexBuffer.setColorRGBA(tr.getRed(), tr.getGreen(), tr.getBlue(), tr.getAlpha());
    // $$ vertexBuffer.addVertex(x + width, y, 0);
    // $$ vertexBuffer.setColorRGBA(tl.getRed(), tl.getGreen(), tl.getBlue(), tl.getAlpha());
    // $$ vertexBuffer.addVertex(x, y, 0);
    // #endif
    tessellator.draw();
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) BufferBuilder(net.minecraft.client.render.BufferBuilder)

Example 5 with Tessellator

use of net.minecraft.client.render.Tessellator in project BlockMeter by ModProg.

the class ColorButton method render.

@Override
public void render(MatrixStack stack, final int int_1, final int int_2, final float float_1) {
    super.render(stack, int_1, int_2, float_1);
    RenderSystem.disableTexture();
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferBuilder = tessellator.getBuffer();
    RenderSystem.setShader(GameRenderer::getPositionColorShader);
    int r = this.color.getRed();
    int g = this.color.getGreen();
    int b = this.color.getBlue();
    int a = texture ? 102 : 255;
    bufferBuilder.begin(DrawMode.QUADS, VertexFormats.POSITION_COLOR);
    bufferBuilder.vertex((double) this.x - (texture ? 1 : 0), (double) this.y - (texture ? 1 : 0), 0.0).color(r, g, b, a).next();
    bufferBuilder.vertex((double) this.x - (texture ? 1 : 0), this.y + this.height + (texture ? 1 : 0), 0.0).color(r, g, b, a).next();
    bufferBuilder.vertex(this.x + this.width + (texture ? 1 : 0), this.y + this.height + (texture ? 1 : 0), 0.0).color(r, g, b, a).next();
    bufferBuilder.vertex(this.x + this.width + (texture ? 1 : 0), (double) this.y - (texture ? 1 : 0), 0.0).color(r, g, b, a).next();
    tessellator.draw();
    RenderSystem.enableTexture();
    if (text != null) {
        boolean dark = (0.299f * color.getRed() + 0.587f * color.getBlue() + 0.114f * color.getRed()) / 255f < 0.8f;
        @SuppressWarnings("resource") final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
        int text_width = textRenderer.getWidth(text);
        if (dark || texture)
            textRenderer.drawWithShadow(stack, text, x + width / 2 - text_width / 2, y + height / 2 - 4, 0xFFFFFF);
        else {
            // shadow
            textRenderer.draw(stack, text, x + width / 2 - text_width / 2 + 1, y + height / 2 - 3, 0xAAAAAA);
            textRenderer.draw(stack, text, x + width / 2 - text_width / 2, y + height / 2 - 4, 0);
        }
    }
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) BufferBuilder(net.minecraft.client.render.BufferBuilder) GameRenderer(net.minecraft.client.render.GameRenderer) TextRenderer(net.minecraft.client.font.TextRenderer)

Aggregations

Tessellator (net.minecraft.client.render.Tessellator)45 BufferBuilder (net.minecraft.client.render.BufferBuilder)41 GameRenderer (net.minecraft.client.render.GameRenderer)29 MatrixStack (net.minecraft.client.util.math.MatrixStack)12 Color (java.awt.Color)4 Inject (org.spongepowered.asm.mixin.injection.Inject)4 Matrix4f (net.minecraft.util.math.Matrix4f)3 Framebuffer (net.minecraft.client.gl.Framebuffer)2 Shader (net.minecraft.client.render.Shader)2 Box (net.minecraft.util.math.Box)2 Vec3d (net.minecraft.util.math.Vec3d)2 Mirror (com.qouteall.immersive_portals.portal.Mirror)1 Random (java.util.Random)1 BlockBase (net.minecraft.block.BlockBase)1 TextRenderer (net.minecraft.client.font.TextRenderer)1 VertexBuffer (net.minecraft.client.gl.VertexBuffer)1 ClientPlayerEntity (net.minecraft.client.network.ClientPlayerEntity)1 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)1 NbtCompound (net.minecraft.nbt.NbtCompound)1 StationTessellator (net.modificationstation.stationapi.api.client.render.StationTessellator)1