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

BracketHandlers

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.api.bracket.BracketHandlers;

Description

This class contains the "simple" Bracket handlers from CraftTweaker. However, some Bracket handlers, like for recipeTypes, tags, tagManagers, won't be shown here as they use a different internal structure.

Members

static getAttribute(tokens as string) as Attribute
script.zs
// BracketHandlers.getAttribute(tokens as string) as Attribute;
BracketHandlers.getAttribute(myString);

Parameters:

tokens Type: string

Return Type: Attribute

static getBannerPattern(tokens as string) as BannerPattern
Gets a banner pattern based on registry name. Throws an exception if it can't find the banner pattern.

Returns: The found banner pattern

script.zs
// BracketHandlers.getBannerPattern(tokens as string) as BannerPattern;
BracketHandlers.getBannerPattern("minecraft:square_bottom_left");

Parameters:

tokens Type: string - The banner pattern's resource location

Return Type: BannerPattern

static getBlock(tokens as string) as Block
Gets the give Block. Throws an Exception if not found

Returns: The found Block

script.zs
// BracketHandlers.getBlock(tokens as string) as Block;
BracketHandlers.getBlock("minecraft:dirt");

Parameters:

tokens Type: string - What you would write in the BEP call.

Return Type: Block

static getBlockState(tokens as string) as BlockState
Creates a Blockstate based on the given inputs. Returns null if it cannot find the block, ignored invalid variants

Returns: The found BlockState

script.zs
// BracketHandlers.getBlockState(tokens as string) as BlockState;
BracketHandlers.getBlockState("minecraft:acacia_planks");

Parameters:

tokens Type: string - The block's resource location and variants

Return Type: BlockState

static getComponentType(tokens as string) as DataComponentType<T>
Gets a data component type based on registry name. Throws an exception if it can't find the data component type.

Returns: The found data component type

script.zs
// BracketHandlers.getComponentType(tokens as string) as DataComponentType<T>;
BracketHandlers.getComponentType("minecraft:max_stack_size");

Parameters:

tokens Type: string - The data component type's resource location

Return Type: DataComponentType<T>

static getEnchantment(tokens as string) as Enchantment
Gets the enchantment based on registry name. Throws an error if it can't find the enchantment.

Returns: The found enchantment

script.zs
// BracketHandlers.getEnchantment(tokens as string) as Enchantment;
BracketHandlers.getEnchantment("minecraft:riptide");

Parameters:

tokens Type: string - The enchantment's registry name

Return Type: Enchantment

static getEntityType(tokens as string) as EntityType<Entity>
Gets the entityType based on registry name. Throws an exception if it can't find the entityType.

Returns: The found entityType

script.zs
// BracketHandlers.getEntityType(tokens as string) as EntityType<Entity>;
BracketHandlers.getEntityType("minecraft:pig");

Parameters:

tokens Type: string - The entityType's resource location

Return Type: EntityType<Entity>

static getFluidStack(tokens as string) as IFluidStack
Gets the fluid Stack based on registry name. Throws an error if it can't find the fluid.

Returns: A stack of the liquid with amount == 1mb

script.zs
// BracketHandlers.getFluidStack(tokens as string) as IFluidStack;
BracketHandlers.getFluidStack("minecraft:water");

Parameters:

tokens Type: string - The Fluid's resource location

Return Type: IFluidStack

static getInstrument(tokens as string) as Instrument
Gets an instrument based on registry name. Throws an exception if it can't find the instrument.

Returns: The found instrument

script.zs
// BracketHandlers.getInstrument(tokens as string) as Instrument;
BracketHandlers.getInstrument("minecraft:ponder_goat_horn");

Parameters:

tokens Type: string - The instrument's resource location

Return Type: Instrument

static getItem(tokens as string) as IItemStack
Gets the item based on registry name. Throws an error if it can't find the item.

Returns: The found item

script.zs
// BracketHandlers.getItem(tokens as string) as IItemStack;
BracketHandlers.getItem("minecraft:dirt");

Parameters:

tokens Type: string - The item's resource location

Return Type: IItemStack

static getMobEffect(tokens as string) as MobEffect
Gets the mobeffect based on registry name. Throws an error if it can't find the mobeffect.

Returns: The found mobeffect

script.zs
// BracketHandlers.getMobEffect(tokens as string) as MobEffect;
BracketHandlers.getMobEffect("minecraft:haste");

Parameters:

tokens Type: string - The mobeffect's resource location

Return Type: MobEffect

static getPotion(tokens as string) as Potion
script.zs
// BracketHandlers.getPotion(tokens as string) as Potion;
BracketHandlers.getPotion(myString);

Parameters:

tokens Type: string

Return Type: Potion

static getProfession(tokens as string) as VillagerProfession
Gets the villager profession based on registry name. Throws an exception if it can't find the profession.

Returns: The found profession

script.zs
// BracketHandlers.getProfession(tokens as string) as VillagerProfession;
BracketHandlers.getProfession("minecraft:armorer");

Parameters:

tokens Type: string - The profession's resource location

Return Type: VillagerProfession

static getRecipeManager(tokens as string) as IRecipeManager<?>
Gets the recipeManager based on registry name. Throws an error if it can't find the recipeManager. Throws an exception if the given recipeType is not found.


This will always return IRecipeManager.
There is also a BEP for that but that works differently so it can't be automatically added to the docs here. But the BEP looks the same as the other ones: <recipetype:minecraft:crafting>

Returns: The found recipeManager

script.zs
// BracketHandlers.getRecipeManager(tokens as string) as IRecipeManager<?>;
BracketHandlers.getRecipeManager("minecraft:crafting");

Parameters:

tokens Type: string - The recipeManager's resource location

Return Type: IRecipeManager<?>

static getSoundEvent(tokens as string) as SoundEvent
Gets a sound event based on registry name. Throws an exception if it can't find the sound event.

Returns: The found sound event

script.zs
// BracketHandlers.getSoundEvent(tokens as string) as SoundEvent;
BracketHandlers.getSoundEvent("minecraft:ambient.cave");

Parameters:

tokens Type: string - The sound event's resource location

Return Type: SoundEvent

static getTargetingStrategy(tokens as string) as ITargetingStrategy
Gets an ITargetingStrategy based on its name.

Throws an exception if the strategy doesn't exist.

Returns: The found targeting strategy

script.zs
// BracketHandlers.getTargetingStrategy(tokens as string) as ITargetingStrategy;
BracketHandlers.getTargetingStrategy("crafttweaker:default");

Parameters:

tokens Type: string - The strategy's resource location

Return Type: ITargetingStrategy

static getTrimMaterial(tokens as string) as TrimMaterial
Gets a trim material based on registry name. Throws an exception if it can't find the trim material.

Returns: The found trim material

script.zs
// BracketHandlers.getTrimMaterial(tokens as string) as TrimMaterial;
BracketHandlers.getTrimMaterial("minecraft:quartz");

Parameters:

tokens Type: string - The trim material's resource location

Return Type: TrimMaterial

static getTrimPattern(tokens as string) as TrimPattern
Gets a trim pattern based on registry name. Throws an exception if it can't find the trim pattern.

Returns: The found trim pattern

script.zs
// BracketHandlers.getTrimPattern(tokens as string) as TrimPattern;
BracketHandlers.getTrimPattern("minecraft:sentry");

Parameters:

tokens Type: string - The trim pattern's resource location

Return Type: TrimPattern

static getVillagerType(tokens as string) as VillagerType
Gets the villager profession based on registry name. Throws an exception if it can't find the profession.

Returns: The found profession

script.zs
// BracketHandlers.getVillagerType(tokens as string) as VillagerType;
BracketHandlers.getVillagerType("minecraft:armorer");

Parameters:

tokens Type: string - The profession's resource location

Return Type: VillagerType