bot can hear sounds now. add some motion API.

This commit is contained in:
JunDao
2019-05-04 00:11:24 +08:00
parent b1422863d0
commit c8505386c6
5 changed files with 865 additions and 38 deletions

View File

@ -1,12 +1,13 @@
package bot
import (
"fmt"
"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
//hand could be one of 0: main hand, 1: off hand
func (c *Client) SwingArm(hand int) error {
return c.conn.WritePacket(pk.Marshal(
data.AnimationServerbound,
@ -22,9 +23,23 @@ func (c *Client) Respawn() error {
))
}
//UseItem use the item player handing.
//hand could be one of 0: main hand, 1: off hand
func (c *Client) UseItem(hand int) error {
return c.conn.WritePacket(pk.Marshal(
data.UseItem,
pk.VarInt(hand),
))
}
//Chat send chat as chat message or command at textbox.
func (c *Client) Chat(msg string) error {
if len(msg) > 256 {
return fmt.Errorf("message too long")
}
return c.conn.WritePacket(pk.Marshal(
data.ChatMessageServerbound,
pk.String(msg),
))
}