Search in sources :

Example 26 with BaseFullChunk

use of cn.nukkit.level.format.generic.BaseFullChunk in project Nukkit by Nukkit.

the class Anvil method loadChunk.

@Override
public BaseFullChunk loadChunk(long index, int chunkX, int chunkZ, boolean create) {
    int regionX = getRegionIndexX(chunkX);
    int regionZ = getRegionIndexZ(chunkZ);
    BaseRegionLoader region = this.loadRegion(regionX, regionZ);
    this.level.timings.syncChunkLoadDataTimer.startTiming();
    BaseFullChunk chunk;
    try {
        chunk = region.readChunk(chunkX - regionX * 32, chunkZ - regionZ * 32);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    if (chunk == null) {
        if (create) {
            chunk = this.getEmptyChunk(chunkX, chunkZ);
            putChunk(index, chunk);
        }
    } else {
        putChunk(index, chunk);
    }
    this.level.timings.syncChunkLoadDataTimer.stopTiming();
    return chunk;
}
Also used : BaseRegionLoader(cn.nukkit.level.format.generic.BaseRegionLoader) BaseFullChunk(cn.nukkit.level.format.generic.BaseFullChunk) IOException(java.io.IOException)

Aggregations

BaseFullChunk (cn.nukkit.level.format.generic.BaseFullChunk)26 IOException (java.io.IOException)5 BlockEntity (cn.nukkit.blockentity.BlockEntity)4 FullChunk (cn.nukkit.level.format.FullChunk)4 Player (cn.nukkit.Player)3 Entity (cn.nukkit.entity.Entity)3 Level (cn.nukkit.level.Level)3 Block (cn.nukkit.block.Block)2 ItemBlock (cn.nukkit.item.ItemBlock)2 SimpleChunkManager (cn.nukkit.level.SimpleChunkManager)2 BaseRegionLoader (cn.nukkit.level.format.generic.BaseRegionLoader)2 Generator (cn.nukkit.level.generator.Generator)2 CompoundTag (cn.nukkit.nbt.tag.CompoundTag)2 Int2ObjectOpenHashMap (it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap)2 Long2ObjectMap (it.unimi.dsi.fastutil.longs.Long2ObjectMap)2 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 BlockEntitySpawnable (cn.nukkit.blockentity.BlockEntitySpawnable)1 BlockUpdateEvent (cn.nukkit.event.block.BlockUpdateEvent)1 LevelProvider (cn.nukkit.level.format.LevelProvider)1