diff --git a/bot/example_test.go b/bot/example_test.go index 8faf702..48dd9de 100644 --- a/bot/example_test.go +++ b/bot/example_test.go @@ -25,7 +25,7 @@ func ExampleClient_JoinServer_offline() { c.Auth.UUID = hex.EncodeToString(id[:]) //Login - err := c.JoinServer("localhost", 25565) + err := c.JoinServer("127.0.0.1") if err != nil { log.Fatal(err) } @@ -57,7 +57,7 @@ func ExampleClient_JoinServer_online() { c.AsTk = auth.AccessToken() //Connect server - err = c.JoinServer("localhost", 25565) + err = c.JoinServer("127.0.0.1") if err != nil { log.Fatal(err) } diff --git a/bot/ingame.go b/bot/ingame.go index 67ffa95..9dbb006 100644 --- a/bot/ingame.go +++ b/bot/ingame.go @@ -460,7 +460,7 @@ func handleUpdateHealthPacket(c *Client, p pk.Packet) error { return err } } - if c.Health < 1 { //player is dead + if c.Health <= 0 { //player is dead c.Physics.Run = false sendPlayerPositionAndLookPacket(c) if c.Events.Die != nil { diff --git a/cmd/autofish/autofish.go b/cmd/autofish/autofish.go index c43caf7..5908663 100644 --- a/cmd/autofish/autofish.go +++ b/cmd/autofish/autofish.go @@ -24,7 +24,7 @@ func main() { c = bot.NewClient() //Login - err := c.JoinServer("localhost", 25565) + err := c.JoinServer("127.0.0.1") if err != nil { log.Fatal(err) } diff --git a/cmd/daze/daze.go b/cmd/daze/daze.go index ad188d7..36c81d2 100644 --- a/cmd/daze/daze.go +++ b/cmd/daze/daze.go @@ -14,10 +14,11 @@ import ( ) var address = flag.String("address", "127.0.0.1", "The server address") +var c *bot.Client func main() { flag.Parse() - c := bot.NewClient() + c = bot.NewClient() //Login err := c.JoinServer(*address) @@ -39,6 +40,12 @@ func main() { } } +func onDeath() error { + log.Println("Died and Respawned") + // If we exclude Respawn(...) then the player won't press the "Respawn" button upon death + return c.Respawn() +} + func onGameStart() error { log.Println("Game start") return nil //if err isn't nil, HandleGame() will return it.