music_quiz: 버튼 interaction hitbox 를 3 타일 분할로 정확히 정합
단일 interaction 의 horizontal hitbox 는 width × width 정사각형 강제라 "가로 0.375 × 두께 0.125" 직사각형이 불가능 → 두께 방향만 잡으면 가로 방향이 짧아지고, 가로를 잡으면 두께가 0.375 가 되어 벽 안쪽으로 0.25 묻혀 F3+B 디버그에서 wireframe 이 벽 안과 머리 앞쪽으로 튀어나옴. 해결: width=0.125 interaction 3개를 가로축으로 타일링. - 각 타일 깊이 0.125 = 버튼 머리 두께와 정확히 일치 - 3 × 0.125 = 0.375 = 버튼 머리 가로와 정확히 일치 (gap 없이 인접) - facing 별 가로축이 다름: south/north 는 x, east/west 는 z selector limit=1 제거 — 한 버튼에 interaction 이 3개라 limit=1 두면 MC 가 임의로 1개만 골라 잘못된 entity 만 검사할 수 있음. `on target` 은 클릭된 1개만 통과하므로 limit 없이도 단일 발화가 보장됨.
This commit is contained in:
@@ -7,48 +7,69 @@
|
|||||||
#
|
#
|
||||||
# interaction entity 는 데이터팩이 직접 summon — /reload 시 commands/stop
|
# interaction entity 는 데이터팩이 직접 summon — /reload 시 commands/stop
|
||||||
# 에서 buttons 가 -1 로 재설정되어 다음 tick 에 ensure 로직이 실행됨.
|
# 에서 buttons 가 -1 로 재설정되어 다음 tick 에 ensure 로직이 실행됨.
|
||||||
# -1 단계에서 같은 태그 entity 를 모두 kill 후 정확히 1개 summon → dup
|
# -1 단계에서 같은 태그 entity 를 모두 kill 후 정확한 개수만 summon → dup
|
||||||
# 누적 없이 항상 "버튼당 1개, 올바른 좌표" 상태로 수렴 (idempotent).
|
# 누적 없이 항상 "버튼당 정확히 3개, 올바른 좌표" 상태로 수렴 (idempotent).
|
||||||
#
|
#
|
||||||
# ---- facing → 소환 오프셋 (이 파일 한 곳에서만 정의) ----
|
# ---- facing → 소환 오프셋 (이 파일 한 곳에서만 정의) ----
|
||||||
# stone_button[face=wall] hitbox: 가로 6/16 (0.375), 세로 4/16 (0.25),
|
# stone_button[face=wall] 머리 hitbox: 가로 6/16 (0.375), 세로 4/16 (0.25),
|
||||||
# 두께 2/16 (0.125). 벽 블록의 한 면에서만 튀어나오고 반대편은 안쪽으로
|
# 두께 2/16 (0.125). interaction entity 의 horizontal hitbox 는 width × width
|
||||||
# 들어감. interaction 의 horizontal hitbox 는 width × width 정사각형
|
# 정사각형 강제라 단일 entity 로는 "가로 0.375 × 두께 0.125" 직사각형이 불가.
|
||||||
# 강제 → width 를 가로(0.375) 에 맞추고 위치를 튀어나온 쪽 면에 정렬.
|
# → 두께(0.125) 만큼만 가지는 width=0.125 interaction 을 가로 방향 3개 타일
|
||||||
|
# 링하여 버튼 머리에 정확히 정합 (가로 3 × 0.125 = 0.375, 두께 그대로 0.125).
|
||||||
#
|
#
|
||||||
# facing 의미: "플레이어가 그 방향을 보면서 누른다". 즉 button 머리는
|
# facing 의미: "플레이어가 그 방향을 보면서 누른다" — 버튼 머리는 facing 의
|
||||||
# facing 의 반대쪽 면에 붙어 있다.
|
# 반대쪽 면에 붙어 있다. 머리 위치 (블록 상대 좌표):
|
||||||
# south : 머리는 블록의 -z 쪽 면(north face) → 소환 z = -0.0625
|
# south : -z 면 (z=0) → 깊이 z = -0.0625, 가로 x = 0.375 / 0.5 / 0.625
|
||||||
# north : 머리는 블록의 +z 쪽 면(south face) → 소환 z = 1.0625
|
# north : +z 면 (z=1) → 깊이 z = 1.0625, 가로 x = 0.375 / 0.5 / 0.625
|
||||||
# east : 머리는 블록의 -x 쪽 면(west face) → 소환 x = -0.0625
|
# east : -x 면 (x=0) → 깊이 x = -0.0625, 가로 z = 0.375 / 0.5 / 0.625
|
||||||
# west : 머리는 블록의 +x 쪽 면(east face) → 소환 x = 1.0625
|
# west : +x 면 (x=1) → 깊이 x = 1.0625, 가로 z = 0.375 / 0.5 / 0.625
|
||||||
# interaction entity Y 는 hitbox 의 바닥(=발 위치) — 버튼 머리가 블록의
|
# 세로(y): 머리는 블록의 세로 중앙 (y+0.375 ~ y+0.625, 높이 0.25). interaction
|
||||||
# 세로 중앙(y+0.5) 에 있고 높이 0.25 라 바닥은 y+0.375.
|
# Y 는 hitbox 바닥(=발 위치) → 소환 y = y+0.375, height=0.25.
|
||||||
|
|
||||||
# ---- 비활성: 버튼 제거 + interaction 응답 차단 후 종료 ----
|
# ---- 비활성: 버튼 제거 + interaction 응답 차단 후 종료 ----
|
||||||
$execute if score $(n) buttons matches ..-2 run setblock $(x) $(y) $(z) minecraft:air
|
$execute if score $(n) buttons matches ..-2 run setblock $(x) $(y) $(z) minecraft:air
|
||||||
$execute if score $(n) buttons matches ..-2 run data modify entity @e[type=minecraft:interaction,tag=mq,tag=$(n),limit=1] response set value 0b
|
$execute if score $(n) buttons matches ..-2 run data modify entity @e[type=minecraft:interaction,tag=mq,tag=$(n)] response set value 0b
|
||||||
$execute if score $(n) buttons matches ..-2 run return 0
|
$execute if score $(n) buttons matches ..-2 run return 0
|
||||||
|
|
||||||
# ---- 초기화: 버튼 블록 배치 + interaction entity 보장 ----
|
# ---- 초기화: 버튼 블록 배치 + interaction entity 보장 ----
|
||||||
# 기존 mq/$(n) interaction 을 전부 제거 후 정확히 1개 소환.
|
# 기존 mq/$(n) interaction 을 전부 제거 후 정확히 3개 소환.
|
||||||
# 옛 월드 cmd block 으로 누적 소환된 dup 이나 엉뚱한 좌표에 남은 잔존
|
# 옛 월드 cmd block 으로 누적 소환된 dup 이나 엉뚱한 좌표에 남은 잔존
|
||||||
# entity 까지 정리 → "정상 상태(버튼당 정확히 1개, 올바른 좌표)" 가 보장됨.
|
# entity 까지 정리 → "정상 상태(버튼당 정확히 3개, 올바른 좌표)" 가 보장됨.
|
||||||
$execute unless score $(n) buttons matches -1.. run scoreboard players set $(n) buttons -1
|
$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 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 run kill @e[type=minecraft:interaction,tag=mq,tag=$(n)]
|
||||||
$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}
|
# south: 깊이축=z(-0.0625), 가로축=x, 3 타일
|
||||||
$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:"south"} positioned $(x) $(y) $(z) run summon minecraft:interaction ~0.375 ~0.375 ~-0.0625 {Tags:["mq","$(n)"],width:0.125f,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 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.125f,height:0.25f,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.625 ~0.375 ~-0.0625 {Tags:["mq","$(n)"],width:0.125f,height:0.25f,response:0b}
|
||||||
|
|
||||||
|
# north: 깊이축=z(+1.0625), 가로축=x, 3 타일
|
||||||
|
$execute if score $(n) buttons matches -1 if data storage mq:tmp btn{f:"north"} positioned $(x) $(y) $(z) run summon minecraft:interaction ~0.375 ~0.375 ~1.0625 {Tags:["mq","$(n)"],width:0.125f,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.125f,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.625 ~0.375 ~1.0625 {Tags:["mq","$(n)"],width:0.125f,height:0.25f,response:0b}
|
||||||
|
|
||||||
|
# east: 깊이축=x(-0.0625), 가로축=z, 3 타일
|
||||||
|
$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.375 {Tags:["mq","$(n)"],width:0.125f,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.125f,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.625 {Tags:["mq","$(n)"],width:0.125f,height:0.25f,response:0b}
|
||||||
|
|
||||||
|
# west: 깊이축=x(+1.0625), 가로축=z, 3 타일
|
||||||
|
$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.375 {Tags:["mq","$(n)"],width:0.125f,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.125f,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.625 {Tags:["mq","$(n)"],width:0.125f,height:0.25f,response:0b}
|
||||||
|
|
||||||
$execute if score $(n) buttons matches -1 run scoreboard players set $(n) buttons 0
|
$execute if score $(n) buttons matches -1 run scoreboard players set $(n) buttons 0
|
||||||
|
|
||||||
# ---- 상시: interaction 클릭/타격 → playsound + 명령/투표 실행 ----
|
# ---- 상시: interaction 클릭/타격 → playsound + 명령/투표 실행 ----
|
||||||
# init main = 0 (퀴즈 시작 전 설정 단계) : 명령 직접 실행
|
# init main = 0 (퀴즈 시작 전 설정 단계) : 명령 직접 실행
|
||||||
# 그 외 : trigger 투표 경로
|
# 그 외 : trigger 투표 경로
|
||||||
$execute as @e[type=minecraft:interaction,tag=mq,tag=$(n),limit=1] on target as @s positioned $(x) $(y) $(z) run playsound minecraft:block.stone_button.click_on block @s ~ ~ ~ 1 1
|
# 같은 태그를 가진 interaction 이 3개지만 `on target` 은 클릭된 1개만 통과
|
||||||
$execute as @e[type=minecraft:interaction,tag=mq,tag=$(n),limit=1] on target as @s positioned $(x) $(y) $(z) if score init main matches 0 run $(c)
|
# (나머지는 target 부재로 체인 중단). 따라서 selector 에 limit=1 두지 않음
|
||||||
$execute as @e[type=minecraft:interaction,tag=mq,tag=$(n),limit=1] on target as @s positioned $(x) $(y) $(z) unless score init main matches 0 run trigger $(n)
|
# — limit=1 을 두면 MC 가 임의로 1개를 골라 잘못된 entity 만 검사할 수 있음.
|
||||||
|
$execute as @e[type=minecraft:interaction,tag=mq,tag=$(n)] on target as @s positioned $(x) $(y) $(z) run playsound minecraft:block.stone_button.click_on block @s ~ ~ ~ 1 1
|
||||||
|
$execute as @e[type=minecraft:interaction,tag=mq,tag=$(n)] on target as @s positioned $(x) $(y) $(z) if score init main matches 0 run $(c)
|
||||||
|
$execute as @e[type=minecraft:interaction,tag=mq,tag=$(n)] on target as @s positioned $(x) $(y) $(z) unless score init main matches 0 run trigger $(n)
|
||||||
|
|
||||||
# ---- 처리 후 attack/interaction NBT 클리어 (다음 tick 중복 발화 방지) ----
|
# ---- 처리 후 attack/interaction NBT 클리어 (다음 tick 중복 발화 방지) ----
|
||||||
$execute as @e[type=minecraft:interaction,tag=mq,tag=$(n)] at @s run data remove entity @s attack
|
$execute as @e[type=minecraft:interaction,tag=mq,tag=$(n)] at @s run data remove entity @s attack
|
||||||
|
|||||||
Reference in New Issue
Block a user