Search in sources :

Example 6 with GameRenderer

use of net.minecraft.client.render.GameRenderer 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)

Example 7 with GameRenderer

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

the class ClientMeasureBox method render.

/**
 * Renders the Box
 *
 * @param camera           rendering Camera
 * @param stack
 * @param currentDimension Dimension the Player currently is in
 * @param boxCreatorName   Name of the Player that created the Box
 */
public void render(final Camera camera, final MatrixStack stack, final Identifier currentDimension, final Text boxCreatorName) {
    if (!(currentDimension.equals(this.dimension))) {
        return;
    }
    final Vec3d pos = camera.getPos();
    // FIXME This actually does nothing
    RenderSystem.lineWidth(2.0f);
    RenderSystem.disableDepthTest();
    RenderSystem.disableTexture();
    RenderSystem.disableBlend();
    stack.push();
    stack.translate(-pos.x, -pos.y, -pos.z);
    final Matrix4f model = stack.peek().getPositionMatrix();
    final Tessellator tess = Tessellator.getInstance();
    final BufferBuilder buffer = tess.getBuffer();
    final float[] color = this.color.getColorComponents();
    final float r = color[0];
    final float g = color[1];
    final float b = color[2];
    // FIXME This actually does nothing
    final float a = 0.8f;
    RenderSystem.setShader(GameRenderer::getPositionColorShader);
    buffer.begin(DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION_COLOR);
    buffer.vertex(model, (float) this.box.minX, (float) this.box.minY, (float) this.box.minZ).color(r, g, b, a).next();
    buffer.vertex(model, (float) this.box.maxX, (float) this.box.minY, (float) this.box.minZ).color(r, g, b, a).next();
    buffer.vertex(model, (float) this.box.maxX, (float) this.box.minY, (float) this.box.maxZ).color(r, g, b, a).next();
    buffer.vertex(model, (float) this.box.minX, (float) this.box.minY, (float) this.box.maxZ).color(r, g, b, a).next();
    buffer.vertex(model, (float) this.box.minX, (float) this.box.minY, (float) this.box.minZ).color(r, g, b, a).next();
    buffer.vertex(model, (float) this.box.minX, (float) this.box.maxY, (float) this.box.minZ).color(r, g, b, a).next();
    buffer.vertex(model, (float) this.box.minX, (float) this.box.maxY, (float) this.box.minZ).color(r, g, b, a).next();
    buffer.vertex(model, (float) this.box.maxX, (float) this.box.maxY, (float) this.box.minZ).color(r, g, b, a).next();
    buffer.vertex(model, (float) this.box.maxX, (float) this.box.maxY, (float) this.box.maxZ).color(r, g, b, a).next();
    buffer.vertex(model, (float) this.box.minX, (float) this.box.maxY, (float) this.box.maxZ).color(r, g, b, a).next();
    buffer.vertex(model, (float) this.box.minX, (float) this.box.maxY, (float) this.box.minZ).color(r, g, b, a).next();
    buffer.vertex(model, (float) this.box.minX, (float) this.box.maxY, (float) this.box.maxZ).color(r, g, b, a).next();
    buffer.vertex(model, (float) this.box.minX, (float) this.box.minY, (float) this.box.maxZ).color(r, g, b, a).next();
    buffer.vertex(model, (float) this.box.maxX, (float) this.box.minY, (float) this.box.maxZ).color(r, g, b, a).next();
    buffer.vertex(model, (float) this.box.maxX, (float) this.box.maxY, (float) this.box.maxZ).color(r, g, b, a).next();
    buffer.vertex(model, (float) this.box.maxX, (float) this.box.maxY, (float) this.box.minZ).color(r, g, b, a).next();
    buffer.vertex(model, (float) this.box.maxX, (float) this.box.minY, (float) this.box.minZ).color(r, g, b, a).next();
    tess.draw();
    if (BlockMeterClient.getConfigManager().getConfig().innerDiagonal) {
        buffer.begin(DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR);
        buffer.vertex(model, (float) this.box.minX, (float) this.box.minY, (float) this.box.minZ).color(r, g, b, a).next();
        buffer.vertex(model, (float) this.box.maxX, (float) this.box.maxY, (float) this.box.maxZ).color(r, g, b, a).next();
        tess.draw();
    }
    RenderSystem.enableTexture();
    RenderSystem.lineWidth(1.0f);
    this.drawLengths(camera, stack, boxCreatorName);
    RenderSystem.enableBlend();
    RenderSystem.enableDepthTest();
    stack.pop();
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) Tessellator(net.minecraft.client.render.Tessellator) BufferBuilder(net.minecraft.client.render.BufferBuilder) GameRenderer(net.minecraft.client.render.GameRenderer) Vec3d(net.minecraft.util.math.Vec3d)

Example 8 with GameRenderer

use of net.minecraft.client.render.GameRenderer in project BleachHack by BleachDrinker420.

the class Renderer method drawQuadFill.

// -------------------- Quads --------------------
public static void drawQuadFill(double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3, double x4, double y4, double z4, int cullMode, QuadColor color) {
    if (!FrustumUtils.isPointVisible(x1, y1, z1) && !FrustumUtils.isPointVisible(x2, y2, z2) && !FrustumUtils.isPointVisible(x3, y3, z3) && !FrustumUtils.isPointVisible(x4, y4, z4)) {
        return;
    }
    setup();
    MatrixStack matrices = matrixFrom(x1, y1, z1);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    // Fill
    RenderSystem.setShader(GameRenderer::getPositionColorShader);
    buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
    Vertexer.vertexQuad(matrices, buffer, 0f, 0f, 0f, (float) (x2 - x1), (float) (y2 - y1), (float) (z2 - z1), (float) (x3 - x1), (float) (y3 - y1), (float) (z3 - z1), (float) (x4 - x1), (float) (y4 - y1), (float) (z4 - z1), cullMode, color);
    tessellator.draw();
    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 9 with GameRenderer

use of net.minecraft.client.render.GameRenderer in project BleachHack by BleachDrinker420.

the class Renderer method drawQuadOutline.

public static void drawQuadOutline(double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3, double x4, double y4, double z4, float lineWidth, QuadColor color) {
    if (!FrustumUtils.isPointVisible(x1, y1, z1) && !FrustumUtils.isPointVisible(x2, y2, z2) && !FrustumUtils.isPointVisible(x3, y3, z3) && !FrustumUtils.isPointVisible(x4, y4, z4)) {
        return;
    }
    setup();
    MatrixStack matrices = matrixFrom(x1, y1, z1);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    int[] colors = color.getAllColors();
    // Outline
    RenderSystem.disableCull();
    RenderSystem.setShader(GameRenderer::getRenderTypeLinesShader);
    RenderSystem.lineWidth(lineWidth);
    buffer.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES);
    Vertexer.vertexLine(matrices, buffer, 0f, 0f, 0f, (float) (x2 - x1), (float) (y2 - y1), (float) (z2 - z1), LineColor.gradient(colors[0], colors[1]));
    Vertexer.vertexLine(matrices, buffer, (float) (x2 - x1), (float) (y2 - y1), (float) (z2 - z1), (float) (x3 - x1), (float) (y3 - y1), (float) (z3 - z1), LineColor.gradient(colors[1], colors[2]));
    Vertexer.vertexLine(matrices, buffer, (float) (x3 - x1), (float) (y3 - y1), (float) (z3 - z1), (float) (x4 - x1), (float) (y4 - y1), (float) (z4 - z1), LineColor.gradient(colors[2], colors[3]));
    Vertexer.vertexLine(matrices, buffer, (float) (x4 - x1), (float) (y4 - y1), (float) (z4 - z1), 0f, 0f, 0f, LineColor.gradient(colors[3], colors[0]));
    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 10 with GameRenderer

use of net.minecraft.client.render.GameRenderer in project BleachHack by BleachDrinker420.

the class WindowScreen method renderBackgroundTexture.

public void renderBackgroundTexture(int vOffset) {
    int colorOffset = (int) ((System.currentTimeMillis() / 75) % 100);
    if (colorOffset > 50)
        colorOffset = 50 - (colorOffset - 50);
    // smooth
    colorOffset = (int) (-(Math.cos(Math.PI * (colorOffset / 50d)) - 1) / 2 * 50);
    RenderSystem.disableTexture();
    RenderSystem.enableBlend();
    RenderSystem.defaultBlendFunc();
    RenderSystem.setShader(GameRenderer::getPositionColorShader);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
    bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
    bufferBuilder.vertex(width, 0, 0).color(30, 20, 80, 255).next();
    bufferBuilder.vertex(0, 0, 0).color(30 + colorOffset / 3, 20, 80, 255).next();
    bufferBuilder.vertex(0, height + 16, 0).color(90, 54, 159, 255).next();
    bufferBuilder.vertex(width, height + 16, 0).color(105 + colorOffset, 54, 189, 255).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)

Aggregations

GameRenderer (net.minecraft.client.render.GameRenderer)70 BufferBuilder (net.minecraft.client.render.BufferBuilder)46 Tessellator (net.minecraft.client.render.Tessellator)31 MatrixStack (net.minecraft.client.util.math.MatrixStack)12 Matrix4f (net.minecraft.util.math.Matrix4f)11 IMatrix4f (dev.hypnotic.utils.mixin.IMatrix4f)6 MinecraftClient (net.minecraft.client.MinecraftClient)5 ItemStack (net.minecraft.item.ItemStack)5 TranslatableText (net.minecraft.text.TranslatableText)4 Color (java.awt.Color)3 TextRenderer (net.minecraft.client.font.TextRenderer)3 Text (net.minecraft.text.Text)3 Vec3d (net.minecraft.util.math.Vec3d)3 Camera (net.minecraft.client.render.Camera)2 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)2 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 MapState (net.minecraft.item.map.MapState)2 OrderedText (net.minecraft.text.OrderedText)2 Box (net.minecraft.util.math.Box)2 IEOFWorldRenderer (com.qouteall.immersive_portals.IEOFWorldRenderer)1