---
title: Event Targeting
---

Unlike Mixins, Mixson events are only run when the given resource the event is targeting is being loaded. Examples of
those times would be on world load, on /reload, and on F3+T. This means that events are not necessarily run in the order
they are defined if they are for different resource locations.

For example, an event targeting the file `models/item/crossbow` will always run before an event targeting
`enchantment/multishot` since the asset folder is loaded before the data folder when running a client and running a
singleplayer world.

<Callout variant = "warning">
    Resources in the same root resource directory are often loaded in parallel. For example, files in the
    "`data/enchantment`" folder may or may not load before "`data/loot_tables`".
</Callout>

Not all resource types are susceptible to a broad event. For instance, tags (like `#axes`) can have multiple files
declared for the same identifier. The order in which resources are placed in this list is determined by their priority
in the resourcepack / datapack selector menu. For mods, this order is determined by when the mod is loaded.

---
Index
---

The `Index` class is used to target a specific resource location and possibly a specific file if multiple resources
exist at the same location. It does this by keeping track of an `Identifier`, which points to the resource location,
and an `int`, which is used as an ordinal for when multiple resources are at the same location.

`Index` has four constructors availible to use:

```java
Index(Identifier id, int ordinal);

Index(String stringId, int ordinal);

Index(Identifier id);

Index(String stringId);
```

For the constructors where the ordinal is not specified, it is assumed to be `-1`. An ordinal of `-1` tells Mixson to
capture all resources at the given location.

<Callout variant = "warning">
    Not all resource types support ordinals. If a resource type does not support ordinals, a `MixsonException` will be
    thrown if the ordinal is changed from `-1` to another value. Examples of resources that do not support ordinals
    include loot tables, recipes, and textures.
</Callout>