Search in sources :

Example 21 with Camera

use of net.minecraft.client.render.Camera in project Skyblocker by LifeIsAParadox.

the class RenderUtilsLiving 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 22 with Camera

use of net.minecraft.client.render.Camera in project Skyblocker by SkyblockerMod.

the class RenderUtils method matrixFrom.

// -------------------- Utils --------------------
public static MatrixStack matrixFrom(double x, double y, double z) {
    MatrixStack matrices = new MatrixStack();
    Camera camera = MinecraftClient.getInstance().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 23 with Camera

use of net.minecraft.client.render.Camera in project Skyblocker by SkyblockerMod.

the class RenderUtilsLiving 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().getPositionMatrix(), 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().getPositionMatrix(), immediate, true, 0, 0xf000f0);
        immediate.draw();
        matrices.pop();
    }
    mc.textRenderer.draw(text, -halfWidth, 0f, -1, false, matrices.peek().getPositionMatrix(), 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 24 with Camera

use of net.minecraft.client.render.Camera in project BleachHack by BleachDrinker420.

the class Renderer method matrixFrom.

// -------------------- Utils --------------------
public static MatrixStack matrixFrom(double x, double y, double z) {
    MatrixStack matrices = new MatrixStack();
    Camera camera = MinecraftClient.getInstance().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 25 with Camera

use of net.minecraft.client.render.Camera in project Client by MatHax.

the class ModelPredicateProviderRegistryMixin method onGetAngleToPos.

@Inject(method = "getAngleToPos(Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/entity/Entity;)D", at = @At("HEAD"), cancellable = true)
private void onGetAngleToPos(Vec3d pos, Entity entity, CallbackInfoReturnable<Double> info) {
    if (Modules.get().isActive(Freecam.class)) {
        Camera camera = mc.gameRenderer.getCamera();
        info.setReturnValue(Math.atan2(pos.getZ() - camera.getPos().z, pos.getX() - camera.getPos().x));
    }
}
Also used : Camera(net.minecraft.client.render.Camera) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

Camera (net.minecraft.client.render.Camera)31 MatrixStack (net.minecraft.client.util.math.MatrixStack)16 Vec3d (net.minecraft.util.math.Vec3d)8 Matrix4f (net.minecraft.util.math.Matrix4f)5 List (java.util.List)4 MinecraftClient (net.minecraft.client.MinecraftClient)4 BufferBuilder (net.minecraft.client.render.BufferBuilder)4 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)4 BlockPos (net.minecraft.util.math.BlockPos)4 GameRenderer (net.minecraft.client.render.GameRenderer)3 IMatrix4f (dev.hypnotic.utils.mixin.IMatrix4f)2 Color (java.awt.Color)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Vec3f (net.minecraft.util.math.Vec3f)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 CameraInvoker (com.glisco.isometricrenders.mixin.CameraInvoker)1 Lists (com.google.common.collect.Lists)1 RenderSystem (com.mojang.blaze3d.systems.RenderSystem)1