world = e.worldObj;
} else {
world = DimensionManager.getWorld(0);
}
}
final TickManager manager = TickThreading.instance.getManager(world == null ? DimensionManager.getWorld(0) : world);
final List<World> worlds = new ArrayList<World>();
if (world == null) {
Collections.addAll(worlds, DimensionManager.getWorlds());
} else {
worlds.add(world);
}
final int hashCode = x != null ? TickManager.getHashCode(x * 16, z * 16) : 0;
if (entity) {
final EntityTickProfiler entityTickProfiler = EntityTickProfiler.ENTITY_TICK_PROFILER;
if (location) {
if (!world.getChunkProvider().chunkExists(x, z)) {
sendChat(commandSender, "The chunk coords " + x + ',' + z + " are not loaded, can not profile.");
return;
}
}
if (!entityTickProfiler.startProfiling(new Runnable() {
@Override
public void run() {
if (location) {
TickRegion tickRegion = manager.getEntityRegion(hashCode);
if (tickRegion != null) {
tickRegion.profilingEnabled = false;
}
tickRegion = manager.getTileEntityRegion(hashCode);
if (tickRegion != null) {
tickRegion.profilingEnabled = false;
}
}
sendChat(commandSender, entityTickProfiler.writeStringData(new TableFormatter(commandSender)).toString());
}
}, location ? ProfilingState.CHUNK : ProfilingState.GLOBAL, time, worlds)) {
sendChat(commandSender, "Someone else is currently profiling.");
}
if (location) {
manager.profilingEnabled = false;
TickRegion tickRegion = manager.getEntityRegion(hashCode);
if (tickRegion != null) {
tickRegion.profilingEnabled = true;
}
tickRegion = manager.getTileEntityRegion(hashCode);
if (tickRegion != null) {
tickRegion.profilingEnabled = true;
}
}
sendChat(commandSender, "Profiling for " + time + " seconds in " + (world == null ? "all worlds " : Log.name(world)) + (location ? " at chunk coords " + x + ',' + z : ""));