Update /bot for 1.18

This commit is contained in:
Tnze
2021-12-11 02:40:41 +08:00
parent a70aaa81d6
commit 97b706f6eb
10 changed files with 57 additions and 30 deletions

View File

@ -18,9 +18,9 @@ type Player struct {
func NewPlayer(c *bot.Client, settings Settings) *Player {
b := &Player{c: c, Settings: settings}
c.Events.AddListener(
bot.PacketHandler{Priority: 0, ID: packetid.ClientboundLogin, F: b.handleJoinGamePacket},
bot.PacketHandler{Priority: 0, ID: packetid.ClientboundLogin, F: b.handleLoginPacket},
bot.PacketHandler{Priority: 0, ID: packetid.ClientboundKeepAlive, F: b.handleKeepAlivePacket},
bot.PacketHandler{Priority: 0, ID: packetid.ClientboundPlayerPosition, F: b.handlePlayerPositionAndLook},
bot.PacketHandler{Priority: 0, ID: packetid.ClientboundPlayerPosition, F: b.handlePlayerPosition},
)
return b
}

View File

@ -39,7 +39,7 @@ type ServInfo struct {
Brand string
}
func (p *Player) handleJoinGamePacket(packet pk.Packet) error {
func (p *Player) handleLoginPacket(packet pk.Packet) error {
var WorldCount pk.VarInt
var WorldNames = make([]pk.Identifier, 0)
err := packet.Scan(
@ -89,7 +89,8 @@ func (p *Player) handleJoinGamePacket(packet pk.Packet) error {
pk.Boolean(p.Settings.ChatColors),
pk.UnsignedByte(p.Settings.DisplayedSkinParts),
pk.VarInt(p.Settings.MainHand),
pk.Boolean(p.Settings.DisableTextFiltering),
pk.Boolean(p.Settings.EnableTextFiltering),
pk.Boolean(p.Settings.AllowListing),
))
if err != nil {
return Error{err}

View File

@ -21,7 +21,7 @@ func (p Player) handleKeepAlivePacket(packet pk.Packet) error {
return nil
}
func (p *Player) handlePlayerPositionAndLook(packet pk.Packet) error {
func (p *Player) handlePlayerPosition(packet pk.Packet) error {
var (
X, Y, Z pk.Double
Yaw, Pitch pk.Float
@ -48,7 +48,6 @@ func (p *Player) handlePlayerPositionAndLook(packet pk.Packet) error {
packetid.ServerboundMoveVehicle,
X, Y-1.62, Z,
Yaw, Pitch,
pk.Boolean(true),
))
if err != nil {
return Error{err}

View File

@ -9,17 +9,17 @@ type Settings struct {
DisplayedSkinParts uint8 //皮肤显示
MainHand int //主手
// Disables filtering of text on signs and written book titles.
// Currently always true in vanilla client (i.e. the filtering is disabled)
DisableTextFiltering bool
// Enables filtering of text on signs and written book titles.
// Currently, always false (i.e. the filtering is disabled)
EnableTextFiltering bool
AllowListing bool
Brand string // The brand string presented to the server.
// The brand string presented to the server.
Brand string
}
/*
Used by Settings.DisplayedSkinParts.
For each bits set if shows match part.
*/
// Used by Settings.DisplayedSkinParts.
// For each bit set if shows match part.
const (
_ = 1 << iota
Jacket