Mask

<mask>

Masks define which blocks or positions can participate in a WorldEdit operation.

A mask is a condition that decides whether a block or position can participate in an operation.

Mask Placeholder

<mask>

The placeholder is not written literally. Replace it with a valid mask expression.

A mask does not determine which block is placed. It only determines which existing blocks or positions match the condition.

Mask and Pattern Example

;replace stone dirt

In this example:

  • stone is the mask.
  • dirt is the pattern.

Block Masks

The simplest mask is a block identifier.

Block Mask

stone

A block identifier without states matches that block regardless of its current states.

A namespace can be included:

Namespaced Block Mask

minecraft:stone

Blocks from another add-on must use their own namespace:

Custom Block Mask

my_addon:custom_block

To inspect the identifier and states of the block you are looking at:

Inspect Block

;blockid

Block State Masks

A block mask can require one or more exact states.

Single Block State

block[state=value]

Separate multiple states with commas:

Multiple Block States

block[state1=value,state2=value]

Example:

Exact Block State Example

oak_stairs[weirdo_direction=0,upside_down_bit=false]

State names and accepted values can change between Minecraft versions.

Union with ,

A comma represents OR. Only one condition needs to match.

Union Syntax

mask1,mask2,mask3

Example:

Multiple Block Union

stone,dirt,gravel

This matches stone, dirt, or gravel.

Do not add spaces after commas inside a union.

Intersection with Spaces

A space represents AND. Every condition must match.

Intersection Syntax

mask1 mask2

Because commands also use spaces to separate arguments, wrap the complete mask expression in quotes:

Quoted Intersection

"stone #surface"

This matches blocks that are both stone and exposed surface blocks.

Grouping with Parentheses

Parentheses group parts of a complex expression and make operator precedence explicit.

Grouped Mask

"(stone,andesite) #surface"

This means:

Grouped Mask Meaning

(stone OR andesite) AND surface

Use parentheses when combining unions, intersections, negation, or offset masks.

Negation with !

The ! prefix inverts a mask.

Negation Syntax

!mask

Match everything except air:

Exclude Air

!air

Exclude an entire group:

Negated Group

!(sand,gravel,dirt)

Negation can also apply to advanced masks:

Visible Surface Mask

"#surface !#shadow"

Existing Blocks with #existing

#existing matches every block that is not air.

Existing Block Mask

#existing

It is approximately equivalent to:

Equivalent Existing Mask

!air

#existing means not air. It does not necessarily mean solid. It can include fluids, vegetation, and other non-air blocks.

Offset Masks with < and >

Offset masks inspect a neighboring vertical block.

OperatorCondition
<maskThe block above must match
>maskThe block below must match

Match dirt with air above it:

Check the Block Above

"dirt <air"

Match air with stone below it:

Check the Block Below

"air >stone"

Offset conditions can contain grouped masks:

Grouped Offset Mask

"air >(dirt,grass_block)"

Nested offsets are supported by the current parser:

Repeated Offset

<<air

This checks two blocks above the evaluated position. Test nested offsets on a small area before using them in a large operation.

Random Masks with %

A random mask matches each position independently with the specified probability.

Random Mask Syntax

%percentage

Match approximately 20% of all evaluated positions:

Twenty Percent Mask

%20

Combine it with another mask to match approximately 20% of stone:

Random Stone Intersection

"stone %20"

The result is probabilistic, not an exact block count. Repeating the same operation can match different positions.

State-Only Masks

State-only masks compare block states without requiring a specific block identifier.

Two modes are available:

  • Flexible: ^[state=value]
  • Strict: ^=[state=value]

Flexible State Matching

Flexible State Mask

^[state=value]

The flexible form matches when:

  • The block has the state with the requested value, or
  • The block does not have that state.

Because of this, it can match more blocks than expected.

Strict State Matching

Strict State Mask

^=[state=value]

The strict form requires the block to contain the state and have exactly the requested value.

Example:

Strict Axis State

^=[pillar_axis=0]

Use the strict form when the state must exist.

Multiple State Conditions

Flexible Multiple States

^[state1=value,state2=value]

Strict Multiple States

^=[state1=value,state2=value]

Surface Masks

#surface matches a non-air block with at least one directly adjacent air block.

Surface Mask

#surface

Alias:

Surface Mask Alias

#exposed

The six adjacent directions are checked:

  • Up
  • Down
  • North
  • South
  • East
  • West

Combine it with a block mask:

Stone Surface Mask

"stone #surface"

The implementation specifically checks for adjacent air. A block next to water or lava is not necessarily considered exposed.

Surface Slope Ranges

A surface mask can restrict the approximate slope angle.

Surface Slope Syntax

#surface[min:max]

Examples:

Flat Surface Range

#surface[0:15]

Medium Slope Range

#surface[10:45]

Steep Surface Range

#surface[50:90]

The range is conceptually measured from to 90°.

Vegetation, flowers, and small decorative blocks can affect the calculated slope.

In latest, use #surface[min:max] instead of the older #slope[min:max] syntax.

Shadow Masks

#shadow matches blocks that are not visible from WorldEdit’s current placement reference.

Shadow Mask

#shadow

Match hidden exposed blocks:

Hidden Surface Mask

"#surface #shadow"

Match visible exposed blocks:

Visible Surface Mask

"#surface !#shadow"

For better performance, combine #shadow with #surface instead of evaluating every internal block.

Block Tag Masks

The current parser supports masks based on block tags.

Block Tag Mask

##tag

Namespaced example:

Namespaced Block Tag

##my_addon:natural_block

Available tags depend on Minecraft, installed add-ons, and tags exposed by the API. Do not assume that a tag exists without confirming it.

Global Masks with ;gmask

A global mask is stored in the player’s WorldEdit session and applies to compatible operations.

Global Mask Syntax

;gmask [mask]

Set a global mask:

Set Global Mask

;gmask #existing

Set a compound global mask:

Compound Global Mask

;gmask "stone #surface"

Clear the active global mask by running the command without an argument:

Clear Global Mask

;gmask

A global mask belongs to the current player session. It is not a server-wide rule.

Not every command uses the global mask. When a command accepts a direct <mask>, [mask], or -m <mask> argument, prefer that direct mask.

Mask Picker

The WorldEdit kit includes a Mask Picker.

Get the Mask Picker

;kit
  • Use it on a block without crouching to create a new global mask.
  • Crouch and use it on additional blocks to add them as a union.
  • Clear the resulting global mask with ;gmask.

The Mask Picker stores the selected block’s full permutation, including its states. A manually written mask such as oak_stairs is broader because it does not require one exact orientation unless states are specified.

Brush Destination Masks with ;mask

;mask controls which destination blocks a held brush can modify.

Brush Mask Syntax

;mask [mask]

Set a brush destination mask:

Set Brush Mask

;mask #existing

Clear it:

Clear Brush Mask

;mask

The mask belongs to the brush configuration attached to the held item.

Brush Trace Masks with ;tracemask

;tracemask controls which blocks a brush can target or use as an impact point.

Trace Mask Syntax

;tracemask [mask]

Set a trace mask:

Set Trace Mask

;tracemask stone

Clear it:

Clear Trace Mask

;tracemask

The difference is:

CommandPurpose
;maskWhich blocks inside the brush volume can be modified
;tracemaskWhich block the brush can target

Combining Active Masks

Masks applied through different systems are combined as an intersection. Every active condition must match.

Conceptually:

Combined Mask Logic

direct mask
AND global mask
AND brush mask

An incompatible combination can prevent an operation from changing anything.

Before diagnosing a mask problem, clear temporary masks:

Clear Active Masks

;mask
;tracemask
;gmask

Then enable only the condition required for the current operation.

Common Mistakes

Confusing a Mask with a Pattern

A mask selects the existing destination. A pattern determines the result that is placed.

Forgetting Quotes

An intersection containing spaces must be quoted.

Incorrect:

Invalid Unquoted Intersection

stone #surface

Correct:

Valid Quoted Intersection

"stone #surface"

Adding Spaces after Commas

Avoid:

Invalid Spaced Union

stone, dirt, gravel

Use:

Valid Compact Union

stone,dirt,gravel

Confusing < and >

Offset Direction Reminder

<air   = air above
>stone = stone below

Treating #existing as Solid Only

#existing means any block that is not air.

Using Flexible State Matching When Strict Matching Is Required

Use ^=[state=value] when the state must exist on the block.

Expecting an Exact Random Percentage

%20 is an independent probability for each position. It does not guarantee an exact 20% total.

Forgetting an Active Global or Brush Mask

An old mask can silently combine with the current one and make the final condition too restrictive.

Quick Reference

MaskMeaning
stoneStone, regardless of unspecified states
stone,dirtStone or dirt
"stone #surface"Stone and exposed surface
!airEverything except air
#existingAny non-air block
<airAir above the evaluated position
>stoneStone below the evaluated position
%20Approximately 20% probability
^[state=value]Flexible state comparison
^=[state=value]Strict state comparison
#surfaceNon-air block adjacent to air
#exposedAlias of #surface
#surface[10:45]Exposed surface within a slope range
#shadowHidden from the placement reference
!#shadowVisible from the placement reference
##tagBlock containing an API tag
(stone,dirt)Grouped union

Reusable Templates

Block Mask Template

<block>

Union Template

<mask1>,<mask2>,<mask3>

Intersection Template

"<mask1> <mask2>"

Negation Template

!<mask>

Offset Template

"<mask> >(<mask1>,<mask2>)"

Random Intersection Template

"<mask> %<percentage>"

Strict State Template

^=[state=value]

Surface Range Template

#surface[min:max]