Development - GregTechCEu/GregTech GitHub Wiki
Building GTCEu from Source
Building from source should be relatively straightforwards.
First you will need a Java 17 JDK. GTCEu uses a Java compiler plugin called Jabel to allow Java 17 syntax to be compiled to Java 8 bytecode. Compilation of the project will use Java 17 JDK features, but built jars will need to be run with Java 8.
Once you have cloned the project, you can pull all the dependencies with Gradle using the following command. If you are using an IDE, such as Intellij IDEA, this will automatically be performed for you.
./gradlew
After the project is fully imported, building is a single command. The build result will be located in the build/libs/
, which is located in the root of the project folder.
./gradlew build
This will produce 4 different jars.
- The Regular Jar (no suffix) is the main jar, used for a standard modded instance. It is obfuscated, so it will only function in an obfuscated/regular environment.
- The Dev Jar is equivalent to the regular built jar, except de-obfuscated. This is intended for use as a full dependency for other projects. It can be used in-game, when in a de-obfuscated environment.
- The API Jar is also intended for use as a dependency, but only contains the
api
package. It will not be usable in-game in any way without the main mod also present (via either a Dev Jar or the Regular jar). It is intended to be a smaller dependency, if not depending on thecommon
implementation. - The Sources Jar provides Sources and JavaDocs. This can be applied using your IDE to view the original sources, instead of decompiled code.
IDE Support
The primary IDE used for development of this project is Intellij IDEA, other IDEs are not tested by the developers of the project and should be considered unsupported.
Running the Game in Dev
The game can be run when de-obfuscated with the following Gradle command:
./gradlew runClient
All game instance data (similar to the .minecraft
folder's contents) can be found in the run/
directory.
A server can be run with the following as well:
./gradlew runServer
The first time the server is run, a eula.txt
will be generated in the run/
folder. This eula must be accepted, and then the server run again in order to work. You can additionally connect to the server locally using a second game instance created by runClient
, and using localhost:25565
as an IP address and port.
There are also commands to run the game in an obfuscated environment as well. This would be analogous to running a regular modded instance from a launcher.
./gradlew runObfClient
./gradlew runObfServer
Development Troubleshooting
A problem one may encounter is the following, when attempting to use runClient
or runServer
:
net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Forge Mod Loader (FML)
Caused by: java.lang.NullPointerException
at net.minecraftforge.fml.common.network.NetworkRegistry.newChannel(NetworkRegistry.java:207)
at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.registerChannel(FMLNetworkHandler.java:185)
at net.minecraftforge.fml.common.FMLContainer.modConstruction(FMLContainer.java:92)
This can be fixed by reloading Gradle. Intellij can perform this with the Gradle Reload button in the upper left corner of the Gradle tab on the far right. Otherwise, it can be performed within the shell:
./gradlew
This reloads the Forge AccessTransformers. The error occurs when the patched classes are different from the expected ones. This will mainly occur if upstream changes to the gregtech_at.cfg
file occur, and the changes are pulled.
If you see the following warning when importing the project into Intellij, you can safely ignore it. This does not affect building, and is a bug in IDEA itself. More info about the bug can be found here.
Cannot resolve resource filtering of MatchingCopyAction. IDEA may fail to build project. Consider using delegated build (enabled by default).
Future common troubleshooting techniques will be added here over time, as they are encountered. A good rule to remember is: "When in doubt, reload Gradle." The majority of build-related issues can usually be fixed by doing so. To seek further support, please contact us on discord, or make an issue on this repository.