"Asynchronous Chunk getEntities call" error 1.17 USE_ENTITY
LoneDev6 opened this issue ยท 8 comments
Describe the bug
Seems this error appears only on 1.17
To Reproduce
Steps to reproduce the behavior:
- Listen to USE_ENTITY packet
- Use the getEntityModifier code:
Entity entity = packet.getEntityModifier(e.getPlayer().getWorld()).read(0);
Expected behavior
No error
Version
This server is running CraftBukkit version 3159-Spigot-f773da8-887bc05 (MC: 1.17) (Implementing API version 1.17-R0.1-SNAPSHOT)
ProtocolLib version 4.7.0-SNAPSHOT-b520
Error
java.lang.RuntimeException: Cannot retrieve entity from ID.
at com.comphenix.protocol.wrappers.BukkitConverters$10.getSpecific(BukkitConverters.java:698) ~[ProtocolLib.jar:4.7.0-SNAPSHOT-b520]
at com.comphenix.protocol.wrappers.BukkitConverters$10.getSpecific(BukkitConverters.java:677) ~[ProtocolLib.jar:4.7.0-SNAPSHOT-b520]
at com.comphenix.protocol.reflect.StructureModifier.readInternal(StructureModifier.java:229) ~[ProtocolLib.jar:4.7.0-SNAPSHOT-b520]
at com.comphenix.protocol.reflect.StructureModifier.read(StructureModifier.java:197) ~[ProtocolLib.jar:4.7.0-SNAPSHOT-b520]
at dev.lone.itemsadder.Core.ItemsDynamicity.Behaviours.BukkitEventsHandlers.PlaceableEntityEventsHandler$1.onPacketReceiving(PlaceableEntityEventsHandler.java:80) ~[ItemsAdder.jar:?]
at com.comphenix.protocol.injector.SortedPacketListenerList.invokeReceivingListener(SortedPacketListenerList.java:114) [ProtocolLib.jar:4.7.0-SNAPSHOT-b520]
at com.comphenix.protocol.injector.SortedPacketListenerList.invokePacketRecieving(SortedPacketListenerList.java:67) [ProtocolLib.jar:4.7.0-SNAPSHOT-b520]
at com.comphenix.protocol.injector.PacketFilterManager.handlePacket(PacketFilterManager.java:537) [ProtocolLib.jar:4.7.0-SNAPSHOT-b520]
at com.comphenix.protocol.injector.PacketFilterManager.invokePacketRecieving(PacketFilterManager.java:509) [ProtocolLib.jar:4.7.0-SNAPSHOT-b520]
at com.comphenix.protocol.injector.netty.ProtocolInjector.packetReceived(ProtocolInjector.java:360) [ProtocolLib.jar:4.7.0-SNAPSHOT-b520]
at com.comphenix.protocol.injector.netty.ProtocolInjector.onPacketReceiving(ProtocolInjector.java:325) [ProtocolLib.jar:4.7.0-SNAPSHOT-b520]
at com.comphenix.protocol.injector.netty.ChannelInjector.decode(ChannelInjector.java:593) [ProtocolLib.jar:4.7.0-SNAPSHOT-b520]
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:489) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:428) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:284) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [spigot.jar:3159-Spigot-f773da8-887bc05]
at com.comphenix.protocol.injector.netty.ChannelInjector$2.channelRead(ChannelInjector.java:289) [ProtocolLib.jar:4.7.0-SNAPSHOT-b520]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:284) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:647) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:547) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:501) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:461) [spigot.jar:3159-Spigot-f773da8-887bc05]
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884) [spigot.jar:3159-Spigot-f773da8-887bc05]
at java.lang.Thread.run(Thread.java:831) [?:?]
Caused by: com.comphenix.protocol.reflect.FieldAccessException: Cannot find entity from ID 584.
at com.comphenix.protocol.injector.EntityUtilities.getEntityFromID(EntityUtilities.java:265) ~[ProtocolLib.jar:4.7.0-SNAPSHOT-b520]
at com.comphenix.protocol.injector.PacketFilterManager.getEntityFromID(PacketFilterManager.java:851) ~[ProtocolLib.jar:4.7.0-SNAPSHOT-b520]
at com.comphenix.protocol.wrappers.BukkitConverters$10.getSpecific(BukkitConverters.java:692) ~[ProtocolLib.jar:4.7.0-SNAPSHOT-b520]
... 46 more
Caused by: java.lang.RuntimeException: An internal error occured.
at com.comphenix.protocol.reflect.accessors.DefaultMethodAccessor.invoke(DefaultMethodAccessor.java:20) ~[ProtocolLib.jar:4.7.0-SNAPSHOT-b520]
at com.comphenix.protocol.injector.EntityUtilities.getEntityFromID(EntityUtilities.java:234) ~[ProtocolLib.jar:4.7.0-SNAPSHOT-b520]
at com.comphenix.protocol.injector.PacketFilterManager.getEntityFromID(PacketFilterManager.java:851) ~[ProtocolLib.jar:4.7.0-SNAPSHOT-b520]
at com.comphenix.protocol.wrappers.BukkitConverters$10.getSpecific(BukkitConverters.java:692) ~[ProtocolLib.jar:4.7.0-SNAPSHOT-b520]
... 46 more
Caused by: java.lang.IllegalStateException: Asynchronous Chunk getEntities call!
at org.spigotmc.AsyncCatcher.catchOp(AsyncCatcher.java:14) ~[spigot.jar:3159-Spigot-f773da8-887bc05]
at net.minecraft.server.level.WorldServer.getEntities(WorldServer.java:1795) ~[spigot.jar:3159-Spigot-f773da8-887bc05]
at net.minecraft.server.level.WorldServer.b(WorldServer.java:1312) ~[spigot.jar:3159-Spigot-f773da8-887bc05]
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.jar:4.7.0-SNAPSHOT-b520]
at com.comphenix.protocol.injector.EntityUtilities.getEntityFromID(EntityUtilities.java:234) ~[ProtocolLib.jar:4.7.0-SNAPSHOT-b520]
at com.comphenix.protocol.injector.PacketFilterManager.getEntityFromID(PacketFilterManager.java:851) ~[ProtocolLib.jar:4.7.0-SNAPSHOT-b520]
at com.comphenix.protocol.wrappers.BukkitConverters$10.getSpecific(BukkitConverters.java:692) ~[ProtocolLib.jar:4.7.0-SNAPSHOT-b520]
... 46 more
[11:07:07] [Netty Server IO #3/ERROR]: Parameters:
net.minecraft.network.protocol.game.PacketPlayInUseEntity@459da272[
a=584
b=net.minecraft.network.protocol.game.PacketPlayInUseEntity$1@58e215d1
c=false
]
@dmulloy2 Having the same issue, certain spigot forks have some sort of Async Catcher for this which is fair.
However in my case i'm unable to use this on the main thread, Let me know if there's any possible solution.
I also don't want to force this to the main thread.
@dmulloy2 Having the same issue, certain spigot forks have some sort of Async Catcher for this which is fair.
However in my case i'm unable to use this on the main thread, Let me know if there's any possible solution.
I also don't want to force this to the main thread.
I'm 99% sure it's impossible to avoid this since it's an internal check of the Spigot code.
In order to bypass this you have to reimplement the NMS code which gets entities to be able to call it on another thread, but keep in mind that it won't be reliable.
@LoneDev6 Makes sense, What was your fix for this if you don't mind me asking?
Cause i'm trying to avoid going on the main thread no matter the cost.
@LoneDev6 Makes sense, What was your fix for this if you don't mind me asking? Cause i'm trying to avoid going on the main thread no matter the cost.
I basically took the NMS code and got rid of the async call check, then called it instead, that's the only way
Hmm that's a tricky one. Are you doing something with use entity that could be done sync?
Hmm that's a tricky one. Are you doing something with use entity that could be done sync?
Nope, I'm just calling this method in a normal packet listener:
getEntityModifier
Seems that they added an async check in some internal functions you call to get the entity modifiers fields