Search in sources :

Example 66 with BufferBuilder

use of net.minecraft.client.render.BufferBuilder in project Hypnotic-Client by Hypnotic-Development.

the class RenderUtils method sideGradientFill.

public static void sideGradientFill(MatrixStack matrixStack, double x1, double y1, double x2, double y2, int color1, int color2, boolean dir) {
    Matrix4f matrix = matrixStack.peek().getPositionMatrix();
    double j;
    if (x1 < x2) {
        j = x1;
        x1 = x2;
        x2 = j;
    }
    if (y1 < y2) {
        j = y1;
        y1 = y2;
        y2 = j;
    }
    float f1 = (float) (color1 >> 24 & 255) / 255.0F;
    float g1 = (float) (color1 >> 16 & 255) / 255.0F;
    float h1 = (float) (color1 >> 8 & 255) / 255.0F;
    float k1 = (float) (color1 & 255) / 255.0F;
    float f2 = (float) (color2 >> 24 & 255) / 255.0F;
    float g2 = (float) (color2 >> 16 & 255) / 255.0F;
    float h2 = (float) (color2 >> 8 & 255) / 255.0F;
    float k2 = (float) (color2 & 255) / 255.0F;
    BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
    RenderSystem.enableBlend();
    RenderSystem.disableTexture();
    RenderSystem.defaultBlendFunc();
    RenderSystem.setShader(GameRenderer::getPositionColorShader);
    bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
    bufferBuilder.vertex(matrix, (float) x1, (float) y2, 0.0F).color(!dir ? g2 : g1, !dir ? h2 : h1, !dir ? k2 : k1, !dir ? f2 : f1).next();
    bufferBuilder.vertex(matrix, (float) x2, (float) y2, 0.0F).color(dir ? g2 : g1, dir ? h2 : h1, dir ? k2 : k1, dir ? f2 : f1).next();
    bufferBuilder.vertex(matrix, (float) x2, (float) y1, 0.0F).color(dir ? g2 : g1, dir ? h2 : h1, dir ? k2 : k1, dir ? f2 : f1).next();
    bufferBuilder.vertex(matrix, (float) x1, (float) y1, 0.0F).color(!dir ? g2 : g1, !dir ? h2 : h1, !dir ? k2 : k1, !dir ? f2 : f1).next();
    bufferBuilder.end();
    BufferRenderer.draw(bufferBuilder);
    RenderSystem.enableTexture();
    RenderSystem.disableBlend();
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) IMatrix4f(dev.hypnotic.utils.mixin.IMatrix4f) BufferBuilder(net.minecraft.client.render.BufferBuilder) GameRenderer(net.minecraft.client.render.GameRenderer)

Example 67 with BufferBuilder

use of net.minecraft.client.render.BufferBuilder in project Hypnotic-Client by Hypnotic-Development.

the class RenderUtils method drawOutlineBox.

public static void drawOutlineBox(MatrixStack matrixStack, Box bb, int color, boolean draw) {
    Color color1 = ColorUtils.getColor(color);
    Matrix4f matrix4f = matrixStack.peek().getPositionMatrix();
    BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
    if (draw)
        bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINES, /*LINES*/
        VertexFormats.POSITION_COLOR);
    VoxelShape shape = VoxelShapes.cuboid(bb);
    shape.forEachEdge((x1, y1, z1, x2, y2, z2) -> {
        bufferBuilder.vertex(matrix4f, (float) x1, (float) y1, (float) z1).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
        bufferBuilder.vertex(matrix4f, (float) x2, (float) y2, (float) z2).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    });
    if (draw) {
        bufferBuilder.end();
        BufferRenderer.draw(bufferBuilder);
    }
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) IMatrix4f(dev.hypnotic.utils.mixin.IMatrix4f) VoxelShape(net.minecraft.util.shape.VoxelShape) Color(java.awt.Color) BufferBuilder(net.minecraft.client.render.BufferBuilder)

Example 68 with BufferBuilder

use of net.minecraft.client.render.BufferBuilder in project Hypnotic-Client by Hypnotic-Development.

the class RenderUtils method drawCircle.

public static void drawCircle(MatrixStack matrices, int xx, int yy, float radius, float width, int sides, Color color) {
    int sections = sides;
    xx *= 2.0f;
    yy *= 2.0f;
    float theta = (float) (6.2831852 / (double) sections);
    float p = (float) Math.cos(theta);
    float s = (float) Math.sin(theta);
    float x = radius *= 2.0f;
    float y = 0.0f;
    float lastX = x, lastY = 0;
    for (int ii = -1; ii < sections; ++ii) {
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder buffer = tessellator.getBuffer();
        RenderSystem.enableBlend();
        RenderSystem.disableDepthTest();
        RenderSystem.disableCull();
        RenderSystem.setShader(GameRenderer::getRenderTypeLinesShader);
        RenderSystem.lineWidth(width);
        buffer.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES);
        Vertexer.vertexLine(matrices, buffer, x + xx, yy + y, 0f, xx + lastX, yy + lastY, 0f, LineColor.single(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()));
        tessellator.draw();
        RenderSystem.enableCull();
        RenderSystem.enableDepthTest();
        lastX = x;
        lastY = y;
        float t = x;
        x = p * x - s * y;
        y = s * t + p * y;
    }
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) BufferBuilder(net.minecraft.client.render.BufferBuilder) GameRenderer(net.minecraft.client.render.GameRenderer)

Example 69 with BufferBuilder

use of net.minecraft.client.render.BufferBuilder in project Hypnotic-Client by Hypnotic-Development.

the class RenderUtils method renderRoundedQuadInternal.

// Taken from Coffee client (https://github.com/business-goose/Coffee/tree/master)
// My rounded stuff looked retarded
public static void renderRoundedQuadInternal(Matrix4f matrix, float cr, float cg, float cb, float ca, double fromX, double fromY, double toX, double toY, double rad, double samples) {
    BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
    bufferBuilder.begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR);
    double toX1 = toX - rad;
    double toY1 = toY - rad;
    double fromX1 = fromX + rad;
    double fromY1 = fromY + rad;
    double[][] map = new double[][] { new double[] { toX1, toY1 }, new double[] { toX1, fromY1 }, new double[] { fromX1, fromY1 }, new double[] { fromX1, toY1 } };
    for (int i = 0; i < 4; i++) {
        double[] current = map[i];
        for (double r = i * 90d; r < (360 / 4d + i * 90d); r += (90 / samples)) {
            float rad1 = (float) Math.toRadians(r);
            float sin = (float) (Math.sin(rad1) * rad);
            float cos = (float) (Math.cos(rad1) * rad);
            bufferBuilder.vertex(matrix, (float) current[0] + sin, (float) current[1] + cos, 0.0F).color(cr, cg, cb, ca).next();
        }
    }
    bufferBuilder.end();
    BufferRenderer.draw(bufferBuilder);
}
Also used : BufferBuilder(net.minecraft.client.render.BufferBuilder)

Example 70 with BufferBuilder

use of net.minecraft.client.render.BufferBuilder in project Hypnotic-Client by Hypnotic-Development.

the class RenderUtils method drawStar.

public static void drawStar(MatrixStack matrices, final int xx, final int yy, final float radius, Color color) {
    int sections = 360;
    double dAngle = 2 * Math.PI / sections;
    float x, y, lastX = 0;
    for (int i = 0; i < sections; i++) {
        x = (float) (radius * Math.sin((i * dAngle)));
        y = (float) (radius * Math.cos((i * dAngle)));
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder buffer = tessellator.getBuffer();
        RenderSystem.disableDepthTest();
        RenderSystem.disableCull();
        RenderSystem.setShader(GameRenderer::getRenderTypeLinesShader);
        RenderSystem.lineWidth(1);
        buffer.begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR);
        Vertexer.vertexTri(matrices, buffer, xx, yy, 0f, xx, yy + y, 10f, xx + lastX, yy, 0f, color);
        tessellator.draw();
        RenderSystem.enableCull();
        RenderSystem.enableDepthTest();
        lastX = x;
    }
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) BufferBuilder(net.minecraft.client.render.BufferBuilder) GameRenderer(net.minecraft.client.render.GameRenderer)

Aggregations

BufferBuilder (net.minecraft.client.render.BufferBuilder)76 GameRenderer (net.minecraft.client.render.GameRenderer)46 Tessellator (net.minecraft.client.render.Tessellator)44 Matrix4f (net.minecraft.util.math.Matrix4f)18 MatrixStack (net.minecraft.client.util.math.MatrixStack)14 IMatrix4f (dev.hypnotic.utils.mixin.IMatrix4f)9 Color (java.awt.Color)9 RenderLayer (net.minecraft.client.render.RenderLayer)5 Vec3d (net.minecraft.util.math.Vec3d)5 BlockState (net.minecraft.block.BlockState)4 BlockEntity (net.minecraft.block.entity.BlockEntity)4 ChunkOcclusionDataBuilder (net.minecraft.client.render.chunk.ChunkOcclusionDataBuilder)4 FluidState (net.minecraft.fluid.FluidState)4 BlockPos (net.minecraft.util.math.BlockPos)4 Random (java.util.Random)3 BlockRenderManager (net.minecraft.client.render.block.BlockRenderManager)3 ChunkRendererRegion (net.minecraft.client.render.chunk.ChunkRendererRegion)3 Inject (org.spongepowered.asm.mixin.injection.Inject)3 Mirror (com.qouteall.immersive_portals.portal.Mirror)2 HashSet (java.util.HashSet)2