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
Refactor replaceAllOccurences & add progress bar when applying actions #1144
Conversation
@jaredlll08 what's your thought? |
I like the progress bar stuff, I think that is really cool. I'm not sure about the replacealloccurances though, the whole method has just been trouble and I'm scared that if we change it now, it may cause even more trouble. How certain are you that it works and all is fine with it? |
It works well. Almost all recipes are corrently modified.
Now A or B will be replaced to C or B. It works perfectly now. |
@jaredlll08 ready for review |
CraftTweaker2-MC1120-Main/src/main/java/crafttweaker/mc1120/CraftTweaker.java
Outdated
Show resolved
Hide resolved
CraftTweaker2-MC1120-Main/src/main/java/crafttweaker/mc1120/recipes/MCRecipeManager.java
Outdated
Show resolved
Hide resolved
Going forward with PRs, maybe mark them as a draft, and when you're ready for review just mark it as ready, just makes it easier to manage things. I also want @kindlich's thoughts on it, but besides that it mostly looks good |
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.
Looks good
@jaredlll08 @kindlich when the PR is merged? I'm developing a modpack that needs the function. |
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.
Looks good to me.
I added a few Codestyle suggestions to make SubActionReplaceAllOccurrences#apply easier to read ^^
Also, as a side note:
This implementation creates a different recipe name if a recipe is affected by multiple replaceAllOccurences calls. Prior implementation would append remodified
, reremodified
etc., This implementation will only append modifed
.
That is fine by me, I just wanted to point it out.
Also, the previous implementation used IIngredient#contains(IIngredient)
to match, whereas you do it manually and allow partial replacements. This can lead to different results if I'm not mistaken.
That is fine by me, I just wanted to point it out.
CraftTweaker2-MC1120-Main/src/main/java/crafttweaker/mc1120/recipes/MCRecipeManager.java
Outdated
Show resolved
Hide resolved
CraftTweaker2-MC1120-Main/src/main/java/crafttweaker/mc1120/recipes/MCRecipeManager.java
Outdated
Show resolved
Hide resolved
CraftTweaker2-MC1120-Main/src/main/java/crafttweaker/mc1120/recipes/MCRecipeManager.java
Outdated
Show resolved
Hide resolved
SubActions only modify the recipe pattern, the ingredient array. After all sub actions are applied, if the ingredient array is modified ( |
I think this PR can slightly increase efficiency of this method.
In my test in an instance with GTCE, it reduces the time taken from 28 seconds to 11 seconds