Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-260378

Code: ListTag.getLongArray does not work

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • None
    • 1.19.3
    • None
    • Plausible
    • (Unassigned)

      Getting a long array from the `ListTag` does not work as intended. A LongArrayTag has the id 12. The method getLongArray checks if the id of the tag is 11, which will never happen. So the result will be a new empty long array, unless the tag actually has the id 11 (which will cause a cast exception).

      Source in net.minecraft.nbt.ListTag: 

         public long[] getLongArray(int p_177992_) {
            if (p_177992_ >= 0 && p_177992_ < this.list.size()) {
               Tag tag = this.list.get(p_177992_);
               if (tag.getId() == 11) {
                  return ((LongArrayTag)tag).getAsLongArray();
               }
            }
      
            return new long[0];
         }

      I doubt this can be reproduced using the game itself. It should be an issue fix as well, just replace 11 with 12. Hope this is the right place to report an issue like this.

            Unassigned Unassigned
            CreativeMD Matthias H.
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: