Interface ICraftTweakerRegistry

All Known Implementing Classes:
CraftTweakerRegistry

public interface ICraftTweakerRegistry
Provides access to information stored by all CraftTweaker registries.

An instance of this class can be obtained through CraftTweakerAPI.

Since:
9.1.0
  • Method Details

    • findLoader

      IScriptLoader findLoader(String name)
      Attempts to find a IScriptLoader with the given name, if available.

      This method can be called only after all registries have been successfully built: attempting to call this method before that might lead to undefined behavior. It is also illegal to attempt to query the global loader through this method.

      Parameters:
      name - The name of the loader that should be found. It cannot be the global loader.
      Returns:
      The IScriptLoader with the given name, if available.
      Throws:
      IllegalArgumentException - If the name does not identify a known loader, or if it refers to the global loader.
      Since:
      9.1.0
    • getAllLoaders

      Collection<IScriptLoader> getAllLoaders()
      Obtains a Collection of all IScriptLoaders known to CraftTweaker.
      Returns:
      A read-only collection of all known loaders.
      Since:
      9.1.0
    • findLoadSource

      IScriptLoadSource findLoadSource(net.minecraft.resources.ResourceLocation id)
      Attempts to find a IScriptLoadSource with the given id, if possible.

      This method can be called only after all registries have been successfully built: attempting to call this method before that might lead to undefined behavior.

      Parameters:
      id - The id of the load source that should be found.
      Returns:
      The IScriptLoadSource with the given id, if available.
      Throws:
      IllegalArgumentException - If the name does not identify a known load source.
      Since:
      9.1.0
    • getZenClassRegistry

      IZenClassRegistry getZenClassRegistry()
      Gets the global IZenClassRegistry.
      Returns:
      The global IZenClassRegistry.
      Since:
      9.1.0
    • getConfiguratorFor

      IScriptRunModuleConfigurator getConfiguratorFor(IScriptLoader loader)
      Obtains the IScriptRunModuleConfigurator that has been registered for the given IScriptLoader.

      This method must be called only after all registries have been successfully built: earlier calls will result in undefined behavior.

      Parameters:
      loader - The loader for which the configurator should be obtained for.
      Returns:
      The corresponding IScriptRunModuleConfigurator.
      Since:
      9.1.0
    • getBracketDumpers

      Map<String,IBracketDumperInfo> getBracketDumpers(IScriptLoader loader)
      Obtains a read-only Map of all bracket dumpers registered for the given IScriptLoader.

      Each entry has a key representing the name of the bracket expression for which the dumper is for and a value corresponding to the IBracketDumperInfo for that bracket expression.

      Parameters:
      loader - The loader for which the bracket dumpers should be obtained.
      Returns:
      A Map containing the requested data.
      Since:
      9.1.0
    • getBracketHandlers

      Map<String,BracketExpressionParser> getBracketHandlers(IScriptLoader loader, String rootPackage)
      Obtains a Map containing all known bracket handlers for the given IScriptLoader residing in the rootPackage.

      The concept of package used in this method corresponds to the ZenCode concept instead of the Java concept. This means that also bracket handlers in the various sub-packages will also be queried.

      Parameters:
      loader - The IScriptLoader for which bracket handlers should be queried.
      rootPackage - The root package under which the bracket handlers should reside.
      Returns:
      A Map whose key represents the name of the bracket and the value the BracketExpressionParser responsible for resolution.
      Since:
      9.1.0
    • getPreprocessors

      List<IPreprocessor> getPreprocessors()
      Gets a read-only List of all known preprocessors.
      Returns:
      All known preprocessors.
      Since:
      9.1.0
    • getRecipeHandlerFor

      <T extends net.minecraft.world.item.crafting.Recipe<?>> IRecipeHandler<T> getRecipeHandlerFor(T recipe)
      Obtains the IRecipeHandler responsible for the given recipe.
      Type Parameters:
      T - The type of the recipe whose handler should be identified.
      Parameters:
      recipe - The recipe whose handler should be identified.
      Returns:
      A IRecipeHandler that is able to deal with the given recipe.
      Since:
      9.1.0
    • getRecipeHandlerFor

      <T extends net.minecraft.world.item.crafting.Recipe<?>> IRecipeHandler<T> getRecipeHandlerFor(Class<T> recipeClazz)
      Obtains the IRecipeHandler responsible for the given recipe class.
      Type Parameters:
      T - The type of the recipe whose handler should be identified.
      Parameters:
      recipeClazz - The recipe class whose handler should be identified.
      Returns:
      A IRecipeHandler that is able to deal with the given recipe class.
      Since:
      9.1.117
    • getEnumBracketValue

      <T extends Enum<T>> T getEnumBracketValue(IScriptLoader loader, net.minecraft.resources.ResourceLocation type, String value)
      Obtains the enumeration constant that corresponds to the given IScriptLoader, id, and value as if it were looked up from the <constant> bracket handler.
      Type Parameters:
      T - The type of the target enumeration.
      Parameters:
      loader - The IScriptLoader under which the enumeration should be queried.
      type - The ResourceLocation that uniquely identifies the enumeration.
      value - The value of the enumeration that should be obtained.
      Returns:
      The enumeration value that would be obtained by the bracket handler.
      Since:
      9.1.0
    • getEnumBracketFor

      <T extends Enum<T>> Optional<Class<T>> getEnumBracketFor(IScriptLoader loader, net.minecraft.resources.ResourceLocation type)
      Obtains the enumeration class that corresponds to the given id in the queried IScriptLoader.
      Type Parameters:
      T - The type of the target enumeration.
      Parameters:
      loader - The IScriptLoader under which the enumeration should be queried.
      type - The ResourceLocation that uniquely identifies the enumeration.
      Returns:
      An Optional wrapping the Class of the enumeration if it can be identified, an empty optional otherwise.
      Since:
      9.1.0
    • getTaggableElementFor

      <T> Optional<Class<T>> getTaggableElementFor(net.minecraft.resources.ResourceKey<T> key)
      Tries to find a taggable element for the given ResourceKey.
      Type Parameters:
      T - The type of element to find.
      Parameters:
      key - The ResourceKey to get the element for.
      Returns:
      An Optional wrapping the Class of the taggable element if it can be found, an empty optional otherwise.
    • getTaggableElementFactory

      <T> TagManagerFactory<T,? extends ITagManager<?>> getTaggableElementFactory(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> key)
      Gets a TagManagerFactory for the given ResourceKey.

      Note: If an element is known but does not have an explicit TagManagerFactory, then a factory for a KnownTagManager is returned. If an element is not known, then a factory for an UnknownTagManager is returned.

      Type Parameters:
      T - The type of element the factory deals with.
      Parameters:
      key - The ResourceKey to get the element factory for.
      Returns:
      A TagManagerFactory for the given ResourceKey.
    • getAllEnumStringsForEnumBracket

      Set<String> getAllEnumStringsForEnumBracket(IScriptLoader loader)
      Gets all bracket handler possibilities that can be queried under the given IScriptLoader.

      The data of the returned set corresponds to strings of the form <constant:id:constant>, where id represents the unique identifier of the enumeration in the given loader and constant the name of the constant under that enumeration.

      Parameters:
      loader - The IScriptLoader for which all valid constant brackets should be queried.
      Returns:
      A Set of strings of the previously mentioned format.
      Since:
      9.1.0