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

Improve TagPrefix-based Recipe Generation #2616

Open
wants to merge 3 commits into
base: 1.20.1
Choose a base branch
from

Conversation

TechLord22
Copy link
Member

@TechLord22 TechLord22 commented Dec 21, 2024

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

Outcome

Improves performance and cleans up recipe generation code.

@TechLord22 TechLord22 requested a review from a team as a code owner December 21, 2024 21:47
@TechLord22 TechLord22 added Do Not Merge DO NOT MERGE THIS PR YET! type: refactor Suggestion to refactor a section of code labels Dec 21, 2024
@YoungOnionMC YoungOnionMC removed the Do Not Merge DO NOT MERGE THIS PR YET! label Jan 1, 2025
*
* @param materials the materials to add as byproducts
*/
public void addOreByProducts(@NotNull Material @NotNull... materials) {
Copy link
Member

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...

Comment on lines +237 to 250
/**
* 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;
}
Copy link
Member

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

Comment on lines +284 to +286
ItemStack copy = stack.copy();
copy.setCount(newCount);
return copy;
Copy link
Member

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

Comment on lines +50 to +57
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);
}
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: refactor Suggestion to refactor a section of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants