@nxg-org/mineflayer-util-plugin
Version:
mineflayer utils for NextGEN mineflayer plugins.
45 lines (44 loc) • 2.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FilterFunctions = void 0;
/**
* TODO: Inherit other bot names. May need to communciate to a server for this one. Or perhaps reference this once?
*/
class FilterFunctions {
constructor(bot) {
this.bot = bot;
this.specificNames = [];
this.botNames = [];
}
addBotName(name) {
this.botNames.push(name);
}
getNearestEntity(func, ...args) {
return this.bot.nearestEntity((entity) => func(entity, ...args));
}
static getNearestEntity(bot, func, ...args) {
return bot.nearestEntity((entity) => func(entity, ...args));
}
allButOtherBotsFilter() {
return this.getNearestEntity((e) => { var _a, _b, _c; return e.type === "player" && ((_c = !((_a = this.botNames) === null || _a === void 0 ? void 0 : _a.includes((_b = e.username) !== null && _b !== void 0 ? _b : ""))) !== null && _c !== void 0 ? _c : true); });
}
static allButOtherBotsFilter(bot, ...names) {
return FilterFunctions.getNearestEntity(bot, (e) => { var _a; return e.type === "player" && !names.includes((_a = e.username) !== null && _a !== void 0 ? _a : ""); });
}
specificNamesFilter() {
return this.getNearestEntity((e) => { var _a, _b, _c; return e.type === "player" && ((_c = (_a = this.specificNames) === null || _a === void 0 ? void 0 : _a.includes((_b = e.username) !== null && _b !== void 0 ? _b : "")) !== null && _c !== void 0 ? _c : true); });
}
static specificNamesFilter(bot, ...names) {
return FilterFunctions.getNearestEntity(bot, (e) => { var _a; return e.type === "player" && names.includes((_a = e.username) !== null && _a !== void 0 ? _a : ""); });
}
nearestCrystalFilter() {
return this.getNearestEntity((e) => e.name === "ender_crystal");
}
static nearestCrystalFilter(bot) {
return FilterFunctions.getNearestEntity(bot, (e) => e.name === "ender_crystal");
}
crystalAtPosition(position) {
return this.getNearestEntity((entity) => entity.position.offset(-0.5, -1, -0.5).equals(position));
}
}
exports.FilterFunctions = FilterFunctions;