Skip to content

Inventory and crafting

Michael Zangl edited this page May 17, 2020 · 5 revisions

Minebot can help you manage your inventory. Some of this is only useful in scripts, but the craft and store commands should make your life much easier.

Storing

Minebot can store your inventory content in chests. For this to work, each chest must be accessible to the bot - it needs to be able to walk to it.

Prepare your storage area by putting item frames on the chests. Put whatever you want the bot to store in that chest in the item frame. Alternativelly, you can place signs on them and write one or more item names on that sign. Signs standing in front of the chest won't work, the sigh needs to be hanging on the chest.

Then simply run the store command next to the chests and the bot will automatically sort your inventory into the chests. Items for which no matching chest is found stay in your inventory.

/minebot store

Taking from chests.

This allows you to get a whole inventory from chests. The command line to get this is so long that you probably want to use this in scripts. On the chat line, you quickly run into the command length limit.

You need to tell the bot which items you want, how many you want and where it should put them. This is expressed as json array. The slots need to be empty before running this command. You can also run this command multiple times. The result is the same but running one command allows the bot to optimize the order in which it takes the items.

Mind that there may be no spaces in the json String (except you use the javascript API, which I highly recommend for this)

Get something to eat (carrots)

/minebot get [{slotIndex:0,amount:64,itemId:391,damageValue:-1}]

Get some carrots and torches

/minebot get [{"slotIndex":0,"amount":32,"itemId":391,"damageValue":-1},{"slotIndex":1,"amount":64,"itemId":50,"damageValue":-1}]

Get something to eat (carrots, if they are empty fall back to bread). Mind that this might also give you one carrot.

/minebot get [{"slotIndex":0,"amount":64,"itemId":391,"damageValue":-1}]
/minebot get [{"slotIndex":0,"amount":64,"itemId":297,"damageValue":-1}]

You see the true power of this when using javascript. You can even construct your own arrays:

var arr = [{slotIndex:0,amount:64,itemId:391,damageValue:-1}];
for (var i = 1; i < 9; i++) {
  arr.push({slotIndex:i,amount:64,itemId:5,damageValue:1}); // 5:1: spurce planks
}

var strategy = minescript.strategy("minebot", "get", JSON.stringify(arr));
minescript.doStrategy(strategy);

Crafting

Crafting allows you to craft many items automatically. Especially when crafting many items this is way faster than doing it by hand. You can also use this in scripts.

You always need to state how many items you would like. The bot might be off by a few items if the number you requested is not achievable.

To get four stacks of spurce planks, you need to specify the amount (4 * 64 = 256), the block id and - in this case - the subtype.

/minebot craft 256 5 1

In case you do not know the block id any more, you can also use the block name:

/minebot craft 256 planks 1

You can even use this for mod items (as long as the bot can interpret the recipe):

/minebot craft 256 minecraft:planks 1

Inventory access

Using the Javascript API, you can read the inventory content. Use minescript.getInventory()

Tips and Bugs

Furnace

If you wand to use furnaces, use hoppers to build an automated furnace and label the chests with the matching item frames. That way the store and get commands work. You cannot (yet) directly interact with furnaces.

Store inventory for later use

Get whatever you want in your inventory. Then run this javascript:

var inv = minescript.getInventory().getJSON();
minescript.storeString("my-inventory", inv);

To load that inventory, use this script:

var inv = minescript.getString("my-inventory", "[]");
if (inv == "[]") {
  minescript.displayChat("The inventory you requested is empty.");
}
var strategy = minescript.strategy("minebot", "get", inv);
minescript.doStrategy(strategy);

Crafting does not work

Some crafting recipes are not recognized yet. There is no workaround.

Pathfinding

The bot will walk towards the chest or crafting table. For this to work, there needs to be a clear path that only contains horizontal movements. The bot needs to stand in front of the block it should interact with and have a clear line of sight with it - only torches and air may be in the way.