Project Zomboid

Project Zomboid

Multi-Cpu Enhance
Nero 12 月 8 日 上午 11:07
B42 Installation for Linux
I decided to try and see if I could get this working on Linux and I believe I may have done it. I haven't tried the Windows version but from what I could tell on Linux, it was utilizing multiple cores and was stable.
So here is how to get it running on Linux.
First go into your Project Zomboid folder in steam, this would most likely be at "~/.local/share/Steam/steamapps/common/ProjectZomboid/projectzomboid/"

In there, you will want to make a bash file. I named mine ProjectZomboid64.sh

In this file, add the following lines
#!/bin/bash # Use directory of script as working directory cd "$(dirname "$0")" # Reset Java options unset _JAVA_OPTIONS # ----- CLASSPATH SETUP ----- PZ_CLASSPATH="./guava-23.0.jar:commons-compress-1.27.1.jar:commons-io-2.18.0.jar:istack-commons-runtime.jar:jassimp.jar:javacord-3.8.0-shaded.jar:javax.activation-api.jar:jaxb-api.jar:jaxb-runtime.jar:lwjgl.jar:lwjgl-glfw.jar:lwjgl-jemalloc.jar:lwjgl-opengl.jar:lwjgl_util.jar:lwjgl-glfw-natives-linux.jar:lwjgl-jemalloc-natives-linux.jar:lwjgl-natives-linux.jar:lwjgl-opengl-natives-linux.jar:sqlite-jdbc-3.48.0.0.jar:trove-3.0.3.jar:uncommons-maths-1.2.3.jar:imgui-binding-1.86.11-8-g3e33dde.jar:commons-codec-1.10.jar:javase-3.2.1.jar:totp-1.0.jar:core-3.2.1.jar:./" # ----- HARDWARE DETECTION ----- # Total system memory in MB total_mem=$(grep MemTotal /proc/meminfo | awk '{print int($2/1024)}') # CPU cores (physical) num_cores=$(lscpu | awk '/^Core\(s\) per socket:/ {print $4}') # CPU threads (logical) num_threads=$(nproc) # Some systems do not report physical cores correctly → fallback if [ -z "$num_cores" ] || [ "$num_cores" -eq 0 ]; then num_cores=$((num_threads/2)) fi # ----- MEMORY SELECTION ----- if [ "$total_mem" -gt 16000 ]; then MEM_MAX="10240m" MEM_MIN="4096m" elif [ "$total_mem" -gt 12000 ]; then MEM_MAX="8192m" MEM_MIN="2048m" elif [ "$total_mem" -gt 8000 ]; then MEM_MAX="6144m" MEM_MIN="2048m" else MEM_MAX="4096m" MEM_MIN="1024m" fi # ----- GC / THREADING SETTINGS ----- if [ "$num_cores" -le 2 ]; then GC_THREADS=1 CONCURRENT_THREADS=1 FJ_PARALLELISM=2 elif [ "$num_cores" -le 4 ]; then GC_THREADS=2 CONCURRENT_THREADS=2 FJ_PARALLELISM=4 elif [ "$num_cores" -le 8 ]; then GC_THREADS=4 CONCURRENT_THREADS=2 FJ_PARALLELISM=6 else GC_THREADS=6 CONCURRENT_THREADS=3 FJ_PARALLELISM=8 fi # ----- LAUNCH GAME ----- echo "Starting Project Zomboid with multicore optimizations..." echo "CPU: $num_cores cores, $num_threads threads" echo "RAM: $total_mem MB (Allocated max: $MEM_MAX)" echo "ForkJoin common parallelism: $FJ_PARALLELISM" # Linux Java location (Steam version) JAVA_BIN="./jre64/bin/java" # Launch "$JAVA_BIN" \ -Djava.awt.headless=true \ -Dzomboid.steam=1 \ -Dzomboid.znetlog=1 \ -XX:-CreateCoredumpOnCrash \ -XX:-OmitStackTraceInFastThrow \ -XX:+UseParallelGC \ -XX:ZCollectionInterval=120 \ -XX:ConcGCThreads=$CONCURRENT_THREADS \ -XX:+UnlockExperimentalVMOptions \ -XX:+AlwaysPreTouch \ -XX:+UseNUMA \ -XX:+DisableExplicitGC \ -Xmx$MEM_MAX \ -Xms$MEM_MIN \ -Djava.library.path="./linux64/:./" \ -Dguava.library.path="." \ -Djogl.disable.openglcore=false \ -Dzomboid.multithreading=true \ -Dzomboid.thread.model=worksteal \ -Dzomboid.thread.priority=high \ -Dzomboid.threadpool.size=$num_cores \ -Djava.util.concurrent.ForkJoinPool.common.parallelism=$FJ_PARALLELISM \ -cp "$PZ_CLASSPATH" \ zombie.gameStates.MainScreenState "$@"
After that, open up your terminal in the same directory. Type "chmod +x ProjectZomboid64.sh"

Then you are going to want to change the following in ProjectZomboid64.json (make a backup of it somewhere if you want)

{ "mainClass": "zombie/gameStates/MainScreenState", "classpath": [ ".", "guava-23.0.jar", "commons-compress-1.27.1.jar", "commons-io-2.18.0.jar", "istack-commons-runtime.jar", "jassimp.jar", "javacord-3.8.0-shaded.jar", "javax.activation-api.jar", "jaxb-api.jar", "jaxb-runtime.jar", "lwjgl.jar", "lwjgl-glfw.jar", "lwjgl-jemalloc.jar", "lwjgl-opengl.jar", "lwjgl_util.jar", "lwjgl-glfw-natives-linux.jar", "lwjgl-jemalloc-natives-linux.jar", "lwjgl-natives-linux.jar", "lwjgl-opengl-natives-linux.jar", "sqlite-jdbc-3.48.0.0.jar", "trove-3.0.3.jar", "uncommons-maths-1.2.3.jar", "imgui-binding-1.86.11-8-g3e33dde.jar", "commons-codec-1.10.jar", "javase-3.2.1.jar", "totp-1.0.jar", "core-3.2.1.jar" ], "vmArgs": [ "-XX:ZCollectionInterval=120", "-Djava.awt.headless=true", "-Xmx8192m", "-Xms4096m", "-XX:+UseG1GC", "-XX:ParallelGCThreads=4", "-XX:+UseNUMA", "-XX:+AlwaysPreTouch", "-XX:+DisableExplicitGC", "-Dzomboid.steam=1", "-Dzomboid.znetlog=1", "-Djava.library.path=linux64/:.", "-XX:-CreateCoredumpOnCrash", "-XX:-OmitStackTraceInFastThrow", "-Djogl.disable.openglcore=false", "-XX:+OptimizeStringConcat" ] }

Finally, go to Steam and go to your library and select Project Zomboid. From there, click the gear icon and click properties. In launch options, you are going to want to add

"/home/$USER/.local/share/Steam/steamapps/common/ProjectZomboid/projectzomboid/ProjectZomboid64.sh" %command%

where $USER will be your linux username. After that, you should be able to Start Project Zomboid and enable the MultiCPU mod and it should work from there.