From 84b819bcb8efa8e6224291794494734a98cdb41f Mon Sep 17 00:00:00 2001 From: Aikar <aikar@aikar.co> Date: Sun, 22 Jul 2018 19:39:56 -0400 Subject: [PATCH] Fix Chest open/close animations --- .../Basic-PlayerProfile-API.patch | 2 +- ...rable-Disabling-Cat-Chest-Detection.patch} | 5 +-- Spigot-Server-Patches/MC-Utils.patch | 28 ++++++++++++++- .../Optimize-TileEntity-Ticking.patch | 36 +++++++++++++++---- .../String-based-Action-Bar-API.patch | 4 +-- 5 files changed, 62 insertions(+), 13 deletions(-) rename Spigot-Server-Patches/{Disable-chest-cat-detection.patch => Configurable-Disabling-Cat-Chest-Detection.patch} (91%) diff --git a/Spigot-Server-Patches/Basic-PlayerProfile-API.patch b/Spigot-Server-Patches/Basic-PlayerProfile-API.patch index f20d000ea5..c7ede96610 100644 --- a/Spigot-Server-Patches/Basic-PlayerProfile-API.patch +++ b/Spigot-Server-Patches/Basic-PlayerProfile-API.patch @@ -404,7 +404,7 @@ index 000000000..3aceb0ea8 + } +} diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java -index 70db1cc14..9ab3844fc 100644 +index 381542e0d..80927de08 100644 --- a/src/main/java/net/minecraft/server/MCUtil.java +++ b/src/main/java/net/minecraft/server/MCUtil.java @@ -0,0 +0,0 @@ diff --git a/Spigot-Server-Patches/Disable-chest-cat-detection.patch b/Spigot-Server-Patches/Configurable-Disabling-Cat-Chest-Detection.patch similarity index 91% rename from Spigot-Server-Patches/Disable-chest-cat-detection.patch rename to Spigot-Server-Patches/Configurable-Disabling-Cat-Chest-Detection.patch index 8e10ef6f50..9eb9aeadfe 100644 --- a/Spigot-Server-Patches/Disable-chest-cat-detection.patch +++ b/Spigot-Server-Patches/Configurable-Disabling-Cat-Chest-Detection.patch @@ -1,8 +1,9 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Aikar <aikar@aikar.co> Date: Thu, 3 Mar 2016 01:13:45 -0600 -Subject: [PATCH] Disable chest cat detection +Subject: [PATCH] Configurable Disabling Cat Chest Detection +Offers a gameplay feature to stop cats from blocking chests diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java index 26d8dbb60..43aa73e1d 100644 @@ -19,7 +20,7 @@ index 26d8dbb60..43aa73e1d 100644 + } } diff --git a/src/main/java/net/minecraft/server/BlockChest.java b/src/main/java/net/minecraft/server/BlockChest.java -index d55122c66..f8be07258 100644 +index 0f6902747..1ad39aca3 100644 --- a/src/main/java/net/minecraft/server/BlockChest.java +++ b/src/main/java/net/minecraft/server/BlockChest.java @@ -0,0 +0,0 @@ public class BlockChest extends BlockTileEntity implements IFluidSource, IFluidC diff --git a/Spigot-Server-Patches/MC-Utils.patch b/Spigot-Server-Patches/MC-Utils.patch index a888d020c0..dc55a3ffb9 100644 --- a/Spigot-Server-Patches/MC-Utils.patch +++ b/Spigot-Server-Patches/MC-Utils.patch @@ -180,7 +180,7 @@ index a540167d6..add618866 100644 } diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java new file mode 100644 -index 000000000..edaa7713d +index 000000000..70cdc3f10 --- /dev/null +++ b/src/main/java/net/minecraft/server/MCUtil.java @@ -0,0 +0,0 @@ @@ -212,6 +212,32 @@ index 000000000..edaa7713d + return MinecraftServer.getServer().isMainThread(); + } + ++ private static class DelayedRunnable implements Runnable { ++ ++ private final int ticks; ++ private final Runnable run; ++ ++ private DelayedRunnable(int ticks, Runnable run) { ++ this.ticks = ticks; ++ this.run = run; ++ } ++ ++ @Override ++ public void run() { ++ if (ticks <= 0) { ++ run.run(); ++ } else { ++ scheduleTask(ticks-1, run); ++ } ++ } ++ } ++ ++ public static void scheduleTask(int ticks, Runnable runnable) { ++ // We use post to main instead of process queue as we don't want to process these mid tick if ++ // Someone uses processQueueWhileWaiting ++ MinecraftServer.getServer().postToMainThread(new DelayedRunnable(ticks, runnable)); ++ } ++ + public static void processQueue() { + Runnable runnable; + Queue<Runnable> processQueue = getProcessQueue(); diff --git a/Spigot-Server-Patches/Optimize-TileEntity-Ticking.patch b/Spigot-Server-Patches/Optimize-TileEntity-Ticking.patch index 898662f3e5..c7b16e41e4 100644 --- a/Spigot-Server-Patches/Optimize-TileEntity-Ticking.patch +++ b/Spigot-Server-Patches/Optimize-TileEntity-Ticking.patch @@ -1,11 +1,11 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Zach Brown <1254957+zachbr@users.noreply.github.com> -Date: Tue, 1 Mar 2016 22:01:19 -0600 +From: Aikar <aikar@aikar.co> +Date: Sun, 8 Mar 2015 22:55:25 -0600 Subject: [PATCH] Optimize TileEntity Ticking diff --git a/src/main/java/net/minecraft/server/TileEntityChest.java b/src/main/java/net/minecraft/server/TileEntityChest.java -index de06bd59a..9b54cbfdc 100644 +index a534c441a..591524f1e 100644 --- a/src/main/java/net/minecraft/server/TileEntityChest.java +++ b/src/main/java/net/minecraft/server/TileEntityChest.java @@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.entity.CraftHumanEntity; @@ -30,7 +30,7 @@ index de06bd59a..9b54cbfdc 100644 + int i = this.position.getX(); + int j = this.position.getY(); + int k = this.position.getZ(); -+ if (!this.world.isClientSide && this.f != 0 /*&& (this.k + i + j + k) % 200 == 0*/) { // Paper - comment out tick rate limiter ++ if (false && !this.world.isClientSide && this.f != 0 && (this.k + i + j + k) % 200 == 0) { // Paper - disable block + // Paper end this.f = 0; f = 5.0F; @@ -41,7 +41,8 @@ index de06bd59a..9b54cbfdc 100644 - this.e = this.a; - f = 0.1F; - if (this.f > 0 && this.a == 0.0F) { +- if (this.f > 0 && this.a == 0.0F) { ++ if (this.f == 1 && this.a == 0.0F) { // check == 1 instead of > 0, first open this.a(SoundEffects.BLOCK_CHEST_OPEN); } + // Paper start @@ -50,8 +51,29 @@ index de06bd59a..9b54cbfdc 100644 + this.e = this.a; + // Paper end - if (this.f == 0 && this.a > 0.0F || this.f > 0 && this.a < 1.0F) { +- if (this.f == 0 && this.a > 0.0F || this.f > 0 && this.a < 1.0F) { ++ if (this.f == 0/* && this.a > 0.0F || this.f > 0 && this.a < 1.0F*/) { // Paper disable all but player count check ++ /* // Paper disable animation stuff float f1 = this.a; + + if (this.f > 0) { +@@ -0,0 +0,0 @@ public class TileEntityChest extends TileEntityLootable implements ITickable { + + float f2 = 0.5F; + ++ + if (this.a < 0.5F && f1 >= 0.5F) { +- this.a(SoundEffects.BLOCK_CHEST_CLOSE); +- } ++ */ ++ // add some delay ++ MCUtil.scheduleTask(10, () -> { ++ if (this.f == 0) this.a(SoundEffects.BLOCK_CHEST_CLOSE); ++ }); ++ // } // Paper end + + if (this.a < 0.0F) { + this.a = 0.0F; @@ -0,0 +0,0 @@ public class TileEntityChest extends TileEntityLootable implements ITickable { ++this.f; @@ -69,7 +91,7 @@ index de06bd59a..9b54cbfdc 100644 int newPower = Math.max(0, Math.min(15, this.f)); diff --git a/src/main/java/net/minecraft/server/TileEntityEnderChest.java b/src/main/java/net/minecraft/server/TileEntityEnderChest.java -index f275fd1c3..7d7628b04 100644 +index 61edd7cc6..9407a8c97 100644 --- a/src/main/java/net/minecraft/server/TileEntityEnderChest.java +++ b/src/main/java/net/minecraft/server/TileEntityEnderChest.java @@ -0,0 +0,0 @@ diff --git a/Spigot-Server-Patches/String-based-Action-Bar-API.patch b/Spigot-Server-Patches/String-based-Action-Bar-API.patch index 0fef359074..7f6340f2fb 100644 --- a/Spigot-Server-Patches/String-based-Action-Bar-API.patch +++ b/Spigot-Server-Patches/String-based-Action-Bar-API.patch @@ -5,7 +5,7 @@ Subject: [PATCH] String based Action Bar API diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java -index edaa7713d..70db1cc14 100644 +index 70cdc3f10..381542e0d 100644 --- a/src/main/java/net/minecraft/server/MCUtil.java +++ b/src/main/java/net/minecraft/server/MCUtil.java @@ -0,0 +0,0 @@ @@ -62,7 +62,7 @@ index edaa7713d..70db1cc14 100644 + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 7d4355439..1c8c364d3 100644 +index dea59d3fa..a546f3118 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {