Table of Contents

Interface IServerNetworkAPI

Namespace
Vintagestory.API.Server
Assembly
VintagestoryAPI.dll

API Features to set up a network channel for custom server<->client data exchange. Server side.

public interface IServerNetworkAPI : INetworkAPI
Extension Methods

Methods

BroadcastArbitraryPacket(byte[], params IServerPlayer[])

Sends a packet data to everyone except given players.This let's you mess with the raw network communication if you know the protocol. Use with caution! For normal network communication you probably want to register your own network channel.

void BroadcastArbitraryPacket(byte[] data, params IServerPlayer[] exceptPlayers)

Parameters

data byte[]
exceptPlayers IServerPlayer[]

BroadcastBlockEntityPacket(BlockPos, int, byte[])

Broadcasts a blockentity packet to all connected players. For quick an easy network communication without setting up a channel first.

void BroadcastBlockEntityPacket(BlockPos pos, int packetId, byte[] data = null)

Parameters

pos BlockPos
packetId int
data byte[]

BroadcastBlockEntityPacket(BlockPos, int, byte[], params IServerPlayer[])

void BroadcastBlockEntityPacket(BlockPos pos, int packetId, byte[] data = null, params IServerPlayer[] skipPlayers)

Parameters

pos BlockPos
packetId int
data byte[]
skipPlayers IServerPlayer[]

BroadcastBlockEntityPacket<T>(BlockPos, int, T)

Broadcasts a blockentity packet to all connected players. For quick an easy network communication without setting up a channel first. Uses ProtoBuf.net to serialize the data.

void BroadcastBlockEntityPacket<T>(BlockPos pos, int packetId, T data = default)

Parameters

pos BlockPos
packetId int
data T

Type Parameters

T

BroadcastEntityPacket(long, int, byte[])

Sends a entity packet to all players in range. For quick an easy entity network communication without setting up a channel first.

void BroadcastEntityPacket(long entityid, int packetId, byte[] data = null)

Parameters

entityid long
packetId int
data byte[]

GetChannel(string)

Returns a previoulsy registered channeled, null otherwise

IServerNetworkChannel GetChannel(string channelName)

Parameters

channelName string

Returns

IServerNetworkChannel

GetUdpChannel(string)

Returns a previoulsy registered channeled, null otherwise

IServerNetworkChannel GetUdpChannel(string channelName)

Parameters

channelName string

Returns

IServerNetworkChannel

RegisterChannel(string)

Supplies you with your very own and personal network channel that you can use to send packets across the network. Use the same channelName on the client and server to have them link up.

IServerNetworkChannel RegisterChannel(string channelName)

Parameters

channelName string

Unique channel identifier

Returns

IServerNetworkChannel

RegisterUdpChannel(string)

Supplies you with your very own and personal network channel that you can use to send packets across the network. Use the same channelName on the client and server to have them link up.

IServerNetworkChannel RegisterUdpChannel(string channelName)

Parameters

channelName string

Unique channel identifier

Returns

IServerNetworkChannel

SendArbitraryPacket(byte[], params IServerPlayer[])

Sends a packet data to given players. This let's you mess with the raw network communication if you know the protocol. Use with caution! For normal network communication you probably want to register your own network channel.

void SendArbitraryPacket(byte[] data, params IServerPlayer[] players)

Parameters

data byte[]
players IServerPlayer[]

SendBlockEntityPacket(IServerPlayer, BlockPos, int, byte[])

Sends a blockentity packet to the given player. For quick an easy network communication without setting up a channel first.

void SendBlockEntityPacket(IServerPlayer player, BlockPos pos, int packetId, byte[] data = null)

Parameters

player IServerPlayer
pos BlockPos
packetId int
data byte[]

SendBlockEntityPacket<T>(IServerPlayer, BlockPos, int, T)

Sends a blockentity packet to the given player. For quick an easy network communication without setting up a channel first. Uses ProtoBuf.net to serialize the data.

void SendBlockEntityPacket<T>(IServerPlayer player, BlockPos pos, int packetId, T data = default)

Parameters

player IServerPlayer
pos BlockPos
packetId int
data T

Type Parameters

T

SendEntityPacket(IServerPlayer, long, int, byte[])

Sends a entity packet to the given player and entity. For quick an easy entity network communication without setting up a channel first.

void SendEntityPacket(IServerPlayer player, long entityid, int packetId, byte[] data = null)

Parameters

player IServerPlayer
entityid long
packetId int
data byte[]