Package codechicken.lib.packet
Class StreamNetworkChannel
java.lang.Object
codechicken.lib.packet.StreamNetworkChannel
A simple Stream based network channel, very similar to the NeoForge api, however
provides raw, stream-based packets.
You would construct one of these and store it statically, see CCLNetwork for inspiration.
Created by covers1624 on 10/26/25.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA handle for constructing a packet bound for a client or the server.static interfaceA handle for constructing client-bound packets.static interfaceThe context available when executing a configuration task.static interfaceA helpful interface for the configuration phase packet handler type.static interfaceA factory for constructingICustomConfigurationTaskinstances.static interfaceA helpful interface for the gameplay packet handler type.static interfaceA handle for constructing server-bound packets. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconfigurationToClient(String name, StreamNetworkChannel.ConfigurationTaskFactory factory, StreamNetworkChannel.ConfigurationHandler handler) Register a packet to configure a connecting client.voidinit(net.neoforged.bus.api.IEventBus bus, net.neoforged.fml.ModContainer container) Called with your mod event bus and mod container.optional()Mark this network channel as optional, not required on the client/server.playBidirectional(String name, StreamNetworkChannel.PlayHandler serverHandler, StreamNetworkChannel.PlayHandler clientHandler) Register a packet to be set to either the client or the server during gameplay.playToClient(String name, StreamNetworkChannel.PlayHandler handler) Register a packet to be set to the client during gameplay.playToServer(String name, StreamNetworkChannel.PlayHandler handler) Register a packet to be set to the server during gameplay.
-
Constructor Details
-
StreamNetworkChannel
Create a new network channel.- Parameters:
namespace- The namespace, usually your mod id.
-
-
Method Details
-
init
public void init(net.neoforged.bus.api.IEventBus bus, net.neoforged.fml.ModContainer container) Called with your mod event bus and mod container.- Parameters:
bus- Your mod event bus.container- Your mod container.
-
optional
Mark this network channel as optional, not required on the client/server.- Returns:
- The same channel.
-
playToClient
public StreamNetworkChannel.ClientPacketHandle playToClient(String name, StreamNetworkChannel.PlayHandler handler) Register a packet to be set to the client during gameplay.- Parameters:
name- The name of the packet.handler- The handler for the packet.- Returns:
- A hande to construct packets.
-
playToServer
public StreamNetworkChannel.ServerPacketHandle playToServer(String name, StreamNetworkChannel.PlayHandler handler) Register a packet to be set to the server during gameplay.- Parameters:
name- The name of the packet.handler- The handler for the packet.- Returns:
- A hande to construct packets.
-
playBidirectional
public StreamNetworkChannel.BidirectionalPacketHandle playBidirectional(String name, StreamNetworkChannel.PlayHandler serverHandler, StreamNetworkChannel.PlayHandler clientHandler) Register a packet to be set to either the client or the server during gameplay.- Parameters:
name- The name of the packet.serverHandler- The handler for the packet server-side.clientHandler- The handler for the packet client-side.- Returns:
- A hande to construct packets.
-
configurationToClient
public void configurationToClient(String name, StreamNetworkChannel.ConfigurationTaskFactory factory, StreamNetworkChannel.ConfigurationHandler handler) Register a packet to configure a connecting client.- Parameters:
name- The name of the packet.factory- The factory to construct aICustomConfigurationTask.handler- The handler for the packet client-side.
-