How to decompile Java code – Project Zomboid

How to decompile Java code – Project Zomboid 1 - steamclue.com
How to decompile Java code – Project Zomboid 1 - steamclue.com

This step by step guide should make it easy to access java code and therefore increase your modding capability and speed.
 
 

Install a free decompiler: IntelliJ IDEA

 

Download

 
You can download it for from the Download section of JetBrains website – [jetbrains.com] .
 
Download the Community edition.
 
 
How to decompile Java code - Project Zomboid - Install a free decompiler: IntelliJ IDEA - D78C1845B
 

 
 

Install

 
Run the downloaded installer and during the installation select your favorite tools folder.
 
 
e.g. I downloaded the version of 2021/2/2 and my favorite tools folder on Windows is D:\Tools\
 
Therefore I’ll have D:\Tools\IntelliJ IDEA Community Edition 2021.2.2\ with the following content:
 
 
How to decompile Java code - Project Zomboid - Install a free decompiler: IntelliJ IDEA - 58BEA79E8
 

 
 

Through IntelliJ

 
You can skip most of this guide and just:
 

  • open IntelliJ
  • open Project Zomboid java directory(*) as a new IntelliJ project and it will dynamically decompile is each time you open it.

But as this will soon be a pain to wait for it over and over, I recommend calling the decompiler by yourself as described in the rest of this guide.
 
 
(*) If you installed Project Zomboid from Steam and do not know where your Steam folder is, ask google – [google.com] .
 
From there, the folder you are looking for is “Steam\steamapps\common\ProjectZomboid\zombie”. It contains plenty of folders and files with “.cla*s” suffix containing the java code you wanna decompile.
 
 
 

Install the corresponding version of the Java Developpement Toolkit

 

Download

 
Project Zomboid tends to use the most up-to-date version of the JDK that you can find on this part of oracle website – [java.net] .
 

  • Select JDK19 for B41.56 (currently in the in the Early access category).
  • Download the version matching your operating system.

 
 
How to decompile Java code - Project Zomboid - Install the corresponding version of the Java Developpement Toolkit - 347E294DD
 

 
 
­

Install

 
Extract all from the selected archive.
 
In the extraction folder you should find a jdk folder.
 
Select that folder and move it with all its content to your favorite tools folder.
 
 
e.g. I downloaded JDK19 and my favorite tools folder on Windows is D:\Tools\
 
Therefore I’ll have D:\Tools\jdk-19\ with the following content:
 
 
How to decompile Java code - Project Zomboid - Install the corresponding version of the Java Developpement Toolkit - 676763600
 

 
 
­

Ensure that version of JDK is used by your OS

 
In order to know how to change your environment variables, google it – [google.com] .
 
You will need to modify your system variable named “Path” by adding a new entry on top of all others (before).
 
The value must be the “bin” folder inside your JDK install folder.
 
In my exemple above it is:
 
 

D:\Tools\jdk-19\bin

 
 
 

Create the decompiling script and folders

 

Create the destination structure

 
First choose a directory to contain the decompiled code.
 
For the exemple below I choose D:\Dev\ProjectZomboid_Decompile\B41.56\
 
Inside, create these items so that it matches the picture below:
 

  • Create an empty text file named decompile.cmd
  • Create an empty text file named decompile_PZ.cmd
  • Create an empty folder named java

 
How to decompile Java code - Project Zomboid - Create the decompiling script and folders - 92AE7079D
 

 
 

decompile.cmd

 
Write the following line inside the file:
 
 

java -cp "D:\Tools\IntelliJ IDEA Community Edition 2021.2.2\plugins\java-decompiler\lib\java-decompiler.jar" org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler -hdc=0 -dgs=1 -rsy=1 -rbr=1 -lit=1 -nls=1 -mpm=60 %*

 
Notice that this line includes the link to you installation folder for IntelliJ.
 
In my case it is “D:\Tools\IntelliJ IDEA Community Edition 2021.2.2”
 
Change it according to your folder choice when installing IntelliJ.
 

 

decompile_PZ.cmd

 
Write the following line inside the file:
 
 

decompile.cmd D:\Tools\Steam\steamapps\common\ProjectZomboid\zombie .\java

 
Notice that this line includes the link to you installation folder for ProjectZomboid.
 
In my case it is “D:\Tools\Steam\steamapps\common\ProjectZomboid”
 
Change it according to your ProjectZomboid folder.
 
If you installed it from Steam and do not know where your Steam folder is, ask google – [google.com] .
 
 
 

Decompile and access the code

Decompile the code

 
Just call decompile_PZ.cmd.
 
It may take some time and populate you java folder while showing lines like:
 
 

INFO: Decompiling cla*s zombie/ZomboidGlobals
INFO: ... done
INFO: Decompiling cla*s zombie/ZomboidFileSystem
INFO: ... done
INFO: Decompiling cla*s zombie/ZomboidBitFlag
..

 
 
Each time Project Zomboid version changes, just copy both decompile scripts into a new B41.57 (and higher) folder, create a java subfolder and call decompile_PZ.cmd to see the code matching the new version of the game.
 
 

Access the code

 
Open the files under your java subdirectory with any Java IDE or text editor.
 
You can search them with you OS search fonctions or more powerfull external tools.
 
 

Written by Tchernobill

 
 
I hope you enjoy the How to decompile Java code – Project Zomboid guide. This is all for now! If you have something to add to this guide or forget to add some information, please let us know via comment! We check each comment manually!
 


Be the first to comment

Leave a Reply

Your email address will not be published.


*