Skip to content

Commit

Permalink
Pass handler to clientside ConfigurationPacketHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
apple502j committed Sep 8, 2023
1 parent 3bafade commit 5038f42
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ public void receive(MinecraftClient client, ClientConfigurationNetworkHandler ne
// Normally, packets are handled on the network IO thread - though it is
// not guaranteed (for example, with 1.19.4 S2C packet bundling)
// Since we're handling it right now, connection check is redundant.
handler.receive(packet, sender);
handler.receive(packet, networkHandler, sender);
} else {
client.execute(() -> {
if (((ClientCommonNetworkHandlerAccessor) networkHandler).getConnection().isOpen()) handler.receive(packet, sender);
if (((ClientCommonNetworkHandlerAccessor) networkHandler).getConnection().isOpen()) handler.receive(packet, networkHandler, sender);
});
}
}
Expand Down Expand Up @@ -218,10 +218,10 @@ public void receive(MinecraftClient client, ClientConfigurationNetworkHandler ne
// Normally, packets are handled on the network IO thread - though it is
// not guaranteed (for example, with 1.19.4 S2C packet bundling)
// Since we're handling it right now, connection check is redundant.
handler.receive(packet, sender);
handler.receive(packet, networkHandler, sender);
} else {
client.execute(() -> {
if (((ClientCommonNetworkHandlerAccessor) networkHandler).getConnection().isOpen()) handler.receive(packet, sender);
if (((ClientCommonNetworkHandlerAccessor) networkHandler).getConnection().isOpen()) handler.receive(packet, networkHandler, sender);
});
}
}
Expand Down Expand Up @@ -451,9 +451,10 @@ public interface ConfigurationPacketHandler<T extends FabricPacket> {
*
*
* @param packet the packet
* @param networkHandler the network handler
* @param responseSender the packet sender
* @see FabricPacket
*/
void receive(T packet, PacketSender responseSender);
void receive(T packet, ClientConfigurationNetworkHandler networkHandler, PacketSender responseSender);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
public class NetworkingConfigurationClientTest implements ClientModInitializer {
@Override
public void onInitializeClient() {
ClientConfigurationNetworking.registerGlobalReceiver(NetworkingConfigurationTest.ConfigurationPacket.PACKET_TYPE, (packet, responseSender) -> {
ClientConfigurationNetworking.registerGlobalReceiver(NetworkingConfigurationTest.ConfigurationPacket.PACKET_TYPE, (packet, handler, responseSender) -> {
// Handle stuff here

// Respond back to the server that the task is complete
Expand Down

0 comments on commit 5038f42

Please sign in to comment.