Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
mysticdrew committed Jun 13, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 17576fc commit 6c5774a
Showing 1 changed file with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -28,15 +28,44 @@ public Side getSide()
return Side.CLIENT;
}

/**
* Register packet.
* Defaults handling the packet on the main thread.
*
* @param packetIdentifier - the packet identifier
* @param messageType - the messageType
* @param encoder - the encoder
* @param decoder - the decoder
* @param handler - the handler
* @param <T>
* @return
*/
@Override
public <T> PacketRegistrar registerPacket(ResourceLocation packetIdentifier, Class<T> messageType, BiConsumer<T, FriendlyByteBuf> encoder, Function<FriendlyByteBuf, T> decoder, Consumer<PacketContext<T>> handler)
{
PacketContainer<T> container = new PacketContainer<>(packetIdentifier, messageType, encoder, decoder, handler);
return registerPacket(packetIdentifier, messageType, encoder, decoder, handler, false);
}

/**
* Register packet.
*
* @param packetIdentifier - the packet identifier
* @param messageType - the messageType
* @param encoder - the encoder
* @param decoder - the decoder
* @param handler - the handler
* @param handleOnNetworkThread - to handle on the network thread
* @param <T>
* @return
*/
@Override
public <T> PacketRegistrar registerPacket(ResourceLocation packetIdentifier, Class<T> messageType, BiConsumer<T, FriendlyByteBuf> encoder, Function<FriendlyByteBuf, T> decoder, Consumer<PacketContext<T>> handler, boolean handleOnNetworkThread)
{
PacketContainer<T> container = new PacketContainer<>(packetIdentifier, messageType, encoder, decoder, handler, handleOnNetworkThread);
QUEUED_PACKET_MAP.put(messageType, container);
return this;
}


public void registerQueuedPackets(PacketRegistrationHandler packetRegistration)
{
if (!QUEUED_PACKET_MAP.isEmpty())

0 comments on commit 6c5774a

Please sign in to comment.