Overview
Paper modifies Minecraft source files through a git-based patch system. This approach enables tracking changes across Minecraft updates and maintaining a clean separation between vanilla code and Paper’s modifications.Three Patch Types
Paper uses three distinct types of patches to organize modifications:Sources (Per-File Patches)
Per-file patches modify individual Minecraft classes. These patches:- Are stored as a single large commit in
paper-server/src/minecraft - Modify one or more Minecraft source files
- Are automatically managed by the
fixupSourcePatchestask - Represent the most common type of modification
Per-file patches are combined into one commit to simplify the git history while still tracking which files changed.
Resources (Per-File Data Patches)
Resource patches modify Minecraft data files such as:- JSON configuration files
- Resource pack assets
- Data pack files
- Other non-code resources
Features (Large Multi-Class Patches)
Feature patches are used for substantial changes that:- Modify multiple Minecraft classes
- Implement complex optimizations
- Add major new functionality
- Can be optionally dropped during updates
Feature patches are kept separate because they’re harder to maintain and may need to be temporarily disabled during Minecraft version updates.
How Patches Are Structured
Thepaper-server/src/minecraft directory is a git repository with a specific commit structure:
- Base commit - Decompiled and deobfuscated vanilla Minecraft source
- Per-file patches commit - All source/resource patches combined
- Feature commits - Individual commits for each feature patch
Working with Patches
Applying Patches
To apply all patches to the Minecraft source:- Resets
paper-server/src/minecraftto the base commit - Applies per-file patches as a single commit
- Applies feature patches as individual commits
Modifying Per-File Patches
The recommended workflow for modifying Minecraft files:- Make your changes to files in
paper-server/src/minecraft - Run
./gradlew fixupSourcePatchesto automatically update patches - Run
./gradlew rebuildPatchesto finalize the changes
Resolving Rebase Conflicts
IffixupSourcePatches encounters conflicts:
- Change
picktoeditfor the “Paper File Patches” commit - Make your changes
- Run
git add . - Run
git commit --amend - Run
git rebase --continue - Run
./gradlew rebuildPatchesfrom the root directory
The
base ref always points to the vanilla Minecraft commit, serving as the rebase target.Adding Feature Patches
For large-scale changes that span multiple files:- Modify files in
paper-server/src/minecraft - Add your changes:
git add .(inside the minecraft directory) - Create a commit:
git commit -m "Your feature description" - Rebuild patches:
./gradlew rebuildPatches(from root directory)
Feature patch commits are automatically converted to patch files in the patches directory during
rebuildPatches.Why Use Feature Patches?
Feature patches are ideal for:- Complex optimizations - Multi-class performance improvements
- Optional features - Changes that can be temporarily disabled
- Experimental changes - Features still under development
- Update safety - Patches that can be dropped during Minecraft updates
Modifying Existing Feature Patches
Fixup Method (Automatic)
Manual Fixup Method
Manual Fixup Method
- Make your changes
- Create a temporary commit
- Run
git rebase -i base - Move your commit below the patch you want to modify
- Change
picktofixup(merge without message) orsquash(merge with message) - Save and complete the rebase
- Run
./gradlew rebuildPatches
Patch Formatting Standards
All modifications to vanilla Minecraft files must be marked with comments:Single-line changes
Multi-line changes
These comments are critical for tracking changes across files and remembering their purpose years later.
Import Handling
When adding new imports to vanilla Minecraft classes:- Prefer fully qualified names for types used infrequently
- Add imports with comments if a type is used many times
- Avoid import section conflicts by using FQN when possible
Gradle Tasks Reference
| Task | Purpose |
|---|---|
applyPatches | Apply all patches to Minecraft source |
rebuildPatches | Convert commits back to patch files |
fixupSourcePatches | Automatically update per-file patches |