func (chunk *Chunk) save(chunkStore chunkstore.IChunkStore) { if chunk.storeDirty { writer := chunkStore.Writer() writer.SetChunkLoc(chunk.loc) writer.SetBlocks(chunk.blocks) writer.SetBlockData(chunk.blockData) writer.SetBlockLight(chunk.blockLight) writer.SetSkyLight(chunk.skyLight) writer.SetHeightMap(chunk.heightMap) writer.SetEntities(chunk.entities) writer.SetTileEntities(chunk.tileEntities) chunkStore.WriteChunk(writer) chunk.storeDirty = false } }
func NewChunkShard(shardConnecter gamerules.IShardConnecter, chunkStore chunkstore.IChunkStore, entityMgr *entity.EntityManager, loc ShardXz) (shard *ChunkShard) { shard = &ChunkShard{ shardConnecter: shardConnecter, chunkStore: chunkStore, entityMgr: entityMgr, loc: loc, originChunkLoc: loc.ToChunkXz(), requests: make(chan iShardRequest, 256), ticksSinceUpdate: 0, saveChunks: chunkStore.SupportsWrite(), // Offset shard saves. ticksSinceSave: (31 * Ticks(loc.Key())) % ticksBetweenSaves, newActiveShards: make(map[uint64]*destActiveShard), shardClients: make(map[uint64]gamerules.IShardShardClient), } shard.selfClient.shard = shard return }