Jump to content

[1.7.2]What's the event which is fired when the client disconnects from a server


Violet Crestfall

Recommended Posts

I think it's cpw.mods.fml.common.network.FMLNetworkEvent.ClientDisconnectionFromServerEvent.

But when I handle this event like this:

@SideOnly(Side.CLIENT)
public class VCCListener {

private boolean active = false;

@SubscribeEvent
public void onClientDisconnectionFromServer(ClientDisconnectionFromServerEvent event) {
	System.out.println("onClientDisconnectionFromServer");
	active = false;
}
}

And register the handler like this:

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
	listener = new VCCListener();
	MinecraftForge.EVENT_BUS.register(listener);
}

It doesn't work. I mean there's no output when I disconnect from a server.

So how to handle the client disconnection from server?

Link to comment
Share on other sites

It is a FML event, so you have to use the FML EventBus (FMLCommonHandler.instance().bus()). You can see if an Event is FML or Forge by looking at it's package.

So I should use FMLCommonHandler when handling a FML event and use MinecraftForge.EVENT_BUS when handling a Forge event?

Thanks very much!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.