⚡ DMZCA Perf Fix
A lightweight client + server Mixin/ASM performance companion mod for DMZCA (Dragon Mine Z + MCA Unified 0.5.x), DragonMineZ (2.x), and DMZ Ultra (0.5+ / 0.6+) on Minecraft Forge 1.20.1.
Eliminates severe village TPS and FPS lag, camera-pan stutters, and GC spikes without altering gameplay mechanics.
Real-World Benchmark Progression (Spark Profiler)
Tested on Minecraft 1.20.1 Forge inside populated MCA + DMZCA villages (DMZCA 0.5.2 + DragonMineZ 2.2.1 + DMZ Ultra 0.6.1):
Overall Village FPS Summary
| Stage | Village FPS | Main Bottleneck Status |
|---|---|---|
No Fix (Vanilla DMZCA 0.5.2) |
~23 FPS |
Severe server & client reflection storms (MethodList.filter, NoSuchMethodException), plus 100% CPU-choked Render thread |
With v1.0.0 (Reflection Cache) |
~50 FPS (volatile, spikes up to 178.87 ms) |
Server reflection fixed (-72% to -85% DMZCA server tick), but client Render thread still saturated by eager StatsData/CustomHair allocations per villager bone |
With v1.1.0 (Reflection + Render Fix) |
80–110 FPS (rare dips to ~56 FPS with F3 open) |
Render thread CPU unblocked (16.04% OpenGL/SwapBuffers headroom), StatsData.<init>() reduced to 0.00% |
Server Thread Benchmarks — No Fix vs. v1.0.0 (+ v1.1.0)
| Server Thread Metric (Village) | No Fix (log) |
With v1.0.0 (log) |
Reduction |
|---|---|---|---|
DMZCA (dmzmcaunified) total tick |
44.06% |
12.52% (avg 6.76%) |
-72% to -85% |
PotaraBreedingRuntime.onNpcTick |
17.65% |
0.96% |
-95% |
NpcCombatStats.onLivingTick |
18.61% |
1.31% |
-93% |
McaGeneticsRuntime.invoke |
15.41% |
1.19% |
-92% |
NpcTrainingSystem.onTick |
14.09% |
3.50% (avg 2.10%) |
-75%+ (further throttled in v1.1.0) |
VillagerEntityMCA.tick |
48.15% |
21.17% (avg 11.13%) |
-56% to -77% |
Reflection garbage (MethodList.filter / fillInStackTrace) |
17.08%+ |
~0% |
Eliminated |
In v1.1.0, server performance is further improved by throttling GenomeBridge.onTick (GeneticLineageArchive.captureNow → 128-tick staggered capture) and resolving KiControlBridge's Mojmap → SRG CompoundTag reflection misses (0 warnings in latest.log).
Client Render thread Benchmarks — v1.0.0 vs. v1.1.0
| Render Thread Metric (Village) | v1.0.0 (log) |
v1.1.0 (log) |
Reduction |
|---|---|---|---|
StatsData.<init>() (eager .orElse bug) |
20.53% |
0.00% (0 ms) |
-100% |
CustomHair.<init>() |
20.00% |
0.00% (4 ms) |
-99.98% |
DMZRacePartsLayer (total) |
17.93% |
1.08% |
-94.0% (16.6× faster) |
NativeMcaRenderEvents (DMZCA Villagers) |
37.70% |
15.84% |
-58.0% (2.4× faster) |
DMZPlayerRenderer.render (total) |
44.94% |
19.76% |
-56.0% |
DMZHairLayer (3D voxel hair) |
5.34% |
2.82% (drops to 2.2%) |
-47.2% |
FormPartsLayer (DMZ Ultra) |
3.18% |
1.29% (drops to 0.9%) |
-59.4% |
NativeHybridTailRig (DMZCA tails) |
2.42% |
0.68% |
-71.9% |
Total Entity Rendering (EntityRenderDispatcher) |
41.29% |
21.74% |
-47.3% |
CPU Headroom (GLFW / OpenGL / SwapBuffers) |
~0% (CPU-choked) |
16.04% |
Unblocked |
What This Mod Fixes
1. Eliminates Eager StatsData / CustomHair Allocations on Every Rendered Bone (v1.1.0)
In DragonMineZ 2.x, 6 hot client render classes (DMZRacePartsLayer ×6, DMZRenderHand ×3, DMZPlayerRenderer, DMZSkinLayer, DMZThirdPartyLayerForwarder, DMZCustomArmorLayer) call:
StatsProvider.get(StatsCapability.INSTANCE, player).orElse(new StatsData(player));
Because Java evaluates .orElse(...) arguments eagerly, a brand-new StatsData → Character → createEmptyHairStyles() → CustomHair object graph was constructed and immediately discarded on every bone of every DMZCA villager on every frame — consuming 20.53% of the entire Render thread and triggering heavy GC stutters whenever looking at villages.
DMZCA Perf Fix v1.1.0 rewrites all 13 bytecode sites to perform a zero-allocation lazy lookup, only creating a fallback if the capability is genuinely absent.
2. Lock-Free Reflection Caching (v1.0.0 + Expanded in v1.1.0)
Rewrites 1,174+ uncached reflection calls and replaces 57 hot reflection helpers across 144 DMZCA classes (including NativeHybridTailRig, NativeBioTailAnimator, NativeTailMotion059, NpcFusionFaceBlend059, PlayerPotaraLeftEarring, KiControlBridge, McaGeneticsRuntime, and PotaraBreedingRuntime) with a lock-free ClassValue-backed cache (73.3× faster in microbenchmarks) with stackless cached negative results.
3. Automatic Mojmap → Forge 1.20.1 SRG Fallback (v1.1.0)
Automatically resolves Mojang-mapped reflection names (e.g. CompoundTag.getCompound → m_128469_, putInt → m_128405_, put → m_128365_, width/height → f_96543_/f_96544_), fixing KiControlBridge's NoSuchMethodException spam in production Forge 1.20.1.
4. Smart Villager 3D Hair Distance LOD (v1.1.0)
Applies distance LOD exclusively to DMZCA villager puppets (NativeMcaPuppet) while keeping real players and UI portraits 100% untouched:
- 0–8 blocks: Full sub-pixel voxel hair detail (
pixelFace→emitCell) and physics (1substep up to 12 blocks). - 8–28 blocks: Keeps full 3D hair blocks without heavy per-cell sub-pixel CPU subdivision.
- > 28 blocks (world render only): Skips 3D voxel hair mesh emission on far-away villagers.
- Configurable via JVM flags:
-Ddmzca.hairLodDistanceBlocks=28,-Ddmzca.hairPixelDetailBlocks=8,-Ddmzca.hairPhysicsBlocks=12.
5. Per-Entity Frame/Tick Cache for DMZ Ultra FormPartsLayer (v1.1.0)
Replaces DMZ Ultra's 1-slot static lookOf cache thrashing in FormPartsLayer.planFor with an immutable lock-free AtomicReferenceArray per-entity cache so multiple villagers on screen stop invalidating each other's cached plan on every bone.
6. Server-Side GenomeBridge.onTick Archive Throttle (v1.1.0)
Rewrites GenomeBridge.onTick's unthrottled per-tick GeneticLineageArchive.captureNow(entity) call to use DMZCA's own 128-tick staggered GeneticLineageArchive.capture(entity).
Compatibility & Installation
- Minecraft / Loader: Minecraft
1.20.1— Forge47+ - Supported Companion Mods (all optional — patches apply automatically only for mods present):
- DMZCA (Dragon Mine Z + MCA Unified)
0.5.x - DragonMineZ
2.x - DMZ Ultra
0.5.x/0.6.x/0.7.0+
- DMZCA (Dragon Mine Z + MCA Unified)
- Side: Required on Client for FPS/render optimizations and on Server (or Singleplayer) for TPS/reflection optimizations. Safe to add to or remove from existing worlds at any time.
- Note: This is an unofficial community performance patch. If the upstream mod authors fix these bottlenecks in a future official release, this patch can simply be removed.