IllegalStateException: Asynchronous Chunk getEntities when attempting to get an entity by ID.
dniym opened this issue ยท 3 comments
Make sure you're doing the following
- [ x] You're using the latest build for your server version
- [x ] This isn't an issue caused by another plugin
- [x ] You've checked for duplicate issues
- [ x] You didn't use
/reload
Describe the question
I am attempting to retrieve an entity object from an entity id pulled from a packet.
API method(s) used
Using a PacketAdapter(plugin, PacketType.Play.Client.USE_ENTITY) to detect when an entity is interacted with.
Then trying to use the BukkitConverters.getEntityConverter(event.getPlayer().getWorld()).getSpecific(entityId);
to get the Entity object from the given ID.
Expected behavior
Getting the Entity object from the Entity ID
Code
If applicable, add relevant code from your project
Additional context
Protocollib gives an error trying to get the entity from the world.
Caused by: java.lang.IllegalStateException: Asynchronous Chunk getEntities call! at org.spigotmc.AsyncCatcher.catchOp(AsyncCatcher.java:14) ~[spigot.jar:3168-Spigot-a483d2c-bc00005] at net.minecraft.server.level.WorldServer.getEntities(WorldServer.java:1795) ~[spigot.jar:3168-Spigot-a483d2c-bc00005] at net.minecraft.server.level.WorldServer.b(WorldServer.java:1312) ~[spigot.jar:3168-Spigot-a483d2c-bc00005] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?] at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?] at com.comphenix.protocol.reflect.accessors.DefaultMethodAccessor.invoke(DefaultMethodAccessor.java:16) ~[ProtocolLib(2).jar:4.7.0-SNAPSHOT-b526] at com.comphenix.protocol.injector.EntityUtilities.getEntityFromID(EntityUtilities.java:234) ~[ProtocolLib(2).jar:4.7.0-SNAPSHOT-b526] at com.comphenix.protocol.injector.PacketFilterManager.getEntityFromID(PacketFilterManager.java:851) ~[ProtocolLib(2).jar:4.7.0-SNAPSHOT-b526] at com.comphenix.protocol.wrappers.BukkitConverters$10.getSpecific(BukkitConverters.java:691) ~[ProtocolLib(2).jar:4.7.0-SNAPSHOT-b526]
Your listener is being run async. Try scheduling a sync task and executing your code.
Your listener is being run async. Try scheduling a sync task and executing your code.
Does protocollib do this when a listener is registered? Because I didn't run it async purposely...
ProtocolLibrary.getProtocolManager().addPacketListener( new PacketAdapter(plugin, PacketType.Play.Client.USE_ENTITY) {
is the way i've always registered packet listeners and I see nothing to indicate that this would be done async.