Using Filters and Regions

Regions define areas that can later be applied to Filters and other modules. Understanding how modules, regions and filters work together is important to make critical mechanics for a map.

Creating a Region

Creating a Region involves certain world coordinates. In this example, we will create simple <cuboid/> regions inside a <union>, which we will save with IDs which we can reference for later use.

<regions>
<union id="spawns">
<cuboid id="red-spawn" min="20,0,55" max="40,10,75"/>
<cuboid id="blue-spawn" min="10,0,-55" max="30,10,-75"/>
</union>
</regions>

Creating a Filter

Creating a Filter allows us to put restrictions on certain events. We want to stop players from entering their enemy's spawn region, usually to prevent spawnkilling. Our goal is to filter players that are entering a region, so we will make basic filters that matches for players on a certain team.

<filters>
<!-- Filter will pass ALLOW if player is on Red Team -->
<team id="only-red">red-team</team>
<team id="only-blue">blue-team</team>
</filters>

Applying a Filter to a Region

Applying filters to a region is done inside the <regions> module. When we make our <apply/> module, we can use the IDs in our region and filter to reference them as a variable. Out of the various events, we will use the enter event. When a player enters red-spawn, we want to make sure that only players on the red team are able to enter it. So we apply our only-red filter to players that are entering it.

<regions>
<union id="spawns">
<cuboid id="red-spawn" min="20,0,55" max="40,10,75"/>
<cuboid id="blue-spawn" min="10,0,-55" max="30,10,-75"/>
</union>
<!-- checks only-red if a player is allowed to enter -->
<apply region="red-spawn" enter="only-red"/>
<apply region="blue-spawn" enter="only-blue"/>
</regions>
<filters>
<team id="only-red">red-team</team>
<team id="only-blue">blue-team</team>
</filters>

Applying things to multiple regions

Typically we want to prevent players from placing or breaking any blocks in spawn, but we have two spawn regions defined in our XML, and both need spawn protection. The <union> element using the ID spawns combines the two team spawns into a single region. Using spawns with <apply/> will let us apply a filter to both regions. We will use the built-in never filter, which denies everything. This XML protects spawn from being damaged by players, TNT, mobs, etc and prevents players from entering their enemy's spawn room, but can still safely enter their own.

<regions>
<union id="spawns">
<cuboid id="red-spawn" min="20,0,55" max="40,10,75"/>
<cuboid id="blue-spawn" min="10,0,-55" max="30,10,-75"/>
</union>
<apply region="red-spawn" enter="only-red"/>
<apply region="blue-spawn" enter="only-blue"/>
<!-- denies all block breaking and placing in both red-spawn and blue-spawn -->
<apply region="spawns" block="never"/>
</regions>
<filters>
<team id="only-red">red-team</team>
<team id="only-blue">blue-team</team>
</filters>