/** * refresh current stored power. */ private void refreshPower() { this.availableTicksSinceUpdate = 0; this.globalAvailablePower = 0; for( final IAEPowerStorage p : this.providers ) { this.globalAvailablePower += p.getAECurrentPower(); } }
@Override public double getProviderEnergyDemand( final double maxRequired ) { double required = 0; final Iterator<IAEPowerStorage> it = this.requesters.iterator(); while( required < maxRequired && it.hasNext() ) { final IAEPowerStorage node = it.next(); if( node.getPowerFlow() != AccessRestriction.READ ) { required += Math.max( 0.0, node.getAEMaxPower() - node.getAECurrentPower() ); } } return required; }
/** * 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; }
this.globalAvailablePower -= ps.getAECurrentPower();
@Override public void addProbeInfo( AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data ) { if( tile instanceof IAEPowerStorage ) { final IAEPowerStorage storage = (IAEPowerStorage) tile; final double maxPower = storage.getAEMaxPower(); if( maxPower > 0 ) { final long internalCurrentPower = (long) ( storage.getAECurrentPower() * 100 ); if( internalCurrentPower >= 0 ) { final long internalMaxPower = (long) ( 100 * maxPower ); final String formatCurrentPower = Platform.formatPowerLong( internalCurrentPower, false ); final String formatMaxPower = Platform.formatPowerLong( internalMaxPower, false ); final String formattedString = String.format( TheOneProbeText.STORED_ENERGY.getLocal(), formatCurrentPower, formatMaxPower ); probeInfo.text( formattedString ); } } } }
final double current = ps.getAECurrentPower();
this.outputMsg( player, "Energy: " + ps.getAECurrentPower() + " / " + ps.getAEMaxPower() );