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

[1.21] Recipe priority system for solving overlaps in recipe ingredients and patterns #1152

Open
wants to merge 9 commits into
base: 1.21.x
Choose a base branch
from

Conversation

bconlon1
Copy link
Contributor

Updated version of #1141

This PR implements a system intended to give modders a solution to the problem of needing to implement a recipe with a pattern of ingredients, but it overlaps with a vanilla recipe that has the same pattern but using a tag instead. For example, a modder may be trying to make a Chest for a specific wood type in a custom dimension, but in Vanilla, crafting Chests uses the #planks tag, so all wood types are normally going to give the default Chest block.

Specifically, this PR does the following main things:

  • Adds a new class RecipePrioritiesProvider, which is a data provider that can be extended to generate a map of recipe ResourceLocations to Integer priorities. Vanilla recipes are considered at a baseline of 0, so positive numbered recipes are higher priority and negative numbered recipes are lower priority.
  • Adds RecipePriorityManager, which reads the JSON data.
  • Patches RecipeManager to use ordered data types that are ordered by taking into account any priority values that are found to match a recipe ID.
  • Changes how AddReloadListenerEvent is constructed slightly, by passing in the list of original listeners to it. This is necessary to allow for inserting RecipePriorityManager to run and generate priorities before RecipeManager so that they can be used in it.

2024-06-18_20 56 21
2024-06-18_20 56 32

@neoforged-pr-publishing
Copy link

  • Publish PR to GitHub Packages

@bconlon1 bconlon1 changed the title [1.21] Recipe Priority system for solving overlaps in recipe ingredients and patterns [1.21] Recipe priority system for solving overlaps in recipe ingredients and patterns Jun 20, 2024
Copy link
Contributor

@marchermans marchermans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs some work to get the details right. But the idea is sound.

@Matyrobbrt Matyrobbrt added enhancement New (or improvement to existing) feature or request 1.21 Targeted at Minecraft 1.21 data driven This request involves a data driven system labels Jun 25, 2024
* @param listener the listener to add to the ResourceManager on reload
* @param before a predicate for what listener to add this before
*/
public void addListenerBefore(PreparableReloadListener listener, Predicate<PreparableReloadListener> before) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should ideally be split into its own PR and account the feedback provided in #598
@pupnewfster has stated that they don't have updating the PR in their priority list, so if you do end up porting it, you should use a toposort and named listeners.

@bconlon1 bconlon1 marked this pull request as draft August 30, 2024 15:25
@bconlon1 bconlon1 marked this pull request as ready for review September 14, 2024 20:03
Copy link
Member

@sciwhiz12 sciwhiz12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't looked too closely at the PR yet, just commenting on the compatibility check failures.

@neoforged-automation
Copy link

@bconlon1, this pull request has conflicts, please resolve them for this PR to move forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.21 Targeted at Minecraft 1.21 data driven This request involves a data driven system enhancement New (or improvement to existing) feature or request needs rebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants