User Tools

Site Tools


tutorial:setup

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
tutorial:setup [2019/10/22 16:54]
fudge
tutorial:setup [2020/04/27 06:25]
upcraftlp ./gradlew, not .gradlew
Line 3: Line 3:
 ===== Prerequisites ===== ===== Prerequisites =====
  
-   * A Java Development Kit (JDK) for Java 8 or newer [[https://​adoptopenjdk.net/​]] +   * A Java Development Kit (JDK) for Java 8 (recommended) ​or newer [[https://​adoptopenjdk.net/​]] 
-   * Any IDE, for example [[https://​www.jetbrains.com/​idea/​download/#​section=windows|Intellij IDEA]]+   * Any Java IDE, for example [[https://​www.jetbrains.com/​idea/​download/#​section=windows|Intellij IDEA]] ​and [[https://​www.eclipse.org/​downloads/​|Eclipse]]. You may also use any other code editors, such as [[https://​code.visualstudio.com/​|Visual Studio Code]].
  
-===== Steps =====+===== Mod Startup ​===== 
 +There are two main ways to make a new mod for Minecraft based on Fabric. You can either manually download fabric-example-mod and setup by yourself, or use automatic tools for you.
  
 +==== Manual Steps ====
    - Copy the starting files from [[https://​github.com/​FabricMC/​fabric-example-mod/​|fabric-example-mod]] (or from [[https://​github.com/​natanfudge/​fabric-example-mod-kotlin|the Kotlin version]], if you wish to use Kotlin,) excluding the ''​LICENSE''​ and ''​README.md''​ files - as those apply to the template itself, not necessarily to your mod.    - Copy the starting files from [[https://​github.com/​FabricMC/​fabric-example-mod/​|fabric-example-mod]] (or from [[https://​github.com/​natanfudge/​fabric-example-mod-kotlin|the Kotlin version]], if you wish to use Kotlin,) excluding the ''​LICENSE''​ and ''​README.md''​ files - as those apply to the template itself, not necessarily to your mod.
    - Edit ''​gradle.properties'':​    - Edit ''​gradle.properties'':​
Line 13: Line 15:
        * Make sure to update the versions of Minecraft, the mappings and the loader - all of which can be queried through [[https://​modmuss50.me/​fabric.html|this website]] - to match the versions you wish to target.        * Make sure to update the versions of Minecraft, the mappings and the loader - all of which can be queried through [[https://​modmuss50.me/​fabric.html|this website]] - to match the versions you wish to target.
        * Add any other dependencies you plan to use in ''​build.gradle''​.        * Add any other dependencies you plan to use in ''​build.gradle''​.
-   - Import the project ​to your IDE. Follow [[tutorial:​vscode_setup|these instructions]] ​to import the project to Visual Studio Code. +   - Import the build.gradle file to your IDE. You may refer to the next section for specific ​IDE's.
-   - If you would like to have the IDE run configs you can run following commands: +
-       * For IntelliJ IDEA: you should have the run configs after importing gradle.  +
-       * For Eclipse: ​''​gradlew eclipse''​.  +
-       * If you use VS Code, configurations were generated at the step 3.+
    - Happy modding!    - Happy modding!
  
 You can generate the Minecraft sources for reference (since IDEA already has a decompiler this is only useful for searching through the code) : You can generate the Minecraft sources for reference (since IDEA already has a decompiler this is only useful for searching through the code) :
- Run the ''​genSources''​ Gradle task. If your IDE doesn'​t have Gradle integration,​ then run the following command in the terminal: ''​gradlew genSources''​ (or ''​.gradlew genSources''​ on Linux/​MacOS).+ Run the ''​genSources''​ Gradle task. If your IDE doesn'​t have Gradle integration,​ then run the following command in the terminal: ''​gradlew genSources''​ (or ''​./gradlew genSources''​ on Linux/​MacOS). 
 +    
 +=== IntelliJ IDEA === 
 +If you are using IntelliJ IDEA by JetBrains, please follow these steps: 
 +    - In the IDEA main menu, select '​Import Project'​ (or File -> Open... if you already have a project open). 
 +    - Select the project'​s build.gradle file to import the project. 
 +    - After Gradle is done setting up, close (File -> Close Project) and re-open the project to fix run configurations not displaying correctly. 
 +    - (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:
 +    - Open the '​Gradle Settings'​ dialog from the Gradle tab.
 +    - Change the 'Build and run using' and 'Run tests using' fields to '​IntelliJ IDEA'.
 +    - Go to File -> Project Structure -> Project and set '​Project compiler output'​ to the '​out'​ subdirectory of your project, if it isn't set yet. This directory doesn'​t have to exist, IDEA will create it when compiling the project for the first time. (Tip: Use the '​Project Directory'​ button in the directory select dialog to quickly jump to your project directory.)
 +
 +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.
 +
 +=== 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 [[tutorial:​vscode_setup|these instructions]]
 +
 +==== Generator ====
 +You may also use [[https://​github.com/​ExtraCrafTX/​GeneratorFabricMod|GeneratorFabricMod]] by ExtraCrafTX,​ a convenient tool to automatically generate new fabric mods from template. Follow these steps:
 +  - Download latest release of GeneratorFabricMod [[https://​github.com/​ExtraCrafTX/​GeneratorFabricMod/​releases|here]] and extract them.
 +  - Make a new directory, then run a command shell there and type ''​path/​to/​GeneratorFabricMod/​bin/​GeneratorFabricMod''​.
 +  - After letting it get its dependencies,​ follow the instructions and input required information.
 +  - You're now done, just open the project folder with in your IDE.
 +
 +==== MinecraftDev IntelliJ IDEA Plugin ====
 +If you are using IntelliJ IDEA you can use Earthcomputer'​s experimental fork of the MinecraftDev plugin. This fork adds support for automatically generating Fabric projects as well as some mixin related features like inspections and generating accessors.
 +You can follow [[https://​github.com/​Earthcomputer/​MinecraftDev/​blob/​dev_new/​readme.md#​installation|these instructions]] to install the plugin.
  
 ===== Getting started ===== ===== Getting started =====
-Try [[tutorial:​items|adding an item]] or [[tutorial:​blocks|a block]]. Its also a good idea to visit [[tutorial:​applychanges|Applying changes without restarting Minecraft]]. +Try [[tutorial:​items|adding an item]] or [[tutorial:​blocks|a block]]. It's also a good idea to visit [[tutorial:​applychanges|Applying changes without restarting Minecraft]].
-===== Advice =====+
  
 +===== 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!   * 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!
-  * As Fabric is in early development,​ occasionally, with development of fabric-loom (our Gradle build plugin) issues may crop up which require ​a manual clearing (deleting) of the cache (which ​can be found in ''​.gradle/​caches/​fabric-loom''​). Those will generally be announced as they are identified.+  * 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.   * Don't hesitate to ask questions! We're here to help you and work with you to make your dream mod a reality.
  
tutorial/setup.txt · Last modified: 2020/09/18 08:48 by siglong