Class LoadResolver<T>

java.lang.Object
net.thewinnt.cutscenes.util.LoadResolver<T>

public class LoadResolver<T> extends Object
Loads some things that may refer to others of their kind.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    An Exception representing a loop in loading objects.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.slf4j.Logger
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    LoadResolver(BiFunction<com.google.gson.JsonElement,LoadResolver<T>,T> reader, Map<net.minecraft.resources.ResourceLocation,com.google.gson.JsonElement> saveData, boolean allowExceptions)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Map<net.minecraft.resources.ResourceLocation,T>
    Loads all the objects from the save, resolving each object's dependencies.
    resolve(net.minecraft.resources.ResourceLocation id)
    Resolves a single object from its ID, also resolving any objects it depends on.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 JSON
      saveData - the saved items
      allowExceptions - if true, will skip items with errors. Otherwise, will throw the exception that occured when loading.
  • Method Details

    • resolve

      @Nullable public T resolve(net.minecraft.resources.ResourceLocation id)
      Resolves a single object from its ID, also resolving any objects it depends on. If an exception occurs when loading, returns null if allowExceptions is true, and throws the exception otherwise.
      Throws:
      LoadResolver.LoopingReferenceException - in case of an infinite loop
    • load

      public Map<net.minecraft.resources.ResourceLocation,T> 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