v1.3.4 — defer mod_active_notice by 20 ticks to fix chat-not-delivered race

v1.3.3 에서 PlayerJoinEvent 시점에 즉시 `execute as <uuid> ... run function`
으로 데이터팩 함수를 호출했는데, JOIN 이벤트 시점은 플레이어가 PlayerList 에
막 들어간 직후라 클라이언트가 시스템 chat 패킷을 받을 준비가 안 됐고
tellraw 가 사라지는 race 가 있었음.

사용자 로그에서 확인: 모드의 `mod_active_notice invoked` 가 03:22:42 에
찍혔으나 클라이언트엔 메세지 안 도착, 1초 뒤 (03:22:43) mq:load 가 보낸
같은 시스템의 tellraw 는 정상 도착, 9초 뒤 수동 /function 호출도 정상.

수정: JOIN 시 즉시 호출하지 않고 UUID → 남은 틱 수 맵에 적재, server tick
마다 카운트 다운, 20 ticks (1초) 후 player 자체를 source 로 한
CommandSourceStack 으로 `function mq:players/mod_active_notice` 호출.

엔트리포인트 변경:
- fabric-1216/2612: ServerTickEvents.END_SERVER_TICK 추가 등록
- neoforge-1216: ServerTickEvent.Post 리스너 추가
This commit is contained in:
Claude
2026-05-14 03:26:27 +09:00
parent a67ec47f89
commit 8f989ee135
5 changed files with 57 additions and 23 deletions

View File

@@ -2,6 +2,7 @@ package kr.tkrmagid.chatanswer.fabric;
import kr.tkrmagid.chatanswer.core.ChatAnswerCore;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.fabricmc.fabric.api.message.v1.ServerMessageEvents;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import org.slf4j.Logger;
@@ -20,7 +21,8 @@ public final class ChatAnswerFabric implements ModInitializer {
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) ->
ChatAnswerCore.onPlayerJoin(handler.player)
);
LOG.info("[{}] Fabric entrypoint registered: ALLOW_CHAT_MESSAGE + JOIN", ChatAnswerCore.MOD_ID);
ServerTickEvents.END_SERVER_TICK.register(ChatAnswerCore::onServerTick);
LOG.info("[{}] Fabric entrypoint registered: ALLOW_CHAT_MESSAGE + JOIN + TICK", ChatAnswerCore.MOD_ID);
} catch (Throwable t) {
LOG.error("[{}] Fabric entrypoint event registration failed", ChatAnswerCore.MOD_ID, t);
throw t;