1.21.6 Clientbound PlayState Packets

This commit is contained in:
2025-06-20 04:22:08 +08:00
parent e40ed2e534
commit 195d34f32d
204 changed files with 10118 additions and 3287 deletions

View File

@ -0,0 +1,35 @@
package client
//codec:gen
type UpdateSectionsBlocks struct {
ChunkSectionPosition int64
Blocks []int64 `mc:"VarLong"`
}
func (s *UpdateSectionsBlocks) SetSectionPos(x, y, z int32) {
s.ChunkSectionPosition = ((int64(x) & 0x3FFFFF) << 42) | (int64(y) & 0xFFFFF) | ((int64(z) & 0x3FFFFF) << 20)
}
func (s UpdateSectionsBlocks) ToSectionPos() (x, y, z int32) {
sectionX := int32(s.ChunkSectionPosition >> 42)
sectionY := int32(s.ChunkSectionPosition << 44 >> 44)
sectionZ := int32(s.ChunkSectionPosition >> 22 >> 42)
return sectionX, sectionY, sectionZ
}
func (s *UpdateSectionsBlocks) AddBlock(x, y, z int, stateID int32) {
s.Blocks = append(s.Blocks, int64(stateID)<<12|(int64(x)<<8|int64(y)<<4|int64(z)))
}
func (s UpdateSectionsBlocks) ParseBlocks() map[[3]int32]int32 {
m := make(map[[3]int32]int32)
for _, block := range s.Blocks {
blockStateId := block >> 12
blockLocalX := (block >> 8) & 0xF
blockLocalY := block & 0xF
blockLocalZ := (block >> 4) & 0xF
m[[3]int32{int32(blockLocalX), int32(blockLocalY), int32(blockLocalZ)}] = int32(blockStateId)
}
return m
}