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

Banners, player indicator and decorations can not be marked on the outermost pixel of a map

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • Minecraft 19w07a, Minecraft 19w08b, Minecraft 19w09a, 1.15.1, 1.15.2 Pre-Release 1, 1.15.2, 20w09a, 20w13b, 20w14a, 20w15a, 20w16a, 20w17a, 1.16 Pre-release 8, 1.16 Release Candidate 1, 1.16, 1.16.2 Release Candidate 1, 1.16.2 Release Candidate 2, 1.16.2, 1.16.3, 1.16.4, 20w46a, 20w49a, 20w51a, 1.16.5, 21w05a, 21w06a, 21w17a, 21w18a, 1.17 Pre-release 1, 1.17 Pre-release 2, 21w37a, 21w39a, 1.18 Pre-release 4, 1.18.2, 22w15a, 22w16b, 1.19 Pre-release 1, 22w44a, 23w12a, 23w14a, 23w16a, 23w17a, 1.20 Pre-release 1, 1.20 Pre-release 2, 1.20 Pre-release 5, 1.20 Pre-release 7, 1.20 Release Candidate 1, 1.20, 1.20.2 Pre-release 1, 1.20.2, 24w03b, 24w04a, 24w07a, 24w11a, 24w39a
    • Community Consensus
    • Survival
    • Maps
    • Low
    • Platform

      The bug

      A banner within the area represented on the outermost pixel of a map can not be marked. With a freshly crafted map, this is only one block on each side, but as you zoom out it becomes as much as sixteen (thirty-two, when you consider that the next map over has the same problem!)

      Code analysis and fix

      Decompiled code analysis on 1.20.4:

      net.minecraft.item.map.MapState

      The logic and range used to determine if a banner falls within the current map bounds is incorrect.

      in {{private void addIcon}} and public boolean addBanner

      if (f >= -63.0F && g >= -63.0F && f <= 63.0F && g <= 63.0F)
      

      Range >=-63 and <=63 is too narrow and will miss a row of 1 block on each side of the map. This is compounded once the scale is calculated as up to 16 blocks on each side will be missed once the banner coordinate is converted to a float on the 128 block scale of the map. The logic should be >=-64 and <64, this will ensure all positions in all scales are included on the map. The range of blocks on the map if the center of the map is 0,0 is -64 to 63 in both axes.

      Solution:

      if (f >= -64.0F && g >= -64.0F && f < 64.0F && g < 64.0F)
      

      Plus a few changes in the player tracking:
       

      if (f < -64.0f) { b = -128; }
      if (g < -64.0f) { c = -128; }
      if (f >= 64.0f) { b = 127; }
      if (g >= 64.0f) { c = 127; }

       
      and
       

      byte b = (byte)((double)(f*2.0f));
      byte c = (byte)((double)(g*2.0f));

       
      I've made a fabric mod using mixins that fixes this server side if devs are interested.

            Unassigned Unassigned
            Greener greener.ca
            Votes:
            33 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              CHK: