LogicUsing Events
Entity Enter / Leave Region
Trigger actions when a non-player entity enters or leaves an area.
These events function identically to their player counterparts but work for any non-player entity.
Entity Enter Region
Triggers when an entity enters the boundaries of a region.
- Action Values:
Entity - Use Cases:
- Making mobs more aggressive when they enter an "arena" region.
- Triggering a dispenser trap when a mob walks over it.
- Counting how many mobs have entered a specific zone.
Entity Leave Region
Triggers when an entity leaves the boundaries of a region.
- Action Values:
Entity - Use Cases:
- Preventing mobs from leaving a designated area by teleporting them back in.
- Despawning (killing) mobs that wander too far from their spawn point.
Example: Leashing Mobs to an Area
- Region: Create a region that defines the mobs' patrol area.
- Property: Create a
Locationproperty calledMobSpawnPoint. Set its default value to the center of the region. - Event:
Entity Leave Region. - Action:
Teleport: Target theEntitythat triggered the event and teleport it to the location stored in theMobSpawnPointproperty.