Search in sources :

Example 36 with Tessellator

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

the class ColorPicker method render.

public void render(MatrixStack matrices, int mouseX, int mouseY) {
    colorSet.displayName = colorSet.name;
    int sx = x + 5, sy = y + 4 + height + 12, ex = x + width - 17, ey = y + 4 + height + getHeight(width) + 8;
    RenderUtils.fill(matrices, x, y + height, x + width, y + height * 8.5, -1);
    RenderUtils.fill(matrices, x + 1, y + height, x + width - 1, y + height * 8.5, new Color(40, 40, 40, 255).getRGB());
    RenderUtils.fill(matrices, sx + 3 + (int) FontManager.robotoSmall.getStringWidth(colorSet.name + colorSet.getHex().toUpperCase()) + 17, sy - 4, sx + 27 + (int) FontManager.robotoSmall.getStringWidth(colorSet.name + colorSet.getHex().toUpperCase()), sy - 12, new Color(0, 0, 0, 200).getRGB());
    DrawableHelper.fill(matrices, sx, sy, ex, ey, -1);
    int satColor = MathHelper.hsvToRgb(colorSet.hue, 1f, 1f);
    int red = satColor >> 16 & 255;
    int green = satColor >> 8 & 255;
    int blue = satColor & 255;
    RenderSystem.disableBlend();
    RenderSystem.disableTexture();
    RenderSystem.enableBlend();
    RenderSystem.defaultBlendFunc();
    RenderSystem.setShader(GameRenderer::getPositionColorShader);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
    // Draw the color
    bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
    bufferBuilder.vertex(ex, sy, 0).color(red, green, blue, 255).next();
    bufferBuilder.vertex(sx, sy, 0).color(red, green, blue, 0).next();
    bufferBuilder.vertex(sx, ey, 0).color(red, green, blue, 0).next();
    bufferBuilder.vertex(ex, ey, 0).color(red, green, blue, 255).next();
    tessellator.draw();
    // Draw the black stuff
    bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
    bufferBuilder.vertex(ex, sy, 0).color(0, 0, 0, 0).next();
    bufferBuilder.vertex(sx, sy, 0).color(0, 0, 0, 0).next();
    bufferBuilder.vertex(sx, ey, 0).color(0, 0, 0, 255).next();
    bufferBuilder.vertex(ex, ey, 0).color(0, 0, 0, 255).next();
    tessellator.draw();
    RenderSystem.disableBlend();
    RenderSystem.enableTexture();
    // Set the color
    if (hovered(mouseX, mouseY, sx, sy, ex, ey) && lmDown) {
        colorSet.bri = 1f - 1f / ((float) (ey - sy) / (mouseY - sy));
        colorSet.sat = 1f / ((float) (ex - sx) / (mouseX - sx));
    }
    int briY = (int) (ey - (ey - sy) * colorSet.bri);
    int satX = (int) (sx + (ex - sx) * colorSet.sat);
    RenderUtils.fill(matrices, satX - 2, briY - 2, satX + 2, briY + 2, Color.GRAY.brighter().getRGB(), Color.WHITE.darker().getRGB(), Color.WHITE.getRGB());
    FontManager.robotoSmall.drawWithShadow(matrices, colorSet.name, (int) sx, (int) sy - 12, -1);
    FontManager.robotoSmall.drawWithShadow(matrices, "#" + colorSet.getHex().toUpperCase(), (int) sx + FontManager.robotoSmall.getStringWidth(colorSet.name) + 12, (int) sy - 12, colorSet.getRGB());
    RenderUtils.fill(matrices, sx + 3 + FontManager.robotoSmall.getStringWidth(colorSet.name), sy - 4, sx + 10 + FontManager.robotoSmall.getStringWidth(colorSet.name), sy - 12, colorSet.getColor().getRGB());
    // Set hex codes
    if (hovered(mouseX, mouseY, sx + 3 + (int) FontManager.robotoSmall.getStringWidth(colorSet.name + colorSet.getHex().toUpperCase()) + 17, sy - 12, sx + 27 + (int) FontManager.robotoSmall.getStringWidth(colorSet.name + colorSet.getHex().toUpperCase()), sy - 4)) {
        RenderSystem.disableDepthTest();
        RenderSystem.depthFunc(GL11.GL_ALWAYS);
        RenderUtils.fill(matrices, mouseX, mouseY, mouseX + FontManager.robotoSmall.getStringWidth("Sets the hex color to your current clipboard") + 6, mouseY - 12, new Color(0, 0, 0, 200).getRGB());
        FontManager.robotoSmall.drawWithShadow(matrices, "Sets the hex color to your current clipboard", mouseX + 2, mouseY - 10, -1);
        RenderSystem.depthFunc(GL11.GL_LEQUAL);
        RenderSystem.enableDepthTest();
        if (lmDown && colorSet.getColor() != colorSet.hexToRgb(mc.keyboard.getClipboard())) {
            Color hexColor = colorSet.hexToRgb(mc.keyboard.getClipboard());
            float[] vals = colorSet.rgbToHsv(hexColor.getRed(), hexColor.getGreen(), hexColor.getBlue(), hexColor.getAlpha());
            colorSet.setHSV(vals[0], vals[1], vals[2]);
            h = vals[0];
            s = vals[1];
            v = vals[2];
        }
    }
    sx = ex + 5;
    ex = ex + 12;
    for (int i = sy; i < ey; i++) {
        float curHue = 1f / ((float) (ey - sy) / (i - sy));
        DrawableHelper.fill(matrices, sx, i, ex, i + 1, 0xff000000 | MathHelper.hsvToRgb(curHue, 1f, 1f));
    }
    if (hovered(mouseX, mouseY, sx, sy, ex, ey) && lmDown) {
        colorSet.hue = 1f / ((float) (ey - sy) / (mouseY - sy));
    }
    int hueY = (int) (sy + (ey - sy) * colorSet.hue);
    RenderUtils.fill(matrices, sx, hueY - 2, ex, hueY + 2, Color.GRAY.brighter().getRGB(), Color.WHITE.darker().getRGB(), Color.WHITE.getRGB());
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) Color(java.awt.Color) BufferBuilder(net.minecraft.client.render.BufferBuilder) GameRenderer(net.minecraft.client.render.GameRenderer)

Example 37 with Tessellator

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

the class ColorBox method render.

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY) {
    colorSet.displayName = colorSet.name;
    int sx = this.x - 10, sy = this.y + 12, ex = this.x + 100, ey = this.y + getHeight(120);
    HypnoticScreen.fontMed.drawWithShadow(matrices, colorSet.name, (int) sx, (int) sy - 12, -1);
    HypnoticScreen.fontMed.drawWithShadow(matrices, "#" + colorSet.getHex().toUpperCase(), (int) sx + HypnoticScreen.fontMed.getStringWidth(colorSet.name) + 12, (int) sy - 12, colorSet.getRGB());
    if (hovered((int) mouseX, (int) mouseY, sx + 160, sy - 12, sx + 190, sy - 4) && rmDown) {
        RenderUtils.setup2DRender(true);
        RenderUtils.end2DRender();
        open = !open;
        rmDown = false;
    }
    RenderUtils.fill(matrices, sx + 190, sy - 12, sx + 160, sy - 4, colorSet.getColor().getRGB());
    RenderUtils.fill(matrices, sx + 3 + HypnoticScreen.fontMed.getStringWidth(colorSet.name), sy - 3, sx + 10 + HypnoticScreen.fontMed.getStringWidth(colorSet.name), sy - 11, colorSet.getColor().getRGB());
    if (hovered(mouseX, mouseY, sx + 3 + (int) HypnoticScreen.fontMed.getStringWidth(colorSet.name + colorSet.getHex().toUpperCase()) + 17, sy - 12, sx + 27 + (int) HypnoticScreen.fontMed.getStringWidth(colorSet.name + colorSet.getHex().toUpperCase()), sy - 4)) {
        RenderUtils.setup2DRender(true);
        RenderUtils.end2DRender();
        if (lmDown && colorSet.getColor() != colorSet.hexToRgb(mc.keyboard.getClipboard())) {
            Color hexColor = colorSet.hexToRgb(mc.keyboard.getClipboard());
            float[] vals = colorSet.rgbToHsv(hexColor.getRed(), hexColor.getGreen(), hexColor.getBlue(), hexColor.getAlpha());
            colorSet.setHSV(vals[0], vals[1], vals[2]);
            h = vals[0];
            s = vals[1];
            v = vals[2];
        }
    }
    if (!open) {
        return;
    }
    RenderUtils.fill(matrices, sx + 3 + (int) HypnoticScreen.fontMed.getStringWidth(colorSet.name + colorSet.getHex().toUpperCase()) + 17, sy - 4, sx + 27 + (int) HypnoticScreen.fontMed.getStringWidth(colorSet.name + colorSet.getHex().toUpperCase()), sy - 12, new Color(0, 0, 0, 200).getRGB());
    RenderUtils.fill(matrices, sx, sy, ex, ey, -1);
    int satColor = MathHelper.hsvToRgb(colorSet.hue, 1f, 1f);
    int red = satColor >> 16 & 255;
    int green = satColor >> 8 & 255;
    int blue = satColor & 255;
    RenderSystem.disableBlend();
    RenderSystem.disableTexture();
    RenderSystem.enableBlend();
    RenderSystem.defaultBlendFunc();
    RenderSystem.setShader(GameRenderer::getPositionColorShader);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
    // Draw the color
    bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
    bufferBuilder.vertex(ex, sy, 0).color(red, green, blue, 255).next();
    bufferBuilder.vertex(sx, sy, 0).color(red, green, blue, 0).next();
    bufferBuilder.vertex(sx, ey, 0).color(red, green, blue, 0).next();
    bufferBuilder.vertex(ex, ey, 0).color(red, green, blue, 255).next();
    tessellator.draw();
    // Draw the black stuff
    bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
    bufferBuilder.vertex(ex, sy, 0).color(0, 0, 0, 0).next();
    bufferBuilder.vertex(sx, sy, 0).color(0, 0, 0, 0).next();
    bufferBuilder.vertex(sx, ey, 0).color(0, 0, 0, 255).next();
    bufferBuilder.vertex(ex, ey, 0).color(0, 0, 0, 255).next();
    tessellator.draw();
    RenderSystem.disableBlend();
    RenderSystem.enableTexture();
    // Set the color
    if (hovered(mouseX, mouseY, sx, sy, ex, ey) && lmDown) {
        colorSet.bri = 1f - 1f / ((float) (ey - sy) / (mouseY - sy));
        colorSet.sat = 1f / ((float) (ex - sx) / (mouseX - sx));
    }
    int briY = (int) (ey - (ey - sy) * colorSet.bri);
    int satX = (int) (sx + (ex - sx) * colorSet.sat);
    // Set hex codes
    if (hovered(mouseX, mouseY, sx + 3 + (int) HypnoticScreen.fontMed.getStringWidth(colorSet.name + colorSet.getHex().toUpperCase()) + 17, sy - 12, sx + 27 + (int) HypnoticScreen.fontMed.getStringWidth(colorSet.name + colorSet.getHex().toUpperCase()), sy - 4)) {
        RenderUtils.setup2DRender(true);
        RenderUtils.fill(matrices, mouseX, mouseY, mouseX + HypnoticScreen.fontMed.getStringWidth("Sets the hex color to your current clipboard") + 6, mouseY - 12, new Color(0, 0, 0, 200).getRGB());
        HypnoticScreen.fontMed.drawWithShadow(matrices, "Sets the hex color to your current clipboard", mouseX + 2, mouseY - 10, -1);
        RenderUtils.end2DRender();
        if (lmDown && colorSet.getColor() != colorSet.hexToRgb(mc.keyboard.getClipboard())) {
            Color hexColor = colorSet.hexToRgb(mc.keyboard.getClipboard());
            float[] vals = colorSet.rgbToHsv(hexColor.getRed(), hexColor.getGreen(), hexColor.getBlue(), hexColor.getAlpha());
            colorSet.setHSV(vals[0], vals[1], vals[2]);
            h = vals[0];
            s = vals[1];
            v = vals[2];
        }
    }
    sx = ex + 5;
    ex = ex + 12;
    for (int i = sy; i < ey; i++) {
        float curHue = 1f / ((float) (ey - sy) / (i - sy));
        DrawableHelper.fill(matrices, sx, i, ex, i + 1, 0xff000000 | MathHelper.hsvToRgb(curHue, 1f, 1f));
    }
    if (hovered(mouseX, mouseY, sx, sy, ex, ey) && lmDown) {
        colorSet.hue = 1f / ((float) (ey - sy) / (mouseY - sy));
    }
    int hueY = (int) (sy + (ey - sy) * colorSet.hue);
    RenderUtils.fill(matrices, sx, hueY - 1, ex, hueY + 1, -1);
    RenderUtils.drawOutlineCircle(matrices, satX - 3, briY - 3, 6, Color.WHITE);
    super.render(matrices, mouseX, mouseY);
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) Color(java.awt.Color) BufferBuilder(net.minecraft.client.render.BufferBuilder) GameRenderer(net.minecraft.client.render.GameRenderer)

Example 38 with Tessellator

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

the class RenderUtils method drawLine.

public static void drawLine(double x1, double y1, double z1, double x2, double y2, double z2, LineColor color, float width) {
    if (!isPointVisible(x1, y1, z1) && !isPointVisible(x2, y2, z2)) {
        return;
    }
    setup3DRender(true);
    MatrixStack matrices = matrixFrom(x1, y1, z1);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    // Line
    RenderSystem.disableDepthTest();
    RenderSystem.disableCull();
    RenderSystem.setShader(GameRenderer::getRenderTypeLinesShader);
    RenderSystem.lineWidth(width);
    buffer.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES);
    Vertexer.vertexLine(matrices, buffer, 0f, 0f, 0f, (float) (x2 - x1), (float) (y2 - y1), (float) (z2 - z1), color);
    tessellator.draw();
    RenderSystem.enableCull();
    RenderSystem.enableDepthTest();
    end3DRender();
}
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 39 with Tessellator

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

the class RenderUtils method renderGuiItemOverlay.

public static void renderGuiItemOverlay(TextRenderer renderer, ItemStack stack, float x, float y, float scale, @Nullable String countLabel) {
    if (!stack.isEmpty()) {
        MatrixStack matrixStack = new MatrixStack();
        if (stack.getCount() != 1 || countLabel != null) {
            String string = countLabel == null ? String.valueOf(stack.getCount()) : countLabel;
            matrixStack.translate(0.0D, 0.0D, (double) (mc.getItemRenderer().zOffset + 200.0F));
            VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer());
            renderer.draw(string, (float) (x + 19 - 2 - renderer.getWidth(string)), (float) (y + 6 + 3), 16777215, true, matrixStack.peek().getPositionMatrix(), immediate, false, 0, 15728880);
            immediate.draw();
        }
        if (stack.isItemBarVisible()) {
            RenderSystem.disableDepthTest();
            RenderSystem.disableTexture();
            RenderSystem.disableBlend();
            int i = stack.getItemBarStep();
            int j = stack.getItemBarColor();
            fill(matrixStack, x + 2, y + 13, x + 2 + 13, y + 13 + 2, 0xff000000);
            fill(matrixStack, x + 2, y + 13, x + 2 + i, y + 13 + 1, new Color(j >> 16 & 255, j >> 8 & 255, j & 255, 255).getRGB());
            RenderSystem.enableBlend();
            RenderSystem.enableTexture();
            RenderSystem.enableDepthTest();
        }
        ClientPlayerEntity clientPlayerEntity = mc.player;
        float f = clientPlayerEntity == null ? 0.0F : clientPlayerEntity.getItemCooldownManager().getCooldownProgress(stack.getItem(), MinecraftClient.getInstance().getTickDelta());
        if (f > 0.0F) {
            RenderSystem.disableDepthTest();
            RenderSystem.disableTexture();
            RenderSystem.enableBlend();
            RenderSystem.defaultBlendFunc();
            Tessellator tessellator2 = Tessellator.getInstance();
            BufferBuilder bufferBuilder2 = tessellator2.getBuffer();
            renderGuiQuad(bufferBuilder2, x, y + MathHelper.floor(16.0F * (1.0F - f)), 16, MathHelper.ceil(16.0F * f), 255, 255, 255, 127);
            RenderSystem.enableTexture();
            RenderSystem.enableDepthTest();
        }
    }
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) MatrixStack(net.minecraft.client.util.math.MatrixStack) Color(java.awt.Color) BufferBuilder(net.minecraft.client.render.BufferBuilder) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) VertexConsumerProvider(net.minecraft.client.render.VertexConsumerProvider)

Example 40 with Tessellator

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

the class RenderUtils method drawBoxFill.

public static void drawBoxFill(Box box, QuadColor color, Direction... excludeDirs) {
    if (!getFrustum().isVisible(box)) {
        return;
    }
    setup3DRender(true);
    MatrixStack matrices = matrixFrom(box.minX, box.minY, box.minZ);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    // Fill
    RenderSystem.setShader(GameRenderer::getPositionColorShader);
    buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
    Vertexer.vertexBoxQuads(matrices, buffer, Boxes.moveToZero(box), color, excludeDirs);
    tessellator.draw();
    end3DRender();
}
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)

Aggregations

Tessellator (net.minecraft.client.render.Tessellator)47 BufferBuilder (net.minecraft.client.render.BufferBuilder)43 GameRenderer (net.minecraft.client.render.GameRenderer)31 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