Table of Contents

Interface IClientNetworkAPI

Namespace
Vintagestory.API.Client
Assembly
VintagestoryAPI.dll

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

public interface IClientNetworkAPI : INetworkAPI

Methods

GetChannel(string)

Returns a previoulsy registered channeled, null otherwise

IClientNetworkChannel GetChannel(string channelName)

Parameters

channelName string

Returns

IClientNetworkChannel

GetChannelState(string)

Check in what state a channel currently is in

EnumChannelState GetChannelState(string channelName)

Parameters

channelName string

Returns

EnumChannelState

RegisterChannel(string)

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

IClientNetworkChannel RegisterChannel(string channelName)

Parameters

channelName string

Unique channel identifier

Returns

IClientNetworkChannel

SendArbitraryPacket(byte[])

Sends given packet data to the server. This let's you mess with the raw network communication and fiddle with internal engine packets if you know the protocol. For normal network communication you probably want to register your own network channel.

void SendArbitraryPacket(byte[] data)

Parameters

data byte[]

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

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

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

Parameters

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

SendBlockEntityPacket(int, int, int, object)

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

void SendBlockEntityPacket(int x, int y, int z, object internalPacket)

Parameters

x int
y int
z int
internalPacket object

SendBlockEntityPacket(BlockPos, int, byte[])

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

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

Parameters

pos BlockPos
packetId int
data byte[]

SendBlockEntityPacket<T>(BlockPos, int, T)

Sends a blockentity interaction packet to the server. For quick an easy blockentity network communication without setting up a channel first. Uses Protobuf.net to serialize your data

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

Parameters

pos BlockPos
packetId int
data T

Type Parameters

T

SendEntityPacket(long, int, byte[])

Sends a entity interaction packet to the server. For quick an easy entity network communication without setting up a channel first.

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

Parameters

entityid long
packetId int
data byte[]

SendEntityPacket(long, object)

Sends a entity interaction packet to the server. For quick an easy entity network communication without setting up a channel first.

void SendEntityPacket(long entityid, object internalPacket)

Parameters

entityid long
internalPacket object

SendHandInteraction(int, BlockSelection, EntitySelection, EnumHandInteract, int, bool, EnumItemUseCancelReason)

Sends the current hand interaction.

void SendHandInteraction(int mouseButton, BlockSelection blockSelection, EntitySelection entitySelection, EnumHandInteract beforeUseType, int state, bool firstEvent, EnumItemUseCancelReason cancelReason)

Parameters

mouseButton int

the current mouse button press

blockSelection BlockSelection

the currently selected Block (if there is one)

entitySelection EntitySelection

the currently selected Entity (if there is one)

beforeUseType EnumHandInteract
state int

The state of the hand.

firstEvent bool

Is it the first of this events for this block? (by default the client calls the interaction every second while the player holds down the right mouse button)

cancelReason EnumItemUseCancelReason

The reason we cancelled the use of an item (if there is one)

SendPacketClient(object)

Sends given packet to server. For use with inventory supplied network packets only, since the packet format is not exposed to the api

void SendPacketClient(object packetClient)

Parameters

packetClient object

The network packet to send.

SendPlayerNowReady()

If any mod denies the client event IsPlayerReady, then it has to call this method once to indicate that the player is now ready to play (which switches the server side client state from Connected to Playing)

void SendPlayerNowReady()