Replace all interface{} to any

This commit is contained in:
Tnze
2023-04-05 19:35:20 +08:00
parent 195945e4ca
commit a42267ba31
21 changed files with 52 additions and 52 deletions

View File

@ -38,7 +38,7 @@ func (p Packet) Scan(fields ...FieldDecoder) error {
}
var bufPool = sync.Pool{
New: func() interface{} {
New: func() any {
return new(bytes.Buffer)
},
}

View File

@ -146,10 +146,10 @@ func ExamplePacket_Scan_joinGame() {
PreGamemode pk.Byte
WorldNames = []pk.Identifier{} // This cannot replace with "var DimensionNames []pk.Identifier" because "nil" has no type information
DimensionCodec struct {
DimensionType interface{} `nbt:"minecraft:dimension_type"`
WorldgenBiome interface{} `nbt:"minecraft:worldgen/biome"`
DimensionType any `nbt:"minecraft:dimension_type"`
WorldgenBiome any `nbt:"minecraft:worldgen/biome"`
}
Dimension interface{}
Dimension any
WorldName pk.Identifier
HashedSeed pk.Long
MaxPlayers pk.VarInt
@ -181,7 +181,7 @@ func ExampleMarshal_setSlot() {
Present bool
ItemID int
ItemCount byte
NBT interface{}
NBT any
}{
{WindowID: 0, Slot: 5, Present: false},
{WindowID: 0, Slot: 5, Present: true, ItemID: 0x01, ItemCount: 1, NBT: pk.Byte(0)},

View File

@ -467,7 +467,7 @@ func (d *Double) ReadFrom(r io.Reader) (n int64, err error) {
}
// NBT encode a value as Named Binary Tag
func NBT(v interface{}, optionalTagName ...string) Field {
func NBT(v any, optionalTagName ...string) Field {
if len(optionalTagName) > 0 {
return nbtField{V: v, FieldName: optionalTagName[0]}
}

View File

@ -26,7 +26,7 @@ var (
//
// Note that Ary DO read or write the Len. You aren't need to do so by your self.
type Ary[LEN VarInt | VarLong | Byte | UnsignedByte | Short | UnsignedShort | Int | Long] struct {
Ary interface{} // Slice or Pointer of Slice of FieldEncoder, FieldDecoder or both (Field)
Ary any // Slice or Pointer of Slice of FieldEncoder, FieldDecoder or both (Field)
}
func (a Ary[LEN]) WriteTo(w io.Writer) (n int64, err error) {