Search in sources :

Example 16 with Camera

use of net.minecraft.client.render.Camera in project BlockMeter by ModProg.

the class BlockMeterClient method renderOverlay.

public void renderOverlay(float partialTicks, MatrixStack stack) {
    final MinecraftClient client = MinecraftClient.getInstance();
    final Camera camera = client.gameRenderer.getCamera();
    final Identifier currentDimension = client.player.world.getRegistryKey().getValue();
    final ModConfig cfg = AutoConfig.getConfigHolder(ModConfig.class).getConfig();
    // MEH! but this seems to be needed to get the first background
    // rectangle
    client.textRenderer.draw(stack, "XXX", -100, -100, 0);
    if (this.active || cfg.showBoxesWhenDisabled)
        if (cfg.showOtherUsersBoxes) {
            if (otherUsersBoxes != null && otherUsersBoxes.size() > 0) {
                this.otherUsersBoxes.forEach((playerText, boxList) -> {
                    boxList.forEach(box -> box.render(camera, stack, currentDimension, playerText));
                });
                this.boxes.forEach(box -> {
                    if (!box.isFinished())
                        box.render(camera, stack, currentDimension);
                });
            }
            if (!cfg.sendBoxes)
                this.boxes.forEach(box -> {
                    if (box.isFinished())
                        box.render(camera, stack, currentDimension, client.player.getDisplayName());
                    else
                        box.render(camera, stack, currentDimension);
                });
        } else
            this.boxes.forEach(box -> box.render(camera, stack, currentDimension));
}
Also used : PacketSender(net.fabricmc.fabric.api.networking.v1.PacketSender) Item(net.minecraft.item.Item) OptionsGui(win.baruna.blockmeter.gui.OptionsGui) ConfigManager(me.shedaniel.autoconfig.ConfigManager) TranslatableText(net.minecraft.text.TranslatableText) PacketByteBuf(net.minecraft.network.PacketByteBuf) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Unpooled(io.netty.buffer.Unpooled) ItemStack(net.minecraft.item.ItemStack) Map(java.util.Map) UseBlockCallback(net.fabricmc.fabric.api.event.player.UseBlockCallback) ClientPlayNetworkHandler(net.minecraft.client.network.ClientPlayNetworkHandler) ClientModInitializer(net.fabricmc.api.ClientModInitializer) ClientPlayNetworking(net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking) PlayerEntity(net.minecraft.entity.player.PlayerEntity) KeyBindingHelper(net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper) InputUtil(net.minecraft.client.util.InputUtil) MatrixStack(net.minecraft.client.util.math.MatrixStack) BlockHitResult(net.minecraft.util.hit.BlockHitResult) BlockPos(net.minecraft.util.math.BlockPos) KeyBinding(net.minecraft.client.option.KeyBinding) GLFW(org.lwjgl.glfw.GLFW) Toml4jConfigSerializer(me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer) ActionResult(net.minecraft.util.ActionResult) HitResult(net.minecraft.util.hit.HitResult) List(java.util.List) Screen(net.minecraft.client.gui.screen.Screen) DyeColor(net.minecraft.util.DyeColor) SelectBoxGui(win.baruna.blockmeter.gui.SelectBoxGui) AutoConfig(me.shedaniel.autoconfig.AutoConfig) Identifier(net.minecraft.util.Identifier) ClientTickEvents(net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents) MinecraftClient(net.minecraft.client.MinecraftClient) Text(net.minecraft.text.Text) ClientMeasureBox(win.baruna.blockmeter.measurebox.ClientMeasureBox) Camera(net.minecraft.client.render.Camera) Identifier(net.minecraft.util.Identifier) MinecraftClient(net.minecraft.client.MinecraftClient) Camera(net.minecraft.client.render.Camera)

Example 17 with Camera

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

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 18 with Camera

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

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 19 with Camera

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

the class RenderUtilsLiving 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 = getCurrentLight();
    DiffuseLighting.disableGuiDepthLighting();
    mc.getBufferBuilders().getEntityVertexConsumers().draw();
    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)

Example 20 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)

Aggregations

Camera (net.minecraft.client.render.Camera)30 MatrixStack (net.minecraft.client.util.math.MatrixStack)15 Vec3d (net.minecraft.util.math.Vec3d)6 MinecraftClient (net.minecraft.client.MinecraftClient)4 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)4 IMatrix4f (dev.hypnotic.utils.mixin.IMatrix4f)2 List (java.util.List)2 BufferBuilder (net.minecraft.client.render.BufferBuilder)2 GameRenderer (net.minecraft.client.render.GameRenderer)2 Matrix4f (net.minecraft.util.math.Matrix4f)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 IEGameRenderer (com.qouteall.immersive_portals.ducks.IEGameRenderer)1 EventTarget (dev.hypnotic.event.EventTarget)1 Freecam (dev.hypnotic.module.render.Freecam)1 QuadColor (dev.hypnotic.utils.render.QuadColor)1 Waypoint (dev.hypnotic.waypoint.Waypoint)1 Unpooled (io.netty.buffer.Unpooled)1