NetworkConvert encodes the container with the specified size and changes the slot from data slots to network slots. This should be used for inventories
(size int)
| 13 | |
| 14 | // NetworkConvert encodes the container with the specified size and changes the slot from data slots to network slots. This should be used for inventories |
| 15 | func (c Container) EncodeResize(size int) []slot.Slot { |
| 16 | s := make([]slot.Slot, size) |
| 17 | for _, item := range c { |
| 18 | id, ok := registry.Item.Lookup(item.Id) |
| 19 | if !ok { |
| 20 | continue |
| 21 | } |
| 22 | s[item.Slot.Network()] = slot.Slot{ |
| 23 | ItemCount: item.Count, |
| 24 | ItemId: id, |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | return s |
| 29 | } |
| 30 | |
| 31 | func (c Container) Encode() []slot.Slot { |
| 32 | s := make([]slot.Slot, len(c)) |