package jesse.keeblarcraft.GuiMgr;

import jesse.keeblarcraft.Keeblarcraft;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.SimpleInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.ScreenHandler;

// Server side screen handler for the attribute tree
public class TreeHandler extends ScreenHandler {
    /////////////////////////////////////////////////////////////////////////////
    /// @fn         TreeHandler
    ///
    /// @arg[in]    syncId is SUPPOSED to be some sync identifier between the
    ///             server and client. This isn't being used yet, so there isn't
    ///             enough knowledge to make a good documentation note on it.
    ///             Coming soon!
    ///
    /// @arg[in]    inventory is the players inventory. Required by HandledScreen
    ///             object however is unused currently so we make the size 0. As
    ///             needs and use-cases change; this may be reworked in the future
    ///
    /// @brief      Class constructor
    /////////////////////////////////////////////////////////////////////////////
    public TreeHandler(int syncId, PlayerInventory inventory) {
        // Call the constructor below
        this(syncId, inventory, new SimpleInventory(0));
    }

    /////////////////////////////////////////////////////////////////////////////
    /// @fn         TreeHandler
    ///
    /// @arg[in]    syncId is SUPPOSED to be some sync identifier between the
    ///             server and client. This isn't being used yet, so there isn't
    ///             enough knowledge to make a good documentation note on it.
    ///             Coming soon!
    ///
    /// @arg[in]    inventory is the players inventory. Required by HandledScreen
    ///             object however is unused currently so we make the size 0. As
    ///             needs and use-cases change; this may be reworked in the future
    ///
    /// @arg[in]    inventory is the SERVER's inventory - which is what syncId
    ///             would likely be useful for. Once I (Jesse) get the screen stuff
    ///             more sorted out - a more useful doxygen comment will be applied
    ///             here in this class. Coming soon!
    ///
    /// @brief      Class constructor
    /////////////////////////////////////////////////////////////////////////////
    public TreeHandler(int syncId, PlayerInventory playerInventory, Inventory inventory) {
        super(Keeblarcraft.TREE_HANDLER, syncId);

        System.out.println("Created tree handler");
        System.out.println("Is static var null? " + Keeblarcraft.TREE_HANDLER == null ? "YES":"NO");
    }

    /////////////////////////////////////////////////////////////////////////////
    /// @fn         quickMove
    ///
    /// @arg[in]    player is the player entity moving an item
    ///
    /// @arg[in]    slot is the inventory slot to quick move to (shift+click)
    ///
    /// @brief      Required by parent class; currently do nothing as we aren't
    ///             using inventories in the gui's!
    /////////////////////////////////////////////////////////////////////////////
    @Override
    public ItemStack quickMove(PlayerEntity player, int slot) {
        return ItemStack.EMPTY;
    }

    /////////////////////////////////////////////////////////////////////////////
    /// @fn         canUse
    ///
    /// @arg[in]    player is the player entity moving an item
    ///
    /// @brief      Returns whether the screen handler can be used. Required by
    ///             parent class as its abstract; but for now players can always
    ///             use GUI's and need no confirmation!
    /////////////////////////////////////////////////////////////////////////////
    @Override
    public boolean canUse(PlayerEntity player) {
        return true;
    }
}
