Smithed Summit is back! Check it out here!
You are currently on the unstable branch. Click here to go to safety.
Download
Choose Minecraft VersionNo available versions
Close

TVOL Trigger Volumes

TVOL Trigger Volumes adds easy-to-use trigger volumes that can be spawned with a single command and configured to run commands and functions on enter, exit or every tick inside.

How to use

Summon a marker entity (technically any entity type is allowed, so you could attach volumes to moving entities etc.), add the tag for the shape and target detection you need, configure size and define event commands and/or functions.

Syntax:

/summon marker ~ ~ ~ {Tags:["tvol.<shape>.<target_type>"],data:{tvol:{<shape-dependant size args>,condition:<condition>,<callbacks>}}}

You can toggle visual outlines with

/function tvol:toggle_outline

Supported Shapes

  • sphere: Sphere Volume
    • Size Arg: radius: The sphere's radius. Only positive values allowed.
  • box: Box Volume (full blocks only)
    • Size Args: dx, dy and dz: Describe size in x, y and z directions, these are fed directly into a target selector dx, dy and dz respectively and can be negative. Thus, they are technically off-by-one as setting them to 0, 0, 0 will create a 1x1x1 block detection.

Target Types

  • player: Only detects players
  • entity: May detect any kind of entity

Conditions (optional)

Conditions are passed into an existing entity @e[] (or @a[]) target selector through a macro and may therefore include any custom selector arguments, but it is most useful to restrict entity types, e.g. with type=minecraft:cow to restrict detection to cows.

Defaults to type=!#tvol:ignored, which excludes markers, armor stands, item displays, block displays, text displays and interaction entities by default.

Callbacks (optional)

You may specify any number of callbacks. Use the event name as a key and a compound tag with a function and/or command to run specified. Both will run as the entity that entered/exited/etc. at the base position of the volume. Functions will be run with argument id set to the volume's id.

Example: on_enter:{command:"say hi",function:"my_datapack:area_entered"},on_exit:{command:"say bye"},on_stay:{function:"my_datapack:area_stay"}

If you don't intend on using an event, you don't need to specify it at all and you may use both a command and a function at the same time (command will execute before function).

Examples

Player-detection sphere with enter and exit command
/summon marker ~ ~ ~ {Tags:["tvol.sphere.player"],data:{tvol:{radius:7.5,on_enter:{command:"say enter sphere"},on_exit:{command:"say exit sphere"}}}}
Box with glowing cows
/summon marker ~ ~ ~ {Tags:["tvol.box.entity"],data:{tvol:{dx:15,dy:3,dz:5,condition:"type=cow",on_stay:{command:"effect give @s minecraft:glowing 1 0 true"}}}}
Entity-detection box
/summon marker ~ ~ ~ {Tags:["tvol.box.entity"],data:{tvol:{dx:20,dy:5,dz:20,on_enter:{command:"say I entered the box",function:"my_datapack:enter_box"},on_exit:{function:"my_datapack:exit_box"}}}}

Utility Functions

There are a couple of utility functions:

  • /function tvol:count {id:<id>}: Returns amount of entities currently inside (not cached, but it uses @e[tag=...] to count all entities with that were already calculated to be inside and given the tag, so it doesn't do any new coordinate checks)
  • /execute as @n[tag=tvol.volume] run function tvol:identify: Returns the id of a box or sphere volume. Must be executed as the volume you need the id of

There are also functions for creating simple boxes or spheres which do not have any event listeners set up.

Smithed

Copyright © 2023-2026 Smithed
Not an official Minecraft product. Not approved by or associated with Mojang Studios