---
title: Updating from V:0.x.x to V:1.0.0
---

<Callout variant="warning">

    This page only gives the minimum details for using V1 Mixson. All information  on this page *IS* outdated. Revisit
    the entire wiki to be update-to-date on all features available.

</Callout>


## Registering Events
There are now only two methods to use for default registration which can both be found in the `Mixson` class:
```java
UUID registerEvent(int priority, String resourceId, String eventName, MixsonEvent event, ResourceReference... references);

UUID registerEvent(int priority, String resourceId, String eventName, MixsonEvent event, boolean silentlyFail, ResourceReference... references);
```
the `resourceId` is now converted to an `Identifier` (or `ResourceLocation`) during registration, so only a string needs
to be passed.

the `eventId` has been replaced with `eventName` which replaces the `BaseEvent#getName` used for debugging. The
`eventName` is not converted to an `Identifier`, so there are no restrictions on what it can be.

### Old Example
```java
Mixson.registerModificationEvent(
        Mixson.DEFAULT_PRIORITY,
        Identifier.ofVanilla("models/item/netherite_chestplate"),
        Identifier.of(MOD_ID, "testevent"),
        (elem) -> {
            // do stuff
        },
        false
);
```
### Updated Example
```java
Mixson.registerEvent(
        Mixson.DEFAULT_PRIORITY,
        "models/item/netherite_chestplate",
        "modid:testevent",
        (context) -> {
            // do stuff
        },
        false
);
```

## Events
There is now only one event type: `MixsonEvent`. Advanced variants have also been removed and reimplemented into this
singular event.

The interface is defined as follows:
```java
public interface MixsonEvent {

    void runEvent(EventContext context);

    default int ordinal() {
        return -1;
    }
}
```
the `EventContext` object provides all the features (and more) that the previous events could do

### Modification Events
To modify the resource, call `EventContext#getFile` to receive a modifiable `JsonElement`.

#### Old Example
```java
(elem) -> {
    // modify elem here
}
```

#### New Example
```java
(context) -> {
    JsonElement elem = context.getFile();
    // modify elem here
}
```

### Creation Events
To create a resource, call one of the `EventContext#createResource` methods. The methods are defined as follows:
```java
void createResource(ResourceLocation id, JsonElement elem); // use on Identified Resources

void createResource(JsonElement elem); // use on Indexed Resources
```
An event will only ever use one of these depending on whether the resource it is called on is an indexed resource or
identified resource. As of 1.0.0, there is only one list resource: namespace resources (such as `sounds.json`). Using
the incorrect method will throw an exception.

For Identified Resources, the `eventName` is not used for the `Identifier`. Instead, the identifier is passed with the
`JsonElement`.

#### Old Example
```java
    () -> {
        JsonElement createdJson = /* json */;
        return createdJson;
    }
```

#### New Example
```java
    (context) -> {
        JsonElement createdJson = /* json */;
        context.createResource(/* resourceId */, createdJson);
    }
```

### Deletion Events
To delete a resource, call `EventContext#markForDeletion` with the parameter `shouldDelete` set to `true`. Resources are
now deleted at the end of resource runtime, which is when all resources have been processed for that resource type. This
means other events can still interact with the resource after it is marked for deletion and even cancel its deletion by
passing `false`.

#### Old Example
```java
    () -> {
        return true;
    }
```

#### New Example
```java
    (context) -> {
        context.markForDeletion(true);
    }
```

### Advanced Events
There are now two constructors for the `ResourceReference`:
```java
    ResourceReference(int priority, String resourceId, String referenceId, int ordinal);

    ResourceReference(int priority, String resourceId, String referenceId);
```
Although both `resourceId` and `referenceId` are taken as `String`s, they are stilled converted to `Identifer`s when the
reference is processed.

the method `BuiltResourceReference#consume` has been replaced with `BuiltResourceReference#retrieve`:
```java
    Optional<JsonElement> retrieve();
```
Resources are now cleared at the end of event runtime instead of when the resource is consumed. However, the
resource may be unavailable if the reference had not been fulfilled yet or the resource doesn't exist.

`BuiltResourceReference`s are now gotten through the `EventContext#getReference` method which has a parameter for a
string. The string is to be the string equivalent of the `referenceId`.
#### Old Example
```java
    (elem, references) -> {
        BuiltResourceReference ref = references.get(/* referenceId */);
    }
```

#### New Example
```java
    (context) -> {
        BuiltResourceReference ref = context.getReference(/* referenceId */);
    }
```

## Mixson APT Entrypoint (Fabric only)
The entrypoint for the Mixson annotation processor was renamed from `mixsonAPT` to `mixson`. This was an oversight
during development that wasn't meant to be shipped.
### Old Example
```json
{
  ...
  "custom": {
    "mixsonAPT": [
      "path.to.the.Class"
    ]
  }
  ...
}
```
### Updated Example
```json
{
  ...
  "custom": {
    "mixson": [
      "path.to.the.Class"
    ]
  }
  ...
}
```

## Events
All annotation events have been replaced with `@MixsonEvent` and `@GenerativeMixsonEvent`. These annotations act the
same as the old ones besides the method definition now always having an `EventContext` parameter.

### Old Example
```java
@ModificationEvent(value = "resourceId")
private static void modid$eventId(JsonElement elem) {
    // content here
}
```
### Updated Example
```java
@MixsonEvent(value = "resourceId")
private static void modid$eventId(EventContext context) {
    JsonElement elem = context.getFile();
    // content here
}
```

## Misc changes

`Mixson#removeEvnts` now takes in `UUID` instead of `Identifier`. the `UUID` is gotten from the registration method when
the event was registered.

the `assertEventRan` methods were removed.
