Class SimpleChannel

java.lang.Object
net.minecraftforge.network.Channel<Object>
net.minecraftforge.network.SimpleChannel
All Implemented Interfaces:
SimpleConnection<Object>

public class SimpleChannel extends Channel<Object> implements SimpleConnection<Object>
  • 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

      protected it.unimi.dsi.fastutil.ints.Int2ObjectMap<SimpleChannel.Message<?,?>> byId
    • byType

      protected it.unimi.dsi.fastutil.objects.Object2ObjectMap<Class<?>,SimpleChannel.Message<?,?>> byType
  • Constructor Details

  • 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 interface SimpleConnection<Object>
    • protocol

      public <NEWBUF extends FriendlyByteBuf, CTX, NEWBASE extends SimplePacket<CTX>> SimpleHandlerProtocol<NEWBUF,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 interface SimpleConnection<Object>
    • messageBuilder

      public <M> SimpleChannel.MessageBuilder<M,FriendlyByteBuf> messageBuilder(Class<M> type)
      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 message
      discriminator - 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 message
      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, NetworkDirection<B> direction)
      Build a new MessageBuilder, using the next available discriminator.
      Type Parameters:
      M - Type of type
      Parameters:
      type - Type of message
      direction - 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 message
      discriminator - 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 message
      discriminator - 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

      public SimpleChannel 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

      private void networkEventListener(CustomPayloadEvent event)
    • toVanillaPacket

      protected Packet<?> toVanillaPacket(Connection con, Object message)
      Overrides:
      toVanillaPacket in class Channel<Object>
    • encode

      public void encode(FriendlyByteBuf out, Object message)
      Specified by:
      encode in class Channel<Object>
    • error

      private void error(String message)