mojira.dev
MC-160901

Using an item while looking at an entity is no longer possible

The bug

It is no longer possible use items while looking at an entity.

This is caused by MC-127094 being fixed.

To reproduce

  1. Look at an entity

  2. Get some food

  3. Make sure you're hungry

  4. Try to eat
    → ❌ That doesn't work

Affected Items

(List may be incomplete)

  • Shields

  • Splash potions

  • Milk buckets

  • Honey bottles

  • Buckets (In Creative; milking cows/mooshrooms)

  • Bowls (In Creative; milking red/brown mooshrooms)

  • Bows

  • Crossbows (Loaded/Unloaded)

  • Tridents

  • Empty maps

  • Snowballs

  • Eggs

  • Food

  • Potions

  • Lingering potions (Same as splash potions)

  • Bottle o' Enchanting

  • Armor (Prevents players from equipping)

  • Fishing rods

Linked issues

Comments 6

DrownedZombie

Please add some of these to the Affected Items:

  • Potions

  • Lingering potions (Same as splash potions)

  • Bottle o' Enchanting

  • Armor (Prevents players from equipping)

This issue may have "temporarily fixed" the issue MC-141494 as the items are no longer used. Though if this issue is fixed, the issue MC-141494 would return.

TheBoy358

Confirmed in 19w38a and 19w38b.

liach

This issue appears to be from the "startUseItem" (using 19w39a obfuscation map names for research) method in Minecraft class.

Snippet:

switch (this.hitResult.getType()) {
                    case ENTITY: {
                        EntityHitResult entityHitResult_1 = (EntityHitResult)this.hitResult;
                        Entity entity_1 = entityHitResult_1.getEntity();
                        if (this.gameMode.interactAt(this.player, entity_1, entityHitResult_1, interactionHand_1) == InteractionResult.SUCCESS || this.gameMode.interact(this.player, entity_1, interactionHand_1) == InteractionResult.SUCCESS) {
                            this.player.swing(interactionHand_1);
                        }
                        return; // This forces to skip item use logic; compare to block one below
                    }
                    case BLOCK: {
                        BlockHitResult blockHitResult_1 = (BlockHitResult)this.hitResult;
                        int int_1 = itemStack_1.getCount();
                        InteractionResult interactionResult_1 = this.gameMode.useItemOn(this.player, this.level, interactionHand_1, blockHitResult_1);
                        if (interactionResult_1 == InteractionResult.SUCCESS) {
                            this.player.swing(interactionHand_1);
                            if (!itemStack_1.isEmpty() && (itemStack_1.getCount() != int_1 || this.gameMode.hasInfiniteItems())) {
                                this.gameRenderer.itemInHandRenderer.itemUsed(interactionHand_1);
                            }
                            return;
                        }
                        if (interactionResult_1 != InteractionResult.FAIL) break;
                        return;
                    }
                }

As you can see, the entity block forces to skip the logic for item interaction even though two types of entity interactions may request to "PASS" instead of "FAIL".

Suggested:

case ENTITY: {
                        EntityHitResult entityHitResult_1 = (EntityHitResult)this.hitResult;
                        Entity entity_1 = entityHitResult_1.getEntity();
                        InteractionResult result1 = this.gameMode.interactAt(this.player, entity_1, entityHitResult_1, interactionHand_1);
                        InteractionResult result2;
                        if (result1 == InteractionResult.SUCCESS || (result2 = this.gameMode.interact(this.player, entity_1, interactionHand_1)) == InteractionResult.SUCCESS) {
                            this.player.swing(interactionHand_1);
                        }
                        if (result1 == InteractionResult.PASS && result2 == InteractionResult.PASS) {
                            break; // Continue to item use logic
                        }
                        return;
                    }
Alex Gonzalez

This also causes the Zombie Doctor advancement to be impossible

violine1101

That I cannot confirm. You just cannot look directly at the zombie villager while curing it, but you can throw a potion of weakness at it through other means. Feeding it a golden apple works as well.

wan6845

Affects bedrock edition

violine1101

coschevi

Confirmed

Important

Player

mob

19w37a, 19w38b, 19w39a, 19w40a

19w42a

Retrieved