If you have trouble with the tutorial you can contact me on discord Konijima#9279
or open an issue.
If you have suggestion you can fork and create a pull request.
Hopefully I made this as easy as possible to understand.
- Easy and fast source decompilation
- Intellisense using global libraries
- Easy source update
- Quick search Java and Lua source
Windows | MacOS | Linux |
---|
Install the IDE on your computer. Find resource online how to install on your specific OS if needed.
Install Capsid and run the configuration.
2) Setup the new project
We will install Capsid in this new project to get the jar libraries and decompiled source.So first, select Groovy & Gradle. Then make sure to use Java 17, it should be default when installing IntelliJ.
![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/SetupCapsid_createNewProject_groovygradle.png?raw=true)
3) Installing Capsid with build.gradle
Once the project is set, it should automatically open build.gradle.Add this line to the plugins table
id 'io.pzstorm.capsid' version '0.4.2'
![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/SetupCapsid_createNewProject_addCapsid.png?raw=true)
Add this line to
settings.gradle
plugins { id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0' }
Then click on the Load Gradle Icon or press Ctrl + Shift + O to apply the changes.
Note: Make sure you're using Gradle version 7 (look in
gradle/wrapper/gradle-wrapper.properties
)
5) Create Run Configurations
Expand the Tasks > build setup in the tree view.Double click createRunConfigurations task to execute it.
![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/SetupCapsid_createNewProject_createRunConfiguration.png?raw=true)
6) Enter path to game installation directory
During the create run configuration you will be prompt to enter the game installation directory.Find and paste the full path to where the game is installed on your machine.
This should be the same directory that contains the executable to run the game.
![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/SetupCapsid_setGameInstallDir.png?raw=true)
Then press enter and wait for the task to complete.
BUILD SUCCESSFUL in 9s 2 actionable tasks: 2 executed 1:50:45 PM: Execution finished 'createRunConfigurations'.In the case that you made a mistake, you can delete the file local.properties and run the task again.
7) Install Emmylua plugin
Select File > Settings...![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/install_emmylua_1.png?raw=true)
Then go to Plugins and search for Emmylua.
![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/install_emmylua_2.png?raw=true)
Install it and check the documentation to learn how it work
Let's get decompiling in a single step.
1) Run Setup Workspace config
Select the new configuration setupWorkspace created from the previous step then Run it.![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/SetupCapsid_createNewProject_setupWorkspace.png?raw=true)
This step will take some time (a couple minutes), it will decompile, annotate and create everything we need to start making mods.
It will run these tasks in this order
zomboidJar, decompileZomboid, annotateZomboid, compileZomboid, zomboidLuaJarWhen everything is complete you should see
BUILD SUCCESSFUL in 217ms 1 actionable task: 1 executed 2:06:28 PM: Execution finished.
Let's organise a little bit before we get to modding.
1) Know the stuff that you need
So first of all, there is a couple things that we will need.![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/SetupCapsid_stuffWeWant.png?raw=true)
build > generated > sources
This directory contains both the java and lua source code. We don't need it but we might want it to do quick search using any search tools that we prefer.
lib
This directory contains the 3 jar files that we will need to get the full power out of IntelliJ while developping mods.
2) Create a directory to keep it organized
Anywhere in your computer, create a directory named zomboid-decompiled.In that directory create a new directory named with the current version of the game.
Copy the 3 jar files into that new directory and optionally copy the build/generated/sources directory.
You can rename the files to append the version for later.
![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/SetupCapsid_organize.png?raw=true)
Alright we are almost there, you will be typing code soon i swear.
1a) Create a new mod
Select File > New > Project...![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/CreateNewMod1.png?raw=true)
Now select the zomboid local workshop directory and enter your new mod name.
![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/CreateNewMod2.png?raw=true)
You should now have an empty project ready to be setup.
![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/CreateNewMod3.png?raw=true)
You can delete the src directory and create your default workshop mod structure.
![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/CreateNewMod4.png?raw=true)
1b) Use an existing mod
Select File > Open...![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/ExistingMod1.png?raw=true)
Select the mod you want to open with IntelliJ and click Trust Project when prompted.
![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/ExistingMod2.png?raw=true)
Press Ctrl + S to save the project and you are ready for the final step.
2) Setup the global libraries (per version)
Select File > Project Structure...![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/setup_libs_1.png?raw=true)
Then select Platform Settings > Global Libraries
![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/setup_libs_2.png?raw=true)
Press the + icon and add both zdoc-lua.jar and zomboid.jar to your global libraries.
Then select zomboid.jar and press the other + icon and add zomboid-sources.jar.
![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/setup_libs_3.png?raw=true)
3) Setup the mod project modules
Select File > Project Structure...![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/setup_libs_1.png?raw=true)
Then select Project Settings > Modules then Dependencies tab.
![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/project_modules.png?raw=true)
Add both global libraries.
![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/project_modules_2.png?raw=true)
Check both library boxes and apply.
![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/project_modules_3.png?raw=true)
You now have intellisense working in your project.
![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/Intelisense_1.png?raw=true)
Now you can search into the source and figure for yourself how things work.
Search in the Java source code
Right-click the zomboid.jar root library in the external libraries part of your project file tree.![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/search-java.png?raw=true)
Then click Find in files
Search in the Lua source code
Right-click the zdoc-lua.jar root library in the external libraries part of your project file tree.![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/search-lua.png?raw=true)
Then click Find in files
But what if PZ updated to a new version?
Decompiling a new PZ version
Make sure your Project Zomboid game has been updated.Open the capsid project we used for decompiling the first time.
Run the setupWorkspace configuration again.
![](https://github.com/Konijima/PZ-Libraries/raw/Tutorial-v2/Images/SetupCapsid_createNewProject_setupWorkspace.png?raw=true)