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
- Extension Methods
Methods
GetChannel(string)
Returns a previously registered channel, null otherwise
IClientNetworkChannel GetChannel(string channelName)
Parameters
channelNamestring
Returns
GetChannelState(string)
Check in what state a channel currently is in
EnumChannelState GetChannelState(string channelName)
Parameters
channelNamestring
Returns
GetUdpChannel(string)
Returns a previously registered channel, null otherwise
IClientNetworkChannel GetUdpChannel(string channelName)
Parameters
channelNamestring
Returns
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
channelNamestringUnique channel identifier
Returns
RegisterUdpChannel(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. Do not send larger messages then 508 bytes since some clients may be behind NAT/firwalls that may drop your packets if they get fragmented
IClientNetworkChannel RegisterUdpChannel(string channelName)
Parameters
channelNamestringUnique channel identifier
Returns
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
databyte[]
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.
[Obsolete("Not dimension aware, use BlockPos overload instead, otherwise thie BlockEntity will probably not work correctly in other dimensions")]
void SendBlockEntityPacket(int x, int y, int z, int packetId, byte[] data = null)
Parameters
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
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
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
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
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
SendEntityPacketWithOffset(long, int, object)
Sends a entity interaction packet to the server. For quick an easy entity network communication without setting up a channel first.
void SendEntityPacketWithOffset(long entityid, int packetIdOffset, object internalPacket)
Parameters
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
mouseButtonintthe current mouse button press
blockSelectionBlockSelectionthe currently selected Block (if there is one)
entitySelectionEntitySelectionthe currently selected Entity (if there is one)
beforeUseTypeEnumHandInteractstateintThe state of the hand.
firstEventboolIs 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)
cancelReasonEnumItemUseCancelReasonThe 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
packetClientobjectThe network packet to send.
SendPlayerMountPositionPacket(Entity)
Sends a mount position via UDP (if possible) to the server
void SendPlayerMountPositionPacket(Entity mount)
Parameters
mountEntity
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()
SendPlayerPositionPacket()
Sends the players entity position (and Mount position) via UDP (if possible) to the server
void SendPlayerPositionPacket()