Scope
- A new zone flag
mob_clear (or mob_purge) that ensures a zone is always free of mobs
- When enabled, all existing mobs inside the zone boundaries should be immediately removed
- Any mob that enters or spawns inside the zone should be automatically killed/removed
- Should work alongside existing
mob_spawning flag — mob_spawning: false prevents new spawns but does NOT remove mobs that wander in from outside; mob_clear actively removes all mobs continuously
- Should apply to hostile, passive, and neutral mobs (controlled by the master toggle)
- Should NOT affect players
- Should optionally have sub-flags for granular control:
mob_clear_hostile, mob_clear_passive, mob_clear_neutral as children of mob_clear (matching the existing spawning flag hierarchy)
- Should be a periodic check (e.g., every few seconds) rather than per-tick to avoid performance impact
Implementation Details
-
New zone flag constants in ZoneFlags.java:
mob_clear — master toggle, parent flag
mob_clear_hostile — clear hostile mobs (child)
mob_clear_passive — clear passive mobs (child)
mob_clear_neutral — clear neutral mobs (child)
-
Default values:
- SafeZone:
mob_clear: true (all sub-flags true) — safe zones should be mob-free
- WarZone:
mob_clear: false (all sub-flags false) — war zones keep mobs for danger
-
Suggested implementation approach:
- Periodic task (every 5-10 seconds) iterates zones with
mob_clear enabled
- For each zone, query entities in the zone's chunk range
- Check each entity against NPCGroup (hostile/passive/neutral) and the sub-flags
- Remove matching entities via
entity.remove() or equivalent server API
- Could reuse the existing
SpawnSuppressionController chunk iteration pattern
-
Parent-child hierarchy in ZoneFlags.getParentFlag():
case MOB_CLEAR_HOSTILE, MOB_CLEAR_PASSIVE, MOB_CLEAR_NEUTRAL -> MOB_CLEAR;
-
UI category: Add to existing "Spawning" category or create a new "Mob Control" category
Risks and Alternatives
- Performance risk: Iterating all entities in zone chunks every few seconds could be expensive with many zones. Mitigate by only processing zones that have
mob_clear enabled, and by using chunk-based spatial indexing (already exists for claims).
- Edge case: Mobs on zone boundaries may flicker in and out. Use a small buffer or only check mobs fully inside the region.
- Alternative — combine with mob_spawning: Instead of a new flag, enhance
mob_spawning: false to also remove existing mobs. However, this changes existing behavior where mob_spawning only prevents new spawns, which some servers may rely on (e.g., keeping existing farm animals but preventing new wild spawns).
- Mixin dependency: May require mixin support to intercept mob movement into zones, or could use a simpler polling approach that doesn't need mixins.
- Named/tamed mobs: Consider whether tamed or named mobs should be exempt from clearing. Could add a config option
mob_clear_exempt_tamed: true.
References and Media
Existing related flags in ZoneFlags.java:
mob_spawning (master toggle) with children hostile_mob_spawning, passive_mob_spawning, neutral_mob_spawning
npc_spawning (mixin-dependent)
- The spawning flags prevent NEW spawns but don't remove mobs that walk in from outside the zone
Similar concept in other games:
- Minecraft WorldGuard
mob-spawning + deny-spawn flags with entity removal
- Factions plugins with "safe zone mob clearing" features
Scope
mob_clear(ormob_purge) that ensures a zone is always free of mobsmob_spawningflag —mob_spawning: falseprevents new spawns but does NOT remove mobs that wander in from outside;mob_clearactively removes all mobs continuouslymob_clear_hostile,mob_clear_passive,mob_clear_neutralas children ofmob_clear(matching the existing spawning flag hierarchy)Implementation Details
New zone flag constants in
ZoneFlags.java:mob_clear— master toggle, parent flagmob_clear_hostile— clear hostile mobs (child)mob_clear_passive— clear passive mobs (child)mob_clear_neutral— clear neutral mobs (child)Default values:
mob_clear: true(all sub-flags true) — safe zones should be mob-freemob_clear: false(all sub-flags false) — war zones keep mobs for dangerSuggested implementation approach:
mob_clearenabledentity.remove()or equivalent server APISpawnSuppressionControllerchunk iteration patternParent-child hierarchy in
ZoneFlags.getParentFlag():UI category: Add to existing "Spawning" category or create a new "Mob Control" category
Risks and Alternatives
mob_clearenabled, and by using chunk-based spatial indexing (already exists for claims).mob_spawning: falseto also remove existing mobs. However, this changes existing behavior wheremob_spawningonly prevents new spawns, which some servers may rely on (e.g., keeping existing farm animals but preventing new wild spawns).mob_clear_exempt_tamed: true.References and Media
Existing related flags in
ZoneFlags.java:mob_spawning(master toggle) with childrenhostile_mob_spawning,passive_mob_spawning,neutral_mob_spawningnpc_spawning(mixin-dependent)Similar concept in other games:
mob-spawning+deny-spawnflags with entity removal