Search in sources :

Example 21 with MinecraftClient

use of net.minecraft.client.MinecraftClient 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 22 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project SeedcrackerX by 19MisterX98.

the class TimeMachine method poke.

public void poke(Phase phase) {
    if (this.worldSeeds.size() == 1)
        return;
    this.isRunning = true;
    while (phase != null && !this.shouldTerminate) {
        if (phase != Phase.BIOMES && pokeStructureReduce()) {
            phase = Phase.BIOMES;
            continue;
        } else if (phase == Phase.STRUCTURES) {
            if (!pokeStructures())
                break;
        } else if (phase == Phase.LIFTING) {
            if (!pokeStructures() && !pokeLifting())
                break;
        } else if (phase == Phase.PILLARS) {
            if (!this.pokePillars())
                break;
        } else if (phase == Phase.BIOMES) {
            if (!this.pokeBiomes())
                break;
        }
        phase = phase.nextPhase();
    }
    if (this.worldSeeds.size() == 1 && !this.shouldTerminate) {
        long seed = worldSeeds.stream().findFirst().get();
        SeedCracker.entrypoints.forEach(entrypoint -> entrypoint.pushWorldSeed(seed));
        MinecraftClient client = MinecraftClient.getInstance();
        if (Config.get().databaseSubmits && client.getNetworkHandler().getPlayerList().size() > 10 && !client.getNetworkHandler().getConnection().isLocal()) {
            Text text = Database.joinFakeServerForAuth();
            if (text == null) {
                Database.handleDatabaseCall(seed);
            } else {
                Log.error(text.getString());
            }
        }
    }
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) Text(net.minecraft.text.Text)

Example 23 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project canvas by vram-guild.

the class CanvasGlHelper method logMachineInfo.

private static void logMachineInfo(GLCapabilities caps) {
    final Logger log = CanvasMod.LOG;
    final MinecraftClient client = MinecraftClient.getInstance();
    log.info("==================  CANVAS RENDERER DEBUG INFORMATION ==================");
    log.info(String.format(" Java: %s %dbit", System.getProperty("java.version"), client.is64Bit() ? 64 : 32));
    log.info(String.format(" CPU: %s", GLX._getCpuInfo()));
    log.info(String.format(" GPU: %s  %s", GLX._getCapsString()), GLX._getLWJGLVersion());
    log.info(String.format(" OpenGL: %s", GLX.getOpenGLVersionString()));
    log.info(String.format(" GpuShader4: %s  VboArb: %s  VaoEnabled: %s  VaoArb: %s", useGpuShader4 ? "Y" : "N", useVboArb ? "Y" : "N", vaoEnabled ? "Y" : "N", useVaoArb ? "Y" : "N"));
    log.info(" (This message can be disabled by configuring logMachineInfo = false.)");
    log.info("========================================================================");
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) Logger(org.apache.logging.log4j.Logger)

Example 24 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project canvas by vram-guild.

the class WorldDataManager method updateLight.

public static void updateLight(float tick, float flicker) {
    final MinecraftClient client = MinecraftClient.getInstance();
    final ClientWorld world = client.world;
    if (world != null) {
        final boolean hasSkyLight = world.dimension.hasSkyLight();
        final boolean nightVision = client.player.hasStatusEffect(StatusEffects.NIGHT_VISION);
        UNIFORM_DATA[DIMENSION_ID] = world.dimension.getType().getRawId();
        UNIFORM_DATA[HAS_SKYLIGHT] = hasSkyLight ? 1 : 0;
        UNIFORM_DATA[AMBIENT_INTENSITY] = world.method_23783(1.0F);
        UNIFORM_DATA[EFFECTIVE_INTENSITY] = hasSkyLight && !nightVision ? UNIFORM_DATA[AMBIENT_INTENSITY] : 1;
        UNIFORM_DATA[MOON_SIZE] = world.getMoonSize();
        UNIFORM_DATA[NIGHT_VISION_ACTIVE] = nightVision ? 1 : 0;
        final float fluidModifier = client.player.method_3140();
        if (nightVision) {
            UNIFORM_DATA[WORLD_EFFECT_MODIFIER] = GameRenderer.getNightVisionStrength(client.player, tick);
        } else if (fluidModifier > 0.0F && client.player.hasStatusEffect(StatusEffects.CONDUIT_POWER)) {
            UNIFORM_DATA[WORLD_EFFECT_MODIFIER] = fluidModifier;
        } else {
            UNIFORM_DATA[WORLD_EFFECT_MODIFIER] = 0.0F;
        }
    }
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) ClientWorld(net.minecraft.client.world.ClientWorld)

Example 25 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project meteor-client by MeteorDevelopment.

the class PlayerListHudMixin method renderLatencyIcon.

@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/PlayerListHud;renderLatencyIcon(Lnet/minecraft/client/util/math/MatrixStack;IIILnet/minecraft/client/network/PlayerListEntry;)V"))
protected void renderLatencyIcon(PlayerListHud self, MatrixStack matrices, int width, int x, int y, PlayerListEntry entry) {
    BetterTab betterTab = Modules.get().get(BetterTab.class);
    if (betterTab.isActive() && betterTab.accurateLatency.get()) {
        MinecraftClient mc = MinecraftClient.getInstance();
        TextRenderer textRenderer = mc.textRenderer;
        int latency = Utils.clamp(entry.getLatency(), 0, 9999);
        int color = latency < 150 ? 0x00E970 : latency < 300 ? 0xE7D020 : 0xD74238;
        String text = latency + "ms";
        textRenderer.drawWithShadow(matrices, text, (float) x + width - textRenderer.getWidth(text), (float) y, color);
    } else {
        renderLatencyIcon(matrices, width, x, y, entry);
    }
}
Also used : BetterTab(meteordevelopment.meteorclient.systems.modules.misc.BetterTab) MinecraftClient(net.minecraft.client.MinecraftClient) TextRenderer(net.minecraft.client.font.TextRenderer) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Aggregations

MinecraftClient (net.minecraft.client.MinecraftClient)84 ItemStack (net.minecraft.item.ItemStack)12 Text (net.minecraft.text.Text)7 Identifier (net.minecraft.util.Identifier)7 Inject (org.spongepowered.asm.mixin.injection.Inject)7 BlockPos (net.minecraft.util.math.BlockPos)6 BlockEntity (net.minecraft.block.entity.BlockEntity)5 TextRenderer (net.minecraft.client.font.TextRenderer)5 ClientPlayNetworkHandler (net.minecraft.client.network.ClientPlayNetworkHandler)5 BlockHitResult (net.minecraft.util.hit.BlockHitResult)5 List (java.util.List)4 BlockState (net.minecraft.block.BlockState)4 MatrixStack (net.minecraft.client.util.math.MatrixStack)4 Entity (net.minecraft.entity.Entity)4 PlayerEntity (net.minecraft.entity.player.PlayerEntity)4 NbtCompound (net.minecraft.nbt.NbtCompound)4 AreaIsometricRenderScreen (com.glisco.isometricrenders.client.gui.AreaIsometricRenderScreen)3 IsometricRenderScreen (com.glisco.isometricrenders.client.gui.IsometricRenderScreen)3 GameRenderer (net.minecraft.client.render.GameRenderer)3 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)3