Fix bugs in packet.Packet.Pack()

This commit is contained in:
Tnze
2021-12-12 15:23:21 +08:00
parent 38cc60ea65
commit 4e7db1e122
3 changed files with 3 additions and 2 deletions

View File

@ -35,7 +35,7 @@ First, you might have a try of the simple examples. It's a good start.
### Run Examples
- Run `go run github.com/Tnze/go-mc/cmd/mcping localhost` to ping and list the localhost mc server.
- Run `go run github.com/Tnze/go-mc/cmd/daze` to join the local server at *localhost:25565* as Steve on the offline mode.
- Run `go run github.com/Tnze/go-mc/cmd/daze` to join the local server at *localhost:25565* as player named Daze on the offline mode.
### Basic Usage

View File

@ -121,6 +121,6 @@ func (d DisconnectErr) Error() string {
}
func onDisconnect(reason chat.Message) error {
// return a error value so that we can stop main loop
// return an error value so that we can stop main loop
return DisconnectErr{Reason: reason}
}

View File

@ -121,6 +121,7 @@ func (p *Packet) packWithCompression(w io.Writer, threshold int) error {
dataLength := bufPool.Get().(*bytes.Buffer)
defer bufPool.Put(dataLength)
dataLength.Reset()
n3, err := VarInt(int(n1) + n2).WriteTo(dataLength)
if err != nil {
return err