Merchant .java

net.minecraft.world.item.trading.Merchant (interface): members: openTradingScreen, notifyTradeUpdated, getTradingPlayer, overrideOffers, notifyTrade.

net.minecraft.world.item.tradinginterface51 linescommon1.4 KB

API Surface (0)

No public/protected methods detected (fields or constants only).

Full Source

Merchant.java51 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.item.trading;
2
3
import java.util.OptionalInt;
4
import net.minecraft.network.chat.Component;
5
import net.minecraft.sounds.SoundEvent;
6
import net.minecraft.world.SimpleMenuProvider;
7
import net.minecraft.world.entity.player.Player;
8
import net.minecraft.world.inventory.MerchantMenu;
9
import net.minecraft.world.item.ItemStack;
10
import org.jspecify.annotations.Nullable;
11
12
public interface Merchant {
13
	void setTradingPlayer(@Nullable Player player);
14
15
	@Nullable Player getTradingPlayer();
16
17
	MerchantOffers getOffers();
18
19
	void overrideOffers(MerchantOffers offers);
20
21
	void notifyTrade(MerchantOffer offer);
22
23
	void notifyTradeUpdated(ItemStack itemStack);
24
25
	int getVillagerXp();
26
27
	void overrideXp(final int xp);
28
29
	boolean showProgressBar();
30
31
	SoundEvent getNotifyTradeSound();
32
33
	default boolean canRestock() {
34
		return false;
35
	}
36
37
	default void openTradingScreen(final Player player, final Component title, final int level) {
38
		OptionalInt containerId = player.openMenu(new SimpleMenuProvider((id, inventory, p) -> new MerchantMenu(id, inventory, this), title));
39
		if (containerId.isPresent()) {
40
			MerchantOffers offers = this.getOffers();
41
			if (!offers.isEmpty()) {
42
				player.sendMerchantOffers(containerId.getAsInt(), offers, level, this.getVillagerXp(), this.showProgressBar(), this.canRestock());
43
			}
44
		}
45
	}
46
47
	boolean isClientSide();
48
49
	boolean stillValid(Player player);
50
}
51

Decompiled Minecraft 26.3 source of Merchant (net/minecraft/world/item/trading/Merchant.java) with Mojang official mappings, stored verbatim on the site.