mojira.dev
MC-108074

Receiving item from villager counts as crafting

The bug

When you trade an item with a villager the crafting stat for the received item increases.

How to reproduce

  1. Summon a villager

    /summon villager ~ ~ ~ {NoAI:1b,Offers:{Recipes:[{buy:{id:"stone",Count:1b},sell:{id:"stone",Count:1b},maxUses:2147483647}]}}
  2. Setup the scoreboard objective

    /scoreboard objectives add craftedStone minecraft.crafted:minecraft.stone
    /scoreboard objectives setdisplay sidebar craftedStone
  3. Trade with the villager
    → The score increases

The reason

The following is based on a decompiled version of Minecraft 1.10 using MCP 9.30.

The method net.minecraft.inventory.SlotMerchantResult.onCrafting(ItemStack) calls the method net.minecraft.item.ItemStack.onCrafting(World, EntityPlayer, int).

Linked issues

Attachments

Comments 15

Confirmed that this bug is still reproducible in 1.15.2 

For scoreboards, is there a workaround or another trade state we can track to keep our score-based datapacks accurate?

Confirmed in 1.16.1 and 20w29a.

Can confirm in 21w03a.

Can confirm in 21w05a.

Can confirm in 21w06a.

5 more comments

Can confirm in 1.18.1.

Can confirm in 1.18.2.

Can confirm in 1.19 and 22w24a.

Can confirm in 1.19.2.

Can confirm in 1.21.4.

Marcono1234

(Unassigned)

Confirmed

Platform

Low

Statistics

crafting, trade, villager

Minecraft 1.10.2, Minecraft 16w39c, Minecraft 1.11, Minecraft 16w50a, Minecraft 1.11.1, , 1.19, 22w24a, 1.19.2, 1.20.1, 1.21.4

Retrieved