Phase 1 of MC 1.5 update. No this is not meant to compile, don't get your hopes up :p

By: md_5 <md_5@live.com.au>
This commit is contained in:
Spigot
2013-03-16 08:35:56 +11:00
parent 8b867225be
commit f831bcfce2
29 changed files with 323 additions and 1063 deletions

View File

@@ -1,4 +1,4 @@
From 37c0d29448613da381e0fafccefd8e1792e2cbfe Mon Sep 17 00:00:00 2001
From ca107d374660de533a321bbe1fb550b097cd1b03 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 10 Jan 2013 00:18:11 -0500
Subject: [PATCH] Improved Timings System
@@ -19,7 +19,7 @@ Tracks nearly every point of minecraft internals and plugin events to give a goo
create mode 100644 src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index c0bab0f..5772932 100644
index d5887a9..3772ad8 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -103,6 +103,7 @@ public class ChunkProviderServer implements IChunkProvider {
@@ -39,10 +39,10 @@ index c0bab0f..5772932 100644
// CraftBukkit start - If we didn't need to load the chunk run the callback now
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index d0a58f8..bf9108a 100644
index 0dc65e6..c68e9cf 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -15,6 +15,7 @@ import org.bukkit.block.BlockFace;
@@ -14,6 +14,7 @@ import org.bukkit.block.BlockFace;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Painting;
import org.bukkit.entity.Vehicle;
@@ -51,7 +51,7 @@ index d0a58f8..bf9108a 100644
import org.bukkit.event.painting.PaintingBreakByEntityEvent;
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
@@ -111,6 +112,8 @@ public abstract class Entity {
public UUID uniqueId = UUID.randomUUID(); // CraftBukkit
public EnumEntitySize at;
public boolean valid = false; // CraftBukkit
+ public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getEntityTimings(this); // Spigot
@@ -59,35 +59,35 @@ index d0a58f8..bf9108a 100644
public Entity(World world) {
this.id = entityCount++;
this.l = 1.0D;
@@ -424,6 +427,7 @@ public abstract class Entity {
@@ -431,6 +434,7 @@ public abstract class Entity {
public void move(double d0, double d1, double d2) {
if (d0 == 0 && d1 == 0 && d2 == 0) { return; } // Spigot
+ org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.startTiming(); // Spigot
if (this.Y) {
if (this.Z) {
this.boundingBox.d(d0, d1, d2);
this.locX = (this.boundingBox.a + this.boundingBox.d) / 2.0D;
@@ -729,6 +733,7 @@ public abstract class Entity {
@@ -730,6 +734,7 @@ public abstract class Entity {
this.world.methodProfiler.b();
}
+ org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.stopTiming(); // Spigot
}
protected void D() {
protected void C() {
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 7d2e633..bd1aeaa 100644
index ae180c2..89ce129 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -505,6 +505,7 @@ public abstract class EntityLiving extends Entity {
@@ -512,6 +512,7 @@ public abstract class EntityLiving extends Entity {
}
public void j_() {
public void l_() {
+ org.bukkit.craftbukkit.SpigotTimings.timerEntityBaseTick.startTiming(); // Spigot
super.j_();
super.l_();
if (!this.world.isStatic) {
int i;
@@ -531,7 +532,9 @@ public abstract class EntityLiving extends Entity {
@@ -538,7 +539,9 @@ public abstract class EntityLiving extends Entity {
}
}
@@ -97,55 +97,55 @@ index 7d2e633..bd1aeaa 100644
double d0 = this.locX - this.lastX;
double d1 = this.locZ - this.lastZ;
float f = (float) (d0 * d0 + d1 * d1);
@@ -622,6 +625,7 @@ public abstract class EntityLiving extends Entity {
@@ -629,6 +632,7 @@ public abstract class EntityLiving extends Entity {
this.world.methodProfiler.b();
this.aD += f2;
this.aE += f2;
+ org.bukkit.craftbukkit.SpigotTimings.timerEntityTickRest.stopTiming(); // Spigot
}
// CraftBukkit start - delegate so we can handle providing a reason for health being regained
@@ -1228,6 +1232,7 @@ public abstract class EntityLiving extends Entity {
@@ -1264,6 +1268,7 @@ public abstract class EntityLiving extends Entity {
}
public void c() {
+ org.bukkit.craftbukkit.SpigotTimings.timerEntityAI.startTiming(); // Spigot
if (this.bV > 0) {
--this.bV;
if (this.bX > 0) {
--this.bX;
}
@@ -1279,6 +1284,7 @@ public abstract class EntityLiving extends Entity {
this.az = this.yaw;
@@ -1315,6 +1320,7 @@ public abstract class EntityLiving extends Entity {
this.aA = this.yaw;
}
}
+ org.bukkit.craftbukkit.SpigotTimings.timerEntityAI.stopTiming(); // Spigot
this.world.methodProfiler.b();
this.world.methodProfiler.a("jump");
@@ -1297,6 +1303,7 @@ public abstract class EntityLiving extends Entity {
@@ -1333,6 +1339,7 @@ public abstract class EntityLiving extends Entity {
this.world.methodProfiler.b();
this.world.methodProfiler.a("travel");
+ org.bukkit.craftbukkit.SpigotTimings.timerEntityAIMove.startTiming(); // Spigot
this.bC *= 0.98F;
this.bD *= 0.98F;
this.bE *= 0.9F;
@@ -1305,11 +1312,14 @@ public abstract class EntityLiving extends Entity {
this.aN *= this.bB();
this.e(this.bC, this.bD);
this.aN = f;
this.bE *= 0.98F;
this.bF *= 0.9F;
@@ -1341,11 +1348,14 @@ public abstract class EntityLiving extends Entity {
this.aO *= this.bE();
this.e(this.bD, this.bE);
this.aO = f;
+ org.bukkit.craftbukkit.SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot
this.world.methodProfiler.b();
this.world.methodProfiler.a("push");
+ org.bukkit.craftbukkit.SpigotTimings.timerEntityAICollision.startTiming(); // Spigot
if (!this.world.isStatic) {
this.bd();
this.bg();
}
+ org.bukkit.craftbukkit.SpigotTimings.timerEntityAICollision.stopTiming(); // Spigot
this.world.methodProfiler.b();
this.world.methodProfiler.a("looting");
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 128016f..aa6a14a 100644
index 36acefb..e8620d5 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -6,7 +6,6 @@ import java.security.KeyPair;
@@ -164,7 +164,7 @@ index 128016f..aa6a14a 100644
import org.bukkit.craftbukkit.util.Waitable;
import org.bukkit.event.server.RemoteServerCommandEvent;
import org.bukkit.event.world.WorldSaveEvent;
@@ -417,7 +417,10 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
@@ -399,7 +399,10 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
currentTPS = (currentTPS * 0.95) + (1E9 / (curTime - lastTick) * 0.05);
lastTick = curTime;
MinecraftServer.currentTick++;
@@ -175,7 +175,7 @@ index 128016f..aa6a14a 100644
}
// Spigot end
} else {
@@ -517,6 +520,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
@@ -499,6 +502,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
this.methodProfiler.a("levels");
// CraftBukkit start - only send timeupdates to the people in that world
@@ -183,7 +183,7 @@ index 128016f..aa6a14a 100644
this.server.getScheduler().mainThreadHeartbeat(this.ticks);
// Run tasks that are waiting on processing
@@ -524,7 +528,10 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
@@ -506,7 +510,10 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
processQueue.remove().run();
}
@@ -194,7 +194,7 @@ index 128016f..aa6a14a 100644
// Send timeupdates to everyone, it will get the right time from the world the player is in.
if (this.ticks % 20 == 0) {
@@ -576,7 +583,9 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
@@ -558,7 +565,9 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
this.methodProfiler.b();
this.methodProfiler.a("tracker");
@@ -204,7 +204,7 @@ index 128016f..aa6a14a 100644
this.methodProfiler.b();
this.methodProfiler.b();
// } // CraftBukkit
@@ -585,14 +594,20 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
@@ -567,14 +576,20 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
}
this.methodProfiler.c("connection");
@@ -213,23 +213,23 @@ index 128016f..aa6a14a 100644
+ SpigotTimings.connectionTimer.stopTiming(); // Spigot
this.methodProfiler.c("players");
+ SpigotTimings.playerListTimer.startTiming(); // Spigot
this.t.tick();
this.s.tick();
+ SpigotTimings.playerListTimer.stopTiming(); // Spigot
this.methodProfiler.c("tickables");
+ SpigotTimings.tickablesTimer.startTiming(); // Spigot
for (i = 0; i < this.p.size(); ++i) {
((IUpdatePlayerListBox) this.p.get(i)).a();
for (i = 0; i < this.o.size(); ++i) {
((IUpdatePlayerListBox) this.o.get(i)).a();
}
+ SpigotTimings.tickablesTimer.stopTiming(); // Spigot
this.methodProfiler.b();
}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 43a24f5..d2c2305 100644
index b3ff786..6fbec1e 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -976,6 +976,7 @@ public class PlayerConnection extends Connection {
@@ -963,6 +963,7 @@ public class PlayerConnection extends Connection {
// CraftBukkit end
private void handleCommand(String s) {
@@ -237,7 +237,7 @@ index 43a24f5..d2c2305 100644
// CraftBukkit start
CraftPlayer player = this.getPlayer();
@@ -983,19 +984,23 @@ public class PlayerConnection extends Connection {
@@ -970,19 +971,23 @@ public class PlayerConnection extends Connection {
this.server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
@@ -246,14 +246,14 @@ index 43a24f5..d2c2305 100644
}
try {
if (server.logCommands) logger.info(event.getPlayer().getName() + " issued server command: " + event.getMessage()); // Spigot
if (server.logCommands) this.minecraftServer.getLogger().info(event.getPlayer().getName() + " issued server command: " + event.getMessage()); // Spigot
if (this.server.dispatchCommand(event.getPlayer(), event.getMessage().substring(1))) {
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
return;
}
} catch (org.bukkit.command.CommandException ex) {
player.sendMessage(org.bukkit.ChatColor.RED + "An internal error occurred while attempting to perform this command");
Logger.getLogger(PlayerConnection.class.getName()).log(Level.SEVERE, null, ex);
java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(Level.SEVERE, null, ex);
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
return;
}
@@ -262,7 +262,7 @@ index 43a24f5..d2c2305 100644
/* CraftBukkit start - No longer needed as we have already handled it in server.dispatchServerCommand above.
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
index d8eb6b9..b6b0d5f 100644
index db3fc42..174546d 100644
--- a/src/main/java/net/minecraft/server/TileEntity.java
+++ b/src/main/java/net/minecraft/server/TileEntity.java
@@ -4,10 +4,12 @@ import java.util.HashMap;
@@ -277,9 +277,9 @@ index d8eb6b9..b6b0d5f 100644
+ public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getTileEntityTimings(this); // Spigot
private static Map a = new HashMap();
private static Map b = new HashMap();
public World world; // CraftBukkit - protected -> public
protected World world;
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 41f4f31..ec1a08f 100644
index c398268..d1be7c3 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -13,6 +13,7 @@ import java.util.concurrent.Callable;
@@ -290,7 +290,7 @@ index 41f4f31..ec1a08f 100644
import org.bukkit.craftbukkit.util.UnsafeList;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.craftbukkit.CraftServer;
@@ -114,6 +115,8 @@ public abstract class World implements IBlockAccess {
@@ -115,6 +116,8 @@ public abstract class World implements IBlockAccess {
final Object chunkLock = new Object();
private byte chunkTickRadius;
@@ -299,7 +299,7 @@ index 41f4f31..ec1a08f 100644
public CraftWorld getWorld() {
return this.world;
}
@@ -193,6 +196,7 @@ public abstract class World implements IBlockAccess {
@@ -194,6 +197,7 @@ public abstract class World implements IBlockAccess {
this.a();
this.getServer().addWorld(this.world); // CraftBukkit
@@ -307,7 +307,7 @@ index 41f4f31..ec1a08f 100644
}
protected abstract IChunkProvider j();
@@ -1259,6 +1263,7 @@ public abstract class World implements IBlockAccess {
@@ -1293,6 +1297,7 @@ public abstract class World implements IBlockAccess {
this.f.clear();
this.methodProfiler.c("regular");
@@ -315,7 +315,7 @@ index 41f4f31..ec1a08f 100644
for (i = 0; i < this.entityList.size(); ++i) {
entity = (Entity) this.entityList.get(i);
@@ -1281,7 +1286,9 @@ public abstract class World implements IBlockAccess {
@@ -1315,7 +1320,9 @@ public abstract class World implements IBlockAccess {
this.methodProfiler.a("tick");
if (!entity.dead) {
try {
@@ -325,38 +325,38 @@ index 41f4f31..ec1a08f 100644
} catch (Throwable throwable1) {
crashreport = CrashReport.a(throwable1, "Ticking entity");
crashreportsystemdetails = crashreport.a("Entity being ticked");
@@ -1311,7 +1318,9 @@ public abstract class World implements IBlockAccess {
@@ -1340,7 +1347,9 @@ public abstract class World implements IBlockAccess {
this.methodProfiler.b();
}
+ timings.entityTick.stopTiming(); // Spigot
this.methodProfiler.c("tileEntities");
+ timings.tileEntityTick.startTiming(); // Spigot
this.M = true;
this.N = true;
Iterator iterator = this.tileEntityList.iterator();
@@ -1326,8 +1335,11 @@ public abstract class World implements IBlockAccess {
@@ -1355,8 +1364,11 @@ public abstract class World implements IBlockAccess {
if (!tileentity.r() && tileentity.o() && this.isLoaded(tileentity.x, tileentity.y, tileentity.z)) {
try {
+ tileentity.tickTimer.startTiming(); // Spigot
tileentity.g();
tileentity.h();
+ tileentity.tickTimer.stopTiming(); // Spigot
} catch (Throwable throwable2) {
+ tileentity.tickTimer.stopTiming(); // Spigot
crashreport = CrashReport.a(throwable2, "Ticking tile entity");
crashreportsystemdetails = crashreport.a("Tile entity being ticked");
if (tileentity == null) {
@@ -1352,6 +1364,8 @@ public abstract class World implements IBlockAccess {
tileentity.a(crashreportsystemdetails);
@@ -1376,6 +1388,8 @@ public abstract class World implements IBlockAccess {
}
}
+ timings.tileEntityTick.stopTiming(); // Spigot
+ timings.tileEntityPending.startTiming(); // Spigot
this.M = false;
this.N = false;
if (!this.b.isEmpty()) {
this.tileEntityList.removeAll(this.b);
@@ -1390,6 +1404,7 @@ public abstract class World implements IBlockAccess {
@@ -1414,6 +1428,7 @@ public abstract class World implements IBlockAccess {
this.a.clear();
}
@@ -364,15 +364,15 @@ index 41f4f31..ec1a08f 100644
this.methodProfiler.b();
this.methodProfiler.b();
}
@@ -1412,6 +1427,7 @@ public abstract class World implements IBlockAccess {
@@ -1436,6 +1451,7 @@ public abstract class World implements IBlockAccess {
byte b0 = 32;
if (!flag || this.d(i - b0, 0, j - b0, i + b0, 0, j + b0)) {
if (!flag || this.e(i - b0, 0, j - b0, i + b0, 0, j + b0)) {
+ entity.tickTimer.startTiming(); // Spigot
entity.T = entity.locX;
entity.U = entity.locY;
entity.V = entity.locZ;
@@ -1473,6 +1489,7 @@ public abstract class World implements IBlockAccess {
entity.U = entity.locX;
entity.V = entity.locY;
entity.W = entity.locZ;
@@ -1497,6 +1513,7 @@ public abstract class World implements IBlockAccess {
entity.passenger = null;
}
}
@@ -381,10 +381,10 @@ index 41f4f31..ec1a08f 100644
}
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 4aa2a19..6cb3e24 100644
index 2407bc6..6ade608 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -157,9 +157,12 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
@@ -168,9 +168,12 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
// CraftBukkit start - Only call spawner if we have players online and the world allows for mobs or animals
long time = this.worldData.getTime();
if (this.getGameRules().getBoolean("doMobSpawning") && (this.allowMonsters || this.allowAnimals) && (this instanceof WorldServer && this.players.size() > 0)) {
@@ -397,8 +397,8 @@ index 4aa2a19..6cb3e24 100644
this.methodProfiler.c("chunkSource");
this.chunkProvider.unloadChunks();
int j = this.a(1.0F);
@@ -186,6 +189,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
this.V();
@@ -196,6 +199,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
this.Y();
this.getWorld().processChunkGC(); // CraftBukkit
+ timings.doTickRest.stopTiming(); // Spigot