use of net.minecraft.client.render.BufferBuilder in project Hypnotic-Client by Hypnotic-Development.
the class ColorBox method render.
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, int offset) {
colorSet.displayName = colorSet.name;
sx = parent.getX() + 5;
sy = parent.getY() + 4 + offset + parent.getHeight() + 12;
ex = parent.getX() + parent.getWidth() - 17;
ey = parent.getY() + 4 + offset + parent.getHeight() + getHeight(parent.getWidth()) + 8;
RenderUtils.fill(matrices, parent.getX() + 1, parent.getY() + offset + parent.getHeight(), parent.getX() + parent.getWidth() - 1, parent.getY() + offset + parent.getHeight() * (open ? 8.5 : 2), new Color(40, 40, 40, 255).getRGB());
HypnoticScreen.fontSmall.drawWithShadow(matrices, colorSet.name, (int) sx, (int) sy - 12, -1);
HypnoticScreen.fontSmall.drawWithShadow(matrices, "#" + colorSet.getHex().toUpperCase(), (int) sx + HypnoticScreen.fontSmall.getStringWidth(colorSet.name) + (open ? 12 : 2), (int) sy - 12, colorSet.getRGB());
if (hovered((int) mouseX, (int) mouseY, sx + (int) HypnoticScreen.fontSmall.getStringWidth(colorSet.name + "#" + colorSet.getHex().toUpperCase()) + 4, sy - 12, (int) (sx + HypnoticScreen.fontSmall.getStringWidth(colorSet.name + "#" + colorSet.getHex().toUpperCase()) + 30), sy - 4) && !open) {
RenderUtils.setup2DRender(true);
RenderUtils.fill(matrices, mouseX, mouseY, mouseX + HypnoticScreen.fontSmall.getStringWidth("Right click me!") + 6, mouseY - 12, new Color(0, 0, 0, 200).getRGB());
HypnoticScreen.fontSmall.drawWithShadow(matrices, "Right click me!", mouseX + 2, mouseY - 10, -1);
RenderUtils.end2DRender();
if (rmDown)
open = true;
}
if (!open) {
RenderUtils.fill(matrices, sx + HypnoticScreen.fontSmall.getStringWidth(colorSet.name + "#" + colorSet.getHex().toUpperCase()) + 4, sy - 12, sx + HypnoticScreen.fontSmall.getStringWidth(colorSet.name + "#" + colorSet.getHex().toUpperCase()) + 30, sy - 4, colorSet.getColor().getRGB());
return;
}
RenderUtils.fill(matrices, sx + 3 + (int) HypnoticScreen.fontSmall.getStringWidth(colorSet.name + colorSet.getHex().toUpperCase()) + 17, sy - 4, sx + 27 + (int) HypnoticScreen.fontSmall.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);
RenderUtils.fill(matrices, satX - 2, briY - 2, satX + 2, briY + 2, Color.GRAY.brighter().getRGB(), Color.WHITE.darker().getRGB(), Color.WHITE.getRGB());
RenderUtils.fill(matrices, sx + 3 + HypnoticScreen.fontSmall.getStringWidth(colorSet.name), sy - 4, sx + 10 + HypnoticScreen.fontSmall.getStringWidth(colorSet.name), sy - 12, colorSet.getColor().getRGB());
if (hovered((int) mouseX, (int) mouseY, sx + 3 + (int) HypnoticScreen.fontSmall.getStringWidth(colorSet.name), sy - 12, sx + 10 + (int) HypnoticScreen.fontSmall.getStringWidth(colorSet.name), sy - 4) && open) {
RenderUtils.setup2DRender(true);
RenderUtils.fill(matrices, mouseX, mouseY, mouseX + HypnoticScreen.fontSmall.getStringWidth("Right click me!") + 6, mouseY - 12, new Color(0, 0, 0, 200).getRGB());
HypnoticScreen.fontSmall.drawWithShadow(matrices, "Right click me!", mouseX + 2, mouseY - 10, -1);
RenderUtils.end2DRender();
if (rmDown)
open = false;
}
// Set hex codes
if (hovered(mouseX, mouseY, sx + 3 + (int) HypnoticScreen.fontSmall.getStringWidth(colorSet.name + colorSet.getHex().toUpperCase()) + 17, sy - 12, sx + 27 + (int) HypnoticScreen.fontSmall.getStringWidth(colorSet.name + colorSet.getHex().toUpperCase()), sy - 4)) {
RenderSystem.disableDepthTest();
RenderSystem.depthFunc(GL11.GL_ALWAYS);
RenderUtils.fill(matrices, mouseX, mouseY, mouseX + HypnoticScreen.fontSmall.getStringWidth("Sets the hex color to your current clipboard") + 6, mouseY - 12, new Color(0, 0, 0, 200).getRGB());
HypnoticScreen.fontSmall.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());
super.render(matrices, mouseX, mouseY, offset);
}
use of net.minecraft.client.render.BufferBuilder in project Hypnotic-Client by Hypnotic-Development.
the class NahrFont method drawer.
private final void drawer(MatrixStack matrixStack, String text, float x, float y, int color) {
x *= 2.0F;
y *= 2.0F;
RenderUtils.setup2DRender(false);
RenderUtils.bindTexture(this.resourceLocation);
if ((color & -67108864) == 0) {
color |= -16777216;
}
int newColor = color;
float startX = x;
boolean scramble = false;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
for (int i = 0; i < text.length(); i++) if ((text.charAt(i) == '\247') && (i + 1 < text.length())) {
char oneMore = Character.toLowerCase(text.charAt(i + 1));
if (oneMore == 'n') {
y += this.theMetrics.getAscent() + 2;
x = startX;
} else if (oneMore == 'k') {
scramble = true;
} else if (oneMore == 'r')
newColor = color;
else {
newColor = getColorFromCode(oneMore);
}
i++;
} else {
try {
String obfText = "\\:><&%$@!/?";
char c = scramble ? obfText.charAt((int) (new Random().nextFloat() * (obfText.length() - 1))) : text.charAt(i);
drawChar(matrixStack, c, x, y, newColor);
x += getStringWidth(Character.toString(c)) * 2.0F;
} catch (ArrayIndexOutOfBoundsException indexException) {
char c = text.charAt(i);
System.err.println("Can't draw character: " + c + " (" + Character.getNumericValue(c) + ")");
}
}
bufferBuilder.end();
BufferRenderer.draw(bufferBuilder);
RenderUtils.shaderColor(0xffffffff);
}
use of net.minecraft.client.render.BufferBuilder in project custom-stars by b3spectacled.
the class MixinWorldRenderer method reloadStars.
@Inject(method = "renderSky(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/math/Matrix4f;FLnet/minecraft/client/render/Camera;ZLjava/lang/Runnable;)V", at = @At("HEAD"))
private void reloadStars(CallbackInfo info) {
if (CustomStars.STARS_RERENDER_OBSERVER.update()) {
CustomStars.log(Level.INFO, "Star settings modified, reloading buffer...");
Tessellator tess = Tessellator.getInstance();
BufferBuilder builder = tess.getBuffer();
RenderSystem.setShader(GameRenderer::getPositionShader);
this.starsBuffer = new VertexBuffer();
((MixinWorldRendererInvoker) this).rerenderStars(builder);
builder.end();
this.starsBuffer.upload(builder);
}
}
use of net.minecraft.client.render.BufferBuilder in project BleachHack by BleachDrinker420.
the class Window method horizontalGradient.
public static void horizontalGradient(MatrixStack matrices, int x1, int y1, int x2, int y2, int color1, int color2) {
float alpha1 = (color1 >> 24 & 255) / 255.0F;
float red1 = (color1 >> 16 & 255) / 255.0F;
float green1 = (color1 >> 8 & 255) / 255.0F;
float blue1 = (color1 & 255) / 255.0F;
float alpha2 = (color2 >> 24 & 255) / 255.0F;
float red2 = (color2 >> 16 & 255) / 255.0F;
float green2 = (color2 >> 8 & 255) / 255.0F;
float blue2 = (color2 & 255) / 255.0F;
RenderSystem.disableTexture();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
bufferBuilder.vertex(x1, y1, 0).color(red1, green1, blue1, alpha1).next();
bufferBuilder.vertex(x1, y2, 0).color(red1, green1, blue1, alpha1).next();
bufferBuilder.vertex(x2, y2, 0).color(red2, green2, blue2, alpha2).next();
bufferBuilder.vertex(x2, y1, 0).color(red2, green2, blue2, alpha2).next();
tessellator.draw();
RenderSystem.disableBlend();
RenderSystem.enableTexture();
}
use of net.minecraft.client.render.BufferBuilder in project BleachHack by BleachDrinker420.
the class Window method verticalGradient.
public static void verticalGradient(MatrixStack matrices, int x1, int y1, int x2, int y2, int color1, int color2) {
float alpha1 = (color1 >> 24 & 255) / 255.0F;
float red1 = (color1 >> 16 & 255) / 255.0F;
float green1 = (color1 >> 8 & 255) / 255.0F;
float blue1 = (color1 & 255) / 255.0F;
float alpha2 = (color2 >> 24 & 255) / 255.0F;
float red2 = (color2 >> 16 & 255) / 255.0F;
float green2 = (color2 >> 8 & 255) / 255.0F;
float blue2 = (color2 & 255) / 255.0F;
RenderSystem.disableTexture();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
bufferBuilder.vertex(x2, y1, 0).color(red1, green1, blue1, alpha1).next();
bufferBuilder.vertex(x1, y1, 0).color(red1, green1, blue1, alpha1).next();
bufferBuilder.vertex(x1, y2, 0).color(red2, green2, blue2, alpha2).next();
bufferBuilder.vertex(x2, y2, 0).color(red2, green2, blue2, alpha2).next();
tessellator.draw();
RenderSystem.disableBlend();
RenderSystem.enableTexture();
}
Aggregations