mirror of
https://code.chipmunk.land/Parker2991/NitoriBot/
synced 2026-12-01 14:45:43 -05:00
added bot.core.commandBlock function to core so there isnt update_command_block packets everywhere and fixed some things up
This commit is contained in:
+27
-44
@@ -1,6 +1,7 @@
|
||||
const nbt = require("prismarine-nbt");
|
||||
const sleep = require("../util/sleep");
|
||||
const convertNbtComponentToJson = require("../util/nbt_parser");
|
||||
const fixansi = require("../util/ansi")
|
||||
|
||||
class CommandCoreModule {
|
||||
constructor(context) {
|
||||
@@ -47,12 +48,6 @@ class CommandCoreModule {
|
||||
0,
|
||||
),
|
||||
),
|
||||
/* item: {
|
||||
present: true,
|
||||
// itemId: 492,
|
||||
itemId: Item.toNotch(new Item(bot.registry.itemsByName.repeating_command_block.id, 1, 0)),
|
||||
itemCount: 1,
|
||||
},*/
|
||||
});
|
||||
|
||||
bot._client.write("block_dig", {
|
||||
@@ -74,12 +69,7 @@ class CommandCoreModule {
|
||||
if (bot.core.usePlacedCommandBlock) {
|
||||
return;
|
||||
} else {
|
||||
bot._client.write("update_command_block", {
|
||||
location: itemPosition,
|
||||
command,
|
||||
flags: 5,
|
||||
mode: 1,
|
||||
});
|
||||
bot.core.commandBlock(command, itemPosition, 1, 5)
|
||||
}
|
||||
} else {
|
||||
bot.chat.command(`${command}`);
|
||||
@@ -136,6 +126,15 @@ class CommandCoreModule {
|
||||
}
|
||||
},
|
||||
|
||||
commandBlock (command, location, mode, flags) {
|
||||
bot._client.write("update_command_block", {
|
||||
command: command.substring(0, 32767),
|
||||
location: location,
|
||||
mode: mode,
|
||||
flags: flags,
|
||||
});
|
||||
},
|
||||
|
||||
run(command) {
|
||||
const location = bot.core.currentBlock();
|
||||
const itemPosition = bot.core.itemPosition;
|
||||
@@ -144,47 +143,25 @@ class CommandCoreModule {
|
||||
if (bot.options.mode === "creayun") {
|
||||
return;
|
||||
} else if (bot.options.mode === "savageFriends") {
|
||||
bot._client.write("update_command_block", {
|
||||
command: command.substring(0, 32767),
|
||||
location: location,
|
||||
mode: 2,
|
||||
flags: 0b101,
|
||||
});
|
||||
bot.core.commandBlock(command, location, 2, 0b101)
|
||||
|
||||
bot.core.incrementCurrentBlock();
|
||||
} else {
|
||||
if (bot.core.usePlacedCommandBlock) {
|
||||
bot._client.write("update_command_block", {
|
||||
command: command.substring(0, 32767),
|
||||
location: itemPosition,
|
||||
mode: 1,
|
||||
flags: 5,
|
||||
});
|
||||
|
||||
bot.core.commandBlock(command, itemPosition, 1, 5)
|
||||
bot.core.incrementCurrentBlock();
|
||||
} else {
|
||||
bot._client.write("update_command_block", {
|
||||
command: command.substring(0, 32767),
|
||||
location,
|
||||
mode: 1,
|
||||
flags: 5,
|
||||
});
|
||||
|
||||
bot.core.commandBlock(command, location, 1, 5)
|
||||
bot.core.incrementCurrentBlock();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
async runTracked(command, selector) {
|
||||
async runTracked(command, source, selector) {
|
||||
const location = bot.core.currentBlock();
|
||||
let transactionId = Math.floor(Math.random() * 10000);
|
||||
|
||||
bot._client.write("update_command_block", {
|
||||
command: command.substring(0, 32767),
|
||||
location,
|
||||
flags: 0b101,
|
||||
mode: 1,
|
||||
});
|
||||
bot.core.commandBlock(command, location, 1, 0b101)
|
||||
|
||||
bot.core.incrementCurrentBlock();
|
||||
|
||||
@@ -192,14 +169,20 @@ class CommandCoreModule {
|
||||
|
||||
bot._client.write("query_block_nbt", { location, transactionId });
|
||||
|
||||
bot.on("packet.nbt_query_response", (data) => {
|
||||
bot.on("packet.nbt_query_response", async (data) => {
|
||||
try {
|
||||
if (data.transactionId == transactionId) {
|
||||
if (data?.nbt?.value?.LastOutput) {
|
||||
bot.tellraw(
|
||||
"@a",
|
||||
JSON.parse(data.nbt.value.LastOutput.value).extra,
|
||||
);
|
||||
const output = JSON.parse(data.nbt.value.LastOutput.value).extra
|
||||
|
||||
if (source.sources.console) {
|
||||
|
||||
} else {
|
||||
bot.tellraw(
|
||||
"@a",
|
||||
output,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
@@ -53,7 +53,7 @@ class DiscordModule {
|
||||
function sendComponent(message) {
|
||||
const ansi = bot
|
||||
.getMessageAsPrismarine(message)
|
||||
?.toAnsi(bot.registry.language)
|
||||
?.toAnsi(bot?.registry?.language)
|
||||
.replaceAll("```\u001b[9```" + "```\u001b[3```")
|
||||
.replaceAll("https://discord", "https:\rdiscord");
|
||||
try {
|
||||
|
||||
+15
-10
@@ -20,6 +20,7 @@ class SelfcareModule {
|
||||
let login = false;
|
||||
let register = false;
|
||||
let positionCount = 0;
|
||||
let loggedin = false
|
||||
bot.vanished = true;
|
||||
bot.on("message", (data) => {
|
||||
try {
|
||||
@@ -191,19 +192,22 @@ class SelfcareModule {
|
||||
|
||||
timer = setInterval(() => {
|
||||
if (bot.options.mode === "savageFriends") {
|
||||
if (login) bot.chat.command("login amogusissus");
|
||||
else if (register)
|
||||
if (login) {
|
||||
bot.chat.command("login amogusissus");
|
||||
loggedin = true
|
||||
}
|
||||
else if (register) {
|
||||
bot.chat.command("register amogusissus amogusissus");
|
||||
else if (gameMode !== 1)
|
||||
loggedin = true
|
||||
}
|
||||
else if (gameMode !== 1 && loggedin)
|
||||
bot.chat.command("minecraft:gamemode creative");
|
||||
else if (permissionLevel < 2)
|
||||
else if (permissionLevel < 2 && loggedin)
|
||||
bot.chat.command(`minecraft:op ${bot.options.username}`);
|
||||
// else if (!prefix)
|
||||
// bot.chat.command(
|
||||
// `rank ${bot.options.username} &8[&bPrefix&8: &3${config.prefixes[0]}&8]`,
|
||||
// );
|
||||
else if (nickname) bot.chat.command("nick off");
|
||||
else if (!vanished && bot.vanished)
|
||||
else if (!prefix && loggedin)
|
||||
bot.chat.command(`rank ${bot.options.username} &8[&bPrefix&8: &3${config.prefixes[0]}&8]`);
|
||||
else if (nickname && loggedin) bot.chat.command("nick off");
|
||||
else if (!vanished && bot.vanished && loggedin)
|
||||
bot.chat.command("essentials:vanish on");
|
||||
else if (clientLock !== 4)
|
||||
bot._client.write("client_command", { actionId: 0 });
|
||||
@@ -244,6 +248,7 @@ class SelfcareModule {
|
||||
god = false;
|
||||
unmuted = false;
|
||||
username = false;
|
||||
loggedin = false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user