Sandertv / gophertunnel

General purpose library for Minecraft Bedrock Edition software written in Go
MIT License
423 stars 96 forks source link

[HELP] How to get names of players online? #32

Closed navaneeth-dev closed 4 years ago

navaneeth-dev commented 4 years ago

Or in other words how do i read packet data? Sorry if im noob (should probably put how to handle packet data in readme)

defer conn.Close()
    for {
        pk, err := conn.ReadPacket()

        if err != nil {
            log.Fatal(err)
        }

        var players []protocol.PlayerListEntry

        //
        //err = pk.Unmarshal([]byte(pk))
        //

        // Handle the incoming packet.
        if err := conn.WritePacket(&packet.PlayerList{
            ActionType: packet.PlayerListActionAdd,
            Entries:    players,
        }); err != nil {
            break
        }
    }