Remove empty items from various block entities

This commit is contained in:
Nassim Jahnke 2024-04-19 09:56:24 +02:00
parent 7825a1e460
commit 3520f99d5a
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F

View File

@ -1343,6 +1343,21 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
data.set(StructuredDataKey.BANNER_PATTERNS, layers);
}
}
// Remove air item from brushable blocks, decorated pots, jukeboxes, and lecterns
removeEmptyItem(tag, "item");
removeEmptyItem(tag, "RecordItem");
removeEmptyItem(tag, "Book");
}
private void removeEmptyItem(final CompoundTag tag, final String key) {
final CompoundTag itemTag = tag.getCompoundTag(key);
if (itemTag != null) {
final int id = itemTag.getInt("id");
if (id == 0) {
tag.remove(key);
}
}
}
private void updateSkullOwnerTag(final CompoundTag tag, final CompoundTag skullOwnerTag) {