1717 */
1818package com .viaversion .viaversion .protocols .protocol1_13to1_12_2 .packets ;
1919
20- import com .github .steveice10 .opennbt .conversion .ConverterRegistry ;
21- import com .github .steveice10 .opennbt .tag .builtin .*;
20+ import com .github .steveice10 .opennbt .tag .builtin .CompoundTag ;
21+ import com .github .steveice10 .opennbt .tag .builtin .IntTag ;
22+ import com .github .steveice10 .opennbt .tag .builtin .ListTag ;
23+ import com .github .steveice10 .opennbt .tag .builtin .NumberTag ;
24+ import com .github .steveice10 .opennbt .tag .builtin .ShortTag ;
25+ import com .github .steveice10 .opennbt .tag .builtin .StringTag ;
26+ import com .github .steveice10 .opennbt .tag .builtin .Tag ;
2227import com .google .common .base .Joiner ;
2328import com .google .common .primitives .Ints ;
2429import com .viaversion .viaversion .api .Via ;
3641import com .viaversion .viaversion .protocols .protocol1_13to1_12_2 .data .SpawnEggRewriter ;
3742import com .viaversion .viaversion .rewriter .ItemRewriter ;
3843import com .viaversion .viaversion .util .Key ;
39-
4044import java .nio .charset .StandardCharsets ;
4145import java .util .ArrayList ;
4246import java .util .List ;
@@ -357,7 +361,7 @@ public Item handleItemToClient(Item item) {
357361 if (tag .get ("CanPlaceOn" ) instanceof ListTag ) {
358362 ListTag old = tag .get ("CanPlaceOn" );
359363 ListTag newCanPlaceOn = new ListTag (StringTag .class );
360- tag .put (NBT_TAG_NAME + "|CanPlaceOn" , ConverterRegistry . convertToTag ( ConverterRegistry . convertToValue ( old ))); // There will be data losing
364+ tag .put (NBT_TAG_NAME + "|CanPlaceOn" , old . clone ());
361365 for (Tag oldTag : old ) {
362366 Object value = oldTag .getValue ();
363367 String oldId = Key .stripMinecraftNamespace (value .toString ());
@@ -379,7 +383,7 @@ public Item handleItemToClient(Item item) {
379383 if (tag .get ("CanDestroy" ) instanceof ListTag ) {
380384 ListTag old = tag .get ("CanDestroy" );
381385 ListTag newCanDestroy = new ListTag (StringTag .class );
382- tag .put (NBT_TAG_NAME + "|CanDestroy" , ConverterRegistry . convertToTag ( ConverterRegistry . convertToValue ( old ))); // There will be data losing
386+ tag .put (NBT_TAG_NAME + "|CanDestroy" , old . clone ());
383387 for (Tag oldTag : old ) {
384388 Object value = oldTag .getValue ();
385389 String oldId = Key .stripMinecraftNamespace (value .toString ());
@@ -617,8 +621,7 @@ public Item handleItemToServer(Item item) {
617621 tag .put ("StoredEnchantments" , newStoredEnch );
618622 }
619623 if (tag .get (NBT_TAG_NAME + "|CanPlaceOn" ) instanceof ListTag ) {
620- tag .put ("CanPlaceOn" , ConverterRegistry .convertToTag (ConverterRegistry .convertToValue (tag .get (NBT_TAG_NAME + "|CanPlaceOn" ))));
621- tag .remove (NBT_TAG_NAME + "|CanPlaceOn" );
624+ tag .put ("CanPlaceOn" , tag .remove (NBT_TAG_NAME + "|CanPlaceOn" ));
622625 } else if (tag .get ("CanPlaceOn" ) instanceof ListTag ) {
623626 ListTag old = tag .get ("CanPlaceOn" );
624627 ListTag newCanPlaceOn = new ListTag (StringTag .class );
@@ -638,10 +641,7 @@ public Item handleItemToServer(Item item) {
638641 tag .put ("CanPlaceOn" , newCanPlaceOn );
639642 }
640643 if (tag .get (NBT_TAG_NAME + "|CanDestroy" ) instanceof ListTag ) {
641- tag .put ("CanDestroy" , ConverterRegistry .convertToTag (
642- ConverterRegistry .convertToValue (tag .get (NBT_TAG_NAME + "|CanDestroy" ))
643- ));
644- tag .remove (NBT_TAG_NAME + "|CanDestroy" );
644+ tag .put ("CanDestroy" , tag .remove (NBT_TAG_NAME + "|CanDestroy" ));
645645 } else if (tag .get ("CanDestroy" ) instanceof ListTag ) {
646646 ListTag old = tag .get ("CanDestroy" );
647647 ListTag newCanDestroy = new ListTag (StringTag .class );
0 commit comments