2023-08-15 23:39:02 -07:00
|
|
|
import minecraftData from 'minecraft-data';
|
2023-11-07 12:00:55 -06:00
|
|
|
import { createBot } from 'mineflayer';
|
|
|
|
import { pathfinder } from 'mineflayer-pathfinder';
|
|
|
|
import { plugin } from 'mineflayer-collectblock';
|
2023-08-15 23:39:02 -07:00
|
|
|
|
2023-11-07 13:06:16 -06:00
|
|
|
const mc_version = '1.19.3'
|
2023-11-07 12:00:55 -06:00
|
|
|
let mcdata = minecraftData(mc_version);
|
|
|
|
|
|
|
|
|
|
|
|
export function initBot(username) {
|
|
|
|
let bot = createBot({
|
|
|
|
host: 'localhost',
|
|
|
|
port: 55916,
|
|
|
|
username: username,
|
|
|
|
version: mc_version,
|
|
|
|
});
|
|
|
|
bot.loadPlugin(pathfinder)
|
|
|
|
bot.loadPlugin(plugin)
|
|
|
|
return bot;
|
|
|
|
}
|
2023-08-15 23:39:02 -07:00
|
|
|
|
|
|
|
export function getItemId(item) {
|
2023-09-29 12:53:56 -07:00
|
|
|
return mcdata.itemsByName[item].id;
|
2023-08-17 00:00:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-09-29 12:53:56 -07:00
|
|
|
export function getAllItems(ignore) {
|
|
|
|
if (!ignore) {
|
|
|
|
ignore = [];
|
|
|
|
}
|
|
|
|
let items = []
|
|
|
|
for (const itemId in mcdata.items) {
|
|
|
|
const item = mcdata.items[itemId];
|
|
|
|
if (!ignore.includes(item.name)) {
|
|
|
|
items.push(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return items;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function getAllItemIds(ignore) {
|
|
|
|
const items = getAllItems(ignore);
|
|
|
|
let itemIds = [];
|
|
|
|
for (const item of items) {
|
|
|
|
itemIds.push(item.id);
|
|
|
|
}
|
|
|
|
return itemIds;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function getAllBlocks(ignore) {
|
|
|
|
if (!ignore) {
|
|
|
|
ignore = [];
|
|
|
|
}
|
2023-08-17 00:00:57 -07:00
|
|
|
let blocks = []
|
2023-09-29 12:53:56 -07:00
|
|
|
for (const blockId in mcdata.blocks) {
|
|
|
|
const block = mcdata.blocks[blockId];
|
|
|
|
if (!ignore.includes(block.name)) {
|
|
|
|
blocks.push(block);
|
2023-08-17 00:00:57 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return blocks;
|
|
|
|
}
|
|
|
|
|
2023-09-29 12:53:56 -07:00
|
|
|
|
|
|
|
export function getAllBlockIds(ignore) {
|
|
|
|
const blocks = getAllBlocks(ignore);
|
|
|
|
let blockIds = [];
|
|
|
|
for (const block of blocks) {
|
|
|
|
blockIds.push(block.id);
|
|
|
|
}
|
|
|
|
return blockIds;
|
|
|
|
}
|