mojira.dev
MC-64119

stat.drop wont increase when Player throws Items out of his Inventory screen

I was messing around with a stat.drop scoreboard and I noticed that the stat wont increase when a Player is in an Inventory screen an throws some Items either with drag'n'drop or by hovering over an Item and pressing Q (drop).
Also, it wont give a player 20 points when he drops 20 Items at once via ctrl+Q (drop)

Fix appreciated 🙂

~ Halbzwilling


Code analysis by @unknown can be found in this comment.

Linked issues

Comments

marcono1234

Confirmed for

  • 14w30c

  • 14w31a

  • Minecraft 1.8-pre 2

  • 1.8.3 because of MC-79097

Also relates to:

Dakotah Intriglia

Can confirm for 14w32

Jean-Baptiste Martin

Confirmed for 1.8

Bob Joe

Can confirm for 1.8.5 on Mac OS 10.8.5

Ely G

Confirmed for 15w47c

marcono1234

Confirmed for

  • 16w05b

Please link to this comment in the description

The following is based on a decompiled version of Minecraft 1.8 using MCP. All method and class names are the ones used in the decompiled version.

The reason why this happens is because different methods are called depending on whether the player has his inventory or any GUI open or not.
When the player throws an item while having a GUI open, the public EntityItem dropPlayerItemWithRandomChoice(ItemStack itemStackIn, boolean p_71019_2_) method of the net.minecraft.entity.player.EntityPlayer class is called.
This method should probably look like this:

/**
 * Args: itemstack, flag
 */
public EntityItem dropPlayerItemWithRandomChoice(ItemStack itemStackIn, boolean p_71019_2_)
{
	// Changed this
	//return this.func_146097_a(itemStackIn, false, false);
	return this.func_146097_a(itemStackIn, false, p_71019_2_);
}

The reason for this is that the argument p_146097_3_ of the method public EntityItem func_146097_a(ItemStack p_146097_1_, boolean p_146097_2_, boolean p_146097_3_) indicates whether or not the item was thrown by the player or got created in any other way.
So in theory this should also fix a bug where the achievement "Diamonds to you!" does not work if the player throws the diamond while having a GUI open.

Asteraoth

Confirmed for 1.9.4

Asteraoth

Confirmed for 16w20a

Roy Sajima

Confirmed for 1.10-pre1

SunCat

Fixed for 16w42a

Halbzwilling

(Unassigned)

Confirmed

Minecraft 14w30c, Minecraft 1.8, Minecraft 1.8.3, Minecraft 1.8.5, Minecraft 15w47c, Minecraft 16w05b, Minecraft 1.9.4, Minecraft 16w20a, Minecraft 1.10 Pre-Release 1

Minecraft 16w42a

Retrieved