Fix null block entity console spam, which caused the world to be invisible

This was a rare bug that only happened on very few servers, and from what I gathered, only 1.8 servers using ViaVersion.
This commit is contained in:
RednedEpic 2020-04-04 17:22:54 -05:00
parent 392b0b5727
commit c13bbcda85
3 changed files with 5 additions and 6 deletions

View file

@ -44,13 +44,12 @@ public abstract class BlockEntityTranslator {
public abstract com.nukkitx.nbt.tag.CompoundTag getDefaultBedrockTag(String bedrockId, int x, int y, int z);
public com.nukkitx.nbt.tag.CompoundTag getBlockEntityTag(CompoundTag tag) {
public com.nukkitx.nbt.tag.CompoundTag getBlockEntityTag(String id, CompoundTag tag) {
int x = Integer.parseInt(String.valueOf(tag.getValue().get("x").getValue()));
int y = Integer.parseInt(String.valueOf(tag.getValue().get("y").getValue()));
int z = Integer.parseInt(String.valueOf(tag.getValue().get("z").getValue()));
CompoundTagBuilder tagBuilder = getConstantBedrockTag(BlockEntityUtils.getBedrockBlockEntityId(
String.valueOf(tag.get("id").getValue())), x, y, z).toBuilder();
CompoundTagBuilder tagBuilder = getConstantBedrockTag(BlockEntityUtils.getBedrockBlockEntityId(id), x, y, z).toBuilder();
translateTag(tag).forEach(tagBuilder::tag);
return tagBuilder.buildRootTag();
}

View file

@ -45,12 +45,12 @@ public class JavaUpdateTileEntityTranslator extends PacketTranslator<ServerUpdat
if (id.equalsIgnoreCase("Sign")) {
// Delay so chunks can finish sending
session.getConnector().getGeneralThreadPool().schedule(() ->
BlockEntityUtils.updateBlockEntity(session, translator.getBlockEntityTag(packet.getNbt()), packet.getPosition()),
BlockEntityUtils.updateBlockEntity(session, translator.getBlockEntityTag("Sign", packet.getNbt()), packet.getPosition()),
5,
TimeUnit.SECONDS
);
} else {
BlockEntityUtils.updateBlockEntity(session, translator.getBlockEntityTag(packet.getNbt()), packet.getPosition());
BlockEntityUtils.updateBlockEntity(session, translator.getBlockEntityTag(id, packet.getNbt()), packet.getPosition());
}
}
}

View file

@ -103,7 +103,7 @@ public class ChunkUtils {
String id = BlockEntityUtils.getBedrockBlockEntityId(tagName);
BlockEntityTranslator blockEntityTranslator = BlockEntityUtils.getBlockEntityTranslator(id);
bedrockBlockEntities[i] = blockEntityTranslator.getBlockEntityTag(tag);
bedrockBlockEntities[i] = blockEntityTranslator.getBlockEntityTag(tagName, tag);
}
chunkData.blockEntities = bedrockBlockEntities;