diff --git a/fabric-networking-api-v1/src/client/java/net/fabricmc/fabric/api/client/networking/v1/ClientConfigurationNetworking.java b/fabric-networking-api-v1/src/client/java/net/fabricmc/fabric/api/client/networking/v1/ClientConfigurationNetworking.java index 78a5dbe044..829a76d8a4 100644 --- a/fabric-networking-api-v1/src/client/java/net/fabricmc/fabric/api/client/networking/v1/ClientConfigurationNetworking.java +++ b/fabric-networking-api-v1/src/client/java/net/fabricmc/fabric/api/client/networking/v1/ClientConfigurationNetworking.java @@ -27,6 +27,7 @@ import net.minecraft.network.PacketByteBuf; import net.minecraft.network.listener.ServerCommonPacketListener; import net.minecraft.network.packet.Packet; +import net.minecraft.text.Text; import net.minecraft.util.Identifier; import net.minecraft.util.thread.ThreadExecutor; @@ -393,6 +394,14 @@ public static void send(T packet) { throw new IllegalStateException("Cannot send packet while not configuring!"); } + /** + * Disconnects from the server. + * @param handler the network handler + */ + public static void disconnect(ClientConfigurationNetworkHandler handler, Text reason) { + ((ClientCommonNetworkHandlerAccessor) handler).getConnection().disconnect(reason); + } + private ClientConfigurationNetworking() { }