2024-07-07 15:44:16 -04:00
|
|
|
function core (bot, options, config) {
|
|
|
|
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
|
|
|
},
|
|
|
|
position: null,
|
|
|
|
currentBlockRelative: { x: 0, y: 0, z: 0 },
|
|
|
|
refill () {
|
|
|
|
const pos = bot.core.position
|
|
|
|
const { start, end } = bot.core.area
|
|
|
|
|
|
|
|
if (!pos) return
|
2024-09-19 11:30:06 -04:00
|
|
|
if (bot.options.useChat || bot.options.isCreayun || bot.options.isSavage) return
|
|
|
|
if (isNaN(pos.x + start.x)) {
|
|
|
|
bot.chat.command('spawn');
|
|
|
|
return
|
|
|
|
}
|
|
|
|
/*^^^
|
|
|
|
for checking is the core pos is null and if so
|
|
|
|
it will not refill core until the pos is not NaN
|
|
|
|
instead of tping to a set cords cuz fuck you im not doing that
|
|
|
|
*/
|
2024-07-20 20:27:17 -04:00
|
|
|
bot.chat.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)}'}`)
|
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
|
|
|
|
}
|
|
|
|
bot.core.refill()
|
|
|
|
},
|
|
|
|
|
|
|
|
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) {
|
|
|
|
const location = bot.core.currentBlock()
|
|
|
|
if (!location) return
|
2024-08-21 12:20:11 -04:00
|
|
|
if (bot.options.isSavage || bot.options.isCreayun || bot.options.useChat) {
|
2024-10-09 12:12:54 -04:00
|
|
|
return
|
2024-07-20 20:27:17 -04:00
|
|
|
} else {
|
|
|
|
bot._client.write('update_command_block', { command: command.substring(0, 32767), location, mode: 1, flags: 0b100 })
|
|
|
|
bot.core.incrementCurrentBlock()
|
|
|
|
}
|
2024-07-07 15:44:16 -04:00
|
|
|
}
|
|
|
|
}
|
2024-07-20 20:27:17 -04:00
|
|
|
// if (bot.options.useChat ?? bot.options.isCreayun ?? bot.options.isSavage) return
|
2024-09-19 11:30:06 -04:00
|
|
|
if (bot.options.isSavage || bot.options.isCreayun) return
|
2024-07-07 15:44:16 -04:00
|
|
|
bot.on('move', () => {
|
2024-07-20 20:27:17 -04:00
|
|
|
// if (bot.options.isSavage) return
|
2024-07-07 15:44:16 -04:00
|
|
|
bot.core.move(bot.position)
|
2024-07-20 20:27:17 -04:00
|
|
|
// setTimeout(() => bot.core.run('say Hello, world!'), 1000)
|
2024-07-07 15:44:16 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = core;
|