Search in sources :

Example 1 with ClientChunkManager

use of net.minecraft.client.world.ClientChunkManager in project EdenClient by HahaOO7.

the class ContainerInfo method tick.

private void tick(ClientPlayerEntity player) {
    ChunkPos center = player.getChunkPos();
    ClientChunkManager cm = player.clientWorld.getChunkManager();
    ChunkPos.stream(center, 2).map(cp -> cm.getWorldChunk(cp.x, cp.z, false)).filter(Objects::nonNull).forEach(this::updateChunk);
}
Also used : ChunkPos(net.minecraft.util.math.ChunkPos) ClientChunkManager(net.minecraft.client.world.ClientChunkManager)

Example 2 with ClientChunkManager

use of net.minecraft.client.world.ClientChunkManager in project EdenClient by HahaOO7.

the class TileEntityEsp method tick.

private void tick(ClientPlayerEntity player) {
    if (!enabled) {
        tileEntities = new ArrayList<>();
        return;
    }
    ChunkPos chunkPos = player.getChunkPos();
    ClientChunkManager cm = player.clientWorld.getChunkManager();
    BlockPos pp = player.getBlockPos();
    tileEntities = ChunkPos.stream(chunkPos, distance).flatMap(cp -> {
        WorldChunk wc = cm.getWorldChunk(cp.x, cp.z, false);
        if (wc == null)
            return null;
        return wc.getBlockEntities().entrySet().stream();
    }).filter(e -> types.contains(e.getValue().getType())).map(Map.Entry::getKey).sorted(Comparator.comparingDouble(pos -> pos.getSquaredDistance(pp))).limit(maxCount).map(v -> (Vec3i) v).toList();
}
Also used : java.util(java.util) PerWorldConfig(at.haha007.edenclient.utils.config.PerWorldConfig) ChatColor(at.haha007.edenclient.utils.ChatColor) ClientChunkManager(net.minecraft.client.world.ClientChunkManager) GameRenderCallback(at.haha007.edenclient.callbacks.GameRenderCallback) JoinWorldCallback(at.haha007.edenclient.callbacks.JoinWorldCallback) VertexBuffer(net.minecraft.client.gl.VertexBuffer) CommandManager(at.haha007.edenclient.command.CommandManager) PlayerUtils.sendModMessage(at.haha007.edenclient.utils.PlayerUtils.sendModMessage) PlayerTickCallback(at.haha007.edenclient.callbacks.PlayerTickCallback) ClientCommandSource(net.minecraft.client.network.ClientCommandSource) BlockEntityTypeSet(at.haha007.edenclient.utils.config.wrappers.BlockEntityTypeSet) RequiredArgumentBuilder(com.mojang.brigadier.builder.RequiredArgumentBuilder) CommandContext(com.mojang.brigadier.context.CommandContext) net.minecraft.client.render(net.minecraft.client.render) net.minecraft.util.math(net.minecraft.util.math) MatrixStack(net.minecraft.client.util.math.MatrixStack) RenderUtils(at.haha007.edenclient.utils.RenderUtils) BlockEntityType(net.minecraft.block.entity.BlockEntityType) Collectors(java.util.stream.Collectors) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) Registry(net.minecraft.util.registry.Registry) WorldChunk(net.minecraft.world.chunk.WorldChunk) ConfigSubscriber(at.haha007.edenclient.utils.config.ConfigSubscriber) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) LeaveWorldCallback(at.haha007.edenclient.callbacks.LeaveWorldCallback) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) IntegerArgumentType(com.mojang.brigadier.arguments.IntegerArgumentType) PlayerUtils(at.haha007.edenclient.utils.PlayerUtils) WorldChunk(net.minecraft.world.chunk.WorldChunk) ClientChunkManager(net.minecraft.client.world.ClientChunkManager)

Example 3 with ClientChunkManager

use of net.minecraft.client.world.ClientChunkManager in project EdenClient by HahaOO7.

the class HeadHunt method tick.

private void tick(ClientPlayerEntity player) {
    if (!enabled) {
        heads = new HashSet<>();
        foundHeads = new HashSet<>();
        return;
    }
    ChunkPos chunkPos = player.getChunkPos();
    ClientChunkManager cm = player.clientWorld.getChunkManager();
    BlockPos pp = player.getBlockPos();
    heads = ChunkPos.stream(chunkPos, 20).flatMap(cp -> {
        WorldChunk wc = cm.getWorldChunk(cp.x, cp.z, false);
        if (wc == null)
            return null;
        return wc.getBlockEntities().entrySet().stream();
    }).filter(e -> e.getValue().getType() == BlockEntityType.SKULL).map(Map.Entry::getKey).sorted(Comparator.comparingDouble(pos -> pos.getSquaredDistance(pp))).limit(1000).map(v -> (Vec3i) v).collect(Collectors.toSet());
    heads.removeAll(foundHeads);
    heads.stream().filter(bp -> player.getPos().squaredDistanceTo(Vec3d.ofCenter(bp)) < 20).forEach(this::clickPos);
    System.out.println("Heads found: " + heads.size());
}
Also used : PerWorldConfig(at.haha007.edenclient.utils.config.PerWorldConfig) ChatColor(at.haha007.edenclient.utils.ChatColor) ClientChunkManager(net.minecraft.client.world.ClientChunkManager) GameRenderCallback(at.haha007.edenclient.callbacks.GameRenderCallback) JoinWorldCallback(at.haha007.edenclient.callbacks.JoinWorldCallback) VertexBuffer(net.minecraft.client.gl.VertexBuffer) HashSet(java.util.HashSet) PlayerInteractBlockC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket) CommandManager(at.haha007.edenclient.command.CommandManager) PlayerUtils.sendModMessage(at.haha007.edenclient.utils.PlayerUtils.sendModMessage) Map(java.util.Map) PlayerTickCallback(at.haha007.edenclient.callbacks.PlayerTickCallback) ClientPlayNetworkHandler(net.minecraft.client.network.ClientPlayNetworkHandler) Hand(net.minecraft.util.Hand) ClientCommandSource(net.minecraft.client.network.ClientCommandSource) RequiredArgumentBuilder(com.mojang.brigadier.builder.RequiredArgumentBuilder) CommandContext(com.mojang.brigadier.context.CommandContext) net.minecraft.client.render(net.minecraft.client.render) net.minecraft.util.math(net.minecraft.util.math) MatrixStack(net.minecraft.client.util.math.MatrixStack) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Set(java.util.Set) RenderUtils(at.haha007.edenclient.utils.RenderUtils) BlockEntityType(net.minecraft.block.entity.BlockEntityType) Collectors(java.util.stream.Collectors) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) WorldChunk(net.minecraft.world.chunk.WorldChunk) ConfigSubscriber(at.haha007.edenclient.utils.config.ConfigSubscriber) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) LeaveWorldCallback(at.haha007.edenclient.callbacks.LeaveWorldCallback) MinecraftClient(net.minecraft.client.MinecraftClient) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) Comparator(java.util.Comparator) IntegerArgumentType(com.mojang.brigadier.arguments.IntegerArgumentType) PlayerUtils(at.haha007.edenclient.utils.PlayerUtils) WorldChunk(net.minecraft.world.chunk.WorldChunk) ClientChunkManager(net.minecraft.client.world.ClientChunkManager) Map(java.util.Map)

Aggregations

ClientChunkManager (net.minecraft.client.world.ClientChunkManager)3 GameRenderCallback (at.haha007.edenclient.callbacks.GameRenderCallback)2 JoinWorldCallback (at.haha007.edenclient.callbacks.JoinWorldCallback)2 LeaveWorldCallback (at.haha007.edenclient.callbacks.LeaveWorldCallback)2 PlayerTickCallback (at.haha007.edenclient.callbacks.PlayerTickCallback)2 CommandManager (at.haha007.edenclient.command.CommandManager)2 ChatColor (at.haha007.edenclient.utils.ChatColor)2 PlayerUtils (at.haha007.edenclient.utils.PlayerUtils)2 PlayerUtils.sendModMessage (at.haha007.edenclient.utils.PlayerUtils.sendModMessage)2 RenderUtils (at.haha007.edenclient.utils.RenderUtils)2 ConfigSubscriber (at.haha007.edenclient.utils.config.ConfigSubscriber)2 PerWorldConfig (at.haha007.edenclient.utils.config.PerWorldConfig)2 RenderSystem (com.mojang.blaze3d.systems.RenderSystem)2 IntegerArgumentType (com.mojang.brigadier.arguments.IntegerArgumentType)2 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)2 RequiredArgumentBuilder (com.mojang.brigadier.builder.RequiredArgumentBuilder)2 CommandContext (com.mojang.brigadier.context.CommandContext)2 Collectors (java.util.stream.Collectors)2 BlockEntityType (net.minecraft.block.entity.BlockEntityType)2 VertexBuffer (net.minecraft.client.gl.VertexBuffer)2