Class ModelManager

java.lang.Object
net.mcreator.workspace.resources.ModelManager

public final class ModelManager extends Object
Caches workspace model data that is expensive to load (e.g. texture mappings). Code paths that modify model files in the workspace need to call invalidateCache() or invalidateCache(File) to ensure that the cache is updated on the next request.
  • Constructor Details

    • ModelManager

      public ModelManager(@Nonnull Workspace workspace)
  • Method Details

    • getTextureMappingsForModel

      @Nullable public Map<String, TexturedModel.TextureMapping> getTextureMappingsForModel(Model model)
      Returns texture mappings of the given model, loading them from the texture mappings file on the first request. The returned map is shared and must not be modified.
      Parameters:
      model - Model to get texture mappings for
      Returns:
      Texture mappings keyed by mapping name or null if the model has no texture mappings
    • invalidateCache

      public void invalidateCache(@Nullable File modelFile)
      Invalidates cached data of the given model so it is reloaded from the workspace on the next request
      Parameters:
      modelFile - Model file as returned by Model.getFile()
    • invalidateCache

      public void invalidateCache()
      Invalidates the model cache so model data is reloaded from the workspace on the next request