use of net.minecraft.client.render.BufferBuilder in project Hypnotic-Client by Hypnotic-Development.
the class RenderUtils method gradientFill.
public static void gradientFill(MatrixStack matrixStack, double x1, double y1, double x2, double y2, int color1, int color2) {
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(g1, h1, k1, f1).next();
bufferBuilder.vertex(matrix, (float) x2, (float) y2, 0.0F).color(g1, h1, k1, f1).next();
bufferBuilder.vertex(matrix, (float) x2, (float) y1, 0.0F).color(g2, h2, k2, f2).next();
bufferBuilder.vertex(matrix, (float) x1, (float) y1, 0.0F).color(g2, h2, k2, f2).next();
bufferBuilder.end();
BufferRenderer.draw(bufferBuilder);
RenderSystem.enableTexture();
RenderSystem.disableBlend();
}
use of net.minecraft.client.render.BufferBuilder in project Hypnotic-Client by Hypnotic-Development.
the class RenderUtils method drawFilledBox.
public static void drawFilledBox(MatrixStack matrixStack, Box bb, Color color, boolean draw) {
Matrix4f matrix4f = matrixStack.peek().getPositionMatrix();
Color color1 = color;
setup3DRender(true);
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
if (draw)
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, /*QUADS*/
VertexFormats.POSITION_COLOR);
float minX = (float) bb.minX;
float minY = (float) bb.minY;
float minZ = (float) bb.minZ;
float maxX = (float) bb.maxX;
float maxY = (float) bb.maxY;
float maxZ = (float) bb.maxZ;
bufferBuilder.vertex(matrix4f, minX, minY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, maxX, minY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, maxX, minY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, minX, minY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, minX, maxY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, minX, maxY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, maxX, maxY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, maxX, maxY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, minX, minY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, minX, maxY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, maxX, maxY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, maxX, minY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, maxX, minY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, maxX, maxY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, maxX, maxY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, maxX, minY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, minX, minY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, maxX, minY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, maxX, maxY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, minX, maxY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, minX, minY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, minX, minY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, minX, maxY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, minX, maxY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
if (draw) {
bufferBuilder.end();
BufferRenderer.draw(bufferBuilder);
}
end3DRender();
}
use of net.minecraft.client.render.BufferBuilder in project Hypnotic-Client by Hypnotic-Development.
the class RenderUtils method drawTexturedQuad.
public static void drawTexturedQuad(Matrix4f matrices, float x0, float x1, float y0, float y1, float z, float u0, float u1, float v0, float v1) {
RenderSystem.setShader(GameRenderer::getPositionTexShader);
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE);
bufferBuilder.vertex(matrices, (float) x0, (float) y1, (float) z).texture(u0, v1).next();
bufferBuilder.vertex(matrices, (float) x1, (float) y1, (float) z).texture(u1, v1).next();
bufferBuilder.vertex(matrices, (float) x1, (float) y0, (float) z).texture(u1, v0).next();
bufferBuilder.vertex(matrices, (float) x0, (float) y0, (float) z).texture(u0, v0).next();
bufferBuilder.end();
BufferRenderer.draw(bufferBuilder);
}
use of net.minecraft.client.render.BufferBuilder 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();
}
}
}
use of net.minecraft.client.render.BufferBuilder 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();
}
Aggregations