Skip to content

Commit

Permalink
fix: biome data not being null when no biomes are set
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmayr committed Sep 8, 2024
1 parent feff00f commit 92e89c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = "eu.cafestube"
version = "2.0.3-SNAPSHOT"
version = "2.0.4-SNAPSHOT"

allprojects {
repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,25 @@ public Schematic deserialize(CompoundBinaryTag compound) {

Map<BlockPos, BlockEntity> blockEntityMap = V2SchematicVersion.parseBlockEntities(dataVersion, blocksTag);

CompoundBinaryTag biomesTag = compound.getCompound("Biomes");
CompoundBinaryTag biomePaletteTag = biomesTag.getCompound("Palette");
Map<Integer, String> biomePalette = StreamSupport.stream(biomePaletteTag.spliterator(), true)
.collect(Collectors.toMap(stringObjectEntry -> ((IntBinaryTag) stringObjectEntry.getValue()).value(), Map.Entry::getKey));
byte[] biomeData = biomesTag.getByteArray("Data");

BiomeData biomeData = null;
if(compound.get("Biomes") != null) {
CompoundBinaryTag biomesTag = compound.getCompound("Biomes");
CompoundBinaryTag biomePaletteTag = biomesTag.getCompound("Palette");
Map<Integer, String> biomePalette = StreamSupport.stream(biomePaletteTag.spliterator(), true)
.collect(Collectors.toMap(stringObjectEntry -> ((IntBinaryTag) stringObjectEntry.getValue()).value(), Map.Entry::getKey));
byte[] biomeDataBytes = biomesTag.getByteArray("Data");

biomeData = new BiomeData(biomePalette, biomeDataBytes, BiomeDataType.THREE_DIMENSIONAL);
}


ListBinaryTag entitiesTag = compound.getList("Entities");
List<Entity> entities = V2SchematicVersion.parseEntities(entitiesTag);


return new Schematic(dataVersion, width, height, length, metadata, offset, blockPalette, blockData,
blockEntityMap, entities, new BiomeData(biomePalette, biomeData, BiomeDataType.THREE_DIMENSIONAL));
blockEntityMap, entities, biomeData);
}

@Override
Expand Down

0 comments on commit 92e89c4

Please sign in to comment.