コード例 #1
0
ファイル: Chunk.cs プロジェクト: pdelvo/Craft.Net
 /// <summary>
 /// Creates a new chunk at the specified location.
 /// </summary>
 public Chunk(Vector3 relativePosition)
 {
     Sections = new Section[16];
     for (int i = 0; i < Sections.Length; i++)
         Sections[i] = new Section((byte)i);
     RelativePosition = relativePosition;
     Biomes = new byte[Width * Depth];
     HeightMap = new int[Width * Depth];
 }
コード例 #2
0
ファイル: Chunk.cs プロジェクト: pdelvo/Craft.Net
 /// <summary>
 /// Creates a new Chunk within the specified <see cref="Craft.Net.Data.Region"/>
 /// at the specified location.
 /// </summary>
 public Chunk(Vector3 relativePosition, Region parentRegion)
 {
     Sections = new Section[16];
     for (int i = 0; i < Sections.Length; i++)
         Sections[i] = new Section((byte)i);
     RelativePosition = relativePosition;
     Biomes = new byte[Width * Depth];
     HeightMap = new int[Width * Depth];
     ParentRegion = parentRegion;
     IsModified = false;
 }
コード例 #3
0
ファイル: Chunk.cs プロジェクト: ammaraskar/Craft.Net
 public static Chunk FromNbt(Vector3 position, NbtFile nbt)
 {
     Chunk chunk = new Chunk(position);
     // Load data
     var root = nbt.RootTag.Get<NbtCompound>("Level");
     chunk.Biomes = root.Get<NbtByteArray>("Biomes").Value;
     chunk.HeightMap = root.Get<NbtIntArray>("HeightMap").Value;
     var sections = root.Get<NbtList>("Sections");
     foreach (var sectionTag in sections) // TODO: This might not work properly
     {
         // Load data
         var compound = (NbtCompound)sectionTag;
         byte y = compound.Get<NbtByte>("Y").Value;
         var section = new Section(y);
         section.Blocks = compound.Get<NbtByteArray>("Blocks").Value;
         section.BlockLight.Data = compound.Get<NbtByteArray>("BlockLight").Value;
         section.SkyLight.Data = compound.Get<NbtByteArray>("SkyLight").Value;
         section.Metadata.Data = compound.Get<NbtByteArray>("Data").Value;
         // Process section
         section.ProcessSection();
         chunk.Sections[y] = section;
     }
     var tileEntities = root.Get<NbtList>("TileEntities");
     if (tileEntities != null)
     {
         foreach (var tag in tileEntities)
         {
             Vector3 tilePosition;
             var entity = TileEntity.FromNbt(tag as NbtCompound, out tilePosition);
             if (entity != null)
                 chunk.TileEntities.Add(tilePosition, entity);
         }
     }
     return chunk;
 }
コード例 #4
0
ファイル: Chunk.cs プロジェクト: pdelvo/Craft.Net
 public static Chunk FromNbt(Vector3 position, NbtFile nbt)
 {
     Chunk chunk = new Chunk(position);
     // Load data
     var root = nbt.RootTag.Get<NbtCompound>("Level");
     chunk.Biomes = root.Get<NbtByteArray>("Biomes").Value;
     chunk.HeightMap = root.Get<NbtIntArray>("HeightMap").Value;
     var sections = root.Get<NbtList>("Sections");
     foreach (var sectionTag in sections.Tags)
     {
         // Load data
         var compound = (NbtCompound)sectionTag;
         byte y = compound.Get<NbtByte>("Y").Value;
         var section = new Section(y);
         section.Blocks = compound.Get<NbtByteArray>("Blocks").Value;
         section.BlockLight.Data = compound.Get<NbtByteArray>("BlockLight").Value;
         section.SkyLight.Data = compound.Get<NbtByteArray>("SkyLight").Value;
         section.Metadata.Data = compound.Get<NbtByteArray>("Data").Value;
         // Process section
         section.ProcessSection();
         chunk.Sections[y] = section;
     }
     return chunk;
 }
コード例 #5
0
ファイル: ReadOnlyWorld.cs プロジェクト: seaboy1234/Craft.Net
 internal ReadOnlySection(Section section)
 {
     Section = section;
 }