VillagerTrades

Importing the class

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

import crafttweaker.api.villagers.VillagerTrades;

Methods

addTrade

Adds a Villager Trade for emeralds for an Item. An example being, giving a villager 2 emeralds for an arrow.

Return Type: void

VillagerTrades.addTrade(profession as MCVillagerProfession, villagerLevel as int, emeralds as int, forSale as ItemStack, maxTrades as int, xp as int, priceMult as float) as void
ParameterTypeDescriptionOptionalDefaultValue
professionMCVillagerProfessionWhat profession this trade should be for.false
villagerLevelintThe level the Villager needs to be.false
emeraldsintThe amount of Emeralds.false
forSaleItemStackWhat Itemstack is being sold (by the Villager).false
maxTradesintHow many times can this trade be done.false
xpintHow much Experience is given by trading.false
priceMultfloatWhen this trade is discounted, how much should it be discounted by.true1.0
addTrade

Adds a Villager Trade for an Item for an Item. An example being, giving a villager 2 diamonds for an arrow.

Return Type: void

VillagerTrades.addTrade(profession as MCVillagerProfession, villagerLevel as int, input1 as ItemStack, forSale as ItemStack, maxTrades as int, xp as int, priceMult as float) as void
ParameterTypeDescriptionOptionalDefaultValue
professionMCVillagerProfessionWhat profession this trade should be for.false
villagerLevelintThe level the Villager needs to be.false
input1ItemStackThe Itemstack that is being given to the Villager.false
forSaleItemStackWhat Itemstack is being sold (by the Villager).false
maxTradesintHow many times can this trade be done.false
xpintHow much Experience is given by trading.false
priceMultfloatWhen this trade is discounted, how much should it be discounted by.true1.0
addTrade

Adds a Villager Trade for two Items for an Item. An example being, giving a villager 2 diamonds and 2 dirt for an arrow.

Return Type: void

VillagerTrades.addTrade(profession as MCVillagerProfession, villagerLevel as int, input1 as ItemStack, input2 as ItemStack, forSale as ItemStack, maxTrades as int, xp as int, priceMult as float) as void
ParameterTypeDescriptionOptionalDefaultValue
professionMCVillagerProfessionWhat profession this trade should be for.false
villagerLevelintThe level the Villager needs to be.false
input1ItemStackThe main Itemstack that is being given to the Villager.false
input2ItemStackThe secondary Itemstack that is being given to the Villager.false
forSaleItemStackWhat Itemstack is being sold (by the Villager).false
maxTradesintHow many times can this trade be done.false
xpintHow much Experience is given by trading.false
priceMultfloatWhen this trade is discounted, how much should it be discounted by.true1.0
addWanderingTrade

Adds a Wandering Trader Trade for emeralds for an Item. An example being, giving a Wandering Trader 2 emeralds for an arrow.

Return Type: void

VillagerTrades.addWanderingTrade(rarity as int, emeralds as int, forSale as ItemStack, maxTrades as int, xp as int) as void
villagerTrades.addWanderingTrade(1, 16, <item:minecraft:diamond>, 16, 2);
ParameterTypeDescription
rarityintThe rarity of the Trade. Valid options are 1 or 2. A Wandering Trader can only spawn with a single trade of rarity 2.
emeraldsintThe amount of Emeralds.
forSaleItemStackWhat Itemstack is being sold (by the Wandering Trader).
maxTradesintHow many times can this trade be done.
xpintHow much Experience is given by trading.
removeDyedArmorForEmeraldsTrade

Removes a Villager trade for Items for Dyed leather armor. An example being, giving a villager a diamond and getting a Blue Dyed Leather clestplate.

Return Type: void

VillagerTrades.removeDyedArmorForEmeraldsTrade(profession as MCVillagerProfession, villagerLevel as int, buyingItem as MCItemDefinition) as void
villagerTrades.removeDyedArmorForEmeraldsTrade(<profession:minecraft:farmer>, 1, <item:minecraft:leather_chestplate>);
ParameterTypeDescription
professionMCVillagerProfessionWhat profession this trade should be for.
villagerLevelintThe level the Villager needs to be.
buyingItemMCItemDefinitionThe base ItemStack that a random Dye colour will be applied to. E.G. A leather chestplate with no effect applied.
removeEmeraldForItemsTrade

Removes a Villager trade for Emeralds for Items. An example being, giving a villager 2 Emaralds for an Arrow.

Return Type: void

VillagerTrades.removeEmeraldForItemsTrade(profession as MCVillagerProfession, villagerLevel as int, tradeFor as MCItemDefinition) as void
villagerTrades.removeEmeraldForItemsTrade(<profession:minecraft:farmer>, 1, <item:minecraft:arrow>.definition);
ParameterTypeDescription
professionMCVillagerProfessionWhat profession this trade should be for.
villagerLevelintThe level the Villager needs to be.
tradeForMCItemDefinitionWhat Itemstack is being sold (by the Villager).
removeEmeraldForMapTrade

Removes a Villager trade for a Map. An example being, giving a villager Emeralds and getting a Map to a structure.

Return Type: void

VillagerTrades.removeEmeraldForMapTrade(profession as MCVillagerProfession, villagerLevel as int) as void
villagerTrades.removeEmeraldForMapTrade(<profession:minecraft:farmer>, 1);
ParameterTypeDescription
professionMCVillagerProfessionWhat profession this trade should be for.
villagerLevelintThe level the Villager needs to be.
removeEnchantedBookForEmeraldsTrade

Removes a Villager trade for an Enchanted Book. An example being, giving a villager Emeralds and getting an Enchanted Book with a random Enchantment.

Return Type: void

VillagerTrades.removeEnchantedBookForEmeraldsTrade(profession as MCVillagerProfession, villagerLevel as int) as void
villagerTrades.removeEnchantedBookForEmeraldsTrade(<profession:minecraft:farmer>, 1);
ParameterTypeDescription
professionMCVillagerProfessionWhat profession this trade should be for.
villagerLevelintThe level the Villager needs to be.
removeEnchantedItemForEmeraldsTrade

Removes a Villager trade for an Enchanted Item. An example being, giving a villager Emeralds and getting an Enchanted Pickaxe.

Return Type: void

VillagerTrades.removeEnchantedItemForEmeraldsTrade(profession as MCVillagerProfession, villagerLevel as int, buyingItem as IItemStack) as void
villagerTrades.removeEnchantedItemForEmeraldsTrade(<profession:minecraft:farmer>, 1, <item:minecraft:diamond_sword>.withTag({Enchantments: [{lvl: 1 as short, id: "minecraft:smite" as string}]}));
ParameterTypeDescription
professionMCVillagerProfessionWhat profession this trade should be for.
villagerLevelintThe level the Villager needs to be.
buyingItemIItemStackThe ItemStack that the Villager is selling (including any NBT).
removeItemWithPotionForEmeraldsAndItemsTrade

Removes a Villager trade for Items for an Item with a PotionEffect. An example being, giving a villager an Arrow and getting a Tipped Arrow with night vision.

Return Type: void

VillagerTrades.removeItemWithPotionForEmeraldsAndItemsTrade(profession as MCVillagerProfession, villagerLevel as int, potionStack as IItemStack, sellingItem as MCItemDefinition) as void
villagerTrades.removeItemWithPotionForEmeraldsAndItemsTrade(<profession:minecraft:farmer>, 1, <item:minecraft:tipped_arrow>, <item:minecraft:arrow>);
ParameterTypeDescription
professionMCVillagerProfessionWhat profession this trade should be for.
villagerLevelintThe level the Villager needs to be.
potionStackIItemStackThe base ItemStack that a random potion effect will be applied to. E.G. A tipped Arrow with no effect applied.
sellingItemMCItemDefinitionWhat Itemstack is being given to the Villager.
removeItemsForEmeraldsAndItemsTrade

Removes a Villager trade for Emeralds and Items for Items. An example being, giving a villager an Emerald and Gravel and getting 16 Flint.

Return Type: void

VillagerTrades.removeItemsForEmeraldsAndItemsTrade(profession as MCVillagerProfession, villagerLevel as int, sellingItem as IItemStack, buyingItem as IItemStack) as void
villagerTrades.removeItemsForEmeraldsAndItemsTrade(<profession:minecraft:farmer>, 1, <item:minecraft:gravel>, <item:minecraft:flint>);
ParameterTypeDescription
professionMCVillagerProfessionWhat profession this trade should be for.
villagerLevelintThe level the Villager needs to be.
sellingItemIItemStackWhat Itemstack is being given to the Villager.
buyingItemIItemStackThe item that the Villager is selling.
removeItemsForEmeraldsTrade

Removes a Villager trade for Items for Emeralds. An example being, giving a villager an Arrow and getting 2 Emaralds.

Return Type: void

VillagerTrades.removeItemsForEmeraldsTrade(profession as MCVillagerProfession, villagerLevel as int, sellingItem as IItemStack) as void
villagerTrades.removeItemsForEmeraldsTrade(<profession:minecraft:farmer>, 1, <item:minecraft:arrow>);
ParameterTypeDescription
professionMCVillagerProfessionWhat profession this trade should be for.
villagerLevelintThe level the Villager needs to be.
sellingItemIItemStackWhat Itemstack is being given to the Villager.
removeSuspiciousStewForEmeraldTrade

Removes a Villager trade for Suspicious Stew. An example being, giving a villager Emeralds and getting a bowl of Suspicious Stew back..

Return Type: void

VillagerTrades.removeSuspiciousStewForEmeraldTrade(profession as MCVillagerProfession, villagerLevel as int) as void
villagerTrades.removeSuspiciousStewForEmeraldTrade(<profession:minecraft:farmer>, 1);
ParameterTypeDescription
professionMCVillagerProfessionWhat profession this trade should be for.
villagerLevelintThe level the Villager needs to be.
removeWanderingTrade

Removes a Wandering Trader trade for Emeralds for Items. An example being, giving a Wandering Trader 2 Emaralds for an Arrow.

Return Type: void

VillagerTrades.removeWanderingTrade(rarity as int, tradeFor as IItemStack) as void
villagerTrades.removeWanderingTrade(2, <item:minecraft:arrow>);
ParameterTypeDescription
rarityintThe rarity of the Trade. Valid options are 1 or 2. A Wandering Trader can only spawn with a single trade of rarity 2.
tradeForIItemStackWhat Itemstack is being sold (by the Villager).