🏛️ 아키텍처 분석 및 Mixin 주입 상세
📌 저장소 소스 코드 고지 사항: 이 위키의 문서는 CurseForge 및 Modrinth의 공개 릴리스 빌드에 앞서 최근 릴리스되지 않은 커밋 또는 개발 기능을 포함할 수 있는 저장소의 현재 소스 코드 상태를 반영합니다.
🔬 최상위 아키텍처 및 수명 주기 흐름도
True Sleep은 서버 수준에서 바닐라 수면 수명 주기를 가로채며, 즉각적인 시간 점프를 TimeWarpManager가 제어하는 동기식 틱 가속 루프로 대체합니다.
[ Player Enters Bed ]
│
▼
[ BedRule.Rule.test() Intercept ]
(Check truesleep:sleep_threshold)
│
▼
[ ServerLevel.tick() Sleep Check ]
(SleepStatus.areEnoughDeepSleeping())
│
+------------+------------+
│ │
[ Not All Sleeping ] [ All Sleeping (Enough) ]
│ │
▼ ▼
[ Initiate Wind-Down ] [ Engage Time Warp Engine ]
(15-tick Deceleration) │
├─► Set Physical Rate (ENGINE_TPS: 50 TPS)
├─► Compute Stride: round(VIRTUAL_TPS / ENGINE_TPS)
├─► Scale RANDOM_TICK_SPEED by Stride
├─► Multi-Tick Machines & Coupled Hoppers
├─► Freeze Mob AI / Age Farm Biology
├─► Apply Sleep Hunger Exhaustion
└─► Smooth Celestial Sun/Moon (Client Lerp)
│
▼
[ Destination Arrival ]
(Cycle Dist < 20 Ticks)
│
▼
[ Snap Monotonic Clock ]
(Set Time to WAKE_TIME: 0)
│
▼
[ Wake Up All Players ]🧩 전체 Mixin 주입 목록 및 디스크립터 대조표
| Mixin 클래스 | 대상 Minecraft 바닐라 클래스 | 주입 지점 | 후킹 메서드 | 주입 목적 및 핵심 기능 |
|---|---|---|---|---|
BedRuleMixin | net.minecraft.world.attribute.BedRule$Rule | @At("HEAD") (Cancellable) | test(Level) | WHEN_DARK 취침 조건 검사를 truesleep:sleep_threshold로 대체. |
ServerLevelMixin | net.minecraft.server.level.ServerLevel | @At("INVOKE") (Redirect) | areEnoughSleeping / areEnoughDeepSleeping | false를 반환하여 바닐라의 즉각적인 밤 건너뛰기 억제. |
ServerLevelMixin | net.minecraft.server.level.ServerLevel | @At("TAIL") | tick(BooleanSupplier) | 수면 조건을 검사하고 TimeWarpManager.tick() 엔진 구동. |
LevelMixin | net.minecraft.world.level.Level | @At("INVOKE") (Redirect) | TickingBlockEntity.tick() | 가속 기계 및 연결된 깔때기에 stride에 비례한 다중 틱 적용. |
MobMixin | net.minecraft.world.entity.Mob | @At("HEAD") (Cancellable) | tick() | 동결된 몹의 이동 AI를 취소하고 생물학적 농장 성장을 연산. |
EntityMixin | net.minecraft.world.entity.Entity | @At("HEAD") | baseTick() | drown_immunity 활성화 시 산소를 채워 수중 익사를 방지. |
LivingEntityMixin | net.minecraft.world.entity.LivingEntity | @At("HEAD") | baseTick() | 활성 물약 효과 지속 시간을 stride - 1틱만큼 고속 소모. |
MobEffectInstanceMixin | net.minecraft.world.effect.MobEffectInstance | Interface Injection | truesleep$ageEffect(int) | 연쇄 숨김 물약 효과를 무한 재귀 없이 안전하게 시간 진행. |
VibrationSystemListenerMixin | net.minecraft.world.level.gameevent.vibrations.VibrationSystem$Listener | @At("HEAD") (Cancellable) | handleGameEvent(...) | 시간 가속 중 워든 음향 진동 이벤트를 자동 차단/음소거. |
client.HudMixin | net.minecraft.client.gui.Hud | @At("HEAD") (Cancellable) | extractSleepOverlay(...) | 수면 중 바닐라의 전체 화면 검은 암전 페이드를 제거. |
client.SkyRendererMixin | net.minecraft.client.renderer.SkyRenderer | @At("TAIL") | extractRenderState(...) | 천체 각도에 0.35 계수 선형 보간을 적용하여 부드러운 하늘 렌더링. |
⚡ 핫 패스 제로 할당 (Zero-Allocation) 캐싱
초고속 시간 진행 중($50\text{ TPS} \times 50\text{ 스트라이드} = 초당 2{,}500\text{회 반복}$), 엔티티 루프 내 메모리 할당은 극심한 가비지 컬렉션(GC) 멈춤을 유발합니다.
True Sleep은 모든 핫 패스에 정적 락프리 병행 캐시를 채택했습니다:
truesleep$unfreezeCache:EntityType<?>별 GameRule 인스턴스를 캐싱하여 문자열 생성 완전 제거.truesleep$WORKER_CACHE:#truesleep:worker_mobs태그 포함 여부 캐싱.truesleep$PRODUCTION_MACHINE_CACHE:#truesleep:accelerated_machines블록 엔티티 타입 캐싱.TimeWarpManager필드 스냅샷: 엔티티 루프 내부에서 매번 조회하지 않고 틱당 1회 불리언 상태를 캐싱.
