Package commonnetwork.api
Class Network
java.lang.Object
commonnetwork.api.Network
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic NetworkHandlerGets the Network handler for use to send packets.static <T> PacketRegistrarregisterConfigurationPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<? extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> type, Class<T> packetClass, net.minecraft.network.codec.StreamCodec<? extends net.minecraft.network.FriendlyByteBuf, T> codec, Consumer<PacketContext<T>> handler) Packet Registrationstatic <T> PacketRegistrarregisterPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<? extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> type, Class<T> packetClass, net.minecraft.network.codec.StreamCodec<? extends net.minecraft.network.FriendlyByteBuf, T> codec, Consumer<PacketContext<T>> handler) Packet Registrationstatic <T> PacketRegistrarregisterPacket(net.minecraft.resources.Identifier packetIdentifier, Class<T> packetClass, BiConsumer<T, net.minecraft.network.FriendlyByteBuf> encoder, Function<net.minecraft.network.FriendlyByteBuf, T> decoder, Consumer<PacketContext<T>> handler) Deprecated, for removal: This API element is subject to removal in a future version.this method will eventually be removed, please migrate to the method supplying your own encoding/decoding codec.
-
Constructor Details
-
Network
public Network()
-
-
Method Details
-
registerPacket
@Deprecated(forRemoval=true) public static <T> PacketRegistrar registerPacket(net.minecraft.resources.Identifier packetIdentifier, Class<T> packetClass, BiConsumer<T, net.minecraft.network.FriendlyByteBuf> encoder, Function<net.minecraft.network.FriendlyByteBuf, T> decoder, Consumer<PacketContext<T>> handler) Deprecated, for removal: This API element is subject to removal in a future version.this method will eventually be removed, please migrate to the method supplying your own encoding/decoding codec. Likely in 1.21.2 or 1.22.Packet Registration- Type Parameters:
T- - The type- Parameters:
packetIdentifier- - The uniqueIdentifierpacket id.packetClass- - The class of the packet.encoder- - The encoder method.decoder- - The decoder method.handler- - The handler method.- Returns:
- The registrar for chaining registrations.
-
registerPacket
public static <T> PacketRegistrar registerPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<? extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> type, Class<T> packetClass, net.minecraft.network.codec.StreamCodec<? extends net.minecraft.network.FriendlyByteBuf, T> codec, Consumer<PacketContext<T>> handler) Packet Registration- Type Parameters:
T- - The class type- Parameters:
type- - The packet type.packetClass- - The class of the packet.codec- - The StreamCodec.handler- - The handler method.- Returns:
- The registrar for chaining registrations.
-
registerConfigurationPacket
public static <T> PacketRegistrar registerConfigurationPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<? extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> type, Class<T> packetClass, net.minecraft.network.codec.StreamCodec<? extends net.minecraft.network.FriendlyByteBuf, T> codec, Consumer<PacketContext<T>> handler) Packet Registration- Type Parameters:
T- - The class type- Parameters:
type- - The packet type.packetClass- - The class of the packet.codec- - The StreamCodec.handler- - The handler method.- Returns:
- The registrar for chaining registrations.
-
getNetworkHandler
Gets the Network handler for use to send packets.- Returns:
- - The network handler
-