about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2023-02-17 18:34:20 +0100
committerBaitinq <manuelpalenzuelamerino@gmail.com>2023-02-17 18:34:20 +0100
commit43df586e1f8ffdca1677b2887f7748d9b5772b28 (patch)
tree17e06c9f619e59101ea22b3ff25859be4c59555d
parentBot: Increase pathfinding think timeout to 20s (diff)
download2bored2walk-master.tar.gz
2bored2walk-master.tar.bz2
2bored2walk-master.zip
-rw-r--r--src/main.ts29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/main.ts b/src/main.ts
index 4377726..dc3bf25 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -4,11 +4,11 @@ import { ChannelType, Client, GatewayIntentBits } from "discord.js";
 const mineflayerViewer = require('prismarine-viewer').mineflayer
 const antiHunger = require('mineflayer-antihunger').plugin
 const autoTotem = require('mineflayer-auto-totem').autototem
-import { pathfinder, Movements, goals } from 'mineflayer-pathfinder';
+import { pathfinder, Movements, goals, PartiallyComputedPath } from 'mineflayer-pathfinder';
 import { plugin as autoeat } from 'mineflayer-auto-eat';
 import autoArmor from '@nxg-org/mineflayer-auto-armor';
 
-const hostname: string = "localhost"
+const hostname: string = "0b0t.org"
 const goal: goals.Goal = new goals.GoalNearXZ(0, -2000000, 44)
 const updateTimeMinutes: number = 30
 const minHealth: number = 0
@@ -22,6 +22,10 @@ const discordToken: string = process.env.DISCORD_TOKEN as string
 //maybe not need to merge, check if end. to diconnect from proxy make a command or somethin
 //todo maybe fix fall damage antihunger
 //TODO: make it take command messages?
+//TODO: check timeout on real server?
+//TODO: warn when stuck
+//TODO: path events like timeout goal_reached etc
+//TODO: Add date to msgs2
 
 function sendMessageToChannel(message: string) {
   const channel = discordClient?.channels.cache.get(discordChannelId)
@@ -44,7 +48,7 @@ discordClient.once("ready", async () => {
 
 const bot = mineflayer.createBot({
   host: hostname,
-  port: 37253,
+  port: 25565,
   username: "s",//process.env.MINECRAFT_EMAIL as string,
   version: "1.12.2",
   auth: 'microsoft'
@@ -55,6 +59,7 @@ bot.loadPlugin(autoeat)
 bot.loadPlugin(antiHunger)
 bot.loadPlugin(autoArmor)
 bot.loadPlugin(autoTotem)
+//plugin for gapples?
 
 bot.once('spawn', async () => {
   mineflayerViewer(bot, { firstPerson: true, port: 3000 });
@@ -81,12 +86,21 @@ bot.on('goal_reached', async () => {
   sendMessageToChannel(`Reached goal (${goal}) with ${bot.username}\n\tCoords: ${bot.entity?.position}\n\tDim: ${bot.game.dimension}\n\tHP: ${bot.health}`)
 })
 
+/*bot.on('path_reset', async (reason: string) => {
+  console.log(new Date() + " -- PATH RESET!: " + reason + " -- " + bot.entity.position)
+})*/
+
+bot.on('path_update', async (status: PartiallyComputedPath) => {
+  if (status.status === "timeout")//seems to work
+    console.log(new Date() + " -- PATH UPDATE!: " + status.status + " -- " + bot.entity.position)
+})
+
 bot.on('entityMoved', async (entity: any) => {
   if (entity.player === null || entity.username === undefined) return
   if (entity.username === bot.username) return
   if (eval(process.env.MINECRAFT_ALTS as string).includes(entity.username)) return
 
-  quit(`player (${entity.username}) moved nearby`)
+  //quit(`player (${entity.username}) moved nearby`)
 })
 
 bot.on('health', async () => {
@@ -96,7 +110,8 @@ bot.on('health', async () => {
 })
 
 bot.on("physicsTick", async () => {
-  (bot as any).autototem.equip()
+  //(bot as any).autototem.equip()
+  //console.log(bot.targetDigBlock)
 })
 
 setInterval(async () => {
@@ -109,11 +124,13 @@ setInterval(async () => {
   if (bot._client.state !== "play") return
   bot.swingArm(undefined)
   //bot.chat("Saturation: " + bot.foodSaturation + " Food: " + bot.food)
+  //console.log(`health: ${bot.health}`)
 }, swingArmTimeSeconds * 1000);
 
 bot.on('death', () => {
   setTimeout(() => {
-    quit("died")
+    //quit("died")
+    console.log("DIED @ " + bot.entity.position)
   }, 3000);
 })