Package commonnetwork.api
Class Dispatcher
java.lang.Object
commonnetwork.api.Dispatcher
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> voidsend(T packet, net.minecraft.network.Connection connection) Sends the packet to the connection.static <T> voidsendToAllClients(T packet, net.minecraft.server.MinecraftServer server) Sends the packet to all the client players in the server, only if the players has the packet registered.static <T> voidsendToClient(T packet, net.minecraft.server.level.ServerPlayer player) Sends the packet to the client player, only if the player has the packet registered.static <T> voidsendToClients(T packet, List<net.minecraft.server.level.ServerPlayer> players) Sends the packet to the client players, only if the players has the packet registered.static <T> voidsendToClientsInLevel(T packet, net.minecraft.server.level.ServerLevel level) Sends the packet to all the client players in the level, only if the players has the packet registered.static <T> voidsendToClientsInRange(T packet, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos, double range) Sends the packet to all the client players in range of a position, only if the players has the packet registered.static <T> voidsendToClientsLoadingChunk(T packet, net.minecraft.world.level.chunk.LevelChunk chunk) Sends the packet to all the client players loading a chunk, only if the players has the packet registered.static <T> voidsendToClientsLoadingPos(T packet, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos) Sends the packet to all the client players loading a position, only if the players has the packet registered.static <T> voidsendToClientsLoadingPos(T packet, net.minecraft.server.level.ServerLevel level, net.minecraft.world.level.ChunkPos pos) Sends the packet to all the client players loading a position, only if the players has the packet registered.static <T> voidsendToServer(T packet) Sends the packet to the server, if the server has the packet registered.static <T> voidsendToServer(T packet, boolean ignoreCheck) Sends the packet to the server.
-
Constructor Details
-
Dispatcher
public Dispatcher()
-
-
Method Details
-
sendToServer
public static <T> void sendToServer(T packet) Sends the packet to the server, if the server has the packet registered.- Type Parameters:
T- - The type- Parameters:
packet- - the packet
-
sendToServer
public static <T> void sendToServer(T packet, boolean ignoreCheck) Sends the packet to the server. Can ignore the check if the server has the packet registered. Likely use case for this is talking to bukkit/spigot/paper servers.- Type Parameters:
T- - The type- Parameters:
packet- - the packetignoreCheck- - ignore the check if the server has the packet registered.
-
send
public static <T> void send(T packet, net.minecraft.network.Connection connection) Sends the packet to the connection.- Type Parameters:
T- - The packet- Parameters:
packet- - the packetconnection- - the connection
-
sendToClient
public static <T> void sendToClient(T packet, net.minecraft.server.level.ServerPlayer player) Sends the packet to the client player, only if the player has the packet registered.- Type Parameters:
T- - The type- Parameters:
packet- - the packetplayer- - the player
-
sendToClients
public static <T> void sendToClients(T packet, List<net.minecraft.server.level.ServerPlayer> players) Sends the packet to the client players, only if the players has the packet registered.- Type Parameters:
T- - The type- Parameters:
packet- - the packetplayers- - the players
-
sendToAllClients
public static <T> void sendToAllClients(T packet, net.minecraft.server.MinecraftServer server) Sends the packet to all the client players in the server, only if the players has the packet registered.- Type Parameters:
T- - The type- Parameters:
packet- - the packetserver- - the server
-
sendToClientsInLevel
public static <T> void sendToClientsInLevel(T packet, net.minecraft.server.level.ServerLevel level) Sends the packet to all the client players in the level, only if the players has the packet registered.- Type Parameters:
T- - The type- Parameters:
packet- - the packetlevel- - the level
-
sendToClientsLoadingChunk
public static <T> void sendToClientsLoadingChunk(T packet, net.minecraft.world.level.chunk.LevelChunk chunk) Sends the packet to all the client players loading a chunk, only if the players has the packet registered.- Type Parameters:
T- - The type- Parameters:
packet- - the packetchunk- - the chunk
-
sendToClientsLoadingPos
public static <T> void sendToClientsLoadingPos(T packet, net.minecraft.server.level.ServerLevel level, net.minecraft.world.level.ChunkPos pos) Sends the packet to all the client players loading a position, only if the players has the packet registered.- Type Parameters:
T- - The type- Parameters:
packet- - the packetlevel- - the levelpos- - the chunkpos
-
sendToClientsLoadingPos
public static <T> void sendToClientsLoadingPos(T packet, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos) Sends the packet to all the client players loading a position, only if the players has the packet registered.- Type Parameters:
T- - The type- Parameters:
packet- - the packetlevel- - the levelpos- - the blockpos
-
sendToClientsInRange
public static <T> void sendToClientsInRange(T packet, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos, double range) Sends the packet to all the client players in range of a position, only if the players has the packet registered.- Type Parameters:
T- - The type- Parameters:
packet- - the packetlevel- - the levelpos- - the blockposrange- - the range
-