Class SimpleTrade

java.lang.Object
me.shedaniel.architectury.registry.trade.SimpleTrade
All Implemented Interfaces:
net.minecraft.world.entity.npc.VillagerTrades.ItemListing

public class SimpleTrade extends Object implements net.minecraft.world.entity.npc.VillagerTrades.ItemListing
This class is the easiest implementation of a trade object. All trades added by vanilla do have custom classes like VillagerTrades.EmeraldForItems, but they aren't accessible.

Instead of widening the access of those classes or recreating them, this class was added to serve a basic trading implementation. To register a trade, just call TradeRegistry.registerVillagerTrade(net.minecraft.world.entity.npc.VillagerProfession, int, VillagerTrades.ItemListing...) or TradeRegistry.registerTradeForWanderingTrader(boolean, VillagerTrades.ItemListing...).

  • Constructor Summary

    Constructors
    Constructor
    Description
    SimpleTrade(net.minecraft.world.item.ItemStack primaryPrice, net.minecraft.world.item.ItemStack secondaryPrice, net.minecraft.world.item.ItemStack sale, int maxTrades, int experiencePoints, float priceMultiplier)
    Constructor for creating the trade.
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable net.minecraft.world.item.trading.MerchantOffer
    getOffer(net.minecraft.world.entity.Entity entity, Random random)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SimpleTrade

      public SimpleTrade(net.minecraft.world.item.ItemStack primaryPrice, net.minecraft.world.item.ItemStack secondaryPrice, net.minecraft.world.item.ItemStack sale, int maxTrades, int experiencePoints, float priceMultiplier)
      Constructor for creating the trade. You can take a look at all the values the vanilla game uses right here VillagerTrades.TRADES.
      Parameters:
      primaryPrice - The first price a player has to pay to get the 'sale' stack.
      secondaryPrice - An optional, secondary price to pay as well as the primary one. If not needed just use ItemStack.EMPTY.
      sale - The ItemStack which a player can purchase in exchange for the two prices.
      maxTrades - The amount of trades one villager or wanderer can do. When the amount is surpassed, the trade can't be purchased anymore.
      experiencePoints - How much experience points does the player get, when trading. Vanilla uses between 2 and 30 for this.
      priceMultiplier - How much should the price rise, after the trade is used. It is added to the stack size of the primary price. Vanilla uses between 0.05 and 0.2.
  • Method Details

    • getOffer

      @Nullable public @Nullable net.minecraft.world.item.trading.MerchantOffer getOffer(net.minecraft.world.entity.Entity entity, Random random)
      Specified by:
      getOffer in interface net.minecraft.world.entity.npc.VillagerTrades.ItemListing