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

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(int, int, int, int, byte[])

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

void BroadcastBlockEntityPacket(int x, int y, int z, int packetId, byte[] data = null)

Parameters

x int
y int
z int
packetId int
data byte[]

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

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

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, int, int, int, 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, int x, int y, int z, int packetId, byte[] data = null)

Parameters

player IServerPlayer
x int
y int
z int
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[]