Improve Crash Report for Ticking GridNodes.
This commit is contained in:
Vendored
+48
-34
@@ -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;
|
||||||
@@ -52,45 +55,56 @@ public class TickManagerCache implements ITickManager
|
|||||||
@Override
|
@Override
|
||||||
public void onUpdateTick()
|
public void onUpdateTick()
|
||||||
{
|
{
|
||||||
currentTick++;
|
TickTracker tt = null;
|
||||||
while (!upcomingTicks.isEmpty())
|
try
|
||||||
{
|
{
|
||||||
TickTracker tt = upcomingTicks.peek();
|
currentTick++;
|
||||||
int diff = (int) (currentTick - tt.lastTick);
|
while (!upcomingTicks.isEmpty())
|
||||||
if ( diff >= tt.current_rate )
|
|
||||||
{
|
{
|
||||||
// remove tt..
|
tt = upcomingTicks.peek();
|
||||||
upcomingTicks.poll();
|
int diff = (int) (currentTick - tt.lastTick);
|
||||||
TickRateModulation mod = tt.gt.tickingRequest( tt.node, diff );
|
if ( diff >= tt.current_rate )
|
||||||
|
|
||||||
switch (mod)
|
|
||||||
{
|
{
|
||||||
case FASTER:
|
// remove tt..
|
||||||
tt.setRate( tt.current_rate - 2 );
|
upcomingTicks.poll();
|
||||||
break;
|
TickRateModulation mod = tt.gt.tickingRequest( tt.node, diff );
|
||||||
case IDLE:
|
|
||||||
tt.setRate( tt.request.maxTickRate );
|
|
||||||
break;
|
|
||||||
case SAME:
|
|
||||||
break;
|
|
||||||
case SLEEP:
|
|
||||||
sleepDevice( tt.node );
|
|
||||||
break;
|
|
||||||
case SLOWER:
|
|
||||||
tt.setRate( tt.current_rate + 1 );
|
|
||||||
break;
|
|
||||||
case URGENT:
|
|
||||||
tt.setRate( 0 );
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( awake.containsKey( tt.node ) )
|
switch (mod)
|
||||||
addToQueue( tt );
|
{
|
||||||
|
case FASTER:
|
||||||
|
tt.setRate( tt.current_rate - 2 );
|
||||||
|
break;
|
||||||
|
case IDLE:
|
||||||
|
tt.setRate( tt.request.maxTickRate );
|
||||||
|
break;
|
||||||
|
case SAME:
|
||||||
|
break;
|
||||||
|
case SLEEP:
|
||||||
|
sleepDevice( tt.node );
|
||||||
|
break;
|
||||||
|
case SLOWER:
|
||||||
|
tt.setRate( tt.current_rate + 1 );
|
||||||
|
break;
|
||||||
|
case URGENT:
|
||||||
|
tt.setRate( 0 );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( awake.containsKey( tt.node ) )
|
||||||
|
addToQueue( tt );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return; // done!
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+23
@@ -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 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user