primaryPrice
public net.minecraft.world.item.ItemStack primaryPrice()
Returns the value of the
primaryPrice
record component.- Returns:
- the value of the
primaryPrice
record component
net.minecraft.world.entity.npc.VillagerTrades.ItemListing
VillagerTrades.EmeraldForItems
, but they aren't accessible.
Instead of widening the access of those classes or recreating them, this class was added to serve a basic trading implementation.
To register a trade, just call
TradeRegistry.registerVillagerTrade(net.minecraft.world.entity.npc.VillagerProfession, int, VillagerTrades.ItemListing...)
or
TradeRegistry.registerTradeForWanderingTrader(boolean, VillagerTrades.ItemListing...)
.
SimpleTrade(net.minecraft.world.item.ItemStack primaryPrice,
net.minecraft.world.item.ItemStack secondaryPrice,
net.minecraft.world.item.ItemStack sale,
int maxTrades,
int experiencePoints,
float priceMultiplier)
final boolean
int
experiencePoints
record component.@Nullable net.minecraft.world.item.trading.MerchantOffer
getOffer(net.minecraft.world.entity.Entity entity,
net.minecraft.util.RandomSource random)
final int
hashCode()
int
maxTrades
record component.float
priceMultiplier
record component.net.minecraft.world.item.ItemStack
primaryPrice
record component.net.minecraft.world.item.ItemStack
sale()
sale
record component.net.minecraft.world.item.ItemStack
secondaryPrice
record component.final String
toString()
VillagerTrades.TRADES
.primaryPrice
- The first price a player has to pay to get the 'sale' stack.secondaryPrice
- A optional, secondary price to pay as well as the primary one. If not needed just use ItemStack.EMPTY
.sale
- The ItemStack which a player can purchase in exchange for the two prices.maxTrades
- The amount of trades one villager or wanderer can do. When the amount is surpassed, the trade can't be purchased anymore.experiencePoints
- How much experience points does the player get, when trading. Vanilla uses between 2 and 30 for this.priceMultiplier
- How much should the price rise, after the trade is used. It is added to the stack size of the primary price. Vanilla uses between 0.05 and 0.2.getOffer
in interface net.minecraft.world.entity.npc.VillagerTrades.ItemListing
Objects::equals(Object,Object)
; primitive components are compared with '=='.primaryPrice
record component.primaryPrice
record componentsecondaryPrice
record component.secondaryPrice
record componentsale
record component.sale
record componentmaxTrades
record component.maxTrades
record componentexperiencePoints
record component.experiencePoints
record componentpriceMultiplier
record component.priceMultiplier
record component