Package net.thewinnt.cutscenes.util
Class LoadResolver<T>
java.lang.Object
net.thewinnt.cutscenes.util.LoadResolver<T>
Loads some things that may refer to others of their kind.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn Exception representing a loop in loading objects. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLoadResolver(BiFunction<com.google.gson.JsonElement, LoadResolver<T>, T> reader, Map<net.minecraft.resources.ResourceLocation, com.google.gson.JsonElement> saveData, boolean allowExceptions) -
Method Summary
-
Field Details
-
LOGGER
public static final org.slf4j.Logger LOGGER
-
-
Constructor Details
-
LoadResolver
public LoadResolver(BiFunction<com.google.gson.JsonElement, LoadResolver<T>, T> reader, Map<net.minecraft.resources.ResourceLocation, com.google.gson.JsonElement> saveData, boolean allowExceptions) - Parameters:
reader- a function that loads an object from JSONsaveData- the saved itemsallowExceptions- if true, will skip items with errors. Otherwise, will throw the exception that occured when loading.
-
-
Method Details
-
resolve
Resolves a single object from its ID, also resolving any objects it depends on. If an exception occurs when loading, returnsnullifallowExceptionsistrue, and throws the exception otherwise.- Throws:
LoadResolver.LoopingReferenceException- in case of an infinite loop
-
load
Loads all the objects from the save, resolving each object's dependencies.- Returns:
- a map of ids to objects
- Throws:
LoadResolver.LoopingReferenceException- in case of an infinite loop
-