mixson

The Referencing System

The referencing system allows events to capture the values of other resources to assist in their task. An example of this would be an event that aims to copy the texture from the netherite chestplate to the diamond chestplate model. Although the event could explicitly change the texture with a string literal, the textures would not match if the netherite chestplate's model changes. The referencing system will provide the netherite chestplate model for the event to use when modifying the diamond chestplate model.

The referencing system starts through creating an instance of ResourceReference. ResourceReference takes in three required parameters and one optional one:

ResourceReference(int priority, String resourceId, String referenceId, int ordinal);
ResourceReference(int priority, String resourceId, String referenceId);

The resourceId is the identifier for the resource the reference is to copy.

The referenceId is the identifier that will be used to retrieve a BuiltResourceReference from the EventContext during runtime.

The BuiltResourceReference is an instance of a referenced resource that is provided to an event.

The object has a single method of use to the user:

Optional<JsonElement> retrieve();

This method will provide the referenced resource.

The Optional<JsonElement> will only be empty if the reference had not been fulfilled either due to it being pointed to a nonexistent resource, or the priority of the reference is greater than the event, meaning the reference will get filled after the event gets processed. The resource is not discarded since a reference may be used multiple times by an event.