use of org.spongepowered.common.accessor.network.protocol.game.ServerboundCustomPayloadPacketAccessor in project SpongeCommon by SpongePowered.
the class SpongeChannelManager method handlePlayPayload.
public boolean handlePlayPayload(final EngineConnection connection, final ServerboundCustomPayloadPacket packet) {
final ServerboundCustomPayloadPacketAccessor accessor = (ServerboundCustomPayloadPacketAccessor) packet;
final ResourceKey channel = (ResourceKey) (Object) accessor.accessor$identifier();
final ChannelBuf payload = (ChannelBuf) accessor.accessor$data();
return this.handlePlayPayload(connection, channel, payload);
}
use of org.spongepowered.common.accessor.network.protocol.game.ServerboundCustomPayloadPacketAccessor 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();
}
}
Aggregations