Search in sources :

Example 6 with MatrixStack

use of net.minecraft.client.util.math.MatrixStack in project BleachHack by BleachDrinker420.

the class Renderer method drawQuadFill.

// -------------------- Quads --------------------
public static void drawQuadFill(double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3, double x4, double y4, double z4, int cullMode, QuadColor color) {
    if (!FrustumUtils.isPointVisible(x1, y1, z1) && !FrustumUtils.isPointVisible(x2, y2, z2) && !FrustumUtils.isPointVisible(x3, y3, z3) && !FrustumUtils.isPointVisible(x4, y4, z4)) {
        return;
    }
    setup();
    MatrixStack matrices = matrixFrom(x1, y1, z1);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    // Fill
    RenderSystem.setShader(GameRenderer::getPositionColorShader);
    buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
    Vertexer.vertexQuad(matrices, buffer, 0f, 0f, 0f, (float) (x2 - x1), (float) (y2 - y1), (float) (z2 - z1), (float) (x3 - x1), (float) (y3 - y1), (float) (z3 - z1), (float) (x4 - x1), (float) (y4 - y1), (float) (z4 - z1), cullMode, color);
    tessellator.draw();
    cleanup();
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) MatrixStack(net.minecraft.client.util.math.MatrixStack) BufferBuilder(net.minecraft.client.render.BufferBuilder) GameRenderer(net.minecraft.client.render.GameRenderer)

Example 7 with MatrixStack

use of net.minecraft.client.util.math.MatrixStack in project BleachHack by BleachDrinker420.

the class Renderer method drawQuadOutline.

public static void drawQuadOutline(double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3, double x4, double y4, double z4, float lineWidth, QuadColor color) {
    if (!FrustumUtils.isPointVisible(x1, y1, z1) && !FrustumUtils.isPointVisible(x2, y2, z2) && !FrustumUtils.isPointVisible(x3, y3, z3) && !FrustumUtils.isPointVisible(x4, y4, z4)) {
        return;
    }
    setup();
    MatrixStack matrices = matrixFrom(x1, y1, z1);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    int[] colors = color.getAllColors();
    // Outline
    RenderSystem.disableCull();
    RenderSystem.setShader(GameRenderer::getRenderTypeLinesShader);
    RenderSystem.lineWidth(lineWidth);
    buffer.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES);
    Vertexer.vertexLine(matrices, buffer, 0f, 0f, 0f, (float) (x2 - x1), (float) (y2 - y1), (float) (z2 - z1), LineColor.gradient(colors[0], colors[1]));
    Vertexer.vertexLine(matrices, buffer, (float) (x2 - x1), (float) (y2 - y1), (float) (z2 - z1), (float) (x3 - x1), (float) (y3 - y1), (float) (z3 - z1), LineColor.gradient(colors[1], colors[2]));
    Vertexer.vertexLine(matrices, buffer, (float) (x3 - x1), (float) (y3 - y1), (float) (z3 - z1), (float) (x4 - x1), (float) (y4 - y1), (float) (z4 - z1), LineColor.gradient(colors[2], colors[3]));
    Vertexer.vertexLine(matrices, buffer, (float) (x4 - x1), (float) (y4 - y1), (float) (z4 - z1), 0f, 0f, 0f, LineColor.gradient(colors[3], colors[0]));
    tessellator.draw();
    RenderSystem.enableCull();
    cleanup();
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) MatrixStack(net.minecraft.client.util.math.MatrixStack) BufferBuilder(net.minecraft.client.render.BufferBuilder) GameRenderer(net.minecraft.client.render.GameRenderer)

Example 8 with MatrixStack

use of net.minecraft.client.util.math.MatrixStack in project BleachHack by BleachDrinker420.

the class WorldRenderer method drawText.

/**
 * Draws text in the world. *
 */
public static void drawText(Text text, double x, double y, double z, double offX, double offY, double scale, boolean fill) {
    MatrixStack matrices = matrixFrom(x, y, z);
    Camera camera = mc.gameRenderer.getCamera();
    matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-camera.getYaw()));
    matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch()));
    RenderSystem.enableBlend();
    RenderSystem.defaultBlendFunc();
    matrices.translate(offX, offY, 0);
    matrices.scale(-0.025f * (float) scale, -0.025f * (float) scale, 1);
    int halfWidth = mc.textRenderer.getWidth(text) / 2;
    VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer());
    if (fill) {
        int opacity = (int) (MinecraftClient.getInstance().options.getTextBackgroundOpacity(0.25F) * 255.0F) << 24;
        mc.textRenderer.draw(text, -halfWidth, 0f, 553648127, false, matrices.peek().getModel(), immediate, true, opacity, 0xf000f0);
        immediate.draw();
    } else {
        matrices.push();
        matrices.translate(1, 1, 0);
        mc.textRenderer.draw(text.copy(), -halfWidth, 0f, 0x202020, false, matrices.peek().getModel(), immediate, true, 0, 0xf000f0);
        immediate.draw();
        matrices.pop();
    }
    mc.textRenderer.draw(text, -halfWidth, 0f, -1, false, matrices.peek().getModel(), immediate, true, 0, 0xf000f0);
    immediate.draw();
    RenderSystem.disableBlend();
}
Also used : MatrixStack(net.minecraft.client.util.math.MatrixStack) Camera(net.minecraft.client.render.Camera) VertexConsumerProvider(net.minecraft.client.render.VertexConsumerProvider)

Example 9 with MatrixStack

use of net.minecraft.client.util.math.MatrixStack in project BleachHack by BleachDrinker420.

the class WorldRenderer method matrixFrom.

public static MatrixStack matrixFrom(double x, double y, double z) {
    MatrixStack matrices = new MatrixStack();
    Camera camera = mc.gameRenderer.getCamera();
    matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch()));
    matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(camera.getYaw() + 180.0F));
    matrices.translate(x - camera.getPos().x, y - camera.getPos().y, z - camera.getPos().z);
    return matrices;
}
Also used : MatrixStack(net.minecraft.client.util.math.MatrixStack) Camera(net.minecraft.client.render.Camera)

Example 10 with MatrixStack

use of net.minecraft.client.util.math.MatrixStack in project BleachHack by BleachDrinker420.

the class WorldRenderer method drawGuiItem.

/**
 * Draws a 2D gui items somewhere in the world. *
 */
public static void drawGuiItem(double x, double y, double z, double offX, double offY, double scale, ItemStack item) {
    if (item.isEmpty()) {
        return;
    }
    MatrixStack matrices = matrixFrom(x, y, z);
    Camera camera = mc.gameRenderer.getCamera();
    matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-camera.getYaw()));
    matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch()));
    matrices.translate(offX, offY, 0);
    matrices.scale((float) scale, (float) scale, 0.001f);
    matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(180f));
    mc.getBufferBuilders().getEntityVertexConsumers().draw();
    RenderSystem.enableBlend();
    RenderSystem.defaultBlendFunc();
    Vec3f[] currentLight = shaderLight.clone();
    DiffuseLighting.disableGuiDepthLighting();
    mc.getItemRenderer().renderItem(item, ModelTransformation.Mode.GUI, 0xF000F0, OverlayTexture.DEFAULT_UV, matrices, mc.getBufferBuilders().getEntityVertexConsumers(), 0);
    mc.getBufferBuilders().getEntityVertexConsumers().draw();
    RenderSystem.setShaderLights(currentLight[0], currentLight[1]);
    RenderSystem.disableBlend();
}
Also used : MatrixStack(net.minecraft.client.util.math.MatrixStack) Camera(net.minecraft.client.render.Camera) Vec3f(net.minecraft.util.math.Vec3f)

Aggregations

MatrixStack (net.minecraft.client.util.math.MatrixStack)83 BufferBuilder (net.minecraft.client.render.BufferBuilder)14 GameRenderer (net.minecraft.client.render.GameRenderer)12 Tessellator (net.minecraft.client.render.Tessellator)12 Camera (net.minecraft.client.render.Camera)11 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)10 MinecraftClient (net.minecraft.client.MinecraftClient)8 BlockPos (net.minecraft.util.math.BlockPos)8 ItemStack (net.minecraft.item.ItemStack)7 Vec3d (net.minecraft.util.math.Vec3d)7 Color (java.awt.Color)6 Random (java.util.Random)6 BlockState (net.minecraft.block.BlockState)6 Identifier (net.minecraft.util.Identifier)6 Matrix4f (net.minecraft.util.math.Matrix4f)6 BlockEntity (net.minecraft.block.entity.BlockEntity)5 LiteralText (net.minecraft.text.LiteralText)5 Box (net.minecraft.util.math.Box)5 Inject (org.spongepowered.asm.mixin.injection.Inject)5 PlayerEntity (net.minecraft.entity.player.PlayerEntity)4