From 4976a5e72d0e210b61b7196d7334c6d065a587ef Mon Sep 17 00:00:00 2001 From: Tnze Date: Sun, 4 Apr 2021 10:29:30 +0800 Subject: [PATCH] chunk example fix --- net/packet/util.go | 2 +- save/chunk_test.go | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/net/packet/util.go b/net/packet/util.go index 6f6f619..d69ccb3 100644 --- a/net/packet/util.go +++ b/net/packet/util.go @@ -20,7 +20,7 @@ import ( // Note that Ary DO NOT read or write the Len. You are controlling it manually. type Ary struct { Len interface{} // Value or Pointer of any integer type, only needed in ReadFrom - Ary interface{} // Slice of FieldEncoder, FieldDecoder or both (Field) + Ary interface{} // Slice or Pointer of Slice of FieldEncoder, FieldDecoder or both (Field) } func (a Ary) WriteTo(r io.Writer) (n int64, err error) { diff --git a/save/chunk_test.go b/save/chunk_test.go index 61e5dd7..f91b4f5 100644 --- a/save/chunk_test.go +++ b/save/chunk_test.go @@ -5,7 +5,6 @@ import ( "github.com/Tnze/go-mc/data/packetid" pk "github.com/Tnze/go-mc/net/packet" "github.com/Tnze/go-mc/save/region" - "math/rand" "testing" "unsafe" ) @@ -41,8 +40,8 @@ func BenchmarkColumn_Load(b *testing.B) { defer r.Close() for i := 0; i < b.N; i++ { - //x, y := (i%1024)/32, (i%1024)%32 - x, y := rand.Intn(32), rand.Intn(32) + x, y := (i%1024)/32, (i%1024)%32 + //x, y := rand.Intn(32), rand.Intn(32) data, err := r.ReadSector(x, y) if err != nil { @@ -116,8 +115,8 @@ func ExampleColumn_send() { PrimaryBitMask, // PrimaryBitMask pk.NBT(c.Level.Heightmaps), // Heightmaps bal, pk.Ary{ - Len: bal, // Biomes array length - Ary: c.Level.Biomes, // Biomes + Len: bal, // Biomes array length + Ary: *(*[]pk.VarInt)(unsafe.Pointer(&c.Level.Biomes)), // Biomes }, size, pk.Ary{ Len: size, // Size