[1.12.2] script priority
tgstyle opened this issue ยท 8 comments
Issue Description:
I have scripts using priority, a removal script should be running before a replacement script. This is not the case, the recipes are not removed and are processed in the replace script. It works fine in versions prior to 618.
What happens:
Script priority is not working,
What you expected to happen:
Scripts need to run in the right priority.
Script used:
removal script: https://gist.github.com/tgstyle/ad9e968b7dc4e5d25c6643faf0be18cf
replacement script: https://gist.github.com/tgstyle/dadd0527e6e3595004a8d56fe6ea35d6
crafttweaker.log file:
https://gist.github.com/tgstyle/f7135fb3fb8a76853288de9be10031ca
Environment:
- Minecraft Version: 1.12.2
- Forge Version: 2854
- CraftTweaker Version: 4.1.20.618
- Are you using a server: yes
- If yes, does the client have the exact same scripts? yes
Game log:
https://gist.github.com/tgstyle/c943e1cdfcce0e0efad39fb44dc0e2f9
Modpack that is using these scripts
https://www.curseforge.com/minecraft/modpacks/mct-tich-immersion
@friendlyhj I believe this was your PR to change replaceAllOccurances, you got any idea?
Working as intended.
Remove functions in ZenScript only mark there are several recipes to remove. The removal and adding operations don't start until the post-initialization phase. So no matter your script priority, removal things always are processed before adding things. Replace means remove and re-add. ReplaceAllOccurance is only like a pump. It scans all recipes, and marks recipes which have "toReplace" ingredient to remove, and adds new recipes after removal operation is done.
ReplaceAllOccurances first starts, then removal, the last is addition.
But I skipped the recipe that the output will be removed when applying replaceAllOccurances. I wonder why you used so much recipes.removeByRecipeName
, change them to recipes.remove
. The issue probably can be solved.
I use recipes.removeByRecipeName because it is much easier to use for specific recipes.
The recommended methods is remove by name as it is a simple list.get(id), compared to looping over all the recipes to see what matches, much faster.
Anyway, if you want it, I will study how to make replacement start between removal and addition.