2014-08-25 04:19:36 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-07-23 01:39:56 +02:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Sun, 8 Mar 2015 22:55:25 -0600
|
2014-08-25 04:19:36 +02:00
|
|
|
Subject: [PATCH] Optimize TileEntity Ticking
|
|
|
|
|
|
|
|
|
2018-09-01 00:56:57 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockChest.java b/src/main/java/net/minecraft/server/BlockChest.java
|
|
|
|
index 9ffec378a9..5401f7d754 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
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean b(World world, BlockPosition blockposition) {
|
|
|
|
- List list = world.a(EntityOcelot.class, new AxisAlignedBB((double)blockposition.getX(), (double)(blockposition.getY() + 1), (double)blockposition.getZ(), (double)(blockposition.getX() + 1), (double)(blockposition.getY() + 2), (double)(blockposition.getZ() + 1)));
|
|
|
|
+ List<EntityOcelot> list = world.a(EntityOcelot.class, new AxisAlignedBB((double)blockposition.getX(), (double)(blockposition.getY() + 1), (double)blockposition.getZ(), (double)(blockposition.getX() + 1), (double)(blockposition.getY() + 2), (double)(blockposition.getZ() + 1))); // Paper - decompile fix
|
|
|
|
if (!list.isEmpty()) {
|
|
|
|
for(EntityOcelot entityocelot : list) {
|
|
|
|
if (entityocelot.isSitting()) {
|
2015-09-19 16:34:17 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntityChest.java b/src/main/java/net/minecraft/server/TileEntityChest.java
|
2018-09-01 00:56:57 +02:00
|
|
|
index ad601a39d9..9573a4ecdf 100644
|
2015-09-19 16:34:17 +02:00
|
|
|
--- 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;
|
|
|
|
import org.bukkit.entity.HumanEntity;
|
|
|
|
// CraftBukkit end
|
2014-11-28 02:17:45 +01:00
|
|
|
|
2016-11-17 03:23:38 +01:00
|
|
|
-public class TileEntityChest extends TileEntityLootable implements ITickable {
|
|
|
|
+public class TileEntityChest extends TileEntityLootable { // Paper - Remove ITickable
|
2015-09-19 16:34:17 +02:00
|
|
|
|
2016-11-17 03:23:38 +01:00
|
|
|
private NonNullList<ItemStack> items;
|
2018-07-15 03:53:17 +02:00
|
|
|
protected float a;
|
2016-11-17 03:23:38 +01:00
|
|
|
@@ -0,0 +0,0 @@ public class TileEntityChest extends TileEntityLootable implements ITickable {
|
2018-07-15 03:53:17 +02:00
|
|
|
int k = this.position.getZ();
|
2014-08-25 04:19:36 +02:00
|
|
|
|
2018-07-15 03:53:17 +02:00
|
|
|
++this.k;
|
|
|
|
+ // Paper start
|
|
|
|
+ }
|
|
|
|
+ private void doOpenLogic() {
|
|
|
|
float f;
|
|
|
|
-
|
|
|
|
- if (!this.world.isClientSide && this.f != 0 && (this.k + i + j + k) % 200 == 0) {
|
|
|
|
+ int i = this.position.getX();
|
|
|
|
+ int j = this.position.getY();
|
|
|
|
+ int k = this.position.getZ();
|
2018-07-23 01:39:56 +02:00
|
|
|
+ if (false && !this.world.isClientSide && this.f != 0 && (this.k + i + j + k) % 200 == 0) { // Paper - disable block
|
2018-07-15 03:53:17 +02:00
|
|
|
+ // Paper end
|
|
|
|
this.f = 0;
|
|
|
|
f = 5.0F;
|
|
|
|
List list = this.world.a(EntityHuman.class, new AxisAlignedBB((double) ((float) i - 5.0F), (double) ((float) j - 5.0F), (double) ((float) k - 5.0F), (double) ((float) (i + 1) + 5.0F), (double) ((float) (j + 1) + 5.0F), (double) ((float) (k + 1) + 5.0F)));
|
2016-11-17 03:23:38 +01:00
|
|
|
@@ -0,0 +0,0 @@ public class TileEntityChest extends TileEntityLootable implements ITickable {
|
2015-09-19 16:34:17 +02:00
|
|
|
}
|
2014-08-25 04:19:36 +02:00
|
|
|
}
|
2018-07-15 03:53:17 +02:00
|
|
|
|
|
|
|
- this.e = this.a;
|
|
|
|
- f = 0.1F;
|
2018-07-23 01:39:56 +02:00
|
|
|
- if (this.f > 0 && this.a == 0.0F) {
|
|
|
|
+ if (this.f == 1 && this.a == 0.0F) { // check == 1 instead of > 0, first open
|
2018-07-15 03:53:17 +02:00
|
|
|
this.a(SoundEffects.BLOCK_CHEST_OPEN);
|
|
|
|
}
|
|
|
|
+ // Paper start
|
|
|
|
+ }
|
|
|
|
+ private void doCloseLogic() {
|
|
|
|
+ this.e = this.a;
|
2016-03-01 00:09:49 +01:00
|
|
|
+ // Paper end
|
2014-11-28 02:17:45 +01:00
|
|
|
|
2018-07-23 01:39:56 +02:00
|
|
|
- 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
|
2018-07-15 03:53:17 +02:00
|
|
|
float f1 = this.a;
|
2018-07-23 01:39:56 +02:00
|
|
|
|
|
|
|
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;
|
2016-11-17 03:23:38 +01:00
|
|
|
@@ -0,0 +0,0 @@ public class TileEntityChest extends TileEntityLootable implements ITickable {
|
2018-07-15 03:53:17 +02:00
|
|
|
|
|
|
|
++this.f;
|
2016-03-01 00:09:49 +01:00
|
|
|
if (this.world == null) return; // CraftBukkit
|
2018-07-15 03:53:17 +02:00
|
|
|
+ doOpenLogic(); // Paper
|
2015-09-19 16:34:17 +02:00
|
|
|
|
2018-07-15 03:53:17 +02:00
|
|
|
// CraftBukkit start - Call redstone event
|
|
|
|
if (this.getBlock() == Blocks.TRAPPED_CHEST) {
|
2016-11-17 03:23:38 +01:00
|
|
|
@@ -0,0 +0,0 @@ public class TileEntityChest extends TileEntityLootable implements ITickable {
|
2018-07-15 03:53:17 +02:00
|
|
|
--this.f;
|
|
|
|
|
|
|
|
// CraftBukkit start - Call redstone event
|
|
|
|
+ doCloseLogic(); // Paper
|
|
|
|
if (this.getBlock() == Blocks.TRAPPED_CHEST) {
|
|
|
|
int newPower = Math.max(0, Math.min(15, this.f));
|
2015-09-19 16:34:17 +02:00
|
|
|
|
2014-08-25 04:19:36 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntityEnderChest.java b/src/main/java/net/minecraft/server/TileEntityEnderChest.java
|
2018-09-01 00:56:57 +02:00
|
|
|
index 05de26405e..bc851d2a04 100644
|
2014-08-25 04:19:36 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/TileEntityEnderChest.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityEnderChest.java
|
2015-09-19 16:34:17 +02:00
|
|
|
@@ -0,0 +0,0 @@
|
|
|
|
package net.minecraft.server;
|
|
|
|
|
2016-03-01 00:09:49 +01:00
|
|
|
-public class TileEntityEnderChest extends TileEntity implements ITickable {
|
|
|
|
+public class TileEntityEnderChest extends TileEntity { // Paper - Remove ITickable
|
2018-07-15 03:53:17 +02:00
|
|
|
public float a;
|
|
|
|
public float e;
|
2018-09-01 00:56:57 +02:00
|
|
|
public int f;
|
2016-03-01 00:09:49 +01:00
|
|
|
@@ -0,0 +0,0 @@ public class TileEntityEnderChest extends TileEntity implements ITickable {
|
2015-09-19 16:34:17 +02:00
|
|
|
}
|
2018-07-15 03:53:17 +02:00
|
|
|
|
|
|
|
this.e = this.a;
|
|
|
|
+ // Paper start
|
|
|
|
+ /*
|
|
|
|
int i = this.position.getX();
|
|
|
|
int j = this.position.getY();
|
|
|
|
int k = this.position.getZ();
|
2018-09-01 00:56:57 +02:00
|
|
|
float fx = 0.1F;
|
2015-09-19 16:34:17 +02:00
|
|
|
+ */
|
2018-07-15 03:53:17 +02:00
|
|
|
+ // Paper start
|
|
|
|
+ }
|
|
|
|
+ private void doOpenLogic() {
|
|
|
|
+ int i = this.position.getX();
|
|
|
|
+ int j = this.position.getY();
|
|
|
|
+ int k = this.position.getZ();
|
2016-03-01 00:09:49 +01:00
|
|
|
+ // Paper end
|
2018-07-15 03:53:17 +02:00
|
|
|
if (this.f > 0 && this.a == 0.0F) {
|
2018-09-01 00:56:57 +02:00
|
|
|
double d0 = (double)i + 0.5D;
|
|
|
|
double d1 = (double)k + 0.5D;
|
|
|
|
this.world.a((EntityHuman)null, d0, (double)j + 0.5D, d1, SoundEffects.BLOCK_ENDER_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
|
2018-07-15 03:53:17 +02:00
|
|
|
}
|
|
|
|
-
|
|
|
|
+ // Paper start
|
|
|
|
+ }
|
|
|
|
+ private void doCloseLogic() {
|
|
|
|
+ int i = this.position.getX();
|
|
|
|
+ int j = this.position.getY();
|
|
|
|
+ int k = this.position.getZ();
|
|
|
|
+ this.e = this.a;
|
|
|
|
+ double d0;
|
|
|
|
+ // Paper end
|
|
|
|
if (this.f == 0 && this.a > 0.0F || this.f > 0 && this.a < 1.0F) {
|
2018-09-01 00:56:57 +02:00
|
|
|
float f2 = this.a;
|
|
|
|
if (this.f > 0) {
|
2016-03-01 00:09:49 +01:00
|
|
|
@@ -0,0 +0,0 @@ public class TileEntityEnderChest extends TileEntity implements ITickable {
|
2018-07-15 03:53:17 +02:00
|
|
|
public void c() {
|
|
|
|
++this.f;
|
|
|
|
this.world.playBlockAction(this.position, Blocks.ENDER_CHEST, 1, this.f);
|
|
|
|
+ doOpenLogic(); // Paper
|
2015-09-19 16:34:17 +02:00
|
|
|
}
|
|
|
|
|
2018-07-15 03:53:17 +02:00
|
|
|
public void d() {
|
|
|
|
--this.f;
|
|
|
|
this.world.playBlockAction(this.position, Blocks.ENDER_CHEST, 1, this.f);
|
|
|
|
+ doCloseLogic(); // Paper
|
2015-09-19 16:34:17 +02:00
|
|
|
}
|
2014-08-25 04:19:36 +02:00
|
|
|
|
2018-07-15 03:53:17 +02:00
|
|
|
public boolean a(EntityHuman entityhuman) {
|
2015-09-13 02:57:39 +02:00
|
|
|
--
|