Improve Crash Report for Ticking GridNodes.
This commit is contained in:
parent
6b89d27562
commit
a1fcdcda80
3 changed files with 77 additions and 34 deletions
16
me/cache/TickManagerCache.java
vendored
16
me/cache/TickManagerCache.java
vendored
|
@ -3,6 +3,9 @@ package appeng.me.cache;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.PriorityQueue;
|
import java.util.PriorityQueue;
|
||||||
|
|
||||||
|
import net.minecraft.crash.CrashReport;
|
||||||
|
import net.minecraft.crash.CrashReportCategory;
|
||||||
|
import net.minecraft.util.ReportedException;
|
||||||
import appeng.api.networking.IGrid;
|
import appeng.api.networking.IGrid;
|
||||||
import appeng.api.networking.IGridHost;
|
import appeng.api.networking.IGridHost;
|
||||||
import appeng.api.networking.IGridNode;
|
import appeng.api.networking.IGridNode;
|
||||||
|
@ -51,11 +54,14 @@ public class TickManagerCache implements ITickManager
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdateTick()
|
public void onUpdateTick()
|
||||||
|
{
|
||||||
|
TickTracker tt = null;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
currentTick++;
|
currentTick++;
|
||||||
while (!upcomingTicks.isEmpty())
|
while (!upcomingTicks.isEmpty())
|
||||||
{
|
{
|
||||||
TickTracker tt = upcomingTicks.peek();
|
tt = upcomingTicks.peek();
|
||||||
int diff = (int) (currentTick - tt.lastTick);
|
int diff = (int) (currentTick - tt.lastTick);
|
||||||
if ( diff >= tt.current_rate )
|
if ( diff >= tt.current_rate )
|
||||||
{
|
{
|
||||||
|
@ -93,6 +99,14 @@ public class TickManagerCache implements ITickManager
|
||||||
return; // done!
|
return; // done!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch( Throwable t )
|
||||||
|
{
|
||||||
|
CrashReport crashreport = CrashReport.makeCrashReport(t, "Ticking GridNode");
|
||||||
|
CrashReportCategory crashreportcategory = crashreport.makeCategory( tt.gt.getClass().getSimpleName() + " being ticked." );
|
||||||
|
tt.addEntityCrashInfo(crashreportcategory);
|
||||||
|
throw new ReportedException(crashreport);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void addToQueue(TickTracker tt)
|
private void addToQueue(TickTracker tt)
|
||||||
{
|
{
|
||||||
|
|
23
me/cache/helpers/TickTracker.java
vendored
23
me/cache/helpers/TickTracker.java
vendored
|
@ -1,9 +1,12 @@
|
||||||
package appeng.me.cache.helpers;
|
package appeng.me.cache.helpers;
|
||||||
|
|
||||||
|
import net.minecraft.crash.CrashReportCategory;
|
||||||
import appeng.api.networking.IGridNode;
|
import appeng.api.networking.IGridNode;
|
||||||
import appeng.api.networking.ticking.IGridTickable;
|
import appeng.api.networking.ticking.IGridTickable;
|
||||||
import appeng.api.networking.ticking.TickingRequest;
|
import appeng.api.networking.ticking.TickingRequest;
|
||||||
|
import appeng.api.util.DimensionalCoord;
|
||||||
import appeng.me.cache.TickManagerCache;
|
import appeng.me.cache.TickManagerCache;
|
||||||
|
import appeng.parts.AEBasePart;
|
||||||
|
|
||||||
public class TickTracker implements Comparable<TickTracker>
|
public class TickTracker implements Comparable<TickTracker>
|
||||||
{
|
{
|
||||||
|
@ -50,4 +53,24 @@ public class TickTracker implements Comparable<TickTracker>
|
||||||
int ts_nextTick = (int) ((t.lastTick - host.getCurrentTick()) + t.current_rate);
|
int ts_nextTick = (int) ((t.lastTick - host.getCurrentTick()) + t.current_rate);
|
||||||
return nextTick - ts_nextTick;
|
return nextTick - ts_nextTick;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addEntityCrashInfo(CrashReportCategory crashreportcategory)
|
||||||
|
{
|
||||||
|
if ( gt instanceof AEBasePart )
|
||||||
|
{
|
||||||
|
AEBasePart part = (AEBasePart)gt;
|
||||||
|
part.addEntityCrashInfo( crashreportcategory );
|
||||||
|
}
|
||||||
|
|
||||||
|
crashreportcategory.addCrashSection( "CurrentTickRate", current_rate );
|
||||||
|
crashreportcategory.addCrashSection( "MinTickRate", request.minTickRate );
|
||||||
|
crashreportcategory.addCrashSection( "MaxTickRate", request.maxTickRate );
|
||||||
|
crashreportcategory.addCrashSection( "MachineType", gt.getClass().getName() );
|
||||||
|
crashreportcategory.addCrashSection( "GridBlockType", node.getGridBlock().getClass().getName() );
|
||||||
|
crashreportcategory.addCrashSection( "ConnectedSides", node.getConnectedSides() );
|
||||||
|
|
||||||
|
DimensionalCoord dc = node.getGridBlock().getLocation();
|
||||||
|
if ( dc != null )
|
||||||
|
crashreportcategory.addCrashSection( "Location", dc );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.RenderBlocks;
|
import net.minecraft.client.renderer.RenderBlocks;
|
||||||
|
import net.minecraft.crash.CrashReportCategory;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -507,4 +508,9 @@ public class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradea
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addEntityCrashInfo(CrashReportCategory crashreportcategory)
|
||||||
|
{
|
||||||
|
crashreportcategory.addCrashSection( "Part Side", side );
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue