Search in sources :

Example 1 with ClientboundCustomQueryPacketAccessor

use of org.spongepowered.common.accessor.network.protocol.login.ClientboundCustomQueryPacketAccessor in project SpongeCommon by SpongePowered.

the class SpongeChannelManager method handleLoginRequestPayload.

public boolean handleLoginRequestPayload(final EngineConnection connection, final ClientboundCustomQueryPacket packet) {
    // Server -> Client request
    final ClientboundCustomQueryPacketAccessor accessor = (ClientboundCustomQueryPacketAccessor) packet;
    final ResourceKey channel = (ResourceKey) (Object) accessor.accessor$identifier();
    final int transactionId = accessor.accessor$transactionId();
    final ChannelBuf payload = (ChannelBuf) accessor.accessor$data();
    try {
        return this.handleLoginRequestPayload(connection, channel, transactionId, payload);
    } finally {
        ChannelBuffers.release(payload);
    }
}
Also used : ClientboundCustomQueryPacketAccessor(org.spongepowered.common.accessor.network.protocol.login.ClientboundCustomQueryPacketAccessor) ChannelBuf(org.spongepowered.api.network.channel.ChannelBuf) ResourceKey(org.spongepowered.api.ResourceKey)

Example 2 with ClientboundCustomQueryPacketAccessor

use of org.spongepowered.common.accessor.network.protocol.login.ClientboundCustomQueryPacketAccessor in project SpongeCommon by SpongePowered.

the class PacketUtil method createLoginPayloadRequest.

public static net.minecraft.network.protocol.Packet<?> createLoginPayloadRequest(final ResourceKey channel, final ChannelBuf payload, final int transactionId) {
    final ClientboundCustomQueryPacket packet = new ClientboundCustomQueryPacket();
    final ClientboundCustomQueryPacketAccessor accessor = (ClientboundCustomQueryPacketAccessor) packet;
    accessor.accessor$identifier((ResourceLocation) (Object) channel);
    accessor.accessor$transactionId(transactionId);
    accessor.accessor$data((FriendlyByteBuf) payload);
    return packet;
}
Also used : ClientboundCustomQueryPacket(net.minecraft.network.protocol.login.ClientboundCustomQueryPacket) ClientboundCustomQueryPacketAccessor(org.spongepowered.common.accessor.network.protocol.login.ClientboundCustomQueryPacketAccessor)

Aggregations

ClientboundCustomQueryPacketAccessor (org.spongepowered.common.accessor.network.protocol.login.ClientboundCustomQueryPacketAccessor)2 ClientboundCustomQueryPacket (net.minecraft.network.protocol.login.ClientboundCustomQueryPacket)1 ResourceKey (org.spongepowered.api.ResourceKey)1 ChannelBuf (org.spongepowered.api.network.channel.ChannelBuf)1