本文整理匯總了Golang中github.com/minero/minero/server/player.Player.SetPos方法的典型用法代碼示例。如果您正苦於以下問題:Golang Player.SetPos方法的具體用法?Golang Player.SetPos怎麽用?Golang Player.SetPos使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/minero/minero/server/player.Player
的用法示例。
在下文中一共展示了Player.SetPos方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Handle0D
// Handle0D handles incoming requests of packet 0x0D: PlayerPosLook
func Handle0D(server *Server, sender *player.Player) {
pkt := new(packet.PlayerPosLook)
pkt.ReadFrom(sender.Conn)
if pkt.Y > pkt.Stance {
r := &packet.Disconnect{"Weird packet 0x0D. Server didn't switch Y with Stance."}
r.WriteTo(sender.Conn)
return
}
// Player is ready for broadcasts
sender.SetReady()
// Save position
sender.SetPos(pkt.X, pkt.Y, pkt.Z)
sender.SetLook(pkt.Pitch, pkt.Yaw)
var p packet.Packet
// BUG(toqueteos): NMS handle relative movements with other packet
// `packet.EntityRelMove` right now we just teleport to the destination.
p = &packet.EntityTeleport{
Entity: sender.Id(),
X: pkt.X,
Y: pkt.Y,
Z: pkt.Z,
Yaw: pkt.Yaw,
Pitch: pkt.Pitch,
}
server.BroadcastPacket(p)
p = &packet.EntityHeadLook{
Entity: sender.Id(),
HeadYaw: pkt.Yaw,
}
server.BroadcastPacket(p)
}