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.
Linked issues
is duplicated by 2
Attachments
Comments 24
No. The maps display fine, but a banner placed in the last map pixel on any edge can't be marked. I made a quick example in a superflat creative world to better demonstrate it:
[media]
The pink banners can be marked on their respective maps. The white and black banners can't be marked on either map.
In this case, with the maps zoomed all the way in, it's easily circumventable by just moving the banner over a block, but it's always the outer map-pixel, so on a max zoomed out map it's a 16-block strip on each side of the map, for a total gap of 32 blocks. That can be a major problem if you happened to build right on the edge!
The world itself (for 19w08b) is attached if you want to see for yourself.
Does MC-144121 describe your issue?