MCPcopy Create free account
hub / github.com/ZeppelinMC/Zeppelin / Merge

Method Merge

server/container/container.go:74–113  ·  view source on GitHub ↗
(slot item.DataSlot, carriedItem *item.Item)

Source from the content-addressed store, hash-verified

72}
73
74func (c *Container) Merge(slot item.DataSlot, carriedItem *item.Item) {
75 if carriedItem.Is(item.Air) {
76 return
77 }
78 it, ok := c.Slot(slot)
79 if !ok {
80 fmt.Println("nothing occupies slot! setting to", slot, *carriedItem)
81 c.SetAt(*carriedItem, slot)
82
83 s, _ := c.Slot(slot)
84 fmt.Println("new item:", slot, s)
85 return
86 }
87 if !carriedItem.Is(it) || it.Count > 64 {
88 fmt.Println("swap", it, "with", *carriedItem)
89 c.SetAt(*carriedItem, slot)
90 *carriedItem = it
91
92 s, _ := c.Slot(slot)
93 fmt.Println("new item:", slot, s)
94 return
95 }
96
97 it.Count += carriedItem.Count
98 carriedItem.Count = 0
99
100 if it.Count > 64 {
101 carriedItem.Count = it.Count - 64
102
103 it.Count = 64
104 }
105
106 if carriedItem.Count == 0 {
107 *carriedItem = item.Air
108 }
109
110 fmt.Println("new item:", it)
111
112 c.SetAt(it, slot)
113}

Callers

nothing calls this directly

Calls 3

SlotMethod · 0.95
SetAtMethod · 0.95
IsMethod · 0.45

Tested by

no test coverage detected