ProtocolLib

3M Downloads

Unable to broadcast packet due to EntityTracker issue

LOOHP opened this issue ยท 7 comments

commented

Describe the bug
Using ProtocolLibrary.getProtocolManager().broadcastServerPacket(packet, entity, false); to sent a packet throws errors related to the EntityTracker

[06:05:19] [Craft Scheduler Thread - 286/ERROR]: [HoloMobHealth] Unhandled exception occured in onPacketSending(PacketEvent) for HoloMobHealth
java.lang.IllegalArgumentException: Unable to find a field that matches {modifiers=[required: 0, banned: 0], name=\QtrackedEntities\E, type=input instanceof interface java.util.Map}
	at com.comphenix.protocol.reflect.FuzzyReflection.getField(FuzzyReflection.java:460) ~[?:?]
	at com.comphenix.protocol.injector.EntityUtilities.getNewEntityTracker(EntityUtilities.java:161) ~[?:?]
	at com.comphenix.protocol.injector.EntityUtilities.getEntityTrackerEntry(EntityUtilities.java:174) ~[?:?]
	at com.comphenix.protocol.injector.EntityUtilities.getTrackedPlayers(EntityUtilities.java:116) ~[?:?]
	at com.comphenix.protocol.injector.EntityUtilities.getEntityTrackers(EntityUtilities.java:101) ~[?:?]
	at com.comphenix.protocol.injector.PacketFilterManager.getEntityTrackers(PacketFilterManager.java:856) ~[?:?]
	at com.comphenix.protocol.injector.PacketFilterManager.broadcastServerPacket(PacketFilterManager.java:617) ~[?:?]
	at com.loohp.holomobhealth.protocol.ArmorStandPacket.updateArmorStand(ArmorStandPacket.java:224) ~[?:?]
	at com.loohp.holomobhealth.modules.ArmorstandDisplay$1.onPacketSending(ArmorstandDisplay.java:235) ~[?:?]
	at com.comphenix.protocol.injector.SortedPacketListenerList.invokeSendingListener(SortedPacketListenerList.java:195) ~[?:?]
	at com.comphenix.protocol.injector.SortedPacketListenerList.invokePacketSending(SortedPacketListenerList.java:149) ~[?:?]
	at com.comphenix.protocol.injector.PacketFilterManager.handlePacket(PacketFilterManager.java:535) ~[?:?]
	at com.comphenix.protocol.injector.PacketFilterManager.invokePacketSending(PacketFilterManager.java:516) ~[?:?]
	at com.comphenix.protocol.injector.netty.ProtocolInjector.packetQueued(ProtocolInjector.java:346) ~[?:?]
	at com.comphenix.protocol.injector.netty.ProtocolInjector.onPacketSending(ProtocolInjector.java:308) ~[?:?]
	at com.comphenix.protocol.injector.netty.ChannelInjector.processSending(ChannelInjector.java:433) ~[?:?]
	at com.comphenix.protocol.injector.netty.ChannelInjector.access$800(ChannelInjector.java:70) ~[?:?]
	at com.comphenix.protocol.injector.netty.ChannelInjector$3.handleScheduled(ChannelInjector.java:373) ~[?:?]
	at com.comphenix.protocol.injector.netty.ChannelInjector$3.onMessageScheduled(ChannelInjector.java:343) ~[?:?]
	at com.comphenix.protocol.injector.netty.ChannelProxy$2.schedulingRunnable(ChannelProxy.java:127) ~[?:?]
	at com.comphenix.protocol.injector.netty.EventLoopProxy.execute(EventLoopProxy.java:95) ~[?:?]
	at net.minecraft.network.NetworkManager.b(NetworkManager.java:203) ~[spigot-1.17.jar:3138-Spigot-66f9d3c-77058c7]
	at net.minecraft.network.NetworkManager.sendPacket(NetworkManager.java:183) ~[spigot-1.17.jar:3138-Spigot-66f9d3c-77058c7]
	at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1708) ~[spigot-1.17.jar:3138-Spigot-66f9d3c-77058c7]
	at net.minecraft.server.network.PlayerConnection.sendPacket(PlayerConnection.java:1694) ~[spigot-1.17.jar:3138-Spigot-66f9d3c-77058c7]
	at jdk.internal.reflect.GeneratedMethodAccessor197.invoke(Unknown Source) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?]
	at com.comphenix.protocol.injector.netty.ChannelInjector.invokeSendPacket(ChannelInjector.java:745) ~[?:?]
	at com.comphenix.protocol.injector.netty.ChannelInjector.sendServerPacket(ChannelInjector.java:730) ~[?:?]
	at com.comphenix.protocol.injector.netty.ProtocolInjector$4.sendServerPacket(ProtocolInjector.java:411) ~[?:?]
	at com.comphenix.protocol.injector.PacketFilterManager.sendServerPacket(PacketFilterManager.java:733) ~[?:?]
	at com.comphenix.protocol.injector.PacketFilterManager.sendServerPacket(PacketFilterManager.java:687) ~[?:?]
	at com.loohp.holomobhealth.protocol.EntityMetadata.lambda$updateEntity$0(EntityMetadata.java:58) ~[?:?]
	at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftTask.run(CraftTask.java:81) [spigot-1.17.jar:3138-Spigot-66f9d3c-77058c7]
	at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:54) [spigot-1.17.jar:3138-Spigot-66f9d3c-77058c7]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) [?:?]
	at java.lang.Thread.run(Thread.java:831) [?:?]
[06:05:19] [Craft Scheduler Thread - 286/ERROR]: Parameters: 
  net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata@2463cb44[
    a=49
    b=[net.minecraft.network.syncher.DataWatcher$Item@313014e1, net.minecraft.network.syncher.DataWatcher$Item@7b90ae7a, net.minecraft.network.syncher.DataWatcher$Item@133a9fcb, net.minecraft.network.syncher.DataWatcher$Item@6de6079e, net.minecraft.network.syncher.DataWatcher$Item@5cc091df, net.minecraft.network.syncher.DataWatcher$Item@22dd0743, net.minecraft.network.syncher.DataWatcher$Item@65de1014, net.minecraft.network.syncher.DataWatcher$Item@38d931c6, net.minecraft.network.syncher.DataWatcher$Item@60cf016b, net.minecraft.network.syncher.DataWatcher$Item@2a62e52e, net.minecraft.network.syncher.DataWatcher$Item@3fa91ec6, net.minecraft.network.syncher.DataWatcher$Item@4e8f4ff4, net.minecraft.network.syncher.DataWatcher$Item@56d3db17, net.minecraft.network.syncher.DataWatcher$Item@6b251f76, net.minecraft.network.syncher.DataWatcher$Item@1c0d63fa, net.minecraft.network.syncher.DataWatcher$Item@28c97f60, net.minecraft.network.syncher.DataWatcher$Item@608a120d]
  ]

To Reproduce
Steps to reproduce the behavior:

  1. Send a packet with the method above
  2. See error

Expected behavior
No error occurs

Screenshots
N/A

Version Info
https://pastebin.com/c2y9T0vy

Additional context
This is the issue I mentioned in #1209

commented

@LOOHP latest dev build should have fixed this

commented

@LOOHP is it working?

commented

I've just tested with Paper 1.17 build 16 and ProtocolLib build 516 to test and I'm getting an error

[21:38:00 ERROR]: [HoloMobHealth] Unhandled exception number 8192 occured in onPacketSending(PacketEvent) for HoloMobHealth
java.lang.NoClassDefFoundError: org/bukkit/craftbukkit/libs/it/unimi/dsi/fastutil/ints/Int2ObjectMap
        at com.comphenix.protocol.injector.EntityUtilities.getNewEntityTracker(EntityUtilities.java:166) ~[?:?]
        at com.comphenix.protocol.injector.EntityUtilities.getEntityTrackerEntry(EntityUtilities.java:187) ~[?:?]
        at com.comphenix.protocol.injector.EntityUtilities.getTrackedPlayers(EntityUtilities.java:117) ~[?:?]
        at com.comphenix.protocol.injector.EntityUtilities.getEntityTrackers(EntityUtilities.java:102) ~[?:?]
        at com.comphenix.protocol.injector.PacketFilterManager.getEntityTrackers(PacketFilterManager.java:856) ~[?:?]
        at com.comphenix.protocol.injector.PacketFilterManager.broadcastServerPacket(PacketFilterManager.java:617) ~[?:?]
        at com.loohp.holomobhealth.protocol.ArmorStandPacket.updateArmorStandLocation(ArmorStandPacket.java:265) ~[?:?]
        at com.loohp.holomobhealth.modules.ArmorstandDisplay$6.lambda$onPacketSending$0(ArmorstandDisplay.java:383) ~[?:?]
        at java.util.ArrayList.forEach(ArrayList.java:1511) ~[?:?]
        at com.loohp.holomobhealth.modules.ArmorstandDisplay$6.onPacketSending(ArmorstandDisplay.java:383) ~[?:?]
        at com.comphenix.protocol.injector.SortedPacketListenerList.invokeSendingListener(SortedPacketListenerList.java:195) ~[?:?]
        at com.comphenix.protocol.injector.SortedPacketListenerList.invokePacketSending(SortedPacketListenerList.java:149) ~[?:?]
        at com.comphenix.protocol.injector.PacketFilterManager.handlePacket(PacketFilterManager.java:535) ~[?:?]
        at com.comphenix.protocol.injector.PacketFilterManager.invokePacketSending(PacketFilterManager.java:516) ~[?:?]
        at com.comphenix.protocol.injector.netty.ProtocolInjector.packetQueued(ProtocolInjector.java:346) ~[?:?]
        at com.comphenix.protocol.injector.netty.ProtocolInjector.onPacketSending(ProtocolInjector.java:308) ~[?:?]
        at com.comphenix.protocol.injector.netty.ChannelInjector.processSending(ChannelInjector.java:433) ~[?:?]
        at com.comphenix.protocol.injector.netty.ChannelInjector.access$800(ChannelInjector.java:70) ~[?:?]
        at com.comphenix.protocol.injector.netty.ChannelInjector$3.handleScheduled(ChannelInjector.java:373) ~[?:?]
        at com.comphenix.protocol.injector.netty.ChannelInjector$3.onMessageScheduled(ChannelInjector.java:343) ~[?:?]
        at com.comphenix.protocol.injector.netty.ChannelProxy$2.schedulingRunnable(ChannelProxy.java:127) ~[?:?]
        at com.comphenix.protocol.injector.netty.EventLoopProxy.execute(EventLoopProxy.java:95) ~[?:?]
        at net.minecraft.network.NetworkManager.b(NetworkManager.java:294) ~[Paper-Server-reobf.jar:git-Paper-"558be4b"]
        at net.minecraft.network.NetworkManager.sendPacket(NetworkManager.java:258) ~[Paper-Server-reobf.jar:git-Paper-"558be4b"]
        at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1920) ~[Paper-Server-reobf.jar:git-Paper-"558be4b"]
        at net.minecraft.server.network.PlayerConnection.sendPacket(PlayerConnection.java:1906) ~[Paper-Server-reobf.jar:git-Paper-"558be4b"]
        at net.minecraft.server.level.PlayerChunkMap$EntityTracker.broadcast(PlayerChunkMap.java:2327) ~[Paper-Server-reobf.jar:git-Paper-"558be4b"]
        at net.minecraft.server.level.EntityTrackerEntry.a(EntityTrackerEntry.java:204) ~[Paper-Server-reobf.jar:git-Paper-"558be4b"]
        at net.minecraft.server.level.PlayerChunkMap.processTrackQueue(PlayerChunkMap.java:2051) ~[Paper-Server-reobf.jar:git-Paper-"558be4b"]
        at net.minecraft.server.level.PlayerChunkMap.g(PlayerChunkMap.java:2062) ~[Paper-Server-reobf.jar:git-Paper-"558be4b"]
        at net.minecraft.server.level.ChunkProviderServer.tickChunks(ChunkProviderServer.java:874) ~[Paper-Server-reobf.jar:git-Paper-"558be4b"]
        at net.minecraft.server.level.ChunkProviderServer.tick(ChunkProviderServer.java:753) ~[Paper-Server-reobf.jar:git-Paper-"558be4b"]
        at net.minecraft.server.level.WorldServer.doTick(WorldServer.java:581) ~[Paper-Server-reobf.jar:git-Paper-"558be4b"]
        at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1551) ~[Paper-Server-reobf.jar:git-Paper-"558be4b"]
        at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:476) ~[Paper-Server-reobf.jar:git-Paper-"558be4b"]
        at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1404) ~[Paper-Server-reobf.jar:git-Paper-"558be4b"]
        at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1180) ~[Paper-Server-reobf.jar:git-Paper-"558be4b"]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:320) ~[Paper-Server-reobf.jar:git-Paper-"558be4b"]
        at java.lang.Thread.run(Thread.java:831) [?:?]

I guess this is just due to the fact that paper relocated the FastUtil, will test with regular spigot in a moment.

commented

Alright, I've tested with regular spigot, there are no errors, tho it seems like the packet isn't sent to nearby players. The same code works when I send the packet to each nearby player individually.

commented

Sorry for the late response, I will give it a try (very) shortly.

commented

@LOOHP is this still broken on the latest dev build?

commented

Should be working!