TESR should use less CPU when no-op.
onInventoryChange for FZ. Networks without batteries can store up to 1000 AE. Fixed a bug that cause energy to spiral out of control and go infinite. Fixed a crash with storage buses and fluids.
This commit is contained in:
@@ -28,39 +28,43 @@ public class TESRWrapper extends TileEntitySpecialRenderer
|
|||||||
@Override
|
@Override
|
||||||
final public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f)
|
final public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f)
|
||||||
{
|
{
|
||||||
if ( Math.abs( x ) > MAX_DISTANCE || Math.abs( y ) > MAX_DISTANCE || Math.abs( z ) > MAX_DISTANCE )
|
if ( te instanceof AEBaseTile )
|
||||||
return;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
Block b = te.getBlockType();
|
Block b = te.getBlockType();
|
||||||
Tessellator tess = Tessellator.instance;
|
|
||||||
if ( tess.isDrawing )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( b instanceof AEBaseBlock && te instanceof AEBaseTile )
|
if ( b instanceof AEBaseBlock && ((AEBaseTile) te).requiresTESR() )
|
||||||
{
|
{
|
||||||
|
if ( Math.abs( x ) > MAX_DISTANCE || Math.abs( y ) > MAX_DISTANCE || Math.abs( z ) > MAX_DISTANCE )
|
||||||
|
return;
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
Tessellator tess = Tessellator.instance;
|
||||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
|
||||||
|
|
||||||
rbinstance.blockAccess = te.worldObj;
|
|
||||||
blkRender.renderTile( (AEBaseBlock) b, (AEBaseTile) te, tess, x, y, z, f, rbinstance );
|
|
||||||
|
|
||||||
if ( tess.isDrawing )
|
if ( tess.isDrawing )
|
||||||
throw new RuntimeException( "Error durring rendering." );
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||||
|
|
||||||
|
rbinstance.blockAccess = te.worldObj;
|
||||||
|
blkRender.renderTile( (AEBaseBlock) b, (AEBaseTile) te, tess, x, y, z, f, rbinstance );
|
||||||
|
|
||||||
|
if ( tess.isDrawing )
|
||||||
|
throw new RuntimeException( "Error durring rendering." );
|
||||||
|
|
||||||
|
GL11.glPopAttrib();
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
catch (Throwable t)
|
||||||
|
{
|
||||||
|
FMLLog.severe( "Hi, Looks like there was a crash while rendering something..." );
|
||||||
|
t.printStackTrace();
|
||||||
|
FMLLog.severe( "MC will now crash ( probobly )!" );
|
||||||
|
throw new RuntimeException( t );
|
||||||
|
}
|
||||||
|
|
||||||
GL11.glPopAttrib();
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Throwable t)
|
|
||||||
{
|
|
||||||
FMLLog.severe( "Hi, Looks like there was a crash while rendering something..." );
|
|
||||||
t.printStackTrace();
|
|
||||||
FMLLog.severe( "MC will now crash ( probobly )!" );
|
|
||||||
throw new RuntimeException( t );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,18 +134,15 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IMEMonito
|
|||||||
PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
|
PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
|
||||||
IItemList<IAEItemStack> monitorCache = monitor.getStorageList();
|
IItemList<IAEItemStack> monitorCache = monitor.getStorageList();
|
||||||
|
|
||||||
int items = 0;
|
|
||||||
for (IAEItemStack send : monitorCache)
|
for (IAEItemStack send : monitorCache)
|
||||||
{
|
{
|
||||||
if ( piu.getLength() > 20000 )
|
if ( piu.getLength() > 20000 )
|
||||||
{
|
{
|
||||||
items = 0;
|
|
||||||
Packet p = piu.getPacket();
|
Packet p = piu.getPacket();
|
||||||
PacketDispatcher.sendPacketToPlayer( p, (Player) c );
|
PacketDispatcher.sendPacketToPlayer( p, (Player) c );
|
||||||
piu = new PacketMEInventoryUpdate();
|
piu = new PacketMEInventoryUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
items++;
|
|
||||||
piu.appendItem( send );
|
piu.appendItem( send );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ public class FZ implements IFZ, IIntegrationModule
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( day_BarrelClass.isInstance( te ) )
|
if ( day_BarrelClass.isInstance( te ) )
|
||||||
return (Integer) day_getMaxSize.invoke( te );
|
return (Integer) day_getMaxSize.invoke( te );
|
||||||
else
|
else
|
||||||
@@ -87,7 +86,6 @@ public class FZ implements IFZ, IIntegrationModule
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( day_BarrelClass.isInstance( te ) )
|
if ( day_BarrelClass.isInstance( te ) )
|
||||||
return (Integer) day_getItemCount.invoke( te );
|
return (Integer) day_getItemCount.invoke( te );
|
||||||
else
|
else
|
||||||
@@ -110,11 +108,12 @@ public class FZ implements IFZ, IIntegrationModule
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( day_BarrelClass.isInstance( te ) )
|
if ( day_BarrelClass.isInstance( te ) )
|
||||||
day_item.set( te, input == null ? null : input.copy() );
|
day_item.set( te, input == null ? null : input.copy() );
|
||||||
else
|
else
|
||||||
item.set( te, input == null ? null : input.copy() );
|
item.set( te, input == null ? null : input.copy() );
|
||||||
|
|
||||||
|
te.onInventoryChanged();
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException e)
|
catch (IllegalArgumentException e)
|
||||||
{
|
{
|
||||||
@@ -129,13 +128,12 @@ public class FZ implements IFZ, IIntegrationModule
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( day_BarrelClass.isInstance( te ) )
|
if ( day_BarrelClass.isInstance( te ) )
|
||||||
day_setItemCount.invoke( te, max );
|
day_setItemCount.invoke( te, max );
|
||||||
else
|
else
|
||||||
setItemCount.invoke( te, max );
|
setItemCount.invoke( te, max );
|
||||||
|
|
||||||
te.worldObj.markBlockForUpdate( te.xCoord, te.yCoord, te.zCoord );
|
te.onInventoryChanged();
|
||||||
}
|
}
|
||||||
catch (IllegalAccessException e)
|
catch (IllegalAccessException e)
|
||||||
{
|
{
|
||||||
|
|||||||
Vendored
+15
-12
@@ -68,6 +68,11 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
IAEPowerStorage lastRequestor;
|
IAEPowerStorage lastRequestor;
|
||||||
Set<IAEPowerStorage> requesters = new LinkedHashSet();
|
Set<IAEPowerStorage> requesters = new LinkedHashSet();
|
||||||
|
|
||||||
|
private double buffer()
|
||||||
|
{
|
||||||
|
return providers.isEmpty() ? 1000.0 : 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
private IAEPowerStorage getFirstRequestor()
|
private IAEPowerStorage getFirstRequestor()
|
||||||
{
|
{
|
||||||
if ( lastRequestor == null )
|
if ( lastRequestor == null )
|
||||||
@@ -183,7 +188,7 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
extra = i;
|
extra = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
return Math.max( 0.0, i - buffer() );
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<IEnergyGrid> seen = new HashSet();
|
Set<IEnergyGrid> seen = new HashSet();
|
||||||
@@ -299,8 +304,8 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
publicPowerState( false, myGrid );
|
publicPowerState( false, myGrid );
|
||||||
|
|
||||||
availableTicksSinceUpdate++;
|
availableTicksSinceUpdate++;
|
||||||
if ( extra > 32 )
|
// if ( extra > 32 )
|
||||||
injectPower( 0.0, Actionable.MODULATE );
|
// injectPower( 0.0, Actionable.MODULATE );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void publicPowerState(boolean newState, IGrid grid)
|
private void publicPowerState(boolean newState, IGrid grid)
|
||||||
@@ -354,7 +359,10 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
return extractedPower;
|
return extractedPower;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
extractedPower += doExtract( extractedPower, amt );
|
{
|
||||||
|
extra = 0;
|
||||||
|
extractedPower = doExtract( extractedPower, amt );
|
||||||
|
}
|
||||||
|
|
||||||
// got more then we wanted?
|
// got more then we wanted?
|
||||||
if ( extractedPower > amt )
|
if ( extractedPower > amt )
|
||||||
@@ -379,8 +387,6 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
|
|
||||||
private double doExtract(double extractedPower, double amt)
|
private double doExtract(double extractedPower, double amt)
|
||||||
{
|
{
|
||||||
extra = 0;
|
|
||||||
|
|
||||||
while (extractedPower < amt && !providers.isEmpty())
|
while (extractedPower < amt && !providers.isEmpty())
|
||||||
{
|
{
|
||||||
IAEPowerStorage node = getFirstProvider();
|
IAEPowerStorage node = getFirstProvider();
|
||||||
@@ -435,8 +441,7 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
return avgDrainPerTick;/*
|
return avgDrainPerTick;/*
|
||||||
* double out = 0;
|
* double out = 0;
|
||||||
*
|
*
|
||||||
* for (double x : totalDrainPastTicks) out +=
|
* for (double x : totalDrainPastTicks) out += x;
|
||||||
* x;
|
|
||||||
*
|
*
|
||||||
* return out / totalDrainPastTicks.length;
|
* return out / totalDrainPastTicks.length;
|
||||||
*/
|
*/
|
||||||
@@ -448,11 +453,9 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
return avgInjectionPerTick;/*
|
return avgInjectionPerTick;/*
|
||||||
* double out = 0;
|
* double out = 0;
|
||||||
*
|
*
|
||||||
* for (double x : totalInjectionPastTicks)
|
* for (double x : totalInjectionPastTicks) out += x;
|
||||||
* out += x;
|
|
||||||
*
|
*
|
||||||
* return out /
|
* return out / totalInjectionPastTicks.length;
|
||||||
* totalInjectionPastTicks.length;
|
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -324,4 +324,10 @@ public class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradea
|
|||||||
{
|
{
|
||||||
host.markForSave();
|
host.markForSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requireDynamicRender()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -57,6 +57,7 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
|
|||||||
public IPartHost tcb;
|
public IPartHost tcb;
|
||||||
|
|
||||||
boolean inWorld = false;
|
boolean inWorld = false;
|
||||||
|
public boolean requiresDynamicRender = false;
|
||||||
|
|
||||||
public void setHost(IPartHost host)
|
public void setHost(IPartHost host)
|
||||||
{
|
{
|
||||||
@@ -76,6 +77,17 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
|
|||||||
return sides[side.ordinal()];
|
return sides[side.ordinal()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateDynamicRender()
|
||||||
|
{
|
||||||
|
requiresDynamicRender = false;
|
||||||
|
for (ForgeDirection s : ForgeDirection.VALID_DIRECTIONS)
|
||||||
|
{
|
||||||
|
IPart p = getPart( s );
|
||||||
|
if ( p != null )
|
||||||
|
requiresDynamicRender = requiresDynamicRender || p.requireDynamicRender();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removePart(ForgeDirection side, boolean supressUpdate)
|
public void removePart(ForgeDirection side, boolean supressUpdate)
|
||||||
{
|
{
|
||||||
@@ -94,6 +106,7 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
|
|||||||
|
|
||||||
if ( !supressUpdate )
|
if ( !supressUpdate )
|
||||||
{
|
{
|
||||||
|
updateDynamicRender();
|
||||||
updateConnections();
|
updateConnections();
|
||||||
markForUpdate();
|
markForUpdate();
|
||||||
PartChanged();
|
PartChanged();
|
||||||
@@ -262,6 +275,7 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateDynamicRender();
|
||||||
updateConnections();
|
updateConnections();
|
||||||
markForUpdate();
|
markForUpdate();
|
||||||
PartChanged();
|
PartChanged();
|
||||||
@@ -543,7 +557,8 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
|
|||||||
if ( part != null )
|
if ( part != null )
|
||||||
{
|
{
|
||||||
setSide( s );
|
setSide( s );
|
||||||
BusCollisionHelper bch = new BusCollisionHelper( boxes, BusRenderHelper.instance.ax, BusRenderHelper.instance.ay, BusRenderHelper.instance.az, null, true );
|
BusCollisionHelper bch = new BusCollisionHelper( boxes, BusRenderHelper.instance.ax, BusRenderHelper.instance.ay,
|
||||||
|
BusRenderHelper.instance.az, null, true );
|
||||||
part.getBoxes( bch );
|
part.getBoxes( bch );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -223,7 +223,14 @@ public class PartLevelEmitter extends PartUpgradeable implements IStackWatcherHo
|
|||||||
@Override
|
@Override
|
||||||
public boolean isValid(Object effectiveGrid)
|
public boolean isValid(Object effectiveGrid)
|
||||||
{
|
{
|
||||||
return getGridNode().getGrid() == effectiveGrid;
|
try
|
||||||
|
{
|
||||||
|
return proxy.getGrid() == effectiveGrid;
|
||||||
|
}
|
||||||
|
catch (GridAccessException e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -72,6 +72,12 @@ public class PartCableAnchor implements IPart
|
|||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requireDynamicRender()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderDynamic(double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer)
|
public void renderDynamic(double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -353,10 +353,13 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
|||||||
@Override
|
@Override
|
||||||
public List<IMEInventoryHandler> getCellArray(StorageChannel channel)
|
public List<IMEInventoryHandler> getCellArray(StorageChannel channel)
|
||||||
{
|
{
|
||||||
IMEInventoryHandler out = proxy.isActive() ? getHandler() : null;
|
if ( channel == StorageChannel.ITEMS )
|
||||||
if ( out == null )
|
{
|
||||||
return Arrays.asList( new IMEInventoryHandler[] {} );
|
IMEInventoryHandler out = proxy.isActive() ? getHandler() : null;
|
||||||
return Arrays.asList( new IMEInventoryHandler[] { out } );
|
if ( out != null )
|
||||||
|
return Arrays.asList( new IMEInventoryHandler[] { out } );
|
||||||
|
}
|
||||||
|
return Arrays.asList( new IMEInventoryHandler[] {} );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -162,6 +162,12 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
|
|||||||
frontSolid = CableBusTextures.PartStorageMonitor_Solid;
|
frontSolid = CableBusTextures.PartStorageMonitor_Solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requireDynamicRender()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderDynamic(double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer)
|
public void renderDynamic(double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -346,4 +346,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile
|
|||||||
super.onInventoryChanged();
|
super.onInventoryChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean requiresTESR()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,7 +116,8 @@ public class TileCrank extends AEBaseTile implements ICustomCollision
|
|||||||
double xOff = -0.15 * getUp().offsetX;
|
double xOff = -0.15 * getUp().offsetX;
|
||||||
double yOff = -0.15 * getUp().offsetY;
|
double yOff = -0.15 * getUp().offsetY;
|
||||||
double zOff = -0.15 * getUp().offsetZ;
|
double zOff = -0.15 * getUp().offsetZ;
|
||||||
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( xOff + 0.15, yOff + 0.15, zOff + 0.15, xOff + 0.85, yOff + 0.85, zOff + 0.85 ) } );
|
return Arrays
|
||||||
|
.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( xOff + 0.15, yOff + 0.15, zOff + 0.15, xOff + 0.85, yOff + 0.85, zOff + 0.85 ) } );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -128,4 +129,10 @@ public class TileCrank extends AEBaseTile implements ICustomCollision
|
|||||||
out.add( AxisAlignedBB.getAABBPool().getAABB( xOff + (double) 0.15, yOff + (double) 0.15, zOff + (double) 0.15,// ahh
|
out.add( AxisAlignedBB.getAABBPool().getAABB( xOff + (double) 0.15, yOff + (double) 0.15, zOff + (double) 0.15,// ahh
|
||||||
xOff + (double) 0.85, yOff + (double) 0.85, zOff + (double) 0.85 ) );
|
xOff + (double) 0.85, yOff + (double) 0.85, zOff + (double) 0.85 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresTESR()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -247,4 +247,10 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresTESR()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -298,4 +298,11 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
|||||||
{
|
{
|
||||||
return cb.isEmpty();
|
return cb.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresTESR()
|
||||||
|
{
|
||||||
|
return cb.requiresDynamicRender;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user