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

avoid encoding hidden items in patterns #6463

Merged
merged 2 commits into from Jul 30, 2022
Merged

avoid encoding hidden items in patterns #6463

merged 2 commits into from Jul 30, 2022

Conversation

rlnt
Copy link
Contributor

@rlnt rlnt commented Jul 28, 2022

This PR implements an improvement for modpacks that care about unification and hide ingredients.

As an example, we can take the Crafting Table. It accepts any planks from the planks tag as ingredients. When encoding the recipe for it, it will use Oak Planks as input because that's the first entry in the planks tag. If you now hide Oak Planks in JEI/REI, it will no longer show up as an ingredient in the recipe.
When encoding patterns after hiding the Oak Planks using the + button, it will still use Oak Planks as inputs which makes no sense. Instead, it will now iterate through the tag until it finds the first visible stack and uses that instead. If there is no visible stack and all are hidden, it will use the previous behavior of using the first tag entry.

Why would this be useful you may ask.
Think about several mods being installed besides AE2 and instead of the Crafting Table, think about a storage block like silver. 3 mods may add their own silver ingots but you only want one primary ingot to be available so you hide the others. To prevent encoding the hidden ingot as input and having to manually overwrite it, it will now use the visible item.

The change was implemented and tested in JEI and REI. While JEI exposes a method to check for visibility, REI is a bit trickier.
I used the same approach they use in their JEI compat layer and it works fine. For performance reasons, I decided to cache the visibility results. The visibility lookup is not that slow but it's better to cache it imo.
Caching it has only one downside. REI's hiding system works on the fly if you hide items within the in-game config menu and the item is instantly gone while it's still marked as visible in the cache. You will have to restart the world if you want to have the encoding work again but since this is only really interesting for a small number of packmakers, this should be fine.

Edit: the author of REI will expose a method for checking the item visibility in one of the next versions because the current way is not very handy

@shartte shartte merged commit 9e0794f into AppliedEnergistics:master Jul 30, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants