mirror of
https://github.com/GTNewHorizons/Opis.git
synced 2026-11-21 20:52:14 +00:00
69 lines
1.8 KiB
Java
69 lines
1.8 KiB
Java
package mcp.mobius.opis.data.server;
|
|
|
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
|
|
|
import cpw.mods.fml.common.FMLCommonHandler;
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import net.minecraft.entity.Entity;
|
|
import mcp.mobius.mobiuscore.profiler.IProfilerEntity;
|
|
import mcp.mobius.opis.modOpis;
|
|
import mcp.mobius.opis.data.managers.EntityManager;
|
|
import mcp.mobius.opis.events.OpisServerTickHandler;
|
|
|
|
public class EntityProfiler extends AbstractProfiler implements IProfilerEntity {
|
|
|
|
private Entity currentEntity = null;
|
|
|
|
/*
|
|
private ConcurrentLinkedQueue<Integer> dataQueue = new ConcurrentLinkedQueue<Integer>();
|
|
|
|
final class UpdateData{
|
|
final long update;
|
|
final Entity entity;
|
|
|
|
public UpdateData(long update, Entity entity){
|
|
this.update = update;
|
|
this.entity = entity;
|
|
}
|
|
|
|
}
|
|
*/
|
|
|
|
@Override
|
|
public void FullEntityStart() {}
|
|
|
|
@Override
|
|
public void FullEntityStop() {}
|
|
|
|
@Override
|
|
public void Start(Entity ent) {
|
|
//if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) return;
|
|
|
|
if ((!modOpis.profilerRun) || (OpisServerTickHandler.instance.profilerUpdateTickCounter % modOpis.profilerDelay != 0)) return;
|
|
|
|
if (ent.worldObj.isRemote) return;
|
|
|
|
this.currentEntity = ent;
|
|
this.clock.start();
|
|
|
|
}
|
|
|
|
@Override
|
|
public void Stop(Entity ent) {
|
|
//if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) return;
|
|
if ((!modOpis.profilerRun) || (OpisServerTickHandler.instance.profilerUpdateTickCounter % modOpis.profilerDelay != 0)) return;
|
|
|
|
this.clock.stop();
|
|
if (ent.worldObj.isRemote) return;
|
|
|
|
if (ent != this.currentEntity)
|
|
throw new RuntimeException(String.format("Mismatched entities during the profiling ! %s %s", ent, this.currentEntity));
|
|
|
|
|
|
EntityManager.addEntity(ent, this.clock.timeDelta);
|
|
this.currentEntity = null;
|
|
|
|
}
|
|
|
|
}
|