Skip to content

Commit 1ddc229

Browse files
committed
Fix loading some chunk formats in 1.12. Fixes #33
1 parent 85191b9 commit 1ddc229

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil112.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@
3131
import de.bluecolored.bluemap.core.world.Biome;
3232
import de.bluecolored.bluemap.core.world.BlockState;
3333
import de.bluecolored.bluemap.core.world.LightData;
34+
import net.querz.nbt.ByteArrayTag;
3435
import net.querz.nbt.CompoundTag;
36+
import net.querz.nbt.IntArrayTag;
3537
import net.querz.nbt.ListTag;
38+
import net.querz.nbt.Tag;
3639
import net.querz.nbt.mca.MCAUtil;
3740

3841
public class ChunkAnvil112 extends Chunk {
@@ -41,7 +44,7 @@ public class ChunkAnvil112 extends Chunk {
4144

4245
private boolean isGenerated;
4346
private Section[] sections;
44-
private byte[] biomes;
47+
private int[] biomes;
4548

4649
@SuppressWarnings("unchecked")
4750
public ChunkAnvil112(MCAWorld world, CompoundTag chunkTag) {
@@ -62,10 +65,21 @@ public ChunkAnvil112(MCAWorld world, CompoundTag chunkTag) {
6265
sections[section.getSectionY()] = section;
6366
}
6467

65-
biomes = levelData.getByteArray("Biomes");
68+
Tag<?> tag = levelData.get("Biomes"); //tag can be byte-array or int-array
69+
if (tag instanceof ByteArrayTag) {
70+
byte[] bs = ((ByteArrayTag) tag).getValue();
71+
biomes = new int[bs.length];
72+
73+
for (int i = 0; i < bs.length; i++) {
74+
biomes[i] = bs[i] & 0xFF;
75+
}
76+
}
77+
else if (tag instanceof IntArrayTag) {
78+
biomes = ((IntArrayTag) tag).getValue();
79+
}
6680

6781
if (biomes == null || biomes.length == 0) {
68-
biomes = new byte[2048];
82+
biomes = new int[2048];
6983
}
7084
}
7185

0 commit comments

Comments
 (0)