mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-23 15:47:57 -05:00
new fill core method
(repeating command block placing method)
This commit is contained in:
parent
0fcf794c81
commit
0acd7861de
1 changed files with 58 additions and 7 deletions
|
@ -1,6 +1,9 @@
|
|||
/* eslint-disable max-len */
|
||||
/* eslint-disable require-jsdoc */
|
||||
const config = require('../config');
|
||||
const nbt = require('prismarine-nbt');
|
||||
const mcData = require('minecraft-data')('1.18.2');
|
||||
const sleep = require('sleep-promise');
|
||||
const chatMessage = require('prismarine-chat')('1.18.2');
|
||||
const Vec3 = require('vec3');
|
||||
|
||||
|
@ -56,7 +59,6 @@ function inject(bot) {
|
|||
} else {
|
||||
bot.chat(fillCommand);
|
||||
}
|
||||
|
||||
bot.emit('core_filled');
|
||||
},
|
||||
};
|
||||
|
@ -67,16 +69,65 @@ function inject(bot) {
|
|||
bot.emit('position', position);
|
||||
});
|
||||
|
||||
bot._client.on('block_change', (packet) => {
|
||||
if (core.isCore(packet.location) && packet.type===0) fillCore();
|
||||
});
|
||||
// bot._client.on('block_change', (packet) => {
|
||||
// if (core.isCore(packet.location) && packet.type===0) fillCore();
|
||||
// });
|
||||
|
||||
bot._client.on('multi_block_change', (packet) => {
|
||||
if (core.start===packet.chunkCoordinates || core.end===packet.chunkCoordinates) fillCore();
|
||||
});
|
||||
// bot._client.on('multi_block_change', (packet) => {
|
||||
// if (core.start===packet.chunkCoordinates || core.end===packet.chunkCoordinates) fillCore();
|
||||
// });
|
||||
|
||||
const interval = setInterval(async () => {
|
||||
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:'{"text":"ChomeNS Bot Core","color":"yellow"}'}`;
|
||||
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),
|
||||
})}),
|
||||
},
|
||||
});
|
||||
await sleep(50);
|
||||
bot.write('block_dig', {
|
||||
status: 0,
|
||||
location: {
|
||||
x: bot.position.x,
|
||||
y: bot.position.y - 1,
|
||||
z: bot.position.z,
|
||||
},
|
||||
face: 1,
|
||||
});
|
||||
await sleep(50);
|
||||
bot.write('block_place', {
|
||||
location: {
|
||||
x: bot.position.x,
|
||||
y: bot.position.y - 1,
|
||||
z: bot.position.z,
|
||||
},
|
||||
hand: 0,
|
||||
direction: 1,
|
||||
cursorX: 0.5,
|
||||
cursorY: 0.5,
|
||||
cursorZ: 0.5,
|
||||
insideBlock: false,
|
||||
});
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
}, 500);
|
||||
|
||||
bot.on('position', fillCore);
|
||||
|
||||
bot.on('end', () => {
|
||||
clearInterval(interval);
|
||||
});
|
||||
|
||||
fillCore();
|
||||
|
||||
bot.core = core;
|
||||
|
|
Loading…
Reference in a new issue