fluid storage bus handler cache tweaks and simplify energy cache
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@ aechannel=stable
|
|||||||
aebuild=7
|
aebuild=7
|
||||||
aegroup=appeng
|
aegroup=appeng
|
||||||
aebasename=appliedenergistics2
|
aebasename=appliedenergistics2
|
||||||
trousers=omni-fixes-v46q
|
trousers=omni-fixes-v46r
|
||||||
|
|
||||||
#########################################################
|
#########################################################
|
||||||
# Versions #
|
# Versions #
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
|||||||
{
|
{
|
||||||
this.resetCacheLogic = 2;
|
this.resetCacheLogic = 2;
|
||||||
}
|
}
|
||||||
else
|
else if( this.resetCacheLogic < 2 )
|
||||||
{
|
{
|
||||||
this.resetCacheLogic = 1;
|
this.resetCacheLogic = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-86
@@ -156,29 +156,15 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
{
|
{
|
||||||
case PROVIDE_POWER:
|
case PROVIDE_POWER:
|
||||||
if( ev.storage.getPowerFlow() != AccessRestriction.WRITE )
|
if( ev.storage.getPowerFlow() != AccessRestriction.WRITE )
|
||||||
{
|
|
||||||
if( !ongoingExtractOperation )
|
|
||||||
{
|
|
||||||
addProvider( ev.storage );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
this.providersToAdd.add( ev.storage );
|
this.providersToAdd.add( ev.storage );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case REQUEST_POWER:
|
case REQUEST_POWER:
|
||||||
if( ev.storage.getPowerFlow() != AccessRestriction.READ )
|
if( ev.storage.getPowerFlow() != AccessRestriction.READ )
|
||||||
{
|
|
||||||
if( !ongoingInjectOperation )
|
|
||||||
{
|
|
||||||
addRequester( ev.storage );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
this.requestersToAdd.add( ev.storage );
|
this.requestersToAdd.add( ev.storage );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -497,8 +483,12 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getStoredPower()
|
public double getStoredPower()
|
||||||
|
{
|
||||||
|
if( this.availableTicksSinceUpdate > 90 )
|
||||||
{
|
{
|
||||||
this.refreshPower();
|
this.refreshPower();
|
||||||
|
}
|
||||||
|
|
||||||
return Math.max( 0.0, this.globalAvailablePower );
|
return Math.max( 0.0, this.globalAvailablePower );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -571,24 +561,10 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
this.globalMaxPower -= ps.getAEMaxPower();
|
this.globalMaxPower -= ps.getAEMaxPower();
|
||||||
this.globalAvailablePower -= ps.getAECurrentPower();
|
this.globalAvailablePower -= ps.getAECurrentPower();
|
||||||
}
|
}
|
||||||
if( !ongoingExtractOperation )
|
|
||||||
{
|
|
||||||
removeProvider( ps );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.providersToRemove.add( ps );
|
this.providersToRemove.add( ps );
|
||||||
}
|
|
||||||
if( !ongoingInjectOperation )
|
|
||||||
{
|
|
||||||
removeRequester( ps );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.requestersToRemove.add( ps );
|
this.requestersToRemove.add( ps );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if( machine instanceof IEnergyWatcherHost )
|
if( machine instanceof IEnergyWatcherHost )
|
||||||
{
|
{
|
||||||
@@ -602,50 +578,6 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addRequester(IAEPowerStorage requester) {
|
|
||||||
Preconditions.checkState(!ongoingInjectOperation,
|
|
||||||
"Cannot modify energy requesters while energy is being injected.");
|
|
||||||
if( requester instanceof GridPowerStorage )
|
|
||||||
{
|
|
||||||
requesters.put( 0, requester );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
requesters.put( 1, requester );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removeRequester(IAEPowerStorage requester) {
|
|
||||||
Preconditions.checkState(!ongoingInjectOperation,
|
|
||||||
"Cannot modify energy requesters while energy is being injected.");
|
|
||||||
if( requester != localStorage )
|
|
||||||
{
|
|
||||||
requesters.remove( 1, requester );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addProvider(IAEPowerStorage provider) {
|
|
||||||
Preconditions.checkState(!ongoingExtractOperation,
|
|
||||||
"Cannot modify energy providers while energy is being extracted.");
|
|
||||||
if( provider instanceof GridPowerStorage )
|
|
||||||
{
|
|
||||||
providers.put( 1, provider );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
providers.put( 0, provider );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removeProvider(IAEPowerStorage provider)
|
|
||||||
{
|
|
||||||
Preconditions.checkState( !ongoingExtractOperation, "Cannot modify energy providers while energy is being extracted." );
|
|
||||||
if( provider != localStorage )
|
|
||||||
{
|
|
||||||
providers.remove( 0, provider );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addNode( final IGridNode node, final IGridHost machine )
|
public void addNode( final IGridNode node, final IGridHost machine )
|
||||||
{
|
{
|
||||||
@@ -677,29 +609,15 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
if( current > 0 && ps.getPowerFlow() != AccessRestriction.WRITE )
|
if( current > 0 && ps.getPowerFlow() != AccessRestriction.WRITE )
|
||||||
{
|
{
|
||||||
this.globalAvailablePower += current;
|
this.globalAvailablePower += current;
|
||||||
if( !ongoingExtractOperation )
|
|
||||||
{
|
|
||||||
addProvider( ps );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.providersToAdd.add( ps );
|
this.providersToAdd.add( ps );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if( current < max && ps.getPowerFlow() != AccessRestriction.READ )
|
if( current < max && ps.getPowerFlow() != AccessRestriction.READ )
|
||||||
{
|
|
||||||
if( !ongoingInjectOperation )
|
|
||||||
{
|
|
||||||
addRequester( ps );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
this.requestersToAdd.add( ps );
|
this.requestersToAdd.add( ps );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if( machine instanceof IEnergyWatcherHost )
|
if( machine instanceof IEnergyWatcherHost )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,8 +23,13 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import appeng.api.config.AccessRestriction;
|
import appeng.api.config.AccessRestriction;
|
||||||
|
import appeng.fluids.parts.PartFluidInterface;
|
||||||
|
import appeng.fluids.tile.TileFluidInterface;
|
||||||
|
import appeng.tile.misc.TileInterface;
|
||||||
|
import appeng.tile.networking.TileCableBus;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
|
||||||
@@ -160,10 +165,30 @@ public abstract class PartSharedStorageBus extends PartUpgradeable implements IG
|
|||||||
public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor )
|
public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor )
|
||||||
{
|
{
|
||||||
if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) )
|
if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) )
|
||||||
|
{
|
||||||
|
|
||||||
|
final TileEntity te = w.getTileEntity( neighbor );
|
||||||
|
|
||||||
|
// In case the TE was destroyed, we have to do a full reset immediately.
|
||||||
|
if( te instanceof TileCableBus )
|
||||||
|
{
|
||||||
|
if( ( (TileCableBus) te ).getPart( this.getSide().getOpposite() ) instanceof PartFluidInterface )
|
||||||
|
{
|
||||||
|
this.resetCache( true );
|
||||||
|
this.resetCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( te == null || te instanceof TileFluidInterface )
|
||||||
|
{
|
||||||
|
this.resetCache( true );
|
||||||
|
this.resetCache();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
this.resetCache( false );
|
this.resetCache( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT( final NBTTagCompound data )
|
public void readFromNBT( final NBTTagCompound data )
|
||||||
|
|||||||
Reference in New Issue
Block a user