Modonomicon

Modonomicon

1M Downloads

BookUnlockStateManager's updateAndSyncFor method has issues when using and condition with entry_unlocked condition

Cmdpro opened this issue ยท 5 comments

commented

Describe the bug
When using BookUnlockStateManager's updateAndSyncFor method, it goes in the order its registered, lets say that A, and B are entries, A is registered before B, and B is registered last, if A has an and condition with an entry_unlocked condition for B and updateAndSyncFor is ran then A wont be unlocked but B will, this is assuming B is now unlocked but was not updated as unlocked before running it

To Reproduce
Steps to reproduce the behavior:

  1. Add 2 entries
  2. Make one of the entries have an and condition with an entry_unlocked condition for one registered after it, the one registered after it has to not be updated as unlocked yet
  3. Run BookUnlockStateManager's updateAndSyncFor method

Expected behavior
A and B are both unlocked

System (please complete the following information):

  • Modonomicon Version: 1.58.0
  • OS: Windows
  • Minecraft Version: 1.20.1
  • Modpack Link and Version, or list of mods: Geckolib, JEI, Modonomicon, Curios, Lodestone and Runology (my mod)

Additional context
This seems like it will also happen with the or condition, also sorry if what i have said is confusing, i struggled figuring out how to describe this bug, i can clarify a certain part if it is confusing

commented

ah i think i see the issue, it seems to also require the parent to be entry B, reason im trying to do this is because it seems that when all conditions are true, it doesnt seem to wait for the parent entries to be unlocked

commented

Btw i do not know how to make a pull request but i believe i know how to fix it, in BookUnlockStates, the update method there is a check for if the condition is BookEntryUnlockedCondition, i believe to fix this, you need to make it also check for the and condition and or condition

commented

I agree with your proposed solution, I ended up generifying it to allow future (and modder custom) conditions to be handled automatically

commented

I updated the test example to have b be the parent of a and root the parent of b but it still works.
I will attempt your suggested fix and publish an update so you can test it :)

commented

@Cmdpro I tried to repro it but failed. Can you take a look and let me know what's wrong (or provide an example - or just modify the file and provide a PR into the fix/unlock-stuff branch?)

https://github.com/klikli-dev/modonomicon/blob/fix/unlock-stuff/common/src/main/java/com/klikli_dev/modonomicon/datagen/book/OtherCategoryProvider.java