summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTravis Watkins <amaranth@ubuntu.com>2013-04-11 18:11:10 -0500
committerWesley Wolfe <weswolf@aol.com>2013-04-13 00:30:43 -0500
commita2d9f33ca38660bb6bd698f598e8a6cfddc4e702 (patch)
treeb4a01d520b89a472663eeb0d260b69d0eb9364d6
parent159d614a3a7a56818b561f79ec2c0b1eb00440a0 (diff)
downloadcraftbukkit-a2d9f33ca38660bb6bd698f598e8a6cfddc4e702.tar
craftbukkit-a2d9f33ca38660bb6bd698f598e8a6cfddc4e702.tar.gz
craftbukkit-a2d9f33ca38660bb6bd698f598e8a6cfddc4e702.tar.lz
craftbukkit-a2d9f33ca38660bb6bd698f598e8a6cfddc4e702.tar.xz
craftbukkit-a2d9f33ca38660bb6bd698f598e8a6cfddc4e702.zip
Various minor performance improvements
Add a check to avoid doing movement work if an entity doesn't move. This usually will not ever happen in the current server but is useful when it does and will be more useful in the future. Only process mob on mob (non-player) collisions every other tick. Players tend to pack a lot of mobs into a small space (sheep farm, mob grinder, etc) so they do a lot of work processing collisions. To help alleviate some of this we only run these calculations every other tick. This has no visible effect on the client but can be a huge win on the server depending on circumstances. Use generic entity inWater checking for squids. Squids have their own logic currently for determining if they are in water. This check is almost identical to the generic entity checking which is run anyway. To avoid doing duplicate work we just remove the squid version. This does not have any noticeable effect on gameplay since the checks are so similar. Use HashSet for tile entities instead of ArrayList. Using an ArrayList for storing tile entities in a world means we have very expensive inserts and removes that aren't at the end of the array due to the array copy this causes. This is most noticeable during chunk unload when a large number of tile entities are removed from the world at once. Using a HashSet here uses a little more memory but is O(1) for all operations so removes this bottleneck.
-rw-r--r--src/main/java/net/minecraft/server/Entity.java6
-rw-r--r--src/main/java/net/minecraft/server/EntityLiving.java6
-rw-r--r--src/main/java/net/minecraft/server/EntitySquid.java2
-rw-r--r--src/main/java/net/minecraft/server/World.java3
4 files changed, 15 insertions, 2 deletions
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 51a5b38c..d510392e 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -417,6 +417,12 @@ public abstract class Entity {
}
public void move(double d0, double d1, double d2) {
+ // CraftBukkit start - Don't do anything if we aren't moving
+ if (d0 == 0 && d1 == 0 && d2 == 0) {
+ return;
+ }
+ // CraftBukkit end
+
if (this.Z) {
this.boundingBox.d(d0, d1, d2);
this.locX = (this.boundingBox.a + this.boundingBox.d) / 2.0D;
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 21819eeb..fd1327a4 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -1411,6 +1411,12 @@ public abstract class EntityLiving extends Entity {
for (int i = 0; i < list.size(); ++i) {
Entity entity = (Entity) list.get(i);
+ // CraftBukkit start - Only handle mob (non-player) collisions every other tick
+ if (entity instanceof EntityLiving && !(this instanceof EntityPlayer) && this.ticksLived % 2 == 0) {
+ continue;
+ }
+ // CraftBukkit end
+
if (entity.L()) {
this.o(entity);
}
diff --git a/src/main/java/net/minecraft/server/EntitySquid.java b/src/main/java/net/minecraft/server/EntitySquid.java
index be8a5ed7..c6e8f786 100644
--- a/src/main/java/net/minecraft/server/EntitySquid.java
+++ b/src/main/java/net/minecraft/server/EntitySquid.java
@@ -63,9 +63,11 @@ public class EntitySquid extends EntityWaterAnimal {
// CraftBukkit end
}
+ /* CraftBukkit start - Delegate to Entity to use existing inWater value
public boolean G() {
return this.world.a(this.boundingBox.grow(0.0D, -0.6000000238418579D, 0.0D), Material.WATER, (Entity) this);
}
+ // CraftBukkit end */
public void c() {
super.c();
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 03b71674..d896f692 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -30,7 +30,7 @@ public abstract class World implements IBlockAccess {
public boolean d = false;
public List entityList = new ArrayList();
protected List f = new ArrayList();
- public List tileEntityList = new ArrayList();
+ public Set tileEntityList = new HashSet(); // CraftBukkit - ArrayList -> HashSet
private List a = new ArrayList();
private List b = new ArrayList();
public List players = new ArrayList();
@@ -44,7 +44,6 @@ public abstract class World implements IBlockAccess {
protected float o;
protected float p;
public int q = 0;
- // public boolean suppressPhysics = false; // CraftBukkit (removed in vanilla)
public boolean callingPlaceEvent = false; // CraftBukkit
public int difficulty;
public Random random = new Random();