Package net.minecraftforge.fml.network
Class NetworkRegistry.ChannelBuilder
- java.lang.Object
-
- net.minecraftforge.fml.network.NetworkRegistry.ChannelBuilder
-
- Enclosing class:
- NetworkRegistry
public static class NetworkRegistry.ChannelBuilder extends java.lang.Object
Builder for constructing network channels using a builder style API.
-
-
Field Summary
Fields Modifier and Type Field Description private ResourceLocation
channelName
private java.util.function.Predicate<java.lang.String>
clientAcceptedVersions
private java.util.function.Supplier<java.lang.String>
networkProtocolVersion
private java.util.function.Predicate<java.lang.String>
serverAcceptedVersions
-
Constructor Summary
Constructors Constructor Description ChannelBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description NetworkRegistry.ChannelBuilder
clientAcceptedVersions(java.util.function.Predicate<java.lang.String> clientAcceptedVersions)
A predicate run on the client, with thenetworkProtocolVersion(Supplier)
string from the server, or the special valueNetworkRegistry.ABSENT
indicating the absence of the channel on the remote side.private NetworkInstance
createNetworkInstance()
Create the network instanceEventNetworkChannel
eventNetworkChannel()
Build a newEventNetworkChannel
with this builder's configuration.static NetworkRegistry.ChannelBuilder
named(ResourceLocation channelName)
The name of the channel.NetworkRegistry.ChannelBuilder
networkProtocolVersion(java.util.function.Supplier<java.lang.String> networkProtocolVersion)
The network protocol string for this channel.NetworkRegistry.ChannelBuilder
serverAcceptedVersions(java.util.function.Predicate<java.lang.String> serverAcceptedVersions)
A predicate run on the server, with thenetworkProtocolVersion(Supplier)
string from the server, or the special valueNetworkRegistry.ABSENT
indicating the absence of the channel on the remote side.SimpleChannel
simpleChannel()
Build a newSimpleChannel
with this builder's configuration.
-
-
-
Field Detail
-
channelName
private ResourceLocation channelName
-
networkProtocolVersion
private java.util.function.Supplier<java.lang.String> networkProtocolVersion
-
clientAcceptedVersions
private java.util.function.Predicate<java.lang.String> clientAcceptedVersions
-
serverAcceptedVersions
private java.util.function.Predicate<java.lang.String> serverAcceptedVersions
-
-
Method Detail
-
named
public static NetworkRegistry.ChannelBuilder named(ResourceLocation channelName)
The name of the channel. Must be unique.- Parameters:
channelName
- The name of the channel- Returns:
- the channel builder
-
networkProtocolVersion
public NetworkRegistry.ChannelBuilder networkProtocolVersion(java.util.function.Supplier<java.lang.String> networkProtocolVersion)
The network protocol string for this channel. This will be gathered during login and sent to the remote partner, where it will be tested with against the relevant predicate.- Parameters:
networkProtocolVersion
- A supplier of strings for network protocol version testing- Returns:
- the channel builder
- See Also:
serverAcceptedVersions(Predicate)
,clientAcceptedVersions(Predicate)
-
clientAcceptedVersions
public NetworkRegistry.ChannelBuilder clientAcceptedVersions(java.util.function.Predicate<java.lang.String> clientAcceptedVersions)
A predicate run on the client, with thenetworkProtocolVersion(Supplier)
string from the server, or the special valueNetworkRegistry.ABSENT
indicating the absence of the channel on the remote side.- Parameters:
clientAcceptedVersions
- A predicate for testing- Returns:
- the channel builder
-
serverAcceptedVersions
public NetworkRegistry.ChannelBuilder serverAcceptedVersions(java.util.function.Predicate<java.lang.String> serverAcceptedVersions)
A predicate run on the server, with thenetworkProtocolVersion(Supplier)
string from the server, or the special valueNetworkRegistry.ABSENT
indicating the absence of the channel on the remote side.- Parameters:
serverAcceptedVersions
- A predicate for testing- Returns:
- the channel builder
-
createNetworkInstance
private NetworkInstance createNetworkInstance()
Create the network instance- Returns:
- the
NetworkInstance
-
simpleChannel
public SimpleChannel simpleChannel()
Build a newSimpleChannel
with this builder's configuration.- Returns:
- A new
SimpleChannel
-
eventNetworkChannel
public EventNetworkChannel eventNetworkChannel()
Build a newEventNetworkChannel
with this builder's configuration.- Returns:
- A new
EventNetworkChannel
-
-