Reference: Registry System
IGUID
com.robertx22.library_of_exile.registry.IGUID
public interface IGUID {
String GUID();
default String getFileName() { return GUID(); }
}
Valid GUID characters: [a-z 0-9 _ : / . -]. Validation is enforced at startup via
Database.checkGuidValidity(). Entries with invalid GUIDs are removed and logged.
Recommended format: "modid:content_name" (using a colon namespace separator).
IWeighted
com.robertx22.library_of_exile.registry.IWeighted
public interface IWeighted {
int Weight();
}
Higher weight = more likely to be selected by ExileRegistryContainer.random().
IAutoGson<T>
com.robertx22.library_of_exile.registry.IAutoGson
Extends ISerializable<T>. Marks a class for automatic Gson serialization.
Class<T> getClassForSerialization();
Serialization uses the shared IAutoGson.GSON instance. Register custom type adapters via
ExileEvents.DATAPACK_GSON_ADAPTER_REGISTRY before this instance is built.
ExileRegistry<C>
com.robertx22.library_of_exile.registry.ExileRegistry
Extends IGUID, IWeighted.
ExileRegistryType getExileRegistryType();
default boolean isRegistryEntryValid() { return true; }
default boolean isFromDatapack() { return false; }
JsonExileRegistry<T>
com.robertx22.library_of_exile.registry.JsonExileRegistry
Extends ExileRegistry<T>. Override of isFromDatapack() returns true. Adds:
void compareLoadedJsonAndFinalClass(JsonObject json, Boolean editmode);
Entries that fail round-trip validation are stored in JsonExileRegistry.INVALID_JSONS_MAP
and reported to players on login.
ExileRegistryType
com.robertx22.library_of_exile.registry.ExileRegistryType
Factory
public static ExileRegistryType register(
String modid,
String id,
int order,
ISerializable ser, // prototype for JSON loading; null = no JSON support
SyncTime synctime
)
Full id = modid + "_" + id.
Key methods
static List<ExileRegistryType> getAllInRegisterOrder()
static void registerJsonListeners(AddReloadListenerEvent event)
String getId() // full id
int getOrder()
SyncTime getSyncTime()
Built-in types (LibDatabase)
| Constant | Full id | Order | SyncTime |
|---|---|---|---|
MAP_DATA_BLOCK |
library_of_exile_map_data_block |
0 | NEVER |
MOB_LIST |
library_of_exile_mob_list |
0 | NEVER |
MOB_AFFIX |
library_of_exile_mob_affix |
0 | ON_LOGIN |
MAP_FINISH_RARITY |
library_of_exile_map_finish_rar |
0 | ON_LOGIN |
MAP_CONTENT |
library_of_exile_map_content |
0 | ON_LOGIN |
LEAGUE |
library_of_exile_league |
0 | NEVER |
RELIC_STAT |
library_of_exile_relic_stat |
0 | ON_LOGIN |
RELIC_TYPE |
library_of_exile_relic_type |
1 | ON_LOGIN |
RELIC_AFFIX |
library_of_exile_relic_affix |
2 | ON_LOGIN |
RELIC_RARITY |
library_of_exile_relic_rarity |
3 | ON_LOGIN |
ITEM_MOD |
library_of_exile_item_modification |
48 | ON_LOGIN |
ITEM_REQ |
library_of_exile_item_requirement |
49 | ON_LOGIN |
CURRENCY |
library_of_exile_currency |
50 | ON_LOGIN |
ORB_EDIT |
library_of_exile_orb_edit |
51 | ON_LOGIN |
Database
com.robertx22.library_of_exile.registry.Database
Static global registry store.
static void addRegistry(ExileRegistryContainer cont)
static ExileRegistryContainer getRegistry(ExileRegistryType type)
static <C extends ExileRegistry<C>> C get(ExileRegistryType type, String guid)
static boolean areDatapacksLoaded(Level world)
static void sendPacketsToClient(ServerPlayer player, SyncTime sync)
static void checkGuidValidity()
static void unregisterInvalidEntries()
static List<ExileRegistryContainer> getAllRegistries()
get() returns the container's default entry (logged as an error) if the GUID is not found.
Use container.getOptional(guid) if you need to distinguish "found" from "not found".
ExileRegistryContainer<C>
com.robertx22.library_of_exile.registry.ExileRegistryContainer
ExileRegistryContainer(ExileRegistryType type, String emptyDefault)
C get(String guid)
C getDefault()
Optional<C> getOptional(String guid)
List<C> getList()
HashMap<String, C> getAll()
C random()
C random(Double randomDouble)
List<C> getFiltered(Predicate<C> predicate)
FilterListWrap<C> getWrapped()
boolean isRegistered(String guid)
int getSize()
ExileRegistryEvent
com.robertx22.library_of_exile.registry.ExileRegistryEvent
Fired via ExileEvents.EXILE_REGISTRY_GATHER for each ExileRegistryType during
FMLCommonSetupEvent.
ExileRegistryType type
void add(ExileRegistry<?> en, ExileRegistrationInfo info)
void addSeriazable(ExileRegistry<?> en, ExileRegistrationInfo info)
// addSeriazable requires en to implement JsonExileRegistry
OrderedModConstructor
com.robertx22.library_of_exile.registry.helpers.OrderedModConstructor
Abstract base class for mod init.
static void register(OrderedModConstructor c, IEventBus modbus)
// Methods to override:
abstract List<ExileRegistryEventClass> getRegisterEvents()
abstract List<ExileKeyHolder> getAllKeyHolders()
abstract void registerDeferredContainers(IEventBus bus)
abstract void registerDeferredEntries()
abstract void registerDatabases()
abstract void registerDatabaseEntries()
Init order when register() is called:
1. registerDeferredContainers(bus)
2. registerDeferredEntries()
3. registerDatabases()
4. registerDatabaseEntries() — deferred to first EXILE_REGISTRY_GATHER event
5. All ExileRegistryEventClass.register() calls
6. All ExileKeyHolder.init() calls
ExileKeyHolder<T>
com.robertx22.library_of_exile.registry.helpers.ExileKeyHolder
ExileKeyHolder(String modid, ExileRegistryType type)
void init() // called by OrderedModConstructor.register
ExileKey<T, Info>
static ExileKey<T, Info> ofId(
ExileKeyHolder<T> holder,
String guid,
Function<ExileKey<T, Info>, T> factory
)
String GUID()
T get() // returns the registered instance after init
SyncTime
public enum SyncTime {
ON_LOGIN, // synced to clients when they log in or /reload fires
NEVER // server-only
}
JSON datapack loader control fields
These top-level fields in any JSON entry control loading behaviour:
| Field | Values | Default | Effect |
|---|---|---|---|
"loader" |
"REPLACE_FULLY", "REPLACE_FIELDS" |
"REPLACE_FULLY" |
Replace entry or merge only present fields |
"enabled" |
true, false |
true |
Set to false to force-remove an entry |