TradePrices 5.46.0
Price changes of trades for a particular player (https://minecraft.wiki/w/Trading#Sale_prices), only on the first price of each trade:
- Reputation (villagers, see
Gossips): minus floor(price multiplier x reputation). Bedrock rule: a negative reputation doesn't raise prices, it only cancels positive gossip. Curing a zombie villager gives major + minor positive gossip, e.g. 5 x 20 + 25 = 125 reputation: -6 for a 0.05 multiplier trade. - Hero of the Village (villagers and, in Bedrock, wandering traders): minus 30% of the base price plus 6.25% per level above I, rounded down but at least 1. Bedrock only gives Hero of the Village I.
The result is at least 1 and at most the stack size. Demand is not implemented.
Constants
HERO_DISCOUNT
php
public const HERO_DISCOUNT = 0.3HERO_DISCOUNT_PER_LEVEL
php
public const HERO_DISCOUNT_PER_LEVEL = 0.0625Methods
applyHeroDiscount()
php
public static function applyHeroDiscount(int $price, int $heroLevel, int $maxStackSize = 64) : intPrice after the Hero of the Village discount of the given level (0 = no effect).
getBuyACount()
php
public static function getBuyACount(\pocketmine\entity\npc\TradeOffer $offer, ?\pocketmine\player\Player $player, ?\pocketmine\entity\npc\Trader $trader = null) : intNumber of items of the first price the player pays for one trade with the trader.
getPrice()
php
public static function getPrice(int $basePrice, float $priceMultiplier, int $reputation, int $heroLevel, int $maxStackSize = 64) : intFirst price of a trade for a player with the given reputation and Hero of the Village level (0 = none).
