mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-08 17:37:42 +01:00
Support block nbt without handler
This commit is contained in:
parent
ddba34712e
commit
faa7c512af
@ -143,32 +143,30 @@ public class AnvilLoader implements IChunkLoader {
|
|||||||
|
|
||||||
private void loadTileEntities(Chunk loadedChunk, ChunkColumn fileChunk) {
|
private void loadTileEntities(Chunk loadedChunk, ChunkColumn fileChunk) {
|
||||||
for (NBTCompound te : fileChunk.getTileEntities()) {
|
for (NBTCompound te : fileChunk.getTileEntities()) {
|
||||||
final String tileEntityID = te.getString("id");
|
|
||||||
if (tileEntityID == null) {
|
|
||||||
LOGGER.warn("Tile entity has failed to load due to invalid namespace");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
final var x = te.getInt("x");
|
final var x = te.getInt("x");
|
||||||
final var y = te.getInt("y");
|
final var y = te.getInt("y");
|
||||||
final var z = te.getInt("z");
|
final var z = te.getInt("z");
|
||||||
if (x == null || y == null || z == null) {
|
if (x == null || y == null || z == null) {
|
||||||
LOGGER.warn("Tile entity {} has failed to load due to invalid coordinate", tileEntityID);
|
LOGGER.warn("Tile entity has failed to load due to invalid coordinate");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Block block = loadedChunk.getBlock(x, y, z);
|
||||||
|
|
||||||
|
final String tileEntityID = te.getString("id");
|
||||||
|
if (tileEntityID != null) {
|
||||||
final var handler = BLOCK_MANAGER.getHandler(tileEntityID);
|
final var handler = BLOCK_MANAGER.getHandler(tileEntityID);
|
||||||
if (handler == null) {
|
if (handler == null) {
|
||||||
LOGGER.warn("Block {} does not have any corresponding handler, world will load anyway.", tileEntityID);
|
LOGGER.warn("Block {} does not have any corresponding handler, world will load anyway.", tileEntityID);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
block = block.withHandler(handler);
|
||||||
|
}
|
||||||
// Remove anvil tags
|
// Remove anvil tags
|
||||||
te.removeTag("id")
|
te.removeTag("id")
|
||||||
.removeTag("x").removeTag("y").removeTag("z")
|
.removeTag("x").removeTag("y").removeTag("z")
|
||||||
.removeTag("keepPacked");
|
.removeTag("keepPacked");
|
||||||
// Place block
|
// Place block
|
||||||
final Block block = loadedChunk.getBlock(x, y, z)
|
loadedChunk.setBlock(x, y, z, block.withNbt(te));
|
||||||
.withHandler(handler)
|
|
||||||
.withNbt(te);
|
|
||||||
loadedChunk.setBlock(x, y, z, block);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user