mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-23 08:08:02 -05:00
send c:register
packet for play phase instead of config (#3544)
This commit is contained in:
parent
31787236d2
commit
2e5ac54849
3 changed files with 9 additions and 3 deletions
|
@ -25,6 +25,7 @@ import net.minecraft.server.network.ServerPlayerConfigurationTask;
|
|||
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerConfigurationConnectionEvents;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerConfigurationNetworking;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||
import net.fabricmc.fabric.impl.networking.server.ServerConfigurationNetworkAddon;
|
||||
import net.fabricmc.fabric.impl.networking.server.ServerNetworkingImpl;
|
||||
|
||||
|
@ -95,7 +96,7 @@ public class CommonPacketsImpl {
|
|||
|
||||
@Override
|
||||
public void sendPacket(Consumer<Packet<?>> sender) {
|
||||
addon.sendPacket(addon.createRegisterPayload());
|
||||
addon.sendPacket(new CommonRegisterPayload(addon.getNegotiatedVersion(), CommonRegisterPayload.PLAY_PHASE, ServerPlayNetworking.getGlobalReceivers()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.UUID;
|
|||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.network.listener.ClientPlayPacketListener;
|
||||
|
@ -43,6 +44,7 @@ import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
|||
import net.fabricmc.fabric.api.networking.v1.FabricPacket;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketType;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||
import net.fabricmc.fabric.test.networking.NetworkingTestmods;
|
||||
|
||||
|
@ -133,6 +135,10 @@ public final class NetworkingPlayPacketTest implements ModInitializer {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
||||
Validate.isTrue(ServerPlayNetworking.canSend(handler, OverlayPacket.PACKET_TYPE));
|
||||
});
|
||||
}
|
||||
|
||||
public record OverlayPacket(Text message) implements FabricPacket {
|
||||
|
|
|
@ -25,7 +25,6 @@ import net.minecraft.util.Identifier;
|
|||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
|
||||
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketSender;
|
||||
|
@ -37,7 +36,7 @@ public final class NetworkingPlayPacketClientTest implements ClientModInitialize
|
|||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
ClientPlayConnectionEvents.INIT.register((handler, client) -> ClientPlayNetworking.registerReceiver(NetworkingPlayPacketTest.OverlayPacket.PACKET_TYPE, this));
|
||||
ClientPlayNetworking.registerGlobalReceiver(NetworkingPlayPacketTest.OverlayPacket.PACKET_TYPE, this);
|
||||
|
||||
ClientCommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> dispatcher.register(
|
||||
ClientCommandManager.literal("clientnetworktestcommand")
|
||||
|
|
Loading…
Reference in a new issue