Save blocks nbt without handler

This commit is contained in:
TheMode 2021-06-24 16:16:41 +02:00
parent 8ff7eed45c
commit b49ccadadc

View File

@ -238,10 +238,13 @@ public class AnvilLoader implements IChunkLoader {
chunkColumn.setBiome(x, 0, z, biome.getId());
// Tile entity
var nbt = block.nbt();
final BlockHandler handler = block.handler();
if (handler != null) {
NBTCompound nbt = Objects.requireNonNullElseGet(block.nbt(), NBTCompound::new);
nbt.setString("id", handler.getNamespaceId().asString());
if (nbt != null || handler != null) {
nbt = Objects.requireNonNullElseGet(nbt, NBTCompound::new);
if (handler != null) {
nbt.setString("id", handler.getNamespaceId().asString());
}
nbt.setInt("x", x + Chunk.CHUNK_SIZE_X * chunk.getChunkX());
nbt.setInt("y", y);
nbt.setInt("z", z + Chunk.CHUNK_SIZE_Z * chunk.getChunkZ());