demand – Wiki Guide
This Minecraft tutorial explains all about the NBT tag called demand in Minecraft Java Edition (PC/Mac).
What does the demand tag do?
In Minecraft Java Edition, the demand NBT tag allows you to set the demand level for a trade. Why is the demand tag important? Well, the villager can increase the price of the first buy item in the trade if the demand and priceMultiplier tags are positive.
A negative value indicates negative demand for this trade and that players have been trading other items with the villager. A positive value indicates positive demand for this trade and that players have been completing this trade more (relative to the other trades offered by the villager).
TIP: When the villager is raising prices based on demand, the price of the first buy item can not exceed the stack size of the item. The game will automatically enforce this price limit.
Which entities use the demand tag?
The demand tag is used by the following entities in Minecraft:
Entity | Description (Minecraft Entity Value) |
Command Examples |
---|---|---|
Villager (minecraft:villager) |
Example (or NBT Tags)
|
Example
Let’s take a look at an example of how to use the demand tag in Minecraft Java Edition 1.18.
In this example, we are going to summon two villagers. Both villagers will buy 7 emeralds and sell 3 gold blocks with a priceMultiplier of 0.05f. For the first villager, we will set our demand to 15. For the second villager, we will set our demand to 5 which is lower.
First Villager with demand of 15
Command:
/summon villager ~ ~1 ~ {VillagerData:{profession:farmer,level:2,type:plains},
Offers:{Recipes:[{buy:{id:emerald,Count:7},
sell:{id:gold_block,Count:3},
priceMultiplier:0.05f,demand:15}]}}
Price Calculation:
price increase = priceMultiplier x demand x price 0.05 x 15 x 7 = 5 (price increase is 5) New price = price + price increase 7 + 5 = 12 (new price is 12)
Second Villager with demand of 5
Command:
/summon villager ~ ~1 ~ {VillagerData:{profession:farmer,level:2,type:plains},
Offers:{Recipes:[{buy:{id:emerald,Count:7},
sell:{id:gold_block,Count:3},
priceMultiplier:0.05f,demand:5}]}}
Price Calculation:
price increase = priceMultiplier x demand x price 0.05 x 5 x 7 = 1 (price increase is 1) New price = price + price increase 7 + 1 = 8 (new price is 8)
As you can see, the first villager with a demand level of 15 charges a higher price of 12 emeralds than the second villager with a lower demand level of 5 who only charges 8 emeralds. One final note: when calculating the price increase, always round down to the nearest integer value. So in the case of the first villager with the price calculation of (0.05 x 15 x 7), the exact result is 5.25, but it is then rounded down to 5 and the second villager with the price calculation of (0.05 x 5 x 7), the exact result is 1.75, but it is then rounded down to 1.
Note:Â This example only shows the effects of the demand tag changing. It does not take into account villager gossip.
Demand does not affect the second buy item!
Just to demonstrate that only the first buy item is affected by the demand, let’s add a second buy item of 7 diamonds to each of the trades. This is what you would see when you open the Villager Trade menu:
First Villager with demand of 15
Second Villager with demand of 5
As you can see, the demand only affects the price of the first buy item (ie: emeralds), but does not affect the price of the second buy item (ie: diamonds). In this example, the amount of diamonds required is always 7 regardless of the demand.