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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 20w46a
    • Minecraft 1.9, Minecraft 1.9.4, Minecraft 16w39c, Minecraft 1.11.2, Minecraft 1.12.2, Minecraft 18w16a, Minecraft 1.13.1, 20w07a
    • Confirmed
    • (Unassigned)

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

            Unassigned Unassigned
            marcono1234 Marcono1234
            Votes:
            10 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: