Paper/Spigot-Server-Patches/0143-Add-option-to-make-parrots-stay-on-shoulders-despite.patch
2021-01-03 17:23:10 +01:00

59 lines
3.1 KiB
Diff

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 c9d026c899d008419ec2bb7fab151bad80fcea8b..ca05b130de6b46764bc11e72a6f100bb96758ce1 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -328,4 +328,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 10c388acaad0cfd6bfffd955a83b29065d591719..f17bd192dc26878ec0979b6812477a96a7f02607 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -436,7 +436,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!
}
}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index bb99e1ed16deba5b39323c5a65bf68986ff816fe..e83f1bfe2b2c33b3bc6788de6998356430857855 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -1903,6 +1903,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);