1.18 update for bot/server

This commit is contained in:
Tnze
2021-12-03 11:58:28 +08:00
parent 43ae82a858
commit bcae505a59
3 changed files with 6 additions and 2 deletions

View File

@ -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),

View File

@ -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

View File

@ -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 {