public void SetBlock(int x, int y, int z, Block block) { x = NumericsHelper.Modulo(x, 16); z = NumericsHelper.Modulo(z, 16); var sectionIndex = y >> 4; var success = Sections[sectionIndex].SetBlock(x, y & 15, z, block); // Palette dynamic sizing if (!success) { var oldSection = Sections[sectionIndex]; var bpb = oldSection.BitsPerBlock; bpb += 1; var newSection = new ChunkSection(bpb, sectionIndex); for (int sx = 0; sx < 16; sx++) { for (int sy = 0; sy < 16; sy++) { for (int sz = 0; sz < 16; sz++) { // Seems to be the safest way to do this. A bit expensive, though... newSection.SetBlock(sx, sy, sz, oldSection.GetBlock(sx, sy, sz)); } } } Sections[sectionIndex] = newSection; SetBlock(x, y, z, block); } }
public Block GetBlock(int x, int y, int z) { x = NumericsHelper.Modulo(x, 16); z = NumericsHelper.Modulo(z, 16); return(Sections[y >> 4].GetBlock(x, y & 15, z)); }
public void Load(string regionFile) { var regionNbt = new NbtFile(); try { regionNbt.LoadFromFile(regionFile); } catch (Exception) { File.Delete(regionFile); File.Move(regionFile + ".bak", regionFile); regionNbt.LoadFromFile(regionFile); } finally { File.Delete(regionFile + ".bak"); } NbtCompound regionCompound = regionNbt.RootTag; var chunksNbt = regionCompound["Chunks"] as NbtList; foreach (var chunkNbt in chunksNbt) { var chunk = GetChunkFromNbt((NbtCompound)chunkNbt); var index = (NumericsHelper.Modulo(chunk.X, cubicRegionSize), NumericsHelper.Modulo(chunk.Z, cubicRegionSize)); LoadedChunks[index.Item1, index.Item2] = chunk; } regionNbt = null; regionCompound = null; GC.Collect(); IsDirty = false; }
public void SetBlockEntity(int x, int y, int z, NbtCompound tileEntityData) { x = NumericsHelper.Modulo(x, 16); z = NumericsHelper.Modulo(z, 16); var value = (short)((x << 8) | (z << 4) | y); this.BlockEntities[value] = tileEntityData; }
public NbtCompound GetBlockEntity(int x, int y, int z) { x = NumericsHelper.Modulo(x, 16); z = NumericsHelper.Modulo(z, 16); var value = (short)((x << 8) | (z << 4) | y); return(this.BlockEntities.GetValueOrDefault(value)); }
public BlockMeta GetBlockMeta(int x, int y, int z) { x = NumericsHelper.Modulo(x, 16); z = NumericsHelper.Modulo(z, 16); var value = (short)((x << 8) | (z << 4) | y); return(this.BlockMetaStore.GetValueOrDefault(value)); }
public void SetBlockMeta(int x, int y, int z, BlockMeta meta) { x = NumericsHelper.Modulo(x, 16); z = NumericsHelper.Modulo(z, 16); var value = (short)((x << 8) | (z << 4) | y); this.BlockMetaStore[value] = meta; }
public void SetBlock(int x, int y, int z, Block block) { SetBlockStateId(x, y, z, block.StateId); x = NumericsHelper.Modulo(x, 16); z = NumericsHelper.Modulo(z, 16); Sections[y >> 4].SetBlock(x, y & 15, z, block); }
public void SetBiome(int x, int y, int z, Biomes biome) { int i = SectionIndex(y); x = NumericsHelper.Modulo(x, 16); y = (y + 64) % 16 / 4; z = NumericsHelper.Modulo(z, 16); Sections[i].SetBiome(x, y, z, biome); }
public Biomes GetBiome(int x, int y, int z) { var i = SectionIndex(y); x = NumericsHelper.Modulo(x, 16); z = NumericsHelper.Modulo(z, 16); y = (y + 64) % 16 / 4; return(Sections[i].GetBiome(x, y, z)); }
public Block GetBlock(int x, int y, int z) { var i = SectionIndex(y); x = NumericsHelper.Modulo(x, 16); y = NumericsHelper.Modulo(y, 16); z = NumericsHelper.Modulo(z, 16); return(Sections[i].GetBlock(x, y, z)); }
public void SetBlock(int x, int y, int z, Block block) { int i = SectionIndex(y); x = NumericsHelper.Modulo(x, 16); y = NumericsHelper.Modulo(y, 16); z = NumericsHelper.Modulo(z, 16); Sections[i].SetBlock(x, y, z, block); }