🇰🇷 한국어 (Korean - South Korea)
🇰🇷 한국어 (Korean - South Korea)
모양
🇰🇷 한국어 (Korean - South Korea)
🇰🇷 한국어 (Korean - South Korea)
모양
이 페이지는 다음 버전에 맞게 작성되었습니다:
1.21.4
이 페이지에서는 Fabric 모드 프로젝트의 구조와 프로젝트의 각 파일과 폴더의 목적에 대해 알아봅니다.
fabric.mod.json
fabric.mod.json
파일은 Fabric 로더에 모드를 설명하는 주요 파일입니다. 여기에는 모드의 식별자(ID), 버전, 종속성 등의 정보가 담깁니다.
여기 fabric.mod.json
파일에서 가장 중요한 필드 몇 가지가 있습니다:
id
: 모드의 식별자. 고유해야 합니다.name
: 모드의 이름.environment
: 모드가 동작할 환경. client
또는 server
, 어디서나 동작한다면 *
을 입력할 수 있습니다.entrypoints
: 모드에서 제공하는 진입점.depends
: 모드가 종속하는 다른 모드의 식별자.mixins
: 모드가 제공하는 Mixin.아래는 fabric.mod.json
의 예시입니다. 앞으로 모든 설명서는 아래 fabric.mod.json
으로 정의된 모드를 예시로 사용할 것입니다.
fabric.mod.json
{
"schemaVersion": 1,
"id": "fabric-docs-reference",
"version": "1.0.0",
"name": "Fabric docs reference",
"icon": "assets/fabric-docs-reference/icon.png",
"environment": "*",
"entrypoints": {
"main": [
"com.example.docs.FabricDocsReference",
"com.example.docs.event.FabricDocsReferenceEvents",
"com.example.docs.command.FabricDocsReferenceCommands",
"com.example.docs.effect.FabricDocsReferenceEffects",
"com.example.docs.potion.FabricDocsReferencePotions",
"com.example.docs.sound.FabricDocsReferenceSounds",
"com.example.docs.damage.FabricDocsReferenceDamageTypes",
"com.example.docs.item.FabricDocsReferenceItems",
"com.example.docs.enchantment.FabricDocsReferenceEnchantments",
"com.example.docs.block.FabricDocsReferenceBlocks",
"com.example.docs.block.entity.FabricDocsReferenceBlockEntities",
"com.example.docs.component.FabricDocsReferenceComponents",
"com.example.docs.advancement.FabricDocsReferenceDatagenAdvancement",
"com.example.docs.networking.FabricDocsReferenceNetworking",
"com.example.docs.networking.basic.FabricDocsReferenceNetworkingBasic"
],
"client": [
"com.example.docs.client.command.FabricDocsReferenceClientCommands",
"com.example.docs.FabricDocsBlockEntityRenderer",
"com.example.docs.FabricDocsDynamicSound",
"com.example.docs.FabricDocsReferenceClient",
"com.example.docs.rendering.HudRenderingEntrypoint",
"com.example.docs.network.basic.FabricDocsReferenceNetworkingBasicClient"
],
"fabric-datagen": [
"com.example.docs.datagen.FabricDocsReferenceDataGenerator"
]
},
"mixins": [
"fabric-docs-reference.mixins.json",
{
"config": "fabric-docs-reference.client.mixins.json",
"environment": "client"
}
],
"depends": {}
}
위에서 언급했듯이, fabric.mod.json
파일에는 entrypoint
라는 필드가 있습니다. 이 필드는 모드가 제공하는 진입점을 특정할 때 사용됩니다.
템플릿 모드 생성기는 main
과 client
두 가지 진입점을 기본으로 생성하며, 각 진입점은 다음과 같은 역할을 합니다:
main
진입점은 게임의 메커니즘처럼 일반적인 코드에 사용되며, ModInitializer
를 구현하는 클래스가 입력됩니다.client
진입점은 GUI처럼 클라이언트 전용 코드에 사용되며, ClientModInitializer
를 구현하는 클래스가 입력됩니다.이러한 진입점은 게임이 시작될 때 각각 실행됩니다.
아래는 게임이 시작되었을 때 메시지를 로그하는 간단한 main
진입점 구현체입니다.
public class FabricDocsReference implements ModInitializer {
// This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name.
// That way, it's clear which mod wrote info, warnings, and errors.
public static final String MOD_ID = "fabric-docs-reference";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
@Override
public void onInitialize() {
// This code runs as soon as Minecraft is in a mod-load-ready state.
// However, some things (like resources) may still be uninitialized.
// Proceed with mild caution.
LOGGER.info("Hello Fabric world!");
}
}
src/main/resources
src/main/resources
폴더는 텍스쳐, 모델, 소리처럼 모드에서 사용하는 리소스가 저장됩니다.
fabric.mod.json
파일과 모드에서 사용할 Mixin 구성 파일도 여기에 저장됩니다.
어셋 파일은 리소스 팩 파일의 구조 그대로 저장됩니다. 예를 들어, mod_block
블록의 텍스처는 assets/mod_id/textures/block/mod_block.png
에 저장될 수 있습니다.
src/client/resources
src/client/resources
폴더에는 UI 텍스처처럼 클라이언트에서만 사용되는 리소스가 저장됩니다.
src/main/java
src/main/java
폴더에는 클라이언트, 서버 모두에서 작동하는 Java 소스 코드가 저장됩니다.
src/client/java
src/client/java
폴더에는 렌더링, 블록 색상처럼 클라이언트에서만 작동하는 Java 소스 코드가 저장됩니다.