类 ChannelBuilder
java.lang.Object
net.minecraftforge.network.ChannelBuilder
Builder for constructing impl channels using a builder style API.
-
字段概要
字段修饰符和类型字段说明private Map
<io.netty.util.AttributeKey<?>, Function<Connection, ?>> private Channel.VersionTest
private Consumer
<Connection> private final ResourceLocation
private int
private boolean
private Channel.VersionTest
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明A predicate run on both sides, with thenetworkProtocolVersion(int)
from the server, the channel on the remote side.<T> ChannelBuilder
attribute
(io.netty.util.AttributeKey<T> key, Function<Connection, T> factory) Registers a AttributeKey to be filled when a new connection is created.<T> ChannelBuilder
Registers a AttributeKey to be filled when a new connection is created.<C> C
channel
(Function<NetworkInstance, C> factory) Registers this channel with the引用无效
NetworkManager
A predicate run on the client, with thenetworkProtocolVersion(int)
from the server, the channel on the remote side.connectionHandler
(Consumer<Connection> handler) Registers a function that will be called when a new connection is established.private NetworkInstance
Create the impl instanceBuild a newEventNetworkChannel
with this builder's configuration.private Channel.VersionTest
private Channel.VersionTest
static ChannelBuilder
Creates a new channel builder, The name of the channel must be unique.static ChannelBuilder
named
(ResourceLocation channelName) Creates a new channel builder, The name of the channel must be unique.networkProtocolVersion
(int version) The impl protocol version for this channel.optional()
Allows a client to connect to a server that is missing this channel.Tells the server to accept clients that are missing this channel.Allows a client to connect to a server that is missing this channel.Build a newPayloadChannel
with this builder's configuration.A predicate run on the server, with thenetworkProtocolVersion(int)
from the server, the channel on the remote side.Build a newSimpleChannel
with this builder's configuration.
-
字段详细资料
-
name
-
networkProtocolVersion
private int networkProtocolVersion -
clientAcceptedVersions
-
serverAcceptedVersions
-
attributes
-
connectionHandler
-
registerSelf
private boolean registerSelf
-
-
构造器详细资料
-
ChannelBuilder
-
-
方法详细资料
-
named
Creates a new channel builder, The name of the channel must be unique.- 参数:
channelName
- The name of the channel
-
named
Creates a new channel builder, The name of the channel must be unique.- 参数:
channelName
- The name of the channel
-
networkProtocolVersion
The impl protocol version 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.
Defaults to 0- 抛出:
IllegalArgumentException
- if version is 无效输入:'<' 0- 另请参阅:
-
acceptedVersions
A predicate run on both sides, with thenetworkProtocolVersion(int)
from the server, the channel on the remote side.
Defaults to only accepting current version and requiring it to be present.- 参数:
test
- A predicate for testing- 另请参阅:
-
clientAcceptedVersions
A predicate run on the client, with thenetworkProtocolVersion(int)
from the server, the channel on the remote side.
Defaults to only accepting current version.- 参数:
test
- A predicate for testing- 另请参阅:
-
serverAcceptedVersions
A predicate run on the server, with thenetworkProtocolVersion(int)
from the server, the channel on the remote side.
Defaults to only accepting current version.- 参数:
test
- A predicate for testing- 另请参阅:
-
optional
Allows a client to connect to a server that is missing this channel. And allows a server to accept a client missing this channel. This includes vanilla connections. -
optionalServer
Allows a client to connect to a server that is missing this channel. -
optionalClient
Tells the server to accept clients that are missing this channel. -
attribute
Registers a AttributeKey to be filled when a new connection is created. This is meant as a simple way to attach data on a per-connection bases.- 参数:
key
- The key to assignfactory
- A factory that creates a new instance of the context data
-
attribute
public <T> ChannelBuilder attribute(io.netty.util.AttributeKey<T> key, Function<Connection, T> factory) Registers a AttributeKey to be filled when a new connection is created. This is meant as a simple way to attach data on a per-connection bases.- 参数:
key
- The key to assignfactory
- A factory that creates a new instance of the context data
-
connectionHandler
Registers a function that will be called when a new connection is established. This is meant to allow you to do basic configuration and add context objects. This is equivalent to theConnectionStartEvent
-
createNetworkInstance
Create the impl instance- 返回:
- the
NetworkInstance
-
getClientAcceptedVersions
-
getServerAcceptedVersions
-
simpleChannel
Build a newSimpleChannel
with this builder's configuration.- 返回:
- A new
SimpleChannel
-
eventNetworkChannel
Build a newEventNetworkChannel
with this builder's configuration.- 返回:
- A new
EventNetworkChannel
-
payloadChannel
Build a newPayloadChannel
with this builder's configuration. -
channel
Registers this channel with the引用无效
NetworkManager
-