Files
TarnaWijaya 26ed99fda6
Build and deploy / Build (push) Has been cancelled
Build and deploy / Update Contributors (push) Has been cancelled
Build and deploy / Deploy (push) Has been cancelled
up3
2026-07-09 08:33:57 +08:00

31 lines
1.1 KiB
Go

package block
import (
"github.com/df-mc/dragonfly/server/block/cube"
"github.com/df-mc/dragonfly/server/item"
"github.com/df-mc/dragonfly/server/item/inventory"
"github.com/df-mc/dragonfly/server/world"
)
// ContainerViewer represents a viewer that is able to view a container and its inventory.
type ContainerViewer interface {
world.Viewer
// ViewSlotChange views a change of a single slot in the inventory, in which the item was changed to the
// new item passed.
ViewSlotChange(slot int, newItem item.Stack)
}
// ContainerOpener represents an entity that is able to open a container.
type ContainerOpener interface {
// OpenBlockContainer opens a block container at the position passed.
OpenBlockContainer(pos cube.Pos, tx *world.Tx)
}
// Container represents a container of items, typically a block such as a chest. Containers may have their
// inventory opened by viewers.
type Container interface {
AddViewer(v ContainerViewer, tx *world.Tx, pos cube.Pos)
RemoveViewer(v ContainerViewer, tx *world.Tx, pos cube.Pos)
Inventory(tx *world.Tx, pos cube.Pos) *inventory.Inventory
}