primaryPrice
public net.minecraft.world.item.ItemStack primaryPrice()
Returns the value of the
primaryPrice record component.- Returns:
- the value of the
primaryPricerecord component
net.minecraft.world.entity.npc.VillagerTrades.ItemListingVillagerTrades.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 booleanintexperiencePoints record component.@Nullable net.minecraft.world.item.trading.MerchantOffergetOffer(net.minecraft.world.entity.Entity entity,
net.minecraft.util.RandomSource random) final inthashCode()intmaxTrades record component.floatpriceMultiplier record component.net.minecraft.world.item.ItemStackprimaryPrice record component.net.minecraft.world.item.ItemStacksale()sale record component.net.minecraft.world.item.ItemStacksecondaryPrice record component.final StringtoString()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.ItemListingObjects::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