2019-06-16 13:00:08 +00:00
|
|
|
From 0b8109d70dce130297bf090e7af8090c483bc3e1 Mon Sep 17 00:00:00 2001
|
2018-07-22 23:39:56 +00:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Sun, 8 Mar 2015 22:55:25 -0600
|
2018-07-15 01:53:17 +00:00
|
|
|
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
|
2019-05-27 23:01:45 +00:00
|
|
|
index 271406f8bb..85b450c054 100644
|
2018-07-15 01:53:17 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/TileEntityChest.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityChest.java
|
|
|
|
@@ -7,7 +7,7 @@ import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
|
|
|
import org.bukkit.entity.HumanEntity;
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
-public class TileEntityChest extends TileEntityLootable implements ITickable {
|
|
|
|
+public class TileEntityChest extends TileEntityLootable { // Paper - Remove ITickable
|
|
|
|
|
|
|
|
private NonNullList<ItemStack> items;
|
|
|
|
protected float a;
|
2019-04-24 01:00:24 +00:00
|
|
|
@@ -101,13 +101,19 @@ public class TileEntityChest extends TileEntityLootable implements ITickable {
|
|
|
|
return nbttagcompound;
|
|
|
|
}
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
public void tick() {
|
|
|
|
int i = this.position.getX();
|
|
|
|
int j = this.position.getY();
|
2018-07-15 01:53:17 +00:00
|
|
|
int k = this.position.getZ();
|
|
|
|
|
2019-04-24 01:00:24 +00:00
|
|
|
++this.j;
|
2018-07-15 01:53:17 +00:00
|
|
|
+ }
|
2019-04-24 01:00:24 +00:00
|
|
|
+
|
|
|
|
+ public void doOpenLogic() {
|
2018-07-15 01:53:17 +00:00
|
|
|
+ int i = this.position.getX();
|
|
|
|
+ int j = this.position.getY();
|
|
|
|
+ int k = this.position.getZ();
|
2019-04-24 01:00:24 +00:00
|
|
|
+
|
|
|
|
this.viewingCount = a(this.world, this, this.j, i, j, k, this.viewingCount);
|
|
|
|
this.b = this.a;
|
|
|
|
float f = 0.1F;
|
|
|
|
@@ -115,8 +121,11 @@ public class TileEntityChest extends TileEntityLootable implements ITickable {
|
|
|
|
if (this.viewingCount > 0 && this.a == 0.0F) {
|
2018-07-15 01:53:17 +00:00
|
|
|
this.a(SoundEffects.BLOCK_CHEST_OPEN);
|
|
|
|
}
|
|
|
|
+ }
|
|
|
|
|
2019-04-24 01:00:24 +00:00
|
|
|
- if (this.viewingCount == 0 && this.a > 0.0F || this.viewingCount > 0 && this.a < 1.0F) {
|
|
|
|
+ public void doCloseLogic() {
|
|
|
|
+ if (this.viewingCount == 0 /* && this.a > 0.0F || this.viewingCount > 0 && this.a < 1.0F */) { // Paper - disable all but player count check
|
|
|
|
+ /* // Paper - disable animation stuff
|
2018-07-15 01:53:17 +00:00
|
|
|
float f1 = this.a;
|
2018-07-22 23:39:56 +00:00
|
|
|
|
2019-04-24 01:00:24 +00:00
|
|
|
if (this.viewingCount > 0) {
|
|
|
|
@@ -132,8 +141,11 @@ public class TileEntityChest extends TileEntityLootable implements ITickable {
|
2018-07-22 23:39:56 +00:00
|
|
|
float f2 = 0.5F;
|
|
|
|
|
|
|
|
if (this.a < 0.5F && f1 >= 0.5F) {
|
|
|
|
- this.a(SoundEffects.BLOCK_CHEST_CLOSE);
|
|
|
|
- }
|
2019-04-24 01:00:24 +00:00
|
|
|
+ */
|
|
|
|
+ MCUtil.scheduleTask(10, () -> {
|
|
|
|
+ this.a(SoundEffects.BLOCK_CHEST_CLOSE);
|
2018-07-22 23:39:56 +00:00
|
|
|
+ });
|
2019-04-24 01:00:24 +00:00
|
|
|
+ //} // Paper end
|
2018-07-22 23:39:56 +00:00
|
|
|
|
|
|
|
if (this.a < 0.0F) {
|
|
|
|
this.a = 0.0F;
|
2019-05-27 04:36:37 +00:00
|
|
|
@@ -172,6 +184,7 @@ public class TileEntityChest extends TileEntityLootable implements ITickable {
|
|
|
|
}
|
|
|
|
|
|
|
|
private void a(SoundEffect soundeffect) {
|
|
|
|
+ if (!this.getBlock().hasProperty(BlockChest.b)) { return; } // Paper - this can be delayed, double check exists - Fixes GH-2074
|
|
|
|
BlockPropertyChestType blockpropertychesttype = (BlockPropertyChestType) this.getBlock().get(BlockChest.b);
|
|
|
|
|
|
|
|
if (blockpropertychesttype != BlockPropertyChestType.LEFT) {
|
|
|
|
@@ -210,6 +223,7 @@ public class TileEntityChest extends TileEntityLootable implements ITickable {
|
2018-07-15 01:53:17 +00:00
|
|
|
|
2019-04-24 01:00:24 +00:00
|
|
|
++this.viewingCount;
|
2018-07-15 01:53:17 +00:00
|
|
|
if (this.world == null) return; // CraftBukkit
|
|
|
|
+ doOpenLogic(); // Paper
|
|
|
|
|
|
|
|
// CraftBukkit start - Call redstone event
|
2019-04-24 01:00:24 +00:00
|
|
|
if (this.getBlock().getBlock() == Blocks.TRAPPED_CHEST) {
|
2019-05-27 04:36:37 +00:00
|
|
|
@@ -232,6 +246,7 @@ public class TileEntityChest extends TileEntityLootable implements ITickable {
|
2019-04-24 01:00:24 +00:00
|
|
|
--this.viewingCount;
|
2018-07-15 01:53:17 +00:00
|
|
|
|
|
|
|
// CraftBukkit start - Call redstone event
|
|
|
|
+ doCloseLogic(); // Paper
|
2019-04-24 01:00:24 +00:00
|
|
|
if (this.getBlock().getBlock() == Blocks.TRAPPED_CHEST) {
|
|
|
|
int newPower = Math.max(0, Math.min(15, this.viewingCount));
|
2018-07-15 01:53:17 +00:00
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntityEnderChest.java b/src/main/java/net/minecraft/server/TileEntityEnderChest.java
|
2019-06-16 13:00:08 +00:00
|
|
|
index 340dd1dafe..14598d7ee9 100644
|
2018-07-15 01:53:17 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/TileEntityEnderChest.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityEnderChest.java
|
|
|
|
@@ -1,6 +1,6 @@
|
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
-public class TileEntityEnderChest extends TileEntity implements ITickable {
|
|
|
|
+public class TileEntityEnderChest extends TileEntity { // Paper - Remove ITickable
|
2019-01-01 03:15:55 +00:00
|
|
|
|
2018-07-15 01:53:17 +00:00
|
|
|
public float a;
|
2019-04-24 01:00:24 +00:00
|
|
|
public float b;
|
|
|
|
@@ -11,18 +11,28 @@ public class TileEntityEnderChest extends TileEntity implements ITickable {
|
|
|
|
super(TileEntityTypes.ENDER_CHEST);
|
|
|
|
}
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
public void tick() {
|
|
|
|
if (++this.g % 20 * 4 == 0) {
|
|
|
|
this.world.playBlockAction(this.position, Blocks.ENDER_CHEST, 1, this.c);
|
2018-07-15 01:53:17 +00:00
|
|
|
}
|
|
|
|
|
2019-04-24 01:00:24 +00:00
|
|
|
this.b = this.a;
|
|
|
|
+ /* // Paper
|
2018-07-15 01:53:17 +00:00
|
|
|
int i = this.position.getX();
|
|
|
|
int j = this.position.getY();
|
|
|
|
int k = this.position.getZ();
|
2019-01-01 03:15:55 +00:00
|
|
|
float f = 0.1F;
|
|
|
|
double d0;
|
2018-07-15 01:53:17 +00:00
|
|
|
+ // Paper start
|
2019-04-24 01:00:24 +00:00
|
|
|
+ */
|
2018-07-15 01:53:17 +00:00
|
|
|
+ }
|
2019-04-24 01:00:24 +00:00
|
|
|
+
|
2018-07-15 01:53:17 +00:00
|
|
|
+ private void doOpenLogic() {
|
|
|
|
+ int i = this.position.getX();
|
|
|
|
+ int j = this.position.getY();
|
|
|
|
+ int k = this.position.getZ();
|
2019-04-24 01:00:24 +00:00
|
|
|
+ double d0;
|
2018-07-15 01:53:17 +00:00
|
|
|
+ // Paper end
|
2019-01-01 03:15:55 +00:00
|
|
|
|
2019-04-24 01:00:24 +00:00
|
|
|
if (this.c > 0 && this.a == 0.0F) {
|
|
|
|
double d1 = (double) i + 0.5D;
|
2019-06-16 13:00:08 +00:00
|
|
|
@@ -30,8 +40,17 @@ public class TileEntityEnderChest extends TileEntity implements ITickable {
|
2019-04-24 01:00:24 +00:00
|
|
|
d0 = (double) k + 0.5D;
|
2019-01-01 03:15:55 +00:00
|
|
|
this.world.a((EntityHuman) null, d1, (double) j + 0.5D, d0, SoundEffects.BLOCK_ENDER_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
|
2018-07-15 01:53:17 +00:00
|
|
|
}
|
|
|
|
+ // Paper start
|
|
|
|
+ }
|
2019-04-24 01:00:24 +00:00
|
|
|
|
2019-06-16 13:00:08 +00:00
|
|
|
- if (this.c == 0 && this.a > 0.0F || this.c > 0 && this.a < 1.0F) {
|
2018-07-15 01:53:17 +00:00
|
|
|
+ private void doCloseLogic() {
|
|
|
|
+ int i = this.position.getX();
|
|
|
|
+ int j = this.position.getY();
|
|
|
|
+ int k = this.position.getZ();
|
|
|
|
+ double d0;
|
2019-06-16 13:00:08 +00:00
|
|
|
+
|
|
|
|
+ if (this.c == 0) { /* && this.a > 0.0F || this.c > 0 && this.a < 1.0F) {
|
2018-07-15 01:53:17 +00:00
|
|
|
+ // Paper end
|
2019-01-01 03:15:55 +00:00
|
|
|
float f1 = this.a;
|
|
|
|
|
2019-06-16 13:00:08 +00:00
|
|
|
if (this.c > 0) {
|
|
|
|
@@ -47,11 +66,15 @@ public class TileEntityEnderChest extends TileEntity implements ITickable {
|
|
|
|
float f2 = 0.5F;
|
|
|
|
|
|
|
|
if (this.a < 0.5F && f1 >= 0.5F) {
|
|
|
|
+ // Paper start
|
|
|
|
+ */
|
|
|
|
d0 = (double) i + 0.5D;
|
|
|
|
double d2 = (double) k + 0.5D;
|
|
|
|
|
|
|
|
+ MCUtil.scheduleTask(10, () -> {
|
|
|
|
this.world.a((EntityHuman) null, d0, (double) j + 0.5D, d2, SoundEffects.BLOCK_ENDER_CHEST_CLOSE, SoundCategory.BLOCKS, 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
|
|
|
|
- }
|
|
|
|
+ });
|
|
|
|
+ // Paper end
|
|
|
|
|
|
|
|
if (this.a < 0.0F) {
|
|
|
|
this.a = 0.0F;
|
|
|
|
@@ -79,11 +102,13 @@ public class TileEntityEnderChest extends TileEntity implements ITickable {
|
2019-05-27 23:01:45 +00:00
|
|
|
public void d() {
|
2019-04-24 01:00:24 +00:00
|
|
|
++this.c;
|
|
|
|
this.world.playBlockAction(this.position, Blocks.ENDER_CHEST, 1, this.c);
|
2018-07-15 01:53:17 +00:00
|
|
|
+ doOpenLogic(); // Paper
|
|
|
|
}
|
|
|
|
|
2019-05-27 23:01:45 +00:00
|
|
|
public void f() {
|
2019-04-24 01:00:24 +00:00
|
|
|
--this.c;
|
|
|
|
this.world.playBlockAction(this.position, Blocks.ENDER_CHEST, 1, this.c);
|
2018-07-15 01:53:17 +00:00
|
|
|
+ doCloseLogic(); // Paper
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(EntityHuman entityhuman) {
|
|
|
|
--
|
2019-06-16 13:00:08 +00:00
|
|
|
2.22.0
|
2018-07-15 01:53:17 +00:00
|
|
|
|