Events/Connection/minified-events

OfflineEvent

Gets fired when no connection could be resolved

When it fires

OfflineEvent fires whenever the connectivity check started by CheckConnectionEvent comes back negative, i.e. when NetworkUtil.ensureOnline(...) throws NoConnectionException. Just like CheckConnectionEvent, this happens in two places:

  1. In Launcher.launchMinecraft(), if this fires, the launch continues in offline mode: no Forge/NeoForge installation step runs, and the client JAR download is skipped in favor of a cached copy. If no cached client JAR exists in that case, OfflineModeNeedsNetworkException is thrown instead.
  2. In ClientDownloader.downloadClient(), if this fires there, the download is aborted immediately (the method returns without downloading anything).

Note that NetworkUtil.ensureOnline(...) itself never posts these events, it only throws. It's the calling code (Launcher, ClientDownloader) that translates the check into CheckConnectionEvent/OfflineEvent. If you call NetworkUtil.ensureOnline(...) directly in your own code, you won't get this event automatically; you'd need to post it yourself.

eventBus.subscribe(OfflineEvent.class, event -> {
    System.out.println("No connection - launching offline");
});

Listening

Subscribe on the EventBus the event is posted to, see Events for which bus that is.

eventBus.subscribe(OfflineEvent.class, event -> {
    // react to the event
});

Posted by

API reference: com.dervarex.minified.events.type.connection.OfflineEvent