A simple example mod for ZombieBuddy that demonstrates how to create a patches-only mod without requiring a main class.
If you find this example helpful or enjoy using ZombieBuddy, consider supporting the developer with a coffee!
This mod displays "Hello World from ZBHelloWorld!" text on the main menu screen by patching the game's MainScreenState.renderBackground() method.
- ✅ Patches-only mod: No Main class required - demonstrates automatic patch discovery from package
- ✅ Simple example: Shows how to use
@Patchannotations - ✅ UI patching: Demonstrates patching game UI rendering methods
- Prerequisites: You must have ZombieBuddy installed and configured first
- Enable the mod: Enable ZBHelloWorld in the Project Zomboid mod manager
- Launch the game: You should see "Hello World from ZBHelloWorld!" text in the top-left corner of the main menu
This mod demonstrates a patches-only approach - it doesn't require a Main class. ZombieBuddy automatically discovers and applies @Patch annotated classes from the package specified in javaPkgName.
require=\ZombieBuddy
javaJarFile=media/java/client/build/libs/client.jar
javaPkgName=me.zed_0xff.zb_hello_worldNotice that there's no Main class! The javaPkgName entry specifies the package where patches are located. ZombieBuddy will automatically discover and apply all @Patch annotated classes in that package.
import me.zed_0xff.zombie_buddy.Patch;
@Patch(className = "zombie.gameStates.MainScreenState", methodName = "renderBackground")
public class Patch_MainScreenState {
@Patch.OnExit
public static void exit() {
TextManager.instance.DrawString(UIFont.Medium, 0, 0,
"Hello World from ZBHelloWorld!", 1.0, 1.0, 1.0, 1.0);
}
}This patch:
- Targets the
renderBackground()method inMainScreenState - Uses
@Patch.OnExitto execute code after the method completes - Draws text on the screen using the game's
TextManager
-
Navigate to the Java project directory:
cd 42/media/java/client -
Build the JAR:
gradle build
-
The JAR will be created at
build/libs/client.jar
ZBHelloWorld/
├── 42/
│ ├── mod.info
│ └── media/
│ ├── java/
│ │ └── client/
│ │ ├── build.gradle
│ │ ├── src/
│ │ │ └── Patch_MainScreenState.java
│ │ └── build/
│ │ └── libs/
│ │ └── client.jar
│ └── lua/
│ └── client/
│ └── ZBHelloWorld.lua
└── README.md
This mod serves as a simple example for learning ZombieBuddy. For more information:
- ZombieBuddy Framework: See the ZombieBuddy repository for the framework source code and detailed documentation
- GitHub Repository: https://github.com/zed-0xff/ZBHelloWorld
- ZombieBuddy Framework: https://github.com/zed-0xff/ZombieBuddy - The framework this mod is built on
Other mods built with ZombieBuddy:
- ZBetterWorkshopUpload: Filters unwanted files from Steam Workshop uploads and provides upload previews
- ZBMacOSHideMenuBar: Fixes the macOS menu bar issue in borderless windowed mode
- ZBBetterFPS: Optimizes FPS by reducing render distance
See LICENSE file for details.
zed-0xff