4 Commits

Author SHA1 Message Date
Claude (owner)
28f1012294 music_quiz: 버튼 interaction 오프셋을 facing 으로부터 자동 계산
button_defs 항목은 이제 {n, x, y, z, f, c} 만 가진다 (ox/oy/oz/w/h 제거).
사용자가 facing 을 바꿀 때마다 손으로 오프셋 표를 옮겨 적을 필요가 없도록
repeat/buttons/btn.mcfunction 한 곳에 facing → 소환 오프셋을 고정해두고
mq:tmp.btn{f:"..."} 분기로 디스패치한다. width/height 도 stone_button
hitbox 에 맞춰 0.375/0.25 로 박제.

handler 는 각 entry 를 mq:tmp.btn 으로 복사한 뒤 btn 을 호출해 분기
predicate 에 사용할 수 있게 한다.
2026-05-17 03:56:41 +09:00
Claude (owner)
4349fddc25 music_quiz: dialog tag entry 에 required:false 추가 — /reload 시 datapack 깨짐 방지
증상:
- /reload 후 다음 에러:
  - Couldn't load tag minecraft:quick_actions as it is missing following references: mq:answer
  - Failed to load function mq:commands/start (Can't find element 'mq:page1' in registry 'minecraft:dialog')
  - Failed to load function mq:answer/open (Can't find element 'mq:answer' ...)

원인:
- MC 의 minecraft:dialog 레지스트리는 hot-reload 불가. /reload 로는 dialog 파일이
  registry 에 등록되지 않음 — 서버 완전 재시작이 필요.
- 그 상태에서 tag 가 `["mq:answer"]` 같은 짧은 형식으로 dialog 를 참조하면
  MC 는 누락된 reference 로 보고 태그 로드 실패 → 같은 reload 의 function 들이
  dialog registry 를 못 찾아 연쇄 실패.

수정:
- quick_actions.json: `"mq:answer"` → `{ "id": "mq:answer", "required": false }`.
  required:false 는 reference 가 없을 때 silently 무시하라는 지시. /reload 직후
  잠시 dialog registry 가 비어있어도 datapack 자체가 깨지지 않음.

주의 (운영):
- 데이터팩 업데이트 후에는 반드시 서버를 완전 재시작 해야 dialog show 호출이
  정상 동작함. /reload 만으로는 dialog 파일이 registry 에 들어가지 않음 — 이건
  MC 26.1 시점의 dialog 시스템 자체 제약 (Smithed/Mojang 문서 기준).
2026-05-17 00:10:51 +09:00
Claude (owner)
a8d09ece02 music_quiz: marker 엔티티 제거 + 노래 재생 채널을 player 로 변경
## marker 제거
모든 marker 소환 코드는 write-only — 어디에서도 @e[type=marker] / tag=default
selector 로 읽거나 죽이지 않았음. interaction 엔티티가 클릭 UI 를 대체한 이후
완전히 쓸모없는 잔존물.

- 삭제: quiz/macro/summon.mcfunction, quiz/macro/summon2.mcfunction (소비처 없음)
- commands/stop.mcfunction: marker_call 빌드 + macro 호출 제거.
  기존 월드에 누적된 legacy marker 청소를 위해 `kill @e[type=minecraft:marker,tag=mq]`
  한 줄 추가 (tag=mq 스코프라 외부 마커는 건드리지 않음).
- quiz/setanswer.mcfunction: 정답 marker 소환 블록 제거.
- init/config.mcfunction: marker 좌표 템플릿 (mq:main marker) 제거.

`answer.title="음악퀴즈"` 대기상태 sentinel 은 marker 외에 reader 가 없지만
다른 reset 의미를 가질 가능성을 고려해 보수적으로 유지.

## 노래 재생 채널을 player 로
init/config.mcfunction: mq:main audio.source 를 "weather" → "player".
play_sound / stop_sound 매크로 모두 동일 source 값을 읽으므로 한 곳 변경으로
모든 노래 재생/정지 채널이 player 채널로 이동. 음악/마스터/플레이어 슬라이더
중 "player" (음성) 슬라이더로 노래 음량 제어 가능.

타이머 비프 / UI 클릭음 등은 "노래 재생" 이 아니므로 weather 채널 그대로 유지.
2026-05-16 23:44:00 +09:00
Claude (owner)
b43d120e66 music_quiz: pack.mcmeta 를 min_format/max_format [101,1] 로 갱신 + normalize/step.mcfunction set string from 파싱 에러 수정
- pack.mcmeta: 25w31a 이후 도입된 min_format/max_format 배열 스펙으로 교체. min_format >= 82 이므로 pack_format 키는 생략.
- step.mcfunction L8, L45: `data modify ... set string from <source>` 는 잘못된 문법. 올바른 형태는 `set string <source> [start] [end]` (from 없음). 이로 인해 8행 부근 파싱이 멈추던 문제 해결.
2026-05-16 23:36:03 +09:00
11 changed files with 62 additions and 68 deletions

View File

@@ -1,6 +1,6 @@
{
"replace": false,
"values": [
"mq:answer"
{ "id": "mq:answer", "required": false }
]
}

View File

@@ -5,7 +5,7 @@ execute store result score n.len func.temp run data get storage mq:tmp norm.in
execute if score n.len func.temp matches 0 run return 0
# 머리글자 추출 → norm.c
data modify storage mq:tmp norm.c set string from storage mq:tmp norm.in 0 1
data modify storage mq:tmp norm.c set string storage mq:tmp norm.in 0 1
# 공백 제거 (스킵)
execute if data storage mq:tmp norm{c:" "} run data modify storage mq:tmp norm.c set value ""
@@ -42,6 +42,6 @@ execute if data storage mq:tmp norm{c:"Z"} run data modify storage mq:tmp norm.c
function mq:answer/normalize/append with storage mq:tmp norm
# 나머지로 진행
data modify storage mq:tmp norm.in set string from storage mq:tmp norm.in 1
data modify storage mq:tmp norm.in set string storage mq:tmp norm.in 1
function mq:answer/normalize/step

View File

@@ -60,12 +60,11 @@ bossbar set mq:process visible false
bossbar set mq:process style notched_10
bossbar set mq:process players @a
# 대기 상태 marker 1개만 소환 (answer.title="음악퀴즈" 가 sentinel)
# 대기 상태로 answer 초기화
data modify storage mq:main answer set value {title:"음악퀴즈", alias:[]}
data modify storage mq:tmp marker_call set from storage mq:main marker
data modify storage mq:tmp marker_call.name set value "음악퀴즈"
data modify storage mq:tmp marker_call.alias set value []
function mq:quiz/macro/summon with storage mq:tmp marker_call
# 이전 버전이 남긴 legacy marker 정리 (현재는 marker 사용 안 함)
kill @e[type=minecraft:marker,tag=mq]
function mq:quiz/stop_sound
function mq:images/clear

View File

@@ -1,25 +1,17 @@
# 버튼 정의. 각 항목 의미:
# n : 이름 (= 트리거/태그) x,y,z : 버튼 블록 좌표 f : facing
# n : 이름 (= 트리거/태그)
# x,y,z : 버튼 블록 좌표
# f : facing (south / north / east / west)
# c : 클릭 시 실행 명령 (init=0 직접, 그 외 trigger $(n) 투표)
# ox,oy,oz : interaction entity 소환 위치 오프셋 (블록 좌표 기준)
# w,h : interaction width / height (float)
#
# stone_button[face=wall] hitbox: 가로 6/16 (0.375), 세로 4/16 (0.25),
# 두께 2/16 (0.125), 벽 반대편으로만 튀어나옴. interaction 의 horizontal
# hitbox 는 width × width 정사각형 강제 → width 를 가로(0.375) 에 맞추고
# 위치 보정으로 "튀어나온 쪽 면 = visible face" 가 되게 함. 반대편은
# 벽 블록 속으로 들어가 invisible.
#
# facing 별 오프셋:
# south : ox=0.5 oy=0.375 oz=-0.0625
# north : ox=0.5 oy=0.375 oz=1.0625
# east : ox=-0.0625 oy=0.375 oz=0.5
# west : ox=1.0625 oy=0.375 oz=0.5
# interaction entity 의 위치/크기는 facing 만 보면 결정됨 — 매번 손으로
# ox/oy/oz/w/h 를 적지 않는다. 실제 오프셋 테이블은 repeat/buttons/btn
# 안에서 한 곳에만 정의되어 있다 (stone_button[face=wall] 면 정합용).
data modify storage mq:main button_defs set value []
data modify storage mq:main button_defs append value {n:"start", x:140, y:62, z:-225, f:"south", c:"function mq:commands/start with storage mq:main", ox:"0.5", oy:"0.375", oz:"-0.0625", w:"0.375", h:"0.25"}
data modify storage mq:main button_defs append value {n:"stop", x:142, y:62, z:-225, f:"south", c:"function mq:commands/stop with storage mq:main", ox:"0.5", oy:"0.375", oz:"-0.0625", w:"0.375", h:"0.25"}
data modify storage mq:main button_defs append value {n:"skip", x:144, y:62, z:-225, f:"south", c:"function mq:commands/skip", ox:"0.5", oy:"0.375", oz:"-0.0625", w:"0.375", h:"0.25"}
data modify storage mq:main button_defs append value {n:"hint", x:146, y:62, z:-225, f:"south", c:"function mq:commands/hint", ox:"0.5", oy:"0.375", oz:"-0.0625", w:"0.375", h:"0.25"}
data modify storage mq:main button_defs append value {n:"replay", x:148, y:62, z:-225, f:"south", c:"function mq:commands/replay", ox:"0.5", oy:"0.375", oz:"-0.0625", w:"0.375", h:"0.25"}
data modify storage mq:main button_defs append value {n:"test", x:144, y:62, z:-213, f:"north", c:"function mq:commands/test", ox:"0.5", oy:"0.375", oz:"1.0625", w:"0.375", h:"0.25"}
data modify storage mq:main button_defs append value {n:"start", x:364, y:146, z:-263, f:"east", c:"function mq:commands/start with storage mq:main"}
data modify storage mq:main button_defs append value {n:"stop", x:364, y:146, z:-265, f:"east", c:"function mq:commands/stop with storage mq:main"}
data modify storage mq:main button_defs append value {n:"skip", x:364, y:146, z:-267, f:"east", c:"function mq:commands/skip"}
data modify storage mq:main button_defs append value {n:"hint", x:364, y:146, z:-269, f:"east", c:"function mq:commands/hint"}
data modify storage mq:main button_defs append value {n:"replay", x:364, y:146, z:-271, f:"east", c:"function mq:commands/replay"}
data modify storage mq:main button_defs append value {n:"test", x:144, y:62, z:-213, f:"north", c:"function mq:commands/test"}

View File

@@ -6,10 +6,12 @@ data modify storage mq:main spawn set value {x: 144, y: 61, z: -219, r: 180, f:
# 음원 재생 — minecraft_launcher 리소스팩의 musicquiz:track_NN 사운드 이벤트
# namespace — 리소스팩 네임스페이스 (기본 "musicquiz")
# source — /playsound 채널. stopsound 와 동일해야 함 (기본 "weather")
# source — /playsound 채널. stopsound 와 동일해야 함. 노래는 "player" 채널로
# 재생 (음성/플레이어 채널 슬라이더로 음량 제어). 타이머/UI 비프는
# 별도로 weather 채널 사용.
# volume — 기본 음량. 곡별 override 는 init/songs.mcfunction 의 volume 필드 사용
# pitch — 1.0 = 원본 속도
data modify storage mq:main audio set value {namespace: "musicquiz", source: "weather", volume: 1.0, pitch: 1.0}
data modify storage mq:main audio set value {namespace: "musicquiz", source: "player", volume: 1.0, pitch: 1.0}
# 정답 페인팅 — 데이터팩의 mq:cover_NN painting_variant (텍스처는 리소스팩 musicquiz:cover_NN)
# namespace — painting_variant 네임스페이스 (기본 "mq")
@@ -17,7 +19,4 @@ data modify storage mq:main audio set value {namespace: "musicquiz", source: "we
# facing — 페인팅이 바라보는 방향: south=0 / west=1 / north=2 / east=3
data modify storage mq:main image set value {namespace: "mq", x: 144, y: 84, z: -261, facing: 0b}
# 정답 입력용 marker entity 소환 좌표
data modify storage mq:main marker set value {x: 144, y: 59, z: -219}
# 곡 개수 max_index 는 init/songs.mcfunction 의 길이로 자동 계산됨

View File

@@ -1,9 +0,0 @@
$execute unless data storage mq:main {answer:{title:"음악퀴즈"}} run summon minecraft:marker $(x) $(y) $(z) {Tags:["mq","default"],CustomName:"정답입력시작"}
$summon minecraft:marker $(x) $(y) $(z) {Tags:["mq","default"],CustomName:"$(name)"}
execute store result score length func.temp run data get storage mq:tmp marker_call.alias
execute if score length func.temp matches 1.. run data modify storage mq:tmp marker_call.name set from storage mq:tmp marker_call.alias[0]
execute if score length func.temp matches 1.. run data remove storage mq:tmp marker_call.alias[0]
execute if score length func.temp matches 1.. run function mq:quiz/macro/summon2 with storage mq:tmp marker_call
$execute unless data storage mq:main {answer:{title:"음악퀴즈"}} run summon minecraft:marker $(x) $(y) $(z) {Tags:["mq","default"],CustomName:"정답입력종료"}

View File

@@ -1,6 +0,0 @@
$summon minecraft:marker $(x) $(y) $(z) {Tags:["mq","default"],CustomName:"$(name)"}
execute store result score length func.temp run data get storage mq:tmp marker_call.alias
execute if score length func.temp matches 1.. run data modify storage mq:tmp marker_call.name set from storage mq:tmp marker_call.alias[0]
execute if score length func.temp matches 1.. run data remove storage mq:tmp marker_call.alias[0]
execute if score length func.temp matches 1.. run function mq:quiz/macro/summon2 with storage mq:tmp marker_call

View File

@@ -1,12 +1,6 @@
# songs[$(idx)] → answer 로 복사하고, 트랙/커버 id 부여
function mq:quiz/macro/setanswer with storage mq:tmp
# 정답 marker entity 소환 (좌표 + name/alias 합쳐서 macro 호출)
data modify storage mq:tmp marker_call set from storage mq:main marker
data modify storage mq:tmp marker_call.name set from storage mq:main answer.title
data modify storage mq:tmp marker_call.alias set from storage mq:main answer.alias
function mq:quiz/macro/summon with storage mq:tmp marker_call
scoreboard players set stop buttons -1
scoreboard players set skip buttons -1
scoreboard players set hint buttons -1

View File

@@ -1,7 +1,5 @@
# 버튼 1개에 대한 매 tick 처리.
# 매크로 인자: n, x, y, z, f, c, ox, oy, oz, w, h
# ox/oy/oz : interaction 소환 위치 오프셋 (블록 좌표 기준, facing 별)
# w / h : interaction width / height (float, 버튼 hitbox 정합용)
# 매크로 인자(mq:tmp.btn): n, x, y, z, f, c
# buttons 점수 상태:
# ..-2 : 비활성 (버튼 블록 제거, interaction 응답 차단)
# -1 : 초기화 단계 (버튼 블록 배치 + interaction entity 보장 후 0 으로)
@@ -11,6 +9,21 @@
# 에서 buttons 가 -1 로 재설정되어 다음 tick 에 ensure 로직이 실행됨.
# -1 단계에서 같은 태그 entity 를 모두 kill 후 정확히 1개 summon → dup
# 누적 없이 항상 "버튼당 1개, 올바른 좌표" 상태로 수렴 (idempotent).
#
# ---- facing → 소환 오프셋 (이 파일 한 곳에서만 정의) ----
# stone_button[face=wall] hitbox: 가로 6/16 (0.375), 세로 4/16 (0.25),
# 두께 2/16 (0.125). 벽 블록의 한 면에서만 튀어나오고 반대편은 안쪽으로
# 들어감. interaction 의 horizontal hitbox 는 width × width 정사각형
# 강제 → width 를 가로(0.375) 에 맞추고 위치를 튀어나온 쪽 면에 정렬.
#
# facing 의미: "플레이어가 그 방향을 보면서 누른다". 즉 button 머리는
# facing 의 반대쪽 면에 붙어 있다.
# south : 머리는 블록의 -z 쪽 면(north face) → 소환 z = -0.0625
# north : 머리는 블록의 +z 쪽 면(south face) → 소환 z = 1.0625
# east : 머리는 블록의 -x 쪽 면(west face) → 소환 x = -0.0625
# west : 머리는 블록의 +x 쪽 면(east face) → 소환 x = 1.0625
# interaction entity Y 는 hitbox 의 바닥(=발 위치) — 버튼 머리가 블록의
# 세로 중앙(y+0.5) 에 있고 높이 0.25 라 바닥은 y+0.375.
# ---- 비활성: 버튼 제거 + interaction 응답 차단 후 종료 ----
$execute if score $(n) buttons matches ..-2 run setblock $(x) $(y) $(z) minecraft:air
@@ -24,7 +37,10 @@ $execute if score $(n) buttons matches ..-2 run return 0
$execute unless score $(n) buttons matches -1.. run scoreboard players set $(n) buttons -1
$execute if score $(n) buttons matches -1 run setblock $(x) $(y) $(z) minecraft:stone_button[face=wall,facing=$(f),powered=false]
$execute if score $(n) buttons matches -1 run kill @e[type=minecraft:interaction,tag=mq,tag=$(n)]
$execute if score $(n) buttons matches -1 positioned $(x) $(y) $(z) positioned ~$(ox) ~$(oy) ~$(oz) run summon minecraft:interaction ~ ~ ~ {Tags:["mq","$(n)"],width:$(w)f,height:$(h)f,response:0b}
$execute if score $(n) buttons matches -1 if data storage mq:tmp btn{f:"south"} positioned $(x) $(y) $(z) run summon minecraft:interaction ~0.5 ~0.375 ~-0.0625 {Tags:["mq","$(n)"],width:0.375f,height:0.25f,response:0b}
$execute if score $(n) buttons matches -1 if data storage mq:tmp btn{f:"north"} positioned $(x) $(y) $(z) run summon minecraft:interaction ~0.5 ~0.375 ~1.0625 {Tags:["mq","$(n)"],width:0.375f,height:0.25f,response:0b}
$execute if score $(n) buttons matches -1 if data storage mq:tmp btn{f:"east"} positioned $(x) $(y) $(z) run summon minecraft:interaction ~-0.0625 ~0.375 ~0.5 {Tags:["mq","$(n)"],width:0.375f,height:0.25f,response:0b}
$execute if score $(n) buttons matches -1 if data storage mq:tmp btn{f:"west"} positioned $(x) $(y) $(z) run summon minecraft:interaction ~1.0625 ~0.375 ~0.5 {Tags:["mq","$(n)"],width:0.375f,height:0.25f,response:0b}
$execute if score $(n) buttons matches -1 run scoreboard players set $(n) buttons 0
# ---- 상시: interaction 클릭/타격 → playsound + 명령/투표 실행 ----

View File

@@ -1,6 +1,16 @@
function mq:repeat/buttons/btn with storage mq:main button_defs[0]
function mq:repeat/buttons/btn with storage mq:main button_defs[1]
function mq:repeat/buttons/btn with storage mq:main button_defs[2]
function mq:repeat/buttons/btn with storage mq:main button_defs[3]
function mq:repeat/buttons/btn with storage mq:main button_defs[4]
function mq:repeat/buttons/btn with storage mq:main button_defs[5]
# 각 button_defs 항목을 mq:tmp.btn 으로 복사 후 btn 호출.
# btn 안에서 facing 별 분기 (if data storage mq:tmp btn{f:"..."}) 를
# 사용하기 위해 현재 항목을 같은 storage 에 노출시킨다.
data modify storage mq:tmp btn set from storage mq:main button_defs[0]
function mq:repeat/buttons/btn with storage mq:tmp btn
data modify storage mq:tmp btn set from storage mq:main button_defs[1]
function mq:repeat/buttons/btn with storage mq:tmp btn
data modify storage mq:tmp btn set from storage mq:main button_defs[2]
function mq:repeat/buttons/btn with storage mq:tmp btn
data modify storage mq:tmp btn set from storage mq:main button_defs[3]
function mq:repeat/buttons/btn with storage mq:tmp btn
data modify storage mq:tmp btn set from storage mq:main button_defs[4]
function mq:repeat/buttons/btn with storage mq:tmp btn
data modify storage mq:tmp btn set from storage mq:main button_defs[5]
function mq:repeat/buttons/btn with storage mq:tmp btn

View File

@@ -1,8 +1,7 @@
{
"pack": {
"pack_format": 75,
"min_format": 75,
"max_format": 75,
"description": "음악퀴즈용 데이터팩입니다."
"description": "음악퀴즈용 데이터팩입니다.",
"min_format": [101, 1],
"max_format": [101, 1]
}
}