Package net.minecraftforge.network
Class SimpleChannel
- All Implemented Interfaces:
SimpleConnection<Object>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final recordSimpleChannel.Flow<BUF extends FriendlyByteBuf,BASE> private static final recordSimpleChannel.HandlerFlow<BUF extends FriendlyByteBuf,CTX, BASE extends SimplePacket<CTX>> private static final recordSimpleChannel.HandlerProtocol<BUF extends FriendlyByteBuf,CTX, BASE extends SimplePacket<CTX>> protected static final recordSimpleChannel.Message<MSG,BUF extends FriendlyByteBuf> static classprivate static final recordSimpleChannel.Protocol<BUF extends FriendlyByteBuf,BASE> private static interfaceprivate static final recordNested classes/interfaces inherited from class net.minecraftforge.network.Channel
Channel.VersionTest -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprotected it.unimi.dsi.fastutil.ints.Int2ObjectMap<SimpleChannel.Message<?, ?>> protected it.unimi.dsi.fastutil.objects.Object2ObjectMap<Class<?>, SimpleChannel.Message<?, ?>> protected intprivate static final org.apache.logging.log4j.Loggerprivate static final org.apache.logging.log4j.Marker -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Finishes off the builder side of the SimpleChanel.protected voidvoidencode(FriendlyByteBuf out, Object message) private voidprivate 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 voidprotected 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, validateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:SimpleConnectionCreates 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:
protocolin 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:SimpleConnectionCreates 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:
protocolin 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:
toVanillaPacketin classChannel<Object>
-
encode
-
error
-