CobbleStacker is a server-side Fabric mod for Minecraft 1.21 designed to significantly reduce entity lag by intelligently stacking mobs, ground items, and spawners. Fully compatible with Cobblemon — all Pokemon are
automatically excluded from stacking.
Mob Stacking
- Automatically merges nearby identical mobs into a single entity with a visible nametag (e.g. "x16 Zombie")
- Respects mob attributes: variant, color, size, baby/adult, tamed owner, profession, and more
- Configurable death behavior: KILL_ONE (kills one and respawns the stack with reduced count) or KILL_ALL (kills the entire stack with multiplied drops and XP)
- Entities with name tags can be excluded from stacking
- Blacklist support by entity type and world
Item Stacking
- Merges ground items of the same type beyond vanilla limits (up to 1024 per stack by default)
- Custom nametags showing the real item count
- Built-in auto-clear system that removes old item stacks after a configurable time, with a whitelist for valuable items
- Manual clearlag command for instant cleanup
Spawner Stacking
- Stack multiple spawners of the same type by right-clicking with a spawner in hand
- Floating hologram displays the spawner type and stack count
- Mobs spawned from stacked spawners come out pre-stacked
- Silk Touch support for spawner drops
- Automatic spawner property repair to prevent broken spawners
- Persistent data saved to JSON
General
- Fully configurable via cobblestacker.json
- Admin commands: /cobblestacker reload, stats, info, kill, clear, clearlag, debug, fixspawner, setstack
- Lightweight and optimized with batch processing, caching, and minimal overhead
- No client-side installation required
How to Install CobbleStacker (Mod)
CobbleStacker by MarcoErCarrozza is verified for Fabric, Neoforge across Minecraft versions 1.21, 1.21.1 (latest release: 1.1.0, file size: 66 KB). Follow the steps below to install it safely from ModCraft.tv:
- Click the Download button above and select your Minecraft version (1.21, 1.21.1) and platform (Fabric, Neoforge).
- Make sure you have the compatible loader or environment installed for Fabric, Neoforge.
- Move the downloaded CobbleStacker file into your Minecraft
.minecraft/modsfolder and launch the game.
All Versions
+ Add Versionliteral string ${mod_version} ended up in the jar, which NeoForge rejected as an invalid version number.
Spawner-Only Mob Stacking
Mobs will now only stack if they were spawned by a mob spawner. Natural mobs (ones that spawn in caves, at night, etc.) will behave completely vanilla and
won't be stacked together. This makes gameplay feel much more natural while still keeping your spawner farms optimized and lag-free.
This is enabled by default. If you want the old behavior (stack all mobs), set "mobOnlySpawnerStack": false in the config.
Item Nametag Visibility Fix
Fixed a bug where setting "itemNametagAlwaysVisible": false would make item stack nametags completely invisible instead of showing them when you're nearby
(like mob nametags do). Now when set to false, item nametags will appear when you're within range of the item stack and disappear when you walk away
Spawner-Only Mob Stacking
Mobs will now only stack if they were spawned by a mob spawner. Natural mobs (ones that spawn in caves, at night, etc.) will behave completely vanilla and
won't be stacked together. This makes gameplay feel much more natural while still keeping your spawner farms optimized and lag-free.
This is enabled by default. If you want the old behavior (stack all mobs), set "mobOnlySpawnerStack": false in the config.
Item Nametag Visibility Fix
Fixed a bug where setting "itemNametagAlwaysVisible": false would make item stack nametags completely invisible instead of showing them when you're nearby
(like mob nametags do). Now when set to false, item nametags will appear when you're within range of the item stack and disappear when you walk away
the same time. This corrupted the internal list Minecraft uses to track entities, causing the server to crash.
We fixed it by making the plugin work on a safe copy of the entity list instead of the live one, so it can't be affected by changes happening at the same time.
You shouldn't see this crash anymore.
the same time. This corrupted the internal list Minecraft uses to track entities, causing the server to crash.
We fixed it by making the plugin work on a safe copy of the entity list instead of the live one, so it can't be affected by changes happening at the same time.
You shouldn't see this crash anymore.
Fixed console spam caused by vanilla Minecraft logging death messages for named entities. Since stacked mobs have custom display names (e.g. "x2 Glow Squid"),
the server would log "Named entity ... died: ..." every time a stacked mob died. The fix clears the stacking nametag right before the death logic runs, so
vanilla no longer treats them as named entities. Player-applied nametags are preserved and unaffected.
Fixed console spam caused by vanilla Minecraft logging death messages for named entities. Since stacked mobs have custom display names (e.g. "x2 Glow Squid"),
the server would log "Named entity ... died: ..." every time a stacked mob died. The fix clears the stacking nametag right before the death logic runs, so
vanilla no longer treats them as named entities. Player-applied nametags are preserved and unaffected.
Bug fix — Watchdog crash (ItemStackManager.java):
- processAutoClear and forceClear were calling item.discard() while iterating level.getAllEntities() (a live iterable), causing a
Feature — Mob nametag visibility distance (3 files):
- ModConfig.java: Added mobNametagVisibleDistance (default 0 = always visible, like current behavior). Set it to e.g. 32 to only show nametags within 32
- MobStackManager.java:
- updateNametag no longer forces setCustomNameVisible(true) when distance mode is active
- New updateNametagVisibility(server) method checks each stacked mob against all players in the level and toggles visibility based on squared distance
- CobbleStackerMod.java: Calls updateNametagVisibility every 10 ticks (0.5s) when distance mode is enabled
— no more screen clutter, no seeing mobs through walls, and no unnecessary nametags in mob farms. Same option is available for items as
itemNametagAlwaysVisible. Just set them to false in cobblestacker.json.
The server was crashing with a Watchdog error because CobbleStacker was modifying the list of entities (removing/discarding items) while still looping through
it. This is like pulling cards out of a deck while someone else is counting them — it causes the game to freeze and eventually the Watchdog kills the server
for being unresponsive.
What we changed: The auto-clear and force-clear systems now first make a list of all the items that need to be removed, and only then actually remove them
after the loop is done. This prevents the freeze entirely.
This tells Fabric to load the mod on both the dedicated server and the integrated server (single player), instead of only on dedicated servers.
- Same logic as Fabric, targeting HopperBlockEntity.addItem(Container, ItemEntity) with mojang mappings (grow, setChanged, getContainerSize, etc.)
- Mixin injecting at HEAD of HopperBlockEntity.extract(Inventory, ItemEntity)
- Intercepts vanilla pickup, reads the real stack amount from ItemStackManager, manually distributes items into hopper slots, and properly handles partial inserts
Critical
1. Spawner drops not restoring mob type when placed
CobbleStackerMod.java:455 — The BLOCK_ENTITY_DATA NBT was missing the "id": "minecraft:mob_spawner" field. Without it, Minecraft 1.21 silently ignores the saved SpawnData when the spawner is placed, resulting in a default
pig spawner. Added blockEntityTag.putString("id", "minecraft:mob_spawner") in dropSpawnerItem.
2. ThreadLocal leak in MobSpawnerLogicMixin
CobbleStackerMod.java:206-211 — If MobSpawnerLogic.serverTick threw an exception, the @At("RETURN") injection wouldn't fire, leaving the ThreadLocal set. Any entity spawned afterwards would be incorrectly treated as a
spawner mob. Fixed by adding a validation check in onEntityLoad that verifies the block at the stored position is actually a spawner; if not, the stale context is cleared.
3. Item/XP duplication with KILL_ALL death behavior
LivingEntityMixin.java:41-45, 71-86, 167-226 — handleKillAll used server.execute() (1-tick delay) and age <= 2 to find drops, which was unreliable: it could miss the actual drops or multiply items from other mobs dying
nearby. Fixed by capturing a snapshot of existing ItemEntity/XP orb IDs in the area before death (in onDeathHead), then at onDeathReturn only multiplying entities that are new (not in the snapshot). Removed the
server.execute() wrapper entirely.
Important
4. Entity ID reuse causing stale stack data
MobStackManager.java:388 — cleanupDeadEntities only ran when stackData.size() > 50, leaving a window where newly spawned entities could inherit stack data from dead entities with the same runtime ID. Removed the size
threshold so cleanup runs every cycle.
5. /cs clear not actually unstacking entities
CobbleStackerCommand.java:226-285 — The clear command just called handleKill which only wiped the internal data maps. Entities remained in the world with stale nametags like "x5 Zombie" while the mod treated them as
stack=1. Now the command iterates all entities, resets their custom names, sets stack to 1, and then clears the data maps.
6. Spawner stacking without mob type validation
CobbleStackerMod.java:351-357, 421-438 — Players could stack different spawner types together (e.g., a Zombie Spawner onto a Pig Spawner) without any warning. Added a mob type compatibility check in handleSpawnerStack with
a new helper method getSpawnerItemEntityType that reads the mob type from the held spawner item's NBT data.
7. No periodic save for spawner data
CobbleStackerMod.java:67, 179-183 — SpawnerDataManager.saveD
...