Paper/Spigot-Server-Patches/0206-Add-option-to-make-parrots-stay-on-shoulders-despite.patch
Aikar 094bb03a37
Optimize Hoppers
- Lots of itemstack cloning removed. Only clone if the item is actually moved
- Return true when a plugin cancels inventory move item event instead of false, as false causes pulls to cycle through all items.
  However, pushes do not exhibit the same behavior, so this is not something plugins could of been relying on.
- Add option (Default on) to cooldown hoppers when they fail to move an item due to full inventory
- Skip subsequent InventoryMoveItemEvents if a plugin does not use the item after first event fire for an iteration
2018-02-12 23:26:02 -05:00

62 lines
2.9 KiB
Diff

From 11ca5b04707c3fdbb26a30fdd80c74db844da97d 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 3ba465305..79b12a6e9 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -414,4 +414,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 0f1d99636..9cda8a177 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -399,7 +399,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.isPassenger()) || this.abilities.isFlying) {
- 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 2367ff1f0..9c8828ebd 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -1514,6 +1514,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.16.1