Skip to content

Commit

Permalink
protocol/writer.go: Immediately write 0 and return if Bitset is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
TwistedAsylumMC committed Dec 6, 2024
1 parent a5ea496 commit 8fe7442
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions minecraft/protocol/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8fe7442

Please sign in to comment.