From 93634e1897c362888397500c59abbf989da72572 Mon Sep 17 00:00:00 2001
From: Max Lee <max@themoep.de>
Date: Mon, 19 Jul 2021 10:31:03 +0100
Subject: [PATCH] Don't apply cramming damage to players (#5903)

---
 ...n-t-apply-cramming-damage-to-players.patch | 40 +++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 patches/server/Don-t-apply-cramming-damage-to-players.patch

diff --git a/patches/server/Don-t-apply-cramming-damage-to-players.patch b/patches/server/Don-t-apply-cramming-damage-to-players.patch
new file mode 100644
index 0000000000..154aa68eeb
--- /dev/null
+++ b/patches/server/Don-t-apply-cramming-damage-to-players.patch
@@ -0,0 +1,40 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Phoenix616 <max@themoep.de>
+Date: Sun, 20 Jun 2021 16:35:42 +0100
+Subject: [PATCH] Don't apply cramming damage to players
+
+It does not make a lot of sense to damage players if they get crammed,
+ especially as the usecase of teleporting lots of players to the same
+ location isn't too uncommon and killing all those players isn't
+ really what one would expect to happen.
+
+For those who really want it a config option is provided.
+
+diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
+--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
++++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+@@ -0,0 +0,0 @@ public class PaperWorldConfig {
+     private void showSignClickCommandFailureMessagesToPlayer() {
+         showSignClickCommandFailureMessagesToPlayer = getBoolean("show-sign-click-command-failure-msgs-to-player", showSignClickCommandFailureMessagesToPlayer);
+     }
++
++    public boolean allowPlayerCrammingDamage = false;
++    private void playerCrammingDamage() {
++        allowPlayerCrammingDamage = getBoolean("allow-player-cramming-damage", allowPlayerCrammingDamage);
++    }
+ }
+ 
+diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
+index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
+--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
++++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
+@@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
+ 
+     @Override
+     public boolean isInvulnerableTo(DamageSource damageSource) {
+-        return super.isInvulnerableTo(damageSource) || this.isChangingDimension() || this.getAbilities().invulnerable && damageSource == DamageSource.WITHER;
++        return super.isInvulnerableTo(damageSource) || this.isChangingDimension() || this.getAbilities().invulnerable && damageSource == DamageSource.WITHER || !level.paperConfig.allowPlayerCrammingDamage && damageSource == DamageSource.CRAMMING; // Paper - disable player cramming
+     }
+ 
+     @Override