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 ayj);
    
    @Nullable
    Player getTradingPlayer();
    
    MerchantOffers getOffers();
    
    void overrideOffers(@Nullable final MerchantOffers bja);
    
    void notifyTrade(final MerchantOffer biz);
    
    void notifyTradeUpdated(final ItemStack ben);
    
    Level getLevel();
    
    int getVillagerXp();
    
    void overrideXp(final int integer);
    
    boolean showProgressBar();
    
    SoundEvent getNotifyTradeSound();
    
    default boolean canRestock() {
        return false;
    }
    
    default void openTradingScreen(final Player ayj, final Component lf, final int integer) {
        final OptionalInt optionalInt5 = ayj.openMenu(new SimpleMenuProvider((integer, ayi, ayj) -> new MerchantMenu(integer, ayi, this), lf));
        if (optionalInt5.isPresent()) {
            final MerchantOffers bja6 = this.getOffers();
            if (!bja6.isEmpty()) {
                ayj.sendMerchantOffers(optionalInt5.getAsInt(), bja6, integer, this.getVillagerXp(), this.showProgressBar(), this.canRestock());
            }
        }
    }
}
