Fix Chest open/close animations

This commit is contained in:
Aikar 2018-07-22 19:39:56 -04:00
parent 9108f443a8
commit 84b819bcb8
5 changed files with 62 additions and 13 deletions

View file

@ -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 @@

View file

@ -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

View file

@ -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();

View file

@ -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 @@

View file

@ -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 {