The last three parameters can be method references to either static or instance methods in Java. Remember that an instance method <code><nowiki>MSG.encode(FriendlyByteBuf)</nowiki></code> still satisfies <code><nowiki>BiConsumer<MSG, FriendlyByteBuf></nowiki></code>, the <code><nowiki>MSG</nowiki></code> simply becomes the implicit first argument.
The last three parameters can be method references to either static or instance methods in Java. Remember that an instance method <code><nowiki>MSG.encode(FriendlyByteBuf)</nowiki></code> still satisfies <code><nowiki>BiConsumer<MSG, FriendlyByteBuf></nowiki></code>, the <code><nowiki>MSG</nowiki></code> simply becomes the implicit first argument.
+
+
<syntaxhighlight lang="java">
+
// A class MessagePacket
+
public void encoder(FriendlyByteBuf buffer) {
+
// Write to buffer
+
}
+
+
public static MessagePacket decoder(FriendlyByteBuf buffer) {
+
// Create packet from buffer data
+
}
+
+
public void messageConsumer(Supplier<NetworkEvent.Context>> ctx) {