Skip to content
Linguardium edited this page Apr 13, 2020 · 4 revisions

Trades:

Trade Objects are potential trades that will be offered by the trader.

Create a trade object by using makeTrade()

Trades can be set to one of many types by using one of the following methods:

randomEnchantedBookTrade()
  This trade type offers a random enchanted book. This trade type is equivalent to the vanilla librarian trades.

randomEnchantmentItemTrade()
  This trade type randomly enchants the sold item. This trade type is equivalent to the vanilla tool and armor trades.
  This can be used to randomly enchant any enchantable item.

randomDyedItemTrade()
  This trade type randomly dyes the sold item. This trade type is equivalent to the vanilla leatherworker trades.

dyedItemTrade(Integer)
dyedItemTrade(Integer[])
dyedItemTrade(Float[])
  This trade type dyes the sold item to a specific color. Color is provided as an array of float values (0.0-1.0), an array of integer values (0-255, 0-255, 0-255) or an integer value (0xRRGGBB or decimal)

randomEffectItemTrade()
  This trade type applies a random potion effect to an item. The item must support potion effects. Vanilla uses this for tipped arrows and potions.

The above trade types will clear the trade options. These should be applied directly after makeTrade().

Trade Options

randomPrice(Integer, Integer)
randomPrice(Integer)
  Can only be used on randomEnchantmentItemTrade or randomEnchantedBookTrade types.
  Enables random pricing based on enchantment level. sets the (min, max) or (max) values
  
doubleTreasureCost(Boolean)
doubleTreasureCost()
  Can only be applied to randomEnchantedBookTrade.
  Enables or sets whether treasure enchantments will cost double.

enableTreasureEnchants(Boolean)
enableTreasureEnchants()
  Can only be applied to randomEnchantmentItemTrade. 
  Enables or sets whether treasure enchantments will be allowed when randomly enchanting items.

item(Item)
  Sets the sold item. Can provide either an itemstack using LibCD's itemstack builder or a formatted item string.
  See LibCD documentation for item string formatting.

count(Integer)
  (Optional) Sets the number of items sold per transaction. This can also be set in a formatted item string using the item(Item) method. defaults to 1.

price(Integer)
  sets the primary price of the sold item in Emeralds.

price(Array[Item,Item])
price(Item)
  Sets the cost of the trade. supports 1 or 2 Item inputs.

secondPrice(Item)
  (Optional) Sets the secondary item cost. This is useful for random book trades using random pricing. defaults to none.

maxUses(Integer)
  (Optional) Sets the maximum number of times the item may be sold to the player before lockout. defaults to 12.

experience(Integer)
  (Optional) Sets the amount of experience provided to the player for this trade. defaults to 1.

priceMultiplier(Float)
  (Optional) Sets the relationship modifier for the price for this trade. defaults to 0.05 or 0.2 depending on trade type (matches Vanilla)

For example usage, see the example js files

Clone this wiki locally