VillagerTrades
Link to villagertrades
Importare la Classe
Link to importare-la-classe
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.
ZenScript Copyimport crafttweaker.api.villagers.VillagerTrades;
Metodi
Link to metodi
Name: addTrade
Adds a new custom trade with the selling and buying items determined by the custom MCMerchantOffer generator.
The function will only run when the villager resolves the trade.
Return Type: void
ZenScript Copy// VillagerTrades.addTrade(profession as MCVillagerProfession, villagerLevel as int, offerGenerator as BiFunction<MCEntity,Random,MCMerchantOffer>) as void
villagerTrades.addTrade(<profession:minecraft:farmer>, 1, (entity, random) => {
return new MCMerchantOffer(<item:minecraft:dirt>, <item:minecraft:diamond>, 16, 0, 5);
});
Parametro | Tipo | Descrizione |
---|---|---|
Parametro profession | Tipo MCVillagerProfession | Descrizione What profession this trade should be for. |
Parametro villagerLevel | Tipo int | Descrizione The level the Villager needs to be. |
Parametro offerGenerator | Tipo BiFunction<MCEntity,Random,MCMerchantOffer> | Descrizione A generator method to make a new MerchantOffer. |
Name: addTrade
Adds a Villager Trade for emeralds for an Item. An example being, giving a villager 2 emeralds for an arrow.
Return Type: void
ZenScript Copy// 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
villagerTrades.addTrade(<profession:minecraft:farmer>, 1, 16, <item:minecraft:diamond>, 5, 2, 0.05);
Parametro | Tipo | Descrizione | Optional | DefaultValue |
---|---|---|---|---|
Parametro profession | Tipo MCVillagerProfession | Descrizione What profession this trade should be for. | Optional no | DefaultValue |
Parametro villagerLevel | Tipo int | Descrizione The level the Villager needs to be. | Optional no | DefaultValue |
Parametro emeralds | Tipo int | Descrizione The amount of Emeralds. | Optional no | DefaultValue |
Parametro forSale | Tipo ItemStack | Descrizione What ItemStack is being sold (by the Villager). | Optional no | DefaultValue |
Parametro maxTrades | Tipo int | Descrizione How many times can this trade be done. | Optional no | DefaultValue |
Parametro xp | Tipo int | Descrizione How much Experience is given by trading. | Optional no | DefaultValue |
Parametro priceMult | Tipo float | Descrizione When this trade is discounted, how much should it be discounted by. | Optional sì | DefaultValue 1.0 |
Name: 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
ZenScript Copy// 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
villagerTrades.addTrade(<profession:minecraft:farmer>, 1, <item:minecraft:dirt> * 16, <item:minecraft:diamond>, 5, 2, 0.05);
Parametro | Tipo | Descrizione | Optional | DefaultValue |
---|---|---|---|---|
Parametro profession | Tipo MCVillagerProfession | Descrizione What profession this trade should be for. | Optional no | DefaultValue |
Parametro villagerLevel | Tipo int | Descrizione The level the Villager needs to be. | Optional no | DefaultValue |
Parametro input1 | Tipo ItemStack | Descrizione The ItemStack that is being given to the Villager. | Optional no | DefaultValue |
Parametro forSale | Tipo ItemStack | Descrizione What ItemStack is being sold (by the Villager). | Optional no | DefaultValue |
Parametro maxTrades | Tipo int | Descrizione How many times can this trade be done. | Optional no | DefaultValue |
Parametro xp | Tipo int | Descrizione How much Experience is given by trading. | Optional no | DefaultValue |
Parametro priceMult | Tipo float | Descrizione When this trade is discounted, how much should it be discounted by. | Optional sì | DefaultValue 1.0 |
Name: 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
ZenScript Copy// 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
villagerTrades.addTrade(<profession:minecraft:farmer>, 1, <item:minecraft:diamond> * 2, <item:minecraft:dirt> * 2, <item:minecraft:arrow>, 5, 2, 0.05);
Parametro | Tipo | Descrizione | Optional | DefaultValue |
---|---|---|---|---|
Parametro profession | Tipo MCVillagerProfession | Descrizione What profession this trade should be for. | Optional no | DefaultValue |
Parametro villagerLevel | Tipo int | Descrizione The level the Villager needs to be. | Optional no | DefaultValue |
Parametro input1 | Tipo ItemStack | Descrizione The main ItemStack that is being given to the Villager. | Optional no | DefaultValue |
Parametro input2 | Tipo ItemStack | Descrizione The secondary ItemStack that is being given to the Villager. | Optional no | DefaultValue |
Parametro forSale | Tipo ItemStack | Descrizione What ItemStack is being sold (by the Villager). | Optional no | DefaultValue |
Parametro maxTrades | Tipo int | Descrizione How many times can this trade be done. | Optional no | DefaultValue |
Parametro xp | Tipo int | Descrizione How much Experience is given by trading. | Optional no | DefaultValue |
Parametro priceMult | Tipo float | Descrizione When this trade is discounted, how much should it be discounted by. | Optional sì | DefaultValue 1.0 |
Name: 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
ZenScript Copy// 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);
Parametro | Tipo | Descrizione |
---|---|---|
Parametro rarity | Tipo int | Descrizione The rarity of the Trade. Valid options are 1 or 2 . A Wandering Trader can only spawn with a single trade of rarity 2 . |
Parametro emeralds | Tipo int | Descrizione The amount of Emeralds. |
Parametro forSale | Tipo ItemStack | Descrizione What ItemStack is being sold (by the Wandering Trader). |
Parametro maxTrades | Tipo int | Descrizione How many times can this trade be done. |
Parametro xp | Tipo int | Descrizione How much Experience is given by trading. |
Name: 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
ZenScript Copy// VillagerTrades.addWanderingTrade(rarity as int, price as IItemStack, forSale as IItemStack, maxTrades as int, xp as int) as void
villagerTrades.addWanderingTrade(1, <item:minecraft:dirt>, <item:minecraft:diamond>, 16, 2);
Parametro | Tipo | Descrizione |
---|---|---|
Parametro rarity | Tipo int | Descrizione The rarity of the Trade. Valid options are 1 or 2 . A Wandering Trader can only spawn with a single trade of rarity 2 . |
Parametro price | Tipo IItemStack | Descrizione The ItemStack being given to the Wandering Trader. |
Parametro forSale | Tipo IItemStack | Descrizione What ItemStack is being sold (by the Wandering Trader). |
Parametro maxTrades | Tipo int | Descrizione How many times can this trade be done. |
Parametro xp | Tipo int | Descrizione How much Experience is given by trading. |
Name: removeAllTrades
Removes all the trades for the given profession and villagerLevel
Return Type: void
ZenScript Copy// VillagerTrades.removeAllTrades(profession as MCVillagerProfession, villagerLevel as int) as void
villagerTrades.removeAllTrades(<profession:minecraft:farmer>, 1);
Parametro | Tipo | Descrizione |
---|---|---|
Parametro profession | Tipo MCVillagerProfession | Descrizione hat profession to remove from. |
Parametro villagerLevel | Tipo int | Descrizione The level the Villager needs to be. |
Name: removeAllWanderinTrades
Removes all wandering trades of the given rarity
Return Type: void
ZenScript Copy// VillagerTrades.removeAllWanderinTrades(rarity as int) as void
villagerTrades.removeAllWanderinTrades(1);
Parametro | Tipo | Descrizione |
---|---|---|
Parametro rarity | Tipo int | Descrizione The rarity of the Trade. Valid options are 1 or 2 . A Wandering Trader can only spawn with a single trade of rarity 2 . |
Name: removeAllWanderingTrades
Removes all wandering trades of the given rarity
Return Type: void
ZenScript Copy// VillagerTrades.removeAllWanderingTrades(rarity as int) as void
villagerTrades.removeAllWanderingTrades(1);
Parametro | Tipo | Descrizione |
---|---|---|
Parametro rarity | Tipo int | Descrizione The rarity of the Trade. Valid options are 1 or 2 . A Wandering Trader can only spawn with a single trade of rarity 2 . |
Name: removeBasicTrade
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.
Return Type: void
ZenScript Copy// VillagerTrades.removeBasicTrade(profession as MCVillagerProfession, villagerLevel as int, forSale as IItemStack, price as IItemStack, price2 as IItemStack) as void
villagerTrades.removeBasicTrade(<profession:minecraft:farmer>, 1, <item:minecraft:arrow>, <item:minecraft:stick>, <item:minecraft:emerald>);
Parametro | Tipo | Descrizione | Optional | DefaultValue |
---|---|---|---|---|
Parametro profession | Tipo MCVillagerProfession | Descrizione What profession this trade should be for. | Optional no | DefaultValue |
Parametro villagerLevel | Tipo int | Descrizione The level the Villager needs to be. | Optional no | DefaultValue |
Parametro forSale | Tipo IItemStack | Descrizione What ItemStack is being sold (by the Villager). | Optional no | DefaultValue |
Parametro price | Tipo IItemStack | Descrizione No Description Provided | Optional sì | DefaultValue item:minecraft:air |
Parametro price2 | Tipo IItemStack | Descrizione No Description Provided | Optional sì | DefaultValue item:minecraft:air |
Name: removeDyedArmorForEmeraldsTrade
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.
Return Type: void
ZenScript Copy// VillagerTrades.removeDyedArmorForEmeraldsTrade(profession as MCVillagerProfession, villagerLevel as int, buyingItem as MCItemDefinition) as void
villagerTrades.removeDyedArmorForEmeraldsTrade(<profession:minecraft:leatherworker>, 1, <item:minecraft:leather_chestplate>);
Parametro | Tipo | Descrizione |
---|---|---|
Parametro profession | Tipo MCVillagerProfession | Descrizione What profession this trade should be for. |
Parametro villagerLevel | Tipo int | Descrizione The level the Villager needs to be. |
Parametro buyingItem | Tipo MCItemDefinition | Descrizione The base ItemStack that a random Dye colour will be applied to. E.G. A leather chestplate with no effect applied. |
Name: removeEmeraldForItemsTrade
Removes a Villager trade for Emeralds for Items. An example being, giving a villager 20 Wheat and getting an Emerald from the villager.
Return Type: void
ZenScript Copy// VillagerTrades.removeEmeraldForItemsTrade(profession as MCVillagerProfession, villagerLevel as int, tradeFor as MCItemDefinition) as void
villagerTrades.removeEmeraldForItemsTrade(<profession:minecraft:farmer>, 1, <item:minecraft:potato>.definition);
Parametro | Tipo | Descrizione |
---|---|---|
Parametro profession | Tipo MCVillagerProfession | Descrizione What profession this trade should be for. |
Parametro villagerLevel | Tipo int | Descrizione The level the Villager needs to be. |
Parametro tradeFor | Tipo MCItemDefinition | Descrizione What ItemStack is being sold (by the Villager). |
Name: removeEmeraldForMapTrade
Removes a Villager trade for a Map. An example being, giving a villager 13 Emeralds and getting a Map to a structure.
Return Type: void
ZenScript Copy// VillagerTrades.removeEmeraldForMapTrade(profession as MCVillagerProfession, villagerLevel as int) as void
villagerTrades.removeEmeraldForMapTrade(<profession:minecraft:cartographer>, 1);
Parametro | Tipo | Descrizione |
---|---|---|
Parametro profession | Tipo MCVillagerProfession | Descrizione What profession this trade should be for. |
Parametro villagerLevel | Tipo int | Descrizione The level the Villager needs to be. |
Name: 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
ZenScript Copy// VillagerTrades.removeEnchantedBookForEmeraldsTrade(profession as MCVillagerProfession, villagerLevel as int) as void
villagerTrades.removeEnchantedBookForEmeraldsTrade(<profession:minecraft:librarian>, 1);
Parametro | Tipo | Descrizione |
---|---|---|
Parametro profession | Tipo MCVillagerProfession | Descrizione What profession this trade should be for. |
Parametro villagerLevel | Tipo int | Descrizione The level the Villager needs to be. |
Name: removeEnchantedItemForEmeraldsTrade
Removes a Villager trade for an Enchanted Item. An example being, giving a villager 3 Emeralds and getting an Enchanted Pickaxe.
Return Type: void
ZenScript Copy// VillagerTrades.removeEnchantedItemForEmeraldsTrade(profession as MCVillagerProfession, villagerLevel as int, buyingItem as IItemStack) as void
villagerTrades.removeEnchantedItemForEmeraldsTrade(<profession:minecraft:armorer>, 1, <item:minecraft:diamond_boots>);
Parametro | Tipo | Descrizione |
---|---|---|
Parametro profession | Tipo MCVillagerProfession | Descrizione What profession this trade should be for. |
Parametro villagerLevel | Tipo int | Descrizione The level the Villager needs to be. |
Parametro buyingItem | Tipo IItemStack | Descrizione The ItemStack that the Villager is selling (including any NBT). |
Name: removeItemWithPotionForEmeraldsAndItemsTrade
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.
Return Type: void
ZenScript Copy// VillagerTrades.removeItemWithPotionForEmeraldsAndItemsTrade(profession as MCVillagerProfession, villagerLevel as int, potionStack as IItemStack, sellingItem as MCItemDefinition) as void
villagerTrades.removeItemWithPotionForEmeraldsAndItemsTrade(<profession:minecraft:fletcher>, 1, <item:minecraft:tipped_arrow>, <item:minecraft:arrow>);
Parametro | Tipo | Descrizione |
---|---|---|
Parametro profession | Tipo MCVillagerProfession | Descrizione What profession this trade should be for. |
Parametro villagerLevel | Tipo int | Descrizione The level the Villager needs to be. |
Parametro potionStack | Tipo IItemStack | Descrizione The base ItemStack that a random potion effect will be applied to. E.G. A tipped Arrow with no effect applied. |
Parametro sellingItem | Tipo MCItemDefinition | Descrizione What ItemStack is being given to the Villager. |
Name: removeItemsForEmeraldsAndItemsTrade
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.
Return Type: void
ZenScript Copy// VillagerTrades.removeItemsForEmeraldsAndItemsTrade(profession as MCVillagerProfession, villagerLevel as int, sellingItem as IItemStack, buyingItem as IItemStack) as void
villagerTrades.removeItemsForEmeraldsAndItemsTrade(<profession:minecraft:fisherman>, 1, <item:minecraft:cooked_cod>, <item:minecraft:cod>);
Parametro | Tipo | Descrizione |
---|---|---|
Parametro profession | Tipo MCVillagerProfession | Descrizione What profession this trade should be for. |
Parametro villagerLevel | Tipo int | Descrizione The level the Villager needs to be. |
Parametro sellingItem | Tipo IItemStack | Descrizione What ItemStack is being given to the Villager. |
Parametro buyingItem | Tipo IItemStack | Descrizione The item that the Villager is selling. |
Name: removeItemsForEmeraldsTrade
Removes a Villager trade for Items for Emeralds. An example being, giving a villager an Emerald and getting 4 Pumpkin Pies from the villager.
Return Type: void
ZenScript Copy// VillagerTrades.removeItemsForEmeraldsTrade(profession as MCVillagerProfession, villagerLevel as int, sellingItem as IItemStack) as void
villagerTrades.removeItemsForEmeraldsTrade(<profession:minecraft:farmer>, 1, <item:minecraft:apple>);
Parametro | Tipo | Descrizione |
---|---|---|
Parametro profession | Tipo MCVillagerProfession | Descrizione What profession this trade should be for. |
Parametro villagerLevel | Tipo int | Descrizione The level the Villager needs to be. |
Parametro sellingItem | Tipo IItemStack | Descrizione What ItemStack is being given to the Villager. |
Name: removeSuspiciousStewForEmeraldTrade
Removes a Villager trade for Suspicious Stew. An example being, giving a villager an Emerald and getting a bowl of Suspicious Stew back.
Return Type: void
ZenScript Copy// VillagerTrades.removeSuspiciousStewForEmeraldTrade(profession as MCVillagerProfession, villagerLevel as int) as void
villagerTrades.removeSuspiciousStewForEmeraldTrade(<profession:minecraft:farmer>, 1);
Parametro | Tipo | Descrizione |
---|---|---|
Parametro profession | Tipo MCVillagerProfession | Descrizione What profession this trade should be for. |
Parametro villagerLevel | Tipo int | Descrizione The level the Villager needs to be. |
Name: removeTrade
Removes the specified trade for the given profession and villagerLevel.
Return Type: void
ZenScript Copy// VillagerTrades.removeTrade(profession as MCVillagerProfession, villagerLevel as int, buying as IIngredient, selling as IIngredient, secondBuying as IIngredient) as void
villagerTrades.removeTrade(<profession:minecraft:farmer>, 1, <item:minecraft:potato>, <item:minecraft:emerald>, <item:minecraft:air>);
Parametro | Tipo | Descrizione | Optional | DefaultValue |
---|---|---|---|---|
Parametro profession | Tipo MCVillagerProfession | Descrizione That profession to remove from. | Optional no | DefaultValue |
Parametro villagerLevel | Tipo int | Descrizione The level the Villager needs to be. | Optional no | DefaultValue |
Parametro buying | Tipo IIngredient | Descrizione The first item that you are giving to the villager. | Optional no | DefaultValue |
Parametro selling | Tipo IIngredient | Descrizione The item that the villager is selling to you. | Optional no | DefaultValue |
Parametro secondBuying | Tipo IIngredient | Descrizione The second item that you are giving to the villager. Will default to air if not provided. | Optional sì | DefaultValue item:minecraft:air |
Name: removeTradesBuying
Removes all trades that have the specified item as the buying item for the given profession and villagerLevel.
Return Type: void
ZenScript Copy// VillagerTrades.removeTradesBuying(profession as MCVillagerProfession, villagerLevel as int, buying as IIngredient) as void
villagerTrades.removeTradesBuying(<profession:minecraft:farmer>, 1, <item:minecraft:potato>);
Parametro | Tipo | Descrizione |
---|---|---|
Parametro profession | Tipo MCVillagerProfession | Descrizione That profession to remove from. |
Parametro villagerLevel | Tipo int | Descrizione The level the Villager needs to be. |
Parametro buying | Tipo IIngredient | Descrizione The first item that you are giving to the villager. |
Name: removeTradesBuying
Removes all trades that have the specified items as the buying items for the given profession and villagerLevel.
Return Type: void
ZenScript Copy// VillagerTrades.removeTradesBuying(profession as MCVillagerProfession, villagerLevel as int, buying as IIngredient, secondBuying as IIngredient) as void
villagerTrades.removeTradesBuying(<profession:minecraft:farmer>, 1, <item:minecraft:potato>, <item:minecraft:air>);
Parametro | Tipo | Descrizione |
---|---|---|
Parametro profession | Tipo MCVillagerProfession | Descrizione That profession to remove from. |
Parametro villagerLevel | Tipo int | Descrizione The level the Villager needs to be. |
Parametro buying | Tipo IIngredient | Descrizione The first item that you are giving to the villager. |
Parametro secondBuying | Tipo IIngredient | Descrizione The second item that you are giving to the villager. Will default to air if not provided. |
Name: removeTradesSelling
Removes all trades that sell the specified item for the given profession and villagerLevel.
Return Type: void
ZenScript Copy// VillagerTrades.removeTradesSelling(profession as MCVillagerProfession, villagerLevel as int, selling as IIngredient) as void
villagerTrades.removeTradesSelling(<profession:minecraft:farmer>, 1, <item:minecraft:emerald>);
Parametro | Tipo | Descrizione |
---|---|---|
Parametro profession | Tipo MCVillagerProfession | Descrizione That profession to remove from. |
Parametro villagerLevel | Tipo int | Descrizione The level the Villager needs to be. |
Parametro selling | Tipo IIngredient | Descrizione The item that the villager is selling to you. |
Name: removeWanderingTrade
Removes a Wandering Trader trade for Emeralds for Items. An example being, giving a Wandering Trader 2 Emeralds for an Arrow.
Return Type: void
ZenScript Copy// VillagerTrades.removeWanderingTrade(rarity as int, tradeFor as IIngredient) as void
villagerTrades.removeWanderingTrade(2, <item:minecraft:arrow>);
Parametro | Tipo | Descrizione |
---|---|---|
Parametro rarity | Tipo int | Descrizione The rarity of the Trade. Valid options are 1 or 2 . A Wandering Trader can only spawn with a single trade of rarity 2 . |
Parametro tradeFor | Tipo IIngredient | Descrizione What ItemStack is being sold (by the Villager). |