Class FabricTrackedDataRegistry
java.lang.Object
net.fabricmc.fabric.api.object.builder.v1.entity.FabricTrackedDataRegistry
Allows registering custom
TrackedDataHandlers in a reliable way.-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable TrackedDataHandler<?> get(Identifier id) Retrieves the handler for the given ID, ornullif it does not exist.static @Nullable IdentifiergetId(TrackedDataHandler<?> handler) Retrieves the ID for the given handler, ornullif the handler was not registered withregister(Identifier, TrackedDataHandler).static voidregister(Identifier id, TrackedDataHandler<?> handler) Registers aTrackedDataHandlerusing the given ID.
-
Method Details
-
register
Registers aTrackedDataHandlerusing the given ID. Use this instead ofTrackedDataHandlerRegistry.register(TrackedDataHandler)as the vanilla method exclusively uses integer IDs, which can result in desyncs and errors with custom handlers. This method is guaranteed to work reliably.Handlers registered with this method will have an associated integer ID as well, which can be used with
TrackedDataHandlerRegistry.get(int)andTrackedDataHandlerRegistry.getId(TrackedDataHandler). However, the integer ID of a given custom handler registered through this method may change on registry sync. The integer IDs of vanilla handlers are guaranteed to remain constant. -
get
Retrieves the handler for the given ID, ornullif it does not exist. -
getId
Retrieves the ID for the given handler, ornullif the handler was not registered withregister(Identifier, TrackedDataHandler).
-