mojira.dev
MC-269813

Item count in villager trade offers is restricted to standard max stack sizes by default

When attempting to create a villager with a trade offer that either buys or sells an item with a max stack size above the default allowed size, the trades will not function as expected, being restricted down to the default values.

Steps to Reproduce:

  1. Summon these villagerss

    /summon minecraft:villager ~ ~ ~ {VillagerData:{profession:"minecraft:cleric", level:5}, Offers:{Recipes:[{maxUses:100, sell:{count:99, id:"minecraft:emerald"}, buy:{count:99, id:"minecraft:diamond_sword"}}]}}
    /summon minecraft:villager ~ ~ ~ {VillagerData:{profession:"minecraft:cleric", level:5}, Offers:{Recipes:[{maxUses:100, sell:{count:99, id:"minecraft:diamond_sword"}, buy:{count:99, id:"minecraft:emerald"}}]}}
  2. Open their respective trading UI's

Observed & Expected Results:

❌ - The item the villager is buying will properly show the expected value of 99 for the item, but will be discounted down to the default max size of 64, despite the item not actually being 'discounted'. The item that the villager is selling will simpy be restricted down to the default max stack size. (one for 'non-stackables', and 64 for most items, etc)
✔ - The villager would require the the player have the proper amount of items to buy (not at a discounted price), and be rewarded with the intended amount.

Screenshots/Videos:

[media]

Notes:

  1. This behavior could be intentional based off of the 'fixed' command in the pinned comment.

  2. Related to MC-269700 MC-269684

Attachments

Comments 3

An easy fix without changing the code a bit would be to use this:

summon minecraft:villager ~ ~ ~ {VillagerData:{profession:"minecraft:cleric", level:5}, Offers:{Recipes:[{maxUses:100, sell:{count:99, id:"minecraft:emerald", components:{"minecraft:max_stack_size":99}}, buy:{count:99, id:"minecraft:diamond_sword", components:{"minecraft:max_stack_size":99}}}]}}
/summon minecraft:villager ~ ~ ~ {VillagerData:{profession:"minecraft:cleric", level:5}, Offers:{Recipes:[{maxUses:100, sell:{count:99, id:"minecraft:diamond_sword", components:{"minecraft:max_stack_size":99}}, buy:{count:99, id:"minecraft:emerald", components:{"minecraft:max_stack_size":99}}}]}}

This may not be fixed due to this

That command is probably the intended behavior, this may be invalid or WAI

[Mod] Jingy

(Unassigned)

Community Consensus

Platform

Low

Commands, Trading

component, max_stack_size, villager-trade

24w12a

Retrieved