Skip to content

Conversation

@AboveAphid
Copy link

Summary

Added the ability to use cartography tables. This code was based upon the furnace.js plugin code.

Changes

Added cartography_table.js plugin
Modified loader.js to load cartography_table.js
Updated api.md docs to explain new functions

Testing

I'm a little new to github and tests so I tried running npm run test
But recieved this, which I assume is because I'm running windows and don't have the right command line tools(?):

> mineflayer@4.33.0 pretest
> npm run lint


> mineflayer@4.33.0 lint
> standard && standard-markdown

'standard' is not recognized as an internal or external command,
operable program or batch file.

Example

In this example the bot finds the nearest cartography table and locks a map using a glass pane and filled map.
It is assumed the bot has already been given the required items (glass pane, and filled map).

async function lock_map() {
    const cartographyTableBlock = bot.findBlock({
        matching: mcData.blocksByName.cartography_table.id,
        maxDistance: 32
    });

    if (cartographyTableBlock) {
        const cartographyTable = await bot.openCartographyTable(cartographyTableBlock);

        const filledMapItem = bot.inventory.findInventoryItem(mcData.itemsByName.filled_map.id);
        const glassPaneItem = bot.inventory.findInventoryItem(mcData.itemsByName.glass_pane.id);

        if (filledMapItem && glassPaneItem) {
            await cartographyTable.putMap(filledMapItem.type, filledMapItem.metadata, filledMapItem.count);
            await cartographyTable.putModifier(glassPaneItem.type, glassPaneItem.metadata, glassPaneItem.count);

            console.log("Waiting...")
            await bot.waitForTicks(20);
            console.log("Waited!")

            const outputItem = cartographyTable.outputItem();
            if (outputItem) {
                await cartographyTable.takeOutput();
                console.log(`Bot took out ${outputItem.count} ${outputItem.name}`);
            }
        } else {
            console.log("Required items not found!")
        }

        // Close the cartography table inventory
        cartographyTable.close();
    }
}

This is based upon the furnace.js plugin with certain modifications made so that it can be used for cartography tables instead.
Added cartography_table.js to plugin loader for bot.
Added cartography table to api.md
(Based upon how furnace was documented)
Changed tab indentation to 2 space indentation to (hopefully) fix the Lint test error that was occuring.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant