aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0144-Add-option-to-make-parrots-stay-on-shoulders-despite.patch
blob: 270c71d6d4d429cd2a9d995ba0052b3c99c7c67d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Tue, 16 May 2017 21:29:08 -0500
Subject: [PATCH] Add option to make parrots stay on shoulders despite movement

Makes parrots not fall off whenever the player changes height, or touches water, or gets hit by a passing leaf.
Instead, switches the behavior so that players have to sneak to make the birds leave.

I suspect Mojang may switch to this behavior before full release.

To be converted into a Paper-API event at some point in the future?

diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index c611b5a63498f5ad1f50a75ccd5d7299e27df7e3..9d1cddc6038f0fd0286e4a32013ae98ff0b00dd1 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -330,4 +330,10 @@ public class PaperWorldConfig {
         maxCollisionsPerEntity = getInt( "max-entity-collisions", this.spigotConfig.getInt("max-entity-collisions", 8) );
         log( "Max Entity Collisions: " + maxCollisionsPerEntity );
     }
+
+    public boolean parrotsHangOnBetter;
+    private void parrotsHangOnBetter() {
+        parrotsHangOnBetter = getBoolean("parrots-are-unaffected-by-player-movement", false);
+        log("Parrots are unaffected by player movement: " + parrotsHangOnBetter);
+    }
 }
diff --git a/src/main/java/net/minecraft/server/network/PlayerConnection.java b/src/main/java/net/minecraft/server/network/PlayerConnection.java
index 8a5a1ca08073d1a4df949a53fbf7e75339bf2761..bf3195eaf1fc7bdddafbb54d0ccf825e95b63210 100644
--- a/src/main/java/net/minecraft/server/network/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/network/PlayerConnection.java
@@ -2052,6 +2052,13 @@ public class PlayerConnection implements PacketListenerPlayIn {
         switch (packetplayinentityaction.c()) {
             case PRESS_SHIFT_KEY:
                 this.player.setSneaking(true);
+
+            // Paper start - Hang on!
+            if (this.player.world.paperConfig.parrotsHangOnBetter) {
+                this.player.releaseShoulderEntities();
+            }
+            // Paper end
+
                 break;
             case RELEASE_SHIFT_KEY:
                 this.player.setSneaking(false);
diff --git a/src/main/java/net/minecraft/world/entity/player/EntityHuman.java b/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
index e3e3426a00128b56d523bb43a59b814b915ad0ff..ba26fc2405e17d582da971d03147fb1865e9b546 100644
--- a/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
+++ b/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
@@ -532,7 +532,7 @@ public abstract class EntityHuman extends EntityLiving {
         this.j(this.getShoulderEntityLeft());
         this.j(this.getShoulderEntityRight());
         if (!this.world.isClientSide && (this.fallDistance > 0.5F || this.isInWater()) || this.abilities.isFlying || this.isSleeping()) {
-            this.releaseShoulderEntities();
+            if (!this.world.paperConfig.parrotsHangOnBetter) this.releaseShoulderEntities(); // Paper - Hang on!
         }
 
     }