2016-12-17 05:13:45 +01:00
|
|
|
From 801f5693fe5379447940a29868132cd8f973ece1 Mon Sep 17 00:00:00 2001
|
2016-03-01 00:09:49 +01:00
|
|
|
From: Zach Brown <zach.brown@destroystokyo.com>
|
|
|
|
Date: Tue, 1 Mar 2016 22:01:19 -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
|
2016-11-17 03:23:38 +01:00
|
|
|
index 28a514a..60452e8 100644
|
2016-03-01 00:09:49 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/TileEntityChest.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityChest.java
|
2016-11-17 03:23:38 +01:00
|
|
|
@@ -8,17 +8,17 @@ import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
2016-03-01 00:09:49 +01:00
|
|
|
import org.bukkit.entity.HumanEntity;
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2016-11-17 03:23:38 +01:00
|
|
|
-public class TileEntityChest extends TileEntityLootable implements ITickable {
|
|
|
|
+public class TileEntityChest extends TileEntityLootable { // Paper - Remove ITickable
|
2016-03-01 00:09:49 +01:00
|
|
|
|
2016-11-17 03:23:38 +01:00
|
|
|
private NonNullList<ItemStack> items;
|
2016-03-01 00:09:49 +01:00
|
|
|
public boolean a;
|
|
|
|
- public TileEntityChest f;
|
|
|
|
- public TileEntityChest g;
|
|
|
|
- public TileEntityChest h;
|
|
|
|
- public TileEntityChest i;
|
|
|
|
- public float j;
|
|
|
|
+ public TileEntityChest f; // Paper - Adjacent Chest Z Neg
|
|
|
|
+ public TileEntityChest g; // Paper - Adjacent Chest X Pos
|
|
|
|
+ public TileEntityChest h; // Paper - Adjacent Chest X Neg
|
|
|
|
+ public TileEntityChest i; // Paper - Adjacent Chest Z Pos
|
|
|
|
+ public float j; // Paper - lid angle
|
|
|
|
public float k;
|
|
|
|
- public int l;
|
|
|
|
+ public int l; // Paper - Number of viewers
|
2016-11-17 03:23:38 +01:00
|
|
|
private int q;
|
|
|
|
private BlockChest.Type r;
|
|
|
|
|
|
|
|
@@ -190,6 +190,8 @@ public class TileEntityChest extends TileEntityLootable implements ITickable {
|
2016-03-01 00:09:49 +01:00
|
|
|
}
|
|
|
|
|
2016-11-17 03:23:38 +01:00
|
|
|
public void F_() {
|
2016-03-01 00:09:49 +01:00
|
|
|
+ // Paper - Disable all of this, just in case this does get ticked
|
|
|
|
+ /*
|
2016-11-17 03:23:38 +01:00
|
|
|
this.o();
|
2016-03-01 00:09:49 +01:00
|
|
|
int i = this.position.getX();
|
|
|
|
int j = this.position.getY();
|
2016-11-17 03:23:38 +01:00
|
|
|
@@ -270,7 +272,8 @@ public class TileEntityChest extends TileEntityLootable implements ITickable {
|
2016-03-01 00:09:49 +01:00
|
|
|
this.j = 0.0F;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-
|
|
|
|
+ */
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean c(int i, int j) {
|
2016-11-17 03:23:38 +01:00
|
|
|
@@ -290,6 +293,28 @@ public class TileEntityChest extends TileEntityLootable implements ITickable {
|
2016-03-01 00:09:49 +01:00
|
|
|
int oldPower = Math.max(0, Math.min(15, this.l)); // CraftBukkit - Get power before new viewer is added
|
|
|
|
|
|
|
|
++this.l;
|
|
|
|
+
|
|
|
|
+ // Paper start - Move chest open sound out of the tick loop
|
2016-11-17 03:23:38 +01:00
|
|
|
+ this.o();
|
2016-03-01 00:09:49 +01:00
|
|
|
+
|
|
|
|
+ if (this.l > 0 && this.j == 0.0F && this.f == null && this.h == null) {
|
|
|
|
+ this.j = 0.7F;
|
|
|
|
+
|
|
|
|
+ double d0 = (double) this.position.getZ() + 0.5D;
|
|
|
|
+ double d1 = (double) this.position.getX() + 0.5D;
|
|
|
|
+
|
|
|
|
+ if (this.i != null) {
|
|
|
|
+ d0 += 0.5D;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (this.g != null) {
|
|
|
|
+ d1 += 0.5D;
|
|
|
|
+ }
|
|
|
|
+
|
2016-11-17 03:23:38 +01:00
|
|
|
+ this.world.a((EntityHuman) null, d1, (double) this.position.getY() + 0.5D, d0, SoundEffects.Z, SoundCategory.BLOCKS, 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
|
2016-03-01 00:09:49 +01:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
if (this.world == null) return; // CraftBukkit
|
|
|
|
this.world.playBlockAction(this.position, this.getBlock(), 1, this.l);
|
|
|
|
|
2016-11-17 03:23:38 +01:00
|
|
|
@@ -314,6 +339,34 @@ public class TileEntityChest extends TileEntityLootable implements ITickable {
|
|
|
|
if (!entityhuman.isSpectator() && this.getBlock() instanceof BlockChest) {
|
2016-03-01 00:09:49 +01:00
|
|
|
int oldPower = Math.max(0, Math.min(15, this.l)); // CraftBukkit - Get power before new viewer is added
|
|
|
|
--this.l;
|
|
|
|
+
|
|
|
|
+ // Paper start - Move chest close sound out of the tick loop
|
|
|
|
+ if (this.l == 0 && this.j > 0.0F || this.l > 0 && this.j < 1.0F) {
|
|
|
|
+ float f = 0.1F;
|
|
|
|
+
|
|
|
|
+ if (this.l > 0) {
|
|
|
|
+ this.j += f;
|
|
|
|
+ } else {
|
|
|
|
+ this.j -= f;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ double d0 = (double) this.getPosition().getX() + 0.5D;
|
|
|
|
+ double d2 = (double) this.getPosition().getZ() + 0.5D;
|
2016-03-05 00:38:51 +01:00
|
|
|
+ int yLoc = this.position.getY();
|
2016-03-01 00:09:49 +01:00
|
|
|
+
|
|
|
|
+ if (this.i != null) {
|
|
|
|
+ d2 += 0.5D;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (this.g != null) {
|
|
|
|
+ d0 += 0.5D;
|
|
|
|
+ }
|
|
|
|
+
|
2016-11-17 03:23:38 +01:00
|
|
|
+ this.world.a((EntityHuman) null, d0, (double) yLoc + 0.5D, d2, SoundEffects.X, SoundCategory.BLOCKS, 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
|
2016-03-05 00:38:51 +01:00
|
|
|
+ this.j = 0.0F;
|
2016-03-01 00:09:49 +01:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
this.world.playBlockAction(this.position, this.getBlock(), 1, this.l);
|
2016-11-17 03:23:38 +01:00
|
|
|
this.world.applyPhysics(this.position, this.getBlock(), false);
|
2016-03-01 00:09:49 +01:00
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntityEnderChest.java b/src/main/java/net/minecraft/server/TileEntityEnderChest.java
|
2016-11-17 03:23:38 +01:00
|
|
|
index 3d61c2d..586ceaa 100644
|
2016-03-01 00:09:49 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/TileEntityEnderChest.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityEnderChest.java
|
|
|
|
@@ -1,15 +1,17 @@
|
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
-public class TileEntityEnderChest extends TileEntity implements ITickable {
|
|
|
|
+public class TileEntityEnderChest extends TileEntity { // Paper - Remove ITickable
|
|
|
|
|
|
|
|
- public float a;
|
|
|
|
+ public float a; // Paper - lid angle
|
|
|
|
public float f;
|
|
|
|
- public int g;
|
|
|
|
+ public int g; // Paper - Number of viewers
|
|
|
|
private int h;
|
|
|
|
|
|
|
|
public TileEntityEnderChest() {}
|
|
|
|
|
2016-11-17 03:23:38 +01:00
|
|
|
public void F_() {
|
2016-03-01 00:09:49 +01:00
|
|
|
+ // Paper start - Disable all of this, just in case this does get ticked
|
|
|
|
+ /*
|
|
|
|
if (++this.h % 20 * 4 == 0) {
|
|
|
|
this.world.playBlockAction(this.position, Blocks.ENDER_CHEST, 1, this.g);
|
|
|
|
}
|
|
|
|
@@ -54,6 +56,8 @@ public class TileEntityEnderChest extends TileEntity implements ITickable {
|
|
|
|
this.a = 0.0F;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+ */
|
|
|
|
+ // Paper end
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -73,11 +77,34 @@ public class TileEntityEnderChest extends TileEntity implements ITickable {
|
|
|
|
|
2016-11-17 03:23:38 +01:00
|
|
|
public void a() {
|
2016-03-01 00:09:49 +01:00
|
|
|
++this.g;
|
|
|
|
+
|
|
|
|
+ // Paper start - Move enderchest open sounds out of the tick loop
|
|
|
|
+ if (this.g > 0 && this.a == 0.0F) {
|
|
|
|
+ this.a = 0.7F;
|
|
|
|
+
|
|
|
|
+ double d1 = (double) this.getPosition().getX() + 0.5D;
|
|
|
|
+ double d0 = (double) this.getPosition().getZ() + 0.5D;
|
|
|
|
+
|
2016-11-17 03:23:38 +01:00
|
|
|
+ this.world.a((EntityHuman) null, d1, (double) this.getPosition().getY() + 0.5D, d0, SoundEffects.aQ, SoundCategory.BLOCKS, 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
|
2016-03-01 00:09:49 +01:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
this.world.playBlockAction(this.position, Blocks.ENDER_CHEST, 1, this.g);
|
|
|
|
}
|
|
|
|
|
2016-05-12 04:07:46 +02:00
|
|
|
public void e() {
|
2016-03-01 00:09:49 +01:00
|
|
|
--this.g;
|
|
|
|
+
|
|
|
|
+ // Paper start - Move enderchest close sounds out of the tick loop
|
|
|
|
+ if (this.g == 0 && this.a > 0.0F || this.g > 0 && this.a < 1.0F) {
|
|
|
|
+ double d0 = (double) this.getPosition().getX() + 0.5D;
|
|
|
|
+ double d2 = (double) this.getPosition().getZ() + 0.5D;
|
|
|
|
+
|
2016-11-17 03:23:38 +01:00
|
|
|
+ this.world.a((EntityHuman) null, d0, (double) this.getPosition().getY() + 0.5D, d2, SoundEffects.aP, SoundCategory.BLOCKS, 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
|
2016-03-01 00:09:49 +01:00
|
|
|
+ this.a = 0.0F;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
this.world.playBlockAction(this.position, Blocks.ENDER_CHEST, 1, this.g);
|
|
|
|
}
|
|
|
|
|
|
|
|
--
|
2016-12-17 05:13:45 +01:00
|
|
|
2.9.3
|
2016-03-01 00:09:49 +01:00
|
|
|
|