Mojira Archive
MC-94682

Loot table creation message for spectators displays twice for entities

The bug

When a player in spectator mode right clicks a container entity (currently only MinecartChest and HopperMinecart) the "Unable to open. Loot not generated yet." message is printed twice.

Note: This message has also one space too much at the end.

How to reproduce with MCP (1.11+) (easy)

  1. Locate net.minecraft.entity.player.EntityPlayerMP.displayGUIChest(IInventory chestInventory).
  2. Change the true in the following line to false.
    this.addChatComponentMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)), true);
  3. Start Minecraft
  4. Summon for example a MinecartChest
    /summon chest_minecart ~ ~ ~ {LootTable:"chests/simple_dungeon"}
    
  5. Switch to Spectator mode
  6. Right-click the MinecartChest

How to reproduce (1.11+) (advanced)

Note: The following steps will cause the original version folder to be deteled

  1. Open the %appdata%\.minecraft\versions directory
  2. Copy the folder of the latest version and rename the copied folder to "MC-94682"
  3. Open the copied folder and apply [Mod] Pokechu22's modification (requires Python)
  4. Rename the .jar file to "MC-94682"
  5. Open the .json file in the copied folder with a text editor
    1. Set "MC-94682" as id
    2. Remove the contents of the downloads key at the end of the the file
  6. Start Minecraft
  7. Select the version called "MC-94682"
  8. Summon for example a MinecartChest
    /summon chest_minecart ~ ~ ~ {LootTable:"chests/simple_dungeon"}
    
  9. Switch to Spectator mode
  10. Right-click the MinecartChest

Delete the folder of the version you modified again and rename the copy to the original name

The reason

The following is based on a decompiled version of Minecraft 1.9 using MCP 9.24 beta.

The reason why this happens is because the method net.minecraft.client.multiplayer.PlayerControllerMP.func_187097_a(EntityPlayer, Entity, ItemStack, EnumHand) returns EnumActionResult.PASS for players in spectator mode. Because of this the player right clicks with his main- and offhand on the entity. This could be solved by having the method net.minecraft.client.Minecraft.rightClickMouse() in general run only for the mainhand if the player is in spectator mode.