VillagerTrades
Importing the class
If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to import it. Simply add the import at the top of the file.
Description
Members
addTrade(profession as VillagerProfession, villagerLevel as int, offerGenerator as BiFunction<MerchantOffer, Entity, RandomSource>)
Adds a new custom trade with the selling and buying items determined by the custom MerchantOffer generator.
The function will only run when the villager resolves the trade.
The function will only run when the villager resolves the trade.
Parameters:
villagerLevel: int
Type: int
- The level the Villager needs to be. offerGenerator: BiFunction<MerchantOffer, Entity, RandomSource>
Type: BiFunction<MerchantOffer, Entity, RandomSource>
- A generator method to make a new MerchantOffer. addTrade(profession as VillagerProfession, villagerLevel as int, emeralds as int, forSale as ItemStack, maxTrades as int, xp as int, priceMult as float = 1.0)
Adds a Villager Trade for emeralds for an Item. An example being, giving a villager 2 emeralds for an arrow.
Parameters:
villagerLevel: int
Type: int
- The level the Villager needs to be. emeralds: int
Type: int
- The amount of Emeralds. maxTrades: int
Type: int
- How many times can this trade be done. xp: int
Type: int
- How much Experience is given by trading. priceMult: float
(optional) Type: float
- When this trade is discounted, how much should it be discounted by.
Default Value: 1.0
addTrade(profession as VillagerProfession, villagerLevel as int, input1 as ItemStack, forSale as ItemStack, maxTrades as int, xp as int, priceMult as float = 1.0)
Adds a Villager Trade for an Item for an Item. An example being, giving a villager 2 diamonds for an arrow.
Parameters:
villagerLevel: int
Type: int
- The level the Villager needs to be. maxTrades: int
Type: int
- How many times can this trade be done. xp: int
Type: int
- How much Experience is given by trading. priceMult: float
(optional) Type: float
- When this trade is discounted, how much should it be discounted by.
Default Value: 1.0
addTrade(profession as VillagerProfession, villagerLevel as int, input1 as ItemStack, input2 as ItemStack, forSale as ItemStack, maxTrades as int, xp as int, priceMult as float = 1.0)
Adds a Villager Trade for two Items for an Item. An example being, giving a villager 2 diamonds and 2 dirt for an arrow.
Parameters:
villagerLevel: int
Type: int
- The level the Villager needs to be. maxTrades: int
Type: int
- How many times can this trade be done. xp: int
Type: int
- How much Experience is given by trading. priceMult: float
(optional) Type: float
- When this trade is discounted, how much should it be discounted by.
Default Value: 1.0
addTrade(profession as VillagerProfession, villagerLevel as int, trade as ItemListing)
Adds the specified VillagerTrades.ItemListing trade.
Parameters:
villagerLevel: int
Type: int
- The level the Villager needs to be. addWanderingTrade(rarity as int, trade as ItemListing)
Adds the specific VillagerTrades.ItemListing trade to the Wandering Trader
Parameters:
rarity: int
Type: int
- The rarity of the Trade. Valid options are 1
or 2
. A Wandering Trader can only spawn with a single trade of rarity 2
. addWanderingTrade(rarity as int, emeralds as int, forSale as ItemStack, maxTrades as int, xp as int)
Adds a Wandering Trader Trade for emeralds for an Item. An example being, giving a Wandering Trader 2 emeralds for an arrow.
Parameters:
rarity: int
Type: int
- The rarity of the Trade. Valid options are 1
or 2
. A Wandering Trader can only spawn with a single trade of rarity 2
. emeralds: int
Type: int
- The amount of Emeralds. maxTrades: int
Type: int
- How many times can this trade be done. xp: int
Type: int
- How much Experience is given by trading. addWanderingTrade(rarity as int, price as IItemStack, forSale as IItemStack, maxTrades as int, xp as int)
Adds a Wandering Trader Trade for emeralds for an Item. An example being, giving a Wandering Trader 2 emeralds for an arrow.
Parameters:
rarity: int
Type: int
- The rarity of the Trade. Valid options are 1
or 2
. A Wandering Trader can only spawn with a single trade of rarity 2
. maxTrades: int
Type: int
- How many times can this trade be done. xp: int
Type: int
- How much Experience is given by trading. removeAllTrades(profession as VillagerProfession, villagerLevel as int)
Removes all the trades for the given profession and villagerLevel
Parameters:
villagerLevel: int
Type: int
- The level the Villager needs to be. removeAllWanderingTrades(rarity as int)
Removes all wandering trades of the given rarity
Parameters:
rarity: int
Type: int
- The rarity of the Trade. Valid options are 1
or 2
. A Wandering Trader can only spawn with a single trade of rarity 2
. removeBasicTrade(profession as VillagerProfession, villagerLevel as int, forSale as IItemStack, price as IItemStack = <item:minecraft:air>, price2 as IItemStack = <item:minecraft:air>)
Removes a
BasicTrade
Villager trade. BasicTrades
are trades that allow any item, to any other item. It is only really used for mod recipes and is not used for any vanilla villager trade. Parameters:
villagerLevel: int
Type: int
- The level the Villager needs to be. removeDyedArmorForEmeraldsTrade(profession as VillagerProfession, villagerLevel as int, buyingItem as Item)
Removes a Villager trade for Items for Dyed leather armor. An example being, giving a villager Leather Leggings and 3 Emeralds and getting a Blue Dyed Leather Leggings.
Parameters:
villagerLevel: int
Type: int
- The level the Villager needs to be. buyingItem: ItemDefinition
Type: ItemDefinition
- The base ItemStack that a random Dye colour will be applied to. E.G. A leather chestplate with no effect applied. removeEmeraldForItemsTrade(profession as VillagerProfession, villagerLevel as int, tradeFor as Item)
Removes a Villager trade for Emeralds for Items. An example being, giving a villager 20 Wheat and getting an Emerald from the villager.
Parameters:
villagerLevel: int
Type: int
- The level the Villager needs to be. removeEnchantBookForEmeraldsTrade(profession as VillagerProfession, villagerLevel as int)
Removes a Villager trade for an Enchanted Book. An example being, giving a villager Emeralds and getting an Enchanted Book with a random Enchantment.
Parameters:
villagerLevel: int
Type: int
- The level the Villager needs to be. removeEnchantedItemForEmeraldsTrade(profession as VillagerProfession, villagerLevel as int, buyingItem as IItemStack)
Removes a Villager trade for an Enchanted Item. An example being, giving a villager 3 Emeralds and getting an Enchanted Pickaxe.
Parameters:
villagerLevel: int
Type: int
- The level the Villager needs to be. buyingItem: IItemStack
Type: IItemStack
- The ItemStack that the Villager is selling (including any NBT). removeItemsAndEmeraldsToItemsTrade(profession as VillagerProfession, villagerLevel as int, sellingItem as IItemStack, buyingItem as IItemStack)
Removes a Villager trade for Emeralds and Items for Items. An example being, giving a villager 6 uncooked Cod and an Emerald and getting back 6 Cooked Cod.
Parameters:
villagerLevel: int
Type: int
- The level the Villager needs to be. removeItemsForEmeraldsTrade(profession as VillagerProfession, villagerLevel as int, sellingItem as IItemStack)
Removes a Villager trade for Items for Emeralds. An example being, giving a villager an Emerald and getting 4 Pumpkin Pies from the villager.
Parameters:
villagerLevel: int
Type: int
- The level the Villager needs to be. removeSuspiciousStewForEmeraldTrade(profession as VillagerProfession, villagerLevel as int)
Removes a Villager trade for Suspicious Stew. An example being, giving a villager an Emerald and getting a bowl of Suspicious Stew back.
Parameters:
villagerLevel: int
Type: int
- The level the Villager needs to be. removeTippedArrowForItemsAndEmeraldsTrade(profession as VillagerProfession, villagerLevel as int, potionStack as IItemStack, sellingItem as Item)
Removes a Villager trade for Items for an Item with a PotionEffect. An example being, giving a villager an Arrow and an Emerald and getting a Tipped Arrow with night vision.
Parameters:
villagerLevel: int
Type: int
- The level the Villager needs to be. potionStack: IItemStack
Type: IItemStack
- The base ItemStack that a random potion effect will be applied to. E.G. A tipped Arrow with no effect applied. removeTrade(profession as VillagerProfession, villagerLevel as int, buying as IIngredient, selling as IIngredient, secondBuying as IIngredient = <item:minecraft:air>)
Removes the specified trade for the given profession and villagerLevel.
Parameters:
villagerLevel: int
Type: int
- The level the Villager needs to be. secondBuying: IIngredient
(optional) Type: IIngredient
- The second item that you are giving to the villager. Will default to air if not provided.
Default Value: <item:minecraft:air>
removeTradesBuying(profession as VillagerProfession, villagerLevel as int, buying as IIngredient)
Removes all trades that have the specified item as the buying item for the given profession and villagerLevel.
Parameters:
villagerLevel: int
Type: int
- The level the Villager needs to be. removeTradesBuying(profession as VillagerProfession, villagerLevel as int, buying as IIngredient, secondBuying as IIngredient)
Removes all trades that have the specified items as the buying items for the given profession and villagerLevel.
Parameters:
villagerLevel: int
Type: int
- The level the Villager needs to be. secondBuying: IIngredient
Type: IIngredient
- The second item that you are giving to the villager. Will default to air if not provided. removeTradesSelling(profession as VillagerProfession, villagerLevel as int, selling as IIngredient)
Removes all trades that sell the specified item for the given profession and villagerLevel.
Parameters:
villagerLevel: int
Type: int
- The level the Villager needs to be. removeTreasureMapForEmeraldsTrade(profession as VillagerProfession, villagerLevel as int)
Removes a Villager trade for a Map. An example being, giving a villager 13 Emeralds and getting a Map to a structure.
Parameters:
villagerLevel: int
Type: int
- The level the Villager needs to be. removeWanderingTrade(rarity as int, tradeFor as IIngredient)
Removes a Wandering Trader trade for Emeralds for Items. An example being, giving a Wandering Trader 2 Emeralds for an Arrow.
Parameters:
rarity: int
Type: int
- The rarity of the Trade. Valid options are 1
or 2
. A Wandering Trader can only spawn with a single trade of rarity 2
.