VillagerTrades
Link to villagertrades
导入类
Link to 导入类
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;
使用方式
Link to 使用方式
Name: addTrade
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.
ZenScript Copy// VillagerTrades.addTrade(profession as VillagerProfession, villagerLevel as int, offerGenerator as BiFunction<Entity,Random,MerchantOffer?>)
villagerTrades.addTrade(<profession:minecraft:farmer>, 1, (entity, random) => {
return new MerchantOffer(<item:minecraft:dirt>, <item:minecraft:diamond>, 16, 0, 5);
});
参数 | 类型 | 描述 |
---|---|---|
参数 profession | 类型 VillagerProfession | 描述 What profession this trade should be for. |
参数 villagerLevel | 类型 int | 描述 The level the Villager needs to be. |
参数 offerGenerator | 类型 BiFunction<Entity,Random,MerchantOffer?> | 描述 A generator method to make a new MerchantOffer. |
Name: addTrade
Adds the specified ItemListing trade.
ZenScript Copy// VillagerTrades.addTrade(profession as VillagerProfession, villagerLevel as int, trade as ItemListing)
villagerTrades.addTrade(<profession:minecraft:farmer>, 1, TreasureMapForEmeralds.create(1, <resource:minecraft:ruined_portal>, "display Name", <constant:minecraft:world/map/decorationtype:mansion>, 16, 8));
参数 | 类型 | 描述 |
---|---|---|
参数 profession | 类型 VillagerProfession | 描述 What profession this trade should be for. |
参数 villagerLevel | 类型 int | 描述 The level the Villager needs to be. |
参数 trade | 类型 ItemListing | 描述 The trade to add. |
Name: addTrade
Adds a Villager Trade for emeralds for an Item. An example being, giving a villager 2 emeralds for an arrow.
ZenScript Copy// VillagerTrades.addTrade(profession as VillagerProfession, villagerLevel as int, emeralds as int, forSale as ItemStack, maxTrades as int, xp as int, priceMult as float)
villagerTrades.addTrade(<profession:minecraft:farmer>, 1, 16, <item:minecraft:diamond>, 5, 2, 0.05);
参数 | 类型 | 描述 | 可选 | 默认值 |
---|---|---|---|---|
参数 profession | 类型 VillagerProfession | 描述 What profession this trade should be for. | 可选 false | 默认值 |
参数 villagerLevel | 类型 int | 描述 The level the Villager needs to be. | 可选 false | 默认值 |
参数 emeralds | 类型 int | 描述 The amount of Emeralds. | 可选 false | 默认值 |
参数 forSale | 类型 物品应用 | 描述 What ItemStack is being sold (by the Villager). | 可选 false | 默认值 |
参数 maxTrades | 类型 int | 描述 How many times can this trade be done. | 可选 false | 默认值 |
参数 xp (经验值) | 类型 int | 描述 How much Experience is given by trading. | 可选 false | 默认值 |
参数 priceMult | 类型 float | 描述 When this trade is discounted, how much should it be discounted by. | 可选 true | 默认值 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.
ZenScript Copy// VillagerTrades.addTrade(profession as VillagerProfession, villagerLevel as int, input1 as ItemStack, forSale as ItemStack, maxTrades as int, xp as int, priceMult as float)
villagerTrades.addTrade(<profession:minecraft:farmer>, 1, <item:minecraft:dirt> * 16, <item:minecraft:diamond>, 5, 2, 0.05);
参数 | 类型 | 描述 | 可选 | 默认值 |
---|---|---|---|---|
参数 profession | 类型 VillagerProfession | 描述 What profession this trade should be for. | 可选 false | 默认值 |
参数 villagerLevel | 类型 int | 描述 The level the Villager needs to be. | 可选 false | 默认值 |
参数 input1 | 类型 物品应用 | 描述 The ItemStack that is being given to the Villager. | 可选 false | 默认值 |
参数 forSale | 类型 物品应用 | 描述 What ItemStack is being sold (by the Villager). | 可选 false | 默认值 |
参数 maxTrades | 类型 int | 描述 How many times can this trade be done. | 可选 false | 默认值 |
参数 xp (经验值) | 类型 int | 描述 How much Experience is given by trading. | 可选 false | 默认值 |
参数 priceMult | 类型 float | 描述 When this trade is discounted, how much should it be discounted by. | 可选 true | 默认值 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.
ZenScript Copy// VillagerTrades.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)
villagerTrades.addTrade(<profession:minecraft:farmer>, 1, <item:minecraft:diamond> * 2, <item:minecraft:dirt> * 2, <item:minecraft:arrow>, 5, 2, 0.05);
参数 | 类型 | 描述 | 可选 | 默认值 |
---|---|---|---|---|
参数 profession | 类型 VillagerProfession | 描述 What profession this trade should be for. | 可选 false | 默认值 |
参数 villagerLevel | 类型 int | 描述 The level the Villager needs to be. | 可选 false | 默认值 |
参数 input1 | 类型 物品应用 | 描述 The main ItemStack that is being given to the Villager. | 可选 false | 默认值 |
参数 input2 | 类型 物品应用 | 描述 The secondary ItemStack that is being given to the Villager. | 可选 false | 默认值 |
参数 forSale | 类型 物品应用 | 描述 What ItemStack is being sold (by the Villager). | 可选 false | 默认值 |
参数 maxTrades | 类型 int | 描述 How many times can this trade be done. | 可选 false | 默认值 |
参数 xp (经验值) | 类型 int | 描述 How much Experience is given by trading. | 可选 false | 默认值 |
参数 priceMult | 类型 float | 描述 When this trade is discounted, how much should it be discounted by. | 可选 true | 默认值 1.0 |
Name: addWanderingTrade
Adds the specific ItemListing trade to the Wandering Trader
ZenScript Copy// VillagerTrades.addWanderingTrade(rarity as int, trade as ItemListing)
villagerTrades.addWanderingTrade(1, TreasureMapForEmeralds.create(1, <resource:minecraft:ruined_portal>, "display Name", <constant:minecraft:world/map/decorationtype:mansion>, 16, 8));
参数 | 类型 | 描述 |
---|---|---|
参数 rarity | 类型 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 . |
参数 trade | 类型 ItemListing | 描述 The trade to add. |
Name: addWanderingTrade
Adds a Wandering Trader Trade for emeralds for an Item. An example being, giving a Wandering Trader 2 emeralds for an arrow.
ZenScript Copy// VillagerTrades.addWanderingTrade(rarity as int, emeralds as int, forSale as ItemStack, maxTrades as int, xp as int)
villagerTrades.addWanderingTrade(1, 16, <item:minecraft:diamond>, 16, 2);
参数 | 类型 | 描述 |
---|---|---|
参数 rarity | 类型 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 | 描述 The amount of Emeralds. |
参数 forSale | 类型 物品应用 | 描述 What ItemStack is being sold (by the Wandering Trader). |
参数 maxTrades | 类型 int | 描述 How many times can this trade be done. |
参数 xp (经验值) | 类型 int | 描述 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.
ZenScript Copy// VillagerTrades.addWanderingTrade(rarity as int, price as IItemStack, forSale as IItemStack, maxTrades as int, xp as int)
villagerTrades.addWanderingTrade(1, <item:minecraft:dirt>, <item:minecraft:diamond>, 16, 2);
参数 | 类型 | 描述 |
---|---|---|
参数 rarity | 类型 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 . |
参数 price | 类型 IItemstack | 描述 The ItemStack being given to the Wandering Trader. |
参数 forSale | 类型 IItemstack | 描述 What ItemStack is being sold (by the Wandering Trader). |
参数 maxTrades | 类型 int | 描述 How many times can this trade be done. |
参数 xp (经验值) | 类型 int | 描述 How much Experience is given by trading. |
Name: removeAllTrades
Removes all the trades for the given profession and villagerLevel
ZenScript Copy// VillagerTrades.removeAllTrades(profession as VillagerProfession, villagerLevel as int)
villagerTrades.removeAllTrades(<profession:minecraft:farmer>, 1);
参数 | 类型 | 描述 |
---|---|---|
参数 profession | 类型 VillagerProfession | 描述 hat profession to remove from. |
参数 villagerLevel | 类型 int | 描述 The level the Villager needs to be. |
Name: removeAllWanderingTrades
Removes all wandering trades of the given rarity
ZenScript CopyVillagerTrades.removeAllWanderingTrades(rarity as int)
参数 | 类型 | 描述 |
---|---|---|
参数 rarity | 类型 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 . |
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.
ZenScript Copy// VillagerTrades.removeBasicTrade(profession as VillagerProfession, villagerLevel as int, forSale as IItemStack, price as IItemStack, price2 as IItemStack)
villagerTrades.removeBasicTrade(<profession:minecraft:farmer>, 1, <item:minecraft:arrow>, <item:minecraft:stick>, <item:minecraft:emerald>);
参数 | 类型 | 描述 | 可选 | 默认值 |
---|---|---|---|---|
参数 profession | 类型 VillagerProfession | 描述 What profession this trade should be for. | 可选 false | 默认值 |
参数 villagerLevel | 类型 int | 描述 The level the Villager needs to be. | 可选 false | 默认值 |
参数 forSale | 类型 IItemstack | 描述 What ItemStack is being sold (by the Villager). | 可选 false | 默认值 |
参数 price | 类型 IItemstack | 描述 | 可选 true | 默认值 item:minecraft:air |
参数 price2 | 类型 IItemstack | 描述 | 可选 true | 默认值 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.
ZenScript Copy// VillagerTrades.removeDyedArmorForEmeraldsTrade(profession as VillagerProfession, villagerLevel as int, buyingItem as ItemDefinition)
villagerTrades.removeDyedArmorForEmeraldsTrade(<profession:minecraft:leatherworker>, 1, <item:minecraft:leather_chestplate>);
参数 | 类型 | 描述 |
---|---|---|
参数 profession | 类型 VillagerProfession | 描述 What profession this trade should be for. |
参数 villagerLevel | 类型 int | 描述 The level the Villager needs to be. |
参数 buyingItem | 类型 ItemDefinition | 描述 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.
ZenScript Copy// VillagerTrades.removeEmeraldForItemsTrade(profession as VillagerProfession, villagerLevel as int, tradeFor as ItemDefinition)
villagerTrades.removeEmeraldForItemsTrade(<profession:minecraft:farmer>, 1, <item:minecraft:potato>.definition);
参数 | 类型 | 描述 |
---|---|---|
参数 profession | 类型 VillagerProfession | 描述 What profession this trade should be for. |
参数 villagerLevel | 类型 int | 描述 The level the Villager needs to be. |
参数 tradeFor | 类型 ItemDefinition | 描述 What ItemStack is being sold (by the Villager). |
Name: removeEnchantBookForEmeraldsTrade
Removes a Villager trade for an Enchanted Book. An example being, giving a villager Emeralds and getting an Enchanted Book with a random Enchantment.
ZenScript Copy// VillagerTrades.removeEnchantBookForEmeraldsTrade(profession as VillagerProfession, villagerLevel as int)
villagerTrades.removeEnchantBookForEmeraldsTrade(<profession:minecraft:librarian>, 1);
参数 | 类型 | 描述 |
---|---|---|
参数 profession | 类型 VillagerProfession | 描述 What profession this trade should be for. |
参数 villagerLevel | 类型 int | 描述 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.
ZenScript Copy// VillagerTrades.removeEnchantedItemForEmeraldsTrade(profession as VillagerProfession, villagerLevel as int, buyingItem as IItemStack)
villagerTrades.removeEnchantedItemForEmeraldsTrade(<profession:minecraft:armorer>, 1, <item:minecraft:diamond_boots>);
参数 | 类型 | 描述 |
---|---|---|
参数 profession | 类型 VillagerProfession | 描述 What profession this trade should be for. |
参数 villagerLevel | 类型 int | 描述 The level the Villager needs to be. |
参数 buyingItem | 类型 IItemstack | 描述 The ItemStack that the Villager is selling (including any NBT). |
Name: removeItemsAndEmeraldsToItemsTrade
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.
ZenScript Copy// VillagerTrades.removeItemsAndEmeraldsToItemsTrade(profession as VillagerProfession, villagerLevel as int, sellingItem as IItemStack, buyingItem as IItemStack)
villagerTrades.removeItemsAndEmeraldsToItemsTrade(<profession:minecraft:fisherman>, 1, <item:minecraft:cooked_cod>, <item:minecraft:cod>);
参数 | 类型 | 描述 |
---|---|---|
参数 profession | 类型 VillagerProfession | 描述 What profession this trade should be for. |
参数 villagerLevel | 类型 int | 描述 The level the Villager needs to be. |
参数 sellingItem | 类型 IItemstack | 描述 What ItemStack is being given to the Villager. |
参数 buyingItem | 类型 IItemstack | 描述 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.
ZenScript Copy// VillagerTrades.removeItemsForEmeraldsTrade(profession as VillagerProfession, villagerLevel as int, sellingItem as IItemStack)
villagerTrades.removeItemsForEmeraldsTrade(<profession:minecraft:farmer>, 1, <item:minecraft:apple>);
参数 | 类型 | 描述 |
---|---|---|
参数 profession | 类型 VillagerProfession | 描述 What profession this trade should be for. |
参数 villagerLevel | 类型 int | 描述 The level the Villager needs to be. |
参数 sellingItem | 类型 IItemstack | 描述 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.
ZenScript Copy// VillagerTrades.removeSuspiciousStewForEmeraldTrade(profession as VillagerProfession, villagerLevel as int)
villagerTrades.removeSuspiciousStewForEmeraldTrade(<profession:minecraft:farmer>, 1);
参数 | 类型 | 描述 |
---|---|---|
参数 profession | 类型 VillagerProfession | 描述 What profession this trade should be for. |
参数 villagerLevel | 类型 int | 描述 The level the Villager needs to be. |
Name: removeTippedArrowForItemsAndEmeraldsTrade
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.
ZenScript Copy// VillagerTrades.removeTippedArrowForItemsAndEmeraldsTrade(profession as VillagerProfession, villagerLevel as int, potionStack as IItemStack, sellingItem as ItemDefinition)
villagerTrades.removeTippedArrowForItemsAndEmeraldsTrade(<profession:minecraft:fletcher>, 1, <item:minecraft:tipped_arrow>, <item:minecraft:arrow>);
参数 | 类型 | 描述 |
---|---|---|
参数 profession | 类型 VillagerProfession | 描述 What profession this trade should be for. |
参数 villagerLevel | 类型 int | 描述 The level the Villager needs to be. |
参数 potionStack | 类型 IItemstack | 描述 The base ItemStack that a random potion effect will be applied to. E.G. A tipped Arrow with no effect applied. |
参数 sellingItem | 类型 ItemDefinition | 描述 What ItemStack is being given to the Villager. |
Name: removeTrade
Removes the specified trade for the given profession and villagerLevel.
ZenScript Copy// VillagerTrades.removeTrade(profession as VillagerProfession, villagerLevel as int, buying as IIngredient, selling as IIngredient, secondBuying as IIngredient)
villagerTrades.removeTrade(<profession:minecraft:farmer>, 1, <item:minecraft:potato>, <item:minecraft:emerald>, <item:minecraft:air>);
参数 | 类型 | 描述 | 可选 | 默认值 |
---|---|---|---|---|
参数 profession | 类型 VillagerProfession | 描述 That profession to remove from. | 可选 false | 默认值 |
参数 villagerLevel | 类型 int | 描述 The level the Villager needs to be. | 可选 false | 默认值 |
参数 buying | 类型 材料(IIngredient) | 描述 The first item that you are giving to the villager. | 可选 false | 默认值 |
参数 selling | 类型 材料(IIngredient) | 描述 The item that the villager is selling to you. | 可选 false | 默认值 |
参数 secondBuying | 类型 材料(IIngredient) | 描述 The second item that you are giving to the villager. Will default to air if not provided. | 可选 true | 默认值 item:minecraft:air |
Name: removeTradesBuying
Removes all trades that have the specified item as the buying item for the given profession and villagerLevel.
ZenScript Copy// VillagerTrades.removeTradesBuying(profession as VillagerProfession, villagerLevel as int, buying as IIngredient)
villagerTrades.removeTradesBuying(<profession:minecraft:farmer>, 1, <item:minecraft:potato>);
参数 | 类型 | 描述 |
---|---|---|
参数 profession | 类型 VillagerProfession | 描述 That profession to remove from. |
参数 villagerLevel | 类型 int | 描述 The level the Villager needs to be. |
参数 buying | 类型 材料(IIngredient) | 描述 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.
ZenScript Copy// VillagerTrades.removeTradesBuying(profession as VillagerProfession, villagerLevel as int, buying as IIngredient, secondBuying as IIngredient)
villagerTrades.removeTradesBuying(<profession:minecraft:farmer>, 1, <item:minecraft:potato>, <item:minecraft:air>);
参数 | 类型 | 描述 |
---|---|---|
参数 profession | 类型 VillagerProfession | 描述 That profession to remove from. |
参数 villagerLevel | 类型 int | 描述 The level the Villager needs to be. |
参数 buying | 类型 材料(IIngredient) | 描述 The first item that you are giving to the villager. |
参数 secondBuying | 类型 材料(IIngredient) | 描述 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.
ZenScript Copy// VillagerTrades.removeTradesSelling(profession as VillagerProfession, villagerLevel as int, selling as IIngredient)
villagerTrades.removeTradesSelling(<profession:minecraft:farmer>, 1, <item:minecraft:emerald>);
参数 | 类型 | 描述 |
---|---|---|
参数 profession | 类型 VillagerProfession | 描述 That profession to remove from. |
参数 villagerLevel | 类型 int | 描述 The level the Villager needs to be. |
参数 selling | 类型 材料(IIngredient) | 描述 The item that the villager is selling to you. |
Name: removeTreasureMapForEmeraldsTrade
Removes a Villager trade for a Map. An example being, giving a villager 13 Emeralds and getting a Map to a structure.
ZenScript Copy// VillagerTrades.removeTreasureMapForEmeraldsTrade(profession as VillagerProfession, villagerLevel as int)
villagerTrades.removeTreasureMapForEmeraldsTrade(<profession:minecraft:cartographer>, 1);
参数 | 类型 | 描述 |
---|---|---|
参数 profession | 类型 VillagerProfession | 描述 What profession this trade should be for. |
参数 villagerLevel | 类型 int | 描述 The level the Villager needs to be. |
Name: removeWanderingTrade
Removes a Wandering Trader trade for Emeralds for Items. An example being, giving a Wandering Trader 2 Emeralds for an Arrow.
ZenScript Copy// VillagerTrades.removeWanderingTrade(rarity as int, tradeFor as IIngredient)
villagerTrades.removeWanderingTrade(2, <item:minecraft:arrow>);
参数 | 类型 | 描述 |
---|---|---|
参数 rarity | 类型 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 . |
参数 tradeFor | 类型 材料(IIngredient) | 描述 What ItemStack is being sold (by the Villager). |