4545using MiNET . Utils ;
4646using MiNET . Utils . IO ;
4747using MiNET . Utils . Vectors ;
48- using Org . BouncyCastle . Asn1 . Cms ;
48+ using Newtonsoft . Json ;
4949
5050namespace MiNET . Worlds
5151{
@@ -174,7 +174,7 @@ public ChunkColumn GetChunk(ChunkCoordinates coordinates, IWorldGenerator genera
174174 sw . Stop ( ) ;
175175
176176 ChunkColumn chunkColumn = null ;
177- if ( version != null && version . First ( ) >= 10 )
177+ if ( version != null && version . First ( ) >= 7 )
178178 {
179179 chunkColumn = new ChunkColumn
180180 {
@@ -217,10 +217,9 @@ public ChunkColumn GetChunk(ChunkCoordinates coordinates, IWorldGenerator genera
217217
218218 //Log.Debug($"Read chunk from LevelDB {coordinates.X}, {coordinates.Z} in {sw.ElapsedMilliseconds} ms.");
219219
220- if ( blockEntityBytes != null )
220+ if ( blockEntityBytes != null && version . First ( ) >= 10 )
221221 {
222222 Memory < byte > data = blockEntityBytes . AsMemory ( ) ;
223-
224223 var file = new NbtFile
225224 {
226225 BigEndian = false ,
@@ -239,6 +238,17 @@ public ChunkColumn GetChunk(ChunkCoordinates coordinates, IWorldGenerator genera
239238 chunkColumn . SetBlockEntity ( new BlockCoordinates ( x , y , z ) , ( NbtCompound ) blockEntityTag ) ;
240239 } while ( position < data . Length ) ;
241240 }
241+ else
242+ { //todo find out how to get block entities on chunk format 7
243+ //Memory<byte> data = blockEntityBytes.AsMemory();
244+ //string jsonString = System.Text.Encoding.UTF8.GetString(data.Span);
245+ //LegacyBlockEntities info = JsonConvert.DeserializeObject<LegacyBlockEntities>(jsonString);
246+ //if (info != null)
247+ //{
248+ //Log.Warn(info.IsEmpty);
249+ //Log.Warn(info.Length);
250+ //}
251+ }
242252 }
243253
244254 if ( chunkColumn == null )
@@ -267,6 +277,12 @@ public ChunkColumn GetChunk(ChunkCoordinates coordinates, IWorldGenerator genera
267277 return chunkColumn ;
268278 }
269279
280+ public class LegacyBlockEntities
281+ {
282+ public int Length { get ; set ; }
283+ public bool IsEmpty { get ; set ; }
284+ }
285+
270286 internal void ParseSection ( SubChunk section , ReadOnlyMemory < byte > data )
271287 {
272288 var reader = new MemoryStreamReader ( data ) ;
0 commit comments