Package net.minecraft.network.listener
Interface PacketListener
- All Known Subinterfaces:
ClientLoginPacketListener,ClientPlayPacketListener,ClientQueryPacketListener,ServerHandshakePacketListener,ServerLoginPacketListener,ServerPacketListener,ServerPlayPacketListener,ServerQueryPacketListener
- All Known Implementing Classes:
ClientLoginNetworkHandler,ClientPlayNetworkHandler,LocalServerHandshakeNetworkHandler,ServerHandshakeNetworkHandler,ServerLoginNetworkHandler,ServerPlayNetworkHandler,ServerQueryNetworkHandler
public interface PacketListener
A packet listener listens to packets on a connection.
Its listener methods will be called on the netty event loop than the client or server game engine threads.
- Mappings:
Namespace Name official qbintermediary net/minecraft/class_2547named net/minecraft/network/listener/PacketListener
-
Method Summary
Modifier and TypeMethodDescriptionReturns the connection this packet listener intends to listen to.voidonDisconnected(Text reason) Called when the connection this listener listens to has disconnected.default booleanReturns whether uncaught exceptions in main thread should crash the game instead of logging and ignoring them.
-
Method Details
-
onDisconnected
Called when the connection this listener listens to has disconnected. Can be used to display the disconnection reason.- Parameters:
reason- the reason of disconnection; may be a generic message- Mappings:
Namespace Name Mixin selector official aLqb;a(Lqk;)Vintermediary method_10839Lnet/minecraft/class_2547;method_10839(Lnet/minecraft/class_2561;)Vnamed onDisconnectedLnet/minecraft/network/listener/PacketListener;onDisconnected(Lnet/minecraft/text/Text;)V
-
getConnection
ClientConnection getConnection()Returns the connection this packet listener intends to listen to.- See Also:
- API Note:
- The returned connection may or may not have this listener as its current packet listener.
- Mappings:
Namespace Name Mixin selector official aLqb;a()Lpw;intermediary method_2872Lnet/minecraft/class_2547;method_2872()Lnet/minecraft/class_2535;named getConnectionLnet/minecraft/network/listener/PacketListener;getConnection()Lnet/minecraft/network/ClientConnection;
-
shouldCrashOnException
default boolean shouldCrashOnException()Returns whether uncaught exceptions in main thread should crash the game instead of logging and ignoring them.- Returns:
- whether uncaught exceptions in main thread should crash the game instead of logging and ignoring them
- See Also:
- API Note:
- This only affects the processing on the main thread done by calling
methods in
NetworkThreadUtils. Uncaught exceptions in other threads or processing in the main thread using theclient.execute(() -> {})code will be unaffected, and always gets logged without crashing. - Implementation Note:
- This is
trueby default. - Mappings:
Namespace Name Mixin selector official bLqb;b()Zintermediary method_40065Lnet/minecraft/class_2547;method_40065()Znamed shouldCrashOnExceptionLnet/minecraft/network/listener/PacketListener;shouldCrashOnException()Z
-