2024-11-14 09:25:22 -05:00
|
|
|
const mcData = require('minecraft-data')('1.20.2');
|
2024-12-06 11:04:23 -05:00
|
|
|
const nbt = require('prismarine-nbt');
|
2025-03-07 11:14:42 -05:00
|
|
|
const sleep = require('../util/sleep');
|
2025-01-15 11:32:27 -05:00
|
|
|
function inject (context) {
|
2024-11-22 12:49:22 -05:00
|
|
|
const bot = context.bot;
|
|
|
|
|
const config = context.config;
|
|
|
|
|
const options = context.options;
|
2024-07-07 15:44:16 -04:00
|
|
|
bot.core = {
|
|
|
|
|
area: {
|
2024-07-20 20:27:17 -04:00
|
|
|
start: config.core?.area.start ?? { x: 0, y: 0, z: 0 },
|
|
|
|
|
end: config.core?.area.end ?? { x: 15, y: 0, z: 15 }
|
2024-07-07 15:44:16 -04:00
|
|
|
},
|
2024-11-13 14:44:41 -05:00
|
|
|
|
2024-07-07 15:44:16 -04:00
|
|
|
position: null,
|
2024-11-13 14:44:41 -05:00
|
|
|
|
2024-12-06 11:04:23 -05:00
|
|
|
itemPosition: null,
|
|
|
|
|
|
2024-07-07 15:44:16 -04:00
|
|
|
currentBlockRelative: { x: 0, y: 0, z: 0 },
|
2024-11-13 14:44:41 -05:00
|
|
|
|
2024-12-06 11:04:23 -05:00
|
|
|
usePlacedCommandBlock: false,
|
|
|
|
|
|
|
|
|
|
chatRefill () {
|
2024-07-07 15:44:16 -04:00
|
|
|
const pos = bot.core.position
|
|
|
|
|
const { start, end } = bot.core.area
|
|
|
|
|
|
|
|
|
|
if (!pos) return
|
2025-03-07 11:14:42 -05:00
|
|
|
if (bot.options.mode === "creayun") return;
|
|
|
|
|
|
|
|
|
|
if (bot.options.mode === "savageFriends") {
|
|
|
|
|
command = `minecraft:fill ${pos.x + start.x} ${pos.y + start.y} ${pos.z + start.z} ${pos.x + end.x} ${pos.y + end.y} ${pos.z + end.z} command_block`
|
|
|
|
|
} else {
|
|
|
|
|
command = `minecraft:fill ${pos.x + start.x} ${pos.y + start.y} ${pos.z + start.z} ${pos.x + end.x} ${pos.y + end.y} ${pos.z + end.z} repeating_command_block{CustomName:'${JSON.stringify(config.core.name)}'} destroy`
|
|
|
|
|
}
|
2025-02-25 19:53:19 +00:00
|
|
|
|
2024-12-06 11:04:23 -05:00
|
|
|
bot.chat.command(`${command}`)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
itemRefill () {
|
|
|
|
|
const pos = bot.core.position;
|
|
|
|
|
const { start, end } = bot.core.area;
|
|
|
|
|
const itemPosition = bot.core.itemPosition;
|
|
|
|
|
|
|
|
|
|
if (!pos) return;
|
2024-12-16 13:48:50 -05:00
|
|
|
|
2024-12-06 11:04:23 -05:00
|
|
|
const command = `minecraft:fill ${pos.x + start.x} ${pos.y + start.y} ${pos.z + start.z} ${pos.x + end.x} ${pos.y + end.y} ${pos.z + end.z} repeating_command_block{CustomName:'${JSON.stringify(config.core.name)}'} destroy`
|
|
|
|
|
|
|
|
|
|
bot._client.write('set_creative_slot', {
|
|
|
|
|
slot: 36,
|
|
|
|
|
item: {
|
|
|
|
|
present: true,
|
|
|
|
|
itemId: mcData.itemsByName.repeating_command_block.id,
|
|
|
|
|
itemCount: 1,
|
|
|
|
|
nbtData: nbt.comp({
|
|
|
|
|
BlockEntityTag: nbt.comp({
|
|
|
|
|
CustomName: nbt.string(JSON.stringify(config.core.itemName))
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
});
|
2024-11-14 09:25:22 -05:00
|
|
|
|
2024-12-06 11:04:23 -05:00
|
|
|
bot._client.write('block_dig', {
|
|
|
|
|
status: 0,
|
|
|
|
|
location: itemPosition,
|
|
|
|
|
face: 0
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
bot._client.write('block_place', {
|
|
|
|
|
hand: 0,
|
|
|
|
|
location: itemPosition,
|
|
|
|
|
direction: 0,
|
2025-03-07 11:14:42 -05:00
|
|
|
cursorX: 0,
|
2024-12-06 11:04:23 -05:00
|
|
|
cursorY: 0,
|
2025-03-07 11:14:42 -05:00
|
|
|
cursorZ: 0,
|
2024-12-06 11:04:23 -05:00
|
|
|
insideBlock: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (bot.core.usePlacedCommandBlock) {
|
|
|
|
|
return
|
|
|
|
|
} else {
|
2024-11-14 09:25:22 -05:00
|
|
|
bot._client.write('update_command_block', {
|
2024-12-06 11:04:23 -05:00
|
|
|
location: itemPosition,
|
2024-11-22 12:49:22 -05:00
|
|
|
command,
|
2024-11-14 09:25:22 -05:00
|
|
|
flags: 5,
|
|
|
|
|
mode: 1
|
|
|
|
|
})
|
|
|
|
|
}
|
2024-07-07 15:44:16 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
move (pos = bot.position) {
|
|
|
|
|
bot.core.position = {
|
|
|
|
|
x: Math.floor(pos.x / 16) * 16,
|
|
|
|
|
y: 0,
|
|
|
|
|
z: Math.floor(pos.z / 16) * 16
|
2024-12-06 11:04:23 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bot.core.itemPosition = {
|
2025-03-14 08:01:58 -04:00
|
|
|
x: Math.floor(pos.x - 2),
|
|
|
|
|
y: Math.floor(pos.y - 2),
|
|
|
|
|
z: Math.floor(pos.z - 2)
|
2024-12-06 11:04:23 -05:00
|
|
|
}
|
|
|
|
|
|
2025-03-14 08:01:58 -04:00
|
|
|
if (config.core.itemRefill && bot.options.mode !== "savageFriends") {
|
2024-12-06 11:04:23 -05:00
|
|
|
bot.core.itemRefill();
|
|
|
|
|
} else {
|
|
|
|
|
bot.core.chatRefill();
|
2024-07-07 15:44:16 -04:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
currentBlock () {
|
|
|
|
|
const relativePosition = bot.core.currentBlockRelative
|
|
|
|
|
const corePosition = bot.core.position
|
|
|
|
|
if (!corePosition) return null
|
|
|
|
|
return { x: relativePosition.x + corePosition.x, y: relativePosition.y + corePosition.y, z: relativePosition.z + corePosition.z }
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
incrementCurrentBlock () {
|
|
|
|
|
const relativePosition = bot.core.currentBlockRelative
|
|
|
|
|
const { start, end } = bot.core.area
|
|
|
|
|
|
|
|
|
|
relativePosition.x++
|
|
|
|
|
|
|
|
|
|
if (relativePosition.x > end.x) {
|
|
|
|
|
relativePosition.x = start.x
|
|
|
|
|
relativePosition.z++
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (relativePosition.z > end.z) {
|
|
|
|
|
relativePosition.z = start.z
|
|
|
|
|
relativePosition.y++
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (relativePosition.y > end.y) {
|
|
|
|
|
relativePosition.x = start.x
|
|
|
|
|
relativePosition.y = start.y
|
|
|
|
|
relativePosition.z = start.z
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
run (command) {
|
2024-12-06 11:04:23 -05:00
|
|
|
const location = bot.core.currentBlock();
|
|
|
|
|
const itemPosition = bot.core.itemPosition;
|
|
|
|
|
|
|
|
|
|
if (!location) return;
|
2025-03-07 11:14:42 -05:00
|
|
|
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.incrementCurrentBlock();
|
2024-07-20 20:27:17 -04:00
|
|
|
} else {
|
2024-12-06 11:04:23 -05:00
|
|
|
if (bot.core.usePlacedCommandBlock) {
|
|
|
|
|
bot._client.write('update_command_block', {
|
|
|
|
|
command: command.substring(0, 32767),
|
|
|
|
|
location: itemPosition,
|
|
|
|
|
mode: 1,
|
|
|
|
|
flags: 5,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
bot.core.incrementCurrentBlock();
|
|
|
|
|
} else {
|
|
|
|
|
bot._client.write('update_command_block', {
|
|
|
|
|
command: command.substring(0, 32767),
|
|
|
|
|
location,
|
|
|
|
|
mode: 1,
|
|
|
|
|
flags: 5
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
bot.core.incrementCurrentBlock();
|
|
|
|
|
}
|
2024-07-20 20:27:17 -04:00
|
|
|
}
|
2024-11-13 14:44:41 -05:00
|
|
|
},
|
2025-03-07 11:14:42 -05:00
|
|
|
|
|
|
|
|
async runTracked (command) {
|
|
|
|
|
const location = bot.core.itemPosition;
|
|
|
|
|
let transactionId = Math.floor(Math.random() * 10000);
|
|
|
|
|
|
|
|
|
|
bot._client.write('set_creative_slot', {
|
|
|
|
|
slot: 36,
|
|
|
|
|
item: {
|
|
|
|
|
present: true,
|
|
|
|
|
itemId: mcData.itemsByName.repeating_command_block.id,
|
|
|
|
|
itemCount: 1,
|
|
|
|
|
nbtData: nbt.comp({
|
|
|
|
|
BlockEntityTag: nbt.comp({
|
|
|
|
|
CustomName: nbt.string(JSON.stringify(config.core.itemName))
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
bot._client.write('block_dig', {
|
|
|
|
|
status: 0,
|
|
|
|
|
location: {
|
|
|
|
|
x: location.x,
|
|
|
|
|
y: location.y - 1,
|
|
|
|
|
z: location.z
|
|
|
|
|
},
|
|
|
|
|
face: 0
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
bot._client.write('block_place', {
|
|
|
|
|
hand: 0,
|
|
|
|
|
location,
|
|
|
|
|
direction: 0,
|
|
|
|
|
cursorX: 0,
|
|
|
|
|
cursorY: 0,
|
|
|
|
|
cursorZ: 0,
|
|
|
|
|
insideBlock: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
bot._client.write('update_command_block', {
|
|
|
|
|
command: command.substring(0, 32767),
|
|
|
|
|
location: {
|
|
|
|
|
x: location.x,
|
|
|
|
|
y: location.y,
|
|
|
|
|
z: location.z
|
|
|
|
|
},
|
|
|
|
|
flags: 0b101,
|
|
|
|
|
mode: 1
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await sleep(100);
|
|
|
|
|
|
|
|
|
|
bot._client.write('query_block_nbt', { location, transactionId });
|
|
|
|
|
|
|
|
|
|
bot.on('packet.nbt_query_response', (data) => {
|
|
|
|
|
try {
|
|
|
|
|
if (data.transactionId == transactionId) {
|
|
|
|
|
if (data?.nbt?.value?.LastOutput) {
|
2025-03-14 08:01:58 -04:00
|
|
|
bot.tellraw("@a", JSON.parse(data.nbt.value.LastOutput.value).extra);
|
|
|
|
|
bot.tellraw(`@a[name="${bot.options.username}"]`, {
|
|
|
|
|
translate: "fnfboyfriendbot_command_block_output",
|
|
|
|
|
extra: [
|
|
|
|
|
JSON.parse(data.nbt.value.LastOutput.value).extra
|
|
|
|
|
]
|
|
|
|
|
});
|
2025-03-07 11:14:42 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log(e.stack)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-07-07 15:44:16 -04:00
|
|
|
}
|
2024-11-13 14:44:41 -05:00
|
|
|
|
2025-01-24 10:00:06 -05:00
|
|
|
require('../util/core_util')(bot, config, options);
|
2024-11-14 09:25:22 -05:00
|
|
|
}
|
2025-01-15 11:32:27 -05:00
|
|
|
module.exports = {
|
|
|
|
|
data: {
|
|
|
|
|
enabled: true,
|
|
|
|
|
name: "core",
|
|
|
|
|
type: "extras"
|
|
|
|
|
},
|
|
|
|
|
inject
|
|
|
|
|
};
|