2015-10-08 02:32:01 +00:00
|
|
|
From 6ec7f2863ddf38e1c9bb2cb7df05f280e90fb860 Mon Sep 17 00:00:00 2001
|
2014-08-25 02:19:36 +00:00
|
|
|
From: Aikar <aikar@aikar.co>
|
2015-10-03 03:58:02 +00:00
|
|
|
Date: Sun, 8 Mar 2015 22:55:25 -0600
|
2014-08-25 02:19:36 +00:00
|
|
|
Subject: [PATCH] Optimize TileEntity Ticking
|
|
|
|
|
|
|
|
|
2015-09-19 14:34:17 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntityChest.java b/src/main/java/net/minecraft/server/TileEntityChest.java
|
|
|
|
index 5eb55e5..5192d95 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/TileEntityChest.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityChest.java
|
|
|
|
@@ -8,17 +8,17 @@ import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
|
|
|
import org.bukkit.entity.HumanEntity;
|
|
|
|
// CraftBukkit end
|
2014-11-28 01:17:45 +00:00
|
|
|
|
2015-09-19 14:34:17 +00:00
|
|
|
-public class TileEntityChest extends TileEntityContainer implements IUpdatePlayerListBox, IInventory {
|
|
|
|
+public class TileEntityChest extends TileEntityContainer implements IInventory { // PaperSpigot - remove IUpdatePlayerListBox
|
|
|
|
|
|
|
|
private ItemStack[] items = new ItemStack[27];
|
|
|
|
public boolean a;
|
|
|
|
- public TileEntityChest f;
|
|
|
|
- public TileEntityChest g;
|
|
|
|
- public TileEntityChest h;
|
|
|
|
- public TileEntityChest i;
|
|
|
|
- public float j;
|
|
|
|
+ public TileEntityChest f; // PaperSpigot - adjacentChestZNeg
|
|
|
|
+ public TileEntityChest g; // PaperSpigot - adjacentChestXPos
|
|
|
|
+ public TileEntityChest h; // PaperSpigot - adjacentChestXNeg
|
|
|
|
+ public TileEntityChest i; // PaperSpigot - adjacentChestZPos
|
|
|
|
+ public float j; // PaperSpigot - lidAngle
|
|
|
|
public float k;
|
|
|
|
- public int l;
|
|
|
|
+ public int l; // PaperSpigot - numPlayersUsing
|
|
|
|
private int n;
|
|
|
|
private int o = -1;
|
|
|
|
private String p;
|
|
|
|
@@ -238,6 +238,8 @@ public class TileEntityChest extends TileEntityContainer implements IUpdatePlaye
|
|
|
|
}
|
2014-08-25 02:19:36 +00:00
|
|
|
|
2014-11-28 01:17:45 +00:00
|
|
|
public void c() {
|
2015-09-19 14:34:17 +00:00
|
|
|
+ // PaperSpigot - Move chest sounds out of the tick loop
|
|
|
|
+ /*
|
|
|
|
this.m();
|
|
|
|
int i = this.position.getX();
|
|
|
|
int j = this.position.getY();
|
|
|
|
@@ -318,7 +320,8 @@ public class TileEntityChest extends TileEntityContainer implements IUpdatePlaye
|
|
|
|
this.j = 0.0F;
|
|
|
|
}
|
2014-08-25 02:19:36 +00:00
|
|
|
}
|
2015-09-19 14:34:17 +00:00
|
|
|
-
|
|
|
|
+ */
|
|
|
|
+ // PaperSpigot end
|
|
|
|
}
|
2014-11-28 01:17:45 +00:00
|
|
|
|
2015-09-19 14:34:17 +00:00
|
|
|
public boolean c(int i, int j) {
|
|
|
|
@@ -339,6 +342,28 @@ public class TileEntityChest extends TileEntityContainer implements IUpdatePlaye
|
|
|
|
|
|
|
|
++this.l;
|
|
|
|
if (this.world == null) return; // CraftBukkit
|
|
|
|
+
|
|
|
|
+ // PaperSpigot start - Move chest open sound out of the tick loop
|
|
|
|
+ this.m();
|
|
|
|
+
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.world.makeSound(d1, (double) this.position.getY() + 0.5D, d0, "random.chestopen", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
|
|
|
|
+ }
|
|
|
|
+ // PaperSpigot end
|
|
|
|
+
|
|
|
|
this.world.playBlockAction(this.position, this.w(), 1, this.l);
|
2014-08-25 02:19:36 +00:00
|
|
|
|
2015-09-19 14:34:17 +00:00
|
|
|
// CraftBukkit start - Call redstone event
|
|
|
|
@@ -361,6 +386,33 @@ public class TileEntityChest extends TileEntityContainer implements IUpdatePlaye
|
|
|
|
int oldPower = Math.max(0, Math.min(15, this.l)); // CraftBukkit - Get power before new viewer is added
|
|
|
|
--this.l;
|
|
|
|
if (this.world == null) return; // CraftBukkit
|
|
|
|
+
|
|
|
|
+ // PaperSpigot start - Move chest close sound handling 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;
|
|
|
|
+
|
|
|
|
+ if (this.i != null) {
|
|
|
|
+ d2 += 0.5D;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (this.g != null) {
|
|
|
|
+ d0 += 0.5D;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.world.makeSound(d0, (double) this.getPosition().getY() + 0.5D, d2, "random.chestclosed", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
|
|
|
|
+ this.j = 0.0F;
|
|
|
|
+ }
|
|
|
|
+ // PaperSpigot end
|
|
|
|
+
|
|
|
|
this.world.playBlockAction(this.position, this.w(), 1, this.l);
|
|
|
|
|
|
|
|
// CraftBukkit start - Call redstone event
|
2014-08-25 02:19:36 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntityEnderChest.java b/src/main/java/net/minecraft/server/TileEntityEnderChest.java
|
2015-09-19 14:34:17 +00:00
|
|
|
index 794cdc8..00fceda 100644
|
2014-08-25 02:19:36 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/TileEntityEnderChest.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityEnderChest.java
|
2015-09-19 14:34:17 +00:00
|
|
|
@@ -1,15 +1,17 @@
|
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
-public class TileEntityEnderChest extends TileEntity implements IUpdatePlayerListBox {
|
|
|
|
+public class TileEntityEnderChest extends TileEntity { // PaperSpigot - remove IUpdatePlayerListBox
|
|
|
|
|
|
|
|
- public float a;
|
|
|
|
+ public float a; // PaperSpigot - lidAngle
|
|
|
|
public float f;
|
|
|
|
- public int g;
|
|
|
|
+ public int g; // PaperSpigot - numPlayersUsing
|
|
|
|
private int h;
|
|
|
|
|
2014-11-28 01:17:45 +00:00
|
|
|
public TileEntityEnderChest() {}
|
2014-08-25 02:19:36 +00:00
|
|
|
|
2014-11-28 01:17:45 +00:00
|
|
|
public void c() {
|
2015-09-19 14:34:17 +00:00
|
|
|
+ // PaperSpigot start - Move enderchest sound handling out of the tick loop
|
|
|
|
+ /*
|
|
|
|
if (++this.h % 20 * 4 == 0) {
|
2014-11-28 01:17:45 +00:00
|
|
|
this.world.playBlockAction(this.position, Blocks.ENDER_CHEST, 1, this.g);
|
2014-08-25 02:19:36 +00:00
|
|
|
}
|
2015-09-19 14:34:17 +00:00
|
|
|
@@ -54,7 +56,8 @@ public class TileEntityEnderChest extends TileEntity implements IUpdatePlayerLis
|
|
|
|
this.a = 0.0F;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-
|
|
|
|
+ */
|
|
|
|
+ // PaperSpigot end
|
|
|
|
}
|
2014-08-25 02:19:36 +00:00
|
|
|
|
2015-09-19 14:34:17 +00:00
|
|
|
public boolean c(int i, int j) {
|
|
|
|
@@ -73,11 +76,34 @@ public class TileEntityEnderChest extends TileEntity implements IUpdatePlayerLis
|
|
|
|
|
|
|
|
public void b() {
|
|
|
|
++this.g;
|
|
|
|
+
|
|
|
|
+ // PaperSpigot 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;
|
|
|
|
+
|
|
|
|
+ this.world.makeSound(d1, (double) this.getPosition().getY() + 0.5D, d0, "random.chestopen", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
|
|
|
|
+ }
|
|
|
|
+ // PaperSpigot end
|
|
|
|
+
|
|
|
|
this.world.playBlockAction(this.position, Blocks.ENDER_CHEST, 1, this.g);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void d() {
|
|
|
|
--this.g;
|
|
|
|
+
|
|
|
|
+ // PaperSpigot 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;
|
|
|
|
+
|
|
|
|
+ this.world.makeSound(d0, (double) this.getPosition().getY() + 0.5D, d2, "random.chestclosed", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
|
|
|
|
+ this.a = 0.0F;
|
|
|
|
+ }
|
|
|
|
+ // PaperSpigot end
|
|
|
|
+
|
|
|
|
this.world.playBlockAction(this.position, Blocks.ENDER_CHEST, 1, this.g);
|
|
|
|
}
|
2014-08-25 02:19:36 +00:00
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2015-10-08 02:32:01 +00:00
|
|
|
index acfceb8..1729071 100644
|
2014-08-25 02:19:36 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2015-09-19 14:34:17 +00:00
|
|
|
@@ -28,6 +28,18 @@ public abstract class World implements IBlockAccess {
|
2015-09-13 04:29:23 +00:00
|
|
|
// Spigot start - guard entity list from removals
|
|
|
|
public final List<Entity> entityList = new java.util.ArrayList<Entity>()
|
|
|
|
{
|
|
|
|
+ // PaperSpigot start - move always activated entities to top of tick list
|
|
|
|
+ @Override
|
2015-09-19 14:34:17 +00:00
|
|
|
+ public boolean add(Entity e) {
|
2015-09-13 04:29:23 +00:00
|
|
|
+ if (e.defaultActivationState) {
|
|
|
|
+ super.add(0, e);
|
|
|
|
+ return true;
|
|
|
|
+ } else {
|
|
|
|
+ return super.add(e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // PaperSpigot end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public Entity remove(int index)
|
|
|
|
{
|
2015-10-07 04:27:01 +00:00
|
|
|
@@ -52,7 +64,7 @@ public abstract class World implements IBlockAccess {
|
|
|
|
};
|
|
|
|
// Spigot end
|
|
|
|
protected final List<Entity> g = Lists.newArrayList();
|
|
|
|
- public final List<TileEntity> h = Lists.newArrayList();
|
|
|
|
+ //public final List<TileEntity> h = Lists.newArrayList(); // PaperSpigot - Remove unused list
|
|
|
|
public final List<TileEntity> tileEntityList = Lists.newArrayList();
|
|
|
|
private final List<TileEntity> b = Lists.newArrayList();
|
|
|
|
private final List<TileEntity> c = Lists.newArrayList();
|
2015-09-19 14:34:17 +00:00
|
|
|
@@ -1394,10 +1406,22 @@ public abstract class World implements IBlockAccess {
|
2015-09-13 04:29:23 +00:00
|
|
|
guardEntityList = true; // Spigot
|
|
|
|
// CraftBukkit start - Use field for loop variable
|
|
|
|
int entitiesThisCycle = 0;
|
|
|
|
+
|
|
|
|
+ // PaperSpigot start - Compute minimum tick index
|
|
|
|
+ int minTickIndex = -1;
|
|
|
|
+ ListIterator<Entity> e = entityList.listIterator();
|
|
|
|
+ while (e.hasNext()) {
|
|
|
|
+ if (!e.next().defaultActivationState) {
|
|
|
|
+ minTickIndex = e.previousIndex();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // PaperSpigot end
|
|
|
|
+
|
|
|
|
if (tickPosition < 0) tickPosition = 0;
|
|
|
|
for (entityLimiter.initTick();
|
2015-10-08 02:32:01 +00:00
|
|
|
- entitiesThisCycle < entityList.size() && (entitiesThisCycle % 10 != 0 || entityLimiter.shouldContinue());
|
2015-09-19 14:34:17 +00:00
|
|
|
- tickPosition++, entitiesThisCycle++) {
|
2015-10-08 02:32:01 +00:00
|
|
|
+ entitiesThisCycle < entityList.size() && (tickPosition <= minTickIndex || entitiesThisCycle % 10 != 0 || entityLimiter.shouldContinue()); // PaperSpigot
|
2015-09-19 14:34:17 +00:00
|
|
|
+ tickPosition++, entitiesThisCycle++) {
|
2015-09-13 04:29:23 +00:00
|
|
|
tickPosition = (tickPosition < entityList.size()) ? tickPosition : 0;
|
|
|
|
entity = (Entity) this.entityList.get(this.tickPosition);
|
2015-09-19 14:34:17 +00:00
|
|
|
// CraftBukkit end
|
2015-10-07 04:27:01 +00:00
|
|
|
@@ -1450,7 +1474,7 @@ public abstract class World implements IBlockAccess {
|
|
|
|
// CraftBukkit start - From below, clean up tile entities before ticking them
|
|
|
|
if (!this.c.isEmpty()) {
|
|
|
|
this.tileEntityList.removeAll(this.c);
|
|
|
|
- this.h.removeAll(this.c);
|
|
|
|
+ //this.h.removeAll(this.c); // PaperSpigot - Remove unused list
|
|
|
|
this.c.clear();
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
@@ -1496,7 +1520,7 @@ public abstract class World implements IBlockAccess {
|
|
|
|
if (tileentity.x()) {
|
|
|
|
tilesThisCycle--;
|
|
|
|
this.tileEntityList.remove(tileTickPosition--);
|
|
|
|
- this.h.remove(tileentity);
|
|
|
|
+ //this.h.remove(tileentity); // PaperSpigot - Remove unused list
|
|
|
|
if (this.isLoaded(tileentity.getPosition())) {
|
|
|
|
this.getChunkAtWorldCoords(tileentity.getPosition()).e(tileentity.getPosition());
|
|
|
|
}
|
|
|
|
@@ -1543,7 +1567,7 @@ public abstract class World implements IBlockAccess {
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(TileEntity tileentity) {
|
|
|
|
- boolean flag = this.h.add(tileentity);
|
|
|
|
+ boolean flag = true; // PaperSpigot - Remove unused list
|
|
|
|
|
|
|
|
if (flag && tileentity instanceof IUpdatePlayerListBox) {
|
|
|
|
this.tileEntityList.add(tileentity);
|
|
|
|
@@ -1561,7 +1585,7 @@ public abstract class World implements IBlockAccess {
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
TileEntity tileentity = (TileEntity) iterator.next();
|
|
|
|
|
|
|
|
- this.h.add(tileentity);
|
|
|
|
+ //this.h.add(tileentity); // PaperSpigot - Remove unused list
|
|
|
|
if (tileentity instanceof IUpdatePlayerListBox) {
|
|
|
|
this.tileEntityList.add(tileentity);
|
|
|
|
}
|
|
|
|
@@ -1997,7 +2021,7 @@ public abstract class World implements IBlockAccess {
|
|
|
|
} else {
|
|
|
|
if (tileentity != null) {
|
|
|
|
this.b.remove(tileentity);
|
|
|
|
- this.h.remove(tileentity);
|
|
|
|
+ //this.h.remove(tileentity); // PaperSpigot - Remove unused list
|
|
|
|
this.tileEntityList.remove(tileentity);
|
|
|
|
}
|
|
|
|
|
2014-08-25 02:19:36 +00:00
|
|
|
--
|
2015-10-07 04:27:01 +00:00
|
|
|
2.6.1.windows.1
|
2014-08-25 02:19:36 +00:00
|
|
|
|