Bug Fixes Recap
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.saveData() was only called during onServerStopping. A server crash meant all spawner stack data since startup was lost. Added a periodic save every 5 minutes (6000
ticks).
Minor / Performance
8. World-spanning bounding box query in processStacking
MobStackManager.java:352-358 — processStacking used getEntitiesByClass with a Box(-30000000 ... +30000000), which defeats Minecraft's spatial index optimization and forces a full entity scan every cycle. Replaced with
world.iterateEntities() which directly iterates the entity list without spatial overhead.
9. Invulnerability inconsistency for spawner-spawned mobs
CobbleStackerMod.java:223 — onEntityLoad set the bypass flag but didn't set setInvulnerable(true), while processBypassRemovals always called setInvulnerable(false) on expiry. This could remove invulnerability that an entity
had for other reasons. Added living.setInvulnerable(true) in onEntityLoad to match the behavior in handleKillOne.
10. Stale batch processing indices across ticks
MobStackManager.java:335-385 — currentWorldIndex and currentEntityIndex persisted between calls, but the entity list was recreated each time. Entities added/removed between ticks could cause out-of-range indices or skipped
entities. Added bounds checking and automatic index reset when indices exceed the current entity list size.
Developer information
Projects on Modrinth are automatically available through a Maven repository for use with JVM build tools such as Gradle.
maven { name = "Modrinth"; url = "https://api.modrinth.com/maven" }