Compare commits
15 Commits
d8d5e75e7d
...
v1.0.22
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
736ec2a3d1 | ||
|
|
da075b60b8 | ||
|
|
b803a422a3 | ||
|
|
5d610cf01a | ||
|
|
2f5038e4f0 | ||
|
|
75daf5bab9 | ||
|
|
ba7089e7b2 | ||
|
|
55ab7fc04b | ||
|
|
28f1012294 | ||
|
|
4349fddc25 | ||
|
|
a8d09ece02 | ||
|
|
b43d120e66 | ||
|
|
f0a2e4fb6b | ||
|
|
2f6dc17092 | ||
|
|
c39a0516bc |
13
README.md
13
README.md
@@ -77,8 +77,17 @@
|
||||
|
||||
- `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` 한 번으로 복구. 월드 회로(커맨드블럭) 의존은
|
||||
없다.
|
||||
|
||||
### 파일 구조
|
||||
|
||||
|
||||
184
docs/mc_video_player_mod_integration.md
Normal file
184
docs/mc_video_player_mod_integration.md
Normal file
@@ -0,0 +1,184 @@
|
||||
# mc_video_player_mod — 음악퀴즈 데이터팩 연동 사양
|
||||
|
||||
음악퀴즈 데이터팩(`music_quiz`)이 영상재생 모드의 **서버 측 + 클라이언트 측**
|
||||
설치 여부를 둘 다 검증할 수 있도록, 모드의 서버 컴포넌트가 두 가지 점수를
|
||||
갱신한다.
|
||||
|
||||
| holder | 의미 | 갱신 주체 / 시점 |
|
||||
|--------|------|------------------|
|
||||
| `#server mq_video_mod` | 서버에 모드 jar 존재 | 서버 컴포넌트가 매 server tick 마다 1 |
|
||||
| `<player> mq_video_mod` | 해당 플레이어 클라에 모드 존재 | 서버 컴포넌트가 client→server payload 수신 시 1 |
|
||||
|
||||
둘 다 같은 objective `mq_video_mod` (dummy) 를 쓰고 holder 이름으로 의미를
|
||||
구분한다. 데이터팩 `mq:commands/start` 가드는 두 단계로 검사:
|
||||
서버 부재 → 전원 안내 후 차단 / 일부 플레이어 클라 부재 → 본인 안내 + 차단.
|
||||
|
||||
> 참고: 자매 모드 `mc_chat_answer_mod` 는 채팅 가로채기가 본질적으로 서버
|
||||
> 측 동작이라 `#server mq_chat_mod` 한 가지만 쓴다 (per-player handshake 무의미).
|
||||
> 본 모드는 클라이언트가 직접 영상 렌더링하므로 per-player handshake 도 필요함.
|
||||
|
||||
## 데이터팩 측이 이미 제공하는 것
|
||||
|
||||
`music_quiz/data/mq/function/load.mcfunction`
|
||||
|
||||
```
|
||||
scoreboard objectives add mq_video_mod dummy
|
||||
```
|
||||
|
||||
`music_quiz/data/mq/function/players/login.mcfunction` 에서 로그인 시 0
|
||||
으로 초기화 (handshake 없는 플레이어는 0 유지).
|
||||
|
||||
```
|
||||
scoreboard players set @s mq_video_mod 0
|
||||
```
|
||||
|
||||
`mq:commands/start.mcfunction` 가드:
|
||||
|
||||
```mcfunction
|
||||
# 서버 부재 우선 차단
|
||||
execute unless score #server mq_video_mod matches 1 run return run function mq:tellraw {"text":"영상재생 모드가 서버에 미설치 — 서버 관리자에게 문의해주세요.","color":"red","msg":""}
|
||||
# unset 매치 안 되므로 materialize
|
||||
scoreboard players add @a mq_video_mod 0
|
||||
# 본인 안내 (tellraw @s 직접 — mq:tellraw 는 @a broadcast 라 부적합)
|
||||
execute as @a[scores={mq_video_mod=..0}] run tellraw @s ["",{"text":"영상재생 모드 미설치 — 모드 적용 후 다시 입장해주세요.","color":"red"}]
|
||||
# 한 명이라도 누락이면 시작 차단
|
||||
execute if entity @a[scores={mq_video_mod=..0}] run return run function mq:tellraw {"text":"필수 모드 미설치 플레이어가 있어 시작할 수 없습니다.","color":"red","msg":""}
|
||||
```
|
||||
|
||||
`load.mcfunction` 에서 `#server mq_video_mod = 0` 으로 미리 깔아둠 → 서버
|
||||
컴포넌트가 한 tick 도 안 돌면 0 유지 → 가드 차단.
|
||||
|
||||
즉, **서버 컴포넌트가 (a) 매 tick `#server mq_video_mod=1` 갱신,
|
||||
(b) client payload 수신 시 송신 플레이어 점수=1 갱신**, 이 두 가지만 하면
|
||||
나머지는 데이터팩이 알아서 한다.
|
||||
|
||||
## 모드가 구현해야 하는 동작
|
||||
|
||||
### 권장: 커스텀 payload handshake (Fabric Networking API / NeoForge Network)
|
||||
|
||||
가장 깔끔하고 위변조 방어도 자연스러움. `/trigger` 방식보다 추천.
|
||||
|
||||
#### Payload 정의 (공용)
|
||||
|
||||
식별자: `mq_video_mod:hello` (또는 자체 modid 네임스페이스).
|
||||
페이로드 본문은 비어도 되고, 버전 정수 한 개 정도면 충분.
|
||||
|
||||
```java
|
||||
public record HelloPayload(int version) implements CustomPacketPayload {
|
||||
public static final CustomPacketPayload.Type<HelloPayload> TYPE =
|
||||
new CustomPacketPayload.Type<>(ResourceLocation.fromNamespaceAndPath("mq_video_mod", "hello"));
|
||||
public static final StreamCodec<FriendlyByteBuf, HelloPayload> CODEC =
|
||||
StreamCodec.composite(ByteBufCodecs.VAR_INT, HelloPayload::version, HelloPayload::new);
|
||||
@Override public Type<?> type() { return TYPE; }
|
||||
}
|
||||
```
|
||||
|
||||
#### 클라이언트 측
|
||||
|
||||
- payload 를 `PayloadTypeRegistry.playC2S()` 에 등록 (Fabric) /
|
||||
`IPayloadRegistrar` 에 등록 (NeoForge).
|
||||
- `ClientPlayConnectionEvents.JOIN` (Fabric) 또는 동등 NeoForge 이벤트에서
|
||||
서버로 1회 전송 + **이후 5초마다 주기적으로 재전송 (필수)**. 데이터팩
|
||||
`mq:players/login` 이 spawn dialog 통과 시점에 점수를 0 으로 리셋하기
|
||||
때문에, JOIN 시점의 1 회 전송만으로는 login 의 리셋이 뒤에 들어와 가드
|
||||
통과가 실패한다. 주기 재전송으로 login 이후 늦어도 다음 5 초 안에 다시
|
||||
1 로 복구되어야 정상 동작.
|
||||
|
||||
```java
|
||||
// JOIN 직후 1 회
|
||||
ClientPlayNetworking.send(new HelloPayload(1));
|
||||
|
||||
// + 주기 재전송 (필수). ClientTickEvents.END_CLIENT_TICK 등에서 카운터.
|
||||
// 100 tick = 5 초 (client 20 tps). 너무 빈번해도 부담 없으니 1~5 초
|
||||
// 사이로 자유롭게.
|
||||
```
|
||||
|
||||
#### 서버 측 (이 모드의 서버 컴포넌트)
|
||||
|
||||
서버 컴포넌트는 **두 가지** 를 한다.
|
||||
|
||||
(1) 매 server tick 마다 `#server mq_video_mod = 1` 갱신 (server presence).
|
||||
점수 값이 변하지 않으면 packet 미전송이므로 매 tick 호출해도 비용 없음.
|
||||
|
||||
```java
|
||||
public static void onServerTick(MinecraftServer server) {
|
||||
Scoreboard sb = server.getScoreboard();
|
||||
Objective obj = sb.getObjective("mq_video_mod");
|
||||
if (obj == null) return; // 데이터팩 미적용 or 아직 load 전
|
||||
sb.getOrCreatePlayerScore(ScoreHolder.forNameOnly("#server"), obj).set(1);
|
||||
}
|
||||
```
|
||||
|
||||
Fabric: `ServerTickEvents.END_SERVER_TICK.register(...)`.
|
||||
NeoForge: `NeoForge.EVENT_BUS.addListener(ServerTickEvent.Post::...)`.
|
||||
|
||||
(2) payload 등록 + 수신 시 송신 플레이어 점수 갱신 (client presence).
|
||||
같은 payload 를 `PayloadTypeRegistry.playC2S()` 에 등록한 뒤:
|
||||
|
||||
```java
|
||||
ServerPlayNetworking.registerGlobalReceiver(HelloPayload.TYPE, (payload, context) -> {
|
||||
ServerPlayer player = context.player();
|
||||
MinecraftServer server = player.getServer();
|
||||
if (server == null) return;
|
||||
Scoreboard sb = server.getScoreboard();
|
||||
Objective obj = sb.getObjective("mq_video_mod");
|
||||
if (obj == null) return; // 데이터팩 미적용 or 아직 load 전
|
||||
// ServerPlayer 자체가 ScoreHolder — @s selector 와 정확히 매칭
|
||||
sb.getOrCreatePlayerScore(player, obj).set(1);
|
||||
});
|
||||
```
|
||||
|
||||
> 참고 구현: `mc_chat_answer_mod` 의 `ChatAnswerCore::markModPresence` 가
|
||||
> 똑같이 `#server` holder 패턴을 쓴다 (단 그 쪽은 client payload 부분 없음).
|
||||
|
||||
#### 타이밍 / 안전망
|
||||
|
||||
- 데이터팩 `mq:players/login` 이 spawn dialog 통과 시점에 점수를 0 으로
|
||||
리셋하므로, **클라 payload 주기 재전송은 필수**. login 이후 다음 재전송
|
||||
까지의 짧은 공백에 호스트가 start 를 누르면 가드가 차단되니, 재전송
|
||||
간격은 5 초 이하 권장.
|
||||
- 서버가 set 한 점수는 다음 join 시 login 에서 다시 0 으로 리셋됨 → 모드를
|
||||
빼고 재접속한 플레이어가 stale 1 을 가질 일 없음.
|
||||
- payload 송신 → 서버 처리는 ms 단위 → 주기 재전송이 살아 있는 한 start
|
||||
타이밍 race 없음.
|
||||
|
||||
### 대안: `/trigger` 방식 (별도 서버 컴포넌트 불필요)
|
||||
|
||||
데이터팩이 trigger objective 를 만들고 클라 모드가 `/trigger mq_video_mod set 1`
|
||||
을 채팅 명령으로 전송하는 방식. 단점:
|
||||
- 데이터팩에 `scoreboard objectives add mq_video_mod trigger` 와 매 join 시
|
||||
`scoreboard players enable @a mq_video_mod` 가 추가로 필요 (현재는 dummy).
|
||||
- 클라 모드가 commands 권한으로 채팅 명령을 보내야 함.
|
||||
- 명령어 packet 이 chat history 에 흔적이 남을 수 있음.
|
||||
|
||||
커스텀 payload 가 추천이지만, 서버 컴포넌트를 추가하기 싫다면 이 경로도
|
||||
가능. 그 경우 데이터팩 측 변경이 필요하니 별도 요청해주세요.
|
||||
|
||||
## 동작 흐름 (권장 경로)
|
||||
|
||||
1. 서버 시작 → 데이터팩 load → `mq_video_mod` objective 생성.
|
||||
2. 클라(모드 있음) 접속 → `ClientPlayConnectionEvents.JOIN` → payload 1 회 전송.
|
||||
3. 서버 모드 수신 → 해당 플레이어 `mq_video_mod = 1`.
|
||||
4. 플레이어 spawn dialog 통과 → `mq:players/login` 이 점수를 0 으로 리셋.
|
||||
5. **클라 모드가 주기 재전송 (5 초 이하 권장, 필수)** → 늦어도 다음 주기에
|
||||
서버 모드가 다시 `mq_video_mod = 1` 로 갱신.
|
||||
6. 호스트 start → 가드가 `@a[scores={mq_video_mod=..0}]` 검사 → 클라 모드
|
||||
미설치 플레이어 있으면 시작 차단.
|
||||
|
||||
## 테스트
|
||||
|
||||
1. **서버 미설치**: 서버에 모드 jar 가 없는 상태에서 데이터팩만 적용 →
|
||||
호스트 start → "영상재생 모드가 서버에 미설치 — 서버 관리자에게..." 한
|
||||
줄 출력 후 차단. (`#server mq_video_mod` 가 갱신되지 않음.)
|
||||
2. **서버 설치 + 일부 클라 미설치**: 모드를 클라에 설치한 플레이어와 안
|
||||
한 플레이어 혼재 → 호스트 start → 클라 미설치 본인에게 "영상재생 모드
|
||||
미설치" + 전원에게 "필수 모드 미설치 플레이어가 있어..." 후 차단.
|
||||
3. **서버 + 모든 클라 설치**: 모두 정상 → start 정상 진행.
|
||||
4. `/scoreboard players list #server` 로 server presence 점수 확인,
|
||||
`/scoreboard players list <player>` 로 client presence 점수 확인.
|
||||
|
||||
## 참고: 자매 모드 `mc_chat_answer_mod` 의 다른 접근
|
||||
|
||||
`mc_chat_answer_mod/common/.../ChatAnswerCore.java::markModPresence` 참고.
|
||||
서버 전용 모드라 fake player `#server` 한 곳에만 set 한다. 클라이언트
|
||||
렌더링 모드인 본 모드는 이 패턴이 아닌 per-player handshake 가 정답.
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"mq:answer"
|
||||
{ "id": "mq:answer", "required": false }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,5 +1,32 @@
|
||||
execute if score init main matches 10 run return run function mq:tellraw {"text":"퀴즈가 완전히 종료된후 시작해주세요.","color":"red","msg":""}
|
||||
|
||||
# ---- 외부 모드 설치 검증 ----
|
||||
# mq_video_mod (mc_video_player_mod) 만 게이트. 영상 렌더링은 클라 모드가
|
||||
# 필수라 없으면 게임이 의미가 없음. same objective 안에 holder 두 종류:
|
||||
# - `#server mq_video_mod` : 서버 컴포넌트가 매 tick 1 로 갱신 (server
|
||||
# presence). 없으면 0 → 서버에 모드 미설치.
|
||||
# - `<player> mq_video_mod` : 클라 join 시 payload 가 서버로 오면 서버
|
||||
# 컴포넌트가 해당 플레이어 점수를 1 로 set (client presence). 클라
|
||||
# 미설치면 0 유지.
|
||||
#
|
||||
# mq_chat_mod (mc_chat_answer_mod) 는 게이트하지 않음 — 채팅 모드는 입력을
|
||||
# "편하게" 만들어주는 옵션일 뿐이고, 모드 없는 환경에서도 `/trigger input`
|
||||
# dialog 경로로 정답 제출이 가능. 과거에 게이트해 두면 모드 presence pulse
|
||||
# 가 호스트 환경 (banner/mohist 같은 fabric-bukkit 하이브리드) 에서 안
|
||||
# 들어오거나, 사용자 모드 버전이 presence tick 이전 (v1.3.4 이하) 일 때
|
||||
# false negative 로 시작이 막혔음.
|
||||
#
|
||||
# 1) 서버 측 영상 모드 부재 — 전원 차단, 단일 안내.
|
||||
execute unless score #server mq_video_mod matches 1 run return run function mq:tellraw {"text":"영상재생 모드가 서버에 미설치 — 서버 관리자에게 문의해주세요.","color":"red","msg":""}
|
||||
|
||||
# 2) 클라이언트 측 모드 (mc_video_player_mod) 부재 — 본인 누락 안내 + 차단.
|
||||
# selector `scores={X=..0}` 는 점수 미존재를 매치하지 않으므로 직전에
|
||||
# `add @a ... 0` 으로 materialize. 개인 안내는 tellraw @s 직접 (mq:tellraw
|
||||
# 는 내부 @a broadcast 라 부적합).
|
||||
scoreboard players add @a mq_video_mod 0
|
||||
execute as @a[scores={mq_video_mod=..0}] run tellraw @s ["",{"text":"영상재생 모드 미설치 — 모드 적용 후 다시 입장해주세요.","color":"red"}]
|
||||
execute if entity @a[scores={mq_video_mod=..0}] run return run function mq:tellraw {"text":"필수 모드 미설치 플레이어가 있어 시작할 수 없습니다.","color":"red","msg":""}
|
||||
|
||||
setblock ~ ~ ~ minecraft:air
|
||||
|
||||
function mq:quiz/stop_sound
|
||||
|
||||
@@ -60,12 +60,17 @@ 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]
|
||||
|
||||
# 이전 버전이 남긴 잔존 text_display 정리.
|
||||
# 현재 버튼은 -1 init 단계에서 같은 tag interaction 만 kill 하므로 (n 태그
|
||||
# 가 일치할 때만), 옛 버튼 정의에 있던 이름의 text_display 가 남으면 안
|
||||
# 지워짐. 여기서 mq 태그 전체를 한 번에 정리해 stale 제거.
|
||||
kill @e[type=minecraft:text_display,tag=mq]
|
||||
|
||||
function mq:quiz/stop_sound
|
||||
function mq:images/clear
|
||||
|
||||
@@ -1,7 +1,23 @@
|
||||
# 버튼 정의. 각 항목 의미:
|
||||
# n : 이름 (= 트리거/태그)
|
||||
# x,y,z : 버튼 블록 좌표
|
||||
# f : facing (south / north / east / west)
|
||||
# c : 클릭 시 실행 명령 (init=0 직접, 그 외 trigger $(n) 투표)
|
||||
#
|
||||
# optional 필드 (버튼 아래 y-1 위치에 같은 벽면 라벨 부착):
|
||||
# label : 표시할 텍스트. 생략하면 라벨 없음.
|
||||
# label_color : 텍스트 색 (예 "black", "red", "#FFAA00"). 기본 "black".
|
||||
# label_font : 텍스트 폰트 (예 "minecraft:default"). 기본 "minecraft:default".
|
||||
# label_scale : 텍스트 크기 (Vector3f 한 축, 3축 동일). 기본 "1.0".
|
||||
#
|
||||
# interaction entity 의 위치/크기와 text_display 의 위치/회전은 facing 만
|
||||
# 보면 결정됨 — 매번 손으로 ox/oy/oz 를 적지 않는다. 실제 오프셋 테이블은
|
||||
# repeat/buttons/btn 안에서 한 곳에만 정의되어 있다.
|
||||
|
||||
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:"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:"skip", x:144, y:62, z:-225, f:"south", c:"function mq:commands/skip"}
|
||||
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:"replay", x:148, y:62, z:-225, f:"south", 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"}
|
||||
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", label:"게임시작"}
|
||||
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", label:"정지"}
|
||||
data modify storage mq:main button_defs append value {n:"skip", x:364, y:146, z:-267, f:"east", c:"function mq:commands/skip", label:"넘기기"}
|
||||
data modify storage mq:main button_defs append value {n:"hint", x:364, y:146, z:-269, f:"east", c:"function mq:commands/hint", label:"힌트"}
|
||||
data modify storage mq:main button_defs append value {n:"replay", x:364, y:146, z:-271, f:"east", c:"function mq:commands/replay", label:"다시듣기"}
|
||||
data modify storage mq:main button_defs append value {n:"test", x:144, y:62, z:-213, f:"north", c:"function mq:commands/test", label:"소리 테스트"}
|
||||
|
||||
@@ -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 의 길이로 자동 계산됨
|
||||
|
||||
@@ -21,6 +21,26 @@ scoreboard objectives add buttons dummy
|
||||
scoreboard objectives add answer dummy
|
||||
scoreboard objectives add leave_game custom:leave_game
|
||||
|
||||
# 외부 모드 존재 확인용 점수.
|
||||
# mq_video_mod : 클라이언트 모드(mc_video_player_mod). 클라 join 시 서버로
|
||||
# handshake payload 전송 → 서버 측 모드가 해당 플레이어 점수를 1 로 set.
|
||||
# 클라에 모드가 없으면 0 유지. (login.mcfunction 에서 플레이어별 0 초기화.)
|
||||
# same objective 안에 holder 두 종류 — `#server` 는 서버 컴포넌트 존재
|
||||
# (서버 측 모드가 매 tick 1 로 갱신), `<player>` 는 클라 측 존재 (payload
|
||||
# 수신 시 1 로 갱신).
|
||||
#
|
||||
# mq_chat_mod (mc_chat_answer_mod) 는 더 이상 게이트하지 않음 — 모드 없는
|
||||
# 환경에서도 `/trigger input` dialog 경로로 정답 제출 가능. presence pulse
|
||||
# 가 호스트 환경에 따라 안 들어오거나 사용자 모드 버전이 옛날일 때 false
|
||||
# negative 로 시작이 막히던 문제 회피. (모드 측은 여전히 매 tick objective
|
||||
# 존재시 1 로 set 시도하지만, objective 가 없으면 silent skip 하므로 무해.)
|
||||
scoreboard objectives remove mq_chat_mod
|
||||
scoreboard objectives remove mq_video_mod
|
||||
scoreboard objectives add mq_video_mod dummy
|
||||
# /reload 후 모드가 한 tick 도 돌기 전에 start 가 호출될 수 있으니
|
||||
# #server 점수도 0 으로 materialize. 모드가 살아 있으면 다음 tick 에 1 로 갱신.
|
||||
scoreboard players set #server mq_video_mod 0
|
||||
|
||||
scoreboard players set two func.temp 2
|
||||
|
||||
bossbar add mq:process [{"text":"진행도: ","color": "yellow","bold": true},{"text":"0","color": "yellow","bold": true},{"text":"/","color": "yellow","bold": true},{"text":"0","color": "yellow","bold": true}]
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
tag @s add player
|
||||
scoreboard players reset @s leave_game
|
||||
|
||||
# 외부 모드 검증 점수 초기화 (per-player 검증 대상만).
|
||||
# mq_video_mod : 클라이언트 모드(mc_video_player_mod) 가 join 시 handshake
|
||||
# payload 를 서버로 보내면 서버 모드가 해당 플레이어 점수를 1 로 set 한다.
|
||||
# 여기서 0 으로 미리 깔아 두면 handshake 가 없는 플레이어는 0 유지 →
|
||||
# start 가드 차단. handshake 가 오면 곧바로 1 로 갱신됨.
|
||||
# mq_chat_mod 는 서버 전용 모드라 fake player(#server) 로 검증 — per-player
|
||||
# 초기화 불필요.
|
||||
scoreboard players set @s mq_video_mod 0
|
||||
|
||||
title @s times 10t 80t 10t
|
||||
title @s subtitle ""
|
||||
title @s title ""
|
||||
|
||||
@@ -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:"정답입력종료"}
|
||||
@@ -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
|
||||
@@ -1,26 +1,19 @@
|
||||
# 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
|
||||
scoreboard players set replay buttons -1
|
||||
|
||||
# 이전 문제의 미처리 정답 입력 정리 + 새 문제의 input trigger 활성화
|
||||
# input trigger 는 유지 (mod 없는 환경에서 /trigger input 으로 dialog 열기 가능).
|
||||
# 채팅 안내 메시지는 제거 — mc_chat_answer_mod 가 채팅 직접 입력을 처리함.
|
||||
data remove storage mq:input queue
|
||||
scoreboard players reset @a submit_seq
|
||||
scoreboard players set seq func.temp 0
|
||||
scoreboard players enable @a input
|
||||
|
||||
# 정답 입력 안내 (클릭 시 trigger input → tick 에서 dialog 오픈)
|
||||
function mq:tellraw {"text":"","color":"black",msg:[{"text":"[ 정답 입력 ]","color":"green","bold":true,"click_event":{"action":"run_command","command":"/trigger input set 1"},"hover_event":{"action":"show_text","value":{"text":"클릭하여 정답 입력창 열기","color":"gray"}}}]}
|
||||
|
||||
scoreboard players set init main 5
|
||||
|
||||
function mq:quiz/play_sound
|
||||
|
||||
@@ -1,28 +1,106 @@
|
||||
# 버튼 1개에 대한 매 tick 처리.
|
||||
# 매크로 인자(mq:tmp.btn): n, x, y, z, f, c, label, label_color, label_font, label_scale
|
||||
# buttons 점수 상태:
|
||||
# ..-2 : 비활성 (버튼 블록 제거, interaction 응답 차단)
|
||||
# -1 : 초기화 단계 (버튼 블록 + interaction × 3 + text_display 보장 후 0)
|
||||
# 0 : 정상 (interaction 클릭 대기)
|
||||
#
|
||||
# interaction/text_display entity 는 데이터팩이 직접 summon — /reload 시
|
||||
# commands/stop 에서 buttons 가 -1 로 재설정되어 다음 tick 에 ensure 로직
|
||||
# 실행. -1 단계에서 같은 태그 entity 를 모두 kill 후 정확한 개수만 다시
|
||||
# summon → 항상 idempotent (dup 누적 없음, 좌표/라벨 갱신 자동 반영).
|
||||
#
|
||||
# ---- facing → 머리 hitbox 위치 (이 파일 한 곳에서만 정의) ----
|
||||
# stone_button[face=wall, facing=X] AABB (블록 상대 좌표):
|
||||
# facing 의 의미 = "버튼 머리 visible 면의 normal 방향". 머리는 그 방향
|
||||
# 쪽 face 에 붙어 있고 hitbox 는 그 face 에서 안쪽(1/8) 만큼 들어감.
|
||||
# south : z ∈ [0, 0.125] 가로 x ∈ [0.3125, 0.6875]
|
||||
# north : z ∈ [0.875, 1] 가로 x ∈ [0.3125, 0.6875]
|
||||
# east : x ∈ [0, 0.125] 가로 z ∈ [0.3125, 0.6875]
|
||||
# west : x ∈ [0.875, 1] 가로 z ∈ [0.3125, 0.6875]
|
||||
# 세로 y ∈ [0.375, 0.625] 공통.
|
||||
#
|
||||
# interaction entity 의 horizontal hitbox 는 width × width 정사각형 강제라
|
||||
# 단일 entity 로는 "가로 0.375 × 두께 0.125" 직사각형 불가. → 두께(0.125)
|
||||
# 와 같은 width=0.125 인 interaction 을 가로축으로 3 개 타일링 (gap 없이
|
||||
# 인접: 중심 0.375 / 0.5 / 0.625, 각 폭 0.125 → 합 [0.3125, 0.6875]).
|
||||
# interaction Y 는 hitbox 바닥 → 소환 y = block y + 0.375, height = 0.25.
|
||||
#
|
||||
# ---- 깊이축: 블록 면 바로 바깥 (이중 트리거 방지) ----
|
||||
# interaction 박스가 stone_button hitbox 와 겹치면 한 번 클릭에 interaction
|
||||
# 도 발화하고 stone_button 도 vanilla 클릭으로 인식되어 powered=true 애니
|
||||
# 메이션이 같이 일어남. → interaction 박스를 버튼 면 바깥쪽으로 한 두께
|
||||
# (0.125) 만큼 빼 ray 가 stone_button 에 닿기 전에 interaction 에서 멈추게.
|
||||
# south : 깊이 z 중심 = -0.0625 (interaction z ∈ [-0.125, 0], 버튼 z ∈ [0, 0.125])
|
||||
# north : 깊이 z 중심 = 1.0625 (interaction z ∈ [1, 1.125], 버튼 z ∈ [0.875, 1])
|
||||
# east : 깊이 x 중심 = -0.0625
|
||||
# west : 깊이 x 중심 = 1.0625
|
||||
#
|
||||
# ---- positioned 의 .5 보정 회피 ----
|
||||
# MC 의 vec3 인자는 정수만 쓰면 자동으로 +0.5 보정됨 (블록 중심으로 잡힘).
|
||||
# positioned 2773 86 5968 → 실제로는 (2773.5, 86, 5968.5). 거기서 ~ 오프셋
|
||||
# 을 더하면 박스 전체가 0.5 칸 어긋남. $(x).0 $(y).0 $(z).0 처럼 decimal
|
||||
# 형태로 넘기면 보정 없이 정확한 블록 origin (minimal corner) 이 됨.
|
||||
#
|
||||
# ---- text_display 위치 (버튼 바로 아래 같은 벽면에 부착) ----
|
||||
# 같은 벽 (button 의 머리 normal 반대편 블록) 의 visible 면에 살짝 띄워
|
||||
# 부착. 텍스트 entity Y 는 텍스트 baseline 근방 → 아래 블록 바닥에 두면
|
||||
# 텍스트가 그 블록 안에 위로 솟아남.
|
||||
# south : ~0.5 ~-1 ~0.01 yaw 0 (head 가 +z 방향 → 벽 +z=0.01 살짝 띄움)
|
||||
# north : ~0.5 ~-1 ~0.99 yaw 180
|
||||
# east : ~0.01 ~-1 ~0.5 yaw -90
|
||||
# west : ~0.99 ~-1 ~0.5 yaw 90
|
||||
|
||||
# ---- 비활성: 블록 + interaction × 3 + text_display 전부 제거 후 종료 ----
|
||||
# data modify entity @e[...] 는 대상 1개 강제 → interaction 3개 모드에선
|
||||
# 못 쓰므로 그냥 kill. 어차피 버튼 블록도 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 kill @e[type=minecraft:interaction,tag=mq,tag=$(n)]
|
||||
$execute if score $(n) buttons matches ..-2 run kill @e[type=minecraft:text_display,tag=mq,tag=$(n)]
|
||||
$execute if score $(n) buttons matches ..-2 run return 0
|
||||
|
||||
# ---- 초기화: 블록 + interaction × 3 + text_display 보장 ----
|
||||
$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 positioned $(x) $(y) $(z) run setblock ~ ~-3 ~ minecraft:redstone_block
|
||||
$execute if score $(n) buttons matches -1 positioned $(x) $(y) $(z) run setblock ~ ~-3 ~ minecraft:red_wool
|
||||
$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:text_display,tag=mq,tag=$(n)]
|
||||
|
||||
# south: 깊이축=z(-0.0625, 블록 면 바깥), 가로축=x, 3 타일 + 라벨
|
||||
$execute if score $(n) buttons matches -1 if data storage mq:tmp btn{f:"south"} positioned $(x).0 $(y).0 $(z).0 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:"south"} positioned $(x).0 $(y).0 $(z).0 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).0 $(y).0 $(z).0 run summon minecraft:interaction ~0.625 ~0.375 ~-0.0625 {Tags:["mq","$(n)"],width:0.125f,height:0.25f,response:0b}
|
||||
$execute if score $(n) buttons matches -1 unless data storage mq:tmp btn{label:""} if data storage mq:tmp btn{f:"south"} positioned $(x).0 $(y).0 $(z).0 run summon minecraft:text_display ~0.5 ~-1 ~0.01 {Tags:["mq","$(n)"],Rotation:[0f,0f],background:0,text:{text:"$(label)",color:"$(label_color)",font:"$(label_font)"},transformation:{scale:[$(label_scale)f,$(label_scale)f,$(label_scale)f],translation:[0f,0f,0f],left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f]}}
|
||||
|
||||
# north: 깊이축=z(+1.0625, 블록 면 바깥), 가로축=x, 3 타일 + 라벨
|
||||
$execute if score $(n) buttons matches -1 if data storage mq:tmp btn{f:"north"} positioned $(x).0 $(y).0 $(z).0 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).0 $(y).0 $(z).0 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).0 $(y).0 $(z).0 run summon minecraft:interaction ~0.625 ~0.375 ~1.0625 {Tags:["mq","$(n)"],width:0.125f,height:0.25f,response:0b}
|
||||
$execute if score $(n) buttons matches -1 unless data storage mq:tmp btn{label:""} if data storage mq:tmp btn{f:"north"} positioned $(x).0 $(y).0 $(z).0 run summon minecraft:text_display ~0.5 ~-1 ~0.99 {Tags:["mq","$(n)"],Rotation:[180f,0f],background:0,text:{text:"$(label)",color:"$(label_color)",font:"$(label_font)"},transformation:{scale:[$(label_scale)f,$(label_scale)f,$(label_scale)f],translation:[0f,0f,0f],left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f]}}
|
||||
|
||||
# east: 깊이축=x(-0.0625, 블록 면 바깥), 가로축=z, 3 타일 + 라벨
|
||||
$execute if score $(n) buttons matches -1 if data storage mq:tmp btn{f:"east"} positioned $(x).0 $(y).0 $(z).0 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).0 $(y).0 $(z).0 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).0 $(y).0 $(z).0 run summon minecraft:interaction ~-0.0625 ~0.375 ~0.625 {Tags:["mq","$(n)"],width:0.125f,height:0.25f,response:0b}
|
||||
$execute if score $(n) buttons matches -1 unless data storage mq:tmp btn{label:""} if data storage mq:tmp btn{f:"east"} positioned $(x).0 $(y).0 $(z).0 run summon minecraft:text_display ~0.01 ~-1 ~0.5 {Tags:["mq","$(n)"],Rotation:[-90f,0f],background:0,text:{text:"$(label)",color:"$(label_color)",font:"$(label_font)"},transformation:{scale:[$(label_scale)f,$(label_scale)f,$(label_scale)f],translation:[0f,0f,0f],left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f]}}
|
||||
|
||||
# west: 깊이축=x(+1.0625, 블록 면 바깥), 가로축=z, 3 타일 + 라벨
|
||||
$execute if score $(n) buttons matches -1 if data storage mq:tmp btn{f:"west"} positioned $(x).0 $(y).0 $(z).0 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).0 $(y).0 $(z).0 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).0 $(y).0 $(z).0 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 unless data storage mq:tmp btn{label:""} if data storage mq:tmp btn{f:"west"} positioned $(x).0 $(y).0 $(z).0 run summon minecraft:text_display ~0.99 ~-1 ~0.5 {Tags:["mq","$(n)"],Rotation:[90f,0f],background:0,text:{text:"$(label)",color:"$(label_color)",font:"$(label_font)"},transformation:{scale:[$(label_scale)f,$(label_scale)f,$(label_scale)f],translation:[0f,0f,0f],left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f]}}
|
||||
|
||||
$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] \
|
||||
if score $(n) buttons matches 0 \
|
||||
run scoreboard players set $(n) buttons 1
|
||||
|
||||
$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) 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)
|
||||
# ---- 상시: interaction 클릭/타격 → playsound + 명령/투표 실행 ----
|
||||
# init main = 0 (퀴즈 시작 전 설정 단계) : 명령 직접 실행
|
||||
# 그 외 : trigger 투표 경로
|
||||
# 한 버튼에 interaction 3개지만 `on target` 은 클릭된 1개만 통과
|
||||
# (나머지는 target 부재로 체인 중단). limit=1 을 두면 MC 가 임의로 1개를
|
||||
# 골라 잘못된 entity 만 검사하므로 limit 두지 않음.
|
||||
$execute as @e[type=minecraft:interaction,tag=mq,tag=$(n)] on target as @s positioned $(x).0 $(y).0 $(z).0 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).0 $(y).0 $(z).0 if score init main matches 0 run $(c)
|
||||
$execute as @e[type=minecraft:interaction,tag=mq,tag=$(n)] on target as @s positioned $(x).0 $(y).0 $(z).0 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 interaction
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
# 한 button entry 의 optional 필드 기본값을 채워 macro 호출 시 $(arg) 미존재
|
||||
# 에러를 방지한다. handler 에서 entry 복사 직후 호출.
|
||||
#
|
||||
# label : 없으면 "" (빈 문자열) -> btn 안의 text_display 분기는 label
|
||||
# 이 "" 이면 스킵.
|
||||
# label_color : 기본 "black"
|
||||
# label_font : 기본 "minecraft:default"
|
||||
# label_scale : 기본 "1.0" (Vector3f 의 한 축, 3축 동일하게 사용됨)
|
||||
#
|
||||
# 구현: defaults 컴파운드를 먼저 만들고 entry (mq:tmp.btn) 를 그 위에 merge
|
||||
# 한 뒤 다시 mq:tmp.btn 으로 되돌린다. data modify ... merge from 은 source
|
||||
# compound 의 키로 target compound 를 덮어쓰므로 entry 에 있는 값은 보존되고
|
||||
# entry 에 없는 키만 default 값으로 채워진다.
|
||||
#
|
||||
# (이전에 `execute unless data storage mq:tmp btn.label run data modify ...`
|
||||
# 방식이었으나 MC 26.1.2 parser 가 해당 라인을 거부했음. merge 방식은 문제
|
||||
# 난 execute-unless-data 구문 자체를 제거.)
|
||||
|
||||
data modify storage mq:tmp btn_default set value {label:"",label_color:"black",label_font:"minecraft:default",label_scale:"1.0"}
|
||||
data modify storage mq:tmp btn_default merge from storage mq:tmp btn
|
||||
data modify storage mq:tmp btn set from storage mq:tmp btn_default
|
||||
@@ -1,6 +1,27 @@
|
||||
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 으로 복사 → optional 필드 기본값 채움
|
||||
# → btn 호출. btn 안에서 facing 별 분기 (if data storage mq:tmp btn{f:"..."})
|
||||
# 와 macro arg ($(label) 등) 둘 다 사용 가능하게 같은 storage 에 노출시킨다.
|
||||
|
||||
data modify storage mq:tmp btn set from storage mq:main button_defs[0]
|
||||
function mq:repeat/buttons/btn_prep
|
||||
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_prep
|
||||
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_prep
|
||||
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_prep
|
||||
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_prep
|
||||
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_prep
|
||||
function mq:repeat/buttons/btn with storage mq:tmp btn
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
{
|
||||
"pack": {
|
||||
"pack_format": 75,
|
||||
"min_format": 75,
|
||||
"max_format": 75,
|
||||
"description": "음악퀴즈용 데이터팩입니다."
|
||||
"description": "음악퀴즈용 데이터팩입니다.",
|
||||
"min_format": [101, 1],
|
||||
"max_format": [101, 1]
|
||||
}
|
||||
}
|
||||
|
||||
74
temp/README.md
Normal file
74
temp/README.md
Normal file
@@ -0,0 +1,74 @@
|
||||
# v1.0.21 → v1.0.22 부분 적용 가이드
|
||||
|
||||
전체 datapack 을 교체하지 않고, 이 폴더의 파일만 덮어쓰면 v1.0.22 와 동일한 상태가 됩니다.
|
||||
|
||||
## 무엇이 바뀌었나 (v1.0.22 신규)
|
||||
|
||||
### `commands/start.mcfunction` + `load.mcfunction` — "채팅정답 모드 미설치" false negative 제거
|
||||
|
||||
모드를 설치했는데도 `/start` 가 "채팅정답 모드가 서버에 미설치" 로 차단되던 문제.
|
||||
|
||||
원인: 검증은 모드가 매 server tick `#server mq_chat_mod` 점수를 1 로 set
|
||||
하는지 보는 방식인데, 다음 케이스에서 score 가 1 로 안 올라가 false negative:
|
||||
- 사용자가 옛 모드 버전 (v1.3.4 이하, presence tick 추가 전) 을 쓰고 있을 때
|
||||
- banner/mohist 같은 fabric-bukkit 하이브리드 호스트에서 ServerTickEvents 가
|
||||
안 들어올 때
|
||||
|
||||
근본 수정: 채팅정답 모드는 입력을 편하게 만들어 주는 **선택적 편의 기능**일
|
||||
뿐, 모드 없이도 `/trigger input` dialog 경로로 정답 제출 가능. 그래서 채팅
|
||||
모드 게이트 자체를 제거. 영상재생 모드 (mc_video_player_mod) 게이트는 진짜
|
||||
필수이므로 유지.
|
||||
|
||||
## 이전 버전 fix 도 같이 포함 (v1.0.20, v1.0.21)
|
||||
|
||||
### `repeat/buttons/btn.mcfunction`
|
||||
- (v1.0.20) `positioned $(x) $(y) $(z)` → `$(x).0 $(y).0 $(z).0`.
|
||||
MC vec3 정수 인자의 +0.5 보정 (블록 중심) 으로 interaction 박스가 0.5 칸
|
||||
어긋나던 문제 회피.
|
||||
- (v1.0.21) interaction 깊이축을 stone_button hitbox 바깥쪽으로 한 두께만큼
|
||||
이동. 한 번 클릭에 stone_button 도 같이 눌리던 (powered=true) 문제 회피.
|
||||
- (v1.0.21) `text_display.text` 를 String JSON 에서 직접 TextComponent
|
||||
compound 로. MC 1.20.5+ 부터 라벨이 `{"text":"게임시작",...}` 코드 그대로
|
||||
렌더되던 문제 회피.
|
||||
|
||||
### `repeat/buttons/btn_prep.mcfunction`
|
||||
- (v1.0.20) `execute unless data storage mq:tmp btn.label ...` 가 MC 26.1.2
|
||||
파서에 거부되던 문제. defaults + `data modify ... merge from` 방식으로
|
||||
재작성.
|
||||
|
||||
## 적용 방법
|
||||
|
||||
서버의 datapack 폴더 (예: `world/datapacks/music_quiz/`) 기준으로 이 폴더의
|
||||
파일을 **같은 경로에 덮어쓰세요**.
|
||||
|
||||
```
|
||||
temp/data/mq/function/commands/start.mcfunction
|
||||
-> <datapack>/data/mq/function/commands/start.mcfunction
|
||||
|
||||
temp/data/mq/function/load.mcfunction
|
||||
-> <datapack>/data/mq/function/load.mcfunction
|
||||
|
||||
temp/data/mq/function/repeat/buttons/btn.mcfunction
|
||||
-> <datapack>/data/mq/function/repeat/buttons/btn.mcfunction
|
||||
|
||||
temp/data/mq/function/repeat/buttons/btn_prep.mcfunction
|
||||
-> <datapack>/data/mq/function/repeat/buttons/btn_prep.mcfunction
|
||||
```
|
||||
|
||||
이미 v1.0.21 을 적용한 상태라면 위 두 `repeat/buttons/*` 파일은 동일하므로
|
||||
사실상 `start.mcfunction` 과 `load.mcfunction` 두 개만 새로 바뀝니다.
|
||||
그래도 4 개 모두 덮어쓰는 게 안전합니다 (idempotent).
|
||||
|
||||
복사 후 게임 안에서:
|
||||
|
||||
```
|
||||
/reload
|
||||
```
|
||||
|
||||
## 확인
|
||||
|
||||
- 채팅정답 모드가 설치되어 있든 아니든 `/start` 가 "채팅정답 모드 미설치"
|
||||
메시지로 차단되지 않아야 합니다. (영상재생 모드는 여전히 필수.)
|
||||
- 버튼 클릭 시 stone_button 의 powered 애니메이션 없음.
|
||||
- 라벨이 `게임시작` 등으로 정상 표시 (JSON 코드 노출 없음).
|
||||
- 콘솔에 파싱 에러 없음.
|
||||
37
temp/data/mq/function/commands/start.mcfunction
Normal file
37
temp/data/mq/function/commands/start.mcfunction
Normal file
@@ -0,0 +1,37 @@
|
||||
execute if score init main matches 10 run return run function mq:tellraw {"text":"퀴즈가 완전히 종료된후 시작해주세요.","color":"red","msg":""}
|
||||
|
||||
# ---- 외부 모드 설치 검증 ----
|
||||
# mq_video_mod (mc_video_player_mod) 만 게이트. 영상 렌더링은 클라 모드가
|
||||
# 필수라 없으면 게임이 의미가 없음. same objective 안에 holder 두 종류:
|
||||
# - `#server mq_video_mod` : 서버 컴포넌트가 매 tick 1 로 갱신 (server
|
||||
# presence). 없으면 0 → 서버에 모드 미설치.
|
||||
# - `<player> mq_video_mod` : 클라 join 시 payload 가 서버로 오면 서버
|
||||
# 컴포넌트가 해당 플레이어 점수를 1 로 set (client presence). 클라
|
||||
# 미설치면 0 유지.
|
||||
#
|
||||
# mq_chat_mod (mc_chat_answer_mod) 는 게이트하지 않음 — 채팅 모드는 입력을
|
||||
# "편하게" 만들어주는 옵션일 뿐이고, 모드 없는 환경에서도 `/trigger input`
|
||||
# dialog 경로로 정답 제출이 가능. 과거에 게이트해 두면 모드 presence pulse
|
||||
# 가 호스트 환경 (banner/mohist 같은 fabric-bukkit 하이브리드) 에서 안
|
||||
# 들어오거나, 사용자 모드 버전이 presence tick 이전 (v1.3.4 이하) 일 때
|
||||
# false negative 로 시작이 막혔음.
|
||||
#
|
||||
# 1) 서버 측 영상 모드 부재 — 전원 차단, 단일 안내.
|
||||
execute unless score #server mq_video_mod matches 1 run return run function mq:tellraw {"text":"영상재생 모드가 서버에 미설치 — 서버 관리자에게 문의해주세요.","color":"red","msg":""}
|
||||
|
||||
# 2) 클라이언트 측 모드 (mc_video_player_mod) 부재 — 본인 누락 안내 + 차단.
|
||||
# selector `scores={X=..0}` 는 점수 미존재를 매치하지 않으므로 직전에
|
||||
# `add @a ... 0` 으로 materialize. 개인 안내는 tellraw @s 직접 (mq:tellraw
|
||||
# 는 내부 @a broadcast 라 부적합).
|
||||
scoreboard players add @a mq_video_mod 0
|
||||
execute as @a[scores={mq_video_mod=..0}] run tellraw @s ["",{"text":"영상재생 모드 미설치 — 모드 적용 후 다시 입장해주세요.","color":"red"}]
|
||||
execute if entity @a[scores={mq_video_mod=..0}] run return run function mq:tellraw {"text":"필수 모드 미설치 플레이어가 있어 시작할 수 없습니다.","color":"red","msg":""}
|
||||
|
||||
setblock ~ ~ ~ minecraft:air
|
||||
|
||||
function mq:quiz/stop_sound
|
||||
|
||||
$scoreboard players set max_index main $(max_index)
|
||||
scoreboard players set init main 1
|
||||
|
||||
dialog show @a mq:page1
|
||||
49
temp/data/mq/function/load.mcfunction
Normal file
49
temp/data/mq/function/load.mcfunction
Normal file
@@ -0,0 +1,49 @@
|
||||
data modify storage mq:main answer set value {title:"", author:"", alias:[]}
|
||||
data merge storage func:temp {}
|
||||
data merge storage mq:tmp {}
|
||||
|
||||
function mq:init/config
|
||||
function mq:init/songs
|
||||
function mq:init/buttons
|
||||
function mq:init/triggers
|
||||
|
||||
function mq:tellraw {"text":"서버 리로드 성공!","color":"white","msg":'""'}
|
||||
|
||||
scoreboard objectives remove func.temp
|
||||
scoreboard objectives remove main
|
||||
scoreboard objectives remove buttons
|
||||
scoreboard objectives remove answer
|
||||
scoreboard objectives remove leave_game
|
||||
|
||||
scoreboard objectives add func.temp dummy
|
||||
scoreboard objectives add main dummy
|
||||
scoreboard objectives add buttons dummy
|
||||
scoreboard objectives add answer dummy
|
||||
scoreboard objectives add leave_game custom:leave_game
|
||||
|
||||
# 외부 모드 존재 확인용 점수.
|
||||
# mq_video_mod : 클라이언트 모드(mc_video_player_mod). 클라 join 시 서버로
|
||||
# handshake payload 전송 → 서버 측 모드가 해당 플레이어 점수를 1 로 set.
|
||||
# 클라에 모드가 없으면 0 유지. (login.mcfunction 에서 플레이어별 0 초기화.)
|
||||
# same objective 안에 holder 두 종류 — `#server` 는 서버 컴포넌트 존재
|
||||
# (서버 측 모드가 매 tick 1 로 갱신), `<player>` 는 클라 측 존재 (payload
|
||||
# 수신 시 1 로 갱신).
|
||||
#
|
||||
# mq_chat_mod (mc_chat_answer_mod) 는 더 이상 게이트하지 않음 — 모드 없는
|
||||
# 환경에서도 `/trigger input` dialog 경로로 정답 제출 가능. presence pulse
|
||||
# 가 호스트 환경에 따라 안 들어오거나 사용자 모드 버전이 옛날일 때 false
|
||||
# negative 로 시작이 막히던 문제 회피. (모드 측은 여전히 매 tick objective
|
||||
# 존재시 1 로 set 시도하지만, objective 가 없으면 silent skip 하므로 무해.)
|
||||
scoreboard objectives remove mq_chat_mod
|
||||
scoreboard objectives remove mq_video_mod
|
||||
scoreboard objectives add mq_video_mod dummy
|
||||
# /reload 후 모드가 한 tick 도 돌기 전에 start 가 호출될 수 있으니
|
||||
# #server 점수도 0 으로 materialize. 모드가 살아 있으면 다음 tick 에 1 로 갱신.
|
||||
scoreboard players set #server mq_video_mod 0
|
||||
|
||||
scoreboard players set two func.temp 2
|
||||
|
||||
bossbar add mq:process [{"text":"진행도: ","color": "yellow","bold": true},{"text":"0","color": "yellow","bold": true},{"text":"/","color": "yellow","bold": true},{"text":"0","color": "yellow","bold": true}]
|
||||
|
||||
function mq:commands/stop with storage mq:main
|
||||
function mq:players/login with storage mq:main spawn
|
||||
106
temp/data/mq/function/repeat/buttons/btn.mcfunction
Normal file
106
temp/data/mq/function/repeat/buttons/btn.mcfunction
Normal file
@@ -0,0 +1,106 @@
|
||||
# 버튼 1개에 대한 매 tick 처리.
|
||||
# 매크로 인자(mq:tmp.btn): n, x, y, z, f, c, label, label_color, label_font, label_scale
|
||||
# buttons 점수 상태:
|
||||
# ..-2 : 비활성 (버튼 블록 제거, interaction 응답 차단)
|
||||
# -1 : 초기화 단계 (버튼 블록 + interaction × 3 + text_display 보장 후 0)
|
||||
# 0 : 정상 (interaction 클릭 대기)
|
||||
#
|
||||
# interaction/text_display entity 는 데이터팩이 직접 summon — /reload 시
|
||||
# commands/stop 에서 buttons 가 -1 로 재설정되어 다음 tick 에 ensure 로직
|
||||
# 실행. -1 단계에서 같은 태그 entity 를 모두 kill 후 정확한 개수만 다시
|
||||
# summon → 항상 idempotent (dup 누적 없음, 좌표/라벨 갱신 자동 반영).
|
||||
#
|
||||
# ---- facing → 머리 hitbox 위치 (이 파일 한 곳에서만 정의) ----
|
||||
# stone_button[face=wall, facing=X] AABB (블록 상대 좌표):
|
||||
# facing 의 의미 = "버튼 머리 visible 면의 normal 방향". 머리는 그 방향
|
||||
# 쪽 face 에 붙어 있고 hitbox 는 그 face 에서 안쪽(1/8) 만큼 들어감.
|
||||
# south : z ∈ [0, 0.125] 가로 x ∈ [0.3125, 0.6875]
|
||||
# north : z ∈ [0.875, 1] 가로 x ∈ [0.3125, 0.6875]
|
||||
# east : x ∈ [0, 0.125] 가로 z ∈ [0.3125, 0.6875]
|
||||
# west : x ∈ [0.875, 1] 가로 z ∈ [0.3125, 0.6875]
|
||||
# 세로 y ∈ [0.375, 0.625] 공통.
|
||||
#
|
||||
# interaction entity 의 horizontal hitbox 는 width × width 정사각형 강제라
|
||||
# 단일 entity 로는 "가로 0.375 × 두께 0.125" 직사각형 불가. → 두께(0.125)
|
||||
# 와 같은 width=0.125 인 interaction 을 가로축으로 3 개 타일링 (gap 없이
|
||||
# 인접: 중심 0.375 / 0.5 / 0.625, 각 폭 0.125 → 합 [0.3125, 0.6875]).
|
||||
# interaction Y 는 hitbox 바닥 → 소환 y = block y + 0.375, height = 0.25.
|
||||
#
|
||||
# ---- 깊이축: 블록 면 바로 바깥 (이중 트리거 방지) ----
|
||||
# interaction 박스가 stone_button hitbox 와 겹치면 한 번 클릭에 interaction
|
||||
# 도 발화하고 stone_button 도 vanilla 클릭으로 인식되어 powered=true 애니
|
||||
# 메이션이 같이 일어남. → interaction 박스를 버튼 면 바깥쪽으로 한 두께
|
||||
# (0.125) 만큼 빼 ray 가 stone_button 에 닿기 전에 interaction 에서 멈추게.
|
||||
# south : 깊이 z 중심 = -0.0625 (interaction z ∈ [-0.125, 0], 버튼 z ∈ [0, 0.125])
|
||||
# north : 깊이 z 중심 = 1.0625 (interaction z ∈ [1, 1.125], 버튼 z ∈ [0.875, 1])
|
||||
# east : 깊이 x 중심 = -0.0625
|
||||
# west : 깊이 x 중심 = 1.0625
|
||||
#
|
||||
# ---- positioned 의 .5 보정 회피 ----
|
||||
# MC 의 vec3 인자는 정수만 쓰면 자동으로 +0.5 보정됨 (블록 중심으로 잡힘).
|
||||
# positioned 2773 86 5968 → 실제로는 (2773.5, 86, 5968.5). 거기서 ~ 오프셋
|
||||
# 을 더하면 박스 전체가 0.5 칸 어긋남. $(x).0 $(y).0 $(z).0 처럼 decimal
|
||||
# 형태로 넘기면 보정 없이 정확한 블록 origin (minimal corner) 이 됨.
|
||||
#
|
||||
# ---- text_display 위치 (버튼 바로 아래 같은 벽면에 부착) ----
|
||||
# 같은 벽 (button 의 머리 normal 반대편 블록) 의 visible 면에 살짝 띄워
|
||||
# 부착. 텍스트 entity Y 는 텍스트 baseline 근방 → 아래 블록 바닥에 두면
|
||||
# 텍스트가 그 블록 안에 위로 솟아남.
|
||||
# south : ~0.5 ~-1 ~0.01 yaw 0 (head 가 +z 방향 → 벽 +z=0.01 살짝 띄움)
|
||||
# north : ~0.5 ~-1 ~0.99 yaw 180
|
||||
# east : ~0.01 ~-1 ~0.5 yaw -90
|
||||
# west : ~0.99 ~-1 ~0.5 yaw 90
|
||||
|
||||
# ---- 비활성: 블록 + interaction × 3 + text_display 전부 제거 후 종료 ----
|
||||
# data modify entity @e[...] 는 대상 1개 강제 → interaction 3개 모드에선
|
||||
# 못 쓰므로 그냥 kill. 어차피 버튼 블록도 air 로 바꾸므로 라벨도 같이 제거.
|
||||
$execute if score $(n) buttons matches ..-2 run setblock $(x) $(y) $(z) minecraft:air
|
||||
$execute if score $(n) buttons matches ..-2 run kill @e[type=minecraft:interaction,tag=mq,tag=$(n)]
|
||||
$execute if score $(n) buttons matches ..-2 run kill @e[type=minecraft:text_display,tag=mq,tag=$(n)]
|
||||
$execute if score $(n) buttons matches ..-2 run return 0
|
||||
|
||||
# ---- 초기화: 블록 + interaction × 3 + text_display 보장 ----
|
||||
$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 run kill @e[type=minecraft:text_display,tag=mq,tag=$(n)]
|
||||
|
||||
# south: 깊이축=z(-0.0625, 블록 면 바깥), 가로축=x, 3 타일 + 라벨
|
||||
$execute if score $(n) buttons matches -1 if data storage mq:tmp btn{f:"south"} positioned $(x).0 $(y).0 $(z).0 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:"south"} positioned $(x).0 $(y).0 $(z).0 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).0 $(y).0 $(z).0 run summon minecraft:interaction ~0.625 ~0.375 ~-0.0625 {Tags:["mq","$(n)"],width:0.125f,height:0.25f,response:0b}
|
||||
$execute if score $(n) buttons matches -1 unless data storage mq:tmp btn{label:""} if data storage mq:tmp btn{f:"south"} positioned $(x).0 $(y).0 $(z).0 run summon minecraft:text_display ~0.5 ~-1 ~0.01 {Tags:["mq","$(n)"],Rotation:[0f,0f],background:0,text:{text:"$(label)",color:"$(label_color)",font:"$(label_font)"},transformation:{scale:[$(label_scale)f,$(label_scale)f,$(label_scale)f],translation:[0f,0f,0f],left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f]}}
|
||||
|
||||
# north: 깊이축=z(+1.0625, 블록 면 바깥), 가로축=x, 3 타일 + 라벨
|
||||
$execute if score $(n) buttons matches -1 if data storage mq:tmp btn{f:"north"} positioned $(x).0 $(y).0 $(z).0 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).0 $(y).0 $(z).0 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).0 $(y).0 $(z).0 run summon minecraft:interaction ~0.625 ~0.375 ~1.0625 {Tags:["mq","$(n)"],width:0.125f,height:0.25f,response:0b}
|
||||
$execute if score $(n) buttons matches -1 unless data storage mq:tmp btn{label:""} if data storage mq:tmp btn{f:"north"} positioned $(x).0 $(y).0 $(z).0 run summon minecraft:text_display ~0.5 ~-1 ~0.99 {Tags:["mq","$(n)"],Rotation:[180f,0f],background:0,text:{text:"$(label)",color:"$(label_color)",font:"$(label_font)"},transformation:{scale:[$(label_scale)f,$(label_scale)f,$(label_scale)f],translation:[0f,0f,0f],left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f]}}
|
||||
|
||||
# east: 깊이축=x(-0.0625, 블록 면 바깥), 가로축=z, 3 타일 + 라벨
|
||||
$execute if score $(n) buttons matches -1 if data storage mq:tmp btn{f:"east"} positioned $(x).0 $(y).0 $(z).0 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).0 $(y).0 $(z).0 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).0 $(y).0 $(z).0 run summon minecraft:interaction ~-0.0625 ~0.375 ~0.625 {Tags:["mq","$(n)"],width:0.125f,height:0.25f,response:0b}
|
||||
$execute if score $(n) buttons matches -1 unless data storage mq:tmp btn{label:""} if data storage mq:tmp btn{f:"east"} positioned $(x).0 $(y).0 $(z).0 run summon minecraft:text_display ~0.01 ~-1 ~0.5 {Tags:["mq","$(n)"],Rotation:[-90f,0f],background:0,text:{text:"$(label)",color:"$(label_color)",font:"$(label_font)"},transformation:{scale:[$(label_scale)f,$(label_scale)f,$(label_scale)f],translation:[0f,0f,0f],left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f]}}
|
||||
|
||||
# west: 깊이축=x(+1.0625, 블록 면 바깥), 가로축=z, 3 타일 + 라벨
|
||||
$execute if score $(n) buttons matches -1 if data storage mq:tmp btn{f:"west"} positioned $(x).0 $(y).0 $(z).0 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).0 $(y).0 $(z).0 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).0 $(y).0 $(z).0 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 unless data storage mq:tmp btn{label:""} if data storage mq:tmp btn{f:"west"} positioned $(x).0 $(y).0 $(z).0 run summon minecraft:text_display ~0.99 ~-1 ~0.5 {Tags:["mq","$(n)"],Rotation:[90f,0f],background:0,text:{text:"$(label)",color:"$(label_color)",font:"$(label_font)"},transformation:{scale:[$(label_scale)f,$(label_scale)f,$(label_scale)f],translation:[0f,0f,0f],left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f]}}
|
||||
|
||||
$execute if score $(n) buttons matches -1 run scoreboard players set $(n) buttons 0
|
||||
|
||||
# ---- 상시: interaction 클릭/타격 → playsound + 명령/투표 실행 ----
|
||||
# init main = 0 (퀴즈 시작 전 설정 단계) : 명령 직접 실행
|
||||
# 그 외 : trigger 투표 경로
|
||||
# 한 버튼에 interaction 3개지만 `on target` 은 클릭된 1개만 통과
|
||||
# (나머지는 target 부재로 체인 중단). limit=1 을 두면 MC 가 임의로 1개를
|
||||
# 골라 잘못된 entity 만 검사하므로 limit 두지 않음.
|
||||
$execute as @e[type=minecraft:interaction,tag=mq,tag=$(n)] on target as @s positioned $(x).0 $(y).0 $(z).0 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).0 $(y).0 $(z).0 if score init main matches 0 run $(c)
|
||||
$execute as @e[type=minecraft:interaction,tag=mq,tag=$(n)] on target as @s positioned $(x).0 $(y).0 $(z).0 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 interaction
|
||||
21
temp/data/mq/function/repeat/buttons/btn_prep.mcfunction
Normal file
21
temp/data/mq/function/repeat/buttons/btn_prep.mcfunction
Normal file
@@ -0,0 +1,21 @@
|
||||
# 한 button entry 의 optional 필드 기본값을 채워 macro 호출 시 $(arg) 미존재
|
||||
# 에러를 방지한다. handler 에서 entry 복사 직후 호출.
|
||||
#
|
||||
# label : 없으면 "" (빈 문자열) -> btn 안의 text_display 분기는 label
|
||||
# 이 "" 이면 스킵.
|
||||
# label_color : 기본 "black"
|
||||
# label_font : 기본 "minecraft:default"
|
||||
# label_scale : 기본 "1.0" (Vector3f 의 한 축, 3축 동일하게 사용됨)
|
||||
#
|
||||
# 구현: defaults 컴파운드를 먼저 만들고 entry (mq:tmp.btn) 를 그 위에 merge
|
||||
# 한 뒤 다시 mq:tmp.btn 으로 되돌린다. data modify ... merge from 은 source
|
||||
# compound 의 키로 target compound 를 덮어쓰므로 entry 에 있는 값은 보존되고
|
||||
# entry 에 없는 키만 default 값으로 채워진다.
|
||||
#
|
||||
# (이전에 `execute unless data storage mq:tmp btn.label run data modify ...`
|
||||
# 방식이었으나 MC 26.1.2 parser 가 해당 라인을 거부했음. merge 방식은 문제
|
||||
# 난 execute-unless-data 구문 자체를 제거.)
|
||||
|
||||
data modify storage mq:tmp btn_default set value {label:"",label_color:"black",label_font:"minecraft:default",label_scale:"1.0"}
|
||||
data modify storage mq:tmp btn_default merge from storage mq:tmp btn
|
||||
data modify storage mq:tmp btn set from storage mq:tmp btn_default
|
||||
BIN
temp/gif.png
BIN
temp/gif.png
Binary file not shown.
|
Before Width: | Height: | Size: 4.6 KiB |
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"animation": {
|
||||
"frametime": 1,
|
||||
"interpolate": false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user