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

Destroyed dropped Minecart items use entity name

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Minecraft 16w32a
    • Minecraft 16w03a, Minecraft 16w04a, Minecraft 16w05b, Minecraft 16w06a, Minecraft 16w07a, Minecraft 16w07b, Minecraft 1.9 Pre-Release 1, Minecraft 1.9 Pre-Release 2, Minecraft 1.9 Pre-Release 3, Minecraft 1.9 Pre-Release 4, Minecraft 1.9, Minecraft 1.9.1 Pre-Release 1, Minecraft 1.9.1 Pre-Release 2, Minecraft 1.9.1 Pre-Release 3, Minecraft 1.9.1, Minecraft 1.9.2, Minecraft 16w15a, Minecraft 16w15b, Minecraft 1.9.3 Pre-Release 1, Minecraft 1.9.3 Pre-Release 2, Minecraft 1.9.3 Pre-Release 3, Minecraft 1.9.3, Minecraft 1.9.4, Minecraft 16w20a, Minecraft 16w21a, Minecraft 16w21b, Minecraft 1.10 Pre-Release 1, Minecraft 1.10 Pre-Release 2, Minecraft 1.10, Minecraft 1.10.2
    • Confirmed
    • Survival

      The bug

      When breaking a minecart (any type) in survival a renamed minecart item is created. In previous versions a renamed minecart was only dropped if the minecart was renamed before.
      Additionally some minecart types have no translation and are displayed as: entity. + Entity type + .name
      Full list:
      entity.MinecartRideable.name
      entity.MinecartFurnace.name
      entity.MinecartTNT.name
      Minecart with Chest
      Minecart with Hopper

      How to reproduce

      Place any type of minecart and break it in Survival mode.

      The reason

      The following is based on decompiled version of Minecraft 1.9 using MCP 9.24 beta. All method and class names are the names used in the decompiled version.

      The reason why this happens is because in previous versions the class net.minecraft.entity.item.EntityMinecart had an extra field for the custom name that would be used for dropping the item (this required a lot of methods to be overridden). In 1.9 minecarts do not have this extra field anymore. The problem is that the method net.minecraft.entity.item.EntityMinecart.killMinecart(DamageSource) uses the method net.minecraft.entity.Entity.getName() to test whether or not the minecart has a custom name. This method will always return a string because this method is used for displaying for example the entity name in the chat. Instead the method of the minecart should test if it has a custom name.

      public void killMinecart(DamageSource source)
      {
          this.setDead();
      
          if (this.worldObj.getGameRules().getBoolean("doEntityDrops"))
          {
              ItemStack itemstack = new ItemStack(Items.minecart, 1);
      
              // Replaced this
              //if (this.getName() != null)
              //{
              //    itemstack.setStackDisplayName(this.getName());
              //}
              if (this.hasCustomName())
              {
                  itemstack.setStackDisplayName(this.getCustomNameTag());
              }
      
              this.entityDropItem(itemstack, 0.0F);
          }
      }
      

        1. 2016-02-16_14.11.28.png
          127 kB
          [Mod] Neko
        2. 2016-06-17_15.30.33.png
          50 kB
          Derek chen
        3. 2017-01-11_13.21.57.png
          68 kB
          Matthew Reynolds

            jeb [Mojang] Jeb (Jens Bergensten)
            marcono1234 Marcono1234
            Votes:
            63 Vote for this issue
            Watchers:
            25 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: