Search in sources :

Example 16 with Matrix4f

use of net.minecraft.util.math.Matrix4f in project Hypnotic-Client by Hypnotic-Development.

the class RenderUtils method getRenderPosition.

public static Vec3d getRenderPosition(Vec3d vec3d, MatrixStack matrixStack) {
    Matrix4f matrix = matrixStack.peek().getPositionMatrix();
    double minX = vec3d.getX() - mc.getEntityRenderDispatcher().camera.getPos().x;
    double minY = vec3d.getY() - mc.getEntityRenderDispatcher().camera.getPos().y;
    double minZ = vec3d.getZ() - mc.getEntityRenderDispatcher().camera.getPos().z;
    Vector4f vector4f = new Vector4f((float) minX, (float) minY, (float) minZ, 1.f);
    vector4f.transform(matrix);
    return new Vec3d(vector4f.getX(), vector4f.getY(), vector4f.getZ());
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) IMatrix4f(dev.hypnotic.utils.mixin.IMatrix4f) Vector4f(net.minecraft.util.math.Vector4f) Vec3d(net.minecraft.util.math.Vec3d)

Example 17 with Matrix4f

use of net.minecraft.util.math.Matrix4f in project Hypnotic-Client by Hypnotic-Development.

the class RenderUtils method renderRoundedQuad.

// Taken from Coffee client (https://github.com/business-goose/Coffee/tree/master)
// My rounded stuff looked retarded
public static void renderRoundedQuad(MatrixStack matrices, Color c, double fromX, double fromY, double toX, double toY, double rad, double samples) {
    int color = c.getRGB();
    Matrix4f matrix = matrices.peek().getPositionMatrix();
    float f = (float) (color >> 24 & 255) / 255.0F;
    float g = (float) (color >> 16 & 255) / 255.0F;
    float h = (float) (color >> 8 & 255) / 255.0F;
    float k = (float) (color & 255) / 255.0F;
    RenderSystem.enableBlend();
    RenderSystem.disableTexture();
    RenderSystem.setShader(GameRenderer::getPositionColorShader);
    renderRoundedQuadInternal(matrix, g, h, k, f, fromX, fromY, toX, toY, rad, samples);
    RenderSystem.enableTexture();
    RenderSystem.disableBlend();
    RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) IMatrix4f(dev.hypnotic.utils.mixin.IMatrix4f) GameRenderer(net.minecraft.client.render.GameRenderer)

Example 18 with Matrix4f

use of net.minecraft.util.math.Matrix4f in project Hypnotic-Client by Hypnotic-Development.

the class RenderUtils method drawOutlineBox.

public static void drawOutlineBox(MatrixStack matrixStack, Box bb, Color color, boolean draw) {
    Color color1 = color;
    Matrix4f matrix4f = matrixStack.peek().getPositionMatrix();
    BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
    if (draw)
        bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINES, /*LINES*/
        VertexFormats.POSITION_COLOR);
    VoxelShape shape = VoxelShapes.cuboid(bb);
    shape.forEachEdge((x1, y1, z1, x2, y2, z2) -> {
        bufferBuilder.vertex(matrix4f, (float) x1, (float) y1, (float) z1).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
        bufferBuilder.vertex(matrix4f, (float) x2, (float) y2, (float) z2).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    });
    if (draw) {
        bufferBuilder.end();
        BufferRenderer.draw(bufferBuilder);
    }
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) IMatrix4f(dev.hypnotic.utils.mixin.IMatrix4f) VoxelShape(net.minecraft.util.shape.VoxelShape) Color(java.awt.Color) BufferBuilder(net.minecraft.client.render.BufferBuilder)

Example 19 with Matrix4f

use of net.minecraft.util.math.Matrix4f in project Hypnotic-Client by Hypnotic-Development.

the class Vertexer method vertexLine.

public static void vertexLine(MatrixStack matrices, VertexConsumer vertexConsumer, float x1, float y1, float z1, float x2, float y2, float z2, LineColor lineColor) {
    Matrix4f model = matrices.peek().getPositionMatrix();
    Matrix3f normal = matrices.peek().getNormalMatrix();
    Vec3f normalVec = getNormal(normal, x1, y1, z1, x2, y2, z2);
    int[] color1 = lineColor.getColor(x1, y1, z1, 0);
    int[] color2 = lineColor.getColor(x2, y2, z2, 1);
    vertexConsumer.vertex(model, x1, y1, z1).color(color1[0], color1[1], color1[2], color1[3]).normal(normal, normalVec.getX(), normalVec.getY(), normalVec.getZ()).next();
    vertexConsumer.vertex(model, x2, y2, z2).color(color2[0], color2[1], color2[2], color2[3]).normal(normal, normalVec.getX(), normalVec.getY(), normalVec.getZ()).next();
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) Matrix3f(net.minecraft.util.math.Matrix3f) Vec3f(net.minecraft.util.math.Vec3f)

Example 20 with Matrix4f

use of net.minecraft.util.math.Matrix4f in project Hypnotic-Client by Hypnotic-Development.

the class NahrFont method drawTexturedModalRect.

private final void drawTexturedModalRect(MatrixStack matrixStack, float x, float y, float u, float v, float width, float height, int color) {
    Matrix4f matrix4f = matrixStack.peek().getPositionMatrix();
    float scale = 0.0039063F;
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferBuilder = tessellator.getBuffer();
    float f = (color >> 24 & 0xFF) / 255.0F;
    float f1 = (color >> 16 & 0xFF) / 255.0F;
    float f2 = (color >> 8 & 0xFF) / 255.0F;
    float f3 = (color & 0xFF) / 255.0F;
    bufferBuilder.vertex(matrix4f, x + 0.0F, y + height, 0.0f).texture((u + 0.0F) * scale, (v + height) * scale).color(f1, f2, f3, f).next();
    bufferBuilder.vertex(matrix4f, x + width, y + height, 0.0f).texture((u + width) * scale, (v + height) * scale).color(f1, f2, f3, f).next();
    bufferBuilder.vertex(matrix4f, x + width, y + 0.0F, 0.0f).texture((u + width) * scale, (v + 0.0F) * scale).color(f1, f2, f3, f).next();
    bufferBuilder.vertex(matrix4f, x + 0.0F, y + 0.0F, 0.0f).texture((u + 0.0F) * scale, (v + 0.0F) * scale).color(f1, f2, f3, f).next();
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) Tessellator(net.minecraft.client.render.Tessellator) BufferBuilder(net.minecraft.client.render.BufferBuilder)

Aggregations

Matrix4f (net.minecraft.util.math.Matrix4f)53 BufferBuilder (net.minecraft.client.render.BufferBuilder)18 IMatrix4f (dev.hypnotic.utils.mixin.IMatrix4f)13 Matrix3f (net.minecraft.util.math.Matrix3f)13 GameRenderer (net.minecraft.client.render.GameRenderer)11 Vec3d (net.minecraft.util.math.Vec3d)8 MatrixStack (net.minecraft.client.util.math.MatrixStack)7 VertexConsumer (net.minecraft.client.render.VertexConsumer)6 Color (java.awt.Color)5 Vec3f (net.minecraft.util.math.Vec3f)5 MinecraftClient (net.minecraft.client.MinecraftClient)3 Camera (net.minecraft.client.render.Camera)3 Tessellator (net.minecraft.client.render.Tessellator)3 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)3 Vector3f (net.minecraft.client.util.math.Vector3f)3 Vector4f (net.minecraft.client.util.math.Vector4f)3 FloatBuffer (java.nio.FloatBuffer)2 ClientPlayerEntity (net.minecraft.client.network.ClientPlayerEntity)2 Entity (net.minecraft.entity.Entity)2 LiteralText (net.minecraft.text.LiteralText)2