Search in sources :

Example 1 with Camera

use of net.minecraft.client.render.Camera 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 2 with Camera

use of net.minecraft.client.render.Camera 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 3 with Camera

use of net.minecraft.client.render.Camera 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)

Example 4 with Camera

use of net.minecraft.client.render.Camera in project sodium-fabric by CaffeineMC.

the class ChunkGraph method init.

private boolean init(BlockPos blockPos, Camera camera, Vec3d cameraPos, Frustum frustum, int frame, boolean spectator) {
    MinecraftClient client = MinecraftClient.getInstance();
    ObjectArrayFIFOQueue<ChunkGraphNode<T>> queue = this.iterationQueue;
    boolean cull = client.chunkCullingEnabled;
    ChunkGraphNode<T> node = this.getOrCreateNode(blockPos);
    if (node != null) {
        node.reset();
        // Player is within bounds and inside a node
        Set<Direction> openFaces = this.getOpenChunkFaces(blockPos);
        if (openFaces.size() == 1) {
            Vector3f vector3f = camera.getHorizontalPlane();
            Direction direction = Direction.getFacing(vector3f.getX(), vector3f.getY(), vector3f.getZ()).getOpposite();
            openFaces.remove(direction);
        }
        if (openFaces.isEmpty() && !spectator) {
            this.visibleNodes.add(node);
        } else {
            if (spectator && this.world.getBlockState(blockPos).isFullOpaque(this.world, blockPos)) {
                cull = false;
            }
            node.setRebuildFrame(frame);
            queue.enqueue(node);
        }
    } else {
        // Player is out-of-bounds
        int y = blockPos.getY() > 0 ? 248 : 8;
        int x = MathHelper.floor(cameraPos.x / 16.0D) * 16;
        int z = MathHelper.floor(cameraPos.z / 16.0D) * 16;
        List<ChunkGraphNode<T>> list = Lists.newArrayList();
        for (int x2 = -this.renderDistance; x2 <= this.renderDistance; ++x2) {
            for (int z2 = -this.renderDistance; z2 <= this.renderDistance; ++z2) {
                ChunkGraphNode<T> chunk = this.getOrCreateNode(new BlockPos(x + (x2 << 4) + 8, y, z + (z2 << 4) + 8));
                if (chunk == null) {
                    continue;
                }
                if (frustum.isVisible(chunk.getBoundingBox())) {
                    chunk.setRebuildFrame(frame);
                    chunk.reset();
                    list.add(chunk);
                }
            }
        }
        list.sort(Comparator.comparingDouble(o -> blockPos.getSquaredDistance(o.chunk.getOrigin().add(8, 8, 8))));
        for (ChunkGraphNode<T> n : list) {
            queue.enqueue(n);
        }
    }
    return cull;
}
Also used : ChunkOcclusionDataBuilder(net.minecraft.client.render.chunk.ChunkOcclusionDataBuilder) SodiumGameOptions(me.jellysquid.mods.sodium.client.gui.SodiumGameOptions) SodiumClientMod(me.jellysquid.mods.sodium.client.SodiumClientMod) net.minecraft.util.math(net.minecraft.util.math) World(net.minecraft.world.World) ObjectArrayList(it.unimi.dsi.fastutil.objects.ObjectArrayList) Set(java.util.Set) ChunkSection(net.minecraft.world.chunk.ChunkSection) DirectionUtil(me.jellysquid.mods.sodium.common.util.DirectionUtil) WorldChunk(net.minecraft.world.chunk.WorldChunk) List(java.util.List) Lists(com.google.common.collect.Lists) Frustum(net.minecraft.client.render.Frustum) Long2ObjectOpenHashMap(it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap) Vector3f(net.minecraft.client.util.math.Vector3f) ObjectArrayFIFOQueue(it.unimi.dsi.fastutil.objects.ObjectArrayFIFOQueue) MinecraftClient(net.minecraft.client.MinecraftClient) BlockState(net.minecraft.block.BlockState) Comparator(java.util.Comparator) ObjectList(it.unimi.dsi.fastutil.objects.ObjectList) EnumSet(java.util.EnumSet) Camera(net.minecraft.client.render.Camera) MinecraftClient(net.minecraft.client.MinecraftClient) Vector3f(net.minecraft.client.util.math.Vector3f)

Example 5 with Camera

use of net.minecraft.client.render.Camera in project ImmersivePortalsMod by qouteall.

the class MyRenderHelper method setupCameraTransformation.

public static void setupCameraTransformation() {
    MinecraftClient mc = MinecraftClient.getInstance();
    // rendering post processing shader may change view port
    if (OFInterface.isShaders.getAsBoolean()) {
    // Shaders.setViewport(0, 0, mc.window.getFramebufferWidth(), mc.window.getFramebufferHeight());
    } else {
        GlStateManager.viewport(0, 0, mc.window.getFramebufferWidth(), mc.window.getFramebufferHeight());
    }
    ((IEGameRenderer) PortalRenderer.mc.gameRenderer).applyCameraTransformations_(partialTicks);
    Camera camera = PortalRenderer.mc.gameRenderer.getCamera();
    camera.update(PortalRenderer.mc.world, (Entity) (PortalRenderer.mc.getCameraEntity() == null ? PortalRenderer.mc.player : PortalRenderer.mc.getCameraEntity()), PortalRenderer.mc.options.perspective > 0, PortalRenderer.mc.options.perspective == 2, partialTicks);
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) Camera(net.minecraft.client.render.Camera) IEGameRenderer(com.qouteall.immersive_portals.ducks.IEGameRenderer)

Aggregations

Camera (net.minecraft.client.render.Camera)25 MatrixStack (net.minecraft.client.util.math.MatrixStack)11 Vec3d (net.minecraft.util.math.Vec3d)6 MinecraftClient (net.minecraft.client.MinecraftClient)3 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)3 Matrix4f (net.minecraft.util.math.Matrix4f)3 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 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 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)1