本文整理匯總了Golang中github.com/minero/minero/server/player.Player.Id方法的典型用法代碼示例。如果您正苦於以下問題:Golang Player.Id方法的具體用法?Golang Player.Id怎麽用?Golang Player.Id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/minero/minero/server/player.Player
的用法示例。
在下文中一共展示了Player.Id方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Handle0A
// Handle0A handles incoming requests of packet 0x0A: Player
func Handle0A(server *Server, sender *player.Player) {
pkt := new(packet.Player)
pkt.ReadFrom(sender.Conn)
resp := &packet.Entity{sender.Id()}
server.BroadcastPacket(resp)
}
示例2: HandleLogin
func (s *Server) HandleLogin(sender *player.Player) {
var r packet.Packet
r = &packet.LoginInfo{
Entity: 33,
LevelType: "default",
GameMode: 1,
Dimension: 0,
Difficulty: 2,
MaxPlayers: 32,
}
r.WriteTo(sender.Conn)
// BUG(toqueteos): Load nearby chunks
for z := int32(-1); z < 2; z++ {
for x := int32(-1); x < 2; x++ {
VirtualChunks(x, z, 64).WriteTo(sender.Conn)
}
}
const (
startX = 8.0
startY = 65.0
startZ = 8.0
)
// Client's spawn position
r = &packet.SpawnPosition{X: int32(startX), Y: int32(startY), Z: int32(startZ)}
r.WriteTo(sender.Conn)
// Client Pos & Look
r = &packet.PlayerPosLook{
startX, startY, startZ, // X, Y, Z
startY + 1.6, // Stance
0.0, 0.0, // Yaw + Pitch
true, // OnGround
}
r.WriteTo(sender.Conn)
// Send nearby clients new client's info
r = &packet.EntityNamedSpawn{
Entity: sender.Id(),
Name: sender.Name,
X: startX, Y: startY, Z: startZ,
Yaw: 0.0,
Pitch: 0.0,
Item: 0,
Metadata: player.JustLoginMetadata(sender.Name),
}
s.BroadcastPacket(r)
// Instantiate all other users on new client
s.BroadcastLogin(sender)
// Save player to server list
s.AddPlayer(sender)
}
示例3: Handle0C
// Handle0C handles incoming requests of packet 0x0C: PlayerLook
func Handle0C(server *Server, sender *player.Player) {
pkt := new(packet.PlayerLook)
pkt.ReadFrom(sender.Conn)
resp := &packet.EntityLook{
Entity: sender.Id(),
Yaw: pkt.Yaw,
Pitch: pkt.Pitch,
}
server.BroadcastPacket(resp)
}
示例4: 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)
}