Skip to content

Commit

Permalink
updated goal logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
GenerelSchwerz committed Feb 21, 2024
1 parent 9e1f2e7 commit c3c0e87
Show file tree
Hide file tree
Showing 3 changed files with 516 additions and 444 deletions.
30 changes: 27 additions & 3 deletions examples/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const { GoalBlock, GoalLookAt, GoalPlaceBlock, GoalInvert } = goals;
const { Vec3 } = require("vec3");
const rl = require('readline')
const { default: loader, EntityState, EPhysicsCtx, EntityPhysics } = require("@nxg-org/mineflayer-physics-util");
const { GoalMineBlock, GoalFollowEntity } = require("../dist/mineflayer-specific/goals");

const { GoalMineBlock, GoalFollowEntity, GoalCompositeAll } = require("../dist/mineflayer-specific/goals");

const bot = createBot({
username: "testing1",
Expand Down Expand Up @@ -67,6 +66,12 @@ bot.once("spawn", async () => {
bot.pathfinder.setPathfinderOptions({
partialPathProducer: true
})


bot.on('goalFinished', (goal) => {
console.log('goal finished', goal)
bot.chat('goal finished')
})
// bot.physics.yawSpeed = 3;
// bot.physics.pitchSpeed = 3

Expand Down Expand Up @@ -136,11 +141,30 @@ async function cmdHandler(username, msg) {
if (!author) return bot.whisper(username, "failed to find player");
const dist = parseInt(args[0]) || 1;
const goal = GoalFollowEntity.fromEntity(author, dist, {neverfinish: true});
const goal1 = GoalInvert.from(goal);
await bot.pathfinder.goto(goal);
break;
}

case "avoidme": {
if (!author) return bot.whisper(username, "failed to find player");
const dist = parseInt(args[0]) || 5;
const goal = GoalFollowEntity.fromEntity(author, dist, {neverfinish: true});
const goal1 = GoalInvert.from(goal)
console.log(goal1)
await bot.pathfinder.goto(goal1);
break;
}

case "boundaryme": {
if (!author) return bot.whisper(username, "failed to find player");
const dist = parseInt(args[0]) || 5;
const goal = GoalFollowEntity.fromEntity(author, dist, {neverfinish: true});
const goal1 = GoalInvert.from(GoalFollowEntity.fromEntity(author, dist - 1, {neverfinish: true}))

await bot.pathfinder.goto(new GoalCompositeAll(goal, goal1));
break;
}

case "blockatme": {
if (!author) return bot.whisper(username, "failed to find player");
const block = bot.blockAt(author.position);
Expand Down
Loading

0 comments on commit c3c0e87

Please sign in to comment.