Make sure you're doing the following
Describe the question
I am working on updating my plugin to support the 1.21.x series of releases (and soon 26.1)
My server is on paper 1.21.11 build 127
I am using the latest dev build of protocol lib (v5.5.0-SNAPSHOT-f911ee9)
I have tested by plugin against both protocol lib 5.4.0 from maven, and v5.5.0-SNAPSHOT-f911ee9 directly from the jar
I am trying to create an ENTITY_TELEPORT (or on new versions after 1.21.2, ENTITY_POSITION_SYNC) packet
When I try to set the position (there are three doubles, x, y ,z) as described for both packets in the protocol wiki, i get the following error
[09:21:22 WARN]: [KenshinsHideAndSeek] Task #3 for KenshinsHideAndSeek v2.0.0 generated an exception
com.comphenix.protocol.reflect.FieldAccessException: Field index 0 is out of bounds for length 0
at ProtocolLib.jar//com.comphenix.protocol.reflect.FieldAccessException.fromFormat(FieldAccessException.java:49) ~[?:?]
at ProtocolLib.jar//com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:318) ~[?:?]
at khs-2.0.0-SNAPSHOT.jar//cat.freya.khs.bukkit.packet.EntityTeleportPacket.setPosition(EntityTeleportPacket.kt:21) ~[?:?]
at khs-2.0.0-SNAPSHOT.jar//cat.freya.khs.bukkit.disguise.Disguise.teleportEntity(Disguise.kt:163) ~[?:?]
at khs-2.0.0-SNAPSHOT.jar//cat.freya.khs.bukkit.disguise.Disguise.update(Disguise.kt:78) ~[?:?]
at khs-2.0.0-SNAPSHOT.jar//cat.freya.khs.bukkit.disguise.Disguiser.update(Disguiser.kt:46) ~[?:?]
at khs-2.0.0-SNAPSHOT.jar//cat.freya.khs.bukkit.KhsPlugin$onEnable$1.run(Plugin.kt:30) ~[?:?]
at org.bukkit.craftbukkit.scheduler.CraftTask.run(CraftTask.java:78) ~[paper-1.21.11.jar:1.21.11-127-bd74bf6]
at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:474) ~[paper-1.21.11.jar:1.21.11-127-bd74bf6]
at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1756) ~[paper-1.21.11.jar:1.21.11-127-bd74bf6]
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1611) ~[paper-1.21.11.jar:1.21.11-127-bd74bf6]
at net.minecraft.server.dedicated.DedicatedServer.tickServer(DedicatedServer.java:427) ~[paper-1.21.11.jar:1.21.11-127-bd74bf6]
at net.minecraft.server.MinecraftServer.processPacketsAndTick(MinecraftServer.java:1667) ~[paper-1.21.11.jar:1.21.11-127-bd74bf6]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1335) ~[paper-1.21.11.jar:1.21.11-127-bd74bf6]
at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:388) ~[paper-1.21.11.jar:1.21.11-127-bd74bf6]
at java.base/java.lang.Thread.run(Thread.java:1474) ~[?:?]
A clear and concise description of what your question is.
API method(s) used
This is the following code I use. Note this is kotlin, so things like .doubles is aliased from .getDoubles()
abstract class Packet(val type: PacketType) {
val manager: ProtocolManager
val packet: PacketContainer
init {
manager = ProtocolLibrary.getProtocolManager()
packet = manager.createPacket(type)
packet.modifier.writeDefaults()
}
fun send(player: BukkitPlayer) {
manager.sendServerPacket(player, packet)
}
fun send(player: KhsPlayer) { // inner is org.bukkit.entity.Player
send((player as BukkitKhsPlayer).inner)
}
}
private fun getPacketType(plugin: KhsPlugin): PacketType {
if (plugin.shim.supports(21, 2))
return PacketType.Play.Server.ENTITY_POSITION_SYNC
else
return PacketType.Play.Server.ENTITY_TELEPORT
}
class EntityTeleportPacket(val plugin: KhsPlugin) : Packet(getPacketType(plugin)) {
fun setEntity(entity: Entity) {
packet.integers.write(0, entity.entityId)
}
fun setPosition(x: Double, y: Double, z: Double) {
packet.doubles.write(0, x)
packet.doubles.write(0, y)
packet.doubles.write(0, z)
}
}
Expected behavior
On previous versions 1.20.x and before this worked fine, but now its not. I'm making this issue as an api question as I don't know for sure if its a bug on protocol libs end, and more likely my skill issue (but who knows)
Am I doing anything wrong or is this a current issue with protocol lib
Make sure you're doing the following
/reloadDescribe the question
I am working on updating my plugin to support the 1.21.x series of releases (and soon 26.1)
My server is on paper 1.21.11 build 127
I am using the latest dev build of protocol lib (v5.5.0-SNAPSHOT-f911ee9)
I have tested by plugin against both protocol lib 5.4.0 from maven, and v5.5.0-SNAPSHOT-f911ee9 directly from the jar
I am trying to create an ENTITY_TELEPORT (or on new versions after 1.21.2, ENTITY_POSITION_SYNC) packet
When I try to set the position (there are three doubles, x, y ,z) as described for both packets in the protocol wiki, i get the following error
A clear and concise description of what your question is.
API method(s) used
This is the following code I use. Note this is kotlin, so things like
.doublesis aliased from.getDoubles()Expected behavior
On previous versions 1.20.x and before this worked fine, but now its not. I'm making this issue as an api question as I don't know for sure if its a bug on protocol libs end, and more likely my skill issue (but who knows)
Am I doing anything wrong or is this a current issue with protocol lib