Add block entity ids in 1.20.3->.5 conversion (#3837)

This commit is contained in:
EnZaXD 2024-05-09 20:37:20 +02:00 committed by GitHub
parent 8c4ff7ebfc
commit f60e31ac78
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1340,6 +1340,12 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
} }
} }
private void addBlockEntityId(final CompoundTag tag, final String id) {
if (!tag.contains("id")) {
tag.putString("id", id);
}
}
private void updateBlockEntityTag(final UserConnection connection, @Nullable final StructuredDataContainer data, final CompoundTag tag) { private void updateBlockEntityTag(final UserConnection connection, @Nullable final StructuredDataContainer data, final CompoundTag tag) {
if (tag == null) { if (tag == null) {
return; return;
@ -1354,6 +1360,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
final ListTag<CompoundTag> beesTag = tag.getListTag("Bees", CompoundTag.class); final ListTag<CompoundTag> beesTag = tag.getListTag("Bees", CompoundTag.class);
if (beesTag != null) { if (beesTag != null) {
updateBees(data, beesTag); updateBees(data, beesTag);
addBlockEntityId(tag, "beehive");
} }
final ListTag<StringTag> sherdsTag = tag.getListTag("sherds", StringTag.class); final ListTag<StringTag> sherdsTag = tag.getListTag("sherds", StringTag.class);
@ -1369,11 +1376,13 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
toMappedItemId(rightSherd), toMappedItemId(rightSherd),
toMappedItemId(frontSherd) toMappedItemId(frontSherd)
)); ));
addBlockEntityId(tag, "decorated_pot");
} }
final StringTag noteBlockSoundTag = tag.getStringTag("note_block_sound"); final StringTag noteBlockSoundTag = tag.getStringTag("note_block_sound");
if (noteBlockSoundTag != null) { if (noteBlockSoundTag != null) {
data.set(StructuredDataKey.NOTE_BLOCK_SOUND, noteBlockSoundTag.getValue()); data.set(StructuredDataKey.NOTE_BLOCK_SOUND, noteBlockSoundTag.getValue());
addBlockEntityId(tag, "player_head");
} }
final StringTag lootTableTag = tag.getStringTag("LootTable"); final StringTag lootTableTag = tag.getStringTag("LootTable");
@ -1424,6 +1433,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
}).filter(Objects::nonNull).toArray(BannerPatternLayer[]::new); }).filter(Objects::nonNull).toArray(BannerPatternLayer[]::new);
tag.remove("Patterns"); tag.remove("Patterns");
tag.put("patterns", patternsTag); tag.put("patterns", patternsTag);
addBlockEntityId(tag, "banner");
if (data != null) { if (data != null) {
data.set(StructuredDataKey.BANNER_PATTERNS, layers); data.set(StructuredDataKey.BANNER_PATTERNS, layers);