Skip to content

Registering Endecs is not documented #9

Description

@Noaaan

When creating custom Endecs (I.E. StructEndecs) you need to register these using the ReflectiveEndecBuilder

An example from Numismatic Overhaul:

// Endec used for shop offers
public static final Endec<ShopOffer> ENDEC = StructEndecBuilder.of(
    BuiltInEndecs.ITEM_STACK.fieldOf("sell", ShopOffer::getSellStack),
    Endec.LONG.fieldOf("price", ShopOffer::getPrice),
    ShopOffer::new
);

// Register method in the "UpdateShopScreenS2CPacket" class
ReflectiveEndecBuilder.register(ShopOffer.ENDEC, ShopOffer.class);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions