Compare commits

..

No commits in common. "aded1e4193a9a49a2a11a9be64ea5cdbf3cf98e4" and "72c4622091639edd84d2c0fae14a736ba17fb759" have entirely different histories.

6 changed files with 513 additions and 525 deletions

16
.gitattributes vendored
View File

@ -1,16 +0,0 @@
# See this article for reference: https://help.github.com/articles/dealing-with-line-endings/
# Refreshing repo after line ending change:
# https://help.github.com/articles/dealing-with-line-endings/#refreshing-a-repository-after-changing-line-endings
# Handle line endings automatically for files detected as text
# and leave all files detected as binary untouched.
* text=auto
#
# The above will handle all files NOT found below
#
# These files are text and should be normalized (Convert crlf => lf)
# Use lf as eol for these files
*.js text eol=lf
*.ts text eol=lf
*.json text eol=lf

View File

@ -88,6 +88,7 @@ fs.watch('./lib/plugins', reloadplugin)
cfg.bot = bot cfg.bot = bot
// TODO better name, or switch to array // TODO better name, or switch to array
cfg.botAddressPrefix = '!' cfg.botAddressPrefix = '!'
cfg.botAddressRegex = new RegExp(`^${bot.username} (${cfg.botAddressPrefix}.+)`)
cfg.quiet = true cfg.quiet = true
@ -109,7 +110,6 @@ bot.once("spawn", () => {
} }
cfg.plugins = plugins cfg.plugins = plugins
cfg.botAddressRegex = new RegExp(`^${bot.username} (${cfg.botAddressPrefix}.+)`)
for (const plugin of Object.values(plugins)) { for (const plugin of Object.values(plugins)) {
try { try {

View File

@ -30,10 +30,11 @@ const events = {
whisper: function command_whisper(username, message) { whisper: function command_whisper(username, message) {
if ([bot.username, "me"].includes(username)) return if ([bot.username, "me"].includes(username)) return
if (/^gossip/.test(message)) return if (/^gossip/.test(message)) return
// if (/^!/.test(message) && username === cfg.admin){
if (username === cfg.admin) { if (username === cfg.admin) {
message = message.replace("\\", "@") message = message.replace("\\", "@")
console.info("whispered command", message) console.info("whispered command", message)
if (message.startsWith(cfg.botAddressPrefix)) { if (/^!/.test(message)) {
command(username, message) command(username, message)
} else { } else {
bot.chat(message) bot.chat(message)
@ -296,7 +297,7 @@ function command(username, message) {
switch (message_parts[1]) { switch (message_parts[1]) {
case "me": case "me":
if (player) { if (player) {
bot.lookAt(player.position.offset(0, 1, 0)) bot.lookAt((new v.Vec3(0, 1, 0)).add(player.position))
} else { } else {
cfg.quiet || bot.chat("can't see you") cfg.quiet || bot.chat("can't see you")
} }
@ -313,7 +314,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(aPlayer.position.offset(0, 1, 0)) if (aPlayer) bot.lookAt((new v.Vec3(0, 1, 0)).add(aPlayer.position))
break; break;
} }
break break
@ -474,7 +475,7 @@ function command(username, message) {
case "howdy": case "howdy":
case "heyo": case "heyo":
case "yo": case "yo":
if (player) bot.lookAt(player.position.offset(0, 1, 0)) if (player) bot.lookAt((new v.Vec3(0, 1, 0)).add(player.position))
// TODO sneak // TODO sneak
// function swingArm() { // function swingArm() {

View File

@ -71,7 +71,9 @@ 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!")
} }

View File

@ -2,6 +2,7 @@
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/";
@ -81,7 +82,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((player.entity || player).position.offset(0, 1, 0)); bot.lookAt((new v.Vec3(0, 1, 0)).add((player.entity || player).position));
} }
} }
}, },
@ -92,7 +93,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((player.entity || player).position.offset(0, 1, 0)); bot.lookAt((new v.Vec3(0, 1, 0)).add((player.entity || player).position));
} }
bot.on("time", looks); bot.on("time", looks);
return () => bot.off("time", looks); return () => bot.off("time", looks);