This commit is contained in:
modmuss 2023-08-13 16:01:02 +01:00 committed by modmuss50
parent e99023d84f
commit ae9c4c6acb
2 changed files with 4 additions and 3 deletions
fabric-networking-api-v1/src
main/java/net/fabricmc/fabric/mixin/networking
testmod/java/net/fabricmc/fabric/test/networking/play

View file

@ -94,7 +94,7 @@ abstract class ClientConnectionMixin implements ChannelInfoHolder {
}
}
@Inject(method = "sendInternal", at = @At(value = "INVOKE_ASSIGN", target = "Lio/netty/channel/Channel;writeAndFlush(Ljava/lang/Object;)Lio/netty/channel/ChannelFuture;", remap = false), locals = LocalCapture.CAPTURE_FAILHARD)
@Inject(method = "sendInternal", at = @At(value = "INVOKE_ASSIGN", target = "Lio/netty/channel/Channel;writeAndFlush(Ljava/lang/Object;)Lio/netty/channel/ChannelFuture;", remap = false), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
private void sendInternal(Packet<?> packet, @Nullable PacketCallbacks listener, NetworkState packetState, NetworkState currentState, CallbackInfo ci, ChannelFuture channelFuture) {
if (listener instanceof GenericFutureListenerHolder holder) {
channelFuture.addListener(holder.getDelegate());

View file

@ -45,8 +45,9 @@ public final class NetworkingPlayPacketTest implements ModInitializer {
public static final Identifier TEST_CHANNEL = NetworkingTestmods.id("test_channel");
public static void sendToTestChannel(ServerPlayerEntity player, String stuff) {
ServerPlayNetworking.send(player, new OverlayPacket(Text.literal(stuff)));
NetworkingTestmods.LOGGER.info("Sent custom payload packet in {}", TEST_CHANNEL);
ServerPlayNetworking.getSender(player).sendPacket(new OverlayPacket(Text.literal(stuff)), future -> {
NetworkingTestmods.LOGGER.info("Sent custom payload packet in {}", TEST_CHANNEL);
});
}
public static void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher) {