Search in sources :

Example 26 with Matrix4f

use of net.minecraft.util.math.Matrix4f in project Neutrino by FrostWizard4.

the class NeutrinoModelLoader method renderElectricityOverlay.

public static void renderElectricityOverlay(MinecraftClient client, MatrixStack matrices) {
    BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
    RenderSystem.setShader(GameRenderer::getPositionColorTexShader);
    RenderSystem.depthFunc(519);
    RenderSystem.depthMask(false);
    RenderSystem.enableBlend();
    RenderSystem.defaultBlendFunc();
    RenderSystem.enableTexture();
    Sprite sprite = ELECTRICITY.getSprite();
    RenderSystem.setShaderTexture(0, sprite.getAtlas().getId());
    float f = sprite.getMinU();
    float g = sprite.getMaxU();
    float h = (f + g) / 2.0f;
    float i = sprite.getMinV();
    float j = sprite.getMaxV();
    float k = (i + j) / 2.0f;
    float l = sprite.getAnimationFrameDelta();
    float m = MathHelper.lerp(l, f, h);
    float n = MathHelper.lerp(l, g, h);
    float o = MathHelper.lerp(l, i, k);
    float p = MathHelper.lerp(l, j, k);
    float q = 1.0f;
    for (int r = 0; r < 2; ++r) {
        matrices.push();
        float s = -0.5f;
        float t = 0.5f;
        float u = -0.5f;
        float v = 0.5f;
        float w = -0.5f;
        matrices.translate((float) (-(r * 2 - 1)) * 0.24f, -0.3f, 0.0);
        matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion((float) (r * 2 - 1) * 10.0f));
        Matrix4f matrix4f = matrices.peek().getPositionMatrix();
        bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE);
        bufferBuilder.vertex(matrix4f, -0.4f, -0.4f, -0.4f).color(1.0f, 1.0f, 1.0f, 0.7f).texture(n, p).next();
        bufferBuilder.vertex(matrix4f, 0.4f, -0.4f, -0.4f).color(1.0f, 1.0f, 1.0f, 0.7f).texture(m, p).next();
        bufferBuilder.vertex(matrix4f, 0.4f, 0.4f, -0.4f).color(1.0f, 1.0f, 1.0f, 0.7f).texture(m, o).next();
        bufferBuilder.vertex(matrix4f, -0.4f, 0.4f, -0.4f).color(1.0f, 1.0f, 1.0f, 0.7f).texture(n, o).next();
        bufferBuilder.end();
        BufferRenderer.draw(bufferBuilder);
        matrices.pop();
    }
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) Sprite(net.minecraft.client.texture.Sprite)

Example 27 with Matrix4f

use of net.minecraft.util.math.Matrix4f in project JexClient by DustinRepo.

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)

Example 28 with Matrix4f

use of net.minecraft.util.math.Matrix4f in project JexClient by DustinRepo.

the class Matrix4x4 method toMinecraft.

public Matrix4f toMinecraft() {
    Matrix4f matrix4f = new Matrix4f();
    try (MemoryStack memoryStack = MemoryStack.stackPush()) {
        FloatBuffer floatBuffer = memoryStack.mallocFloat(16);
        floatBuffer.put(0, this.a00);
        floatBuffer.put(1, this.a01);
        floatBuffer.put(2, this.a02);
        floatBuffer.put(3, this.a03);
        floatBuffer.put(4, this.a10);
        floatBuffer.put(5, this.a11);
        floatBuffer.put(6, this.a12);
        floatBuffer.put(7, this.a13);
        floatBuffer.put(8, this.a20);
        floatBuffer.put(9, this.a21);
        floatBuffer.put(10, this.a22);
        floatBuffer.put(11, this.a23);
        floatBuffer.put(12, this.a30);
        floatBuffer.put(13, this.a31);
        floatBuffer.put(14, this.a32);
        floatBuffer.put(15, this.a33);
        matrix4f.read(floatBuffer, false);
        return matrix4f;
    }
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) MemoryStack(org.lwjgl.system.MemoryStack) FloatBuffer(java.nio.FloatBuffer)

Example 29 with Matrix4f

use of net.minecraft.util.math.Matrix4f in project wildmod by Osmiooo.

the class FireflyEntityRenderer method render.

@Override
public void render(FireflyEntity entity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
    matrixStack.push();
    // you may need to adjust this
    matrixStack.scale(1, 1, 1);
    matrixStack.translate(0, 0.3, 0);
    matrixStack.multiply(this.dispatcher.getRotation());
    matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(180.0F));
    MatrixStack.Entry entry = matrixStack.peek();
    Matrix4f matrix4f = entry.getPositionMatrix();
    Matrix3f matrix3f = entry.getNormalMatrix();
    VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(LAYER);
    int j = getLight(i);
    vertex(vertexConsumer, matrix4f, matrix3f, j, 0.0F, 0, 0, 1);
    vertex(vertexConsumer, matrix4f, matrix3f, j, 1.0F, 0, 1, 1);
    vertex(vertexConsumer, matrix4f, matrix3f, j, 1.0F, 1, 1, 0);
    vertex(vertexConsumer, matrix4f, matrix3f, j, 0.0F, 1, 0, 0);
    matrixStack.pop();
    super.render(entity, f, g, matrixStack, vertexConsumerProvider, i);
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) Matrix3f(net.minecraft.util.math.Matrix3f) MatrixStack(net.minecraft.client.util.math.MatrixStack) VertexConsumer(net.minecraft.client.render.VertexConsumer)

Example 30 with Matrix4f

use of net.minecraft.util.math.Matrix4f in project MiniMap by pl3xgaming.

the class Drawable method draw.

public static void draw(MatrixStack matrixStack, Identifier texture, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1) {
    RenderSystem.setShader(GameRenderer::getPositionTexShader);
    RenderSystem.setShaderTexture(0, texture);
    Matrix4f model = matrixStack.peek().getPositionMatrix();
    BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
    bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE);
    bufferBuilder.vertex(model, x0, y0, 0F).texture(u0, v0).next();
    bufferBuilder.vertex(model, x0, y1, 0F).texture(u0, v1).next();
    bufferBuilder.vertex(model, x1, y1, 0F).texture(u1, v1).next();
    bufferBuilder.vertex(model, x1, y0, 0F).texture(u1, v0).next();
    bufferBuilder.end();
    BufferRenderer.draw(bufferBuilder);
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) BufferBuilder(net.minecraft.client.render.BufferBuilder) GameRenderer(net.minecraft.client.render.GameRenderer)

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