Search in sources :

Example 11 with ChunkManager

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

the class WorldHelper method getEntitiesOfClass.

/**
 * [VanillaCopy] Method for getting entities by class but also exclude one entity
 */
public static List<Entity> getEntitiesOfClass(World world, Entity except, Class<? extends Entity> entityClass, Box box) {
    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.getEntitiesOfClass(chunk, except, entityClass, box, entities);
            }
        }
    }
    return entities;
}
Also used : Entity(net.minecraft.entity.Entity) WorldChunk(net.minecraft.world.chunk.WorldChunk) 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