Search in sources :

Example 6 with WorldChunk

use of net.minecraft.world.chunk.WorldChunk in project CustomHUD by Minenash.

the class ComplexData method update.

@SuppressWarnings("ConstantConditions")
public static void update(Profile profile) {
    if (profile.enabled.serverWorld) {
        IntegratedServer integratedServer = client.getServer();
        serverWorld = integratedServer != null ? integratedServer.getWorld(client.world.getRegistryKey()) : null;
    }
    if (profile.enabled.clientChunk) {
        ChunkPos newPos = new ChunkPos(client.getCameraEntity().getBlockPos());
        if (!Objects.equals(ComplexData.pos, newPos)) {
            pos = newPos;
            chunkFuture = null;
            clientChunk = null;
        }
        if (clientChunk == null)
            clientChunk = client.world.getChunk(pos.x, pos.z);
    }
    if (profile.enabled.serverChunk) {
        if (chunkFuture == null) {
            if (serverWorld != null)
                chunkFuture = serverWorld.getChunkManager().getChunkFutureSyncOnMainThread(pos.x, pos.z, ChunkStatus.FULL, false).thenApply((either) -> either.map((chunk) -> (WorldChunk) chunk, (unloaded) -> null));
            if (chunkFuture == null)
                chunkFuture = CompletableFuture.completedFuture(clientChunk);
        }
        serverChunk = chunkFuture.getNow(null);
    }
    if (profile.enabled.targetBlock) {
        HitResult hit = client.cameraEntity.raycast(profile.targetDistance, 0.0F, false);
        targetBlockPos = hit.getType() == HitResult.Type.BLOCK ? ((BlockHitResult) hit).getBlockPos() : null;
    }
    if (profile.enabled.world)
        world = DataFixUtils.orElse(Optional.ofNullable(client.getServer()).flatMap((integratedServer) -> Optional.ofNullable(integratedServer.getWorld(client.world.getRegistryKey()))), client.world);
    if (profile.enabled.localDifficulty)
        localDifficulty = new LocalDifficulty(world.getDifficulty(), world.getTimeOfDay(), serverChunk == null ? 0 : serverChunk.getInhabitedTime(), world.getMoonSize());
    if (profile.enabled.sound)
        sounds = client.getSoundManager().getDebugString().substring(8).replace(" + ", "/").split("/");
    if (profile.enabled.clientChunkCache)
        clientChunkCache = client.worldRenderer.getChunksDebugString().substring(20).split(", ");
    if (profile.enabled.time) {
        timeOfDay = (int) ((client.world.getTimeOfDay() + 6000) % 24000);
    }
    if (profile.enabled.velocity) {
        if (velocityWaitCounter > 0) {
            velocityWaitCounter--;
            return;
        }
        velocityWaitCounter = 4;
        ClientPlayerEntity p = client.player;
        final double changeXZ = Math.sqrt(Math.pow(Math.abs(p.getX() - x1), 2) + Math.pow(Math.abs(p.getZ() - z1), 2));
        final double changeY = Math.abs(p.getY() - y1);
        final double changeXYZ = Math.sqrt(changeXZ * changeXZ + changeY * changeY);
        x1 = p.getX();
        y1 = p.getY();
        z1 = p.getZ();
        velocityXZ = ((int) (changeXZ * 40)) / 10.0;
        velocityY = ((int) (changeY * 40)) / 10.0;
        velocityXYZ = ((int) (changeXYZ * 40)) / 10.0;
    }
}
Also used : World(net.minecraft.world.World) ServerWorld(net.minecraft.server.world.ServerWorld) BlockHitResult(net.minecraft.util.hit.BlockHitResult) ChunkPos(net.minecraft.util.math.ChunkPos) BlockPos(net.minecraft.util.math.BlockPos) CompletableFuture(java.util.concurrent.CompletableFuture) DataFixUtils(com.mojang.datafixers.DataFixUtils) WorldChunk(net.minecraft.world.chunk.WorldChunk) HitResult(net.minecraft.util.hit.HitResult) Objects(java.util.Objects) IntegratedServer(net.minecraft.server.integrated.IntegratedServer) ChunkStatus(net.minecraft.world.chunk.ChunkStatus) Optional(java.util.Optional) MinecraftClient(net.minecraft.client.MinecraftClient) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) LocalDifficulty(net.minecraft.world.LocalDifficulty) BlockHitResult(net.minecraft.util.hit.BlockHitResult) HitResult(net.minecraft.util.hit.HitResult) IntegratedServer(net.minecraft.server.integrated.IntegratedServer) LocalDifficulty(net.minecraft.world.LocalDifficulty) WorldChunk(net.minecraft.world.chunk.WorldChunk) ChunkPos(net.minecraft.util.math.ChunkPos) BlockHitResult(net.minecraft.util.hit.BlockHitResult) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity)

Example 7 with WorldChunk

use of net.minecraft.world.chunk.WorldChunk in project BleachHack by BleachDrinker420.

the class WorldUtils method getLoadedChunks.

public static List<WorldChunk> getLoadedChunks() {
    List<WorldChunk> chunks = new ArrayList<>();
    int viewDist = mc.options.viewDistance;
    for (int x = -viewDist; x <= viewDist; x++) {
        for (int z = -viewDist; z <= viewDist; z++) {
            WorldChunk chunk = mc.world.getChunkManager().getWorldChunk((int) mc.player.getX() / 16 + x, (int) mc.player.getZ() / 16 + z);
            if (chunk != null) {
                chunks.add(chunk);
            }
        }
    }
    return chunks;
}
Also used : WorldChunk(net.minecraft.world.chunk.WorldChunk) ArrayList(java.util.ArrayList)

Example 8 with WorldChunk

use of net.minecraft.world.chunk.WorldChunk in project EdenClient by HahaOO7.

the class ChestShopMod method checkForShops.

private void checkForShops(ChunkManager cm, ChunkPos chunk) {
    if (!cm.isChunkLoaded(chunk.x, chunk.z))
        return;
    WorldChunk c = cm.getWorldChunk(chunk.x, chunk.z, false);
    if (c == null)
        return;
    shops.remove(chunk);
    ChestShopSet cs = new ChestShopSet();
    c.getBlockEntities().values().stream().filter(t -> t instanceof SignBlockEntity).map(t -> (SignBlockEntity) t).map(ChestShopEntry::new).filter(ChestShopEntry::isShop).forEach(cs::add);
    shops.put(chunk, cs);
}
Also used : WaitForTicksTask(at.haha007.edenclient.utils.tasks.WaitForTicksTask) java.util(java.util) PerWorldConfig(at.haha007.edenclient.utils.config.PerWorldConfig) ChatColor(at.haha007.edenclient.utils.ChatColor) SimpleDateFormat(java.text.SimpleDateFormat) ChunkManager(net.minecraft.world.chunk.ChunkManager) CompletableFuture(java.util.concurrent.CompletableFuture) StringArgumentType(com.mojang.brigadier.arguments.StringArgumentType) Vec3i(net.minecraft.util.math.Vec3i) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CommandManager(at.haha007.edenclient.command.CommandManager) PlayerUtils.sendModMessage(at.haha007.edenclient.utils.PlayerUtils.sendModMessage) SignBlockEntity(net.minecraft.block.entity.SignBlockEntity) PlayerTickCallback(at.haha007.edenclient.callbacks.PlayerTickCallback) ChestShopItemNames(at.haha007.edenclient.mods.datafetcher.ChestShopItemNames) DataFetcher(at.haha007.edenclient.mods.datafetcher.DataFetcher) SuggestionsBuilder(com.mojang.brigadier.suggestion.SuggestionsBuilder) ClientCommandSource(net.minecraft.client.network.ClientCommandSource) Suggestions(com.mojang.brigadier.suggestion.Suggestions) CommandContext(com.mojang.brigadier.context.CommandContext) BufferedWriter(java.io.BufferedWriter) FileWriter(java.io.FileWriter) GetTo(at.haha007.edenclient.mods.GetTo) ChunkPos(net.minecraft.util.math.ChunkPos) IOException(java.io.IOException) net.minecraft.text(net.minecraft.text) Collectors(java.util.stream.Collectors) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) File(java.io.File) WorldChunk(net.minecraft.world.chunk.WorldChunk) RunnableTask(at.haha007.edenclient.utils.tasks.RunnableTask) EdenClient(at.haha007.edenclient.EdenClient) TaskManager(at.haha007.edenclient.utils.tasks.TaskManager) Formatting(net.minecraft.util.Formatting) ConfigSubscriber(at.haha007.edenclient.utils.config.ConfigSubscriber) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) PlayerUtils(at.haha007.edenclient.utils.PlayerUtils) SignBlockEntity(net.minecraft.block.entity.SignBlockEntity) WorldChunk(net.minecraft.world.chunk.WorldChunk)

Example 9 with WorldChunk

use of net.minecraft.world.chunk.WorldChunk 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 10 with WorldChunk

use of net.minecraft.world.chunk.WorldChunk in project meteor-client by MeteorDevelopment.

the class ClientPlayNetworkHandlerMixin method onChunkData.

@Inject(method = "onChunkData", at = @At("TAIL"))
private void onChunkData(ChunkDataS2CPacket packet, CallbackInfo info) {
    WorldChunk chunk = client.world.getChunk(packet.getX(), packet.getZ());
    MeteorClient.EVENT_BUS.post(ChunkDataEvent.get(chunk));
}
Also used : WorldChunk(net.minecraft.world.chunk.WorldChunk) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

WorldChunk (net.minecraft.world.chunk.WorldChunk)34 BlockPos (net.minecraft.util.math.BlockPos)15 BlockState (net.minecraft.block.BlockState)9 ChunkPos (net.minecraft.util.math.ChunkPos)8 Inject (org.spongepowered.asm.mixin.injection.Inject)8 ClientPlayerEntity (net.minecraft.client.network.ClientPlayerEntity)6 PlayerUtils (at.haha007.edenclient.utils.PlayerUtils)4 ConfigSubscriber (at.haha007.edenclient.utils.config.ConfigSubscriber)4 PerWorldConfig (at.haha007.edenclient.utils.config.PerWorldConfig)4 Collectors (java.util.stream.Collectors)4 PlayerTickCallback (at.haha007.edenclient.callbacks.PlayerTickCallback)3 CommandManager (at.haha007.edenclient.command.CommandManager)3 ChatColor (at.haha007.edenclient.utils.ChatColor)3 PlayerUtils.sendModMessage (at.haha007.edenclient.utils.PlayerUtils.sendModMessage)3 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)3 CommandContext (com.mojang.brigadier.context.CommandContext)3 Biome (com.seedfinding.mcbiome.biome.Biome)3 BiomeSource (com.seedfinding.mcbiome.source.BiomeSource)3 BlockEntity (net.minecraft.block.entity.BlockEntity)3 Direction (net.minecraft.util.math.Direction)3