()
| 29 | } |
| 30 | |
| 31 | func (c Container) Encode() []slot.Slot { |
| 32 | s := make([]slot.Slot, len(c)) |
| 33 | for _, item := range c { |
| 34 | id, ok := registry.Item.Lookup(item.Id) |
| 35 | if !ok { |
| 36 | continue |
| 37 | } |
| 38 | s[item.Slot] = slot.Slot{ |
| 39 | ItemCount: item.Count, |
| 40 | ItemId: id, |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | return s |
| 45 | } |
| 46 | |
| 47 | // Set adds the item to the container and replaces the existing one if found, and returns if the operation was successful |
| 48 | func (c *Container) Set(item item.Item) { |