Search in sources :

Example 1 with PacketListener

use of net.minecraft.network.PacketListener in project pollen by MoonflowerTeam.

the class PollinatedFabricLoginChannel method processClient.

private CompletableFuture<@Nullable FriendlyByteBuf> processClient(Minecraft client, PacketListener listener, FriendlyByteBuf data, Consumer<GenericFutureListener<? extends Future<? super Void>>> listenerAdder) {
    CompletableFuture<FriendlyByteBuf> future = new CompletableFuture<>();
    NetworkRegistry.processMessage(this.deserialize(data, PollinatedPacketDirection.LOGIN_CLIENTBOUND), new PollinatedFabricLoginPacketContext(pkt -> {
        try {
            future.complete(this.serialize(pkt, PollinatedPacketDirection.LOGIN_SERVERBOUND));
        } catch (Throwable t) {
            t.printStackTrace();
            future.completeExceptionally(t);
        }
    }, listener.getConnection(), __ -> {
    }, PollinatedPacketDirection.LOGIN_CLIENTBOUND), this.clientMessageHandler.get().get());
    return future;
}
Also used : FriendlyByteBuf(net.minecraft.network.FriendlyByteBuf) FabricLoader(net.fabricmc.loader.api.FabricLoader) ResourceLocation(net.minecraft.resources.ResourceLocation) PollinatedLoginNetworkChannel(gg.moonflower.pollen.api.network.PollinatedLoginNetworkChannel) PacketSender(net.fabricmc.fabric.api.networking.v1.PacketSender) NetworkRegistry(gg.moonflower.pollen.api.registry.NetworkRegistry) PollinatedLoginPacket(gg.moonflower.pollen.api.network.packet.login.PollinatedLoginPacket) CompletableFuture(java.util.concurrent.CompletableFuture) FriendlyByteBuf(net.minecraft.network.FriendlyByteBuf) Function(java.util.function.Function) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) PacketDeserializer(gg.moonflower.pollen.api.network.PacketDeserializer) MinecraftServer(net.minecraft.server.MinecraftServer) Pair(org.apache.commons.lang3.tuple.Pair) Minecraft(net.minecraft.client.Minecraft) EnvType(net.fabricmc.api.EnvType) ClientboundCustomQueryPacketAccessor(gg.moonflower.pollen.core.mixin.client.ClientboundCustomQueryPacketAccessor) ClientLoginNetworking(net.fabricmc.fabric.api.client.networking.v1.ClientLoginNetworking) ApiStatus(org.jetbrains.annotations.ApiStatus) PollinatedPacket(gg.moonflower.pollen.api.network.packet.PollinatedPacket) ServerLoginPacketListenerImplExtension(gg.moonflower.pollen.core.extensions.fabric.ServerLoginPacketListenerImplExtension) ClientPlayNetworking(net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking) PollinatedFabricLoginPacketContext(gg.moonflower.pollen.api.network.fabric.context.PollinatedFabricLoginPacketContext) PacketListener(net.minecraft.network.PacketListener) ServerboundCustomQueryPacket(net.minecraft.network.protocol.login.ServerboundCustomQueryPacket) GenericFutureListener(io.netty.util.concurrent.GenericFutureListener) PollinatedPacketDirection(gg.moonflower.pollen.api.network.packet.PollinatedPacketDirection) ServerLoginConnectionEvents(net.fabricmc.fabric.api.networking.v1.ServerLoginConnectionEvents) PollinatedFabricPacketContext(gg.moonflower.pollen.api.network.fabric.context.PollinatedFabricPacketContext) Consumer(java.util.function.Consumer) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) ServerPlayNetworking(net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking) Packet(net.minecraft.network.protocol.Packet) Future(io.netty.util.concurrent.Future) ServerLoginNetworking(net.fabricmc.fabric.api.networking.v1.ServerLoginNetworking) ClientboundCustomQueryPacket(net.minecraft.network.protocol.login.ClientboundCustomQueryPacket) CompletableFuture(java.util.concurrent.CompletableFuture) PollinatedFabricLoginPacketContext(gg.moonflower.pollen.api.network.fabric.context.PollinatedFabricLoginPacketContext)

Aggregations

PacketDeserializer (gg.moonflower.pollen.api.network.PacketDeserializer)1 PollinatedLoginNetworkChannel (gg.moonflower.pollen.api.network.PollinatedLoginNetworkChannel)1 PollinatedFabricLoginPacketContext (gg.moonflower.pollen.api.network.fabric.context.PollinatedFabricLoginPacketContext)1 PollinatedFabricPacketContext (gg.moonflower.pollen.api.network.fabric.context.PollinatedFabricPacketContext)1 PollinatedPacket (gg.moonflower.pollen.api.network.packet.PollinatedPacket)1 PollinatedPacketDirection (gg.moonflower.pollen.api.network.packet.PollinatedPacketDirection)1 PollinatedLoginPacket (gg.moonflower.pollen.api.network.packet.login.PollinatedLoginPacket)1 NetworkRegistry (gg.moonflower.pollen.api.registry.NetworkRegistry)1 ServerLoginPacketListenerImplExtension (gg.moonflower.pollen.core.extensions.fabric.ServerLoginPacketListenerImplExtension)1 ClientboundCustomQueryPacketAccessor (gg.moonflower.pollen.core.mixin.client.ClientboundCustomQueryPacketAccessor)1 Future (io.netty.util.concurrent.Future)1 GenericFutureListener (io.netty.util.concurrent.GenericFutureListener)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 Supplier (java.util.function.Supplier)1 EnvType (net.fabricmc.api.EnvType)1 ClientLoginNetworking (net.fabricmc.fabric.api.client.networking.v1.ClientLoginNetworking)1