Class TradeOfferHelper

java.lang.Object
net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper

public final class TradeOfferHelper extends Object
Utilities to help with registration of trade offers.
  • Method Details

    • registerVillagerOffers

      public static void registerVillagerOffers(net.minecraft.village.VillagerProfession profession, int level, Consumer<List<net.minecraft.village.TradeOffers.Factory>> factories)
      Registers trade offer factories for use by villagers.

      Below is an example, of registering a trade off factory to be added a blacksmith with a profession level of 3:

       TradeOfferHelper.registerVillagerOffers(VillagerProfession.BLACKSMITH, 3, factories -> {
              factories.add(new CustomTradeFactory(...);
       });
       
      Parameters:
      profession - the villager profession to assign the trades to
      level - the profession level the villager must be to offer the trades
      factories - a consumer to provide the factories
    • registerWanderingTraderOffers

      public static void registerWanderingTraderOffers(int level, Consumer<List<net.minecraft.village.TradeOffers.Factory>> factory)
      Registers trade offer factories for use by wandering trades.
      Parameters:
      level - the level the trades
      factory - a consumer to provide the factories
    • refreshOffers

      @Deprecated public static void refreshOffers()
      Deprecated.
      This never did anything useful.