@@ -37,19 +37,41 @@ public ComponentRewriter1_21(final Protocol1_21To1_20_5 protocol) {
3737 super (protocol , ReadType .NBT );
3838 }
3939
40- @ Override
41- protected void handleShowItem (final UserConnection connection , final CompoundTag componentsTag ) {
42- final CompoundTag attributeModifiers = TagUtil .getNamespacedCompoundTag (componentsTag , "attribute_modifiers" );
43- if (attributeModifiers != null ) {
44- final ListTag <CompoundTag > modifiers = attributeModifiers .getListTag ("modifiers" , CompoundTag .class );
45- for (final CompoundTag modifier : modifiers ) {
46- final String id = modifier .getString ("id" );
47- final UUID uuid = Protocol1_20_5To1_21 .mapAttributeId (id );
48- final String name = AttributeModifierMappings1_21 .idToName (id );
49- modifier .put ("uuid" , new IntArrayTag (UUIDUtil .toIntArray (uuid )));
50- modifier .putString ("name" , name != null ? name : id );
40+ private void convertAttributeModifiersComponent (final CompoundTag tag ) {
41+ final CompoundTag attributeModifiers = TagUtil .getNamespacedCompoundTag (tag , "attribute_modifiers" );
42+ if (attributeModifiers == null ) {
43+ return ;
44+ }
45+ final ListTag <CompoundTag > modifiers = attributeModifiers .getListTag ("modifiers" , CompoundTag .class );
46+ for (final CompoundTag modifier : modifiers ) {
47+ final String id = modifier .getString ("id" );
48+ final UUID uuid = Protocol1_20_5To1_21 .mapAttributeId (id );
49+ final String name = AttributeModifierMappings1_21 .idToName (id );
50+ modifier .put ("uuid" , new IntArrayTag (UUIDUtil .toIntArray (uuid )));
51+ modifier .putString ("name" , name != null ? name : id );
52+ }
53+ }
54+
55+ private void handleContainerComponent (final CompoundTag tag ) {
56+ final ListTag <CompoundTag > container = TagUtil .getNamespacedCompoundTagList (tag , "container" );
57+ if (container == null ) {
58+ return ;
59+ }
60+ for (final CompoundTag entryTag : container ) {
61+ final CompoundTag itemTag = entryTag .getCompoundTag ("item" );
62+
63+ final CompoundTag componentsTag = itemTag .getCompoundTag ("components" );
64+ if (componentsTag != null ) {
65+ convertAttributeModifiersComponent (componentsTag );
66+ handleContainerComponent (componentsTag );
5167 }
5268 }
69+ }
70+
71+ @ Override
72+ protected void handleShowItem (final UserConnection connection , final CompoundTag componentsTag ) {
73+ convertAttributeModifiersComponent (componentsTag );
74+ handleContainerComponent (componentsTag );
5375
5476 TagUtil .removeNamespaced (componentsTag , "jukebox_playable" );
5577 }
0 commit comments