Skip to content

Add options to control mob cap implementation#880

Draft
Alexandra-Myers wants to merge 7 commits intosmartcmd:mainfrom
Alexandra-Myers:main
Draft

Add options to control mob cap implementation#880
Alexandra-Myers wants to merge 7 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 expand the mob cap themselves.
This PR also allows for the removal of the mob cap, with the introduction of 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

NOTE: I have yet to implement the UI changes for world options as of writing this. It should be done before this PR gets merged.
There is now an option for the world to control the limits. By default, it uses the same logic as existed before this version, however there is four options:
Small/0 (Existing mob caps, default logic)
Medium/1 (Mob caps as of #789)
Large/2 (A custom largely expanded version of the mob caps, 100 Monsters, 100 Animals, 40 Ambient, 15 Squid, 24 Wolves, 24 Chickens, 16 Mooshrooms, 32 Snow Golems, 32 Iron Golems, 3 Bosses, 100 Villagers from Breeding, and all other caps are derived from the base ones.)
Unlimited/3 (Does NOT remove a mob cap, 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) 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 0xC0000000.
Added MobCategory::updateMobCaps which updates the mob cap fields (this will not happen if it is set to unlimited), which are no longer constants. This function is called in UIScene_CreateWorldMenu::CreateGame, UIScene_LoadMenu::tick, and MinecraftServer::initServer.
Added world-mob-cap to server.properties to control it on the dedicated server.
Added a slider to UIScene_LaunchMoreOptionsMenu for modifying the mob cap setting.
Inside of Level::canCreateMore, added a check for if eGameHostOption_WorldMobCap is set to Unlimited (3), returning true early if so.
Removed the maxPerLevel parameter from the MobCategory constructor, instead attaching default values statically using MobCategory::updateMobCaps.
Inside of MobSpawner::tick, references to mobCategory->getMaxInstancesPerLevel() were moved to their own variable, as now if eGameHostOption_WorldMobCap is Unlimited, the max instances will be updated to instead use Java's math, as so:

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

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.

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