mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 10:44:55 -05:00
"improve" core
This commit is contained in:
parent
079620296f
commit
2765c24e2d
1 changed files with 50 additions and 50 deletions
100
plugins/core.js
100
plugins/core.js
|
@ -53,68 +53,68 @@ function inject (bot, dcclient, config) {
|
|||
bot.console.error(e)
|
||||
}
|
||||
},
|
||||
async loopPlace () {
|
||||
try {
|
||||
const fillCommand = `/minecraft:fill ${core.start.x} ${core.start.y} ${core.start.z} ${core.end.x} ${core.end.y} ${core.end.z} command_block{CustomName:'${JSON.stringify(config.core.customName)}'}`
|
||||
const location = { x: Math.floor(bot.position.x), y: Math.floor(bot.position.y) - 1, z: Math.floor(bot.position.z) }
|
||||
fillCore () {
|
||||
core.start = new Vec3(
|
||||
Math.floor(bot.position.x / 16) * 16,
|
||||
0 /* bot.position.y */,
|
||||
Math.floor(bot.position.z / 16) * 16
|
||||
).floor()
|
||||
core.end = core.start.clone().translate(16, config.core.layers, 16).subtract(new Vec3(1, 1, 1))
|
||||
|
||||
bot.write('set_creative_slot', {
|
||||
slot: 36,
|
||||
item: {
|
||||
present: true,
|
||||
itemId: mcData.itemsByName.repeating_command_block.id,
|
||||
itemCount: 64,
|
||||
nbtData: nbt.comp({
|
||||
BlockEntityTag: nbt.comp({
|
||||
Command: nbt.string(fillCommand),
|
||||
auto: nbt.byte(1),
|
||||
TrackOutput: nbt.byte(0)
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
bot.write('block_dig', {
|
||||
status: 0,
|
||||
location,
|
||||
face: 1
|
||||
})
|
||||
|
||||
bot.write('block_place', {
|
||||
location,
|
||||
direction: 1,
|
||||
hand: 0,
|
||||
cursorX: 0.5,
|
||||
cursorY: 0.5,
|
||||
cursorZ: 0.5,
|
||||
insideBlock: false
|
||||
})
|
||||
} catch (e) {
|
||||
bot.console.error(e)
|
||||
}
|
||||
placeCore()
|
||||
}
|
||||
}
|
||||
|
||||
function fillCore () {
|
||||
core.start = new Vec3(
|
||||
Math.floor(bot.position.x / 16) * 16,
|
||||
0 /* bot.position.y */,
|
||||
Math.floor(bot.position.z / 16) * 16
|
||||
).floor()
|
||||
core.end = core.start.clone().translate(16, config.core.layers, 16).subtract(new Vec3(1, 1, 1))
|
||||
bot.core = core
|
||||
|
||||
bot.core.loopPlace()
|
||||
function placeCore () {
|
||||
try {
|
||||
const fillCommand = `/minecraft:fill ${core.start.x} ${core.start.y} ${core.start.z} ${core.end.x} ${core.end.y} ${core.end.z} command_block{CustomName:'${JSON.stringify(config.core.customName)}'}`
|
||||
const location = { x: Math.floor(bot.position.x), y: Math.floor(bot.position.y) - 1, z: Math.floor(bot.position.z) }
|
||||
|
||||
bot.write('set_creative_slot', {
|
||||
slot: 36,
|
||||
item: {
|
||||
present: true,
|
||||
itemId: mcData.itemsByName.repeating_command_block.id,
|
||||
itemCount: 64,
|
||||
nbtData: nbt.comp({
|
||||
BlockEntityTag: nbt.comp({
|
||||
Command: nbt.string(fillCommand),
|
||||
auto: nbt.byte(1),
|
||||
TrackOutput: nbt.byte(0)
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
bot.write('block_dig', {
|
||||
status: 0,
|
||||
location,
|
||||
face: 1
|
||||
})
|
||||
|
||||
bot.write('block_place', {
|
||||
location,
|
||||
direction: 1,
|
||||
hand: 0,
|
||||
cursorX: 0.5,
|
||||
cursorY: 0.5,
|
||||
cursorZ: 0.5,
|
||||
insideBlock: false
|
||||
})
|
||||
} catch (e) {
|
||||
bot.console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
bot.on('position', fillCore)
|
||||
bot.on('position', bot.core.fillCore)
|
||||
|
||||
const interval = setInterval(() => fillCore(), config.core.refillInterval)
|
||||
const interval = setInterval(bot.core.fillCore, config.core.refillInterval)
|
||||
|
||||
bot.once('end', () => {
|
||||
clearInterval(interval)
|
||||
})
|
||||
|
||||
bot.core = core
|
||||
}
|
||||
|
||||
module.exports = { inject }
|
||||
|
|
Loading…
Reference in a new issue