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);
        }
    }
}

Related issues

Comments

migrated

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

migrated

sry i can only german. and this is whit Translater

migrated

could you then perhaps add screenshots showing the issue?

migrated

give me time i make it
5min

migrated

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

migrated

sure

migrated

i can the video not uplode. is to big

migrated

have you a email ? i sent you
or have you a idee?

migrated

upload it to youtube or something, you can mark it is "not shown", if you can't, then a message again, I'll give you my g-mail and I'll upload it then

migrated

i have a Facebook Gaming fanpage. name is eisklinge20
is this ok?

migrated

send a message

migrated

OK on facebook it lasts too long. would be to be made nevertheless better about Gmail

migrated

ahhh ok ok i understood . now I will send the video via Gmail . have the address

migrated

ok, I see you're having trouble sending the mail too (took over 8 minutes) so could you perhaps attach screenshots of the issue?

migrated

it is equally ready. then this is a left too goggle drive says Gmail.

migrated
migrated

access...

migrated

ok would be released

migrated

over 1GB, a bit much, isn't it?

migrated

sry say it fraps. or know you a better program?

migrated

I use FRAPS too when I record, but 20 seconds is 900MB, so your recording is absurbly long for a bug report

migrated

ah ok sry is me first video for Bug report. the next is better

migrated

ah, at least the problem is clear in your video

migrated

this is good

migrated

there, reworded for you, and linked the video in the description

migrated

yes

marcono1234

Was the first map you created in this setup also the very first map you created in this world? If you can't remember, press F3 + H and hover over the map, the name should contains "(#0358/0)".

marcono1234

The following assumes that this report is about the first map created in a world, which stops working after another map is created. A better summary would be "Client overrides map data of map with id 0 when a new map is created"


Please link to this comment in the description

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);
        }
    }
}

Note: This change should not cause any problems because the client does not generate a MapData object unless it receives a packet from a server. All rendering methods test as well if the MapData object is not null before trying to render it. Not creating the new item for the client should work as well because the server sends a packet and the client does not know the meta data anyway.
Edit: Client does not create a filled map, which means this note is redundant.

marcono1234

A better summary would be "Client overrides map data of map with id 0 when a new map is created"

Can I please become the reporter of this report?

migrated

Ähm i have Minecraft Not more on my Pc. Sry but Minecraft make me Not more Fun.

marcono1234

Oh sorry, I though you were inactive. Do you mind if I became the reporter (the moderators would change that)?

migrated

Provided the translator now right has made, you would like to become you the leading Supporter of my old problem.

Have I understood so properly?

marcono1234

Not quite, I assume you are German so I will try it in German.

Du hast ja diesen Fehlerbericht erstellt. Die Moderatoren hier können der Ersteller des Berichtes ändern, dadurch könnte ich dann den Bericht bearbeiten und weiter verwalten 🙂
Ich hoffe du hast nichts dagegen

migrated

ahhhh ok.
I see no problem. That you are welcome to make

migrated

and yes i am german. my englisch is not good.
that is the reason why I have to rely on translators

migrated

Changed reporter to @unknown.

marcono1234

@unknown, @unknown is still the reporter

migrated

My phone didn't save the edit 😞 fixed.

migrated

Is ok

migrated

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.

migrated

Confirmed for 1.13.1.

ampolive

Cannot reproduce in 21w40a.

[Mod] markderickson

This was fixed in version 20w46a 🙂

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