PacketEvent not cancelling
Benz56 opened this issue ยท 7 comments
Describe the bug
The PacketEvent doesn't cancel on Spigot 1.16.1.
In 1.15.2 when the player pressed shift when mounted on an armorstand they weren't dismounted; they are on 1.16.1.
To Reproduce
Steps to reproduce the behavior:
- Mount the player on an armor stand.
- Apply this PacketAdapter:
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Client.STEER_VEHICLE) {
@Override
public void onPacketReceiving(final PacketEvent event) {
final Player player = event.getPlayer();
if (!player.isInsideVehicle()) return;
event.setCancelled(true);
}
});
- Notice that the player dismounts the armorstand even though they shouldn't.
Expected behavior
The player shouldn't be able to leave the armorstand.
Version Info
https://pastebin.com/9SLJTVQx
If the issue comes down to which version you use, it's likely an internal change with NMS that ProtocolLib can't really help. To see if this is a PL issue, try cancelling another packet (chat, for example). If that works, you'll have to look for another way to stop dismounts. If it doesn't work, I'll look into why PL isn't cancelling packets
Canceling the chat packet works fine.
Canceling PacketType.Play.Client.STEER_VEHICLE works fine for WASD but doesn't work for shift-presses for some reason. I get this is 1.16 specific but hopefully, there is a fix for this?
I see another user is experiencing the same issue here #892.
I am a developer of BetonQuest and I can confirm that this issue only appears in the STEER_VEHICLE packat. For us it is really important, that this is fixed, because we use this packet in NPC conversations, and this is a realy important feature.
This issue seems unable to receive a fix. I tested a lot even with cancelling these packets in ProtocolLib code. Player gets stucked in a vehicle except on dismount. Perhaps a game issue, I'm not sure, I'm not a pro, but player reacts weirdly and seems still inside a vehicle for the server sometimes :/
I'd like to add that the issue is client-related. E.g. if you're running a 1.15.2 server with protocol support allowing 1.16 clients to join you can cancel the "shift" packet event for every client except 1.16 clients.
I spent a decent amount of time trying to get this to work ProtocolLib side and I concur with md_5 that there isn't really a sane way to do this server-side. So I'm going to close this issue and recommend BKCommonLib's workaround until Mojang fixes the issue. Sorry there isn't a more satisfying response.
Fully confirmed, this is a client issue ^^ https://hub.spigotmc.org/jira/browse/SPIGOT-5891 - https://bugs.mojang.com/browse/MC-191714
For interested people, here is a "workaround" made by BKCommonLib -> bergerhealer/BKCommonLib@6cba8ca