ZenonSeth / logistica

A Minetest item transport and storage mod
Other
1 stars 4 forks source link

Crafting Supplier takes more materials than single item recipe requires, when recipe specified has more than 1 item per slot #18

Closed ZenonSeth closed 1 month ago

ZenonSeth commented 1 month ago

E.g. if the recipe is like so: image Then when requested to craft 1 item the crafting supplier will erroniously:

  1. Require 13 Cobblestone (because there are 6 in one slot), instead of 8 as are needed
  2. Take 13 Cobblestone from the network, and put the leftover 5 into its overflow inventory

Two ways to solve this:

  1. Limit ghost item to 1 item per slot
  2. Make Crafting Supplier check the recipes and take only and exactly what is needed for 1 output.

Created from discussion in https://github.com/ZenonSeth/logistica/issues/17

Ocraw commented 1 month ago

Eh, I should have probably added here instead:

In MCL, creating even stacks, say 8x8, consumes only the 8 needed for one craft, while still crafting 8. The behaviour of requesting all the summed stacks is the same.

Fixed in https://github.com/ZenonSeth/logistica/issues/19

ZenonSeth commented 1 month ago

Release 1.2.4 should now fix this, along with improving the crafting inventory usability by allowing moving items within it, and replacement of items.

Limiting the stacksize to 1 would probably have been easier, but instead I made both the Crafting Supplier and Autocrafter (both affected by this bug) take only the minimum required recipes. This was a bit more difficult because of replacements, but it should now work correctly, while keeping replacements accurate.

Also has been published on ContentDB.

Ocraw commented 1 month ago

Confirming it works. Could the same principle (if I got right what you did) be implemented to import the recipe by clicking with an item on the output? For example clicking on the crafting supplier output holding a furnace automatically sets the ghost items to the recipe for the furnace.

ZenonSeth commented 1 month ago

Yes, that's possible, minetest provides a function to get the crafting recipes for an item. Two things make it a bit more challenging to implement though:

  1. An item can have multiple crafting recipes - not too difficult to solve, just picking the latest one
  2. Item recipes can use groups, rather than specific items, e.g. "group:wood" rather than any specific wood item. I actually don't know what minetest returns in that case, when looking up the recipe. Either it returns a special ItemStack to represent a group, or it translates it to a real recipe - not sure, and if it returns "group:" then that needs to be translated to a real item. In both cases, the recipe arrived at, may not be what the user wants.

Still, it's possible, and for most items it could work just fine. Will keep it in mind to implement, but want to try and take care of some previous bugs/requests first.

ZenonSeth commented 1 month ago

Going to close this as done, as it should be now fixed correctly.