mojira.dev
MC-182814

Drinking honey bottles increases "minecraft.used:minecraft.honey_bottle" by a value of two and runs the "minecraft:consume_item" advancement trigger twice

The Bug:

Drinking honey bottles increases "minecraft.used:minecraft.honey_bottle" by a value of two and runs the "minecraft:consume_item" advancement trigger twice.

Steps to Reproduce:

  1. Create a scoreboard objective for tracking the use of a honey bottle and set it to display on the sidebar by using the commands provided below.

    /scoreboard objectives add UseHoneyBottle minecraft.used:minecraft.honey_bottle
    /scoreboard objectives setdisplay sidebar UseHoneyBottle
  2. Obtain a honey bottle and drink it.

  3. Take note as to whether or not drinking honey bottles increases "minecraft.used:minecraft.honey_bottle" by a value of two and runs the "minecraft:consume_item" advancement trigger twice.

Observed Behavior:

"minecraft.used:minecraft.honey_bottle" increases by a value of two and the "minecraft:consume_item" advancement trigger runs twice.

Expected Behavior:

"minecraft.used:minecraft.honey_bottle" would be increased by a value of one and the "minecraft:consume_item" advancement trigger would only be run once.

Code Analysis:

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

Linked issues

Attachments

Comments 9

Can confirm in 20w46a.

Can confirm in 21w03a.

Can confirm in 21w08b. Video attached.

Can confirm in 21w15a.

Can confirm in 21w16a. I'd like to request ownership of this ticket since the current reporter has been inactive since July 2020. I'm willing to provide all of the necessary information and will keep this report updated.

Code analysis (Yarn mappings)

Honey bottles are a custom item with a food component. The HoneyBottleItem class triggers the criterion in its implementation of the Item#finishUsing method:

@Override
public ItemStack finishUsing(ItemStack stack, World world, LivingEntity user) {
	super.finishUsing(stack, world, user);
	if (user instanceof ServerPlayerEntity serverUser) {
		Criteria.CONSUME_ITEM.trigger(serverUser, stack); // custom item trigger
		serverUser.incrementStat(Stats.USED.getOrCreateStat(this));
	}
}

However, the base implementation of the Item#finishUsing method already triggers the criterion for foods through the player's implementation of the LivingEntity#eatFood method:

@Override
public ItemStack eatFood(World world, ItemStack stack) {
	this.getHungerManager().eat(stack.getItem(), stack);
	this.incrementStat(Stats.USED.getOrCreateStat(stack.getItem()));
	world.playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5f, world.random.nextFloat() * 0.1f + 0.9f);

	if (this instanceof ServerPlayerEntity serverPlayer) {
		Criteria.CONSUME_ITEM.trigger(serverPlayer, stack); // food trigger
	}

	return super.eatFood(world, stack);
}

One recommended fix is to simply remove the unnecessary criterion trigger from the HoneyBottleItem class.

This issue still exists in Minecraft 1.19.4 release candidate 3.

This issue still exists in 1.20.4.

This issue was present in 24w33a but no longer occurs in 24w34a. This issue was fixed in 24w34a.

Loganblahtimes2

Avoma

(Unassigned)

Confirmed

Gameplay

Low

Statistics

consume_item, honey_bottle

1.15.2, 20w19a, 20w21a, 20w22a, 1.16 Pre-release 4, ..., 1.20, 1.20.1, 1.20.4, 23w51b, 1.21

24w34a

Retrieved