-
Notifications
You must be signed in to change notification settings - Fork 48
/
Chunk.java
726 lines (652 loc) · 20.5 KB
/
Chunk.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
package net.querz.mca;
import net.querz.nbt.tag.CompoundTag;
import net.querz.nbt.tag.ListTag;
import net.querz.nbt.io.NamedTag;
import net.querz.nbt.io.NBTDeserializer;
import net.querz.nbt.io.NBTSerializer;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
import static net.querz.mca.LoadFlags.*;
public class Chunk implements Iterable<Section> {
public static final int DEFAULT_DATA_VERSION = 2567;
private boolean partial;
private boolean raw;
private int lastMCAUpdate;
private CompoundTag data;
private int dataVersion;
private long lastUpdate;
private long inhabitedTime;
private int[] biomes;
private CompoundTag heightMaps;
private CompoundTag carvingMasks;
private Map<Integer, Section> sections = new TreeMap<>();
private ListTag<CompoundTag> entities;
private ListTag<CompoundTag> tileEntities;
private ListTag<CompoundTag> tileTicks;
private ListTag<CompoundTag> liquidTicks;
private ListTag<ListTag<?>> lights;
private ListTag<ListTag<?>> liquidsToBeTicked;
private ListTag<ListTag<?>> toBeTicked;
private ListTag<ListTag<?>> postProcessing;
private String status;
private CompoundTag structures;
Chunk(int lastMCAUpdate) {
this.lastMCAUpdate = lastMCAUpdate;
}
/**
* Create a new chunk based on raw base data from a region file.
* @param data The raw base data to be used.
*/
public Chunk(CompoundTag data) {
this.data = data;
initReferences(ALL_DATA);
}
private void initReferences(long loadFlags) {
if (data == null) {
throw new NullPointerException("data cannot be null");
}
if ((loadFlags != ALL_DATA) && (loadFlags & RAW) != 0) {
raw = true;
return;
}
CompoundTag level;
if ((level = data.getCompoundTag("Level")) == null) {
throw new IllegalArgumentException("data does not contain \"Level\" tag");
}
dataVersion = data.getInt("DataVersion");
inhabitedTime = level.getLong("InhabitedTime");
lastUpdate = level.getLong("LastUpdate");
if ((loadFlags & BIOMES) != 0) {
biomes = level.getIntArray("Biomes");
}
if ((loadFlags & HEIGHTMAPS) != 0) {
heightMaps = level.getCompoundTag("Heightmaps");
}
if ((loadFlags & CARVING_MASKS) != 0) {
carvingMasks = level.getCompoundTag("CarvingMasks");
}
if ((loadFlags & ENTITIES) != 0) {
entities = level.containsKey("Entities") ? level.getListTag("Entities").asCompoundTagList() : null;
}
if ((loadFlags & TILE_ENTITIES) != 0) {
tileEntities = level.containsKey("TileEntities") ? level.getListTag("TileEntities").asCompoundTagList() : null;
}
if ((loadFlags & TILE_TICKS) != 0) {
tileTicks = level.containsKey("TileTicks") ? level.getListTag("TileTicks").asCompoundTagList() : null;
}
if ((loadFlags & LIQUID_TICKS) != 0) {
liquidTicks = level.containsKey("LiquidTicks") ? level.getListTag("LiquidTicks").asCompoundTagList() : null;
}
if ((loadFlags & LIGHTS) != 0) {
lights = level.containsKey("Lights") ? level.getListTag("Lights").asListTagList() : null;
}
if ((loadFlags & LIQUIDS_TO_BE_TICKED) != 0) {
liquidsToBeTicked = level.containsKey("LiquidsToBeTicked") ? level.getListTag("LiquidsToBeTicked").asListTagList() : null;
}
if ((loadFlags & TO_BE_TICKED) != 0) {
toBeTicked = level.containsKey("ToBeTicked") ? level.getListTag("ToBeTicked").asListTagList() : null;
}
if ((loadFlags & POST_PROCESSING) != 0) {
postProcessing = level.containsKey("PostProcessing") ? level.getListTag("PostProcessing").asListTagList() : null;
}
status = level.getString("Status");
if ((loadFlags & STRUCTURES) != 0) {
structures = level.getCompoundTag("Structures");
}
if ((loadFlags & (BLOCK_LIGHTS|BLOCK_STATES|SKY_LIGHT)) != 0 && level.containsKey("Sections")) {
for (CompoundTag section : level.getListTag("Sections").asCompoundTagList()) {
int sectionIndex = section.getNumber("Y").byteValue();
Section newSection = new Section(section, dataVersion, loadFlags);
sections.put(sectionIndex, newSection);
}
}
// If we haven't requested the full set of data we can drop the underlying raw data to let the GC handle it.
if (loadFlags != ALL_DATA) {
data = null;
partial = true;
}
}
/**
* Serializes this chunk to a <code>RandomAccessFile</code>.
* @param raf The RandomAccessFile to be written to.
* @param xPos The x-coordinate of the chunk.
* @param zPos The z-coodrinate of the chunk.
* @return The amount of bytes written to the RandomAccessFile.
* @throws UnsupportedOperationException When something went wrong during writing.
* @throws IOException When something went wrong during writing.
*/
public int serialize(RandomAccessFile raf, int xPos, int zPos) throws IOException {
if (partial) {
throw new UnsupportedOperationException("Partially loaded chunks cannot be serialized");
}
ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
try (BufferedOutputStream nbtOut = new BufferedOutputStream(CompressionType.ZLIB.compress(baos))) {
new NBTSerializer(false).toStream(new NamedTag(null, updateHandle(xPos, zPos)), nbtOut);
}
byte[] rawData = baos.toByteArray();
raf.writeInt(rawData.length + 1); // including the byte to store the compression type
raf.writeByte(CompressionType.ZLIB.getID());
raf.write(rawData);
return rawData.length + 5;
}
/**
* Reads chunk data from a RandomAccessFile. The RandomAccessFile must already be at the correct position.
* @param raf The RandomAccessFile to read the chunk data from.
* @throws IOException When something went wrong during reading.
*/
public void deserialize(RandomAccessFile raf) throws IOException {
deserialize(raf, ALL_DATA);
}
/**
* Reads chunk data from a RandomAccessFile. The RandomAccessFile must already be at the correct position.
* @param raf The RandomAccessFile to read the chunk data from.
* @param loadFlags A logical or of {@link LoadFlags} constants indicating what data should be loaded
* @throws IOException When something went wrong during reading.
*/
public void deserialize(RandomAccessFile raf, long loadFlags) throws IOException {
byte compressionTypeByte = raf.readByte();
CompressionType compressionType = CompressionType.getFromID(compressionTypeByte);
if (compressionType == null) {
throw new IOException("invalid compression type " + compressionTypeByte);
}
BufferedInputStream dis = new BufferedInputStream(compressionType.decompress(new FileInputStream(raf.getFD())));
NamedTag tag = new NBTDeserializer(false).fromStream(dis);
if (tag != null && tag.getTag() instanceof CompoundTag) {
data = (CompoundTag) tag.getTag();
initReferences(loadFlags);
} else {
throw new IOException("invalid data tag: " + (tag == null ? "null" : tag.getClass().getName()));
}
}
/**
* @deprecated Use {@link #getBiomeAt(int, int, int)} instead
*/
@Deprecated
public int getBiomeAt(int blockX, int blockZ) {
if (dataVersion < 2202) {
if (biomes == null || biomes.length != 256) {
return -1;
}
return biomes[getBlockIndex(blockX, blockZ)];
} else {
throw new IllegalStateException("cannot get biome using Chunk#getBiomeAt(int,int) from biome data with DataVersion of 2202 or higher, use Chunk#getBiomeAt(int,int,int) instead");
}
}
/**
* Fetches a biome id at a specific block in this chunk.
* The coordinates can be absolute coordinates or relative to the region or chunk.
* @param blockX The x-coordinate of the block.
* @param blockY The y-coordinate of the block.
* @param blockZ The z-coordinate of the block.
* @return The biome id or -1 if the biomes are not correctly initialized.
*/
public int getBiomeAt(int blockX, int blockY, int blockZ) {
if (dataVersion < 2202) {
if (biomes == null || biomes.length != 256) {
return -1;
}
return biomes[getBlockIndex(blockX, blockZ)];
} else {
if (biomes == null || biomes.length != 1024) {
return -1;
}
int biomeX = (blockX & 0xF) >> 2;
int biomeY = (blockY & 0xF) >> 2;
int biomeZ = (blockZ & 0xF) >> 2;
return biomes[getBiomeIndex(biomeX, biomeY, biomeZ)];
}
}
@Deprecated
public void setBiomeAt(int blockX, int blockZ, int biomeID) {
checkRaw();
if (dataVersion < 2202) {
if (biomes == null || biomes.length != 256) {
biomes = new int[256];
Arrays.fill(biomes, -1);
}
biomes[getBlockIndex(blockX, blockZ)] = biomeID;
} else {
if (biomes == null || biomes.length != 1024) {
biomes = new int[1024];
Arrays.fill(biomes, -1);
}
int biomeX = (blockX & 0xF) >> 2;
int biomeZ = (blockZ & 0xF) >> 2;
for (int y = 0; y < 64; y++) {
biomes[getBiomeIndex(biomeX, y, biomeZ)] = biomeID;
}
}
}
/**
* Sets a biome id at a specific block column.
* The coordinates can be absolute coordinates or relative to the region or chunk.
* @param blockX The x-coordinate of the block column.
* @param blockZ The z-coordinate of the block column.
* @param biomeID The biome id to be set.
* When set to a negative number, Minecraft will replace it with the block column's default biome.
*/
public void setBiomeAt(int blockX, int blockY, int blockZ, int biomeID) {
checkRaw();
if (dataVersion < 2202) {
if (biomes == null || biomes.length != 256) {
biomes = new int[256];
Arrays.fill(biomes, -1);
}
biomes[getBlockIndex(blockX, blockZ)] = biomeID;
} else {
if (biomes == null || biomes.length != 1024) {
biomes = new int[1024];
Arrays.fill(biomes, -1);
}
int biomeX = (blockX & 0xF) >> 2;
int biomeZ = (blockZ & 0xF) >> 2;
biomes[getBiomeIndex(biomeX, blockY, biomeZ)] = biomeID;
}
}
int getBiomeIndex(int biomeX, int biomeY, int biomeZ) {
return biomeY * 16 + biomeZ * 4 + biomeX;
}
public CompoundTag getBlockStateAt(int blockX, int blockY, int blockZ) {
Section section = sections.get(MCAUtil.blockToChunk(blockY));
if (section == null) {
return null;
}
return section.getBlockStateAt(blockX, blockY, blockZ);
}
/**
* Sets a block state at a specific location.
* The block coordinates can be absolute or relative to the region or chunk.
* @param blockX The x-coordinate of the block.
* @param blockY The y-coordinate of the block.
* @param blockZ The z-coordinate of the block.
* @param state The block state to be set.
* @param cleanup When <code>true</code>, it will cleanup all palettes of this chunk.
* This option should only be used moderately to avoid unnecessary recalculation of the palette indices.
* Recalculating the Palette should only be executed once right before saving the Chunk to file.
*/
public void setBlockStateAt(int blockX, int blockY, int blockZ, CompoundTag state, boolean cleanup) {
checkRaw();
int sectionIndex = MCAUtil.blockToChunk(blockY);
Section section = sections.get(sectionIndex);
if (section == null) {
sections.put(sectionIndex, section = Section.newSection());
}
section.setBlockStateAt(blockX, blockY, blockZ, state, cleanup);
}
/**
* @return The DataVersion of this chunk.
*/
public int getDataVersion() {
return dataVersion;
}
/**
* Sets the DataVersion of this chunk. This does not check if the data of this chunk conforms
* to that DataVersion, that is the responsibility of the developer.
* @param dataVersion The DataVersion to be set.
*/
public void setDataVersion(int dataVersion) {
checkRaw();
this.dataVersion = dataVersion;
for (Section section : sections.values()) {
if (section != null) {
section.dataVersion = dataVersion;
}
}
}
/**
* @return The timestamp when this region file was last updated in seconds since 1970-01-01.
*/
public int getLastMCAUpdate() {
return lastMCAUpdate;
}
/**
* Sets the timestamp when this region file was last updated in seconds since 1970-01-01.
* @param lastMCAUpdate The time in seconds since 1970-01-01.
*/
public void setLastMCAUpdate(int lastMCAUpdate) {
checkRaw();
this.lastMCAUpdate = lastMCAUpdate;
}
/**
* @return The generation station of this chunk.
*/
public String getStatus() {
return status;
}
/**
* Sets the generation status of this chunk.
* @param status The generation status of this chunk.
*/
public void setStatus(String status) {
checkRaw();
this.status = status;
}
/**
* Fetches the section at the given y-coordinate.
* @param sectionY The y-coordinate of the section in this chunk ranging from 0 to 15.
* @return The Section.
*/
public Section getSection(int sectionY) {
return sections.get(sectionY);
}
/**
* Sets a section at a givesn y-coordinate
* @param sectionY The y-coordinate of the section in this chunk ranging from 0 to 15.
* @param section The section to be set.
*/
public void setSection(int sectionY, Section section) {
checkRaw();
sections.put(sectionY, section);
}
/**
* @return The timestamp when this chunk was last updated as a UNIX timestamp.
*/
public long getLastUpdate() {
return lastUpdate;
}
/**
* Sets the time when this chunk was last updated as a UNIX timestamp.
* @param lastUpdate The UNIX timestamp.
*/
public void setLastUpdate(long lastUpdate) {
checkRaw();
this.lastUpdate = lastUpdate;
}
/**
* @return The cumulative amount of time players have spent in this chunk in ticks.
*/
public long getInhabitedTime() {
return inhabitedTime;
}
/**
* Sets the cumulative amount of time players have spent in this chunk in ticks.
* @param inhabitedTime The time in ticks.
*/
public void setInhabitedTime(long inhabitedTime) {
checkRaw();
this.inhabitedTime = inhabitedTime;
}
/**
* @return A matrix of biome IDs for all block columns in this chunk.
*/
public int[] getBiomes() {
return biomes;
}
/**
* Sets the biome IDs for this chunk.
* @param biomes The biome ID matrix of this chunk. Must have a length of <code>256</code>.
* @throws IllegalArgumentException When the biome matrix does not have a length of <code>256</code>
* or is <code>null</code>
*/
public void setBiomes(int[] biomes) {
checkRaw();
if (biomes != null) {
if (dataVersion < 2202 && biomes.length != 256 || dataVersion >= 2202 && biomes.length != 1024) {
throw new IllegalArgumentException("biomes array must have a length of " + (dataVersion < 2202 ? "256" : "1024"));
}
}
this.biomes = biomes;
}
/**
* @return The height maps of this chunk.
*/
public CompoundTag getHeightMaps() {
return heightMaps;
}
/**
* Sets the height maps of this chunk.
* @param heightMaps The height maps.
*/
public void setHeightMaps(CompoundTag heightMaps) {
checkRaw();
this.heightMaps = heightMaps;
}
/**
* @return The carving masks of this chunk.
*/
public CompoundTag getCarvingMasks() {
return carvingMasks;
}
/**
* Sets the carving masks of this chunk.
* @param carvingMasks The carving masks.
*/
public void setCarvingMasks(CompoundTag carvingMasks) {
checkRaw();
this.carvingMasks = carvingMasks;
}
/**
* @return The entities of this chunk.
*/
public ListTag<CompoundTag> getEntities() {
return entities;
}
/**
* Sets the entities of this chunk.
* @param entities The entities.
*/
public void setEntities(ListTag<CompoundTag> entities) {
checkRaw();
this.entities = entities;
}
/**
* @return The tile entities of this chunk.
*/
public ListTag<CompoundTag> getTileEntities() {
return tileEntities;
}
/**
* Sets the tile entities of this chunk.
* @param tileEntities The tile entities of this chunk.
*/
public void setTileEntities(ListTag<CompoundTag> tileEntities) {
checkRaw();
this.tileEntities = tileEntities;
}
/**
* @return The tile ticks of this chunk.
*/
public ListTag<CompoundTag> getTileTicks() {
return tileTicks;
}
/**
* Sets the tile ticks of this chunk.
* @param tileTicks Thee tile ticks.
*/
public void setTileTicks(ListTag<CompoundTag> tileTicks) {
checkRaw();
this.tileTicks = tileTicks;
}
/**
* @return The liquid ticks of this chunk.
*/
public ListTag<CompoundTag> getLiquidTicks() {
return liquidTicks;
}
/**
* Sets the liquid ticks of this chunk.
* @param liquidTicks The liquid ticks.
*/
public void setLiquidTicks(ListTag<CompoundTag> liquidTicks) {
checkRaw();
this.liquidTicks = liquidTicks;
}
/**
* @return The light sources in this chunk.
*/
public ListTag<ListTag<?>> getLights() {
return lights;
}
/**
* Sets the light sources in this chunk.
* @param lights The light sources.
*/
public void setLights(ListTag<ListTag<?>> lights) {
checkRaw();
this.lights = lights;
}
/**
* @return The liquids to be ticked in this chunk.
*/
public ListTag<ListTag<?>> getLiquidsToBeTicked() {
return liquidsToBeTicked;
}
/**
* Sets the liquids to be ticked in this chunk.
* @param liquidsToBeTicked The liquids to be ticked.
*/
public void setLiquidsToBeTicked(ListTag<ListTag<?>> liquidsToBeTicked) {
checkRaw();
this.liquidsToBeTicked = liquidsToBeTicked;
}
/**
* @return Stuff to be ticked in this chunk.
*/
public ListTag<ListTag<?>> getToBeTicked() {
return toBeTicked;
}
/**
* Sets stuff to be ticked in this chunk.
* @param toBeTicked The stuff to be ticked.
*/
public void setToBeTicked(ListTag<ListTag<?>> toBeTicked) {
checkRaw();
this.toBeTicked = toBeTicked;
}
/**
* @return Things that are in post processing in this chunk.
*/
public ListTag<ListTag<?>> getPostProcessing() {
return postProcessing;
}
/**
* Sets things to be post processed in this chunk.
* @param postProcessing The things to be post processed.
*/
public void setPostProcessing(ListTag<ListTag<?>> postProcessing) {
checkRaw();
this.postProcessing = postProcessing;
}
/**
* @return Data about structures in this chunk.
*/
public CompoundTag getStructures() {
return structures;
}
/**
* Sets data about structures in this chunk.
* @param structures The data about structures.
*/
public void setStructures(CompoundTag structures) {
checkRaw();
this.structures = structures;
}
int getBlockIndex(int blockX, int blockZ) {
return (blockZ & 0xF) * 16 + (blockX & 0xF);
}
public void cleanupPalettesAndBlockStates() {
checkRaw();
for (Section section : sections.values()) {
if (section != null) {
section.cleanupPaletteAndBlockStates();
}
}
}
private void checkRaw() {
if (raw) {
throw new UnsupportedOperationException("cannot update field when working with raw data");
}
}
public static Chunk newChunk() {
return newChunk(DEFAULT_DATA_VERSION);
}
public static Chunk newChunk(int dataVersion) {
Chunk c = new Chunk(0);
c.dataVersion = dataVersion;
c.data = new CompoundTag();
c.data.put("Level", new CompoundTag());
c.status = "mobs_spawned";
return c;
}
/**
* Provides a reference to the full chunk data.
* @return The full chunk data or null if there is none, e.g. when this chunk has only been loaded partially.
*/
public CompoundTag getHandle() {
return data;
}
public CompoundTag updateHandle(int xPos, int zPos) {
if (raw) {
return data;
}
data.putInt("DataVersion", dataVersion);
CompoundTag level = data.getCompoundTag("Level");
level.putInt("xPos", xPos);
level.putInt("zPos", zPos);
level.putLong("LastUpdate", lastUpdate);
level.putLong("InhabitedTime", inhabitedTime);
if (dataVersion < 2202) {
if (biomes != null && biomes.length == 256) {
level.putIntArray("Biomes", biomes);
}
} else {
if (biomes != null && biomes.length == 1024) {
level.putIntArray("Biomes", biomes);
}
}
if (heightMaps != null) {
level.put("Heightmaps", heightMaps);
}
if (carvingMasks != null) {
level.put("CarvingMasks", carvingMasks);
}
if (entities != null) {
level.put("Entities", entities);
}
if (tileEntities != null) {
level.put("TileEntities", tileEntities);
}
if (tileTicks != null) {
level.put("TileTicks", tileTicks);
}
if (liquidTicks != null) {
level.put("LiquidTicks", liquidTicks);
}
if (lights != null) {
level.put("Lights", lights);
}
if (liquidsToBeTicked != null) {
level.put("LiquidsToBeTicked", liquidsToBeTicked);
}
if (toBeTicked != null) {
level.put("ToBeTicked", toBeTicked);
}
if (postProcessing != null) {
level.put("PostProcessing", postProcessing);
}
level.putString("Status", status);
if (structures != null) {
level.put("Structures", structures);
}
ListTag<CompoundTag> sections = new ListTag<>(CompoundTag.class);
for (Section section : this.sections.values()) {
if (section != null) {
sections.add(section.updateHandle());
}
}
level.put("Sections", sections);
return data;
}
@Override
public Iterator<Section> iterator() {
return sections.values().iterator();
}
}