Class FabricTrackedDataRegistry
java.lang.Object
net.fabricmc.fabric.api.object.builder.v1.entity.FabricTrackedDataRegistry
Allows registering custom
TrackedDataHandler
s in a reliable way.-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable TrackedDataHandler
<?> get
(Identifier id) Retrieves the handler for the given ID, ornull
if it does not exist.static @Nullable Identifier
getId
(TrackedDataHandler<?> handler) Retrieves the ID for the given handler, ornull
if the handler was not registered withregister(Identifier, TrackedDataHandler)
.static void
register
(Identifier id, TrackedDataHandler<?> handler) Registers aTrackedDataHandler
using the given ID.
-
Method Details
-
register
Registers aTrackedDataHandler
using 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, ornull
if it does not exist. -
getId
Retrieves the ID for the given handler, ornull
if the handler was not registered withregister(Identifier, TrackedDataHandler)
.
-