public void Remove(TagCompound tag) { Position pos = Entity.GetPosition(tag); int x = (int)Math.Floor(pos.X / 16); int z = (int)Math.Floor(pos.Z / 16); AnvilChunk c = (AnvilChunk)_chunk.GetChunk(new ChunkCoord(x, z)); c.Entities.Remove(tag); }
internal void SaveChunk(AnvilChunk chunk) { RegionFile f = FetchRegion(chunk.Coord.RegionCoord); TagCompound chunkTag = chunk.BuildTag(); using (Stream stream = f.WriteChunk(new ChunkCoord(chunk.Coord.X & 31, chunk.Coord.Z & 31))) { NBTFile.ToStream(stream, chunkTag); } }
public void Add(TagCompound tag) { Position pos = Entity.GetPosition(tag); //Entity.SetPosition(tag, new Tuple<double, double, double>(pos.Item1 % 16, pos.Item2 % 16, pos.Item3 % 16));4 int x = (int)Math.Floor(pos.X / 16); int z = (int)Math.Floor(pos.Z / 16); AnvilChunk c = (AnvilChunk)_chunk.GetChunk(new ChunkCoord(x, z)); c.Entities.Add(tag); //_entities.Add(tag); }
public IEnumerable <TagCompound> GetWithin(Cuboid area) { int fromX = area.MinX / 16; int fromZ = area.MinZ / 16; int toX = area.MaxX / 16; int toZ = area.MaxZ / 16; for (int z = fromZ; z < toZ; z++) { for (int x = fromX; x < toX; x++) { AnvilChunk c = (AnvilChunk)_chunk.GetChunk(new ChunkCoord(x, z)); foreach (TagCompound e in c.Entities) { Position pos = Entity.GetPosition(e); if (area.Contains(pos.X, pos.Y, pos.Z)) { yield return(e); } } } } }
public static AnvilChunk Load(AnvilChunkManager manager, TagCompound compound) { /** * * Untested Code * * */ if (compound == null || !compound.ContainsKey("Level")) { return(null); } TagCompound level = compound["Level"] as TagCompound; int cx = level.GetInt("xPos"); int cy = level.GetInt("zPos"); AnvilChunk c = new AnvilChunk(manager, new ChunkCoord(cx, cy)); if (compound.ContainsKey("DataVersion")) { c.DataVersion = compound.GetInt("DataVersion"); } c._heights = level.GetIntArray("HeightMap"); bool isTerrainPopulated = level.GetBool("TerrainPopulated"); bool isLightPopulated = level.GetBool("LightPopulated"); //if(isTerrainPopulated && isLightPopulated) //{ // c._status = ChunkStatus.Lighted; //} //else if(isTerrainPopulated) //{ // c._status = ChunkStatus.Carved; //} c._isTerrainPopulated = level.GetBool("TerrainPopulated"); c._isLightPopulated = level.GetBool("LightPopulated"); //c.InhabitedTime = tag.GetLong("InhabitedTime"); TagList sections = (TagList)level["Sections"]; c._sections = new AnvilSection[SectionsPerChunk]; for (int i = 0; i < sections.Count; i++) { TagCompound sec = sections[i] as TagCompound; if (sec == null) { continue; } c._sections[i] = new AnvilSectionClassic(sec.GetByte("Y"), true); c._sections[i].Load(sec); } if (level.ContainsKey("Biomes", TagType.ByteArray)) { byte[] oldBiome = level.GetByteArray("Biomes"); for (int i = 0; i < oldBiome.Length; i++) { c._biomes[i] = oldBiome[i]; } } TagList entities = (TagList)level["Entities"]; foreach (TagCompound t in entities) { c.Entities.Add(t); } TagList tiles = (TagList)level["TileEntities"]; foreach (TagCompound t in tiles) { int x = t.GetInt("x"); int y = t.GetInt("y"); int z = t.GetInt("z"); c._tileEntities.Add(new BlockPos(x, y, z), t); } return(c); }
private void CacheStorage(AnvilChunk chunk) { TagCompound c = chunk.BuildTag(); NBTFile.ToFile(string.Format("{0}-{1}-{2}.ocache", 0, chunk.Coord.X, chunk.Coord.Z), c); }