User Tools

Site Tools


ru:tutorial:setup

This is an old revision of the document!


Настройка среды разработки

Необходимо перед началом

  • Java Development Kit (JDK) для Java 8 (рекомендуем) или новее https://adoptopenjdk.net/
  • Любая среда разработки Java, например Intellij IDEA или Eclipse. Однако, Вы также можете использовать любые текстовые редакторы, вроде Visual Studio Code.

Первые шаги

Существует два основных способа создать мод для Minecraft, используя Fabric. Вы можете либо вручную скачать fabric-example-mod и установить его самостоятельно, или же воспользоваться автоматическим инструментарием.

Ручное управление

  1. Скопируйте начальные файлы fabric-example-mod (или версию для Kotlin, если вы хотите использовать Kotlin,), за исключением файлов LICENSE и README.md, так как они нужны только для самого шаблона и не обязательны для Вашего мода.
  2. Отредактируйте gradle.properties:
    • Установите полям archives_base_name и maven_group Ваши предпочтитаемые значения.
    • Не забудьте обновить поля версий Minecraft, маппингов и Loader, - все из них Вы можете узнать на этом сайте - чтобы они совпадали с теми, что Вы хотите.
  3. Добавьте в build.gradle иные зависимости, которые Вы планируете использовать.
  4. Импортируйте файл build.gradle в Вашу среду разработки. Вы можете взглянуть на секцию, соответствующую Вашей среде, ниже.
  5. Счастливой разработки!

Вы можете сгенерировать исходники Minecraft ради справки (так как IDEA умеет декомпилировать, это полезно только для поиска по исходному коду): Запустите задачу Gradle genSources. Если в Вашей среде разработки нет интеграции с Gradle, то запустите следующую команду в терминале: ./gradlew genSources

IntelliJ IDEA

If you are using IntelliJ IDEA by JetBrains, please follow these steps:

  1. In the IDEA main menu, select 'Import Project' (or File → Open… if you already have a project open).
  2. Select the project's build.gradle file to import the project.
  3. After Gradle is done setting up, close (File → Close Project) and re-open the project to fix run configurations not displaying correctly.
  4. (If the run configurations still don't show up, try reimporting the Gradle project from the Gradle tab in IDEA.)

Optional, but recommended: By default, IntelliJ delegates to Gradle to build the project. This is unnecessary for Fabric and causes longer build times and hotswapping related weirdness, among other problems. To make it use the builtin compiler:

  1. Open the 'Gradle Settings' dialog from the Gradle tab.
  2. Change the 'Build and run using' and 'Run tests using' fields to 'IntelliJ IDEA'.
  3. Go to File → Project Structure → Project and set 'Project compiler output' to $PROJECT_DIR$/out.

Unfortunately, it is currently impossible to set an IDE-wide default for the 'Build and run using' and 'Run tests using' options, so these steps have to be repeated for every new project.

NOTE: Don't run ./gradlew idea as it messes up with gradle and breaks develop environment.

Eclipse

If you are using Eclipse and you would like to have the IDE run configs you can run gradlew eclipse.

Visual Studio Code

If you are using VSCode by Microsoft, please follow these instructions

MinecraftDev IntelliJ IDEA Plugin

If you are using IntelliJ IDEA you can use the MinecraftDev plugin. This plugin adds support for automatically generating Fabric projects as well as some mixin related features like inspections, generating accessors/shadow fields, and copying Mixin Target References (JVM Descriptors). The plugin can be found in the IntelliJ plugin repository, so you can install it using IntelliJ's internal plugin browser by navigating to File → Settings → Plugins, then clicking the Marketplace tab and searching for Minecraft.

Generator

If you are unable to use the MinecraftDev plugin or the fabric-example-mod repo, you may also use GeneratorFabricMod by ExtraCrafTX, a convenient tool to automatically generate new fabric mods from template. Follow these steps:

  1. Download latest release of GeneratorFabricMod here and extract them.
  2. Make a new directory, then run a command shell there and type path/to/GeneratorFabricMod/bin/GeneratorFabricMod.
  3. After letting it get its dependencies, follow the instructions and input required information.
  4. You're now done, just open the project folder with in your IDE.

Getting started

Try adding an item or a block. It's also a good idea to visit Applying changes without restarting Minecraft.

Advice

  • While Fabric API is not strictly necessary for developing mods, its primary goal is to provide cross-compatibility and hooks where the game engine does not, and as such it is highly recommended! Even some of the tutorials on the wiki implicitly require Fabric API.
  • Occasionally, with development of fabric-loom (our Gradle build plugin) issues may crop up which require resetting the cache files. This can be done by running gradlew cleanloom. Running gradlew --stop can also help with a few rare issues.
  • Don't hesitate to ask questions! We're here to help you and work with you to make your dream mod a reality.

Troubleshooting

Missing sounds

Sometimes, when importing the Gradle project into an IDE, the assets might not download correctly. In this case, run the downloadAssets task manually - either using IDE's built-in menu or by simply running gradlew downloadAssets.

ru/tutorial/setup.1604681616.txt.gz · Last modified: 2020/11/06 16:53 by falseresync