From bcae505a5942ff87b2bbbbc34d2345b16e26e564 Mon Sep 17 00:00:00 2001 From: Tnze Date: Fri, 3 Dec 2021 11:58:28 +0800 Subject: [PATCH] 1.18 update for bot/server --- bot/basic/info.go | 2 ++ examples/frameworkServer/main.go | 1 + server/ping.go | 5 +++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bot/basic/info.go b/bot/basic/info.go index 9679592..b8c24c1 100644 --- a/bot/basic/info.go +++ b/bot/basic/info.go @@ -20,6 +20,7 @@ type WorldInfo struct { HashedSeed int64 // First 8 bytes of the SHA-256 hash of the world's seed. Used client side for biome noise MaxPlayers int32 // Was once used by the client to draw the player list, but now is ignored. ViewDistance int32 // Render distance (2-32). + SimulationDistance int32 // The distance that the client will process specific things, such as entities. ReducedDebugInfo bool // If true, a Notchian client shows reduced information on the debug screen. For servers in development, this should almost always be false. EnableRespawnScreen bool // Set to false when the doImmediateRespawn gamerule is true. IsDebug bool // True if the world is a debug mode world; debug mode worlds cannot be modified and have predefined blocks. @@ -54,6 +55,7 @@ func (p *Player) handleJoinGamePacket(packet pk.Packet) error { (*pk.Long)(&p.HashedSeed), (*pk.VarInt)(&p.MaxPlayers), (*pk.VarInt)(&p.ViewDistance), + (*pk.VarInt)(&p.SimulationDistance), (*pk.Boolean)(&p.ReducedDebugInfo), (*pk.Boolean)(&p.EnableRespawnScreen), (*pk.Boolean)(&p.IsDebug), diff --git a/examples/frameworkServer/main.go b/examples/frameworkServer/main.go index 8822882..6e77f60 100644 --- a/examples/frameworkServer/main.go +++ b/examples/frameworkServer/main.go @@ -150,6 +150,7 @@ func (m *MyServer) joinGame(conn *net.Conn) error { pk.Long(0), // Hashed Seed pk.VarInt(m.Settings.MaxPlayer), // Max Players pk.VarInt(15), // View Distance + pk.VarInt(15), // Simulation Distance pk.Boolean(false), // Reduced Debug Info pk.Boolean(true), // Enable respawn screen pk.Boolean(false), // Is Debug diff --git a/server/ping.go b/server/ping.go index 4fd0837..f153620 100644 --- a/server/ping.go +++ b/server/ping.go @@ -4,6 +4,7 @@ import ( "encoding/json" "github.com/Tnze/go-mc/chat" + "github.com/Tnze/go-mc/data/packetid" "github.com/Tnze/go-mc/net" pk "github.com/Tnze/go-mc/net/packet" "github.com/google/uuid" @@ -32,14 +33,14 @@ func (s *Server) acceptListPing(conn *net.Conn) { } switch p.ID { - case 0x00: //List + case packetid.ServerInfo: //List var resp []byte resp, err = s.listResp() if err != nil { break } err = conn.WritePacket(pk.Marshal(0x00, pk.String(resp))) - case 0x01: //Ping + case packetid.PingClientbound: //Ping err = conn.WritePacket(p) } if err != nil {