Skip to content

Add options to control mob cap implementation#880

Open
Alexandra-Myers wants to merge 23 commits intosmartcmd:mainfrom
Alexandra-Myers:main
Open

Add options to control mob cap implementation#880
Alexandra-Myers wants to merge 23 commits intosmartcmd:mainfrom
Alexandra-Myers:main

Conversation

@Alexandra-Myers
Copy link

@Alexandra-Myers Alexandra-Myers commented Mar 7, 2026

Description

This is more or less an expansion of #789, preserving LCE functionality by default whilst letting the user remove the mob cap.
This PR introduces per-chunk caps based on Java Edition 1.8.8, as well as 4J's comments on what they changed from Java.

Changes

Previous Behavior

Previously, the limits for certain mob groups in their count was unchangeable, and the limits were enforced level wide rather than per chunk.

Root Cause

This was not erroneous but was rather a design decision to allow for better performance on the devices it ran on.

New Behavior

By default, it uses the same logic as existed before this version, however there is now an option to turn off mob caps, when true it is as follows:
Does NOT remove the mob cap for spawning, rather, breeding, spawn eggs, and construction are all unlimited, and spawning works exactly like in Java, with the base size per chunk for the mob category (leftover in original LCE code, though I edited it to keep the max count the same when one player is on) being scaled by the amount of loaded chunks and then scaled back down by a magic number (it is literally called MAGIC_NUMBER in official mappings for the modern game), which is then used as the mob cap for that category, effectively acting as the mob caps used in LCE, except more dynamic.

Fix Implementation

Stores eGameHostOption_WorldMobCap onto game host options using the bitmask 0x40000000.
Added no-mob-cap to server.properties to control it on the dedicated server.
Added a checkbox to UIScene_LaunchMoreOptionsMenu for modifying the mob cap setting.
Inside of Level::canCreateMore, added a check for if eGameHostOption_NoMobCap is enabled, returning true early if so.
Removed the maxPerLevel parameter from the MobCategory constructor, instead attaching default values statically within MobCategory::staticCtor() (later can become user controlled with a better config system, ideally).
Inside of MobSpawner::tick, references to mobCategory->getMaxInstancesPerLevel() were moved to their own variable, as now if eGameHostOption_NoMobCap is enabled, the max instances will be updated to instead use Java's math, as so:

maxInstances = mobCategory->getMaxInstancesPerChunk() * chunksToPoll.size() / MAGIC_NUMBER; // Java is mobCategory.getMaxInstancesPerChunk() * this.spawnableChunkCount / NaturalSpawner.MAGIC_NUMBER

Inside of MobCategory, added a field m_eJavaBase, which is used instead of m_eBase when eGameHostOption_NoMobCap is enabled, and is in most cases the same as m_eBase except for the creature category, which has eTYPE_ANIMAL set instead, allowing wolves, chickens, and mooshrooms to be included.
Biome::getMobs will now return the field all_friendlies (of type std::vector<Biome::MobSpawnerData *>) added to Biome when eGameHostOption_NoMobCap is enabled, and if it was empty before, fills all_friendlies with values of friendlies, friendies_chicken, friendlies_wolf, and friendlies_mushroomcow (unless there is no contents inside of these).

AI Use Disclosure

No AI was used in the making of this Pull Request.

Related Issues

@Alexandra-Myers Alexandra-Myers marked this pull request as draft March 7, 2026 21:28
@Alexandra-Myers
Copy link
Author

does anyone have any suggested software for dealing with swf files?

@Alexandra-Myers
Copy link
Author

image image These images show the unlimited mob cap removing the limit on spawn eggs (this is running on a dedicated server)

@Alexandra-Myers
Copy link
Author

image I have tested a little bit more, spawning seems to be working fine

@Alexandra-Myers
Copy link
Author

does anyone have any suggested software for dealing with swf files?

I know what they are, however I don't know how to use them.

@Alexandra-Myers Alexandra-Myers marked this pull request as ready for review March 10, 2026 00:30
@Alexandra-Myers
Copy link
Author

Okay, PR ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant