package net.minecraft.client.player.inventory;

import java.util.AbstractList;
import java.util.Collection;
import java.util.Iterator;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import java.util.List;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.core.NonNullList;
import net.minecraft.world.item.ItemStack;
import com.google.common.collect.ForwardingList;

public class Hotbar extends ForwardingList<ItemStack> {
    private final NonNullList<ItemStack> items;
    
    public Hotbar() {
        this.items = NonNullList.<ItemStack>withSize(Inventory.getSelectionSize(), ItemStack.EMPTY);
    }
    
    @Override
    protected List<ItemStack> delegate() {
        return this.items;
    }
    
    public ListTag createTag() {
        final ListTag lk2 = new ListTag();
        for (final ItemStack bki4 : this.delegate()) {
            ((AbstractList<CompoundTag>)lk2).add(bki4.save(new CompoundTag()));
        }
        return lk2;
    }
    
    public void fromTag(final ListTag lk) {
        final List<ItemStack> list3 = this.delegate();
        for (int integer4 = 0; integer4 < list3.size(); ++integer4) {
            list3.set(integer4, ItemStack.of(lk.getCompound(integer4)));
        }
    }
    
    @Override
    public boolean isEmpty() {
        for (final ItemStack bki3 : this.delegate()) {
            if (!bki3.isEmpty()) {
                return false;
            }
        }
        return true;
    }
}
