Understanding Patch Types
Paper uses three types of patches:sources: Per-file patches to Minecraft Java classesresources: Per-file patches to Minecraft data filesfeatures: Larger patches that modify multiple Minecraft classes for complex features
Feature patches are used for large-scale changes that can be optionally dropped during Minecraft updates. This makes updating Paper easier since these patches can be temporarily removed and reapplied later.
Modifying Per-File Minecraft Patches
This is the most common workflow when editing Minecraft files.Fixup Source Patches
Run the fixup command from the root directory:This automatically updates the per-file patches based on your changes.
Resolving Rebase Conflicts
IffixupSourcePatches encounters conflicts, you’ll need to manually resolve them:
Stash Your Changes (Optional)
If you have uncommitted changes you want to preserve:
You can restore your changes later with
git stash pop.Start Interactive Rebase
Navigate to the minecraft directory and start an interactive rebase:
If you’re unfamiliar with vim (the default editor), press
:q! and Enter to exit. Then run export EDITOR=nano before trying again for an easier editor.Mark Commit for Editing
In the editor, replace
pick with edit for the commit you want to modify (typically the first commit, paper File Patches). Save and close the editor.Adding Larger Feature Patches
Feature patches are used for substantial changes that are difficult to track in per-file patches.Create a Commit
If you have specific implementation details to document, include them in the commit message or in code comments.
Modifying Larger Feature Patches
You can modify existing feature patches using either the manual rebase method (see Resolving Rebase Conflicts) or the fixup method below.Fixup Method (Manual)
Change Pick to Fixup/Squash
forfixup: Merge changes without modifying the commit messagesorsquash: Merge changes and edit the commit message
Fixup Method (Automatic)
Create Fixup Commit
For per-file patches, use
git commit -a --fixup file. Use --squash instead of --fixup if you want to modify the commit message too.git logorgit blame- Your IDE’s git integration
- Commit subject:
git commit -a --fixup "Subject of Patch name"
Autosquash Rebase
Rebasing Your PR
When you need to update your PR with the latest changes frommain:
These steps assume
origin is your fork and upstream is the official PaperMC repository.Fix Conflicts
If there are conflicts, resolve them following the steps in Resolving Rebase Conflicts.
Ensure Patch Order (Feature Patches Only)
If your PR creates new feature patches, ensure your patch is the last commit:Option A: Rename the patch file with a high number (e.g.,
9999-Patch-to-add-some-new-stuff.patch) and re-apply patches.Option B: Run interactive rebase and move commits to the end:Access Transformers
Sometimes Vanilla code contains fields, methods, or types with insufficient visibility (e.g., private fields you need to access). Paper uses Access Transformers (ATs) to change visibility or remove final modifiers without directly patching every reference.Edit the AT File
Open
build-data/paper.at and add your access transformer.Read about the AT format in the Access Transformers documentation.
Common Gradle Commands
| Command | Description |
|---|---|
./gradlew applyPatches | Apply all patches to set up the development environment |
./gradlew fixupSourcePatches | Update per-file patches based on your changes |
./gradlew rebuildPatches | Rebuild all patches after making changes |
./gradlew runDev | Run a test server with your changes |
./gradlew publishToMavenLocal | Install Paper to your local Maven repository for testing |