-
-
Notifications
You must be signed in to change notification settings - Fork 355
Support Folia #3277
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
base: master
Are you sure you want to change the base?
Support Folia #3277
Conversation
…sommes sur le bon thread
…4Folia into support-folia
|
I think the changes to make it compatible with Folia are complete. I’m no longer seeing any errors on my end, even after multiple restarts and reloads. |
fullwall
left a comment
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.
I assume that async safety is not checked at all right?
| registry.saveToStore(); | ||
| } | ||
| } | ||
| if (net.citizensnpcs.api.util.SpigotUtil.isFoliaServer()) { |
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.
Why is this necessary?
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.
Because you can't "despawn" the NPCs while the server is down. But fortunately, they despawn during the shutdown.
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.
Because you can't "despawn" the NPCs while the server is down. But fortunately, they despawn during the shutdown.
More specifically, Folia's regional threads are all shutting down during the server shutdown, so it is impossible to interact with them.
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.
This method is also called by reload (I know...) so maybe needs some change there
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.
Actually, I return it if the plugin is disabled, which is false while the server is running, and true when the server stops.
| } | ||
|
|
||
| public static <T> T callPossiblySync(Callable<T> callable, boolean sync) { | ||
| if (SpigotUtil.isFoliaServer()) { |
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.
Perhaps this method should be deleted then
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.
delete callPossiblySync ?
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.
Yes
v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/util/CitizensEntityTracker.java
Outdated
Show resolved
Hide resolved
|
|
||
| @Override | ||
| public void setLocationDirectly(org.bukkit.entity.Entity entity, Location location) { | ||
| // Todo temp teleport |
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.
Is there any equivalent method in folia?
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.
I tried unsuccessfully to find a solution because the entity can leave the regional thread if it has to travel a long distance. Since this method is used during the entity's summoning, I found it more practical to teleport it for the time being.
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.
As I said earlier, I can't restore it exactly to the way it was before, but I did this to maintain the same behavior if we're on the same ticked region:
469dcb9
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.
hmm, isOnOwnerThread is slow isn't it?
I did everything I could to avoid any strange surprises due to async, but it's possible I overlooked something. However, at first glance, it seems to be working on my game server. I will, however, make the changes you requested above. |
Petite explication: Sur Folia, un déplacement d'entité effectué via snapTo déclenche une mise à jour des sections qui necessite d'être exécutée sur le thread propriétaire de la région initiale. Cependant, il est possible que ce dernier ne soit pas dans la même region initiale, de ce fait Folia rejette la demande en générant l'erreur: Cannot move entity off-main qu'on se mette sur le thread de l'entité, ou le thread de la future localisation. De ce fait, je fais une vérification au préalable si c'est le même monde et que la region tické pour l'entité et la future localisation est le même, et si c'est le cas, snapTo fonctionne, sinon il faut lancer une teleportation async. De ce fait, quand tout est réuni, je garde le fonctionnement initial, sinon on est obligé de teleporter l'entité
|
With regards to async safety, I mean for Citizens code not Folia code (e.g. traits) |
Close #3013
Following the Citizens API update, I'm starting to propose this PR for Folia support.
Several features may not work; please report them to me if you notice any.
Environmental Test:
[02:25:58 INFO]: Checking version, please wait...
[02:25:58 INFO]: This server is running Folia version 1.21.8-6-ver/1.21.8@612d9bd (2025-09-30T14:11:15Z) (Implementing API version 1.21.8-R0.1-SNAPSHOT)
You are running the latest version
Previous version: 1.21.8-DEV-05d3e7a (MC: 1.21.8)
Admin commands:
Test NPC Player
Test NPC mobs
Currently broken: