Search in sources :

Example 1 with ChunkManager

use of net.minecraft.world.chunk.ChunkManager in project roadrunner by MaxNeedsSnacks.

the class WorldHelper method getEntitiesOfClassGroup.

/**
 * Method that allows getting entities of a class group.
 * [VanillaCopy] but custom combination of: get class filtered entities together with excluding one entity
 */
public static List<Entity> getEntitiesOfClassGroup(World world, Entity excluded, EntityClassGroup type, Box box, Predicate<Entity> predicate) {
    world.getProfiler().visit("getEntities");
    int minChunkX = MathHelper.floor((box.minX - 2.0D) / 16.0D);
    int maxChunkX = MathHelper.ceil((box.maxX + 2.0D) / 16.0D);
    int minChunkZ = MathHelper.floor((box.minZ - 2.0D) / 16.0D);
    int maxChunkZ = MathHelper.ceil((box.maxZ + 2.0D) / 16.0D);
    List<Entity> entities = Lists.newArrayList();
    ChunkManager chunkManager = world.getChunkManager();
    for (int chunkX = minChunkX; chunkX < maxChunkX; chunkX++) {
        for (int chunkZ = minChunkZ; chunkZ < maxChunkZ; chunkZ++) {
            WorldChunk chunk = chunkManager.getWorldChunk(chunkX, chunkZ, false);
            if (chunk != null) {
                WorldHelper.getEntitiesOfClassGroup(chunk, excluded, type, box, entities, predicate);
            }
        }
    }
    return entities;
}
Also used : Entity(net.minecraft.entity.Entity) WorldChunk(net.minecraft.world.chunk.WorldChunk) ChunkManager(net.minecraft.world.chunk.ChunkManager)

Example 2 with ChunkManager

use of net.minecraft.world.chunk.ChunkManager in project dynmap by webbukkit.

the class FabricMapChunkCache method setChunks.

public void setChunks(FabricWorld dw, List<DynmapChunk> chunks) {
    this.w = dw.getWorld();
    if (dw.isLoaded()) {
        /* Check if world's provider is ServerChunkManager */
        ChunkManager cp = this.w.getChunkManager();
        if (cp instanceof ServerChunkManager) {
            cps = (ServerChunkManager) cp;
        } else {
            Log.severe("Error: world " + dw.getName() + " has unsupported chunk provider");
        }
    }
    super.setChunks(dw, chunks);
}
Also used : ServerChunkManager(net.minecraft.server.world.ServerChunkManager) ChunkManager(net.minecraft.world.chunk.ChunkManager) ServerChunkManager(net.minecraft.server.world.ServerChunkManager)

Example 3 with ChunkManager

use of net.minecraft.world.chunk.ChunkManager in project dynmap by webbukkit.

the class FabricMapChunkCache method setChunks.

public void setChunks(FabricWorld dw, List<DynmapChunk> chunks) {
    this.w = dw.getWorld();
    if (dw.isLoaded()) {
        /* Check if world's provider is ServerChunkManager */
        ChunkManager cp = this.w.getChunkManager();
        if (cp instanceof ServerChunkManager) {
            cps = (ServerChunkManager) cp;
        } else {
            Log.severe("Error: world " + dw.getName() + " has unsupported chunk provider");
        }
    }
    super.setChunks(dw, chunks);
}
Also used : ServerChunkManager(net.minecraft.server.world.ServerChunkManager) ChunkManager(net.minecraft.world.chunk.ChunkManager) ServerChunkManager(net.minecraft.server.world.ServerChunkManager)

Example 4 with ChunkManager

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

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

the class ChestShopMod method checkForShops.

private void checkForShops(ClientPlayerEntity player, int radius) {
    ChunkManager cm = player.clientWorld.getChunkManager();
    ChunkPos.stream(player.getChunkPos(), radius).forEach(cp -> checkForShops(cm, cp));
}
Also used : ChunkManager(net.minecraft.world.chunk.ChunkManager)

Aggregations

ChunkManager (net.minecraft.world.chunk.ChunkManager)11 ServerChunkManager (net.minecraft.server.world.ServerChunkManager)7 WorldChunk (net.minecraft.world.chunk.WorldChunk)3 File (java.io.File)2 Entity (net.minecraft.entity.Entity)2 EdenClient (at.haha007.edenclient.EdenClient)1 PlayerTickCallback (at.haha007.edenclient.callbacks.PlayerTickCallback)1 CommandManager (at.haha007.edenclient.command.CommandManager)1 GetTo (at.haha007.edenclient.mods.GetTo)1 ChestShopItemNames (at.haha007.edenclient.mods.datafetcher.ChestShopItemNames)1 DataFetcher (at.haha007.edenclient.mods.datafetcher.DataFetcher)1 ChatColor (at.haha007.edenclient.utils.ChatColor)1 PlayerUtils (at.haha007.edenclient.utils.PlayerUtils)1 PlayerUtils.sendModMessage (at.haha007.edenclient.utils.PlayerUtils.sendModMessage)1 ConfigSubscriber (at.haha007.edenclient.utils.config.ConfigSubscriber)1 PerWorldConfig (at.haha007.edenclient.utils.config.PerWorldConfig)1 RunnableTask (at.haha007.edenclient.utils.tasks.RunnableTask)1 TaskManager (at.haha007.edenclient.utils.tasks.TaskManager)1 WaitForTicksTask (at.haha007.edenclient.utils.tasks.WaitForTicksTask)1 StringArgumentType (com.mojang.brigadier.arguments.StringArgumentType)1