Class TradeOfferHelper
java.lang.Object
net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper
Utilities to help with registration of trade offers.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
A builder for rebalanced wandering trader offers. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Deprecated, for removal: This API element is subject to removal in a future version.This never did anything useful.static void
registerRebalancedWanderingTraderOffers
(Consumer<TradeOfferHelper.WanderingTraderOffersBuilder> factory) Registers trade offer factories for use by wandering trades.static void
registerVillagerOffers
(VillagerProfession profession, int level, Consumer<List<TradeOffers.Factory>> factories) Registers trade offer factories for use by villagers.static void
registerVillagerOffers
(VillagerProfession profession, int level, TradeOfferHelper.VillagerOffersAdder factories) Registers trade offer factories for use by villagers.static void
registerWanderingTraderOffers
(int level, Consumer<List<TradeOffers.Factory>> factory) Registers trade offer factories for use by wandering trades.
-
Method Details
-
registerVillagerOffers
public static void registerVillagerOffers(VillagerProfession profession, int level, Consumer<List<TradeOffers.Factory>> factories) Registers trade offer factories for use by villagers. This adds the same trade offers to current and rebalanced trades. To add separate offers for the rebalanced trade experiment, useregisterVillagerOffers(VillagerProfession, int, VillagerOffersAdder)
.Below is an example, of registering a trade offer 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 tolevel
- the profession level the villager must be to offer the tradesfactories
- a consumer to provide the factories
-
registerVillagerOffers
@Experimental public static void registerVillagerOffers(VillagerProfession profession, int level, TradeOfferHelper.VillagerOffersAdder factories) Registers trade offer factories for use by villagers. This method allows separate offers to be added depending on whether the rebalanced trade experiment is enabled. If a particular profession's rebalanced trade offers are not added at all, it falls back to the regular trade offers.Below is an example, of registering a trade offer factory to be added a blacksmith with a profession level of 3:
TradeOfferHelper.registerVillagerOffers(VillagerProfession.BLACKSMITH, 3, (factories, rebalanced) -> { factories.add(new CustomTradeFactory(...); });
Experimental feature. This API may receive changes as necessary to adapt to further experiment changes.
- Parameters:
profession
- the villager profession to assign the trades tolevel
- the profession level the villager must be to offer the tradesfactories
- a consumer to provide the factories
-
registerWanderingTraderOffers
public static void registerWanderingTraderOffers(int level, Consumer<List<TradeOffers.Factory>> factory) Registers trade offer factories for use by wandering trades. This does not add offers for the rebalanced trade experiment. To add rebalanced trades, useregisterRebalancedWanderingTraderOffers(java.util.function.Consumer<net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper.WanderingTraderOffersBuilder>)
.- Parameters:
level
- the level the tradesfactory
- a consumer to provide the factories
-
registerRebalancedWanderingTraderOffers
@Experimental public static void registerRebalancedWanderingTraderOffers(Consumer<TradeOfferHelper.WanderingTraderOffersBuilder> factory) Registers trade offer factories for use by wandering trades. This only adds offers for the rebalanced trade experiment. To add regular trades, useregisterWanderingTraderOffers(int, Consumer)
.Experimental feature. This API may receive changes as necessary to adapt to further experiment changes.
- Parameters:
factory
- a consumer to add trade offers
-
refreshOffers
Deprecated, for removal: This API element is subject to removal in a future version.This never did anything useful.
-