Mob Limiter

The Mob Limiter module prevents excessive mob spawning by enforcing per-chunk limits.

Overview

Purpose: Control entity spawning to prevent lag from too many mobs in one area.

Key Features:

  • Global mob limit per chunk
  • Per-type mob limits for specific control
  • Prevents both natural spawns and spawner spawns
  • Automatic chunk optimization
  • Real-time enforcement

How It Works

  1. When a mob tries to spawn, the plugin checks the chunk's mob count
  2. If the chunk has reached the limit, the spawn is cancelled
  3. Per-type limits can further restrict specific mob types
  4. Works with spawners, natural spawns, and breeding

Example:

  • Chunk limit: 50 mobs
  • Current mobs in chunk: 49
  • Next spawn: Allowed (49 < 50)
  • After that: Cancelled (50 = 50)

Configuration

Location: plugins/ClearLaggEnhanced/module/mob-limiter/config.yml

Basic Settings

enabled: true
max-mobs-per-chunk: 50           # Global mob limit per chunk

Recommended values:

  • Small servers (1-20 players): 75
  • Medium servers (20-100 players): 50
  • Large servers (100+ players): 35
  • Laggy servers: 25-30

Per-Type Limits

per-type-limits:
  enabled: true
  limits:
    ZOMBIE: 10
    SKELETON: 10
    CREEPER: 8
    SPIDER: 8
    ENDERMAN: 5
    VILLAGER: 15
    COW: 12
    SHEEP: 12
    PIG: 12
    CHICKEN: 15
    IRON_GOLEM: 3

How per-type limits work:

  • Limits apply in addition to the global limit
  • Even if global limit allows it, per-type limit can block spawns
  • Useful for controlling specific problematic mobs

Example:

  • Global limit: 50 mobs per chunk
  • Zombie limit: 10 per chunk
  • Chunk has 30 total mobs, but 10 are zombies
  • Next zombie spawn: Cancelled (zombie limit reached)
  • Next cow spawn: Allowed (cow limit not reached, global limit OK)

Common Configurations

Passive Mob Farm Server

max-mobs-per-chunk: 60
per-type-limits:
  enabled: true
  limits:
    COW: 20
    SHEEP: 20
    PIG: 20
    CHICKEN: 20
    ZOMBIE: 8
    SKELETON: 8
    CREEPER: 5

Result: Higher limits for farm animals, lower for hostiles.

Hostile Mob Farm Focus

max-mobs-per-chunk: 50
per-type-limits:
  enabled: true
  limits:
    ZOMBIE: 15
    SKELETON: 15
    CREEPER: 10
    SPIDER: 10
    COW: 5
    SHEEP: 5
    PIG: 5
    CHICKEN: 5

Result: Higher limits for hostiles, lower for passives.

PvP/Survival Balance

max-mobs-per-chunk: 40
per-type-limits:
  enabled: true
  limits:
    ZOMBIE: 10
    SKELETON: 10
    CREEPER: 8
    ENDERMAN: 5
    VILLAGER: 12
    IRON_GOLEM: 3

Result: Balanced for both PvE and trading.

Usage Examples

Scenario 1: Spawner Farm

You have a zombie spawner farm in a chunk:

  1. Spawner tries to spawn zombies
  2. Chunk already has 50 mobs
  3. Spawn is cancelled
  4. Farm naturally limits itself

Benefit: No need to manually limit spawner output.

Scenario 2: Natural Spawning

Players are exploring caves:

  1. Chunk has 45 mobs naturally
  2. Next mob tries to spawn naturally
  3. Spawn is cancelled (45 < 50, but limit is 50)
  4. Prevents chunk from having excessive mobs

Benefit: Prevents lag from mob-heavy areas.

Scenario 3: Per-Type Protection

Your server has too many creepers:

per-type-limits:
  enabled: true
  limits:
    CREEPER: 5               # Max 5 creepers per chunk
    ZOMBIE: 15               # But allow 15 zombies

Result: Creepers are limited while other mobs can spawn normally.

Integration with Other Modules

Works With: Spawner Limiter

When used together:

  1. Spawner tries to spawn
  2. Mob Limiter checks chunk limit
  3. If OK, Spawner Limiter checks spawner delay
  4. Only spawns if both allow it

Works With: Entity Clearing

  1. Entity clearing removes excess mobs
  2. Mob count drops below limit
  3. New mobs can spawn again
  4. Creates natural cycle

Recommendation: Use both modules together for best results.

Entity Types

Common hostile mobs:

  • ZOMBIE
  • SKELETON
  • CREEPER
  • SPIDER
  • CAVE_SPIDER
  • ENDERMAN
  • WITCH
  • BLAZE
  • PHANTOM

Common passive mobs:

  • COW
  • SHEEP
  • PIG
  • CHICKEN
  • RABBIT
  • HORSE
  • DONKEY
  • FOX

Villagers and utility:

  • VILLAGER
  • ZOMBIE_VILLAGER
  • IRON_GOLEM
  • SNOW_GOLEM
  • ALLAY

Full list: Spigot EntityType

Performance Impact

Minimal overhead:

  • Checks happen only during spawn events
  • Fast chunk mob counting (O(n) where n = entities in chunk)
  • No continuous background tasks

Expected impact:

  • < 1ms per spawn event
  • Prevents lag by stopping spawns early
  • Actually improves performance overall

Troubleshooting

Mobs Not Spawning

Check these:

  1. Is enabled: true?
  2. What is max-mobs-per-chunk set to?
  3. Are there already that many mobs in the chunk?
  4. Check per-type limits for specific mob types

Debug steps:

  1. Stand in a chunk
  2. Count mobs with /lagg chunkfinder or manually
  3. If count >= limit, spawns will be blocked
  4. Increase limit or clear entities

Too Many Mobs Still Spawning

Solutions:

  1. Lower max-mobs-per-chunk value
  2. Enable per-type limits for problematic mobs
  3. Use with Entity Clearing module
  4. Check if mobs are spawning in different chunks

Per-Type Limits Not Working

Verify:

  1. Is per-type-limits.enabled: true?
  2. Check entity type name spelling (must match exactly)
  3. Entity types are case-sensitive: ZOMBIE, not zombie
  4. Check console for errors

Spawner Not Producing Mobs

This is normal if:

  • Chunk has reached mob limit
  • Specific mob type has reached its limit
  • Use with Spawner Limiter for more control

Solutions:

  • Increase max-mobs-per-chunk
  • Increase per-type limit for spawner mob
  • Spread spawners across multiple chunks

Advanced Configuration

Dimension-Specific Limits

max-mobs-per-chunk: 50           # Default for overworld

per-type-limits:
  enabled: true
  limits:
    ZOMBIE_PIGLIN: 20            # Higher in nether
    BLAZE: 15
    GHAST: 5

Note: This config applies to all worlds. For world-specific configs, you would need multiple instances (not currently supported, but planned).

Farm-Friendly Settings

max-mobs-per-chunk: 75           # High limit for farms
per-type-limits:
  enabled: true
  limits:
    ZOMBIE: 30                   # Allow large zombie farms
    SKELETON: 30
    COW: 30
    CHICKEN: 30
    CREEPER: 15                  # Still limit creepers

Minimal Performance Impact

max-mobs-per-chunk: 100          # Very high limit
per-type-limits:
  enabled: false                 # Disable per-type checks

Use when: Performance is good, just want absolute maximum safety.

Related Modules