Home Commands Examples Getting Started With Scripts Global Keywords
BracketDumpers BracketHandlers BracketValidators ResourceLocationBracketHandler

NameUtil

Importing the class

If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to import it. Simply add the import at the top of the file.

script.zs
import crafttweaker.util.NameUtil;

Description

Set of utility methods related to names and naming in general.

Members

static fixing(input as string) as string
Attempts to automatically fix the given input string, if possible, so that it can be used to build a well-formed ResourceLocation.
IllegalArgumentException If the string cannot be automatically fixed.
ResourceLocationException If the string cannot be automatically fixed.

Returns: The fixed string.

script.zs
// NameUtil.fixing(input as string) as string;
NameUtil.fixing(myString);

Parameters:

input Type: string - The string that should be fixed to a ResourceLocation-compatible format.

Return Type: string

static fixing(input as string, mistakeHandler as BiConsumer<string, List<string>>) as string
Attempts to automatically fix the given input string, if possible, so that it can be used to build a well-formed ResourceLocation.
IllegalArgumentException If the string cannot be automatically fixed.
ResourceLocationException If the string cannot be automatically fixed.

Returns: The fixed string.

script.zs
// NameUtil.fixing(input as string, mistakeHandler as BiConsumer<string, List<string>>) as string;
NameUtil.fixing(myString, myBiConsumer);

Parameters:

input Type: string - The string that should be fixed to a ResourceLocation-compatible format.
mistakeHandler Type: BiConsumer<string, List<string>> - A bi-consumer that gets called if there were any mistakes in the original string. The first
element is the fixed string, and the second is a list of strings containing explanations
for all the identified mistakes.

Return Type: string

static fromFixedName(input as string) as ResourceLocation
Creates a ResourceLocation from the given input, if possible, while fixing mistakes that may be present in the string.
IllegalArgumentException If the string cannot be automatically fixed.
ResourceLocationException If the string cannot be automatically fixed.

Returns: A ResourceLocation that represents the fixed input.

script.zs
// NameUtil.fromFixedName(input as string) as ResourceLocation;
NameUtil.fromFixedName(myString);

Parameters:

input Type: string - The string that should be fixed and converted to a ResourceLocation.

Return Type: ResourceLocation

static fromFixedName(input as string, mistakeHandler as BiConsumer<string, List<string>>) as ResourceLocation
Creates a ResourceLocation from the given input, if possible, while fixing mistakes that may be present in the string.
IllegalArgumentException If the string cannot be automatically fixed.
ResourceLocationException If the string cannot be automatically fixed.

Returns: A ResourceLocation that represents the fixed input.

script.zs
// NameUtil.fromFixedName(input as string, mistakeHandler as BiConsumer<string, List<string>>) as ResourceLocation;
NameUtil.fromFixedName(myString, myBiConsumer);

Parameters:

input Type: string - The string that should be fixed and converted to a ResourceLocation.
mistakeHandler Type: BiConsumer<string, List<string>> - A bi-consumer that gets called if there were any mistakes in the original string. The first
element is the fixed string, and the second is a list of strings containing explanations
for all the identified mistakes.

Return Type: ResourceLocation

static isAutogeneratedName(name as ResourceLocation) as bool
Verifies whether the given name has been autogenerated by CraftTweaker.

Returns: Whether the name has been autogenerated by CraftTweaker.

script.zs
// NameUtil.isAutogeneratedName(name as ResourceLocation) as bool;
NameUtil.isAutogeneratedName(myResourceLocation);

Parameters:

name Type: ResourceLocation - The name to verify.

Return Type: bool