cityopt

Reduces the tick cost of crowded NPC towns on Forge 1.20.1: distance-bucket AI throttling, a pathfinding cooldown, a region MSPT watchdog with hysteresis, async line-of-sight culling, and one-command diagnostics. No entities deleted, no critical AI frozen.
CityOpt
 
Lighter towns. Same NPCs.
 
CityOpt is a small, config-driven optimisation mod for Minecraft 1.20.1 / Forge 47.x aimed at one specific problem: a town full of NPCs. Dozens of them standing around, all running their brains, their pathfinding, their schedules — every single tick — while the client is already busy streaming distant chunks for a long view distance.
 
It does not delete entities. It does not freeze combat AI. It just stops paying full price for things nobody is looking at.
 

 
What it actually changes
 
Server — distance based AI throttling
 
Every living entity is sorted into a distance bucket relative to the nearest player, and its AI step runs on a per-bucket interval instead of every tick.

Two details make this survivable rather than a stutter generator:

* **Phase spreading.** The interval is offset by the entity id, so 300 far-away NPCs do not all wake up on the same tick. The cost is smeared across the whole interval instead of spiking once every four ticks.
* **Locomotion keeps running.** When the AI step is skipped, the movement and jump controllers are still ticked, so nothing snaps or jitters in place. Brains, goal selectors, look control and schedules are what get deferred.

### Server — pathfinding cooldown

A new path is not recomputed more often than every **100 ticks** (configurable) per entity. If a recompute is requested during the cooldown, the entity keeps following its existing path instead. If it has no path at all, the request is always allowed — CityOpt never freezes a mob by refusing to give it a path.

### Server — region MSPT watchdog

Entity AI cost is attributed to **128×128 block regions** and tracked with a rolling average. When a region's AI time and the global tick time both go up, that region's throttle penalty escalates by one step (interval ×2, up to ×4).

It is deliberately hard to make it flap:

* escalation needs **3 consecutive 20-tick windows** above the high-water mark (default 45 ms)
* after every change there is a **10-window cooldown**
* stepping back down needs **30 consecutive windows** below 70 % of the high-water mark
* regions that have not been sampled for 30 windows are dropped from the map

### Server — dropping items and block entities

* Dropped items of the same type within 2 blocks are merged once every 20 ticks (respects max stack size, keeps the younger stack's despawn timer).
* Block entity ticking can be gated down to once per second — **off by default**, and it only ever affects types you explicitly whitelist. Any player within 32 blocks keeps the full tick rate.

### Client — asynchronous visibility culling

For servers where the client is the bottleneck, CityOpt adds a conservative line-of-sight cull on top of what EntityCulling already does:

* a candidate snapshot is collected on the main thread every 2 ticks
* one worker thread (`CityOpt-Visibility`) casts **3 rays** per candidate through a per-section opacity bitmap
* results come back through a `ConcurrentLinkedQueue` and are drained at the end of the tick
* an entity is only hidden after **2 confirmed occlusions**; results expire after 300 ms, entities farther than 48 blocks (configurable) are skipped

The safety rules are not negotiable: section bitmaps are only ever built on the main thread (512 bytes each), the worker **never** calls `getBlockState`, and a section it cannot read means "do not cull". Named, glowing, recently hurt, taller than 3 blocks, vehicles, passengers and anything closer than 8 blocks is always rendered. If the culling code throws for any reason, it disables itself and tells you in the log — it will never take a frame down with it.

### Client — town prewarm

When the player walks into a dense area (default: 40+ living entities within 32 blocks for three consecutive checks), CityOpt smoothly lowers `entityDistanceScaling` to 75 % and restores it 3 seconds after leaving. If you touch the slider yourself, it gives up permanently and never touches the setting again.

Configuration

Two files are generated on first launch:

* `config/cityopt-common.toml` — server side (works on a dedicated server, no client install needed)
* `config/cityopt-client.toml` — client side (culling, prewarm, overlay)

Every optimisation has its own boolean. The defaults are intentionally timid: Brain throttling is off, block-entity gating is off with an empty whitelist, and the client only culls at short range. Turn things on one at a time and watch `/cityopt stats`.

Compatibility

| Mod | What happens |
|---|---|
| **Voxy** | Nothing is shared. CityOpt only touches the entity layer; Voxy's chunk LOD pipeline is never modified. When Voxy is detected it logs a suggestion to lower `sectionRenderDistance` and **never writes `voxy-config.json`**. |
| **EntityCulling** | Fully compatible. With `yieldToEntityCulling` (default: true) CityOpt stops casting rays entirely and only keeps its distance gate, so the two mods never cull the same entity twice. |
| **Embeddium / Oculus** | No renderer mixins, no `LevelRenderer` hooks — nothing to collide with. |
| **ModernFix** | Independent. Neither mod needs the other to be disabled. |
| **spark** | Complementary. `/cityopt stats` gives counters, spark gives the call tree. |

cityopt Team

profile avatar
  • 1
    Projects
  • 16
    Downloads