Search in sources :

Example 11 with Matrix4f

use of net.minecraft.util.math.Matrix4f in project Blockify by clownless.

the class RenderUtil method drawTexture.

public static void drawTexture(MatrixStack matrixStack, URLImage image, float x, float y, float scale) {
    Identifier texture = image.getIdentifier();
    int width = image.getWidth();
    int height = image.getHeight();
    TextureManager tex = MinecraftClient.getInstance().getTextureManager();
    tex.bindTexture(texture);
    RenderSystem.enableTexture();
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferBuilder = tessellator.getBuffer();
    RenderSystem.setShader(GameRenderer::getPositionTexShader);
    RenderSystem.setShaderTexture(0, texture);
    RenderSystem.enableBlend();
    RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA);
    RenderSystem.enableDepthTest();
    bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE);
    Matrix4f matrices = matrixStack.peek().getPositionMatrix();
    bufferBuilder.vertex(matrices, x, y + (height * scale), 0).texture(0, 1).next();
    bufferBuilder.vertex(matrices, x + (width * scale), y + (height * scale), 0).texture(1, 1).next();
    bufferBuilder.vertex(matrices, x + (width * scale), y, 0).texture(1, 0).next();
    bufferBuilder.vertex(matrices, x, y, 0).texture(0, 0).next();
    tessellator.draw();
    RenderSystem.disableBlend();
}
Also used : TextureManager(net.minecraft.client.texture.TextureManager) Matrix4f(net.minecraft.util.math.Matrix4f) Identifier(net.minecraft.util.Identifier)

Example 12 with Matrix4f

use of net.minecraft.util.math.Matrix4f in project EdenClient by HahaOO7.

the class TracerRenderer method render.

private void render(MatrixStack matrixStack, VertexConsumerProvider.Immediate vertexConsumerProvider, float delta) {
    RenderSystem.setShader(GameRenderer::getPositionShader);
    RenderSystem.disableDepthTest();
    Matrix4f matrix = matrixStack.peek().getPositionMatrix();
    Vec3d start = RenderUtils.getCameraPos().add(PlayerUtils.getClientLookVec());
    BufferBuilder bb = Tessellator.getInstance().getBuffer();
    bb.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION);
    tracers.values().forEach(s -> s.forEach(target -> {
        bb.vertex(matrix, (float) target.x, (float) target.y, (float) target.z).next();
        bb.vertex(matrix, (float) start.x, (float) start.y, (float) start.z).next();
    }));
    bb.end();
    RenderSystem.setShaderColor(1, 1, 1, 1);
    BufferRenderer.draw(bb);
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) net.minecraft.client.render(net.minecraft.client.render) MatrixStack(net.minecraft.client.util.math.MatrixStack) Set(java.util.Set) GameRenderCallback(at.haha007.edenclient.callbacks.GameRenderCallback) RenderUtils(at.haha007.edenclient.utils.RenderUtils) HashSet(java.util.HashSet) Vec3d(net.minecraft.util.math.Vec3d) TreeMap(java.util.TreeMap) PlayerTickCallback(at.haha007.edenclient.callbacks.PlayerTickCallback) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) LeaveWorldCallback(at.haha007.edenclient.callbacks.LeaveWorldCallback) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) PlayerUtils(at.haha007.edenclient.utils.PlayerUtils) Matrix4f(net.minecraft.util.math.Matrix4f) Vec3d(net.minecraft.util.math.Vec3d)

Example 13 with Matrix4f

use of net.minecraft.util.math.Matrix4f in project meteor-client by MeteorDevelopment.

the class WorldRendererMixin method onRenderEndSkyDraw.

/**
 * @author Walaryne
 */
@Inject(method = "renderEndSky", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Tessellator;draw()V"))
private void onRenderEndSkyDraw(MatrixStack matrices, CallbackInfo info) {
    Ambience ambience = Modules.get().get(Ambience.class);
    if (ambience.isActive() && ambience.endSky.get() && ambience.customSkyColor.get()) {
        Color customEndSkyColor = ambience.skyColor();
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder bufferBuilder = tessellator.getBuffer();
        Matrix4f matrix4f = matrices.peek().getPositionMatrix();
        bufferBuilder.clear();
        bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, -100.0F).texture(0.0F, 0.0F).color(customEndSkyColor.r, customEndSkyColor.g, customEndSkyColor.b, 255).next();
        bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, 100.0F).texture(0.0F, 16.0F).color(customEndSkyColor.r, customEndSkyColor.g, customEndSkyColor.b, 255).next();
        bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, 100.0F).texture(16.0F, 16.0F).color(customEndSkyColor.r, customEndSkyColor.g, customEndSkyColor.b, 255).next();
        bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, -100.0F).texture(16.0F, 0.0F).color(customEndSkyColor.r, customEndSkyColor.g, customEndSkyColor.b, 255).next();
    }
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) Color(meteordevelopment.meteorclient.utils.render.color.Color) Ambience(meteordevelopment.meteorclient.systems.modules.world.Ambience)

Example 14 with Matrix4f

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

the class RenderUtils method drawFilledBox.

public static void drawFilledBox(MatrixStack matrixStack, Box bb, int color, boolean draw) {
    Matrix4f matrix4f = matrixStack.peek().getPositionMatrix();
    Color color1 = ColorUtils.getColor(color);
    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);
    }
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) IMatrix4f(dev.hypnotic.utils.mixin.IMatrix4f) Color(java.awt.Color) BufferBuilder(net.minecraft.client.render.BufferBuilder)

Example 15 with Matrix4f

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

the class RenderUtils method fill.

public static void fill(MatrixStack matrixStack, double x1, double y1, double x2, double y2, int color) {
    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 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;
    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(g, h, k, f).next();
    bufferBuilder.vertex(matrix, (float) x2, (float) y2, 0.0F).color(g, h, k, f).next();
    bufferBuilder.vertex(matrix, (float) x2, (float) y1, 0.0F).color(g, h, k, f).next();
    bufferBuilder.vertex(matrix, (float) x1, (float) y1, 0.0F).color(g, h, k, f).next();
    bufferBuilder.end();
    BufferRenderer.draw(bufferBuilder);
    RenderSystem.enableTexture();
    RenderSystem.disableBlend();
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) IMatrix4f(dev.hypnotic.utils.mixin.IMatrix4f) 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