github.com/df-mc/dragonfly@v0.9.13/server/block/container.go (about) 1 package block 2 3 import ( 4 "github.com/df-mc/dragonfly/server/block/cube" 5 "github.com/df-mc/dragonfly/server/item" 6 "github.com/df-mc/dragonfly/server/item/inventory" 7 "github.com/df-mc/dragonfly/server/world" 8 ) 9 10 // ContainerViewer represents a viewer that is able to view a container and its inventory. 11 type ContainerViewer interface { 12 world.Viewer 13 // ViewSlotChange views a change of a single slot in the inventory, in which the item was changed to the 14 // new item passed. 15 ViewSlotChange(slot int, newItem item.Stack) 16 } 17 18 // ContainerOpener represents an entity that is able to open a container. 19 type ContainerOpener interface { 20 // OpenBlockContainer opens a block container at the position passed. 21 OpenBlockContainer(pos cube.Pos) 22 } 23 24 // Container represents a container of items, typically a block such as a chest. Containers may have their 25 // inventory opened by viewers. 26 type Container interface { 27 AddViewer(v ContainerViewer, w *world.World, pos cube.Pos) 28 RemoveViewer(v ContainerViewer, w *world.World, pos cube.Pos) 29 Inventory() *inventory.Inventory 30 }