Enhance BitStorage
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
package save
|
||||
|
||||
import (
|
||||
pk "github.com/Tnze/go-mc/net/packet"
|
||||
"math/bits"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
@ -26,3 +28,19 @@ func TestBitStorage_Set(t *testing.T) {
|
||||
t.Errorf("Encode error, got %v but expected: %v", bs.data, data)
|
||||
}
|
||||
}
|
||||
|
||||
func ExampleNewBitStorage_heightmaps() {
|
||||
// Create a BitStorage
|
||||
bs := NewBitStorage(bits.Len(256), 16*16, nil)
|
||||
// Fill your data
|
||||
for i := 0; i < 16; i++ {
|
||||
for j := 0; j < 16; j++ {
|
||||
bs.Set(i*16+j, 0)
|
||||
}
|
||||
}
|
||||
// Encode as NBT, and this is ready for packet.Marshal
|
||||
type HeightMaps struct {
|
||||
MotionBlocking []uint64 `nbt:"MOTION_BLOCKING"`
|
||||
}
|
||||
_ = pk.NBT(HeightMaps{bs.Longs()})
|
||||
}
|
||||
|
Reference in New Issue
Block a user