Bedrock Wiki
  • Discord
  • Contribute
  • bedrock.dev
  • MS Learn
Beginner's Guide
  • Guide
    • 1. Introduction
      guide
    • 2. Add-Ons Explained
    • 3. Software & Preparation
    • 4. Project Setup
    • 5. Create a Custom Item
    • 6. Create a Custom Entity
    • 7. Blockbench: Modeling, Texturing & Animating
    • 8. Adding a Loot Table, Spawn Rule & Crafting Recipe
  • Extra
    • a. Understanding JSON
    • b. Download Example Packs
    • c. Troubleshooting
      help
    • d. Advanced Manifest
    • e. Format Versions
    • f. Project Setup Android
Animation Controllers
  • Intro to Animation Controllers
    guide
  • Entity Commands
  • AFK Detector
  • Death Commands
  • Molang into Scoreboard
  • Respawn Commands
Blocks
  • General
    • Intro to Blocks
      guide
    • Block Components
    • Block Tags
    • Block States
    • Block Traits
    • Block Permutations
    • Block Events
      Scripts
    • Block Event Migration
      help
    • Blocks as Items
    • Troubleshooting Blocks
      help
  • Visuals
    • Block Culling
    • Block Models
      guide
    • Block Texture Animation
    • Block Texture Variation
    • Block Tinting
  • Tutorials
    • Applying Constant Effects
      Scripts
    • Avoiding State Limit
    • Fake Blocks
    • Ore Loot Tables
      Scripts
    • Precise Interaction
      Scripts
    • Precise Rotation
      Scripts
    • Rotatable Blocks
  • Vanilla Re-Creations
    • Custom Crops
      Scripts
    • Custom Glass
    • Custom Glazed Terracotta
    • Custom Trapdoors
      Scripts
  • Documentation
    • Block Format History
    • Block Shapes
    • Block Sounds
    • Vanilla Block Models
Commands
  • General
    • Intro to Command Blocks
    • Functions
    • Block States
    • Coordinate System
    • NBT Commands
    • Scoreboard Operations
    • Understanding Selectors
  • Commands
    • Damage
    • Execute
    • Playanimation
    • Playsound
  • On Event Systems
    • On Player First Join
    • On Player Join
    • On Player Leave
    • On Player Death
    • On Player Respawn
    • On First World Load
  • Scoreboard Systems
    • Entity Counter
    • Scoreboard Timers
    • Comparing And Retrieving Scores
  • Techniques
    • Execute Logic Gates
    • MBE - Max's Block Entity
    • FMBE - A New Way to Create Display Entities
    • Look Detection
    • Movement Detections
    • Orbital Camera
  • Useful Creations
    • Custom Crafter
    • Multiplayer Position Rearrangement
      function
Concepts
  • contents.json
  • Emojis & Symbols
  • Molang
  • Namespaces
  • Overwriting Assets
  • Raw Text
  • Shaders
  • Sounds
  • Subpacks
  • Text and Localization
  • Texture Atlases
  • textures_list.json
Documentation
  • Shared Constructs
  • Advanced Molang
  • File Types
  • Fog IDs
  • Material Configuration Description
  • Menu Categories
  • Molang Queries
  • Pack Folder Structure
  • Sound Definitions
  • Vanilla Materials
Entities
  • General
    • Intro to Entities BP
      guide
    • Intro to Entities RP
      guide
    • Troubleshooting Entities
      help
    • Entity Events
    • Entity Properties
    • NPC Dialogues
    • Render Controllers
    • Spawn Rules
  • Tutorials
    • Convert Points Between Any Space (World, Entity, Bones)
    • Creating Boats
    • Detecting Other Entities
    • Disabling Team Damage
    • Dummy Entities
    • Entity Attacks
    • Entity Holds Item
    • Entity Movement
    • Entity Timers
    • Flying Entities
    • Introduction to AOE Clouds
    • Invulnerable Entities
    • Look at Entity
    • Sleeping Entities
    • Solid Entities
    • Spawning Tamed Entities
      Scripts
    • Village Mechanic
  • Documentation
    • Dummy Components
    • Non-Mob Runtime Identifiers
    • Projectiles
    • Runtime Identifiers
    • Vanilla Usage Components
    • Vanilla Usage Spawn Rules
Items
  • General
    • Intro to Items
      guide
    • Item Components
    • Item Tags
    • Item Events
      Scripts
    • Item Event Migration
      help
    • Troubleshooting Items
      help
  • Tutorials
    • Custom Armor
    • Custom Food
      Scripts
    • Custom Pottery Sherds
    • Custom Weapons
    • Equipment-Based Commands
    • High Resolution Items
    • Spawning Items
    • Throwable Items
  • Documentation
    • Enchantments
    • Attachables
    • Item Format History
    • Numerical Item IDs
    • Vanilla Item Identifiers
    • Vanilla Usage Components
JSON UI
  • General
    • Intro to JSON UI
      guide
    • Best Practices
      guide
  • Tutorials
    • Adding HUD Elements
    • Aseprite Animations
    • Buttons and Toggles
    • Modifying Server Forms
    • Preserve Title Texts
    • String to Number
  • Documentation
    • JSON UI Documentation
Loot, Recipes & Trading
  • General
    • Trading Behavior
  • Documentation
    • Loot Tables
    • Trade Tables
    • Recipes
    • Item Functions
  • Tutorials
    • Randomized Structure Loot
Meta
  • Add-On Performance
  • Style Guide
  • Useful Links
  • Using Schemas
  • Version Control
  • Q&A
    • Blocks and Items Q&A 2024/08/30
    • Deferred Technical Preview Q&A 2024/02/23
    • GameTest Q&A 2021/08/06
    • Scripting and Editor Q&A 2023/09/22
    • World Generation Q&A 2024/11/15
NBT
  • General
    • .mcstructure
  • Tutorials
    • Experiments in Education Edition
    • Extending Structure Limits
  • NBT in Depth
    • About NBT (Named Binary Tag)
    • NBT Libraries
    • Reading NBT Example
Particles
  • General
    • Intro to Particles
      guide
  • Tutorials
    • Disabling Particles
  • Documentation
    • Vanilla Particles
Scripting
  • General
    • Intro to Scripting
    • What is Script API?
    • API Modules
  • Tutorials
    • Block Placement Prevention
    • GameTests
    • Script Core Features
    • Script Forms
    • Script Requests API
    • Simple Chat Commands
  • Documentation
    • Engine Environment
    • Script Resources
    • Script Watchdog
    • Troubleshooting JavaScript
    • TypeScript
Servers
  • Software
    • Bedrock Server Software
  • Protocols
    • Bedrock Protocol
    • NetherNet Protocol
    • RakNet Protocol
Visuals
  • General
    • Introduction to Entity Visuals
      guide
    • Bedrock Modeling
    • Custom Death Animations
    • Effects in Animations
    • Material Creations
    • Materials
    • Math-Based Animations
    • Skin Packs
  • Tutorials
    • Entity Texture Animation
    • Glowing Entity Texture
    • Hurt Animations
    • Leash Position
    • Player Geometry
    • Remove Entity Shadows
    • Retexturing Spawn Eggs
  • Ideas
    • Structure Presentation
World Generation
  • General
    • Intro to World Generation
      guide
    • Biomes
      guide
    • Feature Types
    • Jigsaw Structures
  • Tutorials
    • Block Conditions for Features
    • Generating Custom Ores
    • Generating Custom Structures
    • Generating Patches
    • Heightmap Noise
  • Documentation
    • Biome Tags

Equipment-Based Commands

intermediate
Equipment-Based Commands
  • Command Selector Method
  • Server Animation Method
    • Applying Item Tags
    • Player Behavior
    • Conclusion
    • Additions

A common concept for add-ons is implementing new armor sets with unique effects, just like the turtle shell. Items don't have a component for inflicting mob effects, emitting particles, etc. under certain conditions. However, using the hasitem command selector or server animations, this can easily be done!

Command Selector Method ​

The hasitem selector parameter can be used to target entities based on the items in their equipment slots.

You can view a list of additional slot identifiers at the Minecraft Wiki.

Target Selector
c
@e[hasitem={item=wiki:custom_helmet,location=slot.armor.head}]
1

By using a function that is listed in the tick.json file, we can run commands using this selector every tick.

For example, to make a custom helmet give its wearer jump boost, the following function could be used:

RP/functions/wiki/custom_helmet_effects.mcfunction
c
effect @e[hasitem={item=wiki:custom_helmet,location=slot.armor.head}] jump_boost 10
1
BP/functions/tick.json
json
{
    "values": ["wiki/custom_helmet_effects"]
}
1
2
3

Server Animation Method ​

Keep in mind that this requires modifying the player behavior, which is a common theme for many add-ons; thus, your add-on may not be compatible with others if you wish to do this.

The first step will be to create a server animation, which is a file that runs commands or events at certain keyframes. While client animations are in the resource pack, server animations are in the behavior pack. You can read a bit more here. We can start by using the following as a template:

BP/animations/player.json
json
{
    "format_version": "1.10.0",
    "animations": {
        "animation.player.emerald_armor": {
            "animation_length": 0.05,
            "loop": true,
            "timeline": {
                "0.0": []
            }
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12

Let's go over what's in this template and what everything does:

  • animation.player.emerald_armor is our animation's identifier; you can change this to something else, such as animation.player.phantom_armor.
  • animation_length is how long the animation lasts; we'll use 0.05 seconds, as that's the length of an in-game tick.
  • loop is quite straight-forward; setting it to true makes the animation loop.
  • timeline runs commands and events at given keyframes.

We can add commands to the 0.0 array in our timeline to execute, such as an /effect command, like such:

json
{
    "0.0": ["/effect @s speed 1 0"]
}
1
2
3

We're not limited to /effect, of course. If you want to use some other command, such as /function or /particle, go right ahead!

After this, we're finished in our server animation, and we'll head into the behavior file for our item for a quick addition.

Applying Item Tags ​

To actually check if our item is equipped, we can use a Molang query that checks for item tags.

You can skip this section if:

  • You want check for a vanilla item instead, such as an iron armor piece through the minecraft:iron_tier tag
  • You want to check for the item via q.is_item_name_any, which checks for an item identifier in any slot

In our item's behavior, we'll have to add a tag. For example, if we wanted to add the wiki:emerald_tier tag, we would add the following to the tags component:

minecraft:item > components
json
"minecraft:tags": {
    "tags": ["wiki:emerald_tier"]
}
1
2
3

That's it, now your item has whatever tag you assigned it! You can add more tags if you want, but this is all we need for what we're doing.

Player Behavior ​

Finally, we need to modify the player's behavior to run the server animation. We'll be working entirely within description.

First, we need to set a short name for our animation. If you have any experience with client animations, this process will be quite similar. Add animations to description, and set a short name, like such:

BP/entities/player.json > minecraft:entity > description
json
{
    "identifier": "minecraft:player",
    "spawn_category": "creature",
    "is_spawnable": false,
    "is_summonable": false,
    "animations": {
        "emerald_armor": "animation.player.emerald_armor"
    }
}
1
2
3
4
5
6
7
8
9

Now with a short name set, we can run our animation.

Add scripts to description, and set a Molang query to run. To check for the item, we can use one of the following:

  • q.is_item_name_any, to check for a given item identifier in any slot. This example will check for wiki:totem_of_retreat in either hand:
molang
q.is_item_name_any('slot.weapon.mainhand', 'wiki:totem_of_retreat') || q.is_item_name_any('slot.weapon.offhand', 'wiki:totem_of_retreat')
1
  • q.equipped_item_any_tag, to check for at least one of any given tag in a given slot. This example will allow an emerald- or phantom- tier armor piece to be used:
molang
q.equipped_item_any_tag('slot.armor.head', 'wiki:emerald_tier', 'wiki:phantom_tier')
1
  • q.equipped_item_all_tags, to check for all given tags in a given slot. This example will only allow an armor piece that's both emerald- and ancient- tier:
molang
q.equipped_item_all_tags('slot.armor.head', 'wiki:ancient_tier', 'wiki:emerald_tier')
1

Let's take a look at an example using q.equipped_item_any_tag:

BP/entities/player.json > minecraft:entity > description
json
{
    "identifier": "minecraft:player",
    "spawn_category": "creature",
    "is_spawnable": false,
    "is_summonable": false,
    "animations": {
        "emerald_armor": "animation.player.emerald_armor"
    },
    "scripts": {
        "animate": [
            {
                "emerald_armor": "q.equipped_item_any_tag('slot.armor.head', 'wiki:emerald_tier')"
            }
        ]
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

This example will run a server animation with the emerald_armor short name if an emerald-tier item is equipped in the helmet slot. You can change the Molang field to match your item tag, use a different query, or add additional queries.

You can view a list of additional slot identifiers at the Minecraft Wiki.

Conclusion ​

With the server animation, player behavior, and item tag all set up, your equipped item can now run commands! This technique allows for greater item customization than being restricted to item components. If you want to add more to the effect or add-on, check the next section; otherwise, congratulations, you're finished!

Additions ​

Multiple Required Items ​

If you want to run a command when multiple of the armor set's pieces are equipped, we can expand our Molang from before:

BP/entities/player.json > minecraft:entity > description > scripts
json
"animate": [
    {
        "emerald_armor": "q.equipped_item_any_tag('slot.armor.head', 'wiki:emerald_tier') && q.equipped_item_any_tag('slot.armor.chest', 'wiki:emerald_tier') && q.equipped_item_any_tag('slot.armor.legs', 'wiki:emerald_tier') && q.equipped_item_any_tag('slot.armor.feet', 'wiki:emerald_tier')"
    }
]
1
2
3
4
5

This example will check for emerald-tier armor in all four armor slots, and run the animation if they're all equipped.

Further Conditions ​

The turtle shell doesn't always inflict Water Breathing, but instead only for 10 seconds when a player first enters water. If we want our emerald armor to only run our animation when we have lower health, we can add another query to our Molang:

BP/entities/player.json > minecraft:entity > description > scripts
json
"animate": [
    {
        "emerald_armor": "q.equipped_item_any_tag('slot.armor.head', 'wiki:emerald_tier') && q.health <= 5"
    }
]
1
2
3
4
5

This example will run the animation with 2.5 hearts or less remaining, allowing players to make a quick getaway when they're in danger.

We can also apply this to requiring multiple armor pieces, with even longer Molang:

BP/entities/player.json > minecraft:entity > description > scripts
json
{
    "animate": [
        {
            "emerald_armor": "q.equipped_item_any_tag('slot.armor.head', 'wiki:emerald_tier') && q.equipped_item_any_tag('slot.armor.chest', 'wiki:emerald_tier') && q.equipped_item_any_tag('slot.armor.legs', 'wiki:emerald_tier') && q.equipped_item_any_tag('slot.armor.feet', 'wiki:emerald_tier') && q.health <= 5"
        }
    ]
}
1
2
3
4
5
6
7

You can view a list of documented Molang queries at bedrock.dev.

Multiple Items with Effects ​

If you want to add more items with unique effects, fret not; this is easily done. You can either create a new server animation file, or add on to the file from before, like such:

BP/animations/player.json
json
{
    "format_version": "1.10.0",
    "animations": {
        "animation.player.emerald_armor": {
            "timeline": {
                "0.0": ["..."]
            },
            "animation_length": 0.05,
            "loop": true
        },
        "animation.player.phantom_armor": {
            "timeline": {
                "0.0": ["..."]
            },
            "animation_length": 0.05,
            "loop": true
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

In our player behavior, you'll have to add on to animations and scripts as well.

BP/entities/player.json > minecraft:entity > description
json
{
    "identifier": "minecraft:player",
    "spawn_category": "creature",
    "is_spawnable": false,
    "is_summonable": false,
    "animations": {
        "emerald_armor": "animation.player.emerald_armor",
        "phantom_armor": "animation.player.phantom_armor"
    },
    "scripts": {
        "animate": [
            {
                "emerald_armor": "q.equipped_item_any_tag('slot.armor.head', 'wiki:emerald_tier')"
            },
            {
                "phantom_armor": "q.equipped_item_any_tag('slot.armor.head', 'wiki:phantom_tier')"
            }
        ]
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

Contributors

Edit Equipment-Based Commands on GitHub

Bedrock Wiki by Bedrock OSS

"Minecraft" is a trademark of Mojang AB.

Bedrock OSS, Bedrock Wiki and bedrock.dev are not affiliated in any way with Microsoft or Mojang AB.

  • Privacy Policy
  • Join our Discord
  • Learn how to Contribute
  • Visit our Repository