@@ -295,21 +295,16 @@ public Item handleItemToClient(Item item) {
295295 blockEntityTag .putInt ("Base" , 15 - baseTag .asInt ());
296296 }
297297
298- ListTag patternsTag = blockEntityTag .getListTag ("Patterns" );
298+ ListTag < CompoundTag > patternsTag = blockEntityTag .getListTag ("Patterns" , CompoundTag . class );
299299 if (patternsTag != null ) {
300- for (Tag pattern : patternsTag ) {
301- if (!(pattern instanceof CompoundTag )) {
302- continue ;
303- }
304-
305- CompoundTag patternTag = (CompoundTag ) pattern ;
306- NumberTag colorTag = patternTag .getNumberTag ("Color" );
300+ for (CompoundTag pattern : patternsTag ) {
301+ NumberTag colorTag = pattern .getNumberTag ("Color" );
307302 if (colorTag == null ) {
308303 continue ;
309304 }
310305
311306 // Invert color id
312- patternTag .putInt ("Color" , 15 - colorTag .asInt ());
307+ pattern .putInt ("Color" , 15 - colorTag .asInt ());
313308 }
314309 }
315310 }
@@ -324,16 +319,11 @@ public Item handleItemToClient(Item item) {
324319 }
325320 }
326321 // ench is now Enchantments and now uses identifiers
327- ListTag ench = tag .getListTag ("ench" );
322+ ListTag < CompoundTag > ench = tag .getListTag ("ench" , CompoundTag . class );
328323 if (ench != null ) {
329- ListTag enchantments = new ListTag (CompoundTag .class );
330- for (Tag enchEntry : ench ) {
331- if (!(enchEntry instanceof CompoundTag )) {
332- continue ;
333- }
334-
335- CompoundTag entryTag = (CompoundTag ) enchEntry ;
336- NumberTag idTag = entryTag .getNumberTag ("id" );
324+ ListTag <CompoundTag > enchantments = new ListTag <>(CompoundTag .class );
325+ for (CompoundTag enchEntry : ench ) {
326+ NumberTag idTag = enchEntry .getNumberTag ("id" );
337327 if (idTag == null ) {
338328 continue ;
339329 }
@@ -346,7 +336,7 @@ public Item handleItemToClient(Item item) {
346336 }
347337 enchantmentEntry .putString ("id" , newId );
348338
349- NumberTag levelTag = entryTag .getNumberTag ("lvl" );
339+ NumberTag levelTag = enchEntry .getNumberTag ("lvl" );
350340 if (levelTag != null ) {
351341 enchantmentEntry .putShort ("lvl" , levelTag .asShort ());
352342 }
@@ -357,16 +347,11 @@ public Item handleItemToClient(Item item) {
357347 tag .put ("Enchantments" , enchantments );
358348 }
359349
360- ListTag storedEnch = tag .getListTag ("StoredEnchantments" );
350+ ListTag < CompoundTag > storedEnch = tag .getListTag ("StoredEnchantments" , CompoundTag . class );
361351 if (storedEnch != null ) {
362- ListTag newStoredEnch = new ListTag (CompoundTag .class );
363- for (Tag enchEntry : storedEnch ) {
364- if (!(enchEntry instanceof CompoundTag )) {
365- continue ;
366- }
367-
368- CompoundTag entryTag = (CompoundTag ) enchEntry ;
369- NumberTag idTag = entryTag .getNumberTag ("id" );
352+ ListTag <CompoundTag > newStoredEnch = new ListTag <>(CompoundTag .class );
353+ for (CompoundTag enchEntry : storedEnch ) {
354+ NumberTag idTag = enchEntry .getNumberTag ("id" );
370355 if (idTag == null ) {
371356 continue ;
372357 }
@@ -379,7 +364,7 @@ public Item handleItemToClient(Item item) {
379364 }
380365 enchantmentEntry .putString ("id" , newId );
381366
382- NumberTag levelTag = entryTag .getNumberTag ("lvl" );
367+ NumberTag levelTag = enchEntry .getNumberTag ("lvl" );
383368 if (levelTag != null ) {
384369 enchantmentEntry .putShort ("lvl" , levelTag .asShort ());
385370 }
@@ -389,9 +374,9 @@ public Item handleItemToClient(Item item) {
389374 tag .put ("StoredEnchantments" , newStoredEnch );
390375 }
391376
392- ListTag canPlaceOnTag = tag .getListTag ("CanPlaceOn" );
377+ ListTag <?> canPlaceOnTag = tag .getListTag ("CanPlaceOn" );
393378 if (canPlaceOnTag != null ) {
394- ListTag newCanPlaceOn = new ListTag (StringTag .class );
379+ ListTag < StringTag > newCanPlaceOn = new ListTag <> (StringTag .class );
395380 tag .put (NBT_TAG_NAME + "|CanPlaceOn" , canPlaceOnTag .copy ());
396381 for (Tag oldTag : canPlaceOnTag ) {
397382 Object value = oldTag .getValue ();
@@ -412,9 +397,9 @@ public Item handleItemToClient(Item item) {
412397 tag .put ("CanPlaceOn" , newCanPlaceOn );
413398 }
414399
415- ListTag canDestroyTag = tag .getListTag ("CanDestroy" );
400+ ListTag <?> canDestroyTag = tag .getListTag ("CanDestroy" );
416401 if (canDestroyTag != null ) {
417- ListTag newCanDestroy = new ListTag (StringTag .class );
402+ ListTag < StringTag > newCanDestroy = new ListTag <> (StringTag .class );
418403 tag .put (NBT_TAG_NAME + "|CanDestroy" , canDestroyTag .copy ());
419404 for (Tag oldTag : canDestroyTag ) {
420405 Object value = oldTag .getValue ();
@@ -594,16 +579,11 @@ public Item handleItemToServer(Item item) {
594579 blockEntityTag .putInt ("Base" , 15 - baseTag .asInt ()); // invert color id
595580 }
596581
597- ListTag patternsTag = blockEntityTag .getListTag ("Patterns" );
582+ ListTag < CompoundTag > patternsTag = blockEntityTag .getListTag ("Patterns" , CompoundTag . class );
598583 if (patternsTag != null ) {
599- for (Tag pattern : patternsTag ) {
600- if (!(pattern instanceof CompoundTag )) {
601- continue ;
602- }
603-
604- CompoundTag patternTag = (CompoundTag ) pattern ;
605- NumberTag colorTag = patternTag .getNumberTag ("Color" );
606- patternTag .putInt ("Color" , 15 - colorTag .asInt ()); // Invert color id
584+ for (CompoundTag pattern : patternsTag ) {
585+ NumberTag colorTag = pattern .getNumberTag ("Color" );
586+ pattern .putInt ("Color" , 15 - colorTag .asInt ()); // Invert color id
607587 }
608588 }
609589 }
@@ -619,16 +599,11 @@ public Item handleItemToServer(Item item) {
619599 }
620600
621601 // ench is now Enchantments and now uses identifiers
622- ListTag enchantments = tag .getListTag ("Enchantments" );
602+ ListTag < CompoundTag > enchantments = tag .getListTag ("Enchantments" , CompoundTag . class );
623603 if (enchantments != null ) {
624- ListTag ench = new ListTag (CompoundTag .class );
625- for (Tag enchantmentEntry : enchantments ) {
626- if (!(enchantmentEntry instanceof CompoundTag )) {
627- continue ;
628- }
629-
630- CompoundTag entryTag = (CompoundTag ) enchantmentEntry ;
631- StringTag idTag = entryTag .getStringTag ("id" );
604+ ListTag <CompoundTag > ench = new ListTag <>(CompoundTag .class );
605+ for (CompoundTag enchantmentEntry : enchantments ) {
606+ StringTag idTag = enchantmentEntry .getStringTag ("id" );
632607 if (idTag == null ) {
633608 continue ;
634609 }
@@ -641,7 +616,7 @@ public Item handleItemToServer(Item item) {
641616 }
642617 if (oldId != null ) {
643618 enchEntry .putShort ("id" , oldId );
644- NumberTag levelTag = entryTag .getNumberTag ("lvl" );
619+ NumberTag levelTag = enchantmentEntry .getNumberTag ("lvl" );
645620 if (levelTag != null ) {
646621 enchEntry .putShort ("lvl" , levelTag .asShort ());
647622 }
@@ -653,16 +628,11 @@ public Item handleItemToServer(Item item) {
653628 }
654629
655630
656- ListTag storedEnch = tag .getListTag ("StoredEnchantments" );
631+ ListTag < CompoundTag > storedEnch = tag .getListTag ("StoredEnchantments" , CompoundTag . class );
657632 if (storedEnch != null ) {
658- ListTag newStoredEnch = new ListTag (CompoundTag .class );
659- for (Tag enchantmentEntry : storedEnch ) {
660- if (!(enchantmentEntry instanceof CompoundTag )) {
661- continue ;
662- }
663-
664- CompoundTag entryTag = (CompoundTag ) enchantmentEntry ;
665- StringTag idTag = entryTag .getStringTag ("id" );
633+ ListTag <CompoundTag > newStoredEnch = new ListTag <>(CompoundTag .class );
634+ for (CompoundTag enchantmentEntry : storedEnch ) {
635+ StringTag idTag = enchantmentEntry .getStringTag ("id" );
666636 if (idTag == null ) {
667637 continue ;
668638 }
@@ -679,7 +649,7 @@ public Item handleItemToServer(Item item) {
679649 }
680650
681651 enchEntry .putShort ("id" , oldId );
682- NumberTag levelTag = entryTag .getNumberTag ("lvl" );
652+ NumberTag levelTag = enchantmentEntry .getNumberTag ("lvl" );
683653 if (levelTag != null ) {
684654 enchEntry .putShort ("lvl" , levelTag .asShort ());
685655 }
@@ -690,8 +660,8 @@ public Item handleItemToServer(Item item) {
690660 if (tag .getListTag (NBT_TAG_NAME + "|CanPlaceOn" ) != null ) {
691661 tag .put ("CanPlaceOn" , tag .remove (NBT_TAG_NAME + "|CanPlaceOn" ));
692662 } else if (tag .getListTag ("CanPlaceOn" ) != null ) {
693- ListTag old = tag .getListTag ("CanPlaceOn" );
694- ListTag newCanPlaceOn = new ListTag (StringTag .class );
663+ ListTag <?> old = tag .getListTag ("CanPlaceOn" );
664+ ListTag < StringTag > newCanPlaceOn = new ListTag <> (StringTag .class );
695665 for (Tag oldTag : old ) {
696666 Object value = oldTag .getValue ();
697667 String [] newValues = BlockIdData .fallbackReverseMapping .get (value instanceof String
@@ -702,16 +672,16 @@ public Item handleItemToServer(Item item) {
702672 newCanPlaceOn .add (new StringTag (newValue ));
703673 }
704674 } else {
705- newCanPlaceOn .add (oldTag );
675+ newCanPlaceOn .add (new StringTag ( value . toString ()) );
706676 }
707677 }
708678 tag .put ("CanPlaceOn" , newCanPlaceOn );
709679 }
710680 if (tag .getListTag (NBT_TAG_NAME + "|CanDestroy" ) != null ) {
711681 tag .put ("CanDestroy" , tag .remove (NBT_TAG_NAME + "|CanDestroy" ));
712682 } else if (tag .getListTag ("CanDestroy" ) != null ) {
713- ListTag old = tag .getListTag ("CanDestroy" );
714- ListTag newCanDestroy = new ListTag (StringTag .class );
683+ ListTag <?> old = tag .getListTag ("CanDestroy" );
684+ ListTag < StringTag > newCanDestroy = new ListTag <> (StringTag .class );
715685 for (Tag oldTag : old ) {
716686 Object value = oldTag .getValue ();
717687 String [] newValues = BlockIdData .fallbackReverseMapping .get (value instanceof String
@@ -722,7 +692,7 @@ public Item handleItemToServer(Item item) {
722692 newCanDestroy .add (new StringTag (newValue ));
723693 }
724694 } else {
725- newCanDestroy .add (oldTag );
695+ newCanDestroy .add (new StringTag ( oldTag . getValue (). toString ()) );
726696 }
727697 }
728698 tag .put ("CanDestroy" , newCanDestroy );
0 commit comments