Java 类net.minecraft.server.Chunk 实例源码

项目:CraftBukkit    文件:ChunkIOProvider.java   
public Chunk callStage1(QueuedChunk queuedChunk) throws RuntimeException {
    ChunkRegionLoader loader = queuedChunk.loader;
    Object[] data = loader.loadChunk(queuedChunk.world, queuedChunk.x, queuedChunk.z);

    if (data != null) {
        queuedChunk.compound = (NBTTagCompound) data[1];
        return (Chunk) data[0];
    }

    return null;
}
项目:CraftBukkit    文件:ChunkIOProvider.java   
public void callStage2(QueuedChunk queuedChunk, Chunk chunk) throws RuntimeException {
    if (chunk == null) {
        // If the chunk loading failed just do it synchronously (may generate)
        queuedChunk.provider.originalGetChunkAt(queuedChunk.x, queuedChunk.z);
        return;
    }

    queuedChunk.loader.loadEntities(chunk, queuedChunk.compound.getCompound("Level"), queuedChunk.world);
    chunk.lastSaved = queuedChunk.provider.world.getTime();
    queuedChunk.provider.chunks.put(LongHash.toLong(queuedChunk.x, queuedChunk.z), chunk);
    chunk.addEntities();

    if (queuedChunk.provider.chunkProvider != null) {
        queuedChunk.provider.chunkProvider.recreateStructures(queuedChunk.x, queuedChunk.z);
    }

    Server server = queuedChunk.provider.world.getServer();
    if (server != null) {
        server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(chunk.bukkitChunk, false));
    }

    // Update neighbor counts
    for (int x = -2; x < 3; x++) {
        for (int z = -2; z < 3; z++) {
            if (x == 0 && z == 0) {
                continue;
            }

            Chunk neighbor = queuedChunk.provider.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z);
            if (neighbor != null) {
                neighbor.setNeighborLoaded(-x, -z);
                chunk.setNeighborLoaded(x, z);
            }
        }
    }

    chunk.loadNearby(queuedChunk.provider, queuedChunk.provider, queuedChunk.x, queuedChunk.z);
}
项目:Craftbukkit    文件:ChunkIOProvider.java   
public Chunk callStage1(QueuedChunk queuedChunk) throws RuntimeException {
    try {
        ChunkRegionLoader loader = queuedChunk.loader;
        Object[] data = loader.loadChunk(queuedChunk.world, queuedChunk.x, queuedChunk.z);

        if (data != null) {
            queuedChunk.compound = (NBTTagCompound) data[1];
            return (Chunk) data[0];
        }

        return null;
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}
项目:Craftbukkit    文件:ChunkIOProvider.java   
public void callStage2(QueuedChunk queuedChunk, Chunk chunk) throws RuntimeException {
    if (chunk == null) {
        // If the chunk loading failed just do it synchronously (may generate)
        queuedChunk.provider.originalGetChunkAt(queuedChunk.x, queuedChunk.z);
        return;
    }

    queuedChunk.loader.loadEntities(chunk, queuedChunk.compound.getCompound("Level"), queuedChunk.world);
    chunk.setLastSaved(queuedChunk.provider.world.getTime());
    queuedChunk.provider.chunks.put(LongHash.toLong(queuedChunk.x, queuedChunk.z), chunk);
    chunk.addEntities();

    if (queuedChunk.provider.chunkProvider != null) {
        queuedChunk.provider.chunkProvider.recreateStructures(chunk, queuedChunk.x, queuedChunk.z);
    }

    Server server = queuedChunk.provider.world.getServer();
    if (server != null) {
        server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(chunk.bukkitChunk, false));
    }

    // Update neighbor counts
    for (int x = -2; x < 3; x++) {
        for (int z = -2; z < 3; z++) {
            if (x == 0 && z == 0) {
                continue;
            }

            Chunk neighbor = queuedChunk.provider.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z);
            if (neighbor != null) {
                neighbor.setNeighborLoaded(-x, -z);
                chunk.setNeighborLoaded(x, z);
            }
        }
    }

    chunk.loadNearby(queuedChunk.provider, queuedChunk.provider, queuedChunk.x, queuedChunk.z);
}
项目:Almura-Server    文件:ChunkIOProvider.java   
public Chunk callStage1(QueuedChunk queuedChunk) throws RuntimeException {
    ChunkRegionLoader loader = queuedChunk.loader;
    Object[] data = loader.loadChunk(queuedChunk.world, LongHash.msw(queuedChunk.coords), LongHash.lsw(queuedChunk.coords));

    if (data != null) {
        queuedChunk.compound = (NBTTagCompound) data[1];
        return (Chunk) data[0];
    }

    return null;
}
项目:Almura-Server    文件:ChunkIOProvider.java   
public void callStage2(QueuedChunk queuedChunk, Chunk chunk) throws RuntimeException {
    if(chunk == null) {
        // If the chunk loading failed just do it synchronously (may generate)
        queuedChunk.provider.getChunkAt(LongHash.msw(queuedChunk.coords), LongHash.lsw(queuedChunk.coords));
        return;
    }

    int x = LongHash.msw(queuedChunk.coords);
    int z = LongHash.lsw(queuedChunk.coords);

    // See if someone already loaded this chunk while we were working on it (API, etc)
    if (queuedChunk.provider.chunks.containsKey(queuedChunk.coords)) {
        // Make sure it isn't queued for unload, we need it
        queuedChunk.provider.unloadQueue.remove(queuedChunk.coords);
        return;
    }

    queuedChunk.loader.loadEntities(chunk, queuedChunk.compound.getCompound("Level"), queuedChunk.world);
    chunk.n = queuedChunk.provider.world.getTime();
    queuedChunk.provider.chunks.put(queuedChunk.coords, chunk);
    chunk.addEntities();

    if (queuedChunk.provider.chunkProvider != null) {
        queuedChunk.provider.chunkProvider.recreateStructures(x, z);
    }

    Server server = queuedChunk.provider.world.getServer();
    if (server != null) {
        server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(chunk.bukkitChunk, false));
    }

    chunk.a(queuedChunk.provider, queuedChunk.provider, x, z);
}
项目:Almura-Server    文件:ActivationRange.java   
/**
 * Checks for the activation state of all entities in this chunk.
 *
 * @param chunk
 */
private static void activateChunkEntities(Chunk chunk)
{
    for ( List<Entity> slice : chunk.entitySlices )
    {
        for ( Entity entity : slice )
        {
            if ( MinecraftServer.currentTick > entity.activatedTick )
            {
                if ( entity.defaultActivationState )
                {
                    entity.activatedTick = MinecraftServer.currentTick;
                    continue;
                }
                switch ( entity.activationType )
                {
                    case 1:
                        if ( monsterBB.b( entity.boundingBox ) )
                        {
                            entity.activatedTick = MinecraftServer.currentTick;
                        }
                        break;
                    case 2:
                        if ( animalBB.b( entity.boundingBox ) )
                        {
                            entity.activatedTick = MinecraftServer.currentTick;
                        }
                        break;
                    case 3:
                    default:
                        if ( miscBB.b( entity.boundingBox ) )
                        {
                            entity.activatedTick = MinecraftServer.currentTick;
                        }
                }
            }
        }
    }
}
项目:Tweakkit-Server    文件:ChunkIOProvider.java   
public Chunk callStage1(QueuedChunk queuedChunk) throws RuntimeException {
    ChunkRegionLoader loader = queuedChunk.loader;
    Object[] data = loader.loadChunk(queuedChunk.world, queuedChunk.x, queuedChunk.z);

    if (data != null) {
        queuedChunk.compound = (NBTTagCompound) data[1];
        return (Chunk) data[0];
    }

    return null;
}
项目:Tweakkit-Server    文件:ChunkIOProvider.java   
public void callStage2(QueuedChunk queuedChunk, Chunk chunk) throws RuntimeException {
    if (chunk == null) {
        // If the chunk loading failed just do it synchronously (may generate)
        queuedChunk.provider.originalGetChunkAt(queuedChunk.x, queuedChunk.z);
        return;
    }

    queuedChunk.loader.loadEntities(chunk, queuedChunk.compound.getCompound("Level"), queuedChunk.world);
    chunk.lastSaved = queuedChunk.provider.world.getTime();
    queuedChunk.provider.chunks.put(LongHash.toLong(queuedChunk.x, queuedChunk.z), chunk);
    chunk.addEntities();

    if (queuedChunk.provider.chunkProvider != null) {
        queuedChunk.provider.world.timings.syncChunkLoadStructuresTimer.startTiming(); // Spigot
        queuedChunk.provider.chunkProvider.recreateStructures(queuedChunk.x, queuedChunk.z);
        queuedChunk.provider.world.timings.syncChunkLoadStructuresTimer.stopTiming(); // Spigot
    }

    Server server = queuedChunk.provider.world.getServer();
    if (server != null) {
        server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(chunk.bukkitChunk, false));
    }

    // Update neighbor counts
    for (int x = -2; x < 3; x++) {
        for (int z = -2; z < 3; z++) {
            if (x == 0 && z == 0) {
                continue;
            }

            Chunk neighbor = queuedChunk.provider.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z);
            if (neighbor != null) {
                neighbor.setNeighborLoaded(-x, -z);
                chunk.setNeighborLoaded(x, z);
            }
        }
    }

    chunk.loadNearby(queuedChunk.provider, queuedChunk.provider, queuedChunk.x, queuedChunk.z);
}
项目:Tweakkit-Server    文件:ActivationRange.java   
/**
 * Checks for the activation state of all entities in this chunk.
 *
 * @param chunk
 */
private static void activateChunkEntities(Chunk chunk)
{
    for ( List<Entity> slice : chunk.entitySlices )
    {
        for ( Entity entity : slice )
        {
            if ( MinecraftServer.currentTick > entity.activatedTick )
            {
                if ( entity.defaultActivationState )
                {
                    entity.activatedTick = MinecraftServer.currentTick;
                    continue;
                }
                switch ( entity.activationType )
                {
                    case 1:
                        if ( monsterBB.b( entity.boundingBox ) )
                        {
                            entity.activatedTick = MinecraftServer.currentTick;
                        }
                        break;
                    case 2:
                        if ( animalBB.b( entity.boundingBox ) )
                        {
                            entity.activatedTick = MinecraftServer.currentTick;
                        }
                        break;
                    case 3:
                    default:
                        if ( miscBB.b( entity.boundingBox ) )
                        {
                            entity.activatedTick = MinecraftServer.currentTick;
                        }
                }
            }
        }
    }
}
项目:Tweakkit-Server    文件:ActivationRange.java   
/**
 * Checks if the entity is active for this tick.
 *
 * @param entity
 * @return
 */
public static boolean checkIfActive(Entity entity)
{
    SpigotTimings.checkIfActiveTimer.startTiming();
    boolean isActive = entity.activatedTick >= MinecraftServer.currentTick || entity.defaultActivationState;

    // Should this entity tick?
    if ( !isActive )
    {
        if ( ( MinecraftServer.currentTick - entity.activatedTick - 1 ) % 20 == 0 )
        {
            // Check immunities every 20 ticks.
            if ( checkEntityImmunities( entity ) )
            {
                // Triggered some sort of immunity, give 20 full ticks before we check again.
                entity.activatedTick = MinecraftServer.currentTick + 20;
            }
            isActive = true;
        }
        // Add a little performance juice to active entities. Skip 1/4 if not immune.
    } else if ( !entity.defaultActivationState && entity.ticksLived % 4 == 0 && !checkEntityImmunities( entity ) )
    {
        isActive = false;
    }
    int x = MathHelper.floor( entity.locX );
    int z = MathHelper.floor( entity.locZ );
    // Make sure not on edge of unloaded chunk
    Chunk chunk = entity.world.getChunkIfLoaded( x >> 4, z >> 4 );
    if ( isActive && !( chunk != null && chunk.areNeighborsLoaded( 1 ) ) )
    {
        isActive = false;
    }
    SpigotTimings.checkIfActiveTimer.stopTiming();
    return isActive;
}
项目:SpigotSource    文件:ChunkIOProvider.java   
public Chunk callStage1(QueuedChunk queuedChunk) throws RuntimeException {
    try {
        ChunkRegionLoader loader = queuedChunk.loader;
        Object[] data = loader.loadChunk(queuedChunk.world, queuedChunk.x, queuedChunk.z);

        if (data != null) {
            queuedChunk.compound = (NBTTagCompound) data[1];
            return (Chunk) data[0];
        }

        return null;
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}
项目:SpigotSource    文件:ChunkIOProvider.java   
public void callStage2(QueuedChunk queuedChunk, Chunk chunk) throws RuntimeException {
    if (chunk == null) {
        // If the chunk loading failed just do it synchronously (may generate)
        queuedChunk.provider.originalGetChunkAt(queuedChunk.x, queuedChunk.z);
        return;
    }

    queuedChunk.loader.loadEntities(chunk, queuedChunk.compound.getCompound("Level"), queuedChunk.world);
    chunk.setLastSaved(queuedChunk.provider.world.getTime());
    queuedChunk.provider.chunks.put(ChunkCoordIntPair.a(queuedChunk.x, queuedChunk.z), chunk);
    chunk.addEntities();

    if (queuedChunk.provider.chunkGenerator != null) {
        queuedChunk.provider.world.timings.syncChunkLoadStructuresTimer.startTiming(); // Spigot
        queuedChunk.provider.chunkGenerator.recreateStructures(chunk, queuedChunk.x, queuedChunk.z);
        queuedChunk.provider.world.timings.syncChunkLoadStructuresTimer.stopTiming(); // Spigot
    }

    Server server = queuedChunk.provider.world.getServer();
    if (server != null) {
        server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(chunk.bukkitChunk, false));
    }

    // Update neighbor counts
    for (int x = -2; x < 3; x++) {
        for (int z = -2; z < 3; z++) {
            if (x == 0 && z == 0) {
                continue;
            }

            Chunk neighbor = queuedChunk.provider.getLoadedChunkAt(chunk.locX + x, chunk.locZ + z);
            if (neighbor != null) {
                neighbor.setNeighborLoaded(-x, -z);
                chunk.setNeighborLoaded(x, z);
            }
        }
    }

    chunk.loadNearby(queuedChunk.provider, queuedChunk.provider.chunkGenerator);
}
项目:SpigotSource    文件:ActivationRange.java   
/**
 * Checks for the activation state of all entities in this chunk.
 *
 * @param chunk
 */
private static void activateChunkEntities(Chunk chunk)
{
    for ( List<Entity> slice : chunk.entitySlices )
    {
        for ( Entity entity : slice )
        {
            if ( MinecraftServer.currentTick > entity.activatedTick )
            {
                if ( entity.defaultActivationState )
                {
                    entity.activatedTick = MinecraftServer.currentTick;
                    continue;
                }
                switch ( entity.activationType )
                {
                    case 1:
                        if ( monsterBB.b( entity.getBoundingBox() ) )
                        {
                            entity.activatedTick = MinecraftServer.currentTick;
                        }
                        break;
                    case 2:
                        if ( animalBB.b( entity.getBoundingBox() ) )
                        {
                            entity.activatedTick = MinecraftServer.currentTick;
                        }
                        break;
                    case 3:
                    default:
                        if ( miscBB.b( entity.getBoundingBox() ) )
                        {
                            entity.activatedTick = MinecraftServer.currentTick;
                        }
                }
            }
        }
    }
}
项目:Craft-city    文件:ChunkIOProvider.java   
public Chunk callStage1(QueuedChunk queuedChunk) throws RuntimeException {
    ChunkRegionLoader loader = queuedChunk.loader;
    Object[] data = loader.loadChunk(queuedChunk.world, LongHash.msw(queuedChunk.coords), LongHash.lsw(queuedChunk.coords));

    if (data != null) {
        queuedChunk.compound = (NBTTagCompound) data[1];
        return (Chunk) data[0];
    }

    return null;
}
项目:Craft-city    文件:ChunkIOProvider.java   
public void callStage2(QueuedChunk queuedChunk, Chunk chunk) throws RuntimeException {
    if(chunk == null) {
        // If the chunk loading failed just do it synchronously (may generate)
        queuedChunk.provider.getChunkAt(LongHash.msw(queuedChunk.coords), LongHash.lsw(queuedChunk.coords));
        return;
    }

    int x = LongHash.msw(queuedChunk.coords);
    int z = LongHash.lsw(queuedChunk.coords);

    // See if someone already loaded this chunk while we were working on it (API, etc)
    if (queuedChunk.provider.chunks.containsKey(queuedChunk.coords)) {
        // Make sure it isn't queued for unload, we need it
        queuedChunk.provider.unloadQueue.remove(queuedChunk.coords);
        return;
    }

    queuedChunk.loader.loadEntities(chunk, queuedChunk.compound.getCompound("Level"), queuedChunk.world);
    chunk.n = queuedChunk.provider.world.getTime();
    queuedChunk.provider.chunks.put(queuedChunk.coords, chunk);
    chunk.addEntities();

    if (queuedChunk.provider.chunkProvider != null) {
        queuedChunk.provider.chunkProvider.recreateStructures(x, z);
    }

    Server server = queuedChunk.provider.world.getServer();
    if (server != null) {
        server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(chunk.bukkitChunk, false));
    }

    chunk.a(queuedChunk.provider, queuedChunk.provider, x, z);
}
项目:CraftBukkit    文件:NormalChunkGenerator.java   
public Chunk getOrCreateChunk(int i, int i1) {
    return provider.getOrCreateChunk(i, i1);
}
项目:CraftBukkit    文件:NormalChunkGenerator.java   
public Chunk getChunkAt(int i, int i1) {
    return provider.getChunkAt(i, i1);
}
项目:CraftBukkit    文件:CustomChunkGenerator.java   
public Chunk getChunkAt(int x, int z) {
    return getOrCreateChunk(x, z);
}
项目:CraftBukkit    文件:ChunkIOProvider.java   
public void callStage3(QueuedChunk queuedChunk, Chunk chunk, Runnable runnable) throws RuntimeException {
    runnable.run();
}
项目:CraftBukkit    文件:ChunkIOExecutor.java   
public static Chunk syncChunkLoad(World world, ChunkRegionLoader loader, ChunkProviderServer provider, int x, int z) {
    return instance.getSkipQueue(new QueuedChunk(x, z, loader, world, provider));
}
项目:Craftbukkit    文件:ChunkIOProvider.java   
public void callStage3(QueuedChunk queuedChunk, Chunk chunk, Runnable runnable) throws RuntimeException {
    runnable.run();
}
项目:Craftbukkit    文件:ChunkIOExecutor.java   
public static Chunk syncChunkLoad(World world, ChunkRegionLoader loader, ChunkProviderServer provider, int x, int z) {
    return instance.getSkipQueue(new QueuedChunk(x, z, loader, world, provider));
}
项目:Almura-Server    文件:NormalChunkGenerator.java   
public Chunk getOrCreateChunk(int i, int i1) {
    return provider.getOrCreateChunk(i, i1);
}
项目:Almura-Server    文件:NormalChunkGenerator.java   
public Chunk getChunkAt(int i, int i1) {
    return provider.getChunkAt(i, i1);
}
项目:Almura-Server    文件:CustomChunkGenerator.java   
public Chunk getChunkAt(int x, int z) {
    return getOrCreateChunk(x, z);
}
项目:Almura-Server    文件:ChunkIOProvider.java   
public void callStage3(QueuedChunk queuedChunk, Chunk chunk, Runnable runnable) throws RuntimeException {
    runnable.run();
}
项目:Tweakkit-Server    文件:NormalChunkGenerator.java   
public Chunk getOrCreateChunk(int i, int i1) {
    return provider.getOrCreateChunk(i, i1);
}
项目:Tweakkit-Server    文件:NormalChunkGenerator.java   
public Chunk getChunkAt(int i, int i1) {
    return provider.getChunkAt(i, i1);
}
项目:Tweakkit-Server    文件:CustomChunkGenerator.java   
public Chunk getChunkAt(int x, int z) {
    return getOrCreateChunk(x, z);
}
项目:Tweakkit-Server    文件:ChunkIOProvider.java   
public void callStage3(QueuedChunk queuedChunk, Chunk chunk, Runnable runnable) throws RuntimeException {
    runnable.run();
}
项目:Tweakkit-Server    文件:ChunkIOExecutor.java   
public static Chunk syncChunkLoad(World world, ChunkRegionLoader loader, ChunkProviderServer provider, int x, int z) {
    return instance.getSkipQueue(new QueuedChunk(x, z, loader, world, provider));
}
项目:SpigotSource    文件:ChunkIOProvider.java   
public void callStage3(QueuedChunk queuedChunk, Chunk chunk, Runnable runnable) throws RuntimeException {
    runnable.run();
}
项目:SpigotSource    文件:ChunkIOExecutor.java   
public static Chunk syncChunkLoad(World world, ChunkRegionLoader loader, ChunkProviderServer provider, int x, int z) {
    return instance.getSkipQueue(new QueuedChunk(x, z, loader, world, provider));
}
项目:SpigotSource    文件:ActivationRange.java   
/**
 * Checks if the entity is active for this tick.
 *
 * @param entity
 * @return
 */
public static boolean checkIfActive(Entity entity)
{
    SpigotTimings.checkIfActiveTimer.startTiming();
    // Never safe to skip fireworks or entities not yet added to chunk
    // PAIL: inChunk
    if ( !entity.aa || entity instanceof EntityFireworks ) {
        SpigotTimings.checkIfActiveTimer.stopTiming();
        return true;
    }

    boolean isActive = entity.activatedTick >= MinecraftServer.currentTick || entity.defaultActivationState;

    // Should this entity tick?
    if ( !isActive )
    {
        if ( ( MinecraftServer.currentTick - entity.activatedTick - 1 ) % 20 == 0 )
        {
            // Check immunities every 20 ticks.
            if ( checkEntityImmunities( entity ) )
            {
                // Triggered some sort of immunity, give 20 full ticks before we check again.
                entity.activatedTick = MinecraftServer.currentTick + 20;
            }
            isActive = true;
        }
        // Add a little performance juice to active entities. Skip 1/4 if not immune.
    } else if ( !entity.defaultActivationState && entity.ticksLived % 4 == 0 && !checkEntityImmunities( entity ) )
    {
        isActive = false;
    }
    int x = MathHelper.floor( entity.locX );
    int z = MathHelper.floor( entity.locZ );
    // Make sure not on edge of unloaded chunk
    Chunk chunk = entity.world.getChunkIfLoaded( x >> 4, z >> 4 );
    if ( isActive && !( chunk != null && chunk.areNeighborsLoaded( 1 ) ) )
    {
        isActive = false;
    }
    SpigotTimings.checkIfActiveTimer.stopTiming();
    return isActive;
}
项目:Craft-city    文件:NormalChunkGenerator.java   
public Chunk getOrCreateChunk(int i, int i1) {
    return provider.getOrCreateChunk(i, i1);
}
项目:Craft-city    文件:NormalChunkGenerator.java   
public Chunk getChunkAt(int i, int i1) {
    return provider.getChunkAt(i, i1);
}
项目:Craft-city    文件:CustomChunkGenerator.java   
public Chunk getChunkAt(int x, int z) {
    return getOrCreateChunk(x, z);
}
项目:Craft-city    文件:ChunkIOProvider.java   
public void callStage3(QueuedChunk queuedChunk, Chunk chunk, Runnable runnable) throws RuntimeException {
    runnable.run();
}