Code Monkey home page Code Monkey logo

pz-zmod's Introduction

ZomboidMod

release last-commit License chat

ZomboidMod is a compact mod development environment for Project Zomboid.

It is essentially a wrapper for you mod that enables powerful IDE features and improves your modding workflow. With a collection of Gradle scripts it helps automate the process of setting up, assembling and deploying your project.

Introduction

Whether you are a creating textures, models, maps or writing code you are working with often large and complex collections of files. These files need to be interpreted, and (in case of mod files) version controlled. Since we are human beings, we are not nearly as good at interpreting and storing raw data as machines are. This is why we need their help through advanced tools such as Git and IDE's. Git helps manage our mod versions, while an IDE provides powerful features to increase efficiency, offer code assistance, and make development more enjoyable.

  • Increased efficiency means an overall higher mod quality.
  • Code analysis helps spot bugs and avoid lengthy debugging sessions.
  • Code navigation helps quickly find what we are looking for saving us time and energy.
  • More enjoyable workflow brings more motivation used to create amazing mods.

ZomboidMod serves as an umbrella for these tools, connecting everything you need in one system.

Features

  • Decompiles and packages game classes to expose game engine code.
  • Uses ZomboidDoc to compile a readable and always up-to-date modding Lua library.
  • Compact workspace that can be used straight out of the box.
  • Fully automated project changelog generation.
  • Create mod distributions with a click of a button.
  • Easy installation steps for enabling advanced features.
  • Comes pre-configured for use with Git.
  • Fully integrates with IntelliJ IDEA.

Where do I get it?

Download the latest release from the repository.

Note that you should not clone the repository and use it as a template. Instead, obtain the latest release and follow the installation instructions.

Installation

Notes

  • Little question marks are hyperlinks that reveal more information when you hover over them.
  • Lines that start with an arrow icon can be expanded to reveal more information.

Requirements

Setup

  • Download the latest release from the repository.

  • Extract the release archive in your local mod root directory (overwrite if updating).

  • Make sure the root directory follows project naming standards:

    • Project name has to be all lower-case.
    • Project name has to start with pz- prefix.
    • Use dashes instead of whitespace and underscore characters.
  • Open the project as a Gradle project with Intellij IDEA?.

  • Ensure project SDK is set to JDK 8?.

  • Initialize mod by running initializeMod run configuration?.
  • Prepare workspace by running setupWorkspace run configuration?.

  • Reload Gradle project?.

  • Attach decompiled sources to classes.
    • Open project structure - File -> Project Structure...
    • Open modules -> main -> Dependencies panel.
    • Find and select zomboid-<version>.jar dependency.
    • Click the little pencil icon to edit depdendency properties.

    You should now be in the window called Configure Module Library.

    • Click the little plus icon (Alt + Insert) to attach files.
    • In the new explorer window that just popped up find and select compiled sources which should be in ./lib/zomboid-<version>-sources.jar in project root directory.
    • Click OK in all open windows to save and apply settings.

License

It is important to license your project with an appropriate open source license to ensure others have the right to copy, distribute or modify your work without being at risk of take-downs, shake-downs, or litigation.

Learn what happens when you choose not to license your project.

ZomboidMod distributions contain a template MIT license for your project to use. Keep in mind that you can choose to license your project under a different license at any point in time. To apply the template license provided in the distribution to your project follow these steps:

  • Update copyright in LICENSE.txt to include the current year and your name:

      Copyright (c) [year] [fullname]
    
  • Update copyright in README.md under 'License' section to include your name and (optionally) a link to your Github profile, personal website, or another place online you can be reached:

      MIT © [Yourname](https://github.com/username)
    

Note that you can choose to include your full name or your Github username. It is a matter of preference and legally speaking both should be valid as long as you can prove the identity provided represents you.

Discord integration

If you are a Discord user and want to let the world know that you are working hard on your Project Zomboid mods you can do so with IntelliJ IDEA Discord integration.

Installation

Note that you need to write mod metadata (mod.info) before creating Discord integration so that the integration displays correct project name and description. However the integration is automatically setup after running setupWorkspace so you don't have to worry about that.

You can rerun the task at any time if you accidentally delete the configuration file.?

How to use

Search scopes

IDEA scopes are sets of files you can search in various contexts. ZomboidMod generates custom search scopes to help you find code usages or references helpful in modding the game:

  • mod-lua - All Lua files in media directory.
  • mod-media - All files in media directory.
  • pz-java - Project Zomboid Java classes.
  • pz-lua - Project Zomboid Lua classes.

Learn more about searching everywhere in IntelliJ IDEA.

Changelog

If you are not familiar with what a changelog is I recommend reading keep a changelog.

ZomboidMod uses github-changelog-generator to generate standardized changelogs. Your should generate a changelog after each release, when all issues on project Github repository have been closed with a merge commit.

Before generating a changelog you need to do the following:

  • Make sure you have designated repository url in mod.info file.

  • Generate a Github token and store it in local.properties:

     cg.token=<your-40-digit-token>

Then simply run generateChangelog task to generate project changelog.

Distribution

Before others can download your mod you need to assemble and upload the mod distribution.

Assembling distributions is a process of packaging everything your mod needs to run in production environment in compressed archives. Anything not needed in production environment (such as gradle files) needs to be excluded from distributions.

ZomboidMod handles this for you. Just run assembleModDist and a distribution archive matching the current project version will be created in build/distributions directory.

List of tasks

Setup tasks

  • createDiscordIntegration - Show IDEA project in Discord via rich presence.
  • createLaunchRunConfigs - Create game launch run configurations.
  • createModSearchScopes - Create IDEA search scopes for mod files.
  • initLocalProperties - Initialize local project properties.

Documentation tasks

  • generateChangelog - Generate a project changelog.

Distribution tasks

  • assembleModDist - Assembles the mod distributions.
  • modDistZip - Bundles the project as a distribution.

Mod tasks

  • applyModTemplate - Apply Project Zomboid mod template.
  • createModStructure - Create default mod directory structure.
  • initModInfo - Initialize mod metadata information.
  • loadModInfo - Load mod metadata information.
  • saveModInfo - Save mod metadata to file.
  • showModInfo - Print mod metadata information.

Zomboid tasks

  • annotateZomboidLua - Annotate vanilla Lua with EmmyLua.
  • compileZomboidLua - Compile Lua library from modding API.
  • updateZomboidLua - Run ZomboidDoc to update compiled Lua library.
  • decompileZomboid - Decompile Project Zomboid classes.
  • zomboidClasses - Assembles Project Zomboid classes.
  • zomboidJar - Assembles a jar archive containing game classes.
  • zomboidLuaJar - Assembles a jar containing compiled Lua classes.
  • zomboidSourcesJar - Assembles a jar containing decompiled game sources.
  • zomboidVersion - Read Project Zomboid game version.

Discussion

  • Feel free to open a ticket if you have any problems, questions or suggestions regarding the project.
  • You are also welcome to join us on Discord to talk about modding and follow community projects.

License

MIT © Matthew Cain

pz-zmod's People

Contributors

matshou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

xenoloaf

pz-zmod's Issues

Sync distribution with Steam workshop

Developing mods built with gradle under VCS for the Steam workshop is difficult as everything located in the workshop staging area gets pulled and packaged as part of the mod. This includes project build, config and VCS files.

To resolve this, distributions installed with installDist should be synced with the designated Steam workshop directory to allow modders to keep their mod dev environment separate from workshop directory.

Assembling mod distributions

Creating mod distributions should be automated with gradle distribution plugin.

There are currently tasks that assemble classes (mediaClasses) and resources (processMediaResources), they just need to be packed together with other content in a distribution archive.

Steam mods not loading in game

The mods I have installed via Steam are not appearing in the mods menu.

It should be noted that the game has three directories for mods: Local-Mods, Workshop-Upload, and Workshop-Download.

Local-Mods = C:\Users\<name>\Zomboid\mods
Workshop-Upload = C:\Users\<name>\Zomboid\Workshop
Workshop-Download = D:\Steam\steamapps\workshop\content

Error when decompiling with Java 8 (UnsupportedClassVersionError)

This exception occurs because the decompiler jar distributed with IntelliJ IDEA has been compiled with a higher Java version.

Stacktrace:

java.lang.UnsupportedClassVersionError: org/jetbrains/java/decompiler/main/decompiler/ConsoleDecompiler has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601)
Error: A JNI error has occurred, please check your installation and try again

Library sources do not match bytecode

Decompiled sources do not match bytecode for output of zomboidClasses.

When sources are attached to classes in a jar that resulted as output from zomboidJar the error does not occur.

Console log highlighting

Distribution should include a Grep configuration that highlights log entries according to preset groups. Aside from Highlighting warning and errors, Grep should also highlight all logs printed from mod scripts (provided they use the right format).

2021-02-22_205414

Initialize mod.info with console

Mod properties should not have to be manually updated by users.
They should be able to provide values for each property through console inputs.

Document setting path variable

IDEA path variable $PZ_DIR_PATH needs to be set in order to launch game via run configurations.
This should be documented in Setup section of README.md.

Cannot run "initializeMod" run configuration :: Caused by: java.lang.NoSuchMethodException: No such accessible method: getGameVersion() on object: zombie.core.Core

Reproduction Steps:

  • Follow setup procedure with version 2.4.0 up to the intellij setup
  • In Intellij, Choose > File > Project Structure
  • Set Project SDK to corretto-1.8
  • Set Project language level to sdk default ( 8 - Lambdas, type annotations etc.)
  • Run initializeMod
  • Enter Project Zomboid Path
  • Enter intellij
  • Get error Caused by: java.lang.NoSuchMethodException: No such accessible method: getGameVersion() on object: zombie.core.Core

Create project README

The current project README does not give any information on what this project is about, it is a template for building a mod.
This version of the readme should be the one included in the distribution, but the repo one should be instructional.

Discord rich presence

Create IDEA Discord rich presence configuration so users can display their modding activity.

Task to apply mod template

Current distribution is not including ZomboidMod README.md or LICENSE.txt. Distribution should not be a out-of-the box template, but rather have a task to set it up which can be included in an existing run configuration.

Gradle sync fails with IDEA

Gradle auto-build action fails when refreshing build before initializing mod properties.

FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\Yooks\Documents\GitHub\project-zomboid\pz-zmod\setup.gradle' line: 35

* What went wrong:
A problem occurred evaluating script.
> Unable to find local project property gameDir

Execution failed for task ':compileZomboidLua'.

Hi everyone, when launching the gradle task "setupWorkspace" it is unable to conclude due to the error reported here:
Execution failed for task ':compileZomboidLua'.

Process 'command 'C:\Program Files\Java\jre1.8.0_311\bin\java.exe'' finished with non-zero exit value 1
Any suggestions?

Dynamic game version property

Property game_version defined in gradle.properties should be dynamically set according to actual game version.
We can use version command from ZomboidDoc to get current game version.

initModInfo task failed on Could not get resource 'https://git.io/JqJiC'

  • Environment:
    Windows 11, Intellij IDEAC 2023.2.5, adoptium jdk8u392, in a restricted network but has a proxy tool
  • How it went wrong:
    Downloaded latest release, follow the instruction and got stuck on this.
FAILURE: Build failed with an exception.

* Where:
Script 'D:\Projects\Mod\ProjectZomboid\pzarcade\distribution.gradle' line: 5

* What went wrong:
A problem occurred evaluating script.
> Could not get resource 'https://git.io/JqJiC'.
   > Could not GET 'https://git.io/JqJiC'.
      > Connect to git.io:443 [git.io/128.242.240.218, git.io/2a03:2880:f10a:83:face:b00c:0:25de] failed: Connection timed out: connect

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 42s

Support for modular mod structure

Project Zomboid supports modular mod structures for Steam workshop mods.
Each mod uploaded to the workshop can contain other mods that can then be toggled on and off in the game mod menu.

Currently zmod does not support this modular structure and some features will not work.

Run ZomboidDoc on new versions

ZomboidMod should store the current version of ZomboidDoc and run all associated tasks when dependency updates version.

runZomboidDoc config fails with java version error

Running with fresh install and default settings against build 41 gives an error like:

zombie/Lua/LuaManager has been compiled by a more recent version of the Java Runtime

Changing the following line in zdoc.gradle (176):

		languageVersion = JavaLanguageVersion.of(8)

to

		languageVersion = JavaLanguageVersion.of(15)

fixes the issue for me. Not sure if 15 is the right version to pick but it gets the job to run happily and autocomplete works like a charm.

Set language level for gradle JVM

Currently the setup is relaying on users to properly set their JDK in project properties. This can be improved by using gradle toolchains which allow us to properly designate which JDK we want the project to use. If the designated JDK is not installed locally, it will be downloaded, automating things for users.

Changelog repo user configuration

Project properties that define repository information for generateChangelog task need to be automatically configured from user input. The best way to get repo.owner and repo.name would be from url property in mod.info file.

Automate dev environment creation

Tasks that need to be executed in a particular order to create a dev environment from scratch should be executed under a single task to make it easier for new users to set everything up with just running one or two gradle tasks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.