Project Zomboid

Project Zomboid

33 évaluations
How to decompile Project Zomboid Java code
De Tchernobill
This step by step guide should make it easy to access java code and therefore increase your modding capability and speed.
2
   
Récompenser
Ajouter aux favoris
Favoris
Retirer des favoris
Comments
The procedure in this guide is easy, fast and requires the bare minimum time and installation.
But the decompiled code have very basic variable names (var1, var2 ..).

By using beautiful from quarantin[github.com] instead, you can achieve the same result with "beautifull" names that will help you in the long term.
Unfortunately it is made for linux and you will need a bash interface to use it properly.
Install a free decompiler: IntelliJ IDEA

Download
You can download it for from the Download section of JetBrains website[www.jetbrains.com].
Download the Community edition.



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:



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[www.google.com].
From there, the folder you are looking for is "Steam\steamapps\common\ProjectZomboid\zombie". It contains plenty of folders and files with ".class" 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[jdk.java.net].
  • Select JDK19 for B41.71 (currently in the Early access category).
  • Download the version matching your operating system.



­
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:



­
Ensure that version of JDK is used by your OS
In order to know how to change your environment variables, google it[www.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.
Make sure there aren't any spaces in the project zomboid folder path.
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
⠀⠀

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[www.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 class zombie/ZomboidGlobals INFO: ... done INFO: Decompiling class zombie/ZomboidFileSystem INFO: ... done INFO: Decompiling class zombie/ZomboidBitFlag ..

Each time Project Zomboid version changes, just copy both decompile scripts into a new B41.71 (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.

25 commentaires
Ivar le désossé 7 janv. à 5h59 
Hello, I decompiled using BeautifulJava on Windows and imported the decompiled classes into IntelliJ IDEA via Project Structure, but I don't have any code completion, which is very annoying. Did I do something wrong? Thanks.
Phil J Herman 20 déc. 2024 à 13h19 
Awesome. :)
Champy 20 déc. 2024 à 11h15 
Still works for b42, nice. Thanks Tchernobill !
LordSalsa 15 oct. 2024 à 17h24 
Anyone else click because of the discworld?
thrakkkk 3 juil. 2024 à 9h17 
Recompiling didn't work because there was 80 errors... but after a couple days of frustration I solved my issue with dirtyJOE (Java Overall Editor)! It lets you edit variables in your class file without decompiling it. Now I have custom zoom levels in PZ that match my 1080p resolution much better than the ones provided in the MoreScalesand360vision mod.
cybersys.jmr 6 mai 2024 à 10h26 
A beautiful-java tool? It is designed for this do...
GoDziO 13 févr. 2024 à 13h01 
@Nomad if youre still looking for an answer, IntelliJ by default nested itself in the Jetbrains folder, and the version is newer. Both of these differences have to be accounted for in decompile.cmd path. Also dont forget to add quotation marks around the path in decompilePZ.cmd if steam is in its default Program Files (x86) folder
Myself 27 janv. 2024 à 17h20 
how would I recompile?
Poltergeist 9 déc. 2023 à 20h46 
https://github.com/fesh0r/fernflower

here are the options explained, for those who are curious
Nomad 31 oct. 2023 à 12h00 
Both decompile_PZ.cmd and decompile.cmd shuts down after opening. Was trying to search for solution on internet but can't find anything. I would be thankfull if u could answer.