add SwingArm, Respawn and UseItem function

This commit is contained in:
JunDao
2019-05-03 19:49:13 +08:00
parent 150a5c6f8c
commit b1422863d0
4 changed files with 68 additions and 33 deletions

30
bot/motion.go Normal file
View File

@ -0,0 +1,30 @@
package bot
import (
"github.com/Tnze/go-mc/data"
pk "github.com/Tnze/go-mc/net/packet"
)
//SwingArm swing player's arm.
//hand could be 0: main hand, 1: off hand
func (c *Client) SwingArm(hand int) error {
return c.conn.WritePacket(pk.Marshal(
data.AnimationServerbound,
pk.VarInt(hand),
))
}
//Respawn the player when it was dead.
func (c *Client) Respawn() error {
return c.conn.WritePacket(pk.Marshal(
data.ClientStatus,
pk.VarInt(0),
))
}
func (c *Client) UseItem(hand int) error {
return c.conn.WritePacket(pk.Marshal(
data.UseItem,
pk.VarInt(hand),
))
}