Lolcroc / CraftingAutomat

A vanilla-flavoured autocrafter.
6 stars 9 forks source link

Harvestcraft recipes don't refill from inventory #5

Closed dlowe-net closed 2 years ago

dlowe-net commented 4 years ago

Many Harvestcraft recipes are unusual in that they provide a tool which is not consumed or replaced by the crafting process. I made a workaround, looking at the source code, where one can put a tool in both the crafting matrix and the inventory and it works.

Lolcroc commented 4 years ago

Can you create a pull request so I can view your changes?

dlowe-net commented 4 years ago

Sorry, I meant found a workaround by looking at the source code, not by modifying it.

It works if there's a non-consumable tool in both the crafting matrix and the crafting inventory, but there shouldn't be a need for one in the inventory.

Lolcroc commented 4 years ago

Aa yes, thanks. I am actually aware of this issue. A fix is pretty annoying since Minecraft recipes do not tell up front which items are consumed and which ones aren’t. It’s on the list for future versions.

Specifically, the issue happens for all recipes that consume something from the crafting matrix, then immediately replace it again after crafting. You can only know the item is not actually consumed by doing the crafting and checking the leftovers for any matches.

dlowe-net commented 4 years ago

Right. There's three possibilities per cell - either something is consumed (maybe not even just one thing - some mod out there could do this), something is transformed (like water buckets), or something is replaced. The first two would interact with the inventory.

I think the code might actually be simpler to detect the crafting changes made than to anticipate what might happen.

Lolcroc commented 4 years ago

The code would be simpler yes, but it’s incompatible with the way it’s set up now. There are 2 reasons:

  1. The crafting automat flags whether or not a recipe can be crafted with its own materials. This requires me to anticipate the cost.
  2. Comparators track the amount of recipes that are craftable. This also requires me to anticipate the cost.

Without the anticipated cost, I cannot make users aware if the automat supports auto-crafting or not. This is an important feature I want to keep. My personal solution will be to “bake” the material cost of those non-standard recipes, for example by simulating the recipe once when it’s put in the matrix. If you have suggestions please let me know

Lolcroc commented 2 years ago

I'm closing this issue for now. Future versions of CA will switch to another mechanism of checking ingredients which should fix bugs like these