Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite recipe chain calculator #530

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Meegooo
Copy link

@Meegooo Meegooo commented Sep 15, 2024

Rewrote recipe chain calculator. The main difference is that it now uses graph traversal to calculate things. Fixes GTNewHorizons/GT-New-Horizons-Modpack#17148

Notable features:

  • Support for "ore dictionary" (but really for multiple ingredients per slot)
  • Ability to request negative amount of items to indicate that you already have some (disabled by default).
  • Proper handling of recipes with multiple outputs and recursive recipes

There are some differences in how it looks and feels. Here are new behaviors.

  1. Modifying item counts

    • Ctrl+scroll works only on recipe outputs and increases requested amount of only that item by 1. Fluids are increased by whatever one cell contains, or, if there is no cell, by whatever container holds the max amount. I don't like how the method looks (StackInfo::getFluidCellSize), but could not find a better approach.
    • Ctrl+Shift+Scroll works on any ingredient of the recipe and increases amount of requested items by whatever one craft gives you. This is notably different from how it was before, which was "increase number of requested items by one craft worth for the very last recipe in the chain". I decided to not reimplement this because of potential ambiguity, and because you can simply scroll on the recipe that you actually want.
    • Alt adds a multiplier that is equal to number under NEI item list on the bottom right.
  2. Visual

    • The number of requested items is shown in the top right corner as +123/-123. This is not required to be a multiple of whatever the recipe output is. Previously it would just change number of items individually. This is also shown as X*64 + Y on the tooltip
    • Bottom right shows however many items will be consumed/produced by however many craft iterations were calculated.
    • With shift held, top rights shows number of craft operations in the top right for the whole chain as x123. Bottom right numbers show chain inputs and chain remainders/outputs. Background highlights behave the same way.
    • Shift highlights group that your cursor is next to. You don't need to put you mouse over an itemstack. Tooltips were annoying.
  3. Behavioral and implementation details.

    • Item without ingredients in the crafting chain will sum requested ingredients from other recipes.
    • Pressing Shift+A on an output stack in a NEI recipe pins all output stacks, not just the one you hovered over. I want opinions on that one. Changed it to be consistent with doing the same thing over plus sign. And in general, I don't like how you can only remove ingredients and outputs from pinned recipe, but adding them back is practically impossible. I have no idea how to fix it though.
    • Amount of requested items is completely separate from pinned stack size that is shown. This means that toggling crafting mode will result in zeroed out item stack sizes. This also means that pinning item counts along with ingredients (Ctrl+Shift+A vs Shift+A) has no actual difference for this functionality.
    • If there are multiple recipes that give the same output, first code collects any remainders from all nodes, then, if it needs any more, it chooses first recipe it encounters. Currently, this item in any other recipes is highlighted in red, although that might not be needed anymore.
    • Graph traversal continues for an ingredient only if that ingredient is pinned as both input, and output in other recipe.
    • Recipes are still serialized and stored as BookmarkRecipeId. I extract actual recipes at runtime.
    • Mapping from original ItemStack to calculated ItemStack is done via indexes. Previously it was done as a mapping from ItemStack to ItemStack.

Some screenshots (some are not from GTNH, so textures might be different):

Old screenshots

image
image
image
image

image
image
image
image
image
image

@Dream-Master Dream-Master requested review from slprime and a team September 15, 2024 10:37
@Meegooo Meegooo force-pushed the recipe_chain_refactor branch 2 times, most recently from bdf0c69 to 0146a73 Compare September 15, 2024 11:59
@Meegooo Meegooo marked this pull request as ready for review September 15, 2024 12:02
@slprime
Copy link
Member

slprime commented Sep 15, 2024

ctrl+shift+scroll don't scroll full recipe, only item under mouse. (work only ctrl+scroll)
image

why used second recipe? has ingredients pinned what you meen?
image

Recipe from first group scrolled too
Minecraft1 7 102024-09-1521-13-08-ezgif com-video-to-gif-converter

Alt adds a multiplier that is equal to number under NEI item list on the bottom right.

Don't work correctly. The value must be a multiple of 64 (in my example) but have 65

before after
image image

I'm not sure there is a need for a negative main recipe. I often use shift+ctrl+alt+scroll to reset the recipe.
image

Shift in fluid show how many it is by detail (29kL=29000=....) But if use negative value i don't know how many fluids I've specified. For items same problem

Positive Negative
image image

The ingredient "Magnesiumchloride Dust" is a catalyst in this recipe group, it should not be in the ingredients and remainders. The display of circuits is also questionable

Recipe Tooltip
image image

Same problem. Results have 72 chips but should have 64

Recipe Tooltip
image image

2 different recipes form "Cryogenic Freezer" and "Vacuum Freezer", but only one of them scrolls.
image

Recipe Group

  1. oil -> "Sulfuric Light Fuel"
  2. "Sulfuric Light Fuel" -> "Light Fuel"
  3. "Light Fuel" -> "Lightly Steam-Cracked Light Fuel"
  4. "Lightly Steam-Cracked Light Fuel" -> Ethylene

Chain brocken because fluid in cell (it will work fine before)

Recipe shift
image image

"Sulfuric Light Fuel" and "Light Fuel" highlight like it is in results/remainders, but it isn't

Recipe Tooltip
image image

Previously, the highlight was more informative. Using shift showed how many items were left

Before Now
image image

That's enough for now

@Meegooo
Copy link
Author

Meegooo commented Sep 16, 2024

ctrl+shift+scroll don't scroll full recipe, only item under mouse. (work only ctrl+scroll)

Here you have crafting chain mode disabled. Did it use to do that on shift+ctrl+scroll?

why used second recipe?
2 different recipes form "Cryogenic Freezer" and "Vacuum Freezer", but only one of them scrolls.

It uses whatever recipe it encounters first. I should probably make it more consistent, because currently to the user it feels random because of hashmap. And maybe color conflicting recipe in gray or something. But functionally, I don't see a way to support multiple recipes that give the same output. If there is a recipe that you need pinned, but that you don't wanna use for some item, you can unpin output from that recipe.

has ingredients pinned what you meen?

If you unpin an ingredient from the recipe, then graph traversal won't continue, even if that recipe is pinned. For example, iron is not pinned in hopper recipe, so iron is not calculated.
image
That filtering required extra (annoying) code. So i'm happy to remove that and always continue through for all ingredients.

Recipe from first group scrolled too

Oops, forgot to filter by group id.

Don't work correctly. The value must be a multiple of 64 (in my example) but have 65
I'm not sure there is a need for a negative main recipe. I often use shift+ctrl+alt+scroll to reset the recipe.

Cause currently it adds/removes 64 or whatever multiple you have set. But now that I think about it, forcing it to be a multiple would be nicer. Noted.
Adding shift would increase/decrease number of crafting operations, not reuqested items. So, for 6 slabs from 3 planks it would scroll to -320, 0, 320, 640, 960, etc.

Chain brocken because fluid in cell (it will work fine before)

You mean it should treat cells as raw fluids? Makes sense, noted.

The ingredient "Magnesiumchloride Dust" is a catalyst in this recipe group, it should not be in the ingredients and remainders. The display of circuits is also questionable
Same problem. Results have 72 chips but should have 64

That is by design. It is a catalyst that is unused, but it is required for the craft. They were cancelling each other in first implementation, but after some playtesting I found out that it was not very helpful. In general, this tries to mimic the way AE2 autocrafting works. And that's how it would see it.
As for circuits, not showing ingredients with stack size of 0 would solve it.

"Sulfuric Light Fuel" and "Light Fuel" highlight like it is in results/remainders, but it isn't

That's actually Lightly Steam-Cracked fuel in the remainders. Ethylene requires 19000L and cracking recipe will produce 19200. That is a problem I had with the tooltip, because you often can't tell what ingredient/results/remainders are shown, because a lot of them look very similar
Sulfuric acid is also in the remainders. You did not explicitly request it (you requested only Ethylene), but it was produced as a byproduct of converting sulfuric fuel to normal fuel. Now, if you Ctrl+scroll up on it twice, it will be considered something you requested and will move from remainders to results.

Using shift showed how many items were left

You mean showing outputs+remainders as a stack size for outputs? Okay, previously I couldn't exactly figure out what that was.

Shift in fluid show how many it is by detail (29kL=29000=....) But if use negative value i don't know how many fluids I've specified. For items same problem.

Do you know where that is calculated? There is no reason it shouldn't work, other than explicitly checking for stack size to be greater than 0.

@slprime
Copy link
Member

slprime commented Sep 16, 2024

Here you have crafting chain mode disabled. Did it use to do that on shift+ctrl+scroll?

Previously, the algorithm worked the same whether the chain was enabled or not

It uses whatever recipe it encounters first. I should probably make it more consistent, because currently to the user it feels random because of hashmap. And maybe color conflicting recipe in gray or something. But functionally, I don't see a way to support multiple recipes that give the same output. If there is a recipe that you need pinned, but that you don't wanna use for some item, you can unpin output from that recipe.

Here it would be correct to change the quantity on the recipe you are on.
How will it behave if it is an intermediate recipe? will i be able to specify how many recipes should go on one path and how many on the other or will i have to create several groups?

Adding shift would increase/decrease number of crafting operations, not reuqested items. So, for 6 slabs from 3 planks it would scroll to -320, 0, 320, 640, 960, etc.

How to reset group state? Why do you need a negative value in the final recipe?

You mean it should treat cells as raw fluids? Makes sense, noted.

yes, it will work fine before

That is by design. It is a catalyst that is unused, but it is required for the craft. They were cancelling each other in first implementation, but after some playtesting I found out that it was not very helpful. In general, this tries to mimic the way AE2 autocrafting works. And that's how it would see it.

This will mislead the player into crafting a catalyst in quantities he doesn't need. they are no different from a circuit in situations like this. The only thing you can do is to output it as an ingredient in the amount of one item. Otherwise the player will again have to filter out unnecessary things in tooltips/highlights

That's actually Lightly Steam-Cracked fuel in the remainders. Ethylene requires 19000L and cracking recipe will produce 19200. That is a problem I had with the tooltip, because you often can't tell what ingredient/results/remainders are shown, because a lot of them look very similar

correctly: Ethylene requires 18800L and cracking recipe will produce 19000.
Previously, by holding down the shift key, I could clearly understand what I would have left and at what stage, now I have to look for inputs and outputs for item/fluid and subtract one number from another.

Do you know where that is calculated? There is no reason it shouldn't work, other than explicitly checking for stack size to be greater than 0.

GuiContainerManager.itemCountDetails

@Meegooo
Copy link
Author

Meegooo commented Sep 16, 2024

Notes to self, to not forget anything

  • Make output conflict resolution predictable (always pick the topmost recipe)
  • Forbid changing request amount for conflicting recipe
  • Color conflicting recipe in red and show tooltip with hint (only when shift is held, to reduce noise)
  • Allow using conflicting recipes as passive ingredient providers.
  • Stop changing request count with Ctrl+Shift+Scroll for same recipe in another group
  • Make scrolling consistent between regular mode and crafting mode.
    • Ctrl+Scroll - change requests/stack size by 1 (or once cell worth for fluids) for only selected item (for crafting mode, only output items)
    • Ctrl+Shift+Scroll - change requests/stack size by meta.factor for all items in selected recipe (for crafting mode, only output items, inputs will be calculated)
    • Alt - adds an extra modifier.
    • Final count sticks to a multiple of final multiplier (meta.factor*alt_modifier or cell_size*alt_modifier or 1*alt_modifier, etc)
  • Make negative requests a config option (disable by default)
  • Add config option to remove unconsumed catalysts and common items from inputs and outputs+remainders (enabled by default). Decided against adding a config option for now.
    • reduce fluids in different containers as well. Not necessary anymore.
  • Add number of requested items to tooltip (to know exact amount when it gets compressed to K/M/G)
  • Show remainder amount on pinned itemstacks while holding shift
  • Pulling items for selected group doesn't work (works as intended and as it was before, did not realize there were differences in behavior between selecting a group and not selecting).
  • Support fluids in cells as raw fluid
  • If a recipe produces more than one stack of item (i.e. 64 + 6 of cryolite dust), 64 gets pinned as a regular bookmark, and recipe calculator thinks one craft produces 6. This is an issue in current version when adding recipe from the "plus" sign. I'll fix it here because now this code is used by all recipe pins. However there is another issue with duping recipes (i.e. null catalyst) in that this recipe can't be pinned, because input and output contain the same item. This I would rather fix separately, because this PR is large enough.

@slprime slprime marked this pull request as draft September 17, 2024 04:44
@Meegooo Meegooo force-pushed the recipe_chain_refactor branch 3 times, most recently from 4580ac0 to ab18c57 Compare October 6, 2024 13:35
@Meegooo
Copy link
Author

Meegooo commented Oct 6, 2024

This should be ready, but I haven't playtested much. For this reason, I'm gonna keep it in draft state for a bit.

There is one known old bug, which is unrelated to the changes. You can't pin duping recipes (Null catalyst for example). But I would rather fix it in a new PR.

@PlayfulPiano
Copy link

This should be ready, but I haven't playtested much. For this reason, I'm gonna keep it in draft state for a bit.

There is one known old bug, which is unrelated to the changes. You can't pin duping recipes (Null catalyst for example). But I would rather fix it in a new PR.

is this the same bug causing issues with like for example multiple recipes using the same item? like tin & copper dust both using 3 xp buckets and therefore overwrite each other in bookmarks

@Meegooo
Copy link
Author

Meegooo commented Oct 9, 2024

is this the same bug causing issues with like for example multiple recipes using the same item? like tin & copper dust both using 3 xp buckets and therefore overwrite each other in bookmarks

Which recipe is this exactly? There was a bug that caused multiple stacks of same item in output to override each other when pinning recipe instead of adding up like inputs (ctrl+shift+A on plus sign). That one is fixed. The one that prevents you from properly pinning a recipe that has same items in inputs and outputs is not fixed.

PS. Regarding this PR in general. My attempt to remove common items from inputs and outputs (not remainders, those are fine) caused another bug, that prevents you from requesting i.e. 64 MV circuits and 64 HV circuits in one chain (64 MV circuits you requested will be consumed by 32 HV circuits). I could remove common items as a postprocessing step, but I would rather not.

This would mean that whatever you requested will be shown in outputs exactly. This means that outputs and remainders will show how many items you will have in your inventory at the end, not how many you will gain.

@PlayfulPiano
Copy link

is this the same bug causing issues with like for example multiple recipes using the same item? like tin & copper dust both using 3 xp buckets and therefore overwrite each other in bookmarks

Which recipe is this exactly? There was a bug that caused multiple stacks of same item in output to override each other when pinning recipe instead of adding up like inputs (ctrl+shift+A on plus sign). That one is fixed. The one that prevents you from properly pinning a recipe that has same items in inputs and outputs is not fixed.

PS. Regarding this PR in general. My attempt to remove common items from inputs and outputs (not remainders, those are fine) caused another bug, that prevents you from requesting i.e. 64 MV circuits and 64 HV circuits in one chain (64 MV circuits you requested will be consumed by 32 HV circuits). I could remove common items as a postprocessing step, but I would rather not.

This would mean that whatever you requested will be shown in outputs exactly. This means that outputs and remainders will show how many items you will have in your inventory at the end, not how many you will gain.

for example tin and copper dust both require 3 xp buckets in a crafting table, but if you try to bookmark both they'll overwrite each other.

@Meegooo
Copy link
Author

Meegooo commented Oct 9, 2024

for example tin and copper dust both require 3 xp buckets in a crafting table, but if you try to bookmark both they'll overwrite each other.

Ah, recipes override each other, not items, I see. Currently recipe is identified by its inputs (shapeless) and crafting handler. That is not getting changed here.
To fix this, recipe id should also include outputs (or shape information, but that needs a whitelist of shaped crafting handlers). That change is not trivial and needs to be done very carefully to not nuke any pinned recipes. That is to say, I'm not touching that here, but noted.

@slprime
Copy link
Member

slprime commented Oct 10, 2024

Added items from this gui (it added like pseudo recipe)

image

Highlight broken when chain on

without chain with chain
image image

And it sometimes crashes when i hover to result with shift:

bookmarks state:
image

crash (reload don't help fix bug): https://mclo.gs/vQpnZBV

; {"groups":{"0":{"viewmode":"TODO_LIST","crafting":false},"1":{"viewmode":"TODO_LIST","crafting":true},"2":{"viewmode":"TODO_LIST","crafting":true}}}
{"item":{"strId":"MagicBees:frameMagic","Count":100,"Damage":"0S"},"factor":100,"ingredient":false,"requestedAmount":697,"groupId":1,"recipeId":{"handlerName":"craft-confirm","ingredients":[{"strId":"Thaumcraft:ItemResource","Count":100,"Damage":"7S"},{"strId":"Forestry:frameImpregnated","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"1S"},{"strId":"MagicBees:wax","Count":100,"Damage":"2S"},{"strId":"gregtech:gt.metaitem.01","Count":400,"Damage":"27305S"}]}}
{"item":{"strId":"Thaumcraft:ItemResource","Count":100,"Damage":"7S"},"factor":100,"ingredient":true,"requestedAmount":0,"groupId":1,"recipeId":{"handlerName":"craft-confirm","ingredients":[{"strId":"Thaumcraft:ItemResource","Count":100,"Damage":"7S"},{"strId":"Forestry:frameImpregnated","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"1S"},{"strId":"MagicBees:wax","Count":100,"Damage":"2S"},{"strId":"gregtech:gt.metaitem.01","Count":400,"Damage":"27305S"}]}}
{"item":{"strId":"Forestry:frameImpregnated","Count":100,"Damage":"0S"},"factor":100,"ingredient":true,"requestedAmount":0,"groupId":1,"recipeId":{"handlerName":"craft-confirm","ingredients":[{"strId":"Thaumcraft:ItemResource","Count":100,"Damage":"7S"},{"strId":"Forestry:frameImpregnated","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"1S"},{"strId":"MagicBees:wax","Count":100,"Damage":"2S"},{"strId":"gregtech:gt.metaitem.01","Count":400,"Damage":"27305S"}]}}
{"item":{"strId":"MagicBees:wax","Count":100,"Damage":"0S"},"factor":100,"ingredient":true,"requestedAmount":0,"groupId":1,"recipeId":{"handlerName":"craft-confirm","ingredients":[{"strId":"Thaumcraft:ItemResource","Count":100,"Damage":"7S"},{"strId":"Forestry:frameImpregnated","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"1S"},{"strId":"MagicBees:wax","Count":100,"Damage":"2S"},{"strId":"gregtech:gt.metaitem.01","Count":400,"Damage":"27305S"}]}}
{"item":{"strId":"MagicBees:wax","Count":100,"Damage":"1S"},"factor":100,"ingredient":true,"requestedAmount":0,"groupId":1,"recipeId":{"handlerName":"craft-confirm","ingredients":[{"strId":"Thaumcraft:ItemResource","Count":100,"Damage":"7S"},{"strId":"Forestry:frameImpregnated","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"1S"},{"strId":"MagicBees:wax","Count":100,"Damage":"2S"},{"strId":"gregtech:gt.metaitem.01","Count":400,"Damage":"27305S"}]}}
{"item":{"strId":"MagicBees:wax","Count":100,"Damage":"2S"},"factor":100,"ingredient":true,"requestedAmount":0,"groupId":1,"recipeId":{"handlerName":"craft-confirm","ingredients":[{"strId":"Thaumcraft:ItemResource","Count":100,"Damage":"7S"},{"strId":"Forestry:frameImpregnated","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"1S"},{"strId":"MagicBees:wax","Count":100,"Damage":"2S"},{"strId":"gregtech:gt.metaitem.01","Count":400,"Damage":"27305S"}]}}
{"item":{"strId":"gregtech:gt.metaitem.01","Count":400,"Damage":"27305S"},"factor":400,"ingredient":true,"requestedAmount":0,"groupId":1,"recipeId":{"handlerName":"craft-confirm","ingredients":[{"strId":"Thaumcraft:ItemResource","Count":100,"Damage":"7S"},{"strId":"Forestry:frameImpregnated","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"1S"},{"strId":"MagicBees:wax","Count":100,"Damage":"2S"},{"strId":"gregtech:gt.metaitem.01","Count":400,"Damage":"27305S"}]}}
{"item":{"strId":"MagicBees:frameMagic","Count":1000,"Damage":"0S"},"factor":100,"ingredient":false,"requestedAmount":1400,"groupId":2,"recipeId":{"handlerName":"craft-confirm","ingredients":[{"strId":"Thaumcraft:ItemResource","Count":100,"Damage":"7S"},{"strId":"Forestry:frameImpregnated","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"1S"},{"strId":"MagicBees:wax","Count":100,"Damage":"2S"},{"strId":"gregtech:gt.metaitem.01","Count":400,"Damage":"27305S"}]}}
{"item":{"strId":"Thaumcraft:ItemResource","Count":1000,"Damage":"7S"},"factor":100,"ingredient":true,"requestedAmount":0,"groupId":2,"recipeId":{"handlerName":"craft-confirm","ingredients":[{"strId":"Thaumcraft:ItemResource","Count":100,"Damage":"7S"},{"strId":"Forestry:frameImpregnated","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"1S"},{"strId":"MagicBees:wax","Count":100,"Damage":"2S"},{"strId":"gregtech:gt.metaitem.01","Count":400,"Damage":"27305S"}]}}
{"item":{"strId":"Forestry:frameImpregnated","Count":1000,"Damage":"0S"},"factor":100,"ingredient":true,"requestedAmount":0,"groupId":2,"recipeId":{"handlerName":"craft-confirm","ingredients":[{"strId":"Thaumcraft:ItemResource","Count":100,"Damage":"7S"},{"strId":"Forestry:frameImpregnated","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"1S"},{"strId":"MagicBees:wax","Count":100,"Damage":"2S"},{"strId":"gregtech:gt.metaitem.01","Count":400,"Damage":"27305S"}]}}
{"item":{"strId":"MagicBees:wax","Count":1000,"Damage":"0S"},"factor":100,"ingredient":true,"requestedAmount":0,"groupId":2,"recipeId":{"handlerName":"craft-confirm","ingredients":[{"strId":"Thaumcraft:ItemResource","Count":100,"Damage":"7S"},{"strId":"Forestry:frameImpregnated","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"1S"},{"strId":"MagicBees:wax","Count":100,"Damage":"2S"},{"strId":"gregtech:gt.metaitem.01","Count":400,"Damage":"27305S"}]}}
{"item":{"strId":"MagicBees:wax","Count":1000,"Damage":"1S"},"factor":100,"ingredient":true,"requestedAmount":0,"groupId":2,"recipeId":{"handlerName":"craft-confirm","ingredients":[{"strId":"Thaumcraft:ItemResource","Count":100,"Damage":"7S"},{"strId":"Forestry:frameImpregnated","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"1S"},{"strId":"MagicBees:wax","Count":100,"Damage":"2S"},{"strId":"gregtech:gt.metaitem.01","Count":400,"Damage":"27305S"}]}}
{"item":{"strId":"MagicBees:wax","Count":1000,"Damage":"2S"},"factor":100,"ingredient":true,"requestedAmount":0,"groupId":2,"recipeId":{"handlerName":"craft-confirm","ingredients":[{"strId":"Thaumcraft:ItemResource","Count":100,"Damage":"7S"},{"strId":"Forestry:frameImpregnated","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"1S"},{"strId":"MagicBees:wax","Count":100,"Damage":"2S"},{"strId":"gregtech:gt.metaitem.01","Count":400,"Damage":"27305S"}]}}
{"item":{"strId":"gregtech:gt.metaitem.01","Count":4000,"Damage":"27305S"},"factor":400,"ingredient":true,"requestedAmount":0,"groupId":2,"recipeId":{"handlerName":"craft-confirm","ingredients":[{"strId":"Thaumcraft:ItemResource","Count":100,"Damage":"7S"},{"strId":"Forestry:frameImpregnated","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"0S"},{"strId":"MagicBees:wax","Count":100,"Damage":"1S"},{"strId":"MagicBees:wax","Count":100,"Damage":"2S"},{"strId":"gregtech:gt.metaitem.01","Count":400,"Damage":"27305S"}]}}

It is also inconvenient that the count is reset when the chain is turned on

image

It is also inconvenient that all chain react to shift regardless of the cursor position

Incorrect show chain remainders

recipe tooltip
image image

If i added another recipe to chain, it incorrect calculate fluid. it use ingredient as result

without with
image image

Feedback from other user

before after
image image

ctrl+shift+a should be added only result under mouse, not all results. for all results exists +

@Meegooo
Copy link
Author

Meegooo commented Oct 16, 2024

Highlight broken when chain on

Incorrect show chain remainders

If i added another recipe to chain, it incorrect calculate fluid. it use ingredient as result

Feedback from other user

All of those were caused by the bug I described above in #530 (comment). Those should be fixed, but now outputs can never be used as ingredients, and fixing that is not worth it in my opinion, especially for something that is this minor and arguably is not even a bug.

ctrl+shift+a should be added only result under mouse, not all results. for all results exists +

Fixed

Added items from this gui (it added like pseudo recipe)

...

And it sometimes crashes when i hover to result with shift:

Couldn't reproduce adding the recipe, but I think it crashed because it couldn't find craft-confirm handler. I added a fallback that will use pinned ingredients instead of the real recipe

It is also inconvenient that all chain react to shift regardless of the cursor position

I don't really understand this issue. It used to highlight the entire chain before this? The only difference is that now you don't need to hover over item, you can hover next to the group. And I don't see that as an issue.

It is also inconvenient that the count is reset when the chain is turned on

Reasoning on how to do it Now, this is not trivial. Converting from crafting mode to regular mode is easy, but going backwards would require calculating however many items you need to request to best match counts of regular mode. And whatever I do, conversion from regular mode to crafting mode can't be lossless. I could request only roots of the chain, but that might be inconsistent if you change intermediaries (i.e. if you request both HV and EV circuits in one chain). That could be solved by topologically sorting the nodes, but...

...recursuive recipes. Topological sort does not work if graph has cycles, and a lot of recipes are recursive. If I were to just recalculate root recipes, that will also break for crystal chip recipe. There is actually no way to tell if you want chip parts or full chips.

There is another way. I could keep conversion from crafting mode to regular mode, but completely abandon the reverse conversion, and instead modify requested items amount in normal mode too. As for adding new recipes to the group, my suggestion is to request factor amount for the first recipe in the chain, and don't request anything for other recipes.

Made an attempt at this. Here is how it works.

  1. Adding stack to new group requests stack size for all outputs. Effectively works only for first pin in the entire bookmark page, so... might be useless
  2. Creating new group by drag-n-drop requests the topmost craft. If new group is created over old one that has some items requested, nothing will happen. Not sure about this, but the reasoning is that I think usually the final craft in the chain would be the topmost one.
  3. Switching from crafting mode to regular mode sets stack sizes to whatever was calculated.
  4. Scrolling on item in regular mode that was previously requested in crafting mode sets new requested amount equal to stack size. Scrolling on item that was not requested before does not edit requested amount.

PS. I haven't had much free time for several weeks, so this is not playtested.

PS2. Requesting cells from fluid canner recipes causes weird behavior, because that recipe is self-recursive. But that seems like a completely pointless action, so I don't think fixing it is worth it.

@Meegooo Meegooo force-pushed the recipe_chain_refactor branch 2 times, most recently from 6d29dae to eda5735 Compare October 18, 2024 18:37
@Meegooo Meegooo force-pushed the recipe_chain_refactor branch from eda5735 to 97defd7 Compare October 18, 2024 19:13
@Meegooo Meegooo marked this pull request as ready for review October 26, 2024 09:58
@boubou19 boubou19 added the ongoing freeze - do not merge Not just a bug fix and thus affected by a current freeze for a upcoming version label Nov 17, 2024
@Dream-Master Dream-Master removed the ongoing freeze - do not merge Not just a bug fix and thus affected by a current freeze for a upcoming version label Dec 8, 2024
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.

Item counts in NEI pinned recipe chains are buggy
5 participants