public static GetChunk ( Cubia |
||
pos | Cubia |
|
trans | bool | |
Résultat | MinecraftLevel.Chunk |
/// <summary> /// Tries loading the chunk at the specified position. This is done automatically /// when an area is requested. /// </summary> public Chunk?LoadChunk(Point <int> Pos) { Chunk?chunk; if (SMPInterface.IsSMP) { chunk = SMPInterface.GetChunk(Pos, this._Trans); } else if (!this._Chunks.TryGetValue(Pos, out chunk)) { long regionX = (long)Math.Floor((decimal)Pos.X / 32); long regionZ = (long)Math.Floor((decimal)Pos.Y / 32); string file = this._Source + Path.DirectorySeparatorChar + "region" + Path.DirectorySeparatorChar + "r." + Convert.ToString(regionX) + "." + Convert.ToString(regionZ) + ".mca"; if (File.Exists(file)) { try { using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) //File.OpenRead(file)) { NBTNamedTag <INBTData> dat = NBT.ReadChunk(fs, Pos); NBTCompound level = (NBTCompound)(((NBTCompound)dat.Data).Data["Level"]).Data; this._Chunks.Add(Pos, chunk = ParseChunkFromNBT(level) ); } } catch { this._Chunks.Add(Pos, null); } } else { this._Chunks.Add(Pos, null); } } return(chunk); }