use of net.minecraft.client.render.Tessellator 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;
}
}
use of net.minecraft.client.render.Tessellator 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;
}
}
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, 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.Tessellator 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.Tessellator 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);
}
}
Aggregations