Compare commits
2 Commits
d8d5e75e7d
...
v1.0.10
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f6dc17092 | ||
|
|
c39a0516bc |
13
README.md
13
README.md
@@ -77,8 +77,17 @@
|
|||||||
|
|
||||||
- `start` / `stop` / `skip` / `hint` / `replay` / `test`
|
- `start` / `stop` / `skip` / `hint` / `replay` / `test`
|
||||||
|
|
||||||
버튼 본체는 `interaction` 엔티티 + `redstone_block`-`red_wool` 토글
|
버튼 본체는 보이는 `stone_button` 블록 + 그 좌표에 덮인 `interaction`
|
||||||
패턴으로 디바운스를 처리한다.
|
엔티티로 구성된다. 클릭 처리는 항상 `interaction` 경로로 흐르므로
|
||||||
|
`on target as @s` 로 누른 플레이어가 식별되고, 다수결(`trigger $(n)`)
|
||||||
|
투표가 성립한다.
|
||||||
|
|
||||||
|
`interaction` 은 데이터팩이 직접 소환·관리한다 — `buttons` 점수가
|
||||||
|
`-1` (초기화) 일 때마다 같은 태그의 기존 entity 를 정리하고 정확히
|
||||||
|
1개를 (재)소환한다. `/reload` 가 `commands/stop` 을 호출해 `buttons`
|
||||||
|
점수를 `-1` 로 재설정하므로, 리로드 시 자동 보장된다. `/kill @e` 로
|
||||||
|
지워졌어도 다음 `/reload` 한 번으로 복구. 월드 회로(커맨드블럭) 의존은
|
||||||
|
없다.
|
||||||
|
|
||||||
### 파일 구조
|
### 파일 구조
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,25 @@
|
|||||||
|
# 버튼 정의. 각 항목 의미:
|
||||||
|
# n : 이름 (= 트리거/태그) x,y,z : 버튼 블록 좌표 f : facing
|
||||||
|
# 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
|
||||||
|
|
||||||
data modify storage mq:main button_defs set value []
|
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"}
|
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"}
|
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"}
|
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"}
|
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"}
|
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"}
|
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"}
|
||||||
|
|||||||
@@ -1,28 +1,39 @@
|
|||||||
|
# 버튼 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 정합용)
|
||||||
|
# buttons 점수 상태:
|
||||||
|
# ..-2 : 비활성 (버튼 블록 제거, interaction 응답 차단)
|
||||||
|
# -1 : 초기화 단계 (버튼 블록 배치 + interaction entity 보장 후 0 으로)
|
||||||
|
# 0 : 정상 (interaction 클릭 대기)
|
||||||
|
#
|
||||||
|
# interaction entity 는 데이터팩이 직접 summon — /reload 시 commands/stop
|
||||||
|
# 에서 buttons 가 -1 로 재설정되어 다음 tick 에 ensure 로직이 실행됨.
|
||||||
|
# -1 단계에서 같은 태그 entity 를 모두 kill 후 정확히 1개 summon → dup
|
||||||
|
# 누적 없이 항상 "버튼당 1개, 올바른 좌표" 상태로 수렴 (idempotent).
|
||||||
|
|
||||||
|
# ---- 비활성: 버튼 제거 + 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),limit=1] 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 보장 ----
|
||||||
|
# 기존 mq/$(n) interaction 을 전부 제거 후 정확히 1개 소환.
|
||||||
|
# 옛 월드 cmd block 으로 누적 소환된 dup 이나 엉뚱한 좌표에 남은 잔존
|
||||||
|
# entity 까지 정리 → "정상 상태(버튼당 정확히 1개, 올바른 좌표)" 가 보장됨.
|
||||||
$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 positioned $(x) $(y) $(z) run setblock ~ ~-3 ~ minecraft:redstone_block
|
$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) run setblock ~ ~-3 ~ minecraft:red_wool
|
$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 run scoreboard players set $(n) buttons 0
|
$execute if score $(n) buttons matches -1 run scoreboard players set $(n) buttons 0
|
||||||
|
|
||||||
$execute if block $(x) $(y) $(z) minecraft:stone_button[face=wall,facing=$(f),powered=true] \
|
# ---- 상시: interaction 클릭/타격 → playsound + 명령/투표 실행 ----
|
||||||
if score $(n) buttons matches 0 \
|
# init main = 0 (퀴즈 시작 전 설정 단계) : 명령 직접 실행
|
||||||
run scoreboard players set $(n) buttons 1
|
# 그 외 : trigger 투표 경로
|
||||||
|
|
||||||
$execute if score $(n) buttons matches 1 unless entity @e[type=minecraft:interaction,tag=mq,tag=$(n),limit=1] positioned $(x) $(y) $(z) run $(c)
|
|
||||||
|
|
||||||
$execute if score $(n) buttons matches 1 \
|
|
||||||
run scoreboard players set $(n) buttons 2
|
|
||||||
|
|
||||||
$execute if block $(x) $(y) $(z) minecraft:stone_button[face=wall,facing=$(f),powered=false] \
|
|
||||||
if score $(n) buttons matches 1.. \
|
|
||||||
run scoreboard players set $(n) buttons 0
|
|
||||||
|
|
||||||
$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
|
$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
|
||||||
$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)
|
$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)
|
||||||
$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)
|
$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)
|
||||||
|
|
||||||
|
# ---- 처리 후 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
|
||||||
$execute as @e[type=minecraft:interaction,tag=mq,tag=$(n)] at @s run data remove entity @s interaction
|
$execute as @e[type=minecraft:interaction,tag=mq,tag=$(n)] at @s run data remove entity @s interaction
|
||||||
|
|||||||
Reference in New Issue
Block a user