ProtocolLib

3M Downloads

Exception when trying to read the entity metadata (1.19.3)

Brokkonaut opened this issue ยท 4 comments

commented

I am not sure if I use the api correctly, I tried to modify the entity metadata in the ENTITY_METADATA packet in 1.19.3, so I tried to get the values like this

List<WrappedDataValue> watchables = packet.getDataValueCollectionModifier().read(0);

but i get the following exception:
java.lang.IllegalArgumentException: handle (net.minecraft.network.syncher.DataWatcher$Item@45339ee7) is not a class net.minecraft.network.syncher.DataWatcher$b, but class net.minecraft.network.syncher.DataWatcher$Item
https://cpaste.de/ibewiriwil.properties

Server
ProtocolLib Version: ProtocolLib v5.0.0-SNAPSHOT-b607
Bukkit Version: 1.19.3-R0.1-SNAPSHOT
Server Version: git-Paper-"c919e94" (MC: 1.19.3)
Java Version: 17.0.4

commented

Thanks for the code snippet. I'm attempting to resolve this entity metadata packet change in this Spigot thread, unfortunately I have been unsuccessful so far. I'm intercepting packets, not sending them, so I couldn't understand how to transfer the goods of the code snippet across.

Edit: check this thread for the solution :)

commented

Not sure what you're doing exactly, for reference how deal with meta in 1.19.3 (and only 1.19.3), see:

PacketContainer entityMetadata = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
StructureModifier<List<WrappedDataValue>> watchableAccessor = entityMetadata.getDataValueCollectionModifier();
assertEquals(0, watchableAccessor.read(0).size());
List<WrappedDataValue> values = Lists.newArrayList(
new WrappedDataValue(0, Registry.get(Byte.class), (byte) 21),
new WrappedDataValue(1, Registry.get(String.class), "World"));
// Insert and read back
watchableAccessor.write(0, values);
assertEquals(values, watchableAccessor.read(0));

Thanks. Changing from packet.getWatchableCollectionModifier().read(0) to packet.getDataValueCollectionModifier().read(0) fixed my issue.

commented
[18:33:50 ERROR]: [ProtocolStringReplacer] Unhandled exception occurred in onPacketSending(PacketEvent) for ProtocolStringReplacer
java.lang.IllegalArgumentException: Unrecognized type class net.minecraft.network.syncher.DataWatcher$b
        at com.comphenix.protocol.wrappers.BukkitConverters$8.getSpecific(BukkitConverters.java:639) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.wrappers.BukkitConverters$8.getSpecific(BukkitConverters.java:626) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.wrappers.Converters$1.getSpecific(Converters.java:42) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.wrappers.BukkitConverters.getSpecificList(BukkitConverters.java:321) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.wrappers.BukkitConverters.access$000(BukkitConverters.java:91) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.wrappers.BukkitConverters$3.getSpecific(BukkitConverters.java:365) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.wrappers.BukkitConverters$3.getSpecific(BukkitConverters.java:362) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.wrappers.Converters$1.getSpecific(Converters.java:42) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.reflect.StructureModifier.readInternal(StructureModifier.java:274) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.reflect.StructureModifier.read(StructureModifier.java:224) ~[ProtocolLib.jar:?]
        at me.rothes.protocolstringreplacer.packetlisteners.server.EntityMetadata.process(EntityMetadata.java:46) ~[ProtocolStringReplacer v2.12.2.jar:?]
        at me.rothes.protocolstringreplacer.packetlisteners.server.AbstractServerPacketListener.access$100(AbstractServerPacketListener.java:27) ~[ProtocolStringReplacer v2.12.2.jar:?]
        at me.rothes.protocolstringreplacer.packetlisteners.server.AbstractServerPacketListener$1.onPacketSending(AbstractServerPacketListener.java:42) ~[ProtocolStringReplacer v2.12.2.jar:?]
        at com.comphenix.protocol.injector.SortedPacketListenerList.invokeSendingListener(SortedPacketListenerList.java:195) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.injector.SortedPacketListenerList.invokePacketSending(SortedPacketListenerList.java:149) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.injector.PacketFilterManager.postPacketToListeners(PacketFilterManager.java:547) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.injector.PacketFilterManager.invokePacketSending(PacketFilterManager.java:521) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.injector.netty.manager.NetworkManagerInjector.onPacketSending(NetworkManagerInjector.java:99) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.injector.netty.channel.NettyChannelInjector.processOutbound(NettyChannelInjector.java:571) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.injector.netty.channel.NettyChannelInjector$2.doProxyRunnable(NettyChannelInjector.java:472) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.injector.netty.channel.NettyEventLoopProxy.proxyRunnable(NettyEventLoopProxy.java:43) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.injector.netty.channel.NettyEventLoopProxy.execute(NettyEventLoopProxy.java:252) ~[ProtocolLib.jar:?]
        at net.minecraft.network.Connection.sendPacket(Connection.java:432) ~[?:?]
        at net.minecraft.network.Connection.send(Connection.java:379) ~[?:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.send(ServerGamePacketListenerImpl.java:2161) ~[?:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.send(ServerGamePacketListenerImpl.java:2147) ~[?:?]
        at net.minecraft.server.level.ServerEntity.sendPairingData(ServerEntity.java:279) ~[?:?]
        at net.minecraft.server.level.ServerEntity.addPairing(ServerEntity.java:262) ~[?:?]
        at net.minecraft.server.level.ChunkMap$TrackedEntity.updatePlayer(ChunkMap.java:1614) ~[?:?]
        at net.minecraft.server.level.ChunkMap.addEntity(ChunkMap.java:1218) ~[paper-1.19.3.jar:git-Paper-327]
        at net.minecraft.server.players.PlayerList.postChunkLoadJoin(PlayerList.java:413) ~[paper-1.19.3.jar:git-Paper-327]
        at net.minecraft.server.players.PlayerList.lambda$placeNewPlayer$0(PlayerList.java:316) ~[paper-1.19.3.jar:git-Paper-327]
        at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.19.3.jar:git-Paper-327]
        at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
        at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
        at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1341) ~[paper-1.19.3.jar:git-Paper-327]
        at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:197) ~[paper-1.19.3.jar:git-Paper-327]
        at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
        at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1318) ~[paper-1.19.3.jar:git-Paper-327]
        at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1311) ~[paper-1.19.3.jar:git-Paper-327]
        at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
        at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1389) ~[paper-1.19.3.jar:git-Paper-327]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1173) ~[paper-1.19.3.jar:git-Paper-327]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:316) ~[paper-1.19.3.jar:git-Paper-327]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
[18:33:50 ERROR]: Parameters:
  net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata@1bcd81aa[
    b=83
    c=[b[id=9, serializer=net.minecraft.network.syncher.DataWatcherSerializer$1@325240dd, value=6.0], b[id=16, serializer=net.minecraft.network.syncher.DataWatcherSerializer$1@41cfcb6d, value=1]]
  ]

ProtocolLib v5.0.0-SNAPSHOT-b607

commented

Not sure what you're doing exactly, for reference how deal with meta in 1.19.3 (and only 1.19.3), see:

PacketContainer entityMetadata = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
StructureModifier<List<WrappedDataValue>> watchableAccessor = entityMetadata.getDataValueCollectionModifier();
assertEquals(0, watchableAccessor.read(0).size());
List<WrappedDataValue> values = Lists.newArrayList(
new WrappedDataValue(0, Registry.get(Byte.class), (byte) 21),
new WrappedDataValue(1, Registry.get(String.class), "World"));
// Insert and read back
watchableAccessor.write(0, values);
assertEquals(values, watchableAccessor.read(0));