func New(size int, f func(slot int, item item.Stack)) *Inventory {
	if size <= 0 {
		panic("inventory size must be at least 1")
	}
	if f == nil {
		f = func(slot int, item item.Stack) {}
	}
	return &Inventory{h: NopHandler{}, slots: make([]item.Stack, size), f: f, canAdd: func(s item.Stack, slot int) bool { return true }}
}
New creates a new inventory with the size passed. The inventory size cannot be changed after it has been
constructed.
A function may be passed which is called every time a slot is changed. The function may also be nil, if
nothing needs to be done.
package inventory
import (
	"errors"
	"fmt"
	"github.com/df-mc/dragonfly/server/item"
	"math"
	"strings"
	"sync"
)
type Inventory struct {
	mu    sync.RWMutex
	h     Handler
	slots []item.Stack
	f      func(slot int, item item.Stack)
	canAdd func(s item.Stack, slot int) bool
}
var ErrSlotOutOfRange = errors.New("slot is out of range: must be in range 0 <= slot < inventory.Size()")