Skip to content

TradeOffer 5.46.0 ​

final class · pocketmine\entity\npc\TradeOffer · source

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) : self

getBuyA() ​

php
public function getBuyA() : \pocketmine\item\Item

getBuyB() ​

php
public function getBuyB() : ?\pocketmine\item\Item

getMaxUses() ​

php
public function getMaxUses() : int

getNetworkId() ​

php
public function getNetworkId() : int

getPriceMultiplier() ​

php
public function getPriceMultiplier() : float

How much reputation (and demand) changes the first price (see TradePrices).

getSell() ​

php
public function getSell() : \pocketmine\item\Item

getTier() ​

php
public function getTier() : int

Trader level needed for this trade, 0 (novice) to 4 (master).

getTraderExp() ​

php
public function getTraderExp() : int

getUses() ​

php
public function getUses() : int

givesPlayerExp() ​

php
public function givesPlayerExp() : bool

isDisabled() ​

php
public function isDisabled() : bool

setUses() ​

php
public function setUses(int $uses) : void

toNbt() ​

php
public function toNbt(?int $buyACount = null) : \pocketmine\nbt\tag\CompoundTag

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.