package net.minecraft.world.item.trading;

import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.entity.player.Inventory;
import java.util.OptionalInt;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.SimpleMenuProvider;
import net.minecraft.world.inventory.MerchantMenu;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.level.Level;
import net.minecraft.world.item.ItemStack;
import javax.annotation.Nullable;
import net.minecraft.world.entity.player.Player;

public interface Merchant {
    void setTradingPlayer(@Nullable final Player bec);
    
    @Nullable
    Player getTradingPlayer();
    
    MerchantOffers getOffers();
    
    void overrideOffers(@Nullable final MerchantOffers bpa);
    
    void notifyTrade(final MerchantOffer boz);
    
    void notifyTradeUpdated(final ItemStack bki);
    
    Level getLevel();
    
    int getVillagerXp();
    
    void overrideXp(final int integer);
    
    boolean showProgressBar();
    
    SoundEvent getNotifyTradeSound();
    
    default boolean canRestock() {
        return false;
    }
    
    default void openTradingScreen(final Player bec, final Component mr, final int integer) {
        final OptionalInt optionalInt5 = bec.openMenu(new SimpleMenuProvider((integer, beb, bec) -> new MerchantMenu(integer, beb, this), mr));
        if (optionalInt5.isPresent()) {
            final MerchantOffers bpa6 = this.getOffers();
            if (!bpa6.isEmpty()) {
                bec.sendMerchantOffers(optionalInt5.getAsInt(), bpa6, integer, this.getVillagerXp(), this.showProgressBar(), this.canRestock());
            }
        }
    }
}
