Package commoble.morered

# Class PacketTypeFactory

java.lang.Object
commoble.morered.PacketTypeFactory

public class PacketTypeFactory extends Object

## Constructor Summary

Constructors
Constructor
Description
`PacketTypeFactory()`

## Method Summary

Modifier and Type
Method
Description
`static <PACKET extends Consumer<net.minecraftforge.network.NetworkEvent.Context>>
void`
`register(int id, net.minecraftforge.network.simple.SimpleChannel channel, com.mojang.serialization.Codec<PACKET> codec, PACKET defaultPacket)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### PacketTypeFactory

public PacketTypeFactory()

## Method Details

### register

public static <PACKET extends Consumer<net.minecraftforge.network.NetworkEvent.Context>> void register(int id, net.minecraftforge.network.simple.SimpleChannel channel, com.mojang.serialization.Codec<PACKET> codec, PACKET defaultPacket)

Type Parameters:
  `PACKET` - the packet class
Parameters:
  `id` - A packet type id unique to this packet type within the context of the channel we are registering to
  `channel` - The SimpleChannel to register a packet type to
  `codec` - A codec for the packet's class
  `defaultPacket` - If a packet instance cannot be parsed on the client, it will be treated as this packet instance instead. The defaultPacket instance must have the same class instance as any packets sent of this type, and cannot have the same class instance as any other registered packet. (lambdas and anonymous classes are fine as long as a different declaration is used for each packet type)