inventory

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSlotOutOfRange = errors.New("slot is out of range: must be in range 0 <= slot < inventory.Size()")

Functions

This section is empty.

Types

type Armour

type Armour struct {
	// contains filtered or unexported fields
}

func NewArmour

func NewArmour(f func(slot int, before, after item.Stack)) *Armour

func (*Armour) Boots

func (a *Armour) Boots() item.Stack

func (*Armour) Chestplate

func (a *Armour) Chestplate() item.Stack

func (*Armour) Clear

func (a *Armour) Clear() []item.Stack

func (*Armour) Close

func (a *Armour) Close() error

func (*Armour) Damage

func (a *Armour) Damage(dmg float64, f DamageFunc)

func (*Armour) DamageReduction

func (a *Armour) DamageReduction(dmg float64, src world.DamageSource) float64

func (*Armour) Handle

func (a *Armour) Handle(h Handler)

func (*Armour) Helmet

func (a *Armour) Helmet() item.Stack

func (*Armour) HighestEnchantmentLevel

func (a *Armour) HighestEnchantmentLevel(t item.EnchantmentType) int

func (*Armour) Inventory

func (a *Armour) Inventory() *Inventory

func (*Armour) Items

func (a *Armour) Items() []item.Stack

func (*Armour) KnockBackResistance

func (a *Armour) KnockBackResistance() float64

func (*Armour) Leggings

func (a *Armour) Leggings() item.Stack

func (*Armour) Set

func (a *Armour) Set(helmet, chestplate, leggings, boots item.Stack)

func (*Armour) SetBoots

func (a *Armour) SetBoots(boots item.Stack)

func (*Armour) SetChestplate

func (a *Armour) SetChestplate(chestplate item.Stack)

func (*Armour) SetHelmet

func (a *Armour) SetHelmet(helmet item.Stack)

func (*Armour) SetLeggings

func (a *Armour) SetLeggings(leggings item.Stack)

func (*Armour) Slots

func (a *Armour) Slots() []item.Stack

func (*Armour) String

func (a *Armour) String() string

func (*Armour) ThornsDamage

func (a *Armour) ThornsDamage(f DamageFunc) float64

type Context

type Context = event.Context[Holder]

type DamageFunc

type DamageFunc func(s item.Stack, d int) item.Stack

type Handler

type Handler interface {
	HandleTake(ctx *Context, slot int, it item.Stack)

	HandlePlace(ctx *Context, slot int, it item.Stack)

	HandleDrop(ctx *Context, slot int, it item.Stack)
}

type Holder

type Holder interface{}

type Inventory

type Inventory struct {
	// contains filtered or unexported fields
}

func New

func New(size int, f SlotFunc) *Inventory

func (*Inventory) AddItem

func (inv *Inventory) AddItem(it item.Stack) (n int, err error)

func (*Inventory) Clear

func (inv *Inventory) Clear() []item.Stack

func (*Inventory) Clone

func (inv *Inventory) Clone(f SlotFunc) *Inventory

func (*Inventory) Close

func (inv *Inventory) Close() error

func (*Inventory) ContainsItem

func (inv *Inventory) ContainsItem(it item.Stack) bool

func (*Inventory) ContainsItemFunc

func (inv *Inventory) ContainsItemFunc(n int, comparable func(stack item.Stack) bool) bool

func (*Inventory) Empty

func (inv *Inventory) Empty() bool

func (*Inventory) First

func (inv *Inventory) First(item item.Stack) (int, bool)

func (*Inventory) FirstEmpty

func (inv *Inventory) FirstEmpty() (int, bool)

func (*Inventory) FirstFunc

func (inv *Inventory) FirstFunc(comparable func(stack item.Stack) bool) (int, bool)

func (*Inventory) Handle

func (inv *Inventory) Handle(h Handler)

func (*Inventory) Handler

func (inv *Inventory) Handler() Handler

func (*Inventory) Item

func (inv *Inventory) Item(slot int) (item.Stack, error)

func (*Inventory) Items

func (inv *Inventory) Items() []item.Stack

func (*Inventory) Merge

func (inv *Inventory) Merge(inv2 *Inventory, f func(int, item.Stack, item.Stack)) *Inventory

func (*Inventory) RemoveItem

func (inv *Inventory) RemoveItem(it item.Stack) error

func (*Inventory) RemoveItemFunc

func (inv *Inventory) RemoveItemFunc(n int, comparable func(stack item.Stack) bool) error

func (*Inventory) SetItem

func (inv *Inventory) SetItem(slot int, item item.Stack) error

func (*Inventory) Size

func (inv *Inventory) Size() int

func (*Inventory) SlotFunc

func (inv *Inventory) SlotFunc(f SlotFunc)

func (*Inventory) SlotValidatorFunc

func (inv *Inventory) SlotValidatorFunc(f SlotValidatorFunc)

func (*Inventory) Slots

func (inv *Inventory) Slots() []item.Stack

func (*Inventory) String

func (inv *Inventory) String() string

func (*Inventory) Swap

func (inv *Inventory) Swap(slotA, slotB int) error

type NopHandler

type NopHandler struct{}

func (NopHandler) HandleDrop

func (NopHandler) HandleDrop(*Context, int, item.Stack)

func (NopHandler) HandlePlace

func (NopHandler) HandlePlace(*Context, int, item.Stack)

func (NopHandler) HandleTake

func (NopHandler) HandleTake(*Context, int, item.Stack)

type SlotFunc

type SlotFunc func(slot int, before, after item.Stack)

type SlotValidatorFunc

type SlotValidatorFunc func(s item.Stack, slot int) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL