-
Notifications
You must be signed in to change notification settings - Fork 189
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
Improve TagPrefix-based Recipe Generation #2616
base: 1.20.1
Are you sure you want to change the base?
Conversation
* | ||
* @param materials the materials to add as byproducts | ||
*/ | ||
public void addOreByProducts(@NotNull Material @NotNull... materials) { |
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.
I love @NotNull Material @NotNull...
/** | ||
* Copies the ItemStack with new stack size. | ||
* | ||
* @param stack item stack for copying | ||
* @return a copy of ItemStack, or {@link ItemStack#EMPTY} if the stack is empty | ||
*/ | ||
public static @NotNull ItemStack copy(int newCount, @NotNull ItemStack stack) { | ||
if (stack.isEmpty()) { | ||
return ItemStack.EMPTY; | ||
} | ||
ItemStack copy = stack.copy(); | ||
copy.setCount(newCount); | ||
return copy; | ||
} |
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 can be removed in favor of ItemStack#copyWithCount
ItemStack copy = stack.copy(); | ||
copy.setCount(newCount); | ||
return copy; |
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.
change this to use ItemStack#copyWithCount
private static final Reference2IntMap<TagPrefix> INSULATION_AMOUNT = new Reference2IntOpenHashMap<>(); | ||
static { | ||
INSULATION_AMOUNT.put(cableGtSingle, 1); | ||
INSULATION_AMOUNT.put(cableGtDouble, 1); | ||
INSULATION_AMOUNT.put(cableGtQuadruple, 2); | ||
INSULATION_AMOUNT.put(cableGtOctal, 3); | ||
INSULATION_AMOUNT.put(cableGtHex, 5); | ||
} |
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.
could use the Util.make(T,Consumer<T>)
method from vanilla here
What
Improves TagPrefix-based Recipe Generation. Notably, this PR no longer iterates all materials for every registration handler. Instead, materials are only iterated once.
Also, fixes a bug where ores of gem materials would not forge hammer to the gem if the material had an ignored gem.
Implementation Details
GTUtil.copyAmount
andGTUtil.selectItemInList
to begin with.TagPrefix.MaterialRecipeHandler
andTagPrefix#executeHandler
. This will require addons to update, and this PR serves as an example of how to do so.Outcome
Improves performance and cleans up recipe generation code.