/** * refresh current stored power. */ private void refreshPower() { this.availableTicksSinceUpdate = 0; this.globalAvailablePower = 0; for( final IAEPowerStorage p : this.providers ) { this.globalAvailablePower += p.getAECurrentPower(); } }
public void post( final EnergyGridCache energyGridCache ) { this.watcherHost.onThresholdPass( energyGridCache ); }
private static boolean isPowered( final IGrid grid ) { if( grid == null ) { return false; } final IEnergyGrid eg = grid.getCache( IEnergyGrid.class ); return eg.isNetworkPowered(); }
protected void updatePowerStatus() { try { if( this.networkNode != null ) { this.setPowered( this.networkNode.isActive() ); } else if( this.getPowerSource() instanceof IEnergyGrid ) { this.setPowered( ( (IEnergyGrid) this.getPowerSource() ).isNetworkPowered() ); } else { this.setPowered( this.getPowerSource().extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.8 ); } } catch( final Throwable t ) { // :P } }
@Override public double extractAEPower( final double amt, final Actionable mode, final PowerMultiplier usePowerMultiplier ) { if( this.node.isActive() ) { return this.realSrc.extractAEPower( amt, mode, usePowerMultiplier ); } return 0.0; } }
@Override public void onThresholdPass( final IEnergyGrid energyGrid ) { this.lastReportedValue = (long) energyGrid.getStoredPower(); this.updateState(); }
/** * Called on server to transfer information from server to client. * <p/> * If the {@link net.minecraft.tileentity.TileEntity} is a {@link appeng.api.networking.energy.IAEPowerStorage}, it * writes the power information to the {@code #tag} using the {@code #ID_CURRENT_POWER} key. * * @param player player looking at the power storage * @param te power storage * @param tag transferred tag which is send to the client * @param world world of the power storage * @param pos pos of the power storage * * @return tag send to the client */ @Override public NBTTagCompound getNBTData( EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos ) { if( te instanceof IAEPowerStorage ) { final IAEPowerStorage storage = (IAEPowerStorage) te; if( storage.getAEMaxPower() > 0 ) { final long internalCurrentPower = (long) ( 100 * storage.getAECurrentPower() ); tag.setLong( ID_CURRENT_POWER, internalCurrentPower ); } } return tag; }
private int userPower( final int ticksPassed, final int bonusValue, final double acceleratorTax ) { try { return (int) ( this.getProxy() .getEnergy() .extractAEPower( ticksPassed * bonusValue * acceleratorTax, Actionable.MODULATE, PowerMultiplier.CONFIG ) / acceleratorTax ); } catch( final GridAccessException e ) { return 0; } }
@Override protected double getFunnelPowerDemand( final double maxRequired ) { try { final IEnergyGrid grid = this.getProxy().getEnergy(); return grid.getEnergyDemand( maxRequired ); } catch( final GridAccessException e ) { return this.getInternalMaxPower(); } }
@Override protected double funnelPowerIntoStorage( final double power, final Actionable mode ) { try { final IEnergyGrid grid = this.getProxy().getEnergy(); final double leftOver = grid.injectPower( power, mode ); return leftOver; } catch( final GridAccessException e ) { return super.funnelPowerIntoStorage( power, mode ); } }
public boolean isPowered() { try { return this.getEnergy().isNetworkPowered(); } catch( final GridAccessException e ) { return false; } }
protected void updatePowerStatus() { try { if( this.networkNode != null ) { this.setPowered( this.networkNode.isActive() ); } else if( this.getPowerSource() instanceof IEnergyGrid ) { this.setPowered( ( (IEnergyGrid) this.getPowerSource() ).isNetworkPowered() ); } else { this.setPowered( this.getPowerSource().extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.8 ); } } catch( final Exception ignore ) { // :P } }
protected void queueTunnelDrain( final PowerUnits unit, final double f ) { final double ae_to_tax = unit.convertTo( PowerUnits.AE, f * AEConfig.TUNNEL_POWER_LOSS ); try { this.getProxy().getEnergy().extractAEPower( ae_to_tax, Actionable.MODULATE, PowerMultiplier.ONE ); } catch( final GridAccessException e ) { // :P } }
@Override protected double getFunnelPowerDemand( final double maxReceived ) { try { final IEnergyGrid grid = this.getProxy().getEnergy(); return grid.getEnergyDemand( maxReceived ); } catch( final GridAccessException e ) { // no grid? use local... return super.getFunnelPowerDemand( maxReceived ); } }
@Override protected double funnelPowerIntoStorage( final double power, final Actionable mode ) { try { final IEnergyGrid grid = this.getProxy().getEnergy(); final double leftOver = grid.injectPower( power, mode ); return leftOver; } catch( final GridAccessException e ) { // no grid? use local... return super.funnelPowerIntoStorage( power, mode ); } }
public boolean isPowered() { if( Platform.isClient() ) { return ( this.constructed & this.powered ) == this.powered && this.constructed != -1; } try { return this.getProxy().getEnergy().isNetworkPowered(); } catch( final GridAccessException e ) { // :P } return false; }
private void updatePowerState() { boolean newState = false; try { newState = this.getProxy().isActive() && this.getProxy().getEnergy().extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.0001; } catch( final GridAccessException ignored ) { } if( newState != this.isPowered ) { this.isPowered = newState; this.markForUpdate(); } }
@Override public boolean isPowered() { if( Platform.isServer() ) { try { return this.getProxy().getEnergy().isNetworkPowered(); } catch( final GridAccessException e ) { return false; } } return this.hasPower; }
@Override public boolean isActive() { final IGrid g = this.getGrid(); if( g != null ) { final IPathingGrid pg = g.getCache( IPathingGrid.class ); final IEnergyGrid eg = g.getCache( IEnergyGrid.class ); return eg.isNetworkPowered() && !pg.isNetworkBooting() && this.meetsChannelRequirements(); } return false; }
@Override public void writeToStream( final ByteBuf data ) throws IOException { super.writeToStream( data ); try { data.writeBoolean( this.getProxy().getEnergy().isNetworkPowered() ); } catch( final GridAccessException e ) { data.writeBoolean( false ); } }