mojira.dev
MC-99189

Client overrides map data of map with id 0 when a new map is created

The bug

When you have already a map with id 0 and create a new map, the map with id 0 stops updating. Reloading the world fixes this.

Video showing the bug

How top reproduce

  1. If a map with id 0 exists already you can use

    /give @p filled_map

    Otherwise create a new map by right clicking with an empty map

  2. Make sure the player marker moves when you move

  3. Create another map

  4. Look at the map with id 0 again and move around
    → It does not update anymore

The reason

The following is based on a decompiled version of Minecraft 1.10 using MCP 9.30.

The reason for this is that the method net.minecraft.item.ItemEmptyMap.onItemRightClick(ItemStack, World, EntityPlayer, EnumHand) currently creates server- and client-side a MapData object and stores it. This should not happen client-side because the client does not store the map id and uses therefor always 0. The problem is that if a map with the id 0 already existed, the net.minecraft.client.gui.MapItemRenderer registered it already, but because of the new map being generated with the id 0, the old map gets overridden. The MapItemRenderer refers however still to the old MapData which is not updated anymore (intended). The client should probably not create a MapData object in the first place.

Possible fix

public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    // The following is the new method content
    --itemStackIn.stackSize;
    
    if (worldIn.isRemote) {
        return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
    }
    else {
        ItemStack itemstack = new ItemStack(Items.FILLED_MAP, 1, worldIn.getUniqueDataId("map"));
        String s = "map_" + itemstack.getMetadata();
        MapData mapdata = new MapData(s);
        worldIn.setItemData(s, mapdata);
        mapdata.scale = 0;
        mapdata.calculateMapCenter(playerIn.posX, playerIn.posZ, mapdata.scale);
        mapdata.dimension = (byte)worldIn.provider.getDimensionType().getId();
        mapdata.trackingPosition = true;
        mapdata.markDirty();

        if (itemStackIn.stackSize <= 0)
        {
            return new ActionResult(EnumActionResult.SUCCESS, itemstack);
        }
        else
        {
            if (!playerIn.inventory.addItemStackToInventory(itemstack.copy()))
            {
                playerIn.dropItem(itemstack, false);
            }

            playerIn.addStat(StatList.getObjectUseStats(this));
            return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
        }
    }
}

Linked issues

Comments 43

[Mod] redstonehelper

Your description is very hard to understand. Please provide a better one.

sry i can only german. and this is whit Translater

could you then perhaps add screenshots showing the issue?

give me time i make it
5min

ähm can i make a video? it better to show

33 more comments

Is ok

Is this still an issue in the latest snapshot 16w44a? If so please update the affected versions.

This is an automated comment on any open or reopened issue with out-of-date affected versions.

Confirmed for 1.13.1.

Cannot reproduce in 21w40a.

[Mod] markderickson

This was fixed in version 20w46a 🙂

Eisklinge20

marcono1234

(Unassigned)

Confirmed

(Unassigned)

client, filled_map, map

Minecraft 1.9, Minecraft 1.9.4, Minecraft 16w39c, Minecraft 1.11.2, Minecraft 1.12.2, Minecraft 18w16a, Minecraft 1.13.1, 20w07a

20w46a

Retrieved