From 5cc421cff9fa6c52984b77606f5a9762eea62b94 Mon Sep 17 00:00:00 2001 From: KennyTV <28825609+KennyTV@users.noreply.github.com> Date: Mon, 20 May 2019 10:30:42 +0200 Subject: [PATCH] Don't cancel normal suffocation --- .../listeners/multiversion/PlayerSneakListener.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/multiversion/PlayerSneakListener.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/multiversion/PlayerSneakListener.java index 30dacd545..e756a116b 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/multiversion/PlayerSneakListener.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/multiversion/PlayerSneakListener.java @@ -102,7 +102,14 @@ public class PlayerSneakListener extends ViaBukkitListener { Player player = (Player) event.getEntity(); if (!sneakingUuids.contains(player.getUniqueId())) return; - event.setCancelled(true); + + // Don't cancel when they should actually be suffocating; Essentially cancel when the head is in the top block only ever so slightly + // ~0.041 should suffice, but gotta stay be safe + double y = player.getEyeLocation().getY() + 0.045; + y -= (int) y; + if (y < 0.09) { + event.setCancelled(true); + } } @EventHandler