ProtocolLib

3M Downloads

First field of RESPAWN packet is different in 1.13

mirolm opened this issue ยท 4 comments

commented

In previous versions of minecraft this field was integer and addressing it looked like this:

PacketContainer respawn = new PacketContainer(RESPAWN);

int dimensionId = receiver.getWorld().getEnvironment().getId();
respawn.getIntegers().writeSafely(0, dimensionId);

In 1.13 for this field we need to use DimensionManager class with reflection. Can we do this with only ProtocolLib without using reflection?

commented

The dimension seems to still be an integer unless I'm missing something

commented

My bad it happened on 1.13.1 maybe things changed there. Here is the error from a plugin that uses it:

[19:16:37] [Server thread/WARN]: [ChangeSkin] Task #382 for ChangeSkin v3.1-SNAPSHOT-a053874 generated an exception
com.comphenix.protocol.reflect.FieldAccessException: No field with type int exists in class PacketPlayOutRespawn.
        at com.comphenix.protocol.reflect.StructureModifier.writeInternal(StructureModifier.java:363) ~[?:?]
        at com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:343) ~[?:?]
        at com.github.games647.changeskin.bukkit.task.SkinApplier.sendPacketsSelf(SkinApplier.java:160) ~[?:?]
        at com.github.games647.changeskin.bukkit.task.SkinApplier.sendUpdateSelf(SkinApplier.java:115) ~[?:?]
        at com.github.games647.changeskin.bukkit.task.SkinApplier.applyInstantUpdate(SkinApplier.java:85) ~[?:?]
        at com.github.games647.changeskin.core.shared.task.SharedApplier.applySkin(SharedApplier.java:27) ~[?:?]
        at com.github.games647.changeskin.bukkit.task.SkinApplier.run(SkinApplier.java:73) ~[?:?]
        at org.bukkit.craftbukkit.v1_13_R2.scheduler.CraftTask.run(CraftTask.java:76) ~[spigot-1.13.1.jar:git-Spigot-2440e18-9636bb8]
        at org.bukkit.craftbukkit.v1_13_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:361) [spigot-1.13.1.jar:git-Spigot-2440e18-9636bb8]
        at net.minecraft.server.v1_13_R2.MinecraftServer.b(MinecraftServer.java:889) [spigot-1.13.1.jar:git-Spigot-2440e18-9636bb8]
        at net.minecraft.server.v1_13_R2.DedicatedServer.b(DedicatedServer.java:411) [spigot-1.13.1.jar:git-Spigot-2440e18-9636bb8]
        at net.minecraft.server.v1_13_R2.MinecraftServer.a(MinecraftServer.java:831) [spigot-1.13.1.jar:git-Spigot-2440e18-9636bb8]
        at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:729) [spigot-1.13.1.jar:git-Spigot-2440e18-9636bb8]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_181]
commented

Right, yeah, just noticed that on 1.13.1. What a useless change... Anyways I'll look into a decent fix

commented

Added in 6fdf0f8