본문으로 건너뛰기
버전: Minecraft 26.2

게임 규칙·사운드·파티클·발전 과제

게임 규칙​

GameRuleKey<Boolean> greet = mod.content().booleanRule("golems_greet_players", true, GameRuleCategory.MOBS);
GameRuleKey<Integer> multiplier = mod.content().integerRule("spark_multiplier", 1, 1, 8, GameRuleCategory.DROPS);

int value = world.gameRule(multiplier);
world.setGameRule(multiplier, 4);
  • /gamerule <mod>:<이름>으로 값을 바꿀 수 있으며, 값은 월드에 저장됩니다.
  • 분류는 PLAYER, MOBS, SPAWNING, DROPS, UPDATES, CHAT, MISC 중에서 고릅니다.
  • integerRule의 인수는 (path, 기본값, 최소, 최대, 분류) 순서입니다.

사운드​

SoundHandle chime = mod.content().sound("chime");
world.playSound(pos, chime.id(), 1f, 1f);
world.playSound(pos, ResourceId.minecraft("block.note_block.bell"), 1, 1);

사운드 이벤트가 실제로 내는 소리는 assets/<mod>/sounds.json에서 정합니다.

assets/my_mod/sounds.json
{
"chime": {
"sounds": ["minecraft:random/orb"],
"subtitle": "subtitles.my_mod.chime"
}
}

파티클​

ContentHandle sparkle = mod.content().particle("sparkle", ParticleDefinition.of(16).asGlowing().withTint(0xFFD54F));
world.spawnParticles(sparkle.id(), x, y, z, 12, 0.3); // 개수, 퍼짐
world.spawnParticles(ResourceId.minecraft("heart"), x, y, z, 5, 0.3); // 게임 파티클
  • 파티클 종류는 서버와 클라이언트 양쪽에서 선언해야 하므로 common 엔트리포인트에서 content().particle로 선언합니다.
  • ParticleDefinition.of(수명틱)에 withGravity, withScale, asGlowing, withTint를 이어서 호출할 수 있습니다.
  • 스프라이트는 assets/<mod>/particles/<path>.json과 textures/particle/에서 읽습니다. 스프라이트가 여러 장이면 수명에 따라 차례로 바뀝니다.
  • 파티클은 spawnParticles나 /particle로 생성합니다. 게임 파티클 중에는 옵션이 필요 없는 단순 파티클만 쓸 수 있습니다.
assets/my_mod/particles/sparkle.json
{"textures": ["my_mod:sparkle_0", "my_mod:sparkle_1"]}

발전 과제 트리거​

AdvancementTrigger usedWand = mod.content().advancementTrigger("used_wand");
usedWand.trigger(player); // 서버에서 호출

player.hasAdvancement(id);
player.grantAdvancement(id);
player.revokeAdvancement(id);
  • 발전 과제 파일은 데이터 팩(data/<mod>/advancement/)에 두고, 조건의 "trigger"에 <mod>:used_wand를 씁니다.
  • 모드는 트리거를 선언한 뒤 trigger(player)로 조건을 충족시킵니다.
  • grantAdvancement/revokeAdvancement는 모든 조건을 한 번에 바꾸며, 서버 플레이어에게만 쓸 수 있습니다.
  • 게임 테스트에서는 createMockServerPlayer()로 확인합니다.
data/my_mod/advancement/used_wand.json
{
"parent": "minecraft:story/root",
"display": {
"icon": {"id": "my_mod:spark_wand"},
"title": {"translate": "advancements.my_mod.used_wand.title"},
"description": {"translate": "advancements.my_mod.used_wand.description"}
},
"criteria": {
"used": {"trigger": "my_mod:used_wand"}
}
}
Buy me a coffee