You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 12, 2019. It is now read-only.
After you go g.HandleGame(), you have to get event channel by events := g.GetEvents() and receive Events from events. The events hasn't buffer so if you don't receive Event, game handler will be block.
Generally, you could handle events like this example:
package main
import (
bot "github.com/Tnze/gomcbot""github.com/mattn/go-colorable""log"
)
funcmain() {
//loginlog.SetOutput(colorable.NewColorableStdout())
auth:= bot.Auth{Name: "Steve"}
g, err:=auth.JoinServer("localhost", 25565)
iferr!=nil {
log.Fatal(err)
}
gog.HandleGame()
//handle eventsfore:=rangeg.GetEvents() {
switche.(type) {
case bot.PlayerSpawnEvent:
log.Println("player is spawned")
case bot.ChatMessageEvent: //chat messagelog.Println(e.(bot.ChatMessageEvent).Msg)
case bot.DisconnectEvent: //disconnectlog.Println(bot.ChatMsg(e.(bot.DisconnectEvent)))
default:
// log.Println(e)
}
}
}