Skip to content

Commit

Permalink
feat: add base for hard-fork
Browse files Browse the repository at this point in the history
  • Loading branch information
TrainmasterHD committed Jan 3, 2025
1 parent f85ce2c commit 5f7573b
Show file tree
Hide file tree
Showing 21 changed files with 276 additions and 171 deletions.
15 changes: 10 additions & 5 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
* text=auto
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

*.sh text eol=lf
gradlew text eol=lf
*.bat text eol=crlf
# These are Windows script files and should use crlf
*.bat text eol=crlf

# Binary files should be left untouched
*.jar binary

*.jar binary
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Clean
run: ./gradlew clean
- name: Apply Patches
run: ./gradlew applyPatches --info
run: ./gradlew applyAllPatches --info
- name: Bundle
run: ./gradlew createMojmapBundlerJar --info
- name: Rename Artifact
Expand Down
59 changes: 11 additions & 48 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,53 +1,16 @@
.gradle/
build/
# Ignore Gradle project-specific cache directory
.gradle

# Eclipse stuff
.classpath
.project
.settings/
# Ignore Gradle build output directory
build

# VSCode stuff
.vscode/
/run

# netbeans
nbproject/
nbactions.xml
/cheetah-server/build.gradle.kts
/cheetah-server/src/minecraft
/paper-server
/cheetah-api/build.gradle.kts
/paper-api
/paper-api-generator

# we use maven!
build.xml

# maven
target/
dependency-reduced-pom.xml

# vim
.*.sw[a-p]

# various other potential build files
build/
bin/
dist/
manifest.mf

# Mac filesystem dust
.DS_Store/
.DS_Store

# intellij
*.iml
*.ipr
*.iws
.idea/
out/

# Linux temp files
*~

# other stuff
run/

cheetah-server
cheetah-api
paper-api-generator

!gradle/wrapper/gradle-wrapper.jar
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This is a fork of Paper tailored for the use at GommeHD.net
- Clone this repository
- Open a shell (e.g. using Git Bash on Windows)
- On Windows, make sure that `git config core.longpaths true` is set for this project
- Run `./gradlew applyPatches` to apply the patches
- Run `./gradlew applyAllPatches` to apply the patches
- Run `./gradlew createMojmapBundlerJar` to create the final jar file
- The final jar file can be found in `build/libs/cheetah-1.21.4-bundler-1.21.4-R0.1-SNAPSHOT-reobf.jar`

Expand All @@ -26,7 +26,7 @@ Thus, changes to the NMS code will not be reflected to plugins using it.
```

## How to apply changes
- First apply the patches using `./gradlew applyPatches`
- First apply the patches using `./gradlew applyAllPatches`
- Perform the changes to the code
- If you are a missing file, you can import it from NMS. For this, add a new line to `build-data/dev-imports.txt`, e.g. `minecraft net.minecraft.world.level.entity.LevelEntityGetterAdapter` to import the LevelEntityGetterAdapter. Then apply the patches again (`./gradlew applyPatches`). Keep in mind that all uncommited changes to the code will get LOST by this!
- Once all changes have been applied, switch to the subproject in your shell (`cd cheetah-server` or `cd cheetah-api`) and run `git add .`. Then, commit your changes using `git commit -m "NAME OF PATCH"`
Expand All @@ -36,7 +36,7 @@ Thus, changes to the NMS code will not be reflected to plugins using it.
## Update upstream
- Make sure all changes are committed and patches have been rebuilt
- Identify the latest commit in https://github.com/PaperMC/Paper/commits/master and copy its hash. Update `paperRef` in `gradle.properties` accordingly.
- Run `./gradlew applyPatches`
- Run `./gradlew applyAllPatches`
- Fix potential conflicts during merges and update your code to the latest version
- Run `./gradlew rebuildPatches`
- Validate that everything works and commit your changes
Expand Down
9 changes: 4 additions & 5 deletions build-data/dev-imports.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
# To import classes from the vanilla Minecraft jar use `minecraft` as the artifactId:
# minecraft net.minecraft.world.level.entity.LevelEntityGetterAdapter
# minecraft net/minecraft/world/level/entity/LevelEntityGetter.java
minecraft net.minecraft.server.dedicated.DedicatedServerProperties
minecraft net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket
minecraft net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket
#minecraft net.minecraft.world.entity.ai.behavior.GiveGiftToHero
#minecraft net.minecraft.world.level.levelgen.structure.structures.EndCityPieces
# To import minecraft data files, like the default chat type, use `mc_data` as the prefix:
# mc_data chat_type/chat.json
# mc_data dimension_type/overworld.json
#
3 changes: 3 additions & 0 deletions build-data/fork.at
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This file is auto generated, any changes may be overridden!
# See CONTRIBUTING.md on how to add access transformers.
public net.minecraft.data.registries.TradeRebalanceRegistries BUILDER
18 changes: 0 additions & 18 deletions build-data/reobf-mappings-patch.tiny

This file was deleted.

144 changes: 57 additions & 87 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,121 +1,91 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent

plugins {
java
`maven-publish`
id("io.papermc.paperweight.patcher") version "1.7.7"
java // TODO java launcher tasks
id("io.papermc.paperweight.patcher") version "2.0.0-beta.8"
}

val paperMavenPublicUrl = "https://papermc.io/repo/repository/maven-public/"
paperweight {
upstreams.paper {
ref = "54debf494f467a71c561cf8765c4f21725c99dd8"

repositories {
mavenCentral()
maven(paperMavenPublicUrl) {
content { onlyForConfigurations(configurations.paperclip.name) }
}
maven {
name = "gommeRepo"
url = uri("https://repo.gomme.dev/repository/public/")
// credentials(PasswordCredentials::class)
patchFile {
path = "paper-server/build.gradle.kts"
outputFile = file("cheetah-server/build.gradle.kts")
patchFile = file("cheetah-server/build.gradle.kts.patch")
}
patchFile {
path = "paper-api/build.gradle.kts"
outputFile = file("cheetah-api/build.gradle.kts")
patchFile = file("cheetah-api/build.gradle.kts.patch")
}
patchDir("paperApi") {
upstreamPath = "paper-api"
excludes = setOf("build.gradle.kts")
patchesDir = file("cheetah-api/paper-patches")
outputDir = file("paper-api")
}
patchDir("paperApiGenerator") {
upstreamPath = "paper-api-generator"
patchesDir = file("cheetah-api-generator/paper-patches")
outputDir = file("paper-api-generator")
}
}
}

dependencies {
remapper("net.fabricmc:tiny-remapper:0.10.3:fat")
decompiler("org.vineflower:vineflower:1.10.1")
paperclip("io.papermc:paperclip:3.0.3")
}
val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"

allprojects {
apply(plugin = "java")
subprojects {
apply(plugin = "java-library")
apply(plugin = "maven-publish")

java {
extensions.configure<JavaPluginExtension> {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
}

subprojects {
repositories {
mavenCentral()
maven(paperMavenPublicUrl)
}

dependencies {
// "testRuntimeOnly"("org.junit.platform:junit-platform-launcher")
}

tasks.withType<AbstractArchiveTask>().configureEach {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}
tasks.withType<JavaCompile> {
options.encoding = Charsets.UTF_8.name()
options.release = 21
options.isFork = true
}
tasks.withType<Javadoc> {
options.encoding = Charsets.UTF_8.name()
}
tasks.withType<ProcessResources> {
filteringCharset = Charsets.UTF_8.name()
}

repositories {
mavenCentral()
maven(paperMavenPublicUrl)
}
}

paperweight {
serverProject = project(":cheetah-server")

remapRepo = paperMavenPublicUrl
decompileRepo = paperMavenPublicUrl

usePaperUpstream(providers.gradleProperty("paperRef")) {
withPaperPatcher {
apiPatchDir = layout.projectDirectory.dir("patches/api")
apiOutputDir = layout.projectDirectory.dir("cheetah-api")

serverPatchDir = layout.projectDirectory.dir("patches/server")
serverOutputDir = layout.projectDirectory.dir("cheetah-server")
}

patchTasks.register("generatedApi") {
isBareDirectory = true
upstreamDirPath = "paper-api-generator/generated"
patchDir = layout.projectDirectory.dir("patches/generated-api")
outputDir = layout.projectDirectory.dir("paper-api-generator/generated")
tasks.withType<Test> {
testLogging {
showStackTraces = true
exceptionFormat = TestExceptionFormat.FULL
events(TestLogEvent.STANDARD_OUT)
}
}
}

//
// Everything below here is optional if you don't care about publishing API or dev bundles to your repository
//

tasks.generateDevelopmentBundle {
apiCoordinates = "net.gommehd.cheetah:cheetah-api"
libraryRepositories.set(
listOf(
"https://repo.maven.apache.org/maven2/",
paperMavenPublicUrl,
"https://repo.gomme.dev/repository/snapshots/", // This should be a repo hosting your API (in this example, 'com.example.paperfork:forktest-api')
)
)
}

allprojects {
// Publishing API:
// ./gradlew :cheetah-api:publish[ToMavenLocal]
publishing {
extensions.configure<PublishingExtension> {
repositories {
maven {
name = "gommeRepo"
url = uri("https://repo.gomme.dev/repository/snapshots/")
// See Gradle docs for how to provide credentials to PasswordCredentials
// https://docs.gradle.org/current/samples/sample_publishing_credentials.html
/*
maven("https://repo.papermc.io/repository/maven-snapshots/") {
name = "paperSnapshots"
credentials(PasswordCredentials::class)
}
}
}
}

publishing {
// Publishing dev bundle:
// ./gradlew publishDevBundlePublicationTo(MavenLocal|MyRepoSnapshotsRepository) -PpublishDevBundle
if (project.hasProperty("publishDevBundle")) {
publications.create<MavenPublication>("devBundle") {
artifact(tasks.generateDevelopmentBundle) {
artifactId = "dev-bundle"
}
*/
}
}
}
44 changes: 44 additions & 0 deletions cheetah-api/build.gradle.kts.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
--- a/paper-api/build.gradle.kts
+++ b/paper-api/build.gradle.kts
@@ -105,6 +_,18 @@
main {
java {
srcDir(generatedApiPath)
+ srcDir(file("../paper-api/src/main/java"))
+ }
+ resources {
+ srcDir(file("../paper-api/src/main/resources"))
+ }
+ }
+ test {
+ java {
+ srcDir(file("../paper-api/src/test/java"))
+ }
+ resources {
+ srcDir(file("../paper-api/src/test/resources"))
}
}
}
@@ -174,7 +_,7 @@

tasks.withType<Javadoc> {
val options = options as StandardJavadocDocletOptions
- options.overview = "src/main/javadoc/overview.html"
+ options.overview = "../paper-api/src/main/javadoc/overview.html"
options.use()
options.isDocFilesSubDirs = true
options.links(
@@ -212,11 +_,11 @@
}

// workaround for https://github.com/gradle/gradle/issues/4046
- inputs.dir("src/main/javadoc").withPropertyName("javadoc-sourceset")
+ inputs.dir("../paper-api/src/main/javadoc").withPropertyName("javadoc-sourceset")
val fsOps = services.fileSystemOperations
doLast {
fsOps.copy {
- from("src/main/javadoc") {
+ from("../paper-api/src/main/javadoc") {
include("**/doc-files/**")
}
into("build/docs/javadoc")
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/src/main/java/io/papermc/paper/advancement/AdvancementDisplay.java
+++ b/src/main/java/io/papermc/paper/advancement/AdvancementDisplay.java
@@ -27,7 +_,7 @@
*
* @return the frame type
*/
- Frame frame();
+ Frame frame(); // patch

/**
* Gets the advancement title.
2 changes: 2 additions & 0 deletions cheetah-api/src/main/java/ForkFile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
public class ForkFile {
}
Loading

0 comments on commit 5f7573b

Please sign in to comment.