Search in sources :

Example 1 with ClientboundCustomPayloadPacketAccessor

use of org.spongepowered.common.accessor.network.protocol.game.ClientboundCustomPayloadPacketAccessor in project SpongeCommon by SpongePowered.

the class SpongeChannelManager method handlePlayPayload.

public boolean handlePlayPayload(final EngineConnection connection, final ClientboundCustomPayloadPacket packet) {
    final ClientboundCustomPayloadPacketAccessor accessor = (ClientboundCustomPayloadPacketAccessor) packet;
    final ResourceKey channel = (ResourceKey) (Object) accessor.accessor$identifier();
    final ChannelBuf payload = (ChannelBuf) accessor.accessor$data();
    return this.handlePlayPayload(connection, channel, payload);
}
Also used : ClientboundCustomPayloadPacketAccessor(org.spongepowered.common.accessor.network.protocol.game.ClientboundCustomPayloadPacketAccessor) ChannelBuf(org.spongepowered.api.network.channel.ChannelBuf) ResourceKey(org.spongepowered.api.ResourceKey)

Example 2 with ClientboundCustomPayloadPacketAccessor

use of org.spongepowered.common.accessor.network.protocol.game.ClientboundCustomPayloadPacketAccessor in project SpongeCommon by SpongePowered.

the class PacketUtil method createPlayPayload.

public static net.minecraft.network.protocol.Packet<?> createPlayPayload(final ResourceKey channel, final ChannelBuf payload, final EngineConnectionSide<?> side) {
    if (side == EngineConnectionSide.CLIENT) {
        final ServerboundCustomPayloadPacketAccessor packet = (ServerboundCustomPayloadPacketAccessor) new ServerboundCustomPayloadPacket();
        packet.accessor$identifier((ResourceLocation) (Object) channel);
        packet.accessor$data((FriendlyByteBuf) payload);
        return (net.minecraft.network.protocol.Packet<?>) packet;
    } else if (side == EngineConnectionSide.SERVER) {
        final ClientboundCustomPayloadPacketAccessor packet = (ClientboundCustomPayloadPacketAccessor) new ClientboundCustomPayloadPacket();
        packet.accessor$identifier((ResourceLocation) (Object) channel);
        packet.accessor$data((FriendlyByteBuf) payload);
        return (net.minecraft.network.protocol.Packet<?>) packet;
    } else {
        throw new UnsupportedOperationException();
    }
}
Also used : FriendlyByteBuf(net.minecraft.network.FriendlyByteBuf) ServerboundCustomQueryPacket(net.minecraft.network.protocol.login.ServerboundCustomQueryPacket) ClientboundCustomPayloadPacket(net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket) ServerboundCustomPayloadPacket(net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket) Packet(org.spongepowered.api.network.channel.packet.Packet) ClientboundCustomQueryPacket(net.minecraft.network.protocol.login.ClientboundCustomQueryPacket) ServerboundCustomPayloadPacketAccessor(org.spongepowered.common.accessor.network.protocol.game.ServerboundCustomPayloadPacketAccessor) ClientboundCustomPayloadPacket(net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket) ServerboundCustomPayloadPacket(net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket) ClientboundCustomPayloadPacketAccessor(org.spongepowered.common.accessor.network.protocol.game.ClientboundCustomPayloadPacketAccessor) ResourceLocation(net.minecraft.resources.ResourceLocation)

Aggregations

ClientboundCustomPayloadPacketAccessor (org.spongepowered.common.accessor.network.protocol.game.ClientboundCustomPayloadPacketAccessor)2 FriendlyByteBuf (net.minecraft.network.FriendlyByteBuf)1 ClientboundCustomPayloadPacket (net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket)1 ServerboundCustomPayloadPacket (net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket)1 ClientboundCustomQueryPacket (net.minecraft.network.protocol.login.ClientboundCustomQueryPacket)1 ServerboundCustomQueryPacket (net.minecraft.network.protocol.login.ServerboundCustomQueryPacket)1 ResourceLocation (net.minecraft.resources.ResourceLocation)1 ResourceKey (org.spongepowered.api.ResourceKey)1 ChannelBuf (org.spongepowered.api.network.channel.ChannelBuf)1 Packet (org.spongepowered.api.network.channel.packet.Packet)1 ServerboundCustomPayloadPacketAccessor (org.spongepowered.common.accessor.network.protocol.game.ServerboundCustomPayloadPacketAccessor)1