/
completed_using_item.go
54 lines (48 loc) · 1.25 KB
/
completed_using_item.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package packet
import (
"bytes"
"encoding/binary"
)
const (
UseItemEquipArmor = iota
UseItemEat
UseItemAttack
UseItemConsume
UseItemThrow
UseItemShoot
UseItemPlace
UseItemFillBottle
UseItemFillBucket
UseItemPourBucket
UseItemUseTool
UseItemInteract
UseItemRetrieved
UseItemDyed
UseItemTraded
)
// CompletedUsingItem is sent by the server to tell the client that it should be done using the item it is
// currently using.
type CompletedUsingItem struct {
// UsedItemID is the item ID of the item that the client completed using. This should typically be the
// ID of the item held in the hand.
UsedItemID int16
// UseMethod is the method of the using of the item that was completed. It is one of the constants that
// may be found above.
UseMethod int32
}
// ID ...
func (*CompletedUsingItem) ID() uint32 {
return IDCompletedUsingItem
}
// Marshal ...
func (pk *CompletedUsingItem) Marshal(buf *bytes.Buffer) {
_ = binary.Write(buf, binary.LittleEndian, pk.UsedItemID)
_ = binary.Write(buf, binary.LittleEndian, pk.UseMethod)
}
// Unmarshal ...
func (pk *CompletedUsingItem) Unmarshal(buf *bytes.Buffer) error {
return chainErr(
binary.Read(buf, binary.LittleEndian, &pk.UsedItemID),
binary.Read(buf, binary.LittleEndian, &pk.UseMethod),
)
}