Skip to content

Commit 93d6fa2

Browse files
Only add (block) entity id if needed for tooltips in 1.20.3->.5
1 parent 162fcaf commit 93d6fa2

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/rewriter/BlockItemPacketRewriter1_20_5.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,12 @@ public Item toStructuredItem(final UserConnection connection, final Item old) {
471471
CompoundTag entityTag = tag.getCompoundTag("EntityTag");
472472
if (entityTag != null) {
473473
entityTag = entityTag.copy();
474+
// Additional tooltips of items don't validate the entity id in 1.20.4, add the entity id for these back so
475+
// 1.20.5+ parses it correctly (as otherwise not used on the client).
474476
if (entityTag.contains("variant")) {
475477
entityTag.putString("id", "minecraft:painting");
476-
} else if (entityTag.contains("ShowArms")) {
477-
entityTag.putString("id", "minecraft:armor_stand");
478478
}
479+
479480
if (entityTag.contains("id")) {
480481
data.set(StructuredDataKey.ENTITY_DATA, entityTag);
481482
}
@@ -484,10 +485,21 @@ public Item toStructuredItem(final UserConnection connection, final Item old) {
484485
final CompoundTag blockEntityTag = tag.getCompoundTag("BlockEntityTag");
485486
if (blockEntityTag != null) {
486487
final CompoundTag clonedTag = blockEntityTag.copy();
488+
// Same as above
487489
updateBlockEntityTag(connection, data, clonedTag);
490+
CompoundTag spawnData = clonedTag.getCompoundTag("SpawnData");
491+
if (spawnData == null) {
492+
spawnData = clonedTag.getCompoundTag("spawn_data");
493+
}
494+
if (spawnData != null) {
495+
final CompoundTag entity = spawnData.getCompoundTag("entity");
496+
if (entity != null && entity.getString("id") != null) {
497+
addBlockEntityId(clonedTag, clonedTag.contains("SpawnData") ? "mob_spawner" : "trial_spawner");
498+
}
499+
}
488500

489501
// Not always needed, e.g. shields that had the base color in a block entity tag before
490-
if (blockEntityTag.contains("id")) {
502+
if (clonedTag.contains("id")) {
491503
item.dataContainer().set(StructuredDataKey.BLOCK_ENTITY_DATA, clonedTag);
492504
}
493505
}
@@ -1520,7 +1532,7 @@ private void updateBlockEntityTag(final UserConnection connection, @Nullable fin
15201532
}
15211533

15221534
data.set(StructuredDataKey.CONTAINER1_20_5, filteredItems);
1523-
addBlockEntityId(tag, "shulker_box"); // Won't happen to the others and doesn't actually have to be correct otherwise
1535+
addBlockEntityId(tag, "shulker_box");
15241536
}
15251537
}
15261538

0 commit comments

Comments
 (0)