-
-
Notifications
You must be signed in to change notification settings - Fork 179
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
base: 1.21.x
Are you sure you want to change the base?
[1.21] Recipe priority system for solving overlaps in recipe ingredients and patterns #1152
Conversation
|
There was a problem hiding this 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.
patches/net/minecraft/world/item/crafting/RecipeManager.java.patch
Outdated
Show resolved
Hide resolved
patches/net/minecraft/world/item/crafting/RecipeManager.java.patch
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/common/crafting/RecipePriorityManager.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/event/AddReloadListenerEvent.java
Outdated
Show resolved
Hide resolved
* @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) { |
There was a problem hiding this comment.
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.
src/main/java/net/neoforged/neoforge/common/crafting/RecipePriorityManager.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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.
src/main/java/net/neoforged/neoforge/event/AddReloadListenerEvent.java
Outdated
Show resolved
Hide resolved
@bconlon1, this pull request has conflicts, please resolve them for this PR to move forward. |
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:
RecipePrioritiesProvider
, which is a data provider that can be extended to generate a map of recipeResourceLocation
s toInteger
priorities. Vanilla recipes are considered at a baseline of 0, so positive numbered recipes are higher priority and negative numbered recipes are lower priority.RecipePriorityManager
, which reads the JSON data.RecipeManager
to use ordered data types that are ordered by taking into account any priority values that are found to match a recipe ID.AddReloadListenerEvent
is constructed slightly, by passing in the list of original listeners to it. This is necessary to allow for insertingRecipePriorityManager
to run and generate priorities beforeRecipeManager
so that they can be used in it.