refactor: ♻️ replace add
with vec3.offset
This avoids having to import and creat a `new vec3.v()`
This commit is contained in:
parent
22490f7ec1
commit
60394e38eb
|
@ -296,7 +296,7 @@ function command(username, message) {
|
||||||
switch (message_parts[1]) {
|
switch (message_parts[1]) {
|
||||||
case "me":
|
case "me":
|
||||||
if (player) {
|
if (player) {
|
||||||
bot.lookAt((new v.Vec3(0, 1, 0)).add(player.position))
|
bot.lookAt(player.position.offset(0, 1, 0))
|
||||||
} else {
|
} else {
|
||||||
cfg.quiet || bot.chat("can't see you")
|
cfg.quiet || bot.chat("can't see you")
|
||||||
}
|
}
|
||||||
|
@ -313,7 +313,7 @@ function command(username, message) {
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
const aPlayer = bot.players[message_parts[2]] ? bot.players[message_parts[2]].entity : null
|
const aPlayer = bot.players[message_parts[2]] ? bot.players[message_parts[2]].entity : null
|
||||||
if (aPlayer) bot.lookAt((new v.Vec3(0, 1, 0)).add(aPlayer.position))
|
if (aPlayer) bot.lookAt(aPlayer.position.offset(0, 1, 0))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
@ -474,7 +474,7 @@ function command(username, message) {
|
||||||
case "howdy":
|
case "howdy":
|
||||||
case "heyo":
|
case "heyo":
|
||||||
case "yo":
|
case "yo":
|
||||||
if (player) bot.lookAt((new v.Vec3(0, 1, 0)).add(player.position))
|
if (player) bot.lookAt(player.position.offset(0, 1, 0))
|
||||||
|
|
||||||
// TODO sneak
|
// TODO sneak
|
||||||
// function swingArm() {
|
// function swingArm() {
|
||||||
|
|
|
@ -71,9 +71,7 @@ function lookForMobs() {
|
||||||
bot.pvp.attack(entityEnemy)
|
bot.pvp.attack(entityEnemy)
|
||||||
} else if (entityEnemy) {
|
} else if (entityEnemy) {
|
||||||
bot.lookAt(
|
bot.lookAt(
|
||||||
// (new v.Vec3(0, 1, 0)).add(
|
|
||||||
entityEnemy.position
|
entityEnemy.position
|
||||||
// )
|
|
||||||
)
|
)
|
||||||
cfg.quiet || bot.chat("AH! A creeper! They creep me out!")
|
cfg.quiet || bot.chat("AH! A creeper! They creep me out!")
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
const { createMachine, interpret, InterpreterStatus } = require('xstate');
|
const { createMachine, interpret, InterpreterStatus } = require('xstate');
|
||||||
// import { access, mkdir, writeFile, readFile } from "fs";
|
// import { access, mkdir, writeFile, readFile } from "fs";
|
||||||
const { access, mkdir, writeFile, readFile } = require('fs');
|
const { access, mkdir, writeFile, readFile } = require('fs');
|
||||||
const v = require('vec3'); // for look dummy action, maybe not needed in future
|
|
||||||
// ANGRAM_PREFIX='MINECRAFT'
|
// ANGRAM_PREFIX='MINECRAFT'
|
||||||
const { MINECRAFT_DATA_FOLDER } = process.env || require("dotenv-packed").parseEnv().parsed;
|
const { MINECRAFT_DATA_FOLDER } = process.env || require("dotenv-packed").parseEnv().parsed;
|
||||||
const storage_dir = MINECRAFT_DATA_FOLDER || './data/' + "/sm/";
|
const storage_dir = MINECRAFT_DATA_FOLDER || './data/' + "/sm/";
|
||||||
|
@ -82,7 +81,7 @@ function init(smName = "dummy", webserver) {
|
||||||
const player = context?.player || bot.nearestEntity(entity => entity.type === 'player');
|
const player = context?.player || bot.nearestEntity(entity => entity.type === 'player');
|
||||||
if (player.position || player.entity) {
|
if (player.position || player.entity) {
|
||||||
context.player = player;
|
context.player = player;
|
||||||
bot.lookAt((new v.Vec3(0, 1, 0)).add((player.entity || player).position));
|
bot.lookAt((player.entity || player).position.offset(0, 1, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -93,7 +92,7 @@ function init(smName = "dummy", webserver) {
|
||||||
if (player.position || player.entity) {
|
if (player.position || player.entity) {
|
||||||
context.player = player;
|
context.player = player;
|
||||||
function looks() {
|
function looks() {
|
||||||
bot.lookAt((new v.Vec3(0, 1, 0)).add((player.entity || player).position));
|
bot.lookAt((player.entity || player).position.offset(0, 1, 0));
|
||||||
}
|
}
|
||||||
bot.on("time", looks);
|
bot.on("time", looks);
|
||||||
return () => bot.off("time", looks);
|
return () => bot.off("time", looks);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user