PrismarineJS / mineflayer

Create Minecraft bots with a powerful, stable, and high level JavaScript API.
https://prismarinejs.github.io/mineflayer/
MIT License
4.95k stars 904 forks source link

Craft special cases : handle custom recipes and not consumed items #222

Open rom1504 opened 9 years ago

rom1504 commented 9 years ago

Currently it is assumed that all the blocks used in a recipe are consumed (https://github.com/andrewrk/mineflayer/blob/master/lib/plugins/inventory.js#L572).

It is not true for all recipes (see http://minecraft.gamepedia.com/Written_Book )

So it should be handled by mineflayer :

Custom recipes are related to this consumption/not consumption

roblabla commented 9 years ago

We should test the proxy with a bukkit plugin like http://dev.bukkit.org/bukkit-plugins/recipemanager/ to figure out how it's done.

deathcap commented 9 years ago

Also consider "container" items, e.g., milk bucket's container = empty bucket, returned from crafting cake http://minecraft.gamepedia.com/Cake

rom1504 commented 9 years ago

Yeah so.. I finally understoof what is "outShape" in recipes.json inShape is the shape before crafting, outShape is the shape after crafting

So, it should be checked if there is an outShape there https://github.com/andrewrk/mineflayer/blob/master/lib/plugins/inventory.js#L572 and I think that will handle all the cases we are talking about in that issue.

rom1504 commented 9 years ago

So, it would be nice to test if we can craft a cake. It that works, this issue is half-done.

rom1504 commented 9 years ago

Ok crafting a cake works.

rom1504 commented 9 years ago

Is it possible to get a "written book" by the creative inventory ? it doesn't seem there so I can't test whether that recipe would work.

thejoshwolfe commented 9 years ago

creative api can probably give you everything, since it's how the normal client simply moves items around.

deathcap commented 9 years ago

Also what about firework crafting recipes (according to http://minecraft.gamepedia.com/Fireworks "firework rocket is one of the few items in the game that cannot be taken directly out of a creative inventory") and item repair recipes (combining two damaged tools)

rom1504 commented 9 years ago

I meant "creative inventory" not creative API, ie I don't know how to give myself a written book in the actual game. Edit: oh it doesn't look like in the wiki, but it's there. Its display name is "enchanted book". And the recipe doesn't work with the enchanted book. If someone knows how to do that recipe, please explain, I can't test it with mineflayer if I don't understand how to do it in the game.

I'll try the firework recipe.

"item repair recipe" is not an actual recipe, so it shouldn't be in the recipes.json, maybe it should be stored elsewhere or just computed an other way (the rule is " Two items of the same type and material can be placed anywhere on the crafting grid, and the result is a single repaired item. ") and there should be an other method than bot.craft to do it, maybe bot.repair or something.

rom1504 commented 9 years ago

crafting fireworks works.

rom1504 commented 9 years ago

I'd better have an automatic test for this though (see https://github.com/andrewrk/mineflayer/issues/239#issuecomment-87342357) instead of testing manually.

deathcap commented 9 years ago

I meant "creative inventory" not creative API, ie I don't know how to give myself a written book in the actual game.

You can use commands:

/give player minecraft:written_book 1 0 {author:'Player', title:'title1', resolved:1, generation:0, pages: ['hi']}

rom1504 commented 9 years ago

Ok that worked.

That recipe is broken in mineflayer, the reason is this recipe has ingredients and "outIngredients", which is not handled by mineflayer (and minecraft-data).

see https://github.com/PrismarineJS/minecraft-data/issues/10

rom1504 commented 9 years ago

Recipes with metadata (even the simplest one like "white" log --> "white" wood) are broken. The problem is likely in the data, fixing this depends on https://github.com/PrismarineJS/minecraft-data/issues/7

Also : it would be nice to know which recipe is broken and which is not (see https://github.com/andrewrk/mineflayer/issues/239)

Matitron commented 3 years ago

with 1.17 (note:it may have happened before 1.17) but containers like bottles that are used eg: if i make a recipie that turns a honey bottle into a potato the bottle will remain but we still can't control witch item is consumed but its a start i suppose :P