Fix 1.21.x patch hooks and build from papyrus/* branches.

Correct ExperienceOrb unified-diff replacements, add ServerPlayerGameMode
anchors for older Paper layouts, and check out pre-prepared version branches
in CI instead of preparing at build time.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Sasha Baranov 2026-06-15 20:56:35 -04:00
parent cca716f57f
commit b2a2431a2b
4 changed files with 70 additions and 17 deletions

View File

@ -4,6 +4,7 @@ on:
push:
branches:
- main
- 'papyrus/*'
tags:
- 'v*'
pull_request:
@ -22,30 +23,26 @@ jobs:
matrix:
include:
- mc: '26.1.2'
paper_ref: ''
ref: 'main'
java: '25'
prepare: false
- mc: '1.21.11'
paper_ref: '1.21.11'
ref: 'papyrus/1.21.11'
java: '21'
prepare: true
- mc: '1.21.10'
paper_ref: '1.21.10'
ref: 'papyrus/1.21.10'
java: '21'
prepare: true
- mc: '1.21.8'
paper_ref: '1.21.8'
ref: 'papyrus/1.21.8'
java: '21'
prepare: true
- mc: '1.21.4'
paper_ref: '1.21.4'
ref: 'papyrus/1.21.4'
java: '21'
prepare: true
env:
ORG_GRADLE_PROJECT_org.gradle.configuration-cache: false
steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.ref }}
fetch-depth: 0
- name: JDK ${{ matrix.java }}
@ -54,12 +51,6 @@ jobs:
java-version: ${{ matrix.java }}
distribution: zulu
- name: Prepare Papyrus tree
if: matrix.prepare
run: |
PAPYRUS_SOURCE="$(git rev-parse HEAD)"
./scripts/prepare-papyrus-version.sh "${{ matrix.mc }}" "${{ matrix.paper_ref }}" "$PAPYRUS_SOURCE"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:

View File

@ -1,5 +1,5 @@
# Supported Minecraft versions for Papyrus server jar builds.
# All versions are built from the main branch; older MC versions are prepared at CI time.
# 26.1.2 builds from main; 1.21.x builds from papyrus/<version> branches.
# 1.21.1 is omitted: upstream Paper has no modern paperweight source for that release.
26.1.2

View File

@ -50,6 +50,23 @@ RULES: dict[str, list[dict]] = {
"+",
],
},
{
"match": [
"+ // Paper end - Trigger bee_nest_destroyed trigger in the correct place",
"+",
"+ return true;",
"+ // CraftBukkit end",
],
"insert_at": 4,
"lines": [
"+ // Papyrus start - integrated anticheat",
"+ if (flag && block != null) {",
"+ io.papermc.paper.anticheat.PapyrusAnticheat.onBlockBroken(this.player, block);",
"+ }",
"+ // Papyrus end - integrated anticheat",
"+",
],
},
],
"net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch": [
{
@ -207,6 +224,8 @@ RULES: dict[str, list[dict]] = {
"+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause",
],
"replace": [
"- if (this.age >= 6000) {",
"- this.discard();",
"+ if (this.age >= level().paperConfig().environment.experienceOrbDespawnRate) { // Papyrus - configurable orb despawn rate",
"+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause",
],
@ -226,6 +245,7 @@ RULES: dict[str, list[dict]] = {
" Player nearestPlayer = this.level().getNearestPlayer(this, 8.0);",
],
"replace": [
"- Player nearestPlayer = this.level().getNearestPlayer(this, 8.0);",
"+ Player nearestPlayer = this.level().getNearestPlayer(this, this.level().paperConfig().environment.experienceOrbPickupRadius); // Papyrus - configurable pickup radius",
],
},
@ -249,6 +269,7 @@ RULES: dict[str, list[dict]] = {
"+ }",
"+ // Paper - TODO some other event for this kind of merge",
"+ final double mergeRadius = level.paperConfig().entities.spawning.experienceOrbMergeRadius; // Papyrus - configurable merge radius",
"- AABB aabb = AABB.ofSize(pos, 1.0, 1.0, 1.0);",
"+ AABB aabb = AABB.ofSize(pos, mergeRadius, mergeRadius, mergeRadius);",
],
},
@ -265,6 +286,7 @@ RULES: dict[str, list[dict]] = {
"+ }",
"+ // Paper - TODO some other event for this kind of merge",
"+ final double mergeRadius = level.paperConfig().entities.spawning.experienceOrbMergeRadius; // Papyrus - configurable merge radius",
"- AABB aabb = AABB.ofSize(pos, 1.0, 1.0, 1.0);",
"+ AABB aabb = AABB.ofSize(pos, mergeRadius, mergeRadius, mergeRadius);",
],
},

View File

@ -0,0 +1,40 @@
#!/usr/bin/env bash
# Create or refresh papyrus/<mc-version> with a full prepared Papyrus tree.
set -euo pipefail
if [[ $# -lt 1 ]]; then
echo "Usage: $0 <mc-version> [paper-ref] [papyrus-source-ref]" >&2
exit 1
fi
MC_VERSION="$1"
PAPER_REF="${2:-$1}"
PAPYRUS_SOURCE_REF="${3:-origin/main}"
BRANCH="papyrus/${MC_VERSION}"
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
git fetch origin main
git fetch --depth 1 https://github.com/PaperMC/Paper.git "refs/tags/${PAPER_REF}:refs/tags/${PAPER_REF}" 2>/dev/null || true
SOURCE_SHA="$(git rev-parse "$PAPYRUS_SOURCE_REF")"
echo "==> Creating ${BRANCH} from Paper ${PAPER_REF} (overlay ${SOURCE_SHA})"
git checkout -B "$BRANCH" "$PAPYRUS_SOURCE_REF"
./scripts/prepare-papyrus-version.sh "$MC_VERSION" "$PAPER_REF" "$SOURCE_SHA"
git add -A
if git diff --cached --quiet; then
echo "No changes to commit on ${BRANCH}"
else
git commit -m "$(cat <<EOF
Papyrus ${MC_VERSION} full overlay from main.
Prepared from Paper ${PAPER_REF} with Papyrus branding, anticheat, and config.
EOF
)"
fi
git push -u origin "$BRANCH"
git checkout main
echo "==> ${BRANCH} pushed"