Interface ICraftTweakerRegistry
- All Known Implementing Classes:
CraftTweakerRegistry
An instance of this class can be obtained through CraftTweakerAPI.
- Since:
- 9.1.0
-
Method Summary
Modifier and TypeMethodDescriptionfindLoader(String name) Attempts to find anIScriptLoaderwith the given name, if available.findLoadSource(net.minecraft.resources.ResourceLocation id) Attempts to find anIScriptLoadSourcewith the given id, if possible.<T> IRecipeComponent<T>findRecipeComponent(net.minecraft.resources.ResourceLocation id) Obtains theIRecipeComponentwith the given id, if available.Gets all bracket handler possibilities that can be queried under the givenIScriptLoader.Obtains aCollectionof allIScriptLoaders known to CraftTweaker.Obtains aCollectionof allIRecipeComponents known to CraftTweaker.getBracketDumpers(IScriptLoader loader) Obtains a read-onlyMapof all bracket dumpers registered for the givenIScriptLoader.getBracketHandlers(IScriptLoader loader, String rootPackage) Obtains aMapcontaining all known bracket handlers for the givenIScriptLoaderresiding in therootPackage.getConfiguratorFor(IScriptLoader loader) Obtains theIScriptRunModuleConfiguratorthat has been registered for the givenIScriptLoader.getEnumBracketFor(IScriptLoader loader, net.minecraft.resources.ResourceLocation type) Obtains the enumeration class that corresponds to the given id in the queriedIScriptLoader.<T extends Enum<T>>
TgetEnumBracketValue(IScriptLoader loader, net.minecraft.resources.ResourceLocation type, String value) Obtains the enumeration constant that corresponds to the givenIScriptLoader, id, and value as if it were looked up from the<constant>bracket handler.Provides access to the globalIEventRegistry.Gets a read-onlyListof all known preprocessors.<T extends net.minecraft.world.item.crafting.Recipe<?>>
IRecipeHandler<T>getRecipeHandlerFor(Class<T> recipeClazz) Obtains theIRecipeHandlerresponsible for the given recipe class.<T extends net.minecraft.world.item.crafting.Recipe<?>>
IRecipeHandler<T>getRecipeHandlerFor(T recipe) Obtains theIRecipeHandlerresponsible for the given recipe.Offers access to theIReplacerRegistry.<T> TagManagerFactory<T,? extends ITagManager<?>> getTaggableElementFactory(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> key) Gets aTagManagerFactoryfor the givenResourceKey.getTaggableElementFor(net.minecraft.resources.ResourceKey<T> key) Tries to find a taggable element for the givenResourceKey.Gets the globalIZenClassRegistry.
-
Method Details
-
findLoader
Attempts to find anIScriptLoaderwith 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
IScriptLoaderwith 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 aCollectionof allIScriptLoaders known to CraftTweaker.- Returns:
- A read-only collection of all known loaders.
- Since:
- 9.1.0
-
findLoadSource
Attempts to find anIScriptLoadSourcewith 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
IScriptLoadSourcewith 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 globalIZenClassRegistry.- Returns:
- The global
IZenClassRegistry. - Since:
- 9.1.0
-
getConfiguratorFor
Obtains theIScriptRunModuleConfiguratorthat has been registered for the givenIScriptLoader.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
Obtains a read-onlyMapof all bracket dumpers registered for the givenIScriptLoader.Each entry has a key representing the name of the bracket expression for which the dumper is for and a value corresponding to the
IBracketDumperInfofor that bracket expression.- Parameters:
loader- The loader for which the bracket dumpers should be obtained.- Returns:
- A
Mapcontaining the requested data. - Since:
- 9.1.0
-
getBracketHandlers
Obtains aMapcontaining all known bracket handlers for the givenIScriptLoaderresiding in therootPackage.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- TheIScriptLoaderfor which bracket handlers should be queried.rootPackage- The root package under which the bracket handlers should reside.- Returns:
- A
Mapwhose key represents the name of the bracket and the value theBracketExpressionParserresponsible for resolution. - Since:
- 9.1.0
-
getPreprocessors
List<IPreprocessor> getPreprocessors()Gets a read-onlyListof 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 theIRecipeHandlerresponsible 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:
- an
IRecipeHandlerthat 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 theIRecipeHandlerresponsible 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:
- an
IRecipeHandlerthat is able to deal with the given recipe class. - Since:
- 9.1.117
-
findRecipeComponent
Obtains theIRecipeComponentwith the given id, 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.
Take note that all recipe components have a type associated with them. This query does not attempt to verify that the component with the given id reflects the type specified in the type parameter. Care must be taken by the caller of this method to ensure correctness.
- Type Parameters:
T- The type associated with theIRecipeComponent.- Parameters:
id- The name id of the recipe component.- Returns:
- The
IRecipeComponentwith the given name, if available. - Throws:
IllegalArgumentException- If the name does not identify a valid recipe component.- Since:
- 10.0.0
-
getAllRecipeComponents
Collection<IRecipeComponent<?>> getAllRecipeComponents()Obtains aCollectionof allIRecipeComponents known to CraftTweaker.- Returns:
- A read-only collection of all known components.
- Since:
- 10.0.0
-
getEnumBracketValue
<T extends Enum<T>> T getEnumBracketValue(IScriptLoader loader, net.minecraft.resources.ResourceLocation type, String value) Obtains the enumeration constant that corresponds to the givenIScriptLoader, 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- TheIScriptLoaderunder which the enumeration should be queried.type- TheResourceLocationthat 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 queriedIScriptLoader.- Type Parameters:
T- The type of the target enumeration.- Parameters:
loader- TheIScriptLoaderunder which the enumeration should be queried.type- TheResourceLocationthat uniquely identifies the enumeration.- Returns:
- An
Optionalwrapping theClassof the enumeration if it can be identified, an empty optional otherwise. - Since:
- 9.1.0
-
getTaggableElementFor
Tries to find a taggable element for the givenResourceKey.- Type Parameters:
T- The type of element to find.- Parameters:
key- TheResourceKeyto get the element for.- Returns:
- An
Optionalwrapping theClassof 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 aTagManagerFactoryfor the givenResourceKey.Note: If an element is known but does not have an explicit
TagManagerFactory, then a factory for aKnownTagManageris returned. If an element is not known, then a factory for anUnknownTagManageris returned.- Type Parameters:
T- The type of element the factory deals with.- Parameters:
key- TheResourceKeyto get the element factory for.- Returns:
- A
TagManagerFactoryfor the givenResourceKey.
-
getAllEnumStringsForEnumBracket
Gets all bracket handler possibilities that can be queried under the givenIScriptLoader.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- TheIScriptLoaderfor which all validconstantbrackets should be queried.- Returns:
- A
Setof strings of the previously mentioned format. - Since:
- 9.1.0
-
getReplacerRegistry
IReplacerRegistry getReplacerRegistry()Offers access to theIReplacerRegistry.- Returns:
- The
IReplacerRegistry. - Since:
- 10.0.0
-
getEventRegistry
IEventRegistry getEventRegistry()Provides access to the globalIEventRegistry.- Returns:
- The
IEventRegistry. - Since:
- 11.0.0
-