TradeOffer 5.46.0
One trade of a villager or wandering trader: the items wanted (buyA, optional buyB), the item given, how many times it can be used before restocking, and the experience it gives the trader (and whether the player gets some). The network ID (TradeOffer::getNetworkId()) is what the client sends in CraftRecipe requests to make this trade; it's unique for the server session.
Serialized like vanilla Bedrock "Recipes" entries (buyA/buyB/sell items, buyCountA/B, maxUses, uses, tier, traderExp, rewardExp, priceMultiplierA/B, demand, netId).
Methods
__construct()
php
public function __construct(\pocketmine\item\Item $buyA, ?\pocketmine\item\Item $buyB, \pocketmine\item\Item $sell, int $maxUses, int $tier, int $traderExp, bool $rewardExp = true, int $uses = 0, float $priceMultiplier = 0.05)fromNbt()
php
public static function fromNbt(\pocketmine\nbt\tag\CompoundTag $nbt) : selfgetBuyA()
php
public function getBuyA() : \pocketmine\item\ItemgetBuyB()
php
public function getBuyB() : ?\pocketmine\item\ItemgetMaxUses()
php
public function getMaxUses() : intgetNetworkId()
php
public function getNetworkId() : intgetPriceMultiplier()
php
public function getPriceMultiplier() : floatHow much reputation (and demand) changes the first price (see TradePrices).
getSell()
php
public function getSell() : \pocketmine\item\ItemgetTier()
php
public function getTier() : intTrader level needed for this trade, 0 (novice) to 4 (master).
getTraderExp()
php
public function getTraderExp() : intgetUses()
php
public function getUses() : intgivesPlayerExp()
php
public function givesPlayerExp() : boolisDisabled()
php
public function isDisabled() : boolsetUses()
php
public function setUses(int $uses) : voidtoNbt()
php
public function toNbt(?int $buyACount = null) : \pocketmine\nbt\tag\CompoundTag