refactor: ♻️ replace add with vec3.offset
This avoids having to import and creat a `new vec3.v()`
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
const { createMachine, interpret, InterpreterStatus } = require('xstate');
|
||||
// import { access, mkdir, writeFile, readFile } from "fs";
|
||||
const { access, mkdir, writeFile, readFile } = require('fs');
|
||||
const v = require('vec3'); // for look dummy action, maybe not needed in future
|
||||
// ANGRAM_PREFIX='MINECRAFT'
|
||||
const { MINECRAFT_DATA_FOLDER } = process.env || require("dotenv-packed").parseEnv().parsed;
|
||||
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');
|
||||
if (player.position || player.entity) {
|
||||
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) {
|
||||
context.player = player;
|
||||
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);
|
||||
return () => bot.off("time", looks);
|
||||
|
||||
Reference in New Issue
Block a user