Ejemplo n.º 1
0
func chop(client *mcclient.Client, p xyz) {
	for {
		block, _, _, _, _, _ := client.GetBlock(p.x, p.y, p.z)

		if block == 17 {
			moveTo(client, p)
			ansi.Printf(ansi.Green, "Breaking block at (%d, %d, %d)\n", p.x, p.y, p.z)
			die(client.SendPacket(0x0E, int8(0), int32(p.x), int8(p.y), int32(p.z), int8(5)))
			die(client.SendPacket(0x0E, int8(2), int32(p.x), int8(p.y), int32(p.z), int8(5)))
			time.Sleep(time.Second * 3)
			p.y++

		} else {
			break
		}
	}
}
Ejemplo n.º 2
0
func moveTo(client *mcclient.Client, p xyz) {
	p.x++ // Dont stand in the tree!

	ticker := time.NewTicker(mcclient.Tick)

	ansi.Printf(ansi.Green, "Moving from (%d, %d, %d) to (%d, %d, %d)\n", int(client.PlayerX), int(client.PlayerY), int(client.PlayerZ), p.x, p.y, p.z)

	for (int(client.PlayerX) != p.x) || (int(client.PlayerY) != p.y) || (int(client.PlayerZ) != p.z) {

		//println(client.PlayerX, client.PlayerY, client.PlayerZ)

		if int(client.PlayerX) < p.x {
			client.PlayerX += 0.2
		} else if int(client.PlayerX) > p.x {
			client.PlayerX -= 0.2
		}

		if int(client.PlayerY) < p.y {
			client.PlayerY += 0.2
		} else if int(client.PlayerY) > p.y {
			client.PlayerY -= 0.2
		}

		if int(client.PlayerZ) < p.z {
			client.PlayerZ += 0.2
		} else if int(client.PlayerZ) > p.z {
			client.PlayerZ -= 0.2
		}

		client.PlayerStance = client.PlayerY + 1.0
		die(client.SendPacket(0x0D, client.PlayerX, client.PlayerY, client.PlayerStance, client.PlayerZ, client.PlayerYaw, client.PlayerPitch, client.PlayerOnGround))

		<-ticker.C
	}

	ansi.Printf(ansi.Green, "Done moving\n")
}