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.
Methods
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.
Parameter | Type | Description |
---|---|---|
Parameter profession | Type VillagerProfession | Description What profession this trade should be for. |
Parameter villagerLevel | Type int | Description The level the Villager needs to be. |
Parameter offerGenerator | Type BiFunction<Entity,Random,MerchantOffer?> | Description A generator method to make a new MerchantOffer. |
Adds the specified ItemListing trade.
Parameter | Type | Description |
---|---|---|
Parameter profession | Type VillagerProfession | Description What profession this trade should be for. |
Parameter villagerLevel | Type int | Description The level the Villager needs to be. |
Parameter trade | Type ItemListing | Description The trade to add. |
Adds a Villager Trade for emeralds for an Item. An example being, giving a villager 2 emeralds for an arrow.
Parameter | Type | Description | Optional | Default Value |
---|---|---|---|---|
Parameter profession | Type VillagerProfession | Description What profession this trade should be for. | Optional false | Default Value |
Parameter villagerLevel | Type int | Description The level the Villager needs to be. | Optional false | Default Value |
Parameter emeralds | Type int | Description The amount of Emeralds. | Optional false | Default Value |
Parameter forSale | Type ItemStack | Description What ItemStack is being sold (by the Villager). | Optional false | Default Value |
Parameter maxTrades | Type int | Description How many times can this trade be done. | Optional false | Default Value |
Parameter xp | Type int | Description How much Experience is given by trading. | Optional false | Default Value |
Parameter priceMult | Type float | Description When this trade is discounted, how much should it be discounted by. | Optional true | Default Value 1.0 |
Adds a Villager Trade for an Item for an Item. An example being, giving a villager 2 diamonds for an arrow.
Parameter | Type | Description | Optional | Default Value |
---|---|---|---|---|
Parameter profession | Type VillagerProfession | Description What profession this trade should be for. | Optional false | Default Value |
Parameter villagerLevel | Type int | Description The level the Villager needs to be. | Optional false | Default Value |
Parameter input1 | Type ItemStack | Description The ItemStack that is being given to the Villager. | Optional false | Default Value |
Parameter forSale | Type ItemStack | Description What ItemStack is being sold (by the Villager). | Optional false | Default Value |
Parameter maxTrades | Type int | Description How many times can this trade be done. | Optional false | Default Value |
Parameter xp | Type int | Description How much Experience is given by trading. | Optional false | Default Value |
Parameter priceMult | Type float | Description When this trade is discounted, how much should it be discounted by. | Optional true | Default Value 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.
Parameter | Type | Description | Optional | Default Value |
---|---|---|---|---|
Parameter profession | Type VillagerProfession | Description What profession this trade should be for. | Optional false | Default Value |
Parameter villagerLevel | Type int | Description The level the Villager needs to be. | Optional false | Default Value |
Parameter input1 | Type ItemStack | Description The main ItemStack that is being given to the Villager. | Optional false | Default Value |
Parameter input2 | Type ItemStack | Description The secondary ItemStack that is being given to the Villager. | Optional false | Default Value |
Parameter forSale | Type ItemStack | Description What ItemStack is being sold (by the Villager). | Optional false | Default Value |
Parameter maxTrades | Type int | Description How many times can this trade be done. | Optional false | Default Value |
Parameter xp | Type int | Description How much Experience is given by trading. | Optional false | Default Value |
Parameter priceMult | Type float | Description When this trade is discounted, how much should it be discounted by. | Optional true | Default Value 1.0 |
Adds the specific ItemListing trade to the Wandering Trader
Parameter | Type | Description |
---|---|---|
Parameter rarity | Type int | Description The rarity of the Trade. Valid options are 1 or 2 . A Wandering Trader can only spawn with a single trade of rarity 2 . |
Parameter trade | Type ItemListing | Description The trade to add. |
Adds a Wandering Trader Trade for emeralds for an Item. An example being, giving a Wandering Trader 2 emeralds for an arrow.
Parameter | Type | Description |
---|---|---|
Parameter rarity | Type int | Description The rarity of the Trade. Valid options are 1 or 2 . A Wandering Trader can only spawn with a single trade of rarity 2 . |
Parameter emeralds | Type int | Description The amount of Emeralds. |
Parameter forSale | Type ItemStack | Description What ItemStack is being sold (by the Wandering Trader). |
Parameter maxTrades | Type int | Description How many times can this trade be done. |
Parameter xp | Type int | Description How much Experience is given by trading. |
Adds a Wandering Trader Trade for emeralds for an Item. An example being, giving a Wandering Trader 2 emeralds for an arrow.
Parameter | Type | Description |
---|---|---|
Parameter rarity | Type int | Description The rarity of the Trade. Valid options are 1 or 2 . A Wandering Trader can only spawn with a single trade of rarity 2 . |
Parameter price | Type IItemStack | Description The ItemStack being given to the Wandering Trader. |
Parameter forSale | Type IItemStack | Description What ItemStack is being sold (by the Wandering Trader). |
Parameter maxTrades | Type int | Description How many times can this trade be done. |
Parameter xp | Type int | Description How much Experience is given by trading. |
Removes all the trades for the given profession and villagerLevel
Parameter | Type | Description |
---|---|---|
Parameter profession | Type VillagerProfession | Description hat profession to remove from. |
Parameter villagerLevel | Type int | Description The level the Villager needs to be. |
Removes all wandering trades of the given rarity
Parameter | Type | Description |
---|---|---|
Parameter rarity | Type int | Description The rarity of the Trade. Valid options are 1 or 2 . A Wandering Trader can only spawn with a single trade of rarity 2 . |
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.
Parameter | Type | Description | Optional | Default Value |
---|---|---|---|---|
Parameter profession | Type VillagerProfession | Description What profession this trade should be for. | Optional false | Default Value |
Parameter villagerLevel | Type int | Description The level the Villager needs to be. | Optional false | Default Value |
Parameter forSale | Type IItemStack | Description What ItemStack is being sold (by the Villager). | Optional false | Default Value |
Parameter price | Type IItemStack | Description | Optional true | Default Value item:minecraft:air |
Parameter price2 | Type IItemStack | Description | Optional true | Default Value item:minecraft:air |
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.
Parameter | Type | Description |
---|---|---|
Parameter profession | Type VillagerProfession | Description What profession this trade should be for. |
Parameter villagerLevel | Type int | Description The level the Villager needs to be. |
Parameter buyingItem | Type ItemDefinition | Description The base ItemStack that a random Dye colour will be applied to. E.G. A leather chestplate with no effect applied. |
Removes a Villager trade for Emeralds for Items. An example being, giving a villager 20 Wheat and getting an Emerald from the villager.
Parameter | Type | Description |
---|---|---|
Parameter profession | Type VillagerProfession | Description What profession this trade should be for. |
Parameter villagerLevel | Type int | Description The level the Villager needs to be. |
Parameter tradeFor | Type ItemDefinition | Description What ItemStack is being sold (by the Villager). |
Removes a Villager trade for an Enchanted Book. An example being, giving a villager Emeralds and getting an Enchanted Book with a random Enchantment.
Parameter | Type | Description |
---|---|---|
Parameter profession | Type VillagerProfession | Description What profession this trade should be for. |
Parameter villagerLevel | Type int | Description The level the Villager needs to be. |
Removes a Villager trade for an Enchanted Item. An example being, giving a villager 3 Emeralds and getting an Enchanted Pickaxe.
Parameter | Type | Description |
---|---|---|
Parameter profession | Type VillagerProfession | Description What profession this trade should be for. |
Parameter villagerLevel | Type int | Description The level the Villager needs to be. |
Parameter buyingItem | Type IItemStack | Description The ItemStack that the Villager is selling (including any NBT). |
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.
Parameter | Type | Description |
---|---|---|
Parameter profession | Type VillagerProfession | Description What profession this trade should be for. |
Parameter villagerLevel | Type int | Description The level the Villager needs to be. |
Parameter sellingItem | Type IItemStack | Description What ItemStack is being given to the Villager. |
Parameter buyingItem | Type IItemStack | Description The item that the Villager is selling. |
Removes a Villager trade for Items for Emeralds. An example being, giving a villager an Emerald and getting 4 Pumpkin Pies from the villager.
Parameter | Type | Description |
---|---|---|
Parameter profession | Type VillagerProfession | Description What profession this trade should be for. |
Parameter villagerLevel | Type int | Description The level the Villager needs to be. |
Parameter sellingItem | Type IItemStack | Description What ItemStack is being given to the Villager. |
Removes a Villager trade for Suspicious Stew. An example being, giving a villager an Emerald and getting a bowl of Suspicious Stew back.
Parameter | Type | Description |
---|---|---|
Parameter profession | Type VillagerProfession | Description What profession this trade should be for. |
Parameter villagerLevel | Type int | Description The level the Villager needs to be. |
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.
Parameter | Type | Description |
---|---|---|
Parameter profession | Type VillagerProfession | Description What profession this trade should be for. |
Parameter villagerLevel | Type int | Description The level the Villager needs to be. |
Parameter potionStack | Type IItemStack | Description The base ItemStack that a random potion effect will be applied to. E.G. A tipped Arrow with no effect applied. |
Parameter sellingItem | Type ItemDefinition | Description What ItemStack is being given to the Villager. |
Removes the specified trade for the given profession and villagerLevel.
Parameter | Type | Description | Optional | Default Value |
---|---|---|---|---|
Parameter profession | Type VillagerProfession | Description That profession to remove from. | Optional false | Default Value |
Parameter villagerLevel | Type int | Description The level the Villager needs to be. | Optional false | Default Value |
Parameter buying | Type IIngredient | Description The first item that you are giving to the villager. | Optional false | Default Value |
Parameter selling | Type IIngredient | Description The item that the villager is selling to you. | Optional false | Default Value |
Parameter secondBuying | Type IIngredient | Description The second item that you are giving to the villager. Will default to air if not provided. | Optional true | Default Value item:minecraft:air |
Removes all trades that have the specified item as the buying item for the given profession and villagerLevel.
Parameter | Type | Description |
---|---|---|
Parameter profession | Type VillagerProfession | Description That profession to remove from. |
Parameter villagerLevel | Type int | Description The level the Villager needs to be. |
Parameter buying | Type IIngredient | Description The first item that you are giving to the villager. |
Removes all trades that have the specified items as the buying items for the given profession and villagerLevel.
Parameter | Type | Description |
---|---|---|
Parameter profession | Type VillagerProfession | Description That profession to remove from. |
Parameter villagerLevel | Type int | Description The level the Villager needs to be. |
Parameter buying | Type IIngredient | Description The first item that you are giving to the villager. |
Parameter secondBuying | Type IIngredient | Description The second item that you are giving to the villager. Will default to air if not provided. |
Removes all trades that sell the specified item for the given profession and villagerLevel.
Parameter | Type | Description |
---|---|---|
Parameter profession | Type VillagerProfession | Description That profession to remove from. |
Parameter villagerLevel | Type int | Description The level the Villager needs to be. |
Parameter selling | Type IIngredient | Description The item that the villager is selling to you. |
Removes a Villager trade for a Map. An example being, giving a villager 13 Emeralds and getting a Map to a structure.
Parameter | Type | Description |
---|---|---|
Parameter profession | Type VillagerProfession | Description What profession this trade should be for. |
Parameter villagerLevel | Type int | Description The level the Villager needs to be. |
Removes a Wandering Trader trade for Emeralds for Items. An example being, giving a Wandering Trader 2 Emeralds for an Arrow.
Parameter | Type | Description |
---|---|---|
Parameter rarity | Type int | Description The rarity of the Trade. Valid options are 1 or 2 . A Wandering Trader can only spawn with a single trade of rarity 2 . |
Parameter tradeFor | Type IIngredient | Description What ItemStack is being sold (by the Villager). |