From 8fe74428474d7682a3d2b37e666bdfa5cf9328c1 Mon Sep 17 00:00:00 2001 From: TwistedAsylumMC Date: Fri, 6 Dec 2024 14:12:44 +0000 Subject: [PATCH] protocol/writer.go: Immediately write 0 and return if Bitset is zero --- minecraft/protocol/writer.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/minecraft/protocol/writer.go b/minecraft/protocol/writer.go index af6818ca..189163e1 100644 --- a/minecraft/protocol/writer.go +++ b/minecraft/protocol/writer.go @@ -482,6 +482,11 @@ func (w *Writer) Bitset(x *Bitset, size int) { u := new(big.Int) u.Set(x.int) + if len(u.Bits()) == 0 { + _ = w.w.WriteByte(0) + return + } + for u.Cmp(varintMaxByteValue) >= 0 { _ = w.w.WriteByte(byte(u.Bits()[0]) | 0x80) u.Rsh(u, 7)