Home Commands Examples Getting Started With Scripts Global Keywords

BracketHandlers

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.

Importing the class

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

script.zs
import crafttweaker.api.bracket.BracketHandlers;

Static Methods

Return Type: Attribute

script.zs
BracketHandlers.getAttribute(tokens as string) as Attribute
ParameterType
Parameter
tokens
Type
string

Gets the give Block. Throws an Exception if not found

Returns: The found Block
Return Type: Block

script.zs
<block:minecraft:dirt>
// BracketHandlers.getBlock(tokens as string) as Block
BracketHandlers.getBlock("minecraft:dirt");
ParameterTypeDescription
Parameter
tokens
Type
string
Description
What you would write in the BEP call.

Creates a Blockstate based on the given inputs.
Returns null if it cannot find the block, ignored invalid variants

Returns: The found BlockState
Return Type: BlockState

script.zs
<blockstate:minecraft:acacia_planks>
<blockstate:minecraft:furnace:facing=north,lit=false>
// BracketHandlers.getBlockState(tokens as string) as BlockState
BracketHandlers.getBlockState("minecraft:acacia_planks");
BracketHandlers.getBlockState("minecraft:furnace:facing=north,lit=false");
ParameterTypeDescription
Parameter
tokens
Type
string
Description
The block’s resource location and variants

Gets the enchantment based on registry name. Throws an error if it can’t find the enchantment.

Returns: The found enchantment
Return Type: Enchantment

script.zs
<enchantment:minecraft:riptide>
// BracketHandlers.getEnchantment(tokens as string) as Enchantment
BracketHandlers.getEnchantment("minecraft:riptide");
ParameterTypeDescription
Parameter
tokens
Type
string
Description
The enchantment’s registry name

Gets the entityType based on registry name. Throws an exception if it can’t find the entityType.

Returns: The found entityType
Return Type: EntityType<Entity>

script.zs
<entitytype:minecraft:pig>
// BracketHandlers.getEntityType(tokens as string) as EntityType<Entity>
BracketHandlers.getEntityType("minecraft:pig");
ParameterTypeDescription
Parameter
tokens
Type
string
Description
The entityType’s resource location

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
Return Type: IFluidStack

script.zs
<fluid:minecraft:water>
// BracketHandlers.getFluidStack(tokens as string) as IFluidStack
BracketHandlers.getFluidStack("minecraft:water");
ParameterTypeDescription
Parameter
tokens
Type
string
Description
The Fluid’s resource location

Gets the item based on registry name. Throws an error if it can’t find the item.

Returns: The found item
Return Type: IItemStack

script.zs
<item:minecraft:dirt>
// BracketHandlers.getItem(tokens as string) as IItemStack
BracketHandlers.getItem("minecraft:dirt");
ParameterTypeDescription
Parameter
tokens
Type
string
Description
The item’s resource location

Gets the mobeffect based on registry name. Throws an error if it can’t find the mobeffect.

Returns: The found mobeffect
Return Type: MobEffect

script.zs
<mobeffect:minecraft:haste>
// BracketHandlers.getMobEffect(tokens as string) as MobEffect
BracketHandlers.getMobEffect("minecraft:haste");
ParameterTypeDescription
Parameter
tokens
Type
string
Description
The mobeffect’s resource location

Return Type: Potion

script.zs
BracketHandlers.getPotion(tokens as string) as Potion
ParameterType
Parameter
tokens
Type
string

Gets the villager profession based on registry name. Throws an exception if it can’t find the profession.

Returns: The found profession
Return Type: VillagerProfession

script.zs
<profession:minecraft:armorer>
// BracketHandlers.getProfession(tokens as string) as VillagerProfession
BracketHandlers.getProfession("minecraft:armorer");
ParameterTypeDescription
Parameter
tokens
Type
string
Description
The profession’s resource location

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:

Returns: The found recipeManager
Return Type: IRecipeManager

script.zs
// BracketHandlers.getRecipeManager(tokens as string) as IRecipeManager
BracketHandlers.getRecipeManager("minecraft:crafting");
ParameterTypeDescription
Parameter
tokens
Type
string
Description
The recipeManager’s resource location
Deprecated
Use ResourceLocationBracketHandler #getResourceLocation(String) instead.

Creates a Resource location based on the tokens.
Throws an error if the tokens are not a valid location.

Returns: The location
Return Type: ResourceLocation

script.zs
// BracketHandlers.getResourceLocation(tokens as string) as ResourceLocation
BracketHandlers.getResourceLocation("minecraft:dirt");
ParameterTypeDescription
Parameter
tokens
Type
string
Description
The resource location

Gets a sound event based on registry name. Throws an exception if it can’t find the sound event.

Returns: The found sound event
Return Type: SoundEvent

script.zs
<soundevent:minecraft:ambient.cave>
// BracketHandlers.getSoundEvent(tokens as string) as SoundEvent
BracketHandlers.getSoundEvent("minecraft:ambient.cave");
ParameterTypeDescription
Parameter
tokens
Type
string
Description
The sound event’s resource location

Gets an ITargetingStrategy based on its name.

Throws an exception if the strategy doesn’t exist.

Returns: The found targeting strategy
Return Type: ITargetingStrategy

script.zs
<targetingstrategy:crafttweaker:default>
// BracketHandlers.getTargetingStrategy(tokens as string) as ITargetingStrategy
BracketHandlers.getTargetingStrategy("crafttweaker:default");
ParameterTypeDescription
Parameter
tokens
Type
string
Description
The strategy’s resource location

Gets the villager profession based on registry name. Throws an exception if it can’t find the profession.

Returns: The found profession
Return Type: VillagerType

script.zs
<villagertype:minecraft:armorer>
// BracketHandlers.getVillagerType(tokens as string) as VillagerType
BracketHandlers.getVillagerType("minecraft:armorer");
ParameterTypeDescription
Parameter
tokens
Type
string
Description
The profession’s resource location