Update packetid name
This commit is contained in:
@ -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.Login, F: b.handleJoinGamePacket},
|
||||
bot.PacketHandler{Priority: 0, ID: packetid.KeepAliveClientbound, F: b.handleKeepAlivePacket},
|
||||
bot.PacketHandler{Priority: 0, ID: packetid.PositionClientbound, F: b.handlePlayerPositionAndLook},
|
||||
bot.PacketHandler{Priority: 0, ID: packetid.ClientboundLogin, F: b.handleJoinGamePacket},
|
||||
bot.PacketHandler{Priority: 0, ID: packetid.ClientboundKeepAlive, F: b.handleKeepAlivePacket},
|
||||
bot.PacketHandler{Priority: 0, ID: packetid.ClientboundPlayerPosition, F: b.handlePlayerPositionAndLook},
|
||||
)
|
||||
return b
|
||||
}
|
||||
@ -29,7 +29,7 @@ func (p *Player) Respawn() error {
|
||||
const PerformRespawn = 0
|
||||
|
||||
err := p.c.Conn.WritePacket(pk.Marshal(
|
||||
packetid.ClientCommand,
|
||||
packetid.ServerboundClientCommand,
|
||||
pk.VarInt(PerformRespawn),
|
||||
))
|
||||
if err != nil {
|
||||
|
@ -19,10 +19,10 @@ type EventsListener struct {
|
||||
|
||||
func (e EventsListener) Attach(c *bot.Client) {
|
||||
c.Events.AddListener(
|
||||
bot.PacketHandler{Priority: 64, ID: packetid.Login, F: e.onJoinGame},
|
||||
bot.PacketHandler{Priority: 64, ID: packetid.ChatClientbound, F: e.onChatMsg},
|
||||
bot.PacketHandler{Priority: 64, ID: packetid.KickDisconnect, F: e.onDisconnect},
|
||||
bot.PacketHandler{Priority: 64, ID: packetid.UpdateHealth, F: e.onUpdateHealth},
|
||||
bot.PacketHandler{Priority: 64, ID: packetid.ClientboundLogin, F: e.onJoinGame},
|
||||
bot.PacketHandler{Priority: 64, ID: packetid.ClientboundChat, F: e.onChatMsg},
|
||||
bot.PacketHandler{Priority: 64, ID: packetid.ClientboundDisconnect, F: e.onDisconnect},
|
||||
bot.PacketHandler{Priority: 64, ID: packetid.ClientboundSetHealth, F: e.onUpdateHealth},
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ func (p *Player) handleJoinGamePacket(packet pk.Packet) error {
|
||||
p.WorldNames = *(*[]string)(unsafe.Pointer(&WorldNames))
|
||||
|
||||
err = p.c.Conn.WritePacket(pk.Marshal( //PluginMessage packet
|
||||
packetid.CustomPayloadServerbound,
|
||||
packetid.ServerboundCustomPayload,
|
||||
pk.Identifier("minecraft:brand"),
|
||||
pk.String(p.Settings.Brand),
|
||||
))
|
||||
@ -82,7 +82,7 @@ func (p *Player) handleJoinGamePacket(packet pk.Packet) error {
|
||||
}
|
||||
|
||||
err = p.c.Conn.WritePacket(pk.Marshal(
|
||||
packetid.Settings, // Client settings
|
||||
packetid.ServerboundClientInformation, // Client settings
|
||||
pk.String(p.Settings.Locale),
|
||||
pk.Byte(p.Settings.ViewDistance),
|
||||
pk.VarInt(p.Settings.ChatMode),
|
||||
|
@ -12,7 +12,7 @@ func (p Player) handleKeepAlivePacket(packet pk.Packet) error {
|
||||
}
|
||||
// Response
|
||||
err := p.c.Conn.WritePacket(pk.Packet{
|
||||
ID: packetid.KeepAliveServerbound,
|
||||
ID: packetid.ServerboundKeepAlive,
|
||||
Data: packet.Data,
|
||||
})
|
||||
if err != nil {
|
||||
@ -35,7 +35,7 @@ func (p *Player) handlePlayerPositionAndLook(packet pk.Packet) error {
|
||||
|
||||
// Teleport Confirm
|
||||
err := p.c.Conn.WritePacket(pk.Marshal(
|
||||
packetid.TeleportConfirm,
|
||||
packetid.ServerboundAcceptTeleportation,
|
||||
TeleportID,
|
||||
))
|
||||
if err != nil {
|
||||
@ -45,7 +45,7 @@ func (p *Player) handlePlayerPositionAndLook(packet pk.Packet) error {
|
||||
if !p.isSpawn {
|
||||
// PlayerPositionAndRotation to confirm the spawn position
|
||||
err = p.c.Conn.WritePacket(pk.Marshal(
|
||||
packetid.PositionLook,
|
||||
packetid.ServerboundMoveVehicle,
|
||||
X, Y-1.62, Z,
|
||||
Yaw, Pitch,
|
||||
pk.Boolean(true),
|
||||
|
Reference in New Issue
Block a user