How-to: Add Mob Lists

A MobList is a weighted collection of entity types used by the map and spawning systems to pick which mobs appear. Mob lists are tagged so consumers can filter by context (map, forest, obelisk, etc.).


Option A: Hardcoded Java

public class MyMobListHolder extends ExileKeyHolder<MobList> {

    public MyMobListHolder(String modid) {
        super(modid, LibDatabase.MOB_LIST);
    }

    public ExileKey<MobList, KeyInfo> OCEAN = ExileKey.ofId(
        this, "my_mod:ocean",
        x -> {
            List<MobEntry> entries = new ArrayList<>();
            entries.add(new MobEntry(1000, EntityType.DROWNED));
            entries.add(new MobEntry(300,  EntityType.GUARDIAN));
            entries.add(new MobEntry(50,   EntityType.ELDER_GUARDIAN));

            return new MobList(
                x.GUID(),
                1000,           // weight of this list relative to other lists
                entries,
                MobListTags.MAP // tags — can pass multiple
            );
        }
    );
}

Register via getAllKeyHolders().


Option B: JSON datapack

Create a file at:

src/main/resources/data/<your_namespace>/library_of_exile_mob_list/<name>.json
{
  "id": "my_mod:ocean",
  "weight": 1000,
  "mobs": [
    { "weight": 1000, "mob_id": "minecraft:drowned" },
    { "weight": 300,  "mob_id": "minecraft:guardian" },
    { "weight": 50,   "mob_id": "minecraft:elder_guardian" }
  ],
  "tags": {
    "tags": [
      "library_of_exile:map"
    ]
  }
}

Using built-in tags

Tag constant String value Usage
MobListTags.MAP library_of_exile:map General map spawning
MobListTags.FOREST library_of_exile:forest Forest biome maps
MobListTags.HARVEST library_of_exile:harvest Harvest league events
MobListTags.OBELISK library_of_exile:obelisk Ancient obelisk spawns
MobListTags.HAS_FLYING_MOBS library_of_exile:has_flying_mobs Indicates the list contains flying mobs

Defining custom tags

public class MyMobListTags {
    public static final RegistryTag<MobList> OCEAN =
        new MobListTag("my_mod", "ocean");
}

Pass it to new MobList(...) alongside any built-in tags:

new MobList(x.GUID(), 1000, entries, MobListTags.MAP, MyMobListTags.OCEAN)

Querying mob lists at runtime

The ExileRegistryContainer for mob lists supports filtered queries:

ExileRegistryContainer<MobList> lists = Database.getRegistry(LibDatabase.MOB_LIST);

// Get all lists tagged for maps:
List<MobList> mapLists = lists.getFiltered(
    ml -> ml.tags.has(MobListTags.MAP)
);

// Pick a weighted-random list from those results:
MobList chosen = RandomUtils.weightedRandom(mapLists);

// Pick a random mob from that list:
MobEntry mob = chosen.getRandomMob();

Use mob.mob_id (a ResourceLocation string) to resolve the EntityType:

EntityType<?> type = ForgeRegistries.ENTITY_TYPES.getValue(
    new ResourceLocation(mob.mob_id)
);

Notes

  • Mob lists are SyncTime.NEVER — they never reach the client.
  • The weight field on the MobList itself (not the MobEntry weights) determines how often this list is chosen relative to other lists in the same filtered pool.
  • An empty mobs list is valid but will cause getRandomMob() to return null. Guard against this if you query lists that might be modified by other mods.