Fix some CME's in the powernet, and add a basic profiler to it, might add a command or someway to use this without enabling it in the code
This commit is contained in:
parent
796df6c055
commit
871edce960
3 changed files with 30 additions and 4 deletions
|
@ -29,12 +29,26 @@ public class TRTickHandler {
|
|||
previouslyWearing = chestslot;
|
||||
}
|
||||
|
||||
int ticksCounted = 0;
|
||||
long tickTime = 0;
|
||||
|
||||
@SubscribeEvent
|
||||
public void worldTick(TickEvent.WorldTickEvent e) {
|
||||
if (e.world.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
long start = System.nanoTime();
|
||||
MinecraftForge.EVENT_BUS.post(new PowerTickEvent());
|
||||
long elapsed = System.nanoTime() - start;
|
||||
tickTime += elapsed;
|
||||
ticksCounted ++;
|
||||
if(ticksCounted == 20 * 5){
|
||||
//Enable this this line to get some infomation when debuging.
|
||||
//System.out.println("Average powernet tick time over last 5 seconds: " + (tickTime / ticksCounted) + "ns");
|
||||
ticksCounted = 0;
|
||||
tickTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -357,7 +357,10 @@ public abstract class CableMultipart extends Multipart
|
|||
network = new TRPowerNet(getCableType());
|
||||
network.addElement(this);
|
||||
}
|
||||
network.endpoints.clear();
|
||||
for (Iterator<TRPowerNet.EnergyHandler> it = network.endpoints.iterator(); it.hasNext(); ) {
|
||||
it.next();
|
||||
it.remove();
|
||||
}
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
TileEntity te = getNeighbourTile(dir);
|
||||
if (te != null && te instanceof IEnergyInterfaceTile) {
|
||||
|
|
|
@ -11,6 +11,7 @@ import techreborn.parts.powerCables.CableMultipart;
|
|||
import techreborn.parts.powerCables.EnumCableType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class TRPowerNet {
|
||||
|
@ -135,7 +136,12 @@ public class TRPowerNet {
|
|||
}
|
||||
|
||||
}
|
||||
endpoints.removeAll(deadHandlers);
|
||||
for (Iterator<EnergyHandler> it = endpoints.iterator(); it.hasNext(); ) {
|
||||
EnergyHandler energyHandler = it.next();
|
||||
if (deadHandlers.contains(energyHandler)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void rebuild() {
|
||||
|
@ -206,7 +212,10 @@ public class TRPowerNet {
|
|||
}
|
||||
|
||||
cables.clear();
|
||||
endpoints.clear();
|
||||
for (Iterator<TRPowerNet.EnergyHandler> it = endpoints.iterator(); it.hasNext(); ) {
|
||||
it.next();
|
||||
it.remove();
|
||||
}
|
||||
energy = 0;
|
||||
|
||||
MinecraftForge.EVENT_BUS.unregister(this);
|
||||
|
@ -221,7 +230,7 @@ public class TRPowerNet {
|
|||
return maxAdd;
|
||||
}
|
||||
|
||||
private static class EnergyHandler {
|
||||
public static class EnergyHandler {
|
||||
private final IEnergyInterfaceTile tile;
|
||||
private final EnumCableType type;
|
||||
private EnumFacing side;
|
||||
|
|
Loading…
Add table
Reference in a new issue