7 Commits

Author SHA1 Message Date
Claude
8f989ee135 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 리스너 추가
2026-05-14 03:26:27 +09:00
Claude
a67ec47f89 v1.3.3 — replace storage flag with direct function call (race-free)
이전 v1.3.2: onPlayerJoin 에서 storage chat_answer:status active=1b 를 set.
하지만 통합 서버 (integrated singleplayer) 에서 데이터팩의 mq:load 가
player join 이후에 도는 케이스가 있어 모드가 써놓은 1b 를 데이터팩이
0b 로 덮어쓰는 race 가 있었고, repeat/players 의 첫 tick 체크 시점에
이미 0b 라서 알림 메세지가 안 떴음.

v1.3.3: storage flag 자체를 폐기. onPlayerJoin 에서
  execute as <uuid> at @s run function mq:players/mod_active_notice
를 호출. 데이터팩이 메세지 텍스트를 정의하고, 모드는 "지금 들어온 이
플레이어에게 보여라" 만 트리거한다. 데이터팩 자체가 없으면 함수가 없어
suppressed source 의 command 실패로 silent → 안전.

데이터팩(music_quiz) 도 동일 커밋으로 함수 추가 및 flag 제거됨.
2026-05-14 03:15:04 +09:00
Claude
d1c6504973 v1.3.2 — verbose logging to diagnose missing active=1b write
증상: chat_answer:status active 가 0b 그대로 → 데이터팩 login 메시지 안 뜸.
mq:load 는 정상 작동(0b 초기화 됨)인데 모드의 onPlayerJoin 이 1b 로 안 씀.

추가 로그:
  - ChatAnswerFabric.onInitialize: 진입/완료, event register 예외시 ERROR
  - ChatAnswerCore.onPlayerJoin: 진입 (player 이름 포함), 성공 시 INFO,
    실패 catch 를 LOG.debug → LOG.warn 으로 승격해 latest.log 에 보이게.

이 로그를 보고 다음 중 어디서 깨지는지 좁힐 수 있음:
  - "Fabric entrypoint onInitialize starting" 안 보임 → nested jar 미로드
  - "onInitialize starting" 보이고 "registered" 안 보임 → fabric-api ABI mismatch
  - "onPlayerJoin fired" 안 보임 → JOIN 이벤트 미발화
  - "active=1b set" 안 보이고 "failed" 만 보임 → command 실행 실패

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 03:02:00 +09:00
Claude
939505c861 v1.3.1 — fix: declare nested fabric jars in outer fabric.mod.json
v1.3.0 의 nested fabric jar 가 실제로 로드되지 않던 버그 수정.

Fabric Loader 는 META-INF/jars/ 디렉토리를 자동 스캔하지 않고, 부모 jar 의
fabric.mod.json 에 "jars" 배열로 명시된 파일만 처리한다. v1.3.0 에선 jars
배열이 비어 있어서 outer chat_answer 컨테이너만 로드되고 (entrypoint 없으니
no-op), 실제 채팅 hook 을 담은 nested fabric jar 는 그대로 무시됐다.

수정:
  - container-resources/fabric.mod.json: "jars" 배열에 두 nested 경로 명시
  - root build.gradle: containerJar 의 nested jar 파일명을 버전 suffix 없는
    고정 이름 (chat_answer-fabric-1216.jar / -2612.jar) 으로 변경. outer
    fabric.mod.json 의 jars 항목과 일치해야 Fabric Loader 가 찾는다.

증상: 음악퀴즈 데이터팩 맵 접속 시 "모드 활성화" 메시지 안 뜸
      (ServerPlayConnectionEvents.JOIN 이 실행 안 되어 storage chat_answer:status
       active 가 0b 로 유지).
원인: 위와 같이 nested jar 가 로드 안 됨.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 02:50:25 +09:00
Claude
e01137ee31 v1.3.0 — single jar covers Fabric 1.21.6 + Fabric 26.1.2 + NeoForge 1.21.6
이전엔 1.21.6 (v1.1.1) 와 26.1.2 (v1.2.1) 가 분리된 jar 였음. 사용자 입장에서
버전별로 다른 파일을 받아야 했고 합친 의미가 없어서, 한 jar 가 어느 환경에든
들어갈 수 있도록 컨테이너 구조로 재작업.

구조:
  - outer chat_answer-1.3.0.jar
    ├── fabric.mod.json         (entrypoint 없는 컨테이너 메타. MC dep 없음.)
    ├── META-INF/neoforge.mods.toml  (NeoForge 1.21.6 모드 본체 메타)
    ├── kr/.../neoforge/        (NeoForge 1.21.6 entry + core, Mojang 매핑)
    ├── kr/.../core/            (NeoForge 가 쓰는 공유 core 사본)
    └── META-INF/jars/          (Fabric Loader 가 자동 스캔)
        ├── chat_answer-fabric-1216-1.3.0.jar  (MC ">=1.21.6 <1.22")
        └── chat_answer-fabric-2612-1.3.0.jar  (MC ">=26.1.2")

로더별 동작:
  - Fabric 1.21.6  → outer 는 no-op 컨테이너, 1216 nested 가 활성 (intermediary class_NNNN 리매핑됨)
  - Fabric 26.1.2  → outer 는 no-op 컨테이너, 2612 nested 가 활성 (intermediary 0.0.0 identity)
  - NeoForge 1.21.6 → outer 의 NeoForge entry 가 동작. Fabric 메타와 nested jars 는 NeoForge 가 무시.

핵심 트레이드오프:
  - 1.21.6 fabric subproject 는 modImplementation 필수 (intermediary 매핑 리맵 필요)
  - 26.1.2 fabric subproject 는 implementation 으로 충분 (서버 jar unobfuscated → identity 매핑)
  - 26.1.2 NeoForge 는 moddev plugin 이 아직 26.x 를 파싱 못 함 → 1.21.6 만 지원
  - 두 nested fabric jar 는 mod id 동일 (chat_answer_fabric) — depends.minecraft 가 상호 배타라
    한 환경에서 둘이 동시 candidate 가 되지 않으므로 충돌 없음.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 02:45:54 +09:00
Claude
785efe24b9 v1.2.1 — add icon, drop contact homepage
- Embed music quiz icon at assets/chat_answer/icon.png; reference from
  fabric.mod.json so ModMenu shows it.
- Remove contact.homepage (private Gitea — owner-only).
2026-05-14 02:28:20 +09:00
Claude
e4bfda783a v1.2.0 — target MC 26.1.2
User reported NoClassDefFoundError: net/minecraft/class_7471 on MC 26.1.2.
Root cause: v1.1.1 was built for 1.21.6 intermediary, which uses
class_NNNN obfuscated names. MC 26.x ships an unobfuscated server jar
with Mojang names directly, so intermediary lookups for class_7471
(=PlayerChatMessage in 1.21.6) fail at runtime.

Build retargeted to 26.1.2:
- minecraft 26.1.2 / loader 0.19.2 / fabric-api 0.148.2+26.1.2
- Loom 1.16-SNAPSHOT, Shadow 9.4.1 (Java 25 bytecode support)
- Gradle 9.5.1, JDK 25 toolchain
- Drop officialMojangMappings(); use intermediary:0.0.0 identity
  (Mojang stopped publishing proguard mappings for 26.x).
- Adapt code: ServerPlayer.getServer() removed in 26.1.2 → use
  player.level().getServer() (ServerPlayer.level() returns ServerLevel).
- NeoForge dropped from this build — moddev plugin can't parse 26.1.2
  yet, falls back to 1.21.5.
- 1.2.0 = Fabric only; 1.21.6 users stay on 1.1.1.
2026-05-14 01:55:02 +09:00
22 changed files with 377 additions and 184 deletions

View File

@@ -8,12 +8,14 @@ allprojects {
group = project.mod_group group = project.mod_group
version = project.mod_version version = project.mod_version
// 기본 JDK toolchain 은 Java 25 (26.x Loom 빌드 요구). subproject 가 필요하면
// 자체 release 21 등으로 다운그레이드.
java { java {
toolchain.languageVersion = JavaLanguageVersion.of(21) toolchain.languageVersion = JavaLanguageVersion.of(25)
} }
tasks.withType(JavaCompile).configureEach { tasks.withType(JavaCompile).configureEach {
options.release = 21 options.release = 25
options.encoding = 'UTF-8' options.encoding = 'UTF-8'
} }
@@ -24,30 +26,57 @@ allprojects {
} }
} }
// ───── merged jar ────────────────────────────────────────────────────────── // ───── 단일 배포 jar 컨테이너 ────────────────────────────────────────────────
// fabric + neoforge 각각의 remapJar 결과물을 한 jar 안에 압축해서 단일 배포물 생성. // 한 jar 가 어떤 환경에서도 동작하도록:
// 같은 클래스(common 코드)는 한 번만 포함. 각 로더는 자신의 mod metadata // * outer = NeoForge 1.21.6 모드 본체 (NeoForge 만 fabric.mod.json 을 무시)
// (fabric.mod.json / META-INF/neoforge.mods.toml) 만 인식해서 자기 쪽 진입점만 로드. // + 메타로 fabric.mod.json (entrypoint 없는 컨테이너)
// * META-INF/jars/ = Fabric 용 nested jar 둘 (1.21.6 / 26.1.2)
// Fabric Loader 가 depends.minecraft 로 자동 매칭. NeoForge 는 무시.
//
// 결과: chat_answer-<version>.jar 한 개를 Fabric 1.21.6 / Fabric 26.1.2 / NeoForge
// 1.21.6 어디에 넣어도 적절한 코드 경로가 활성화된다.
tasks.register('containerJar', Jar) {
dependsOn ':fabric-1216:remapJar',
':fabric-2612:remapJar',
':neoforge-1216:jar'
tasks.register('mergedJar', Jar) {
dependsOn ':fabric:relocatedJar', ':neoforge:jar'
archiveBaseName = project.mod_id archiveBaseName = project.mod_id
archiveVersion = project.mod_version archiveVersion = project.mod_version
archiveClassifier = 'all' archiveClassifier = ''
destinationDirectory = file('build/libs') destinationDirectory = file('build/libs')
duplicatesStrategy = DuplicatesStrategy.EXCLUDE duplicatesStrategy = DuplicatesStrategy.EXCLUDE
// Fabric: Shadow(relocatedJar) 가 common 패키지를 kr.tkrmagid.chatanswer.fabric.core 로 옮긴 jar // 1. NeoForge 모드 본체 (classes + META-INF/neoforge.mods.toml + icon.png) 을 통째로.
// NeoForge: common 은 그대로 kr.tkrmagid.chatanswer.core 에 위치 // MANIFEST.MF 는 새 jar 가 자체적으로 생성하니 제외.
// → 같은 클래스명 다른 매핑이라도 패키지 경로가 달라서 공존 가능 from(zipTree(project(':neoforge-1216').tasks.named('jar').flatMap { it.archiveFile })) {
from(zipTree(project(':fabric').tasks.named('relocatedJar').flatMap { it.archiveFile }))
from(zipTree(project(':neoforge').tasks.named('jar').flatMap { it.archiveFile })) {
// META-INF/MANIFEST.MF 는 Fabric 측 것을 그대로 사용 (둘 다 단순 manifest)
exclude 'META-INF/MANIFEST.MF' exclude 'META-INF/MANIFEST.MF'
} }
// 2. Fabric 컨테이너 메타데이터 (entrypoint 없이 그냥 "외피") 와 아이콘.
// fabric.mod.json 의 ${version} 만 치환.
filteringCharset = 'UTF-8'
from("${rootDir}/container-resources") {
filesMatching("fabric.mod.json") {
expand("version": project.mod_version)
}
}
// 3. Fabric nested jars. Fabric Loader 는 META-INF/jars/ 를 자동 스캔하지
// 않고 outer fabric.mod.json 의 "jars" 배열에 명시된 파일만 처리하므로,
// container-resources/fabric.mod.json 의 jars 항목과 일치하는 고정 파일명
// (버전 suffix 제거) 으로 넣는다.
into('META-INF/jars') {
from(project(':fabric-1216').tasks.named('remapJar').flatMap { it.archiveFile }) {
rename '.+\\.jar', 'chat_answer-fabric-1216.jar'
}
from(project(':fabric-2612').tasks.named('remapJar').flatMap { it.archiveFile }) {
rename '.+\\.jar', 'chat_answer-fabric-2612.jar'
}
}
} }
tasks.register('buildAll') { tasks.register('buildAll') {
dependsOn 'mergedJar' dependsOn 'containerJar'
} }

View File

@@ -1,5 +1,9 @@
package kr.tkrmagid.chatanswer.core; package kr.tkrmagid.chatanswer.core;
import java.util.Iterator;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
@@ -29,25 +33,55 @@ public final class ChatAnswerCore {
private static final String SCOREBOARD_HOLDER = "init"; private static final String SCOREBOARD_HOLDER = "init";
private static final int ACCEPTING_ANSWER_STATE = 5; private static final int ACCEPTING_ANSWER_STATE = 5;
/** JOIN 이벤트 시점엔 클라이언트가 chat HUD 를 받을 준비가 안 됐을 수 있어
* tellraw 패킷이 사라지는 경우가 있다. 그래서 N 틱 늦춰서 호출한다. */
private static final int NOTICE_DELAY_TICKS = 20;
private static final Map<UUID, Integer> PENDING_NOTICES = new ConcurrentHashMap<>();
private ChatAnswerCore() {} private ChatAnswerCore() {}
/** /**
* 플레이어 로그인 직후 호출. 데이터팩이 "모드 살아있음" 신호로 쓸 수 있게 * 플레이어 로그인 시점에 호출. 음악퀴즈 데이터팩의
* storage chat_answer:status 에 active=1b 를 세팅한다. 데이터팩의 mq:load 가 * mq:players/mod_active_notice
* 매 /reload 와 서버 시작 시 이 값을 0b 로 clear 하므로, 모드가 없으면 이 * 함수를 해당 플레이어 컨텍스트로 호출한다. 단, JOIN 이벤트가 너무 일러서
* 호출이 일어나지 않아 0b 로 유지되고, 모드가 있으면 첫 로그인 직후 1b 로 갱신. * 즉시 호출 시 tellraw 가 클라이언트에 도달하지 못하는 race 가 있어
* {@link #NOTICE_DELAY_TICKS} 만큼 늦춘다 ({@link #onServerTick} 가 처리).
*/ */
public static void onPlayerJoin(ServerPlayer player) { public static void onPlayerJoin(ServerPlayer player) {
MinecraftServer server = player.getServer(); String name = player.getName().getString();
if (server == null) return; LOG.info("[{}] onPlayerJoin fired for {}, scheduling notice in {} ticks",
CommandSourceStack source = server.createCommandSourceStack().withSuppressedOutput(); MOD_ID, name, NOTICE_DELAY_TICKS);
PENDING_NOTICES.put(player.getUUID(), NOTICE_DELAY_TICKS);
}
/** 각 로더 entrypoint 가 매 server tick 마다 호출해야 한다. */
public static void onServerTick(MinecraftServer server) {
if (PENDING_NOTICES.isEmpty()) return;
Iterator<Map.Entry<UUID, Integer>> it = PENDING_NOTICES.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<UUID, Integer> e = it.next();
int remaining = e.getValue() - 1;
if (remaining > 0) {
e.setValue(remaining);
continue;
}
UUID uuid = e.getKey();
it.remove();
ServerPlayer player = server.getPlayerList().getPlayer(uuid);
if (player == null) continue;
deliverNotice(server, player);
}
}
private static void deliverNotice(MinecraftServer server, ServerPlayer player) {
String name = player.getName().getString();
// 플레이어 자체를 source 로 써서 함수 안의 @s 가 그대로 player.
CommandSourceStack source = player.createCommandSourceStack().withSuppressedOutput();
try { try {
server.getCommands().performPrefixedCommand( server.getCommands().performPrefixedCommand(source, "function mq:players/mod_active_notice");
source, LOG.info("[{}] mod_active_notice delivered for {}", MOD_ID, name);
"data modify storage chat_answer:status active set value 1b"
);
} catch (Exception e) { } catch (Exception e) {
LOG.debug("[{}] failed to set active flag: {}", MOD_ID, e.toString()); LOG.warn("[{}] failed to deliver mod_active_notice for {}: {}", MOD_ID, name, e.toString(), e);
} }
} }
@@ -55,7 +89,7 @@ public final class ChatAnswerCore {
* @return true = 채팅을 평소처럼 broadcast / false = 채팅 차단 (이미 정답 제출 처리됨) * @return true = 채팅을 평소처럼 broadcast / false = 채팅 차단 (이미 정답 제출 처리됨)
*/ */
public static boolean handleChat(ServerPlayer sender, String rawText) { public static boolean handleChat(ServerPlayer sender, String rawText) {
MinecraftServer server = sender.getServer(); MinecraftServer server = sender.level().getServer();
if (server == null) return true; if (server == null) return true;
if (!isAcceptingAnswer(server)) return true; if (!isAcceptingAnswer(server)) return true;

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@@ -0,0 +1,19 @@
{
"schemaVersion": 1,
"id": "chat_answer",
"version": "${version}",
"name": "채팅정답",
"description": "음악퀴즈(mq) 데이터팩이 정답 입력을 받는 상태(init=5)에서 채팅을 가로채 mq:answer/submit 함수로 전달합니다. 단일 jar 에 1.21.6 (Fabric/NeoForge) + 26.1.2 (Fabric) 빌드가 모두 들어있어 어느 환경에서도 그대로 동작합니다.",
"authors": [ "tkrmagid" ],
"license": "MIT",
"icon": "assets/chat_answer/icon.png",
"environment": "*",
"jars": [
{ "file": "META-INF/jars/chat_answer-fabric-1216.jar" },
{ "file": "META-INF/jars/chat_answer-fabric-2612.jar" }
],
"depends": {
"fabricloader": ">=0.16.0",
"java": ">=21"
}
}

53
fabric-1216/build.gradle Normal file
View File

@@ -0,0 +1,53 @@
plugins {
id 'fabric-loom' version '1.16-SNAPSHOT'
}
base.archivesName = "${project.mod_id}-fabric-1216"
// 1.21.6 은 Java 21 런타임. release 21 로 컴파일.
java {
toolchain.languageVersion = JavaLanguageVersion.of(25)
}
tasks.withType(JavaCompile).configureEach {
options.release = 21
}
// common/ 디렉토리의 로더 비종속 소스 포함. Mojang 매핑으로 컴파일됨.
sourceSets {
main {
java {
srcDirs += "${rootDir}/common/src/main/java"
}
}
}
dependencies {
minecraft "com.mojang:minecraft:${project.mc_1216}"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_1216}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_1216}"
}
loom {
serverOnlyMinecraftJar()
}
processResources {
inputs.property "version", project.version
inputs.property "mod_id", project.mod_id
filteringCharset = 'UTF-8'
filesMatching("fabric.mod.json") {
expand(
"version": project.version,
"mod_id": project.mod_id
)
}
}
jar {
from(rootProject.file("LICENSE")) {
rename { "${it}_${project.mod_id}_fabric_1216" }
}
}

View File

@@ -0,0 +1,31 @@
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;
import org.slf4j.LoggerFactory;
public final class ChatAnswerFabric implements ModInitializer {
private static final Logger LOG = LoggerFactory.getLogger(ChatAnswerCore.MOD_ID);
@Override
public void onInitialize() {
LOG.info("[{}] Fabric entrypoint onInitialize starting", ChatAnswerCore.MOD_ID);
try {
ServerMessageEvents.ALLOW_CHAT_MESSAGE.register((message, sender, params) ->
ChatAnswerCore.handleChat(sender, message.signedContent())
);
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) ->
ChatAnswerCore.onPlayerJoin(handler.player)
);
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;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@@ -1,21 +1,19 @@
{ {
"schemaVersion": 1, "schemaVersion": 1,
"id": "${mod_id}", "id": "chat_answer_fabric",
"version": "${version}", "version": "${version}",
"name": "${mod_name}", "name": "채팅정답 (Fabric impl)",
"description": "음악퀴즈(mq) 데이터팩이 정답 입력을 받는 상태(init=5)에서 채팅을 가로채 mq:answer/submit 함수로 전달합니다.", "description": "음악퀴즈(mq) 데이터팩이 정답 입력을 받는 상태(init=5)에서 채팅을 가로채 mq:answer/submit 함수로 전달합니다. (MC 1.21.6 변형)",
"authors": [ "tkrmagid" ], "authors": [ "tkrmagid" ],
"contact": {
"homepage": "https://git.tkrmagid.kr/tkrmagid/mc_chat_answer_mod"
},
"license": "MIT", "license": "MIT",
"icon": "assets/chat_answer/icon.png",
"environment": "*", "environment": "*",
"entrypoints": { "entrypoints": {
"main": [ "kr.tkrmagid.chatanswer.fabric.ChatAnswerFabric" ] "main": [ "kr.tkrmagid.chatanswer.fabric.ChatAnswerFabric" ]
}, },
"depends": { "depends": {
"fabricloader": ">=0.16.0", "fabricloader": ">=0.16.0",
"minecraft": ">=1.21.6", "minecraft": ">=1.21.6 <1.22",
"java": ">=21", "java": ">=21",
"fabric-api": "*" "fabric-api": "*"
} }

42
fabric-2612/build.gradle Normal file
View File

@@ -0,0 +1,42 @@
plugins {
id 'fabric-loom' version '1.16-SNAPSHOT'
}
base.archivesName = "${project.mod_id}-fabric-2612"
// common/ 디렉토리의 로더 비종속 소스 포함.
sourceSets {
main {
java {
srcDirs += "${rootDir}/common/src/main/java"
}
}
}
dependencies {
// MC 26.x: server jar 가 unobfuscated. intermediary 0.0.0 = identity mapping.
minecraft "com.mojang:minecraft:${project.mc_2612}"
mappings "net.fabricmc:intermediary:0.0.0:v2"
implementation "net.fabricmc:fabric-loader:${project.fabric_loader_2612}"
implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_2612}"
}
processResources {
inputs.property "version", project.version
inputs.property "mod_id", project.mod_id
filteringCharset = 'UTF-8'
filesMatching("fabric.mod.json") {
expand(
"version": project.version,
"mod_id": project.mod_id
)
}
}
jar {
from(rootProject.file("LICENSE")) {
rename { "${it}_${project.mod_id}_fabric_2612" }
}
}

View File

@@ -0,0 +1,31 @@
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;
import org.slf4j.LoggerFactory;
public final class ChatAnswerFabric implements ModInitializer {
private static final Logger LOG = LoggerFactory.getLogger(ChatAnswerCore.MOD_ID);
@Override
public void onInitialize() {
LOG.info("[{}] Fabric entrypoint onInitialize starting", ChatAnswerCore.MOD_ID);
try {
ServerMessageEvents.ALLOW_CHAT_MESSAGE.register((message, sender, params) ->
ChatAnswerCore.handleChat(sender, message.signedContent())
);
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) ->
ChatAnswerCore.onPlayerJoin(handler.player)
);
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;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@@ -0,0 +1,20 @@
{
"schemaVersion": 1,
"id": "chat_answer_fabric",
"version": "${version}",
"name": "채팅정답 (Fabric impl)",
"description": "음악퀴즈(mq) 데이터팩이 정답 입력을 받는 상태(init=5)에서 채팅을 가로채 mq:answer/submit 함수로 전달합니다. (MC 26.1.2 변형)",
"authors": [ "tkrmagid" ],
"license": "MIT",
"icon": "assets/chat_answer/icon.png",
"environment": "*",
"entrypoints": {
"main": [ "kr.tkrmagid.chatanswer.fabric.ChatAnswerFabric" ]
},
"depends": {
"fabricloader": ">=0.19.0",
"minecraft": ">=26.1.2",
"java": ">=21",
"fabric-api": "*"
}
}

View File

@@ -1,71 +0,0 @@
plugins {
id 'fabric-loom' version '1.10-SNAPSHOT'
id 'com.gradleup.shadow' version '8.3.5'
}
archivesBaseName = "${project.mod_id}-fabric"
// common/ 디렉토리의 로더 비종속 소스를 fabric 컴파일에 포함 (Mojang 매핑으로 컴파일)
sourceSets {
main {
java {
srcDirs += "${rootDir}/common/src/main/java"
}
}
}
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
}
loom {
serverOnlyMinecraftJar()
}
processResources {
inputs.property "version", project.version
inputs.property "mod_id", project.mod_id
inputs.property "mod_name", project.mod_name
filesMatching("fabric.mod.json") {
expand(
"version": project.version,
"mod_id": project.mod_id,
"mod_name": project.mod_name
)
}
}
jar {
from(rootProject.file("LICENSE")) {
rename { "${it}_${project.mod_id}" }
}
}
// ───── relocation for single-jar merge ─────────────────────────────────────
// Fabric 의 common 코드는 intermediary 매핑으로 컴파일되고, NeoForge 의 common
// 코드는 Mojang 매핑으로 컴파일된다. 둘은 바이트코드가 달라서 같은 클래스 경로에
// 공존 불가. Shadow 의 relocate 로 Fabric 쪽 common 클래스만 별도 패키지로 옮겨서
// merged jar 안에서 충돌하지 않게 한다.
//
// 진행 순서: loom 의 remapJar 결과 → shadowJar 가 받아서 패키지 재배치 →
// rootProject 의 mergedJar 가 이걸 사용.
// Shadow 가 자동으로 만든 shadowJar 는 main sourceSet + 런타임 classpath 를 전부
// 포함해서 100MB+ 가 되어버린다. 우리한테 필요한 건 "remapJar 결과물에 relocate 만
// 적용한 작은 jar" 이므로, 별도 ShadowJar 태스크를 새로 만들어서 입력을 명시적으로
// remapJar 의 zipTree 만 지정한다.
tasks.register('relocatedJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
dependsOn 'remapJar'
archiveClassifier = 'relocated'
from zipTree(tasks.named('remapJar').flatMap { it.archiveFile })
relocate 'kr.tkrmagid.chatanswer.core', 'kr.tkrmagid.chatanswer.fabric.core'
mergeServiceFiles()
}
tasks.named('build') {
dependsOn 'relocatedJar'
}

View File

@@ -1,18 +0,0 @@
package kr.tkrmagid.chatanswer.fabric;
import kr.tkrmagid.chatanswer.core.ChatAnswerCore;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.message.v1.ServerMessageEvents;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
public final class ChatAnswerFabric implements ModInitializer {
@Override
public void onInitialize() {
ServerMessageEvents.ALLOW_CHAT_MESSAGE.register((message, sender, params) ->
ChatAnswerCore.handleChat(sender, message.signedContent())
);
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) ->
ChatAnswerCore.onPlayerJoin(handler.player)
);
}
}

View File

@@ -1,20 +1,26 @@
org.gradle.jvmargs=-Xmx3G org.gradle.jvmargs=-Xmx3G
org.gradle.parallel=true org.gradle.parallel=true
# ───── target Minecraft / loader versions ───────────────────────────────────
# 1.21.6 = dialog system 최초 버전 = 음악퀴즈 데이터팩 최소 요구 버전
minecraft_version=1.21.6
# Fabric
yarn_mappings=1.21.6+build.1
loader_version=0.16.10
fabric_version=0.128.2+1.21.6
# NeoForge
neoforge_version=21.6.20-beta
# ───── mod metadata ───────────────────────────────────────────────────────── # ───── mod metadata ─────────────────────────────────────────────────────────
mod_id=chat_answer mod_id=chat_answer
mod_version=1.1.1 mod_version=1.3.4
mod_group=kr.tkrmagid.chatanswer mod_group=kr.tkrmagid.chatanswer
mod_name=채팅정답 mod_name=채팅정답
# ───── per-target MC / loader versions ──────────────────────────────────────
# 한 jar 로 1.21.6 (Fabric/NeoForge) + 26.1.2 (Fabric) 전부 커버하기 위해
# 각 타겟마다 별도 subproject 가 자기 버전으로 빌드되고, 결과물을 outer
# container jar 가 묶는다 (Fabric 은 META-INF/jars/ JiJ, NeoForge 는 outer 본체).
# Fabric MC 1.21.6
mc_1216=1.21.6
fabric_api_1216=0.128.2+1.21.6
fabric_loader_1216=0.16.10
# Fabric MC 26.1.2 (26.x 서버 jar 는 unobfuscated. intermediary 0.0.0 = identity)
mc_2612=26.1.2
fabric_api_2612=0.148.2+26.1.2
fabric_loader_2612=0.19.2
# NeoForge MC 1.21.6 (26.x 는 NeoForge moddev plugin 이 아직 인식 못 함)
neoforge_1216=21.6.20-beta

View File

@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

View File

@@ -0,0 +1,49 @@
plugins {
id 'net.neoforged.moddev' version '2.0.97'
}
base.archivesName = "${project.mod_id}-neoforge-1216"
// NeoForge 1.21.6 은 Java 21. release 21 로 컴파일.
java {
toolchain.languageVersion = JavaLanguageVersion.of(25)
}
tasks.withType(JavaCompile).configureEach {
options.release = 21
}
sourceSets {
main {
java {
srcDirs += "${rootDir}/common/src/main/java"
}
}
}
neoForge {
version = project.neoforge_1216
}
processResources {
inputs.property "version", project.version
inputs.property "mod_id", project.mod_id
inputs.property "minecraft_version", project.mc_1216
inputs.property "neoforge_version", project.neoforge_1216
filteringCharset = 'UTF-8'
filesMatching("META-INF/neoforge.mods.toml") {
expand(
"version": project.version,
"mod_id": project.mod_id,
"minecraft_version": project.mc_1216,
"neoforge_version": project.neoforge_1216
)
}
}
jar {
from(rootProject.file("LICENSE")) {
rename { "${it}_${project.mod_id}_neoforge_1216" }
}
}

View File

@@ -8,12 +8,14 @@ import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.ServerChatEvent; import net.neoforged.neoforge.event.ServerChatEvent;
import net.neoforged.neoforge.event.entity.player.PlayerEvent; import net.neoforged.neoforge.event.entity.player.PlayerEvent;
import net.neoforged.neoforge.event.tick.ServerTickEvent;
@Mod(ChatAnswerCore.MOD_ID) @Mod(ChatAnswerCore.MOD_ID)
public final class ChatAnswerNeoForge { public final class ChatAnswerNeoForge {
public ChatAnswerNeoForge(IEventBus modBus) { public ChatAnswerNeoForge(IEventBus modBus) {
NeoForge.EVENT_BUS.addListener(ChatAnswerNeoForge::onServerChat); NeoForge.EVENT_BUS.addListener(ChatAnswerNeoForge::onServerChat);
NeoForge.EVENT_BUS.addListener(ChatAnswerNeoForge::onPlayerLogin); NeoForge.EVENT_BUS.addListener(ChatAnswerNeoForge::onPlayerLogin);
NeoForge.EVENT_BUS.addListener(ChatAnswerNeoForge::onServerTick);
} }
@SubscribeEvent @SubscribeEvent
@@ -30,4 +32,9 @@ public final class ChatAnswerNeoForge {
ChatAnswerCore.onPlayerJoin(player); ChatAnswerCore.onPlayerJoin(player);
} }
} }
@SubscribeEvent
public static void onServerTick(ServerTickEvent.Post event) {
ChatAnswerCore.onServerTick(event.getServer());
}
} }

View File

@@ -1,15 +1,14 @@
modLoader = "javafml" modLoader = "javafml"
loaderVersion = "[1,)" loaderVersion = "[1,)"
license = "MIT" license = "MIT"
issueTrackerURL = "https://git.tkrmagid.kr/tkrmagid/mc_chat_answer_mod/issues"
[[mods]] [[mods]]
modId = "${mod_id}" modId = "${mod_id}"
version = "${version}" version = "${version}"
displayName = "${mod_name}" displayName = "채팅정답"
authors = "tkrmagid" authors = "tkrmagid"
description = '''음악퀴즈(mq) 데이터팩이 정답 입력을 받는 상태(init=5)에서 채팅을 가로채 mq:answer/submit 함수로 전달합니다.''' description = '''음악퀴즈(mq) 데이터팩이 정답 입력을 받는 상태(init=5)에서 채팅을 가로채 mq:answer/submit 함수로 전달합니다.'''
displayURL = "https://git.tkrmagid.kr/tkrmagid/mc_chat_answer_mod" logoFile = "icon.png"
[[dependencies.${mod_id}]] [[dependencies.${mod_id}]]
modId = "neoforge" modId = "neoforge"

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@@ -1,41 +0,0 @@
plugins {
id 'net.neoforged.moddev' version '2.0.97'
}
archivesBaseName = "${project.mod_id}-neoforge"
sourceSets {
main {
java {
srcDirs += "${rootDir}/common/src/main/java"
}
}
}
neoForge {
version = project.neoforge_version
}
processResources {
inputs.property "version", project.version
inputs.property "mod_id", project.mod_id
inputs.property "mod_name", project.mod_name
inputs.property "minecraft_version", project.minecraft_version
inputs.property "neoforge_version", project.neoforge_version
filesMatching("META-INF/neoforge.mods.toml") {
expand(
"version": project.version,
"mod_id": project.mod_id,
"mod_name": project.mod_name,
"minecraft_version": project.minecraft_version,
"neoforge_version": project.neoforge_version
)
}
}
jar {
from(rootProject.file("LICENSE")) {
rename { "${it}_${project.mod_id}" }
}
}

View File

@@ -8,4 +8,9 @@ pluginManagement {
} }
rootProject.name = 'chat_answer' rootProject.name = 'chat_answer'
include 'fabric', 'neoforge'
// 세 개의 target-specific subproject. 각각 자기 MC/로더 버전으로 컴파일/리맵.
// rootProject 의 containerJar 가 셋의 산출물을 하나로 묶어 단일 jar 배포물 생성.
include 'fabric-1216'
include 'fabric-2612'
include 'neoforge-1216'