public class NetworkRegistry
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
NetworkRegistry.ChannelBuilder
Builder for constructing network channels using a builder style API.
|
static class |
NetworkRegistry.LoginPayload
Tracks individual outbound messages for dispatch to clients during login handling.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ABSENT
Special value for clientAcceptedVersions and serverAcceptedVersions predicates indicating the other side lacks
this channel.
|
static java.lang.String |
ACCEPTVANILLA |
private static java.util.Map<ResourceLocation,NetworkInstance> |
instances |
private static boolean |
lock |
private static org.apache.logging.log4j.Logger |
LOGGER |
private static org.apache.logging.log4j.Marker |
NETREGISTRY |
| Constructor and Description |
|---|
NetworkRegistry() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
acceptsVanillaClientConnections() |
(package private) static java.util.Map<ResourceLocation,java.lang.String> |
buildChannelVersions()
Construct the Map representation of the channel list, for use during login handshaking
|
(package private) static java.util.Map<ResourceLocation,org.apache.commons.lang3.tuple.Pair<java.lang.String,java.lang.Boolean>> |
buildChannelVersionsForListPing()
Construct the Map representation of the channel list, for the client to check against during list ping
|
static boolean |
canConnectToVanillaServer() |
static boolean |
checkListPingCompatibilityForClient(java.util.Map<ResourceLocation,org.apache.commons.lang3.tuple.Pair<java.lang.String,java.lang.Boolean>> incoming) |
private static NetworkInstance |
createInstance(ResourceLocation name,
java.util.function.Supplier<java.lang.String> networkProtocolVersion,
java.util.function.Predicate<java.lang.String> clientAcceptedVersions,
java.util.function.Predicate<java.lang.String> serverAcceptedVersions)
Creates the internal
NetworkInstance that tracks the channel data. |
(package private) static java.util.Optional<NetworkInstance> |
findTarget(ResourceLocation resourceLocation)
Find the
NetworkInstance, if possible |
(package private) static java.util.List<NetworkRegistry.LoginPayload> |
gatherLoginPayloads(NetworkDirection direction,
boolean isLocal)
Retrieve the
NetworkRegistry.LoginPayload list for dispatch during FMLHandshakeHandler.tickLogin(NetworkManager) handling. |
static java.util.List<java.lang.String> |
getClientNonVanillaNetworkMods() |
static java.util.List<java.lang.String> |
getServerNonVanillaNetworkMods() |
boolean |
isLocked() |
(package private) static java.util.List<java.lang.String> |
listRejectedVanillaMods(java.util.function.BiFunction<NetworkInstance,java.lang.String,java.lang.Boolean> testFunction) |
static void |
lock() |
static EventNetworkChannel |
newEventChannel(ResourceLocation name,
java.util.function.Supplier<java.lang.String> networkProtocolVersion,
java.util.function.Predicate<java.lang.String> clientAcceptedVersions,
java.util.function.Predicate<java.lang.String> serverAcceptedVersions)
Create a new
EventNetworkChannel. |
static SimpleChannel |
newSimpleChannel(ResourceLocation name,
java.util.function.Supplier<java.lang.String> networkProtocolVersion,
java.util.function.Predicate<java.lang.String> clientAcceptedVersions,
java.util.function.Predicate<java.lang.String> serverAcceptedVersions)
Create a new
SimpleChannel. |
private static boolean |
validateChannels(java.util.Map<ResourceLocation,java.lang.String> incoming,
java.lang.String originName,
java.util.function.BiFunction<NetworkInstance,java.lang.String,java.lang.Boolean> testFunction)
Tests if the map matches with the supplied predicate tester
|
(package private) static boolean |
validateClientChannels(java.util.Map<ResourceLocation,java.lang.String> channels)
Validate the channels from the server on the client.
|
(package private) static boolean |
validateServerChannels(java.util.Map<ResourceLocation,java.lang.String> channels)
Validate the channels from the client on the server.
|
private static final org.apache.logging.log4j.Logger LOGGER
private static final org.apache.logging.log4j.Marker NETREGISTRY
private static java.util.Map<ResourceLocation,NetworkInstance> instances
public static java.lang.String ABSENT
public static java.lang.String ACCEPTVANILLA
private static boolean lock
public static java.util.List<java.lang.String> getServerNonVanillaNetworkMods()
public static java.util.List<java.lang.String> getClientNonVanillaNetworkMods()
public static boolean acceptsVanillaClientConnections()
public static boolean canConnectToVanillaServer()
public static SimpleChannel newSimpleChannel(ResourceLocation name, java.util.function.Supplier<java.lang.String> networkProtocolVersion, java.util.function.Predicate<java.lang.String> clientAcceptedVersions, java.util.function.Predicate<java.lang.String> serverAcceptedVersions)
SimpleChannel.name - The registry name for this channel. Must be uniquenetworkProtocolVersion - The network protocol version string that will be offered to the remote side NetworkRegistry.ChannelBuilder.networkProtocolVersion(Supplier)clientAcceptedVersions - Called on the client with the networkProtocolVersion string from the server NetworkRegistry.ChannelBuilder.clientAcceptedVersions(Predicate)serverAcceptedVersions - Called on the server with the networkProtocolVersion string from the client NetworkRegistry.ChannelBuilder.serverAcceptedVersions(Predicate)SimpleChannelnewSimpleChannel(ResourceLocation, Supplier, Predicate, Predicate)public static EventNetworkChannel newEventChannel(ResourceLocation name, java.util.function.Supplier<java.lang.String> networkProtocolVersion, java.util.function.Predicate<java.lang.String> clientAcceptedVersions, java.util.function.Predicate<java.lang.String> serverAcceptedVersions)
EventNetworkChannel.name - The registry name for this channel. Must be uniquenetworkProtocolVersion - The network protocol version string that will be offered to the remote side NetworkRegistry.ChannelBuilder.networkProtocolVersion(Supplier)clientAcceptedVersions - Called on the client with the networkProtocolVersion string from the server NetworkRegistry.ChannelBuilder.clientAcceptedVersions(Predicate)serverAcceptedVersions - Called on the server with the networkProtocolVersion string from the client NetworkRegistry.ChannelBuilder.serverAcceptedVersions(Predicate)EventNetworkChannelnewEventChannel(ResourceLocation, Supplier, Predicate, Predicate)private static NetworkInstance createInstance(ResourceLocation name, java.util.function.Supplier<java.lang.String> networkProtocolVersion, java.util.function.Predicate<java.lang.String> clientAcceptedVersions, java.util.function.Predicate<java.lang.String> serverAcceptedVersions)
NetworkInstance that tracks the channel data.name - registry namenetworkProtocolVersion - The protocol version stringclientAcceptedVersions - The client accepted predicateserverAcceptedVersions - The server accepted predicateNetworkInstancejava.lang.IllegalArgumentException - if the name already existsstatic java.util.Optional<NetworkInstance> findTarget(ResourceLocation resourceLocation)
NetworkInstance, if possibleresourceLocation - The network instance to lookupOptional NetworkInstancestatic java.util.Map<ResourceLocation,java.lang.String> buildChannelVersions()
static java.util.Map<ResourceLocation,org.apache.commons.lang3.tuple.Pair<java.lang.String,java.lang.Boolean>> buildChannelVersionsForListPing()
static java.util.List<java.lang.String> listRejectedVanillaMods(java.util.function.BiFunction<NetworkInstance,java.lang.String,java.lang.Boolean> testFunction)
static boolean validateClientChannels(java.util.Map<ResourceLocation,java.lang.String> channels)
channels - An @Map of name->version pairs for testingstatic boolean validateServerChannels(java.util.Map<ResourceLocation,java.lang.String> channels)
channels - An @Map of name->version pairs for testingprivate static boolean validateChannels(java.util.Map<ResourceLocation,java.lang.String> incoming, java.lang.String originName, java.util.function.BiFunction<NetworkInstance,java.lang.String,java.lang.Boolean> testFunction)
incoming - An @Map of name->version pairs for testingoriginName - A label for use in logging (where the version pairs came from)testFunction - The test function to use for testingstatic java.util.List<NetworkRegistry.LoginPayload> gatherLoginPayloads(NetworkDirection direction, boolean isLocal)
NetworkRegistry.LoginPayload list for dispatch during FMLHandshakeHandler.tickLogin(NetworkManager) handling.
Dispatches NetworkEvent.GatherLoginPayloadsEvent to each NetworkInstance.direction - the network direction for the request - only gathers for LOGIN_TO_CLIENTNetworkRegistry.LoginPayload listpublic static boolean checkListPingCompatibilityForClient(java.util.Map<ResourceLocation,org.apache.commons.lang3.tuple.Pair<java.lang.String,java.lang.Boolean>> incoming)
public boolean isLocked()
public static void lock()