Lithium (Fabric)

Lithium (Fabric)

22M Downloads

Move NearbyEntityListener::forEachChunkInRangeChange call to after Fabric Api's ServerEntityEvents#ENTITY_LOAD runs

Fuzss opened this issue ยท 1 comments

commented

Hey there, so I have a couple mods that add additional goals to some vanilla entities which are of type AvoidEntityGoal, e.g. make villagers avoid/flee from skeletons. I do this using Fabric Api's ServerEntityEvents#ENTITY_LOAD callback, since this seems to be the best place for such a thing without having to resort to custom mixins.

When doing this with Lithium installed, the game crashes when my new goals are trying to be added in ServerEntityEvents#ENTITY_LOAD with the following exception:
java.lang.IllegalStateException: Cannot add sublisteners after listening range was set! (full crash-report)

This happens since NearbyEntityListenerMulti#range is set in NearbyEntityListenerMulti::getChunkRange which runs before the Fabric Api callback.

Would it be possible to set the range field after Fabric Api's callback has run, either by moving the injection in ServerEntityManagerMixin or by migrating to the Fabric Api callback at a phase that runs after fabric:default?

commented

Your request is not possible, but instead I replaced the IllegalStateException with code that handles the situation correctly. This should fix the issue without futher action from your side.