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.ObjectBuilder for constructing network channels using a builder style API.
-
-
Field Summary
Fields Modifier and Type Field Description private ResourceLocationchannelNameprivate java.util.function.Predicate<java.lang.String>clientAcceptedVersionsprivate java.util.function.Supplier<java.lang.String>networkProtocolVersionprivate 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.ChannelBuilderclientAcceptedVersions(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.ABSENTindicating the absence of the channel on the remote side.private NetworkInstancecreateNetworkInstance()Create the network instanceEventNetworkChanneleventNetworkChannel()Build a newEventNetworkChannelwith this builder's configuration.static NetworkRegistry.ChannelBuildernamed(ResourceLocation channelName)The name of the channel.NetworkRegistry.ChannelBuildernetworkProtocolVersion(java.util.function.Supplier<java.lang.String> networkProtocolVersion)The network protocol string for this channel.NetworkRegistry.ChannelBuilderserverAcceptedVersions(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.ABSENTindicating the absence of the channel on the remote side.SimpleChannelsimpleChannel()Build a newSimpleChannelwith 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.ABSENTindicating 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.ABSENTindicating 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 newSimpleChannelwith this builder's configuration.- Returns:
- A new
SimpleChannel
-
eventNetworkChannel
public EventNetworkChannel eventNetworkChannel()
Build a newEventNetworkChannelwith this builder's configuration.- Returns:
- A new
EventNetworkChannel
-
-