From c6e0ceabd753ef01b69de6dbfbc0026348713f3b Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Tue, 16 May 2017 21:34:47 -0500
Subject: [PATCH] Add an option to make parrots stick to shoulders

When enabled, Parrots will not fly off of a player's shoulder everytime
they change Y level, touch water, sneeze, etc.
Instead, a player must toggle shift to "shake" the parrots off.
---
 ...ke-parrots-stay-on-shoulders-despite.patch | 61 +++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 Spigot-Server-Patches/0213-Add-option-to-make-parrots-stay-on-shoulders-despite.patch

diff --git a/Spigot-Server-Patches/0213-Add-option-to-make-parrots-stay-on-shoulders-despite.patch b/Spigot-Server-Patches/0213-Add-option-to-make-parrots-stay-on-shoulders-despite.patch
new file mode 100644
index 0000000000..ae53277e28
--- /dev/null
+++ b/Spigot-Server-Patches/0213-Add-option-to-make-parrots-stay-on-shoulders-despite.patch
@@ -0,0 +1,61 @@
+From 20de43ace6818d683b68d70a87343a9760b7a720 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 af953dda4..1ce3aaa8c 100644
+--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
++++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+@@ -416,4 +416,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/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
+index 29c2fd4c9..02f3c001b 100644
+--- a/src/main/java/net/minecraft/server/EntityHuman.java
++++ b/src/main/java/net/minecraft/server/EntityHuman.java
+@@ -400,7 +400,7 @@ public abstract class EntityHuman extends EntityLiving {
+         this.j(this.getShoulderEntityLeft());
+         this.j(this.getShoulderEntityRight());
+         if (!this.world.isClientSide && (!this.onGround || this.isInWater())) {
+-            this.releaseShoulderEntities();
++            if (!this.world.paperConfig.parrotsHangOnBetter) this.releaseShoulderEntities(); // Paper - Hang on!
+         }
+ 
+     }
+diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
+index 0b6fd67e7..7a4673278 100644
+--- a/src/main/java/net/minecraft/server/PlayerConnection.java
++++ b/src/main/java/net/minecraft/server/PlayerConnection.java
+@@ -1482,6 +1482,13 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
+         switch (packetplayinentityaction.b()) {
+         case START_SNEAKING:
+             this.player.setSneaking(true);
++
++            // Paper start - Hang on!
++            if (this.player.world.paperConfig.parrotsHangOnBetter) {
++                this.player.releaseShoulderEntities();
++            }
++            // Paper end
++
+             break;
+ 
+         case STOP_SNEAKING:
+-- 
+2.13.0.windows.1
+