Register Scarpet trait command only if Carpet is loaded and init profession later #129
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
About the command, it makes it register only if Carpet is loaded, given else it's just wasted memory and a check per player when syncing command. It's not the main purpose of the PR.
About initializing the profession later, there's currently an issue-ish where Carpet is sensitive to the load order with the
CarpetEventServer.Event
class. If it's initialized too early, when entities from mods that haven't had their initializers run yet will generate a log entry each time they spawn (and will have less functionality in scarpet). Taterzens was causing this with the chainTaterzensFabric.onInitialize
>ScarpetProfession::new
>ScarpetProfession static
>TaterzenScarpetEvent extends
>CarpetEventServer.Event
(found in gnembon/fabric-carpet#1647).The fix was moving it to the class initialization of the command, given it runs later, late enough that most mods should've registered their entities. It's not the best of fixes, but it does the job.
I want this to be fixed in Carpet but I haven't done it yet and it likely won't be on 1.19.3, so I'm PRing this fix/workaround so it's not an issue with taterzens on 1.19.3.
This issue is also present in 1.19.2, though idk if you do backports.