Hi! I'm using the WrapperPlayServerLogin wrapper and I can't seem to set the dimension field using WrapperPlayServerLogin#setDimension.
Here's my code (simplified):
PacketContainer packet = protocolManager.createPacket(PacketType.Play.Server.LOGIN);
WrapperPlayServerLogin wrapper = new WrapperPlayServerLogin(packet);
wrapper.setDimension(Bukkit.getWorlds().get(0));
// Later I'm casting the packet to a WirePacket
WirePacket wirePacket = WirePacket.fromPacket(packet);
byte[] packetBytes = wirePacket.getBytes();
And here's the error:
org.bukkit.command.CommandException: Unhandled exception executing command 'test' in plugin ReplayCore v1.0.0
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.19.4-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[paper-api-1.19.4-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R3.CraftServer.dispatchCommand(CraftServer.java:929) ~[paper-1.19.4.jar:git-Paper-550]
at org.bukkit.craftbukkit.v1_19_R3.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:64) ~[paper-1.19.4.jar:git-Paper-550]
at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:264) ~[paper-1.19.4.jar:?]
at net.minecraft.commands.Commands.performCommand(Commands.java:322) ~[?:?]
at net.minecraft.commands.Commands.performCommand(Commands.java:306) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.performChatCommand(ServerGamePacketListenerImpl.java:2297) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$20(ServerGamePacketListenerImpl.java:2257) ~[?:?]
at net.minecraft.util.thread.BlockableEventLoop.lambda$submitAsync$0(BlockableEventLoop.java:59) ~[?:?]
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.19.4.jar:git-Paper-550]
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:1342) ~[paper-1.19.4.jar:git-Paper-550]
at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:197) ~[paper-1.19.4.jar:git-Paper-550]
at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1319) ~[paper-1.19.4.jar:git-Paper-550]
at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1312) ~[paper-1.19.4.jar:git-Paper-550]
at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1290) ~[paper-1.19.4.jar:git-Paper-550]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1178) ~[paper-1.19.4.jar:git-Paper-550]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:320) ~[paper-1.19.4.jar:git-Paper-550]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.IllegalStateException: Unable to invoke method public abstract void net.minecraft.network.protocol.Packet.a(net.minecraft.network.PacketDataSerializer)
at com.comphenix.protocol.reflect.accessors.DefaultMethodAccessor.invoke(DefaultMethodAccessor.java:25) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.netty.WirePacket.bytesFromPacket(WirePacket.java:89) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.netty.WirePacket.fromPacket(WirePacket.java:72) ~[ProtocolLib.jar:?]
at net.laboulangerie.replaycore.packets.ReplayPacket.toBytes(ReplayPacket.java:30) ~[ReplayCore.jar:?]
at net.laboulangerie.replaycore.packets.LoginPackets.getPacketsBytes(LoginPackets.java:110) ~[ReplayCore.jar:?]
at net.laboulangerie.replaycore.commands.Test.onCommand(Test.java:26) ~[ReplayCore.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.19.4-R0.1-SNAPSHOT.jar:?]
... 23 more
Caused by: java.lang.ClassCastException: class net.minecraft.server.level.WorldServer cannot be cast to class net.minecraft.resources.ResourceKey (net.minecraft.server.level.WorldServer and net.minecraft.resources.ResourceKey are in unnamed module of loader java.net.URLClassLoader @61386958)
at net.minecraft.network.FriendlyByteBuf.writeCollection(FriendlyByteBuf.java:243) ~[?:?]
at net.minecraft.network.protocol.game.ClientboundLoginPacket.write(ClientboundLoginPacket.java:37) ~[?:?]
at com.comphenix.protocol.reflect.accessors.DefaultMethodAccessor.invoke(DefaultMethodAccessor.java:23) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.netty.WirePacket.bytesFromPacket(WirePacket.java:89) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.injector.netty.WirePacket.fromPacket(WirePacket.java:72) ~[ProtocolLib.jar:?]
at net.laboulangerie.replaycore.packets.ReplayPacket.toBytes(ReplayPacket.java:30) ~[ReplayCore.jar:?]
at net.laboulangerie.replaycore.packets.LoginPackets.getPacketsBytes(LoginPackets.java:110) ~[ReplayCore.jar:?]
at net.laboulangerie.replaycore.commands.Test.onCommand(Test.java:26) ~[ReplayCore.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.19.4-R0.1-SNAPSHOT.jar:?]
... 23 more
Looks like I should be passing a ResourceKey instead of a World, but the wrapper method only accepts worlds. I don't think this is related to the casting to WirePacket and then to bytes because that's a simple conversion, but it looks like that this is the conversion that is catching the type issue.
Also I noticed that the test for this wrapper contains a commented line about the setDimension, maybe that's how this issue got introduced.
Thanks for looking into the issue!
Hi! I'm using the WrapperPlayServerLogin wrapper and I can't seem to set the dimension field using WrapperPlayServerLogin#setDimension.
Here's my code (simplified):
And here's the error:
Looks like I should be passing a ResourceKey instead of a World, but the wrapper method only accepts worlds. I don't think this is related to the casting to WirePacket and then to bytes because that's a simple conversion, but it looks like that this is the conversion that is catching the type issue.
Also I noticed that the test for this wrapper contains a commented line about the setDimension, maybe that's how this issue got introduced.
Thanks for looking into the issue!