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 revisionPrevious revision
Next revision
Previous revision
tutorial:setup [2022/06/21 08:00] – [Advice] solidblocktutorial:setup [2024/04/15 00:35] (current) – update solidblock
Line 2: Line 2:
  
 ===== Prerequisites ===== ===== Prerequisites =====
-   * A Java Development Kit (JDK) for Java 17 (recommended) or newer. Visit [[https://adoptium.net/releases.html]] for installers.+   * A Java Development Kit (JDK) for Java 21 (recommended for 1.20.5) or newer. Visit [[https://adoptium.net/releases.html]] for installers.
        * If you are professional, you can obtain a JDK from [[http://jdk.java.net/]], which needs to be extracted and have system variables set up manually.        * If you are professional, you can obtain a JDK from [[http://jdk.java.net/]], which needs to be extracted and have system variables set up manually.
    * 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]].    * 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]].
Line 9: Line 9:
 ===== Mod Setup ===== ===== Mod Setup =====
 ==== Manual Steps ==== ==== Manual Steps ====
-   - Copy the starting files from [[https://github.com/FabricMC/fabric-example-mod/|fabric-example-mod]] (or from [[https://github.com/SmushyTaco/Example-Mod/|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://fabricmc.net/develop/template/|the template generator]], if you wish to use Kotlin or other featues.) 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'':
        * Make sure to set ''archives_base_name'' and ''maven_group'' to your preferred values.        * Make sure to set ''archives_base_name'' and ''maven_group'' to your preferred values.
Line 16: Line 16:
    - Import the build.gradle file to your IDE. You may refer to the next section for specific IDE's.    - Import the build.gradle file to your IDE. You may refer to the next section for specific IDE's.
    - Happy modding!    - Happy modding!
 +
 +=== Fabric Mod ID Change ===
 +As of Minecraft 1.19.2, Fabric API's mod ID has changed from ''fabric'' to ''fabric-api''. When backporting from 1.19.2 to earlier versions, you must alter the ''depends'' section of your ''fabric.mod.json'' to expect ''fabric''.
  
 === IntelliJ IDEA === === IntelliJ IDEA ===
Line 28: Line 31:
     - Open the 'Gradle Settings' dialog from the Gradle tab.     - Open the 'Gradle Settings' dialog from the Gradle tab.
     - Change the 'Build and run using' and 'Run tests using' fields to 'IntelliJ IDEA'.     - 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 ''$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. 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.
Line 46: Line 48:
  
 === Visual Studio Code === === Visual Studio Code ===
-If you are using VSCode, please follow [[tutorial:vscode_setup|these instructions]].+If you are using VSCode, please follow [[tutorial:setup:vscode|these instructions]].
  
 ===== Generating Minecraft Sources ===== ===== Generating Minecraft Sources =====
Line 54: Line 56:
  
 To generate the Minecraft source. run the ''genSources'' gradle task. To generate the Minecraft source. run the ''genSources'' gradle task.
-If your IDE doesn't have gradle integration, run the following command in the terminal: ''gradlew genSources'' (or ''./gradlew genSources'' on Linux/MacOS).+If your IDE doesn't have gradle integration, run the following command in the terminal: ''gradlew genSources'' (or ''./gradlew genSources'' on Linux/macOS).
 It can take a while depending on your computer power. It can take a while depending on your computer power.
 You may need to refresh gradle after running the task. You may need to refresh gradle after running the task.
Line 68: Line 70:
   * Keep up with the latest Loom version (which is defined in ''build.gradle'') and the Fabric Loader and Fabric API version for your mod (which is defined in ''build.gradle'' or ''gradle.properties''). Latest version can be found in [[https://fabricmc.net/develop/]]. Even the old version Minecraft is supported by latest Loom and latest Fabric Loader.   * Keep up with the latest Loom version (which is defined in ''build.gradle'') and the Fabric Loader and Fabric API version for your mod (which is defined in ''build.gradle'' or ''gradle.properties''). Latest version can be found in [[https://fabricmc.net/develop/]]. Even the old version Minecraft is supported by latest Loom and latest Fabric Loader.
   * Keep up with the latest Gradle version, which can be defined in ''gradle/wrapper/gradle-wrapper.properties''. Old version Minecraft is supported by latest Gradle.   * Keep up with the latest Gradle version, which can be defined in ''gradle/wrapper/gradle-wrapper.properties''. Old version Minecraft is supported by latest Gradle.
-    * Different Gradle versions require different Java versions. Usually latest Gradle supports the recommended Java version 17.+    * Different Gradle versions require different Java versions.
   * If you're developing mods for old version Minecraft, besides changing ''gradle.properties'', you may also need to change the Java compatibility version in ''build.gradle'' and the mixin config.   * If you're developing mods for old version Minecraft, besides changing ''gradle.properties'', you may also need to change the Java compatibility version in ''build.gradle'' and the mixin config.
   * 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.
  
 ===== Troubleshooting ===== ===== Troubleshooting =====
 +
 +==== "no usages" on every method ====
 +After running the ''genSources'' gradle task in IntelliJ IDEA, check if the sources are attached properly. Open a Minecraft .class file and click on the "Choose Sources..." button on the top right of the screen. Select the jar with "-sources" at the end (e.g. ''.gradle\loom-cache\1.20.1\net.fabricmc.yarn.1_20_1.1.20.1+build.10-v2\minecraft-project-@-merged-named-sources.jar'')
  
 ==== Missing sounds ==== ==== 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''. 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''.
  
 +==== Could not find or load class net.fabricmc.devlaunchinjector.Main: java.lang.ClassNotFoundException / "no JDK module specified" in the run config  ====
 +It seems to be a bug of Intellij IDEA since a recent update 2023.2. To fix, just delete the `.idea` folder entirely and then restart Intellij IDEA. The module will be reconstructed. You may need to specify Java versions again. If after restarting there is no run config, you can run `gradle ideaSyncTask` then check it again.
 +
 +==== java.lang.ClassNotFoundException: net.fabricmc.loader.impl.launch.knot.KnotClient / java.lang.TypeNotPresentException: Type net/minecraft/util/Identifier not present / java.lang.RuntimeException: Minecraft game provider couldn't locate the game! The game may be absent from the class path, lacks some expected files, suffers from jar corruption or is of an unsupported variety/version. ====
 +This may be because the project path contains non-ASCII characters that may cause incompatibility. Try move the project to paths without non-ASCII characters, or in the run config of "Minecraft Client" and "Minecraft Server", set "Shorten Command Line" from "@argfile (Java 9+)" to "none".
 ===== What's Next?  ===== ===== What's Next?  =====
 Create your first [[tutorial:items|item]]. Create your first [[tutorial:items|item]].
tutorial/setup.1655798454.txt.gz · Last modified: 2022/06/21 08:00 by solidblock