Package net.minecraftforge.network
Class SimpleChannel
- All Implemented Interfaces:
SimpleConnection<Object>
-
Nested Class Summary
Modifier and TypeClassDescriptionprivate static final record
SimpleChannel.Flow<BUF extends FriendlyByteBuf,
BASE> private static final record
SimpleChannel.HandlerFlow<BUF extends FriendlyByteBuf,
CTX, BASE extends SimplePacket<CTX>> private static final record
SimpleChannel.HandlerProtocol<BUF extends FriendlyByteBuf,
CTX, BASE extends SimplePacket<CTX>> protected static final record
SimpleChannel.Message<MSG,
BUF extends FriendlyByteBuf> static class
private static final record
SimpleChannel.Protocol<BUF extends FriendlyByteBuf,
BASE> private static interface
private static final record
Nested classes/interfaces inherited from class net.minecraftforge.network.Channel
Channel.VersionTest
-
Field Summary
Modifier and TypeFieldDescriptionprivate boolean
protected it.unimi.dsi.fastutil.ints.Int2ObjectMap
<SimpleChannel.Message<?, ?>> protected it.unimi.dsi.fastutil.objects.Object2ObjectMap
<Class<?>, SimpleChannel.Message<?, ?>> protected int
private static final org.apache.logging.log4j.Logger
private static final org.apache.logging.log4j.Marker
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Finishes off the builder side of the SimpleChanel.protected void
void
encode
(FriendlyByteBuf out, Object message) private void
private SimpleChannel.Message
<Object, FriendlyByteBuf> get
(int id) private SimpleChannel.Message
<Object, FriendlyByteBuf> messageBuilder
(Class<M> type) Build a new MessageBuilder, using the next available discriminator.messageBuilder
(Class<M> type, int discriminator) Build a new MessageBuilder.<M,
B extends FriendlyByteBuf>
SimpleChannel.MessageBuilder<M, B> messageBuilder
(Class<M> type, int discriminator, NetworkDirection<B> direction) Build a new MessageBuilder.<M,
B extends FriendlyByteBuf>
SimpleChannel.MessageBuilder<M, B> messageBuilder
(Class<M> type, int discriminator, NetworkProtocol<B> protocol) Build a new MessageBuilder, using the next available discriminator.<M,
B extends FriendlyByteBuf>
SimpleChannel.MessageBuilder<M, B> messageBuilder
(Class<M> type, NetworkDirection<B> direction) Build a new MessageBuilder, using the next available discriminator.<M,
B extends FriendlyByteBuf>
SimpleChannel.MessageBuilder<M, B> messageBuilder
(Class<M> type, NetworkProtocol<B> protocol) Build a new MessageBuilder, using the next available discriminator.private void
protected int
<NEWBUF extends FriendlyByteBuf,
CTX, NEWBASE extends SimplePacket<CTX>>
SimpleHandlerProtocol<NEWBUF, NEWBASE> protocol
(io.netty.util.AttributeKey<CTX> context, NetworkProtocol<NEWBUF> protocol) Creates a builder grouping together all packets under the same protocol.<NEWBUF extends FriendlyByteBuf,
NEWBASE>
SimpleProtocol<NEWBUF, NEWBASE> protocol
(NetworkProtocol<NEWBUF> protocol) Creates a builder grouping together all packets under the same protocol.protected Packet
<?> toVanillaPacket
(Connection con, Object message) Methods inherited from class net.minecraftforge.network.Channel
getName, getName, getProtocolVersion, isRemotePresent, reply, send, send, validate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minecraftforge.network.simple.SimpleConnection
any, any, any, any, configuration, configuration, configuration, configuration, login, login, login, login, play, play, play, play, protocol, protocol
-
Field Details
-
LOGGER
private static final org.apache.logging.log4j.Logger LOGGER -
MARKER
private static final org.apache.logging.log4j.Marker MARKER -
built
private boolean built -
lastIndex
protected int lastIndex -
byId
-
byType
protected it.unimi.dsi.fastutil.objects.Object2ObjectMap<Class<?>,SimpleChannel.Message<?, byType?>>
-
-
Constructor Details
-
SimpleChannel
-
-
Method Details
-
protocol
public <NEWBUF extends FriendlyByteBuf,NEWBASE> SimpleProtocol<NEWBUF,NEWBASE> protocol(NetworkProtocol<NEWBUF> protocol) Description copied from interface:SimpleConnection
Creates a builder grouping together all packets under the same protocol. This will validate that the protocol matches before the packet is sent or received.- Specified by:
protocol
in interfaceSimpleConnection<Object>
-
protocol
public <NEWBUF extends FriendlyByteBuf,CTX, SimpleHandlerProtocol<NEWBUF,NEWBASE extends SimplePacket<CTX>> NEWBASE> protocol(io.netty.util.AttributeKey<CTX> context, NetworkProtocol<NEWBUF> protocol) Description copied from interface:SimpleConnection
Creates a builder grouping together all packets under the same protocol. This will validate that the protocol matches before the packet is sent or received.- Specified by:
protocol
in interfaceSimpleConnection<Object>
-
messageBuilder
Build a new MessageBuilder, using the next available discriminator.- Type Parameters:
M
- Type of type- Parameters:
type
- Type of message
-
messageBuilder
public <M> SimpleChannel.MessageBuilder<M,FriendlyByteBuf> messageBuilder(Class<M> type, int discriminator) Build a new MessageBuilder.- Type Parameters:
M
- Type of type- Parameters:
type
- Type of messagediscriminator
- Manually configured discriminator, Must be a positive number.
-
messageBuilder
public <M,B extends FriendlyByteBuf> SimpleChannel.MessageBuilder<M,B> messageBuilder(Class<M> type, NetworkProtocol<B> protocol) Build a new MessageBuilder, using the next available discriminator.- Type Parameters:
M
- Type of type- Parameters:
type
- Type of messageprotocol
- The protocol that this packet is allowed to be sent/received in, Use enforce strict state handling to prevent spoofing.
-
messageBuilder
public <M,B extends FriendlyByteBuf> SimpleChannel.MessageBuilder<M,B> messageBuilder(Class<M> type, NetworkDirection<B> direction) Build a new MessageBuilder, using the next available discriminator.- Type Parameters:
M
- Type of type- Parameters:
type
- Type of messagedirection
- a impl direction which will be asserted before any processing of this message occurs. Use to enforce strict sided handling to prevent spoofing.
-
messageBuilder
public <M,B extends FriendlyByteBuf> SimpleChannel.MessageBuilder<M,B> messageBuilder(Class<M> type, int discriminator, NetworkProtocol<B> protocol) Build a new MessageBuilder, using the next available discriminator.- Type Parameters:
M
- Type of type- Parameters:
type
- Type of messagediscriminator
- Manually configured discriminator, Must be a positive number.protocol
- The protocol that this packet is allowed to be sent/received in, Use enforce strict state handling to prevent spoofing.
-
messageBuilder
public <M,B extends FriendlyByteBuf> SimpleChannel.MessageBuilder<M,B> messageBuilder(Class<M> type, int discriminator, NetworkDirection<B> direction) Build a new MessageBuilder.- Type Parameters:
M
- Type of type- Parameters:
type
- Type of messagediscriminator
- Manually configured discriminator, Must be a positive number.direction
- a impl direction which will be asserted before any processing of this message occurs. Use to enforce strict sided handling to prevent spoofing.
-
build
Finishes off the builder side of the SimpleChanel. This prevents adding more messages to this channel. -
checkBuilt
protected void checkBuilt() -
get
-
get
-
nextIndex
protected int nextIndex() -
networkEventListener
-
toVanillaPacket
- Overrides:
toVanillaPacket
in classChannel<Object>
-
encode
-
error
-