mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
Leaf 1.21.4
WIP
This commit is contained in:
10
.github/workflows/auto-update.yml
vendored
10
.github/workflows/auto-update.yml
vendored
@@ -45,23 +45,23 @@ jobs:
|
||||
- name: Grant execute permission for gradlew
|
||||
run: |
|
||||
cd Leaf
|
||||
git config --global user.name "Dreeam"
|
||||
git config --global user.name "Dreeam-qwq"
|
||||
git config --global user.email 61569423+Dreeam-qwq@users.noreply.github.com
|
||||
chmod +x gradlew
|
||||
|
||||
- uses: actions/setup-java@main
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: 21
|
||||
java-version: '21'
|
||||
|
||||
- name: Running tests before push
|
||||
run: |
|
||||
cd Leaf
|
||||
if ! git diff --quiet; then
|
||||
echo "Running tests...."
|
||||
./gradlew applyPatches
|
||||
./gradlew createMojmapPaperclipJar
|
||||
./gradlew rebuildPatches
|
||||
./gradlew applyAllPatches
|
||||
./gradlew build
|
||||
./gradlew rebuildAllServerPatches
|
||||
fi
|
||||
|
||||
- name: Check for changes and write to repository
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
name: Build Leaf 1.21.3
|
||||
name: Build Leaf 1.21.4
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "ver/1.21.3" ]
|
||||
branches: [ "dev/1.21.4" ]
|
||||
pull_request:
|
||||
branches: [ "ver/1.21.3" ]
|
||||
branches: [ "ver/1.21.4" ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@main
|
||||
- uses: gradle/actions/wrapper-validation@main
|
||||
- name: Set up JDK
|
||||
uses: graalvm/setup-graalvm@main
|
||||
with:
|
||||
@@ -33,8 +32,8 @@ jobs:
|
||||
|
||||
- name: Rename Paperclip Jar
|
||||
run: |
|
||||
mv build/libs/leaf-paperclip-1.21.3-R0.1-SNAPSHOT-mojmap.jar ./leaf-1.21.3-mojmap.jar
|
||||
mv build/libs/leaf-paperclip-1.21.3-R0.1-SNAPSHOT-reobf.jar ./leaf-1.21.3-reobf.jar
|
||||
mv leaf-server/build/libs/leaf-paperclip-1.21.4-R0.1-SNAPSHOT-mojmap.jar ./leaf-1.21.4-mojmap.jar
|
||||
mv leaf-server/build/libs/leaf-paperclip-1.21.4-R0.1-SNAPSHOT-reobf.jar ./leaf-1.21.4-reobf.jar
|
||||
|
||||
- name: Publish API
|
||||
if: github.event_name != 'pull_request'
|
||||
@@ -44,18 +43,19 @@ jobs:
|
||||
export REPO_USER=${{ secrets.REPO_USER }}
|
||||
echo "REPO_PASSWORD=${{ secrets.REPO_PASSWORD }}" >> $GITHUB_ENV
|
||||
export REPO_PASSWORD=${{ secrets.REPO_PASSWORD }}
|
||||
./gradlew :leaf-api:publish
|
||||
./gradlew publishDevBundlePublicationToLeafRepository -PpublishDevBundle=true
|
||||
./gradlew publish
|
||||
# TODO
|
||||
# ./gradlew publishDevBundlePublicationToLeafRepository -PpublishDevBundle=true
|
||||
|
||||
- name: Upload Leaf
|
||||
uses: actions/upload-artifact@main
|
||||
with:
|
||||
name: Leaf 1.21.3
|
||||
path: ./leaf-1.21.3-*.jar
|
||||
name: Leaf 1.21.4
|
||||
path: ./leaf-1.21.4-*.jar
|
||||
|
||||
- name: Rename Paperclip Jar
|
||||
- name: Rename Leaf Jar
|
||||
run: |
|
||||
mv ./leaf-1.21.3-mojmap.jar ./leaf-1.21.3.jar
|
||||
mv ./leaf-1.21.4-mojmap.jar ./leaf-1.21.4.jar
|
||||
|
||||
# TODO: marvinpinto/action-automatic-releases is archived, need to find new one
|
||||
# Notes: create releases every time, similar changelogs with this, all commits for changelogs
|
||||
@@ -63,8 +63,8 @@ jobs:
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: marvinpinto/action-automatic-releases@master
|
||||
with:
|
||||
title: "Leaf 1.21.3"
|
||||
automatic_release_tag: "ver-1.21.3"
|
||||
title: "Leaf 1.21.4"
|
||||
automatic_release_tag: "ver-1.21.4"
|
||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
files: "./leaf-1.21.3.jar"
|
||||
prerelease: false
|
||||
files: "./leaf-1.21.4.jar"
|
||||
prerelease: true
|
||||
11
.gitignore
vendored
11
.gitignore
vendored
@@ -22,7 +22,10 @@ build-data
|
||||
patches/todo
|
||||
run
|
||||
|
||||
Leaf-API
|
||||
Leaf-MojangAPI
|
||||
Leaf-Server
|
||||
paper-api-generator
|
||||
leaf-api/build.gradle.kts
|
||||
leaf-server/build.gradle.kts
|
||||
leaf-server/src/minecraft
|
||||
gale-api
|
||||
gale-server
|
||||
paper-api
|
||||
paper-server
|
||||
|
||||
138
Leaf-API/build.gradle.kts.patch
Normal file
138
Leaf-API/build.gradle.kts.patch
Normal file
@@ -0,0 +1,138 @@
|
||||
--- a/gale-api/build.gradle.kts
|
||||
+++ b/gale-api/build.gradle.kts
|
||||
@@ -12,8 +_,10 @@
|
||||
val annotationsVersion = "26.0.1"
|
||||
val bungeeCordChatVersion = "1.20-R0.2"
|
||||
val adventureVersion = "4.18.0"
|
||||
-val slf4jVersion = "2.0.9"
|
||||
-val log4jVersion = "2.17.1"
|
||||
+// Leaf start - Bump Dependencies
|
||||
+val slf4jVersion = "2.0.16"
|
||||
+val log4jVersion = "2.24.3"
|
||||
+// Leaf end - Bump Dependencies
|
||||
|
||||
val apiAndDocs: Configuration by configurations.creating {
|
||||
attributes {
|
||||
@@ -41,9 +_,9 @@
|
||||
dependencies {
|
||||
|
||||
// api dependencies are listed transitively to API consumers
|
||||
- api("com.google.guava:guava:33.3.1-jre")
|
||||
+ api("com.google.guava:guava:33.4.0-jre") // Leaf - Bump Dependencies
|
||||
api("com.google.code.gson:gson:2.11.0")
|
||||
- api("org.yaml:snakeyaml:2.2")
|
||||
+ api("org.yaml:snakeyaml:2.3") // Leaf - Bump Dependencies
|
||||
api("org.joml:joml:1.10.8") {
|
||||
isTransitive = false // https://github.com/JOML-CI/JOML/issues/352
|
||||
}
|
||||
@@ -54,6 +_,7 @@
|
||||
api("org.apache.logging.log4j:log4j-api:$log4jVersion")
|
||||
api("org.slf4j:slf4j-api:$slf4jVersion")
|
||||
api("com.mojang:brigadier:1.3.10")
|
||||
+ api("io.sentry:sentry:8.0.0-rc.3") // Pufferfish
|
||||
|
||||
// Deprecate bungeecord-chat in favor of adventure
|
||||
api("net.md-5:bungeecord-chat:$bungeeCordChatVersion-deprecated+build.19") {
|
||||
@@ -68,29 +_,37 @@
|
||||
apiAndDocs("net.kyori:adventure-text-serializer-plain")
|
||||
apiAndDocs("net.kyori:adventure-text-logger-slf4j")
|
||||
|
||||
- api("org.apache.maven:maven-resolver-provider:3.9.6") // make API dependency for Paper Plugins
|
||||
- compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.18")
|
||||
- compileOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.18")
|
||||
+ // Leaf start - Bump Dependencies
|
||||
+ api("org.apache.maven:maven-resolver-provider:3.9.9") // make API dependency for Paper Plugins
|
||||
+ compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.22") // Dreeam TODO - Update to 2.0.1
|
||||
+ compileOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.22") // Dreeam TODO - Update to 2.0.1
|
||||
+ // Leaf start - Bump Dependencies
|
||||
|
||||
// Annotations - Slowly migrate to jspecify
|
||||
val annotations = "org.jetbrains:annotations:$annotationsVersion"
|
||||
compileOnly(annotations)
|
||||
testCompileOnly(annotations)
|
||||
|
||||
- val checkerQual = "org.checkerframework:checker-qual:3.33.0"
|
||||
+ val checkerQual = "org.checkerframework:checker-qual:3.48.4" // Leaf - Bump Dependencies
|
||||
compileOnlyApi(checkerQual)
|
||||
testCompileOnly(checkerQual)
|
||||
|
||||
api("org.jspecify:jspecify:1.0.0")
|
||||
|
||||
// Test dependencies
|
||||
- testImplementation("org.apache.commons:commons-lang3:3.12.0")
|
||||
- testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
|
||||
- testImplementation("org.hamcrest:hamcrest:2.2")
|
||||
- testImplementation("org.mockito:mockito-core:5.14.1")
|
||||
+ // Leaf start - Bump Dependencies
|
||||
+ testImplementation("org.apache.commons:commons-lang3:3.17.0")
|
||||
+ testImplementation("org.junit.jupiter:junit-jupiter:5.11.4")
|
||||
+ testImplementation("org.hamcrest:hamcrest:3.0")
|
||||
+ testImplementation("org.mockito:mockito-core:5.15.2")
|
||||
testImplementation("org.ow2.asm:asm-tree:9.7.1")
|
||||
- mockitoAgent("org.mockito:mockito-core:5.14.1") { isTransitive = false } // configure mockito agent that is needed in newer java versions
|
||||
+ mockitoAgent("org.mockito:mockito-core:5.15.2") { isTransitive = false } // configure mockito agent that is needed in newer java versions
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
+
|
||||
+ // commons-lang3 is removed in maven-resolver-provider since 3.9.8
|
||||
+ // Add this because bukkit api still need it.
|
||||
+ compileOnly("org.apache.commons:commons-lang3:3.17.0")
|
||||
+ // Leaf end - Bump Dependencies
|
||||
}
|
||||
|
||||
val generatedApiPath: java.nio.file.Path = rootProject.layout.projectDirectory.dir("paper-api/src/generated/java").asFile.toPath() // Gale - project setup
|
||||
@@ -105,17 +_,21 @@
|
||||
srcDir(generatedApiPath)
|
||||
// Gale start - project setup
|
||||
srcDir(file("../paper-api/src/main/java"))
|
||||
+ srcDir(file("../gale-api/src/main/java")) // Leaf - project setup
|
||||
}
|
||||
resources {
|
||||
srcDir(file("../paper-api/src/main/resources"))
|
||||
+ srcDir(file("../gale-api/src/main/resources")) // Leaf - project setup
|
||||
}
|
||||
}
|
||||
test {
|
||||
java {
|
||||
srcDir(file("../paper-api/src/test/java"))
|
||||
+ srcDir(file("../gale-api/src/test/java")) // Leaf - project setup
|
||||
}
|
||||
resources {
|
||||
srcDir(file("../paper-api/src/test/resources"))
|
||||
+ srcDir(file("../gale-api/src/test/resources")) // Leaf - project setup
|
||||
// Gale end - project setup
|
||||
}
|
||||
}
|
||||
@@ -203,8 +_,8 @@
|
||||
options.use()
|
||||
options.isDocFilesSubDirs = true
|
||||
options.links(
|
||||
- "https://guava.dev/releases/33.3.1-jre/api/docs/",
|
||||
- "https://javadoc.io/doc/org.yaml/snakeyaml/2.2/",
|
||||
+ "https://guava.dev/releases/33.4.0-jre/api/docs/", // Leaf - Bump Dependencies
|
||||
+ "https://javadoc.io/doc/org.yaml/snakeyaml/2.3/", // Leaf - Bump Dependencies
|
||||
"https://javadoc.io/doc/org.jetbrains/annotations/$annotationsVersion/",
|
||||
"https://javadoc.io/doc/org.joml/joml/1.10.8/",
|
||||
"https://www.javadoc.io/doc/com.google.code.gson/gson/2.11.0",
|
||||
@@ -217,8 +_,8 @@
|
||||
"https://jd.advntr.dev/text-serializer-plain/$adventureVersion/",
|
||||
"https://jd.advntr.dev/text-logger-slf4j/$adventureVersion/",
|
||||
"https://javadoc.io/doc/org.slf4j/slf4j-api/$slf4jVersion/",
|
||||
- "https://javadoc.io/doc/org.apache.logging.log4j/log4j-api/$log4jVersion/",
|
||||
- "https://javadoc.io/doc/org.apache.maven.resolver/maven-resolver-api/1.7.3",
|
||||
+ "https://javadoc.io/doc/org.apache.logging.log4j/log4j-api/2.20.0/", // Leaf - Bump Dependencies
|
||||
+ "https://javadoc.io/doc/org.apache.maven.resolver/maven-resolver-api/1.9.22", // Leaf - Bump Dependencies
|
||||
)
|
||||
options.tags("apiNote:a:API Note:")
|
||||
|
||||
@@ -276,6 +_,11 @@
|
||||
jarToScan.set(tasks.jar.flatMap { it.archiveFile })
|
||||
classpath.from(configurations.compileClasspath)
|
||||
}
|
||||
+// Leaf start - Bump Dependencies
|
||||
+repositories {
|
||||
+ mavenCentral()
|
||||
+}
|
||||
+// Leaf end - Bump Dependencies
|
||||
tasks.check {
|
||||
dependsOn(scanJarForOldGeneratedCode)
|
||||
}
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Rebrand
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/ServerBuildInfo.java b/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
index b68770f6992b044d13e67d9affa6933c90ca8fb8..bef5b7b089f33c8ce1304292804ea56d16e574c9 100644
|
||||
index b68770f6992b044d13e67d9affa6933c90ca8fb8..184ed5a41a138d14757f12acd4ec3113cb165b72 100644
|
||||
--- a/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
+++ b/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
@@ -26,6 +26,17 @@ public interface ServerBuildInfo {
|
||||
@@ -14,9 +14,9 @@ index b68770f6992b044d13e67d9affa6933c90ca8fb8..bef5b7b089f33c8ce1304292804ea56d
|
||||
|
||||
+ // Leaf start
|
||||
+ /**
|
||||
+ * The brand id for Purpur.
|
||||
+ * The brand id for Pufferfish.
|
||||
+ */
|
||||
+ Key BRAND_PURPUR_ID = Key.key("purpurmc", "purpur");
|
||||
+ Key BRAND_PUFFERFISH_ID = Key.key("pufferfish", "pufferfish");
|
||||
+ /**
|
||||
+ * The brand id for Leaf.
|
||||
+ */
|
||||
@@ -5,10 +5,10 @@ Subject: [PATCH] Leaf config files
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index a3b84a898210b012d5fbae55f0bb739b5487505c..597b06c2cb289c235ad14009b186aa00f55cefcd 100644
|
||||
index 2dccd3f72e188a34c9cdf80816aadb0c79351279..331006b854dfe785c567baf8489afaac01a99cd0 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -2336,6 +2336,14 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
@@ -2383,6 +2383,14 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
|
||||
// Paper end
|
||||
|
||||
@@ -6,18 +6,6 @@ Subject: [PATCH] Pufferfish: Sentry
|
||||
Original license: GPL v3
|
||||
Original project: https://github.com/pufferfish-gg/Pufferfish
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 3c50294a0a68fd8e9fd4028d41495ad3b9781b1e..5fac022f2373105df7f9cfb292642c4a399c7db4 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -64,6 +64,7 @@ dependencies {
|
||||
apiAndDocs("net.kyori:adventure-text-logger-slf4j")
|
||||
api("org.apache.logging.log4j:log4j-api:$log4jVersion")
|
||||
api("org.slf4j:slf4j-api:$slf4jVersion")
|
||||
+ api("io.sentry:sentry:5.4.0") // Pufferfish
|
||||
|
||||
implementation("org.ow2.asm:asm:9.7.1")
|
||||
implementation("org.ow2.asm:asm-commons:9.7.1")
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/sentry/SentryContext.java b/src/main/java/gg/pufferfish/pufferfish/sentry/SentryContext.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..c7772aac00f6db664f7a5673bc2585fa025e6aad
|
||||
@@ -1,22 +1,27 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Github Actions <no-reply@github.com>
|
||||
Date: Thu, 12 Dec 2024 11:10:02 +0000
|
||||
Date: Thu, 16 Jan 2025 11:21:11 +0000
|
||||
Subject: [PATCH] Purpur API Changes
|
||||
|
||||
Original license: MIT
|
||||
Original project: https://github.com/PurpurMC/Purpur
|
||||
|
||||
Commit: 16ce24aa7eb08232030e4570e027f7baefa5f3f9
|
||||
Commit: dd4143984219cea8440913b7918322b5ba59265a
|
||||
|
||||
Patches below are removed in this patch:
|
||||
Pufferfish-API-Changes.patch
|
||||
Build-System-Changes.patch
|
||||
Clean-up-version-command-output.patch
|
||||
Remove-Timings.patch
|
||||
Add-log-suppression-for-LibraryLoader.patch
|
||||
Patches listed below are removed in this patch, They exists in Gale or Leaf:
|
||||
* "co/aikar/timings/TimedEventExecutor.java.patch"
|
||||
* "co/aikar/timings/Timing.java.patch"
|
||||
* "co/aikar/timings/Timings.java.patch"
|
||||
* "co/aikar/timings/TimingsCommand.java.patch"
|
||||
* "com/destroystokyo/paper/util/VersionFetcher.java.patch"
|
||||
* "org/bukkit/command/defaults/VersionCommand.java.patch"
|
||||
* "org/bukkit/command/SimpleCommandMap.java.patch" (Timings changes)
|
||||
* "org/bukkit/plugin/java/JavaPluginLoader.java.patch"
|
||||
* "org/bukkit/plugin/java/LibraryLoader.java.patch"
|
||||
* "org/spigotmc/CustomTimingsHandler.java.patch"
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/ServerBuildInfo.java b/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
index bef5b7b089f33c8ce1304292804ea56d16e574c9..5873b42c198d7972e4147d019c790b612ae1b735 100644
|
||||
index 184ed5a41a138d14757f12acd4ec3113cb165b72..2240bb704dd9fa62836efa1b3d6ec4d7744d9b1d 100644
|
||||
--- a/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
+++ b/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
@@ -26,6 +26,13 @@ public interface ServerBuildInfo {
|
||||
@@ -25,24 +30,24 @@ index bef5b7b089f33c8ce1304292804ea56d16e574c9..5873b42c198d7972e4147d019c790b61
|
||||
|
||||
+ // Purpur start
|
||||
+ /**
|
||||
+ * The brand id for Pufferfish.
|
||||
+ * The brand id for Purpur.
|
||||
+ */
|
||||
+ Key BRAND_PUFFERFISH_ID = Key.key("pufferfish", "pufferfish");
|
||||
+ Key BRAND_PURPUR_ID = Key.key("purpurmc", "purpur");
|
||||
+ // Purpur end
|
||||
+
|
||||
// Leaf start
|
||||
/**
|
||||
* The brand id for Purpur.
|
||||
* The brand id for Pufferfish.
|
||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||
index 2ddaa049b5b14ef7de2899862b3cc69537361b00..2477a560ed345116cd9d4e90f98694b84a1faf28 100644
|
||||
index 6c24786d349b88b414a1d96e4c0415f75d8fa545..196109f427fb1169785b82b4cfb52c53329d2bea 100644
|
||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||
@@ -3035,4 +3035,127 @@ public final class Bukkit {
|
||||
@@ -3047,4 +3047,133 @@ public final class Bukkit {
|
||||
public static Server.Spigot spigot() {
|
||||
return server.spigot();
|
||||
}
|
||||
+
|
||||
+ // Purpur start
|
||||
+ // Purpur start - Bring back server name
|
||||
+ /**
|
||||
+ * Get the name of this server
|
||||
+ * @return the name of the server
|
||||
@@ -51,7 +56,9 @@ index 2ddaa049b5b14ef7de2899862b3cc69537361b00..2477a560ed345116cd9d4e90f98694b8
|
||||
+ public static String getServerName() {
|
||||
+ return server.getServerName();
|
||||
+ }
|
||||
+ // Purpur end - Bring back server name
|
||||
+
|
||||
+ // Purpur start - Lagging threshold
|
||||
+ /**
|
||||
+ * Check if server is lagging according to laggy threshold setting
|
||||
+ *
|
||||
@@ -60,7 +67,9 @@ index 2ddaa049b5b14ef7de2899862b3cc69537361b00..2477a560ed345116cd9d4e90f98694b8
|
||||
+ public static boolean isLagging() {
|
||||
+ return server.isLagging();
|
||||
+ }
|
||||
+ // Purpur end - Lagging threshold
|
||||
+
|
||||
+ // Purpur start - Added the ability to add combustible items
|
||||
+ /**
|
||||
+ * Add an Item as fuel for furnaces
|
||||
+ *
|
||||
@@ -79,7 +88,9 @@ index 2ddaa049b5b14ef7de2899862b3cc69537361b00..2477a560ed345116cd9d4e90f98694b8
|
||||
+ public static void removeFuel(@NotNull Material material) {
|
||||
+ server.removeFuel(material);
|
||||
+ }
|
||||
+ // Purpur end - Added the ability to add combustible items
|
||||
+
|
||||
+ // Purpur start - Debug Marker API
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to all players on the server.
|
||||
+ * <p>
|
||||
@@ -163,10 +174,10 @@ index 2ddaa049b5b14ef7de2899862b3cc69537361b00..2477a560ed345116cd9d4e90f98694b8
|
||||
+ public static void clearBlockHighlights() {
|
||||
+ server.clearBlockHighlights();
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+ // Purpur end - Debug Marker API
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/ChatColor.java b/src/main/java/org/bukkit/ChatColor.java
|
||||
index 918a045165cdcde264bc24082b7afebb407271de..e98d6321c5f2cdde91b54f8a74cbcc045eae75a8 100644
|
||||
index 918a045165cdcde264bc24082b7afebb407271de..f283bcabff7fe6eede6cf4344537e43048c35166 100644
|
||||
--- a/src/main/java/org/bukkit/ChatColor.java
|
||||
+++ b/src/main/java/org/bukkit/ChatColor.java
|
||||
@@ -456,4 +456,77 @@ public enum ChatColor {
|
||||
@@ -174,7 +185,7 @@ index 918a045165cdcde264bc24082b7afebb407271de..e98d6321c5f2cdde91b54f8a74cbcc04
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // Purpur start
|
||||
+ // Purpur start - ChatColor conveniences
|
||||
+ /**
|
||||
+ * Convert legacy string into a string ready to be parsed by MiniMessage
|
||||
+ *
|
||||
@@ -245,18 +256,18 @@ index 918a045165cdcde264bc24082b7afebb407271de..e98d6321c5f2cdde91b54f8a74cbcc04
|
||||
+ public static String color(@Nullable String str, boolean parseHex) {
|
||||
+ return str != null ? net.md_5.bungee.api.ChatColor.translateAlternateColorCodes('&', parseHex ? replaceHex(str) : str) : str;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+ // Purpur end - ChatColor conveniences
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
|
||||
index 028ac35df6c4d044d07b3869751736d418c1eb0e..95c1f331f364c5fafa100860f3c9674f18888714 100644
|
||||
index 9afafc00e457c721a1b20b05c6a5d330caa40dfb..6469d4e1097e694d8bf00610ed8d34de132bd19c 100644
|
||||
--- a/src/main/java/org/bukkit/Material.java
|
||||
+++ b/src/main/java/org/bukkit/Material.java
|
||||
@@ -5840,4 +5840,40 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
|
||||
@@ -5812,4 +5812,40 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
|
||||
return this.asItemType().getDefaultDataTypes();
|
||||
}
|
||||
// Paper end - data component API
|
||||
+
|
||||
+ // Purpur start
|
||||
+ // Purpur start - ItemStack convenience methods
|
||||
+ public boolean isArmor() {
|
||||
+ switch (this) {
|
||||
+ // <editor-fold defaultstate="collapsed" desc="isarmor">
|
||||
@@ -290,7 +301,7 @@ index 028ac35df6c4d044d07b3869751736d418c1eb0e..95c1f331f364c5fafa100860f3c9674f
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+ // Purpur end - ItemStack convenience methods
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/OfflinePlayer.java b/src/main/java/org/bukkit/OfflinePlayer.java
|
||||
index 5622fe3165baad8138c22cfc016ed6c3834cf702..6d31b561d915180fcd473b317721064feed28f37 100644
|
||||
@@ -404,10 +415,10 @@ index 5622fe3165baad8138c22cfc016ed6c3834cf702..6d31b561d915180fcd473b317721064f
|
||||
+ // Purpur end - OfflinePlayer API
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index 597b06c2cb289c235ad14009b186aa00f55cefcd..582c1f053020dff2cde8a1a7a1a760a84e856b7c 100644
|
||||
index 331006b854dfe785c567baf8489afaac01a99cd0..335db5f0893df51c65c5aab7f11fd6aef59a191d 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -2336,6 +2336,18 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
@@ -2383,6 +2383,18 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
|
||||
// Paper end
|
||||
|
||||
@@ -426,26 +437,30 @@ index 597b06c2cb289c235ad14009b186aa00f55cefcd..582c1f053020dff2cde8a1a7a1a760a8
|
||||
// Leaf start
|
||||
@NotNull
|
||||
public org.bukkit.configuration.file.YamlConfiguration getLeafConfig()
|
||||
@@ -2693,4 +2705,105 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
@@ -2740,4 +2752,111 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
*/
|
||||
long getLastTickOversleepTime();
|
||||
// Gale end - YAPFA - last tick time - API
|
||||
+
|
||||
+ // Purpur start
|
||||
+ // Purpur start - Bring back server name
|
||||
+ /**
|
||||
+ * Get the name of this server
|
||||
+ * @return the name of the server
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ String getServerName();
|
||||
+ // Purpur end - Bring back server name
|
||||
+
|
||||
+ // Purpur start - Lagging threshold
|
||||
+ /**
|
||||
+ * Check if server is lagging according to laggy threshold setting
|
||||
+ *
|
||||
+ * @return True if lagging
|
||||
+ */
|
||||
+ boolean isLagging();
|
||||
+ // Purpur end - Lagging threshold
|
||||
+
|
||||
+ // Purpur start - Added the ability to add combustible items
|
||||
+ /**
|
||||
+ * Add an Item as fuel for furnaces
|
||||
+ *
|
||||
@@ -460,7 +475,9 @@ index 597b06c2cb289c235ad14009b186aa00f55cefcd..582c1f053020dff2cde8a1a7a1a760a8
|
||||
+ * @param material The material that will no longer be a fuel
|
||||
+ */
|
||||
+ public void removeFuel(@NotNull Material material);
|
||||
+ // Purpur end - Added the ability to add combustible items
|
||||
+
|
||||
+ // Purpur start - Debug Marker API
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to all players on the server.
|
||||
+ * <p>
|
||||
@@ -530,13 +547,13 @@ index 597b06c2cb289c235ad14009b186aa00f55cefcd..582c1f053020dff2cde8a1a7a1a760a8
|
||||
+ * Clears all debug block highlights for all players on the server.
|
||||
+ */
|
||||
+ void clearBlockHighlights();
|
||||
+ // Purpur end
|
||||
+ // Purpur end - Debug Marker API
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
||||
index bef54a6c8290e09cbaac20b03dde8dfb902c96b0..5f7de23e419175e55459df760c7190639ea39f18 100644
|
||||
index e99fa923d35b6dda0b02968bdcf6b43552517ea4..5ee6f017101a05b568b69627b1819d63dbe8094e 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -4246,6 +4246,86 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
|
||||
@@ -4238,6 +4238,86 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
|
||||
@Nullable
|
||||
public DragonBattle getEnderDragonBattle();
|
||||
|
||||
@@ -624,14 +641,14 @@ index bef54a6c8290e09cbaac20b03dde8dfb902c96b0..5f7de23e419175e55459df760c719063
|
||||
* Get all {@link FeatureFlag} enabled in this world.
|
||||
*
|
||||
diff --git a/src/main/java/org/bukkit/block/EntityBlockStorage.java b/src/main/java/org/bukkit/block/EntityBlockStorage.java
|
||||
index 739911cda33b373f99df627a3a378b37d7d461aa..51e78c22cd021722b963fe31d1d9175d141add1a 100644
|
||||
index 739911cda33b373f99df627a3a378b37d7d461aa..58e16c12b06fa11d30b67f5038844ff9990790ae 100644
|
||||
--- a/src/main/java/org/bukkit/block/EntityBlockStorage.java
|
||||
+++ b/src/main/java/org/bukkit/block/EntityBlockStorage.java
|
||||
@@ -47,6 +47,24 @@ public interface EntityBlockStorage<T extends Entity> extends TileState {
|
||||
@@ -47,6 +47,25 @@ public interface EntityBlockStorage<T extends Entity> extends TileState {
|
||||
@NotNull
|
||||
List<T> releaseEntities();
|
||||
|
||||
+ // Purpur start
|
||||
+ // Purpur start - Stored Bee API
|
||||
+ /**
|
||||
+ * Releases a stored entity, and returns the entity in the world.
|
||||
+ *
|
||||
@@ -648,19 +665,20 @@ index 739911cda33b373f99df627a3a378b37d7d461aa..51e78c22cd021722b963fe31d1d9175d
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ List<org.purpurmc.purpur.entity.StoredEntity<T>> getEntities();
|
||||
+ //Purpur end
|
||||
+ // Purpur end - Stored Bee API
|
||||
+
|
||||
/**
|
||||
* Add an entity to the block.
|
||||
*
|
||||
diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||
index 5df19bd701c67506689fc7f49d91f99ebfbc83f0..a09b5458191eb5df4787859b72a37fa1fa2bffba 100644
|
||||
index 5df19bd701c67506689fc7f49d91f99ebfbc83f0..32c81559507a8e5085c91d466cda69d0dc11327e 100644
|
||||
--- a/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||
+++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||
@@ -153,6 +153,19 @@ public class SimpleCommandMap implements CommandMap {
|
||||
return false;
|
||||
}
|
||||
|
||||
+ // Purpur start
|
||||
+ // Purpur start - ExecuteCommandEvent
|
||||
+ String[] parsedArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
+ org.purpurmc.purpur.event.ExecuteCommandEvent event = new org.purpurmc.purpur.event.ExecuteCommandEvent(sender, target, sentCommandLabel, parsedArgs);
|
||||
+ if (!event.callEvent()) {
|
||||
@@ -671,7 +689,7 @@ index 5df19bd701c67506689fc7f49d91f99ebfbc83f0..a09b5458191eb5df4787859b72a37fa1
|
||||
+ target = event.getCommand();
|
||||
+ sentCommandLabel = event.getLabel();
|
||||
+ parsedArgs = event.getArgs();
|
||||
+ // Purpur end
|
||||
+ // Purpur end - ExecuteCommandEvent
|
||||
+
|
||||
// Paper start - Plugins do weird things to workaround normal registration
|
||||
if (target.timings == null) {
|
||||
@@ -681,19 +699,19 @@ index 5df19bd701c67506689fc7f49d91f99ebfbc83f0..a09b5458191eb5df4787859b72a37fa1
|
||||
try (co.aikar.timings.Timing ignored = target.timings.startTiming()) { // Paper - use try with resources
|
||||
// Note: we don't return the result of target.execute as thats success / failure, we return handled (true) or not handled (false)
|
||||
- target.execute(sender, sentCommandLabel, Arrays.copyOfRange(args, 1, args.length));
|
||||
+ target.execute(sender, sentCommandLabel, parsedArgs); // Purpur
|
||||
+ target.execute(sender, sentCommandLabel, parsedArgs); // Purpur - ExecuteCommandEvent
|
||||
} // target.timings.stopTiming(); // Spigot // Paper
|
||||
} catch (CommandException ex) {
|
||||
server.getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerCommandException(ex, target, sender, args))); // Paper
|
||||
diff --git a/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java b/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java
|
||||
index 6fcc15d588239481136876d117ab346a8deac1dd..13b903e785a9ef5e513cb9d6483482133cc5f25b 100644
|
||||
index 6fcc15d588239481136876d117ab346a8deac1dd..ad04cb5542f219f617bcb6ed60cf248ab53d83bc 100644
|
||||
--- a/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java
|
||||
+++ b/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java
|
||||
@@ -227,6 +227,28 @@ public enum EnchantmentTarget {
|
||||
@@ -227,6 +227,30 @@ public enum EnchantmentTarget {
|
||||
public boolean includes(@NotNull Material item) {
|
||||
return BREAKABLE.includes(item) || (WEARABLE.includes(item) && !item.equals(Material.ELYTRA)) || item.equals(Material.COMPASS);
|
||||
}
|
||||
+ // Purpur start
|
||||
+ // Purpur start - Add enchantment target for bows and crossbows
|
||||
+ },
|
||||
+
|
||||
+ /**
|
||||
@@ -704,6 +722,8 @@ index 6fcc15d588239481136876d117ab346a8deac1dd..13b903e785a9ef5e513cb9d648348213
|
||||
+ public boolean includes(@NotNull Material item) {
|
||||
+ return item.equals(Material.BOW) || item.equals(Material.CROSSBOW);
|
||||
+ }
|
||||
+ // Purpur end - Add enchantment target for bows and crossbows
|
||||
+ // Purpur start - Shears can have looting enchantment
|
||||
+ },
|
||||
+
|
||||
+ /**
|
||||
@@ -714,7 +734,7 @@ index 6fcc15d588239481136876d117ab346a8deac1dd..13b903e785a9ef5e513cb9d648348213
|
||||
+ public boolean includes(@NotNull Material item) {
|
||||
+ return WEAPON.includes(item) || item.equals(Material.SHEARS);
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+ // Purpur end - Shears can have looting enchantment
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -753,15 +773,15 @@ index 7b379fb21e800a766ad022705a12dff6d42279ab..10a8d64ad2da0be2c14f34c3e7d1957c
|
||||
// Paper start
|
||||
/**
|
||||
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
|
||||
index 19272cff8d6d040e95b2644d70acdac606e06c16..076fe310d500ebb52e705a3a69e895061702f470 100644
|
||||
index ddf7829eee5e3f0ded9319a5a0a7b2e2486320a4..49d3ca54a761e08cfe1bc770cb879223bf0e21e8 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Entity.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
||||
@@ -1172,4 +1172,55 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
|
||||
@@ -1196,4 +1196,59 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
|
||||
*/
|
||||
void broadcastHurtAnimation(@NotNull java.util.Collection<Player> players);
|
||||
// Paper end - broadcast hurt animation
|
||||
+
|
||||
+ // Purpur start
|
||||
+ // Purpur start - Ridables
|
||||
+ /**
|
||||
+ * Get the riding player
|
||||
+ *
|
||||
@@ -790,14 +810,18 @@ index 19272cff8d6d040e95b2644d70acdac606e06c16..076fe310d500ebb52e705a3a69e89506
|
||||
+ * @return True if ridable in water
|
||||
+ */
|
||||
+ boolean isRidableInWater();
|
||||
+ // Purpur end - Ridables
|
||||
+
|
||||
+ // Purpur start - API for any mob to burn daylight
|
||||
+ /**
|
||||
+ * Checks if the entity is in daylight
|
||||
+ *
|
||||
+ * @return True if in daylight
|
||||
+ */
|
||||
+ boolean isInDaylight();
|
||||
+ // Purpur end - API for any mob to burn daylight
|
||||
+
|
||||
+ // Purpur start - Fire Immunity API
|
||||
+ /**
|
||||
+ * Checks if the entity is fire immune
|
||||
+ *
|
||||
@@ -810,7 +834,7 @@ index 19272cff8d6d040e95b2644d70acdac606e06c16..076fe310d500ebb52e705a3a69e89506
|
||||
+ * Set this to null to restore the entity type default
|
||||
+ */
|
||||
+ void setImmuneToFire(@Nullable Boolean fireImmune);
|
||||
+ // Purpur end
|
||||
+ // Purpur end - Fire Immunity API
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/entity/IronGolem.java b/src/main/java/org/bukkit/entity/IronGolem.java
|
||||
index 655e37cb3a09610a3f3df805d6dcad17d722da62..09fd716c8fc9ea34a1cbf87bcbe22df035422a51 100644
|
||||
@@ -955,10 +979,10 @@ index bc84b892cae5fe7019a3ad481e9da79956efa1fe..48eb5b00c460cccde29d327cef1d63fc
|
||||
+ // Purpur end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||
index 20e3c0f856ec034b1d7a5617337ac093386b200f..347d6cbee7daba824adf798c1ec9895ae1da67ab 100644
|
||||
index 1ee59ed42de64ae1a0a580b3f640cdcb5f51c71b..886a954b1a12e895f5d54fd35a9acb36673e3733 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -3921,4 +3921,123 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||
@@ -3902,4 +3902,123 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||
*/
|
||||
void sendEntityEffect(org.bukkit.@NotNull EntityEffect effect, @NotNull Entity target);
|
||||
// Paper end - entity effect API
|
||||
@@ -967,7 +991,7 @@ index 20e3c0f856ec034b1d7a5617337ac093386b200f..347d6cbee7daba824adf798c1ec9895a
|
||||
+ /**
|
||||
+ * Allows you to get if player uses PurpurClient
|
||||
+ *
|
||||
+ * @return True if Player uses Purpur Client
|
||||
+ * @return true if player uses PurpurClient
|
||||
+ */
|
||||
+ public boolean usesPurpurClient();
|
||||
+
|
||||
@@ -1152,11 +1176,11 @@ index 14543c2238b45c526dd9aebea2aa5c22f5df54dc..5312daf33405704c74e2c9e109754285
|
||||
+ // Purpur end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/entity/Wolf.java b/src/main/java/org/bukkit/entity/Wolf.java
|
||||
index c73489f4b745bc84501ce94f0227b034d9768eae..a97129e71f16ec691759add664bdfd35ab90aaed 100644
|
||||
index 346fdddd2ed8f0b8b66860c969f5e80c51c6d622..6f62277c3461d436a656cbd80bc59e70cb1a6f3a 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Wolf.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Wolf.java
|
||||
@@ -108,4 +108,20 @@ public interface Wolf extends Tameable, Sittable, io.papermc.paper.entity.Collar
|
||||
return Registry.WOLF_VARIANT.getOrThrow(NamespacedKey.minecraft(key));
|
||||
@@ -110,4 +110,20 @@ public interface Wolf extends Tameable, Sittable, io.papermc.paper.entity.Collar
|
||||
return RegistryAccess.registryAccess().getRegistry(RegistryKey.WOLF_VARIANT).getOrThrow(NamespacedKey.minecraft(key));
|
||||
}
|
||||
}
|
||||
+
|
||||
@@ -1208,7 +1232,7 @@ index 8fdfcbc7d20fe0af6b220ab94516247093637621..f6a8928408e11a5ae723366e4ea1280d
|
||||
* When a player gets bad omen after killing a patrol captain.
|
||||
*
|
||||
diff --git a/src/main/java/org/bukkit/event/inventory/InventoryType.java b/src/main/java/org/bukkit/event/inventory/InventoryType.java
|
||||
index 81118a91c2e22e02a1f774d1cc4d3e97064087ce..3ac1e4a821a5b48d3936222cbfddadd3b803deef 100644
|
||||
index 81118a91c2e22e02a1f774d1cc4d3e97064087ce..6640df827e354cc32cea5fc71b9e464443202708 100644
|
||||
--- a/src/main/java/org/bukkit/event/inventory/InventoryType.java
|
||||
+++ b/src/main/java/org/bukkit/event/inventory/InventoryType.java
|
||||
@@ -164,7 +164,7 @@ public enum InventoryType {
|
||||
@@ -1216,7 +1240,7 @@ index 81118a91c2e22e02a1f774d1cc4d3e97064087ce..3ac1e4a821a5b48d3936222cbfddadd3
|
||||
;
|
||||
|
||||
- private final int size;
|
||||
+ private int size; public void setDefaultSize(int size) { this.size = size; } // Purpur - remove final and add setter
|
||||
+ private int size; @ApiStatus.Internal public void setDefaultSize(int size) { this.size = size; } // Purpur - remove final and add setter
|
||||
private final String title;
|
||||
private final MenuType menuType;
|
||||
private final boolean isCreatable;
|
||||
@@ -1268,29 +1292,29 @@ index f1f97a85ec713c05c882d7588f4a3e4a017f4795..813f6cd253322538bdf96eb323dd23a7
|
||||
+ // Purpur end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
index 8c9654cd19af8b28fa276a55c5060eb389e60c1c..875124b06d87cd4163f0ab1d4dd75f939622f8aa 100644
|
||||
index 55457c7539c08e861263333ae40cbfe9d25814f4..9b3c3d6563c94aec225a332db5d5653887ac5f4b 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
@@ -19,6 +19,13 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
@@ -21,6 +21,13 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
+// Purpur start
|
||||
+// Purpur start - ItemStack convenience methods
|
||||
+import com.google.common.collect.Multimap;
|
||||
+import java.util.Collection;
|
||||
+import org.bukkit.attribute.Attribute;
|
||||
+import org.bukkit.attribute.AttributeModifier;
|
||||
+import org.bukkit.block.data.BlockData;
|
||||
+// Purpur end
|
||||
+// Purpur end - ItemStack convenience methods
|
||||
|
||||
/**
|
||||
* Represents a stack of items.
|
||||
@@ -1318,4 +1325,482 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||
@@ -1329,4 +1336,482 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||
return this.craftDelegate.matchesWithoutData(item, excludeTypes, ignoreCount);
|
||||
}
|
||||
// Paper end - data component API
|
||||
+
|
||||
+ // Purpur start
|
||||
+ // Purpur start - ItemStack convenience methods
|
||||
+ /**
|
||||
+ * Gets the display name that is set.
|
||||
+ * <p>
|
||||
@@ -1766,17 +1790,17 @@ index 8c9654cd19af8b28fa276a55c5060eb389e60c1c..875124b06d87cd4163f0ab1d4dd75f93
|
||||
+ public boolean damage(int amount, boolean ignoreUnbreaking) {
|
||||
+ return this.craftDelegate.damage(amount, ignoreUnbreaking);
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+ // Purpur end - ItemStack convenience methods
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/inventory/RecipeChoice.java b/src/main/java/org/bukkit/inventory/RecipeChoice.java
|
||||
index 922bb69b5f218e489a6dd5e0f207743c1f1d3d35..9b3e292be334d21eb978373f434bf3811ec4af2b 100644
|
||||
index 922bb69b5f218e489a6dd5e0f207743c1f1d3d35..3606c6457a98e0e39d6a4b171bc11b61aac73e5c 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/RecipeChoice.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/RecipeChoice.java
|
||||
@@ -191,6 +191,7 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
||||
public static class ExactChoice implements RecipeChoice {
|
||||
|
||||
private List<ItemStack> choices;
|
||||
+ private Predicate<ItemStack> predicate; // Purpur
|
||||
+ private Predicate<ItemStack> predicate; // Purpur - Add predicate to recipe's ExactChoice ingredient
|
||||
|
||||
public ExactChoice(@NotNull ItemStack stack) {
|
||||
this(Arrays.asList(stack));
|
||||
@@ -1784,7 +1808,7 @@ index 922bb69b5f218e489a6dd5e0f207743c1f1d3d35..9b3e292be334d21eb978373f434bf381
|
||||
|
||||
@Override
|
||||
public boolean test(@NotNull ItemStack t) {
|
||||
+ if (predicate != null) return predicate.test(t); // Purpur
|
||||
+ if (predicate != null) return predicate.test(t); // Purpur - Add predicate to recipe's ExactChoice ingredient
|
||||
for (ItemStack match : choices) {
|
||||
if (t.isSimilar(match)) {
|
||||
return true;
|
||||
@@ -1792,7 +1816,7 @@ index 922bb69b5f218e489a6dd5e0f207743c1f1d3d35..9b3e292be334d21eb978373f434bf381
|
||||
return false;
|
||||
}
|
||||
|
||||
+ // Purpur start
|
||||
+ // Purpur start - Add predicate to recipe's ExactChoice ingredient
|
||||
+ @org.jetbrains.annotations.Nullable
|
||||
+ public Predicate<ItemStack> getPredicate() {
|
||||
+ return predicate;
|
||||
@@ -1801,13 +1825,13 @@ index 922bb69b5f218e489a6dd5e0f207743c1f1d3d35..9b3e292be334d21eb978373f434bf381
|
||||
+ public void setPredicate(@org.jetbrains.annotations.Nullable Predicate<ItemStack> predicate) {
|
||||
+ this.predicate = predicate;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+ // Purpur end - Add predicate to recipe's ExactChoice ingredient
|
||||
+
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
diff --git a/src/main/java/org/bukkit/inventory/view/AnvilView.java b/src/main/java/org/bukkit/inventory/view/AnvilView.java
|
||||
index 3c1aa1e036bee08304c1cdca59f6a5bc0ba306c0..709fb2d1c7e3253034a651a9f68c003601b598a4 100644
|
||||
index 3c1aa1e036bee08304c1cdca59f6a5bc0ba306c0..b273e168c976fb6e185da3ba83d9d69e0b2e7920 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/view/AnvilView.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/view/AnvilView.java
|
||||
@@ -89,4 +89,34 @@ public interface AnvilView extends InventoryView {
|
||||
@@ -1815,7 +1839,7 @@ index 3c1aa1e036bee08304c1cdca59f6a5bc0ba306c0..709fb2d1c7e3253034a651a9f68c0036
|
||||
void bypassEnchantmentLevelRestriction(boolean bypassEnchantmentLevelRestriction);
|
||||
// Paper end - bypass anvil level restrictions
|
||||
+
|
||||
+ // Purpur start
|
||||
+ // Purpur start - Anvil API
|
||||
+ /**
|
||||
+ * Gets if the player viewing the anvil inventory can bypass experience cost
|
||||
+ *
|
||||
@@ -1843,27 +1867,27 @@ index 3c1aa1e036bee08304c1cdca59f6a5bc0ba306c0..709fb2d1c7e3253034a651a9f68c0036
|
||||
+ * @param canDoUnsafeEnchants whether the player viewing the anvil inventory can do unsafe enchants
|
||||
+ */
|
||||
+ void setDoUnsafeEnchants(boolean canDoUnsafeEnchants);
|
||||
+ // Purpur end
|
||||
+ // Purpur end - Anvil API
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/map/MapRenderer.java b/src/main/java/org/bukkit/map/MapRenderer.java
|
||||
index cb7040876a99a5a7e49b81684ef0f3b79584c376..22d8f31b1b8a5dbb5ab3275068642937c097abfe 100644
|
||||
index cb7040876a99a5a7e49b81684ef0f3b79584c376..63351a0fb4263e2e7ccb6896768a5b10378de297 100644
|
||||
--- a/src/main/java/org/bukkit/map/MapRenderer.java
|
||||
+++ b/src/main/java/org/bukkit/map/MapRenderer.java
|
||||
@@ -54,4 +54,12 @@ public abstract class MapRenderer {
|
||||
*/
|
||||
public abstract void render(@NotNull MapView map, @NotNull MapCanvas canvas, @NotNull Player player);
|
||||
|
||||
+ // Purpur - start
|
||||
+ // Purpur - start - Explorer Map API
|
||||
+ /**
|
||||
+ * Check if this is an explorer (aka treasure) map.
|
||||
+ *
|
||||
+ * @return True if explorer map
|
||||
+ */
|
||||
+ public abstract boolean isExplorerMap();
|
||||
+ // Purpur - end
|
||||
+ // Purpur - end - Explorer Map API
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/permissions/PermissibleBase.java b/src/main/java/org/bukkit/permissions/PermissibleBase.java
|
||||
index 75b77cc4fe189b4b6baa1af3663dc492e992a266..30b98d1645c571ba5c18e5cc93b0bec3f74b1d3b 100644
|
||||
index 75b77cc4fe189b4b6baa1af3663dc492e992a266..1aa3c6dbf2f2a62fbec990f931d5c5d5c8e5a0bd 100644
|
||||
--- a/src/main/java/org/bukkit/permissions/PermissibleBase.java
|
||||
+++ b/src/main/java/org/bukkit/permissions/PermissibleBase.java
|
||||
@@ -169,7 +169,7 @@ public class PermissibleBase implements Permissible {
|
||||
@@ -1871,7 +1895,7 @@ index 75b77cc4fe189b4b6baa1af3663dc492e992a266..30b98d1645c571ba5c18e5cc93b0bec3
|
||||
for (Permission perm : defaults) {
|
||||
String name = perm.getName().toLowerCase(Locale.ROOT);
|
||||
- permissions.put(name, new PermissionAttachmentInfo(parent, name, null, true));
|
||||
+ permissions.put(name, new PermissionAttachmentInfo(parent, name, null, perm.getDefault().getValue(isOp()))); // Purpur
|
||||
+ permissions.put(name, new PermissionAttachmentInfo(parent, name, null, perm.getDefault().getValue(isOp()))); // Purpur - Fix default permission system
|
||||
Bukkit.getServer().getPluginManager().subscribeToPermission(name, parent);
|
||||
calculateChildPermissions(perm.getChildren(), false, null);
|
||||
}
|
||||
@@ -1880,24 +1904,24 @@ index 75b77cc4fe189b4b6baa1af3663dc492e992a266..30b98d1645c571ba5c18e5cc93b0bec3
|
||||
|
||||
Permission perm = Bukkit.getServer().getPluginManager().getPermission(name);
|
||||
- boolean value = entry.getValue() ^ invert;
|
||||
+ boolean value = (entry.getValue() == null && perm != null ? perm.getDefault().getValue(isOp()) : entry.getValue()) ^ invert; // Purpur
|
||||
+ boolean value = (entry.getValue() == null && perm != null ? perm.getDefault().getValue(isOp()) : entry.getValue()) ^ invert; // Purpur - Fix default permission system
|
||||
String lname = name.toLowerCase(Locale.ROOT);
|
||||
|
||||
permissions.put(lname, new PermissionAttachmentInfo(parent, lname, attachment, value));
|
||||
diff --git a/src/main/java/org/bukkit/util/permissions/CommandPermissions.java b/src/main/java/org/bukkit/util/permissions/CommandPermissions.java
|
||||
index 7763d6101ac61900db1e2310966b99584539fd0e..d5a42707d365ffd72532bbb1a59a1ca7145f9918 100644
|
||||
index 7763d6101ac61900db1e2310966b99584539fd0e..48c67cb3a7073db85d7cf2308e5b1aae89b7a1d2 100644
|
||||
--- a/src/main/java/org/bukkit/util/permissions/CommandPermissions.java
|
||||
+++ b/src/main/java/org/bukkit/util/permissions/CommandPermissions.java
|
||||
@@ -18,6 +18,7 @@ public final class CommandPermissions {
|
||||
DefaultPermissions.registerPermission(PREFIX + "plugins", "Allows the user to view the list of plugins running on this server", PermissionDefault.TRUE, commands);
|
||||
DefaultPermissions.registerPermission(PREFIX + "reload", "Allows the user to reload the server settings", PermissionDefault.OP, commands);
|
||||
DefaultPermissions.registerPermission(PREFIX + "version", "Allows the user to view the version of the server", PermissionDefault.TRUE, commands);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "purpur", "Allows the user to use the purpur command", PermissionDefault.OP, commands); // Purpur
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "purpur", "Allows the user to use the purpur command", PermissionDefault.OP, commands); // Purpur - Default permissions
|
||||
|
||||
commands.recalculatePermissibles();
|
||||
return commands;
|
||||
diff --git a/src/main/java/org/bukkit/util/permissions/DefaultPermissions.java b/src/main/java/org/bukkit/util/permissions/DefaultPermissions.java
|
||||
index e1a4ddf2c07cdd242fa8054a0152522fe4039e85..10627d2a11251a8cb01bbc3f6242d66f3505a16e 100644
|
||||
index e1a4ddf2c07cdd242fa8054a0152522fe4039e85..5329de48a739cafac98514e24edaf5f1b9d41fff 100644
|
||||
--- a/src/main/java/org/bukkit/util/permissions/DefaultPermissions.java
|
||||
+++ b/src/main/java/org/bukkit/util/permissions/DefaultPermissions.java
|
||||
@@ -31,7 +31,7 @@ public final class DefaultPermissions {
|
||||
@@ -1905,7 +1929,7 @@ index e1a4ddf2c07cdd242fa8054a0152522fe4039e85..10627d2a11251a8cb01bbc3f6242d66f
|
||||
if (withLegacy) {
|
||||
Permission legacy = new Permission(LEGACY_PREFIX + result.getName(), result.getDescription(), PermissionDefault.FALSE);
|
||||
- legacy.getChildren().put(result.getName(), true);
|
||||
+ legacy.getChildren().put(result.getName(), null); // Purpur
|
||||
+ legacy.getChildren().put(result.getName(), null); // Purpur - Fix default permission system
|
||||
registerPermission(perm, false);
|
||||
}
|
||||
|
||||
@@ -1914,7 +1938,7 @@ index e1a4ddf2c07cdd242fa8054a0152522fe4039e85..10627d2a11251a8cb01bbc3f6242d66f
|
||||
@NotNull
|
||||
public static Permission registerPermission(@NotNull Permission perm, @NotNull Permission parent) {
|
||||
- parent.getChildren().put(perm.getName(), true);
|
||||
+ parent.getChildren().put(perm.getName(), null); // Purpur
|
||||
+ parent.getChildren().put(perm.getName(), null); // Purpur - Fix default permission system
|
||||
return registerPermission(perm);
|
||||
}
|
||||
|
||||
@@ -1923,7 +1947,7 @@ index e1a4ddf2c07cdd242fa8054a0152522fe4039e85..10627d2a11251a8cb01bbc3f6242d66f
|
||||
public static Permission registerPermission(@NotNull String name, @Nullable String desc, @NotNull Permission parent) {
|
||||
Permission perm = registerPermission(name, desc);
|
||||
- parent.getChildren().put(perm.getName(), true);
|
||||
+ parent.getChildren().put(perm.getName(), null); // Purpur
|
||||
+ parent.getChildren().put(perm.getName(), null); // Purpur - Fix default permission system
|
||||
return perm;
|
||||
}
|
||||
|
||||
@@ -1932,7 +1956,7 @@ index e1a4ddf2c07cdd242fa8054a0152522fe4039e85..10627d2a11251a8cb01bbc3f6242d66f
|
||||
public static Permission registerPermission(@NotNull String name, @Nullable String desc, @Nullable PermissionDefault def, @NotNull Permission parent) {
|
||||
Permission perm = registerPermission(name, desc, def);
|
||||
- parent.getChildren().put(perm.getName(), true);
|
||||
+ parent.getChildren().put(perm.getName(), null); // Purpur
|
||||
+ parent.getChildren().put(perm.getName(), null); // Purpur - Fix default permission system
|
||||
return perm;
|
||||
}
|
||||
|
||||
@@ -1941,7 +1965,7 @@ index e1a4ddf2c07cdd242fa8054a0152522fe4039e85..10627d2a11251a8cb01bbc3f6242d66f
|
||||
public static Permission registerPermission(@NotNull String name, @Nullable String desc, @Nullable PermissionDefault def, @Nullable Map<String, Boolean> children, @NotNull Permission parent) {
|
||||
Permission perm = registerPermission(name, desc, def, children);
|
||||
- parent.getChildren().put(perm.getName(), true);
|
||||
+ parent.getChildren().put(perm.getName(), null); // Purpur
|
||||
+ parent.getChildren().put(perm.getName(), null); // Purpur - Fix default permission system
|
||||
return perm;
|
||||
}
|
||||
|
||||
@@ -1949,104 +1973,11 @@ index e1a4ddf2c07cdd242fa8054a0152522fe4039e85..10627d2a11251a8cb01bbc3f6242d66f
|
||||
CommandPermissions.registerPermissions(parent);
|
||||
BroadcastPermissions.registerPermissions(parent);
|
||||
|
||||
+ PurpurPermissions.registerPermissions(); // Purpur
|
||||
+ org.purpurmc.purpur.util.permissions.PurpurPermissions.registerPermissions(); // Purpur - Default permissions
|
||||
+
|
||||
parent.recalculatePermissibles();
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/util/permissions/PurpurPermissions.java b/src/main/java/org/bukkit/util/permissions/PurpurPermissions.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..baec4c87d7ea4d54934ca22fd1eb7b46dd69061b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/bukkit/util/permissions/PurpurPermissions.java
|
||||
@@ -0,0 +1,87 @@
|
||||
+package org.bukkit.util.permissions;
|
||||
+
|
||||
+import org.bukkit.entity.Entity;
|
||||
+import org.bukkit.entity.EntityType;
|
||||
+import org.bukkit.entity.Mob;
|
||||
+import org.bukkit.permissions.Permission;
|
||||
+import org.bukkit.permissions.PermissionDefault;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.util.HashSet;
|
||||
+import java.util.Set;
|
||||
+
|
||||
+public final class PurpurPermissions {
|
||||
+ private static final String ROOT = "purpur";
|
||||
+ private static final String PREFIX = ROOT + ".";
|
||||
+ private static final Set<String> mobs = new HashSet<>();
|
||||
+
|
||||
+ static {
|
||||
+ for (EntityType mob : EntityType.values()) {
|
||||
+ Class<? extends Entity> clazz = mob.getEntityClass();
|
||||
+ if (clazz != null && Mob.class.isAssignableFrom(clazz)) {
|
||||
+ mobs.add(mob.getName());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static Permission registerPermissions() {
|
||||
+ Permission purpur = DefaultPermissions.registerPermission(ROOT, "Gives the user the ability to use all Purpur utilities and commands", PermissionDefault.FALSE);
|
||||
+
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "enderchest.rows.six", "Gives the user six rows of enderchest space", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "enderchest.rows.five", "Gives the user five rows of enderchest space", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "enderchest.rows.four", "Gives the user four rows of enderchest space", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "enderchest.rows.three", "Gives the user three rows of enderchest space", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "enderchest.rows.two", "Gives the user two rows of enderchest space", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "enderchest.rows.one", "Gives the user one row of enderchest space", PermissionDefault.FALSE, purpur);
|
||||
+
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "debug.f3n", "Allows the user to use F3+N keybind to swap gamemodes", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "joinfullserver", "Allows the user to join a full server", PermissionDefault.OP, purpur);
|
||||
+
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "drop.spawners", "Allows the user to drop spawner cage when broken with diamond pickaxe with silk touch", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "place.spawners", "Allows the user to place spawner cage in the world", PermissionDefault.FALSE, purpur);
|
||||
+
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "mending_shift_click", "Allows the user to use shift-right-click to mend items", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "inventory_totem", "Uses a totem from anywhere in the user's inventory on death", PermissionDefault.FALSE, purpur);
|
||||
+
|
||||
+ Permission anvil = DefaultPermissions.registerPermission(PREFIX + "anvil", "Allows the user to use all anvil color and format abilities", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "anvil.color", "Allows the user to use color codes in an anvil", PermissionDefault.FALSE, anvil);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "anvil.minimessage", "Allows the user to use minimessage tags in an anvil", PermissionDefault.FALSE, anvil);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "anvil.remove_italics", "Allows the user to remove italics in an anvil", PermissionDefault.FALSE, anvil);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "anvil.format", "Allows the user to use format codes in an anvil", PermissionDefault.FALSE, anvil);
|
||||
+ anvil.recalculatePermissibles();
|
||||
+
|
||||
+ Permission book = DefaultPermissions.registerPermission(PREFIX + "book", "Allows the user to use color codes on books", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "book.color.edit", "Allows the user to use color codes on books when editing", PermissionDefault.FALSE, book);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "book.color.sign", "Allows the user to use color codes on books when signing", PermissionDefault.FALSE, book);
|
||||
+ book.recalculatePermissibles();
|
||||
+
|
||||
+ Permission sign = DefaultPermissions.registerPermission(PREFIX + "sign", "Allows the user to use all sign abilities", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "sign.edit", "Allows the user to click signs to open sign editor", PermissionDefault.FALSE, sign);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "sign.color", "Allows the user to use color codes on signs", PermissionDefault.FALSE, sign);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "sign.style", "Allows the user to use style codes on signs", PermissionDefault.FALSE, sign);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "sign.magic", "Allows the user to use magic/obfuscate code on signs", PermissionDefault.FALSE, sign);
|
||||
+ sign.recalculatePermissibles();
|
||||
+
|
||||
+ Permission ride = DefaultPermissions.registerPermission("allow.ride", "Allows the user to ride all mobs", PermissionDefault.FALSE, purpur);
|
||||
+ for (String mob : mobs) {
|
||||
+ DefaultPermissions.registerPermission("allow.ride." + mob, "Allows the user to ride " + mob, PermissionDefault.FALSE, ride);
|
||||
+ }
|
||||
+ ride.recalculatePermissibles();
|
||||
+
|
||||
+ Permission special = DefaultPermissions.registerPermission("allow.special", "Allows the user to use all mobs special abilities", PermissionDefault.FALSE, purpur);
|
||||
+ for (String mob : mobs) {
|
||||
+ DefaultPermissions.registerPermission("allow.special." + mob, "Allows the user to use " + mob + " special ability", PermissionDefault.FALSE, special);
|
||||
+ }
|
||||
+ special.recalculatePermissibles();
|
||||
+
|
||||
+ Permission powered = DefaultPermissions.registerPermission("allow.powered", "Allows the user to toggle all mobs powered state", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission("allow.powered.creeper", "Allows the user to toggle creeper powered state", PermissionDefault.FALSE, powered);
|
||||
+ powered.recalculatePermissibles();
|
||||
+
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "portal.instant", "Allows the user to bypass portal wait time", PermissionDefault.FALSE, purpur);
|
||||
+
|
||||
+ purpur.recalculatePermissibles();
|
||||
+ return purpur;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/entity/StoredEntity.java b/src/main/java/org/purpurmc/purpur/entity/StoredEntity.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..29540d55532197d2381a52ea9222b5785d224ef8
|
||||
@@ -3551,18 +3482,96 @@ index 0000000000000000000000000000000000000000..cbdad4cf09c170064a45644efdf7aa0b
|
||||
+ return getOrDefault(key.translationKey());
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/test/java/org/bukkit/AnnotationTest.java b/src/test/java/org/bukkit/AnnotationTest.java
|
||||
index f9e4b16a21d6cc6c9cbbe06d20c8af25e72e3ddb..4028b230e7fe1c78520f227a377a2a61e8381ecc 100644
|
||||
--- a/src/test/java/org/bukkit/AnnotationTest.java
|
||||
+++ b/src/test/java/org/bukkit/AnnotationTest.java
|
||||
@@ -47,6 +47,10 @@ public class AnnotationTest {
|
||||
"org/bukkit/plugin/java/PluginClassLoader",
|
||||
// Generic functional interface
|
||||
"org/bukkit/util/Consumer",
|
||||
+ // Purpur start
|
||||
+ "gg/pufferfish/pufferfish/sentry/SentryContext",
|
||||
+ "gg/pufferfish/pufferfish/sentry/SentryContext$State",
|
||||
+ // Purpur end
|
||||
// Paper start
|
||||
"io/papermc/paper/util/TransformingRandomAccessList",
|
||||
"io/papermc/paper/util/TransformingRandomAccessList$TransformedListIterator",
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/util/permissions/PurpurPermissions.java b/src/main/java/org/purpurmc/purpur/util/permissions/PurpurPermissions.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..50647252ed654fbcf71db72a283fb8080ecee6d3
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/util/permissions/PurpurPermissions.java
|
||||
@@ -0,0 +1,87 @@
|
||||
+package org.purpurmc.purpur.util.permissions;
|
||||
+
|
||||
+import org.bukkit.entity.Entity;
|
||||
+import org.bukkit.entity.EntityType;
|
||||
+import org.bukkit.entity.Mob;
|
||||
+import org.bukkit.permissions.Permission;
|
||||
+import org.bukkit.permissions.PermissionDefault;
|
||||
+import org.bukkit.util.permissions.DefaultPermissions;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.util.HashSet;
|
||||
+import java.util.Set;
|
||||
+
|
||||
+public final class PurpurPermissions {
|
||||
+ private static final String ROOT = "purpur";
|
||||
+ private static final String PREFIX = ROOT + ".";
|
||||
+ private static final Set<String> mobs = new HashSet<>();
|
||||
+
|
||||
+ static {
|
||||
+ for (EntityType mob : EntityType.values()) {
|
||||
+ Class<? extends Entity> clazz = mob.getEntityClass();
|
||||
+ if (clazz != null && Mob.class.isAssignableFrom(clazz)) {
|
||||
+ mobs.add(mob.getName());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static Permission registerPermissions() {
|
||||
+ Permission purpur = DefaultPermissions.registerPermission(ROOT, "Gives the user the ability to use all Purpur utilities and commands", PermissionDefault.FALSE);
|
||||
+
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "enderchest.rows.six", "Gives the user six rows of enderchest space", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "enderchest.rows.five", "Gives the user five rows of enderchest space", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "enderchest.rows.four", "Gives the user four rows of enderchest space", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "enderchest.rows.three", "Gives the user three rows of enderchest space", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "enderchest.rows.two", "Gives the user two rows of enderchest space", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "enderchest.rows.one", "Gives the user one row of enderchest space", PermissionDefault.FALSE, purpur);
|
||||
+
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "debug.f3n", "Allows the user to use F3+N keybind to swap gamemodes", PermissionDefault.FALSE, purpur);
|
||||
+
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "joinfullserver", "Allows the user to join a full server", PermissionDefault.OP, purpur);
|
||||
+
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "bypassIdleKick", "Allows the user to bypass being kicked while idle", PermissionDefault.FALSE, purpur);
|
||||
+
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "inventory_totem", "Allows the user to use totem of undying anywhere in their inventory", PermissionDefault.FALSE, purpur);
|
||||
+
|
||||
+ Permission anvil = DefaultPermissions.registerPermission(PREFIX + "anvil", "Allows the user to use all anvil color and format abilities", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "anvil.color", "Allows the user to use color codes in an anvil", PermissionDefault.FALSE, anvil);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "anvil.minimessage", "Allows the user to use minimessage tags in an anvil", PermissionDefault.FALSE, anvil);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "anvil.remove_italics", "Allows the user to remove italics in an anvil", PermissionDefault.FALSE, anvil);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "anvil.format", "Allows the user to use format codes in an anvil", PermissionDefault.FALSE, anvil);
|
||||
+ anvil.recalculatePermissibles();
|
||||
+
|
||||
+ Permission book = DefaultPermissions.registerPermission(PREFIX + "book", "Allows the user to use color codes on books", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "book.color.edit", "Allows the user to use color codes on books when editing", PermissionDefault.FALSE, book);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "book.color.sign", "Allows the user to use color codes on books when signing", PermissionDefault.FALSE, book);
|
||||
+ book.recalculatePermissibles();
|
||||
+
|
||||
+ Permission sign = DefaultPermissions.registerPermission(PREFIX + "sign", "Allows the user to use all sign abilities", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "sign.edit", "Allows the user to click signs to open sign editor", PermissionDefault.TRUE, sign);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "sign.color", "Allows the user to use color codes on signs", PermissionDefault.FALSE, sign);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "sign.style", "Allows the user to use style codes on signs", PermissionDefault.FALSE, sign);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "sign.magic", "Allows the user to use magic/obfuscate code on signs", PermissionDefault.FALSE, sign);
|
||||
+ sign.recalculatePermissibles();
|
||||
+
|
||||
+ Permission ride = DefaultPermissions.registerPermission("allow.ride", "Allows the user to ride all mobs", PermissionDefault.FALSE, purpur);
|
||||
+ for (String mob : mobs) {
|
||||
+ DefaultPermissions.registerPermission("allow.ride." + mob, "Allows the user to ride " + mob, PermissionDefault.FALSE, ride);
|
||||
+ }
|
||||
+ ride.recalculatePermissibles();
|
||||
+
|
||||
+ Permission special = DefaultPermissions.registerPermission("allow.special", "Allows the user to use all mobs special abilities", PermissionDefault.FALSE, purpur);
|
||||
+ for (String mob : mobs) {
|
||||
+ DefaultPermissions.registerPermission("allow.special." + mob, "Allows the user to use " + mob + " special ability", PermissionDefault.FALSE, special);
|
||||
+ }
|
||||
+ special.recalculatePermissibles();
|
||||
+
|
||||
+ Permission powered = DefaultPermissions.registerPermission("allow.powered", "Allows the user to toggle all mobs powered state", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission("allow.powered.creeper", "Allows the user to toggle creeper powered state", PermissionDefault.FALSE, powered);
|
||||
+ powered.recalculatePermissibles();
|
||||
+
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "portal.instant", "Allows the user to bypass portal wait time", PermissionDefault.FALSE, purpur);
|
||||
+
|
||||
+ purpur.recalculatePermissibles();
|
||||
+ return purpur;
|
||||
+ }
|
||||
+}
|
||||
@@ -1,32 +1,40 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Github Actions <no-reply@github.com>
|
||||
Date: Fri, 21 Jun 2024 03:34:00 +0000
|
||||
Date: Thu, 16 Jan 2025 11:21:11 +0000
|
||||
Subject: [PATCH] Purpur generated-api Changes
|
||||
|
||||
Original license: MIT
|
||||
Original project: https://github.com/PurpurMC/Purpur
|
||||
|
||||
Commit: 16ce24aa7eb08232030e4570e027f7baefa5f3f9
|
||||
Commit: dd4143984219cea8440913b7918322b5ba59265a
|
||||
|
||||
diff --git a/com/destroystokyo/paper/entity/ai/VanillaGoal.java b/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
||||
index 35dfd25f21ca67b7f4d69326500980f4a021ef49..a9816fbfa466b3fe3f82c19aeeeb564c660e4b6a 100644
|
||||
--- a/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
||||
+++ b/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
||||
@@ -441,6 +441,18 @@ public interface VanillaGoal<T extends Mob> extends Goal<T> {
|
||||
diff --git a/src/generated/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java b/src/generated/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
||||
index f15a7b4471cd31a487467ec7ecf7a186fa887a51..f09fefe6821d8b2b8c8f055985bacc2e042ca569 100644
|
||||
--- a/src/generated/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
||||
+++ b/src/generated/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
||||
@@ -441,6 +441,26 @@ public interface VanillaGoal<T extends Mob> extends Goal<T> {
|
||||
|
||||
GoalKey<Zombie> ZOMBIE_ATTACK_TURTLE_EGG = create("zombie_attack_turtle_egg", Zombie.class);
|
||||
|
||||
+ // Purpur start
|
||||
+ // Purpur start - Ridables
|
||||
+ GoalKey<Mob> MOB_HAS_RIDER = GoalKey.of(Mob.class, NamespacedKey.minecraft("has_rider"));
|
||||
+ GoalKey<AbstractHorse> HORSE_HAS_RIDER = GoalKey.of(AbstractHorse.class, NamespacedKey.minecraft("horse_has_rider"));
|
||||
+ GoalKey<Llama> LLAMA_HAS_RIDER = GoalKey.of(Llama.class, NamespacedKey.minecraft("llama_has_rider"));
|
||||
+ // Purpur end - Ridables
|
||||
+ // Purpur start - Phantoms attracted to crystals and crystals shoot phantoms
|
||||
+ GoalKey<Phantom> FIND_CRYSTAL = GoalKey.of(Phantom.class, NamespacedKey.minecraft("find_crystal"));
|
||||
+ GoalKey<Phantom> ORBIT_CRYSTAL = GoalKey.of(Phantom.class, NamespacedKey.minecraft("orbit_crystal"));
|
||||
+ // Purpur end - Phantoms attracted to crystals and crystals shoot phantoms
|
||||
+ // Purpur start - Add option to disable zombie aggressiveness towards villagers when lagging
|
||||
+ GoalKey<Drowned> DROWNED_ATTACK_VILLAGER = GoalKey.of(Drowned.class, NamespacedKey.minecraft("drowned_attack_villager"));
|
||||
+ GoalKey<Zombie> ZOMBIE_ATTACK_VILLAGER = GoalKey.of(Zombie.class, NamespacedKey.minecraft("zombie_attack_villager"));
|
||||
+ // Purpur end - Add option to disable zombie aggressiveness towards villagers when lagging
|
||||
+ // Purpur start - Configurable chance for wolves to spawn rabid
|
||||
+ GoalKey<Wolf> AVOID_RABID_WOLF = GoalKey.of(Wolf.class, NamespacedKey.minecraft("avoid_rabid_wolf"));
|
||||
+ // Purpur end - Configurable chance for wolves to spawn rabid
|
||||
+ // Purpur start - Iron golem poppy calms anger
|
||||
+ GoalKey<IronGolem> RECEIVE_FLOWER = GoalKey.of(IronGolem.class, NamespacedKey.minecraft("receive_flower"));
|
||||
+ // Purpur end
|
||||
+ // Purpur end - Iron golem poppy calms anger
|
||||
+
|
||||
private static <T extends Mob> GoalKey<T> create(final String key, final Class<T> type) {
|
||||
return GoalKey.of(type, NamespacedKey.minecraft(key));
|
||||
@@ -2866,7 +2866,7 @@ index 45ed63797b13e114bf3795c80a6c3967d8eb2351..00000000000000000000000000000000
|
||||
- }
|
||||
-}
|
||||
diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java
|
||||
index 74384a56eebbce41d431db2507c55eddbcf50a41..7d1ac11cfffbaf7d799f2a0032221fb23ee6daf5 100644
|
||||
index 71eb845a4d3b8b6ec3b816a0f20ec807e0f9a86d..a43419c23aa0f6fd809caf5a841cb138f350b7ba 100644
|
||||
--- a/src/main/java/org/bukkit/command/Command.java
|
||||
+++ b/src/main/java/org/bukkit/command/Command.java
|
||||
@@ -33,16 +33,6 @@ public abstract class Command {
|
||||
@@ -2910,7 +2910,7 @@ index abe256e1e45ce28036da4aa1586715bc8a1a3414..9eab8024e0675865f17669847759a26d
|
||||
return i >= j && i <= k;
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||
index a09b5458191eb5df4787859b72a37fa1fa2bffba..6551a74b5c900d52f162c38c2b2ca94a8fc5c444 100644
|
||||
index 32c81559507a8e5085c91d466cda69d0dc11327e..7e9f1237f197094318fc41df2e2fa58fbc81e528 100644
|
||||
--- a/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||
+++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||
@@ -39,7 +39,6 @@ public class SimpleCommandMap implements CommandMap {
|
||||
@@ -2931,7 +2931,7 @@ index a09b5458191eb5df4787859b72a37fa1fa2bffba..6551a74b5c900d52f162c38c2b2ca94a
|
||||
boolean registered = register(label, command, false, fallbackPrefix);
|
||||
@@ -166,23 +164,13 @@ public class SimpleCommandMap implements CommandMap {
|
||||
parsedArgs = event.getArgs();
|
||||
// Purpur end
|
||||
// Purpur end - ExecuteCommandEvent
|
||||
|
||||
- // Paper start - Plugins do weird things to workaround normal registration
|
||||
- if (target.timings == null) {
|
||||
@@ -2942,7 +2942,7 @@ index a09b5458191eb5df4787859b72a37fa1fa2bffba..6551a74b5c900d52f162c38c2b2ca94a
|
||||
try {
|
||||
- try (co.aikar.timings.Timing ignored = target.timings.startTiming()) { // Paper - use try with resources
|
||||
// Note: we don't return the result of target.execute as thats success / failure, we return handled (true) or not handled (false)
|
||||
target.execute(sender, sentCommandLabel, parsedArgs); // Purpur
|
||||
target.execute(sender, sentCommandLabel, parsedArgs); // Purpur - ExecuteCommandEvent
|
||||
- } // target.timings.stopTiming(); // Spigot // Paper
|
||||
} catch (CommandException ex) {
|
||||
server.getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerCommandException(ex, target, sender, args))); // Paper
|
||||
@@ -3047,7 +3047,7 @@ index 2fae50a9d1f0d9ecd91036697dedd64bc56f7d3b..2daf3d072e4441778ca566387d6a80d6
|
||||
}
|
||||
diff --git a/src/main/java/org/spigotmc/CustomTimingsHandler.java b/src/main/java/org/spigotmc/CustomTimingsHandler.java
|
||||
deleted file mode 100644
|
||||
index 12946bd55fcf7c40d39081779a7fa30049ee6165..0000000000000000000000000000000000000000
|
||||
index 5fbacfcf108432c5187aa9a4092d00d7d5b0fd53..0000000000000000000000000000000000000000
|
||||
--- a/src/main/java/org/spigotmc/CustomTimingsHandler.java
|
||||
+++ /dev/null
|
||||
@@ -1,67 +0,0 @@
|
||||
@@ -3101,7 +3101,7 @@ index 12946bd55fcf7c40d39081779a7fa30049ee6165..00000000000000000000000000000000
|
||||
- public CustomTimingsHandler(@NotNull String name) {
|
||||
- Timing timing;
|
||||
-
|
||||
- new AuthorNagException("Deprecated use of CustomTimingsHandler. Please Switch to Timings.of ASAP").printStackTrace();
|
||||
- new AuthorNagException("Deprecated use of CustomTimingsHandler. Timings has been removed.").printStackTrace();
|
||||
- try {
|
||||
- final Method ofSafe = TimingsManager.class.getDeclaredMethod("getHandler", String.class, String.class, Timing.class);
|
||||
- ofSafe.setAccessible(true);
|
||||
@@ -3119,10 +3119,10 @@ index 12946bd55fcf7c40d39081779a7fa30049ee6165..00000000000000000000000000000000
|
||||
-
|
||||
-}
|
||||
diff --git a/src/test/java/org/bukkit/AnnotationTest.java b/src/test/java/org/bukkit/AnnotationTest.java
|
||||
index 4028b230e7fe1c78520f227a377a2a61e8381ecc..0f3683841bf853752f802dd1b05a081a49681992 100644
|
||||
index 37feafd626aaa17aba888d7ff13728b3c6f26d4d..e42619418c1a3e3dac22e7310bb9d64b42b9f6a7 100644
|
||||
--- a/src/test/java/org/bukkit/AnnotationTest.java
|
||||
+++ b/src/test/java/org/bukkit/AnnotationTest.java
|
||||
@@ -54,15 +54,6 @@ public class AnnotationTest {
|
||||
@@ -50,15 +50,6 @@ public class AnnotationTest {
|
||||
// Paper start
|
||||
"io/papermc/paper/util/TransformingRandomAccessList",
|
||||
"io/papermc/paper/util/TransformingRandomAccessList$TransformedListIterator",
|
||||
@@ -7,10 +7,10 @@ Original license: MIT
|
||||
Original project: https://github.com/KeYiMC/KeYi
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||
index 347d6cbee7daba824adf798c1ec9895ae1da67ab..d5e4d34ca02567105ad92f7a1d7e3cc0f579320c 100644
|
||||
index 886a954b1a12e895f5d54fd35a9acb36673e3733..02cf7995d15487a4958ba5a5a19018d24d707b80 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -4040,4 +4040,23 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||
@@ -4021,4 +4021,23 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||
sendDeathScreen(message);
|
||||
}
|
||||
// Purpur end
|
||||
@@ -9,10 +9,10 @@ Original project: https://github.com/Cryptite/Slice
|
||||
Co-authored-by: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||
index d5e4d34ca02567105ad92f7a1d7e3cc0f579320c..acb8975fc2598e69c21be8d97a42a61c3944649d 100644
|
||||
index 02cf7995d15487a4958ba5a5a19018d24d707b80..31fcd0512b8b9ad2a36d8338c581972a450cda7c 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -3731,6 +3731,33 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||
@@ -3732,6 +3732,33 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||
String getClientBrandName();
|
||||
// Paper end
|
||||
|
||||
@@ -11,13 +11,21 @@ Original project: https://github.com/LeavesMC/Leaves
|
||||
This patch is Powered by ReplayMod(https://github.com/ReplayMod)
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||
index 2477a560ed345116cd9d4e90f98694b84a1faf28..17d3f7839de56821d51a3008c73e78f1bedc98ad 100644
|
||||
index 196109f427fb1169785b82b4cfb52c53329d2bea..3e999a4805fbf733dc1530e7dbf23aa10642cb39 100644
|
||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||
@@ -3158,4 +3158,10 @@ public final class Bukkit {
|
||||
@@ -3048,6 +3048,7 @@ public final class Bukkit {
|
||||
return server.spigot();
|
||||
}
|
||||
|
||||
+
|
||||
// Purpur start - Bring back server name
|
||||
/**
|
||||
* Get the name of this server
|
||||
@@ -3176,4 +3177,10 @@ public final class Bukkit {
|
||||
server.clearBlockHighlights();
|
||||
}
|
||||
// Purpur end
|
||||
// Purpur end - Debug Marker API
|
||||
+
|
||||
+ // Leaves start - Photographer API
|
||||
+ public static @NotNull org.leavesmc.leaves.entity.PhotographerManager getPhotographerManager() {
|
||||
@@ -26,10 +34,10 @@ index 2477a560ed345116cd9d4e90f98694b84a1faf28..17d3f7839de56821d51a3008c73e78f1
|
||||
+ // Leaves end - Photographer API
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index 582c1f053020dff2cde8a1a7a1a760a84e856b7c..b3f3e70382f0c1e497d71c4490ee06740d7fa27a 100644
|
||||
index 335db5f0893df51c65c5aab7f11fd6aef59a191d..78ddb4f8e90d797920ed7664055ba81d3c7cde41 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -62,6 +62,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -66,6 +66,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -37,10 +45,10 @@ index 582c1f053020dff2cde8a1a7a1a760a84e856b7c..b3f3e70382f0c1e497d71c4490ee0674
|
||||
|
||||
/**
|
||||
* Represents a server implementation.
|
||||
@@ -2806,4 +2807,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
@@ -2859,4 +2860,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
*/
|
||||
void clearBlockHighlights();
|
||||
// Purpur end
|
||||
// Purpur end - Debug Marker API
|
||||
+
|
||||
+ // Leaves start - Photographer API
|
||||
+ @NotNull PhotographerManager getPhotographerManager();
|
||||
189
Leaf-Server/build.gradle.kts.patch
Normal file
189
Leaf-Server/build.gradle.kts.patch
Normal file
@@ -0,0 +1,189 @@
|
||||
--- a/gale-server/build.gradle.kts
|
||||
+++ b/gale-server/build.gradle.kts
|
||||
@@ -9,10 +_,11 @@
|
||||
}
|
||||
|
||||
val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
|
||||
+val leafMavenPublicUrl = "https://maven.nostal.ink/repository/maven-snapshots/" // Leaf - project setup - Add publish repo
|
||||
|
||||
dependencies {
|
||||
mache("io.papermc:mache:1.21.4+build.7")
|
||||
- paperclip("io.papermc:paperclip:3.0.3")
|
||||
+ paperclip("cn.dreeam:quantumleaper:1.0.0-SNAPSHOT") // Leaf - project setup - Use own paperclip fork
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
}
|
||||
|
||||
@@ -31,7 +_,30 @@
|
||||
}
|
||||
}
|
||||
|
||||
- activeFork = gale
|
||||
+ // Leaf start - project setup
|
||||
+ val leaf = forks.register("leaf") {
|
||||
+ forks = gale
|
||||
+ upstream.patchRepo("paperServer") {
|
||||
+ upstreamRepo = gale.patchedRepo("paperServer")
|
||||
+ patchesDir = rootDirectory.dir("leaf-server/paper-patches")
|
||||
+ outputDir = rootDirectory.dir("paper-server")
|
||||
+ }
|
||||
+ upstream.patchDir("galeServer") {
|
||||
+ upstreamPath = "gale-server"
|
||||
+ excludes = setOf(
|
||||
+ "src/minecraft",
|
||||
+ "paper-patches",
|
||||
+ "minecraft-patches",
|
||||
+ "build.gradle.kts",
|
||||
+ "build.gradle.kts.patch"
|
||||
+ )
|
||||
+ patchesDir = rootDirectory.dir("leaf-server/gale-patches")
|
||||
+ outputDir = rootDirectory.dir("gale-server")
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ activeFork = leaf
|
||||
+ // Leaf end - project setup
|
||||
// Gale end - project setup
|
||||
|
||||
spigot {
|
||||
@@ -56,6 +_,7 @@
|
||||
libraryRepositories.addAll(
|
||||
"https://repo.maven.apache.org/maven2/",
|
||||
paperMavenPublicUrl,
|
||||
+ leafMavenPublicUrl // Leaf - project setup - Add publish repo
|
||||
)
|
||||
}
|
||||
|
||||
@@ -119,10 +_,14 @@
|
||||
main {
|
||||
java { srcDir("../paper-server/src/main/java") }
|
||||
resources { srcDir("../paper-server/src/main/resources") }
|
||||
+ java { srcDir("../gale-server/src/main/java") } // Leaf - project setup
|
||||
+ resources { srcDir("../gale-server/src/main/resources") } // Leaf - project setup
|
||||
}
|
||||
test {
|
||||
java { srcDir("../paper-server/src/test/java") }
|
||||
resources { srcDir("../paper-server/src/test/resources") }
|
||||
+ java { srcDir("../gale-server/src/test/java") } // Leaf - project setup
|
||||
+ resources { srcDir("../gale-server/src/test/resources") } // Leaf - project setup
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,10 +_,19 @@
|
||||
}
|
||||
|
||||
dependencies {
|
||||
- implementation(project(":gale-api")) // Gale - project setup - Depend on own API
|
||||
+ implementation(project(":leaf-api")) // Gale - project setup - Depend on own API // Leaf - project setup
|
||||
+
|
||||
+ // Leaf start - Libraries
|
||||
+ implementation("com.github.thatsmusic99:ConfigurationMaster-API:v2.0.0-rc.2") { // Leaf Config
|
||||
+ exclude(group = "org.yaml", module = "snakeyaml")
|
||||
+ }
|
||||
+ implementation("com.github.luben:zstd-jni:1.5.6-9") // LinearPaper
|
||||
+ implementation("org.lz4:lz4-java:1.8.0") // LinearPaper
|
||||
+ implementation("com.github.ben-manes.caffeine:caffeine:3.1.8")
|
||||
+ // Leaf end - Libraries
|
||||
implementation("ca.spottedleaf:concurrentutil:0.0.3")
|
||||
- implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+
|
||||
- implementation("org.jline:jline-terminal-jni:3.27.1") // fall back to jni on java 21
|
||||
+ implementation("org.jline:jline-terminal-ffm:3.28.0") // use ffm on java 22+ // Leaf - Bump Dependencies
|
||||
+ implementation("org.jline:jline-terminal-jni:3.28.0") // fall back to jni on java 21 // Leaf - Bump Dependencies
|
||||
implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
||||
implementation("net.kyori:adventure-text-serializer-ansi:4.18.0") // Keep in sync with adventureVersion from Paper-API build file
|
||||
|
||||
@@ -160,35 +_,47 @@
|
||||
all its classes to check if they are plugins.
|
||||
Scanning takes about 1-2 seconds so adding this speeds up the server start.
|
||||
*/
|
||||
- implementation("org.apache.logging.log4j:log4j-core:2.19.0")
|
||||
- log4jPlugins.annotationProcessorConfigurationName("org.apache.logging.log4j:log4j-core:2.19.0") // Needed to generate meta for our Log4j plugins
|
||||
+ // Leaf start - Bump Dependencies
|
||||
+ implementation("org.apache.logging.log4j:log4j-core:2.24.3")
|
||||
+ log4jPlugins.annotationProcessorConfigurationName("org.apache.logging.log4j:log4j-core:2.24.3") // Needed to generate meta for our Log4j plugins
|
||||
runtimeOnly(log4jPlugins.output)
|
||||
alsoShade(log4jPlugins.output)
|
||||
|
||||
- implementation("com.velocitypowered:velocity-native:3.3.0-SNAPSHOT") {
|
||||
+ implementation("com.velocitypowered:velocity-native:3.4.0-SNAPSHOT") {
|
||||
isTransitive = false
|
||||
}
|
||||
- implementation("io.netty:netty-codec-haproxy:4.1.97.Final") // Add support for proxy protocol
|
||||
- implementation("org.apache.logging.log4j:log4j-iostreams:2.24.1")
|
||||
+ implementation("io.netty:netty-codec-haproxy:4.1.116.Final") // Add support for proxy protocol
|
||||
+ implementation("org.apache.logging.log4j:log4j-iostreams:2.24.3")
|
||||
+ // Leaf end - Bump Dependencies
|
||||
implementation("org.ow2.asm:asm-commons:9.7.1")
|
||||
implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT")
|
||||
implementation("commons-lang:commons-lang:2.6")
|
||||
- runtimeOnly("org.xerial:sqlite-jdbc:3.47.0.0")
|
||||
+ runtimeOnly("org.xerial:sqlite-jdbc:3.47.2.0") // Leaf - Bump Dependencies
|
||||
runtimeOnly("com.mysql:mysql-connector-j:9.1.0")
|
||||
- runtimeOnly("com.lmax:disruptor:3.4.4")
|
||||
-
|
||||
- runtimeOnly("org.apache.maven:maven-resolver-provider:3.9.6")
|
||||
- runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.18")
|
||||
- runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.18")
|
||||
-
|
||||
- testImplementation("io.github.classgraph:classgraph:4.8.47") // For mob goal test
|
||||
- testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
|
||||
- testImplementation("org.junit.platform:junit-platform-suite-engine:1.10.0")
|
||||
- testImplementation("org.hamcrest:hamcrest:2.2")
|
||||
- testImplementation("org.mockito:mockito-core:5.14.1")
|
||||
- mockitoAgent("org.mockito:mockito-core:5.14.1") { isTransitive = false } // Configure mockito agent that is needed in newer java versions
|
||||
+ runtimeOnly("com.lmax:disruptor:3.4.4") // Dreeam TODO - Waiting Log4j 3.x to support disruptor 4.0.0
|
||||
+
|
||||
+ // Leaf start - Bump Dependencies
|
||||
+ runtimeOnly("org.apache.maven:maven-resolver-provider:3.9.9")
|
||||
+ runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.22") // Dreeam TODO - Update to 2.0.1
|
||||
+ runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.22") // Dreeam TODO - Update to 2.0.1
|
||||
+ // Leaf end - Bump Dependencies
|
||||
+
|
||||
+ // Purpur start
|
||||
+ implementation("org.mozilla:rhino-runtime:1.7.15")
|
||||
+ implementation("org.mozilla:rhino-engine:1.7.15")
|
||||
+ implementation("dev.omega24:upnp4j:1.0")
|
||||
+ // Purpur end
|
||||
+
|
||||
+ // Leaf start - Bump Dependencies
|
||||
+ testImplementation("io.github.classgraph:classgraph:4.8.179") // For mob goal test
|
||||
+ testImplementation("org.junit.jupiter:junit-jupiter:5.11.4")
|
||||
+ testImplementation("org.junit.platform:junit-platform-suite-engine:1.11.4")
|
||||
+ testImplementation("org.hamcrest:hamcrest:3.0")
|
||||
+ testImplementation("org.mockito:mockito-core:5.15.2")
|
||||
+ mockitoAgent("org.mockito:mockito-core:5.15.2") { isTransitive = false } // Configure mockito agent that is needed in newer java versions
|
||||
testImplementation("org.ow2.asm:asm-tree:9.7.1")
|
||||
- testImplementation("org.junit-pioneer:junit-pioneer:2.2.0") // CartesianTest
|
||||
+ testImplementation("org.junit-pioneer:junit-pioneer:2.3.0") // CartesianTest
|
||||
+ // Leaf end - Bump Dependencies
|
||||
|
||||
implementation("net.neoforged:srgutils:1.0.9") // Mappings handling
|
||||
implementation("net.neoforged:AutoRenamingTool:2.0.3") // Remap plugins
|
||||
@@ -202,6 +_,8 @@
|
||||
// Spark
|
||||
implementation("me.lucko:spark-api:0.1-20240720.200737-2")
|
||||
implementation("me.lucko:spark-paper:1.10.119-SNAPSHOT")
|
||||
+
|
||||
+ implementation("io.netty:netty-all:4.1.116.Final") // Leaf - Bump Dependencies // Dreeam TODO - Update to 4.2.0
|
||||
}
|
||||
|
||||
// Gale start - hide irrelevant compilation warnings
|
||||
@@ -226,14 +_,14 @@
|
||||
val gitBranch = git.exec(providers, "rev-parse", "--abbrev-ref", "HEAD").get().trim()
|
||||
attributes(
|
||||
"Main-Class" to "org.bukkit.craftbukkit.Main",
|
||||
- "Implementation-Title" to "Gale", // Gale - branding changes
|
||||
+ "Implementation-Title" to "Leaf", // Gale - branding changes // Leaf - Rebrand
|
||||
"Implementation-Version" to implementationVersion,
|
||||
"Implementation-Vendor" to date,
|
||||
- "Specification-Title" to "Gale", // Gale - branding changes
|
||||
+ "Specification-Title" to "Leaf", // Gale - branding changes // Leaf - Rebrand
|
||||
"Specification-Version" to project.version,
|
||||
- "Specification-Vendor" to "GaleMC Team", // Gale - branding changes
|
||||
- "Brand-Id" to "galemc:gale", // Gale - branding changes
|
||||
- "Brand-Name" to "Gale", // Gale - branding changes
|
||||
+ "Specification-Vendor" to "Winds Studio", // Gale - branding changes // Leaf - Rebrand
|
||||
+ "Brand-Id" to "winds-studio:leaf", // Gale - branding changes // Leaf - Rebrand
|
||||
+ "Brand-Name" to "Leaf", // Gale - branding changes // Leaf - Rebrand
|
||||
"Build-Number" to (build ?: ""),
|
||||
"Build-Time" to buildTime.toString(),
|
||||
"Git-Branch" to gitBranch,
|
||||
@@ -0,0 +1,33 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Mon, 29 Apr 2024 14:18:58 -0400
|
||||
Subject: [PATCH] Fix Pufferfish and Purpur patches
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/galemc/gale/version/AbstractPaperVersionFetcher.java b/src/main/java/org/galemc/gale/version/AbstractPaperVersionFetcher.java
|
||||
index fab5d5af9ec6a20810ce5e437dd617684cc5768f..d0a031014ec410142d59c8edd577bf035b7e407b 100644
|
||||
--- a/src/main/java/org/galemc/gale/version/AbstractPaperVersionFetcher.java
|
||||
+++ b/src/main/java/org/galemc/gale/version/AbstractPaperVersionFetcher.java
|
||||
@@ -101,10 +101,10 @@ public abstract class AbstractPaperVersionFetcher implements VersionFetcher {
|
||||
// Gale end - branding changes - version fetcher
|
||||
|
||||
return switch (distance) {
|
||||
- case DISTANCE_ERROR -> text("Error obtaining version information", NamedTextColor.YELLOW);
|
||||
- case 0 -> text("You are running the latest version", NamedTextColor.GREEN);
|
||||
- case DISTANCE_UNKNOWN -> text("Unknown version", NamedTextColor.YELLOW);
|
||||
- default -> text("You are " + distance + " version(s) behind", NamedTextColor.YELLOW)
|
||||
+ case DISTANCE_ERROR -> text("* Error obtaining version information", NamedTextColor.RED); // Purpur
|
||||
+ case 0 -> text("* You are running the latest version", NamedTextColor.GREEN); // Purpur
|
||||
+ case DISTANCE_UNKNOWN -> text("* Unknown version", NamedTextColor.YELLOW); // Purpur
|
||||
+ default -> text("* You are " + distance + " version(s) behind", NamedTextColor.YELLOW) // Purpur
|
||||
.append(Component.newline())
|
||||
.append(text("Download the new version at: ")
|
||||
.append(text(this.downloadPage, NamedTextColor.GOLD) // Gale - branding changes - version fetcher
|
||||
@@ -149,6 +149,6 @@ public abstract class AbstractPaperVersionFetcher implements VersionFetcher {
|
||||
return null;
|
||||
}
|
||||
|
||||
- return text("Previous version: " + oldVersion, NamedTextColor.GRAY, TextDecoration.ITALIC);
|
||||
+ return text("Previous: " + oldVersion, NamedTextColor.GRAY, TextDecoration.ITALIC); // Purpur
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,10 @@ Original license: MIT
|
||||
Original project: https://github.com/KeYiMC/KeYi
|
||||
|
||||
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
index 5b9e55bc9c7a67487400f59ba6bfaa9f68c6504a..838d15a8c81f168b6d94adb602a996123313aaea 100644
|
||||
index a12b0fa0df84fc44861cebbfbdc4a06a990accce..37896174667b884fcdc83b0a613686d76b66f247 100644
|
||||
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
@@ -126,7 +126,7 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
||||
@@ -120,7 +120,7 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Mon, 15 Jan 2024 10:53:10 -0500
|
||||
Subject: [PATCH] Reduce items finding hopper nearby check
|
||||
|
||||
This patch add a toggle for items checking MinecraftHopper nearby,
|
||||
|
||||
But still recommend to turn-off `checkForMinecartNearItemWhileActive`
|
||||
Since `Reduce-hopper-item-checks.patch` will cause lag under massive dropped items
|
||||
|
||||
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
index 37896174667b884fcdc83b0a613686d76b66f247..c449e8cbe66a751800072f4b77186dc1ee09865e 100644
|
||||
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
@@ -78,6 +78,7 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
||||
public int duration = 100;
|
||||
public int nearbyItemMaxAge = 1200;
|
||||
public int checkForMinecartNearItemInterval = 20;
|
||||
+ public boolean checkForMinecartNearItemWhileActive = false; // Leaf - Make it configurable and reorder code
|
||||
public boolean checkForMinecartNearItemWhileInactive = true;
|
||||
public double maxItemHorizontalDistance = 24.0;
|
||||
public double maxItemVerticalDistance = 4.0;
|
||||
62
Leaf-Server/minecraft-patches/features/0001-Rebrand.patch
Normal file
62
Leaf-Server/minecraft-patches/features/0001-Rebrand.patch
Normal file
@@ -0,0 +1,62 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Encode42 <me@encode42.dev>
|
||||
Date: Thu, 16 Sep 2021 20:39:45 -0400
|
||||
Subject: [PATCH] Rebrand
|
||||
|
||||
|
||||
diff --git a/net/minecraft/CrashReport.java b/net/minecraft/CrashReport.java
|
||||
index 3e0e88afcf010d9a3d46e48bca5cbdf98fe97544..60afaa49e54ff1a52bc52b99ad160682a68dcd97 100644
|
||||
--- a/net/minecraft/CrashReport.java
|
||||
+++ b/net/minecraft/CrashReport.java
|
||||
@@ -30,6 +30,7 @@ public class CrashReport {
|
||||
private boolean trackingStackTrace = true;
|
||||
private StackTraceElement[] uncategorizedStackTrace = new StackTraceElement[0];
|
||||
private final SystemReport systemReport = new SystemReport();
|
||||
+ private List<String> extraInfo = List.of("", "DO NOT REPORT THIS TO PAPER OR GALE! REPORT TO LEAF INSTEAD!", ""); // Leaf - Purpur
|
||||
|
||||
public CrashReport(String title, Throwable exception) {
|
||||
io.papermc.paper.util.StacktraceDeobfuscator.INSTANCE.deobfuscateThrowable(exception); // Paper
|
||||
@@ -130,7 +131,7 @@ public class CrashReport {
|
||||
}
|
||||
|
||||
public String getFriendlyReport(ReportType type) {
|
||||
- return this.getFriendlyReport(type, List.of());
|
||||
+ return this.getFriendlyReport(type, extraInfo); // Leaf - Purpur
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -161,7 +162,7 @@ public class CrashReport {
|
||||
}
|
||||
|
||||
public boolean saveToFile(Path path, ReportType type) {
|
||||
- return this.saveToFile(path, type, List.of());
|
||||
+ return this.saveToFile(path, type, extraInfo); // Leaf - Purpur
|
||||
}
|
||||
|
||||
public SystemReport getSystemReport() {
|
||||
diff --git a/net/minecraft/world/damagesource/DamageSource.java b/net/minecraft/world/damagesource/DamageSource.java
|
||||
index aea139e47a0866c63c0fc6728840e5ad92a26403..3d8d7460ab31e9183e26ada76ad05378f8bb925d 100644
|
||||
--- a/net/minecraft/world/damagesource/DamageSource.java
|
||||
+++ b/net/minecraft/world/damagesource/DamageSource.java
|
||||
@@ -66,7 +66,7 @@ public class DamageSource {
|
||||
|
||||
public DamageSource customEventDamager(Entity entity) {
|
||||
if (this.directEntity != null) {
|
||||
- throw new IllegalStateException("Cannot set custom event damager when direct entity is already set (report a bug to Paper, if you think this is a Gale bug, please report it at https://github.com/GaleMC/Gale/issues)"); // Gale - branding changes
|
||||
+ throw new IllegalStateException("Cannot set custom event damager when direct entity is already set (report a bug to Paper, if you think this is a Leaf bug, please report it at https://github.com/Winds-Studio/Leaf/issues)"); // Gale - branding changes // Leaf
|
||||
}
|
||||
DamageSource damageSource = this.cloneInstance();
|
||||
damageSource.customEventDamager = entity;
|
||||
diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
index 3abb8aefcca325e28f0af07bd859be74f0aee08d..7fff86a4956f59b2f4a9f7e283256879c034c1b8 100644
|
||||
--- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
+++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
@@ -288,7 +288,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
We do not want people to report thread issues to Paper,
|
||||
but we do want people to report thread issues to Gale.
|
||||
*/
|
||||
- org.apache.logging.log4j.LogManager.getLogger().fatal(msg + " (" + file.toString().replaceAll(".+[\\\\/]", "") + " - " + x + "," + z + ") Go clean it up to remove this message. /minecraft:tp " + (x<<4)+" 128 "+(z<<4) + " - DO NOT REPORT THIS TO PAPER OR GALE - You may ask for help on Discord, but do not file an issue. These error messages can not be removed. - If you think this is a Gale bug, please report it at https://github.com/GaleMC/Gale/issues)");
|
||||
+ org.apache.logging.log4j.LogManager.getLogger().fatal(msg + " (" + file.toString().replaceAll(".+[\\\\/]", "") + " - " + x + "," + z + ") Go clean it up to remove this message. /minecraft:tp " + (x<<4)+" 128 "+(z<<4) + " - DO NOT REPORT THIS TO PAPER OR LEAF - You may ask for help on Discord, but do not file an issue. These error messages can not be removed. - If you think this is a Leaf bug, please report it at https://github.com/Winds-Studio/Leaf/issues)"); // Leaf
|
||||
// Gale end - branding changes
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Wed, 12 Oct 2022 10:42:15 -0400
|
||||
Subject: [PATCH] Leaf Config
|
||||
|
||||
Leaf Config v3
|
||||
including load config, backup old or outdated config, and add config to spark profiler automatically.
|
||||
|
||||
TODO - Dreeam:
|
||||
Add per world config
|
||||
Add config reload
|
||||
|
||||
diff --git a/net/minecraft/server/Main.java b/net/minecraft/server/Main.java
|
||||
index 9aa664537cc37e44db46d5a2a64ae3116938c681..841546cef2a98427ae78ca2a07693391eb0d3035 100644
|
||||
--- a/net/minecraft/server/Main.java
|
||||
+++ b/net/minecraft/server/Main.java
|
||||
@@ -112,6 +112,7 @@ public class Main {
|
||||
Bootstrap.bootStrap();
|
||||
Bootstrap.validate();
|
||||
Util.startTimerHackThread();
|
||||
+ org.dreeam.leaf.config.LeafConfig.loadConfig(); // Leaf
|
||||
Path path1 = Paths.get("server.properties");
|
||||
DedicatedServerSettings dedicatedServerSettings = new DedicatedServerSettings(optionSet); // CraftBukkit - CLI argument support
|
||||
dedicatedServerSettings.forceSave();
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 0da1eeab6a2f8336283a62ebcb3aa0d1b1933c85..8794ae06ac574b399cc2dbb3fa61b6ef51d8062d 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1175,6 +1175,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
org.spigotmc.WatchdogThread.tick();
|
||||
// Paper end
|
||||
org.spigotmc.WatchdogThread.hasStarted = true; // Paper
|
||||
+ org.dreeam.leaf.config.LeafConfig.regSparkExtraConfig(); // Leaf - Leaf Config
|
||||
Arrays.fill(this.recentTps, 20);
|
||||
// Paper start - further improve server tick loop
|
||||
long tickSection = Util.getNanos();
|
||||
@@ -0,0 +1,166 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Kevin Raneri <kevin.raneri@gmail.com>
|
||||
Date: Wed, 10 Nov 2021 00:37:03 -0500
|
||||
Subject: [PATCH] Pufferfish: Optimize mob spawning
|
||||
|
||||
Original license: GPL v3
|
||||
Original project: https://github.com/pufferfish-gg/Pufferfish
|
||||
|
||||
Co-authored-by: booky10 <boooky10@gmail.com>
|
||||
|
||||
This patch aims to reduce the main-thread impact of mob spawning by
|
||||
offloading as much work as possible to other threads. It is possible for
|
||||
inconsistencies to come up, but when they happen they never interfere
|
||||
with the server's operation (they don't produce errors), and side
|
||||
effects are limited to more or less mobs being spawned in any particular
|
||||
tick.
|
||||
|
||||
It is possible to disable this optimization if it is not required or if
|
||||
it interferes with any plugins. On servers with thousands of entities,
|
||||
this can result in performance gains of up to 15%, which is significant
|
||||
and, in my opinion, worth the low risk of minor mob-spawning-related
|
||||
inconsistencies.
|
||||
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 8794ae06ac574b399cc2dbb3fa61b6ef51d8062d..5f0fa04a4ed2b0073240edbf39aeed9007911e63 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -287,6 +287,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
public boolean isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
|
||||
private final Set<String> pluginsBlockingSleep = new java.util.HashSet<>(); // Paper - API to allow/disallow tick sleeping
|
||||
public static final long SERVER_INIT = System.nanoTime(); // Paper - Lag compensation
|
||||
+ public gg.pufferfish.pufferfish.util.AsyncExecutor mobSpawnExecutor = new gg.pufferfish.pufferfish.util.AsyncExecutor("MobSpawning"); // Pufferfish - optimize mob spawning
|
||||
|
||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> threadFunction) {
|
||||
ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.init(); // Paper - rewrite data converter system
|
||||
diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index f2e24d52240a84ff7ca69ad2c8ec0d1c197467c0..30dc45b2201bf7435d7f38866dfa4b5fbbf44957 100644
|
||||
--- a/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -362,6 +362,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
LOGGER.info("JMX monitoring enabled");
|
||||
}
|
||||
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncMobSpawning.enabled) mobSpawnExecutor.start(); // Pufferfish
|
||||
+
|
||||
return true;
|
||||
}
|
||||
}
|
||||
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
||||
index b6127fff62c49809cfa54e39a35c89f45f46c66c..fde7de56f46502a1cc268318684e67ac2fbd5157 100644
|
||||
--- a/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -179,6 +179,8 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
}
|
||||
// Paper end - chunk tick iteration optimisations
|
||||
|
||||
+ public boolean firstRunSpawnCounts = true; // Pufferfish
|
||||
+ public final java.util.concurrent.atomic.AtomicBoolean _pufferfish_spawnCountsReady = new java.util.concurrent.atomic.AtomicBoolean(false); // Pufferfish - optimize countmobs
|
||||
|
||||
public ServerChunkCache(
|
||||
ServerLevel level,
|
||||
@@ -513,6 +515,43 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
|
||||
this.broadcastChangedChunks(); // Gale - Purpur - remove vanilla profiler
|
||||
}
|
||||
+
|
||||
+ // Pufferfish start - optimize mob spawning
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncMobSpawning.enabled) {
|
||||
+ for (ServerPlayer player : this.level.players) {
|
||||
+ // Paper start - per player mob spawning backoff
|
||||
+ for (int ii = 0; ii < ServerPlayer.MOBCATEGORY_TOTAL_ENUMS; ii++) {
|
||||
+ player.mobCounts[ii] = 0;
|
||||
+
|
||||
+ int newBackoff = player.mobBackoffCounts[ii] - 1; // TODO make configurable bleed // TODO use nonlinear algorithm?
|
||||
+ if (newBackoff < 0) {
|
||||
+ newBackoff = 0;
|
||||
+ }
|
||||
+ player.mobBackoffCounts[ii] = newBackoff;
|
||||
+ }
|
||||
+ // Paper end - per player mob spawning backoff
|
||||
+ }
|
||||
+ if (firstRunSpawnCounts) {
|
||||
+ firstRunSpawnCounts = false;
|
||||
+ _pufferfish_spawnCountsReady.set(true);
|
||||
+ }
|
||||
+ if (_pufferfish_spawnCountsReady.getAndSet(false)) {
|
||||
+ net.minecraft.server.MinecraftServer.getServer().mobSpawnExecutor.submit(() -> {
|
||||
+ int mapped = distanceManager.getNaturalSpawnChunkCount();
|
||||
+ ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet.Iterator<Entity> objectiterator =
|
||||
+ level.entityTickList.entities.iterator(ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet.ITERATOR_FLAG_SEE_ADDITIONS);
|
||||
+ try {
|
||||
+ gg.pufferfish.pufferfish.util.IterableWrapper<Entity> wrappedIterator =
|
||||
+ new gg.pufferfish.pufferfish.util.IterableWrapper<>(objectiterator);
|
||||
+ lastSpawnState = NaturalSpawner.createState(mapped, wrappedIterator, this::getFullChunk, null, true);
|
||||
+ } finally {
|
||||
+ objectiterator.finishedIterating();
|
||||
+ }
|
||||
+ _pufferfish_spawnCountsReady.set(true);
|
||||
+ });
|
||||
+ }
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
}
|
||||
|
||||
private void broadcastChangedChunks() { // Gale - Purpur - remove vanilla profiler
|
||||
@@ -559,6 +598,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
int naturalSpawnChunkCount = this.distanceManager.getNaturalSpawnChunkCount();
|
||||
// Paper start - Optional per player mob spawns
|
||||
if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled
|
||||
+ if (!org.dreeam.leaf.config.modules.async.AsyncMobSpawning.enabled) { // Pufferfish - moved down when async processing
|
||||
// re-set mob counts
|
||||
for (ServerPlayer player : this.level.players) {
|
||||
// Paper start - per player mob spawning backoff
|
||||
@@ -573,12 +613,16 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
}
|
||||
// Paper end - per player mob spawning backoff
|
||||
}
|
||||
- spawnState = NaturalSpawner.createState(naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, null, true);
|
||||
+ lastSpawnState = NaturalSpawner.createState(naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, null, true); // Pufferfish - async mob spawning
|
||||
+ } // Pufferfish - (endif) moved down when async processing
|
||||
} else {
|
||||
- spawnState = NaturalSpawner.createState(naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, !this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new LocalMobCapCalculator(this.chunkMap) : null, false);
|
||||
+ // Pufferfish start - async mob spawning
|
||||
+ lastSpawnState = NaturalSpawner.createState(naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, !this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new LocalMobCapCalculator(this.chunkMap) : null, false);
|
||||
+ _pufferfish_spawnCountsReady.set(true);
|
||||
+ // Pufferfish end
|
||||
}
|
||||
// Paper end - Optional per player mob spawns
|
||||
- this.lastSpawnState = spawnState;
|
||||
+ //this.lastSpawnState = spawnState; // Pufferfish - this is managed asynchronously
|
||||
// Gale start - MultiPaper - skip unnecessary mob spawning computations
|
||||
} else {
|
||||
spawnState = null;
|
||||
@@ -596,7 +640,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
}
|
||||
// Paper end - PlayerNaturallySpawnCreaturesEvent
|
||||
boolean flag = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getLevelData().getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit
|
||||
- filteredSpawningCategories = NaturalSpawner.getFilteredSpawningCategories(spawnState, this.spawnFriendlies, this.spawnEnemies, flag, this.level); // CraftBukkit
|
||||
+ filteredSpawningCategories = NaturalSpawner.getFilteredSpawningCategories(lastSpawnState, this.spawnFriendlies, this.spawnEnemies, flag, this.level); // CraftBukkit // Pufferfish
|
||||
} else {
|
||||
filteredSpawningCategories = List.of();
|
||||
}
|
||||
@@ -604,8 +648,8 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
for (LevelChunk levelChunk : chunks) {
|
||||
ChunkPos pos = levelChunk.getPos();
|
||||
levelChunk.incrementInhabitedTime(timeInhabited);
|
||||
- if (!filteredSpawningCategories.isEmpty() && this.level.getWorldBorder().isWithinBounds(pos) && this.chunkMap.anyPlayerCloseEnoughForSpawning(pos, true)) { // Spigot
|
||||
- NaturalSpawner.spawnForChunk(this.level, levelChunk, spawnState, filteredSpawningCategories);
|
||||
+ if (!filteredSpawningCategories.isEmpty() && this.level.getWorldBorder().isWithinBounds(pos) && (!org.dreeam.leaf.config.modules.async.AsyncMobSpawning.enabled || _pufferfish_spawnCountsReady.get()) && this.chunkMap.anyPlayerCloseEnoughForSpawning(pos, true)) { // Spigot // Pufferfish
|
||||
+ NaturalSpawner.spawnForChunk(this.level, levelChunk, lastSpawnState, filteredSpawningCategories); // Pufferfish
|
||||
}
|
||||
|
||||
if (true) { // Paper - rewrite chunk system
|
||||
diff --git a/net/minecraft/world/level/entity/EntityTickList.java b/net/minecraft/world/level/entity/EntityTickList.java
|
||||
index 423779a2b690f387a4f0bd07b97b50e0baefda76..dec51066fc3f57b7bdc56195313c219f45a7fbee 100644
|
||||
--- a/net/minecraft/world/level/entity/EntityTickList.java
|
||||
+++ b/net/minecraft/world/level/entity/EntityTickList.java
|
||||
@@ -9,7 +9,7 @@ import javax.annotation.Nullable;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
public class EntityTickList {
|
||||
- private final ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<net.minecraft.world.entity.Entity> entities = new ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<>(); // Paper - rewrite chunk system
|
||||
+ public final ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<net.minecraft.world.entity.Entity> entities = new ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<>(); // Paper - rewrite chunk system // Pufferfish - private->public
|
||||
|
||||
private void ensureActiveIsNotIterated() {
|
||||
// Paper - rewrite chunk system
|
||||
@@ -0,0 +1,334 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Sauve <paul@technove.co>
|
||||
Date: Fri, 15 Jan 2021 19:05:01 -0600
|
||||
Subject: [PATCH] Pufferfish: Dynamic Activation of Brain
|
||||
|
||||
Dreeam TODO: waiting Paper dealing with the newGoalRate
|
||||
|
||||
Original license: GPL v3
|
||||
Original project: https://github.com/pufferfish-gg/Pufferfish
|
||||
|
||||
This replaces the current method of ticking an inactive entity's
|
||||
pathfinder 1/4 times with a new method that's dynamic based off how far
|
||||
away it is from a player. If an entity is within 32 blocks, it gets
|
||||
ticked every tick. If it's within 45 blocks, it gets ticked every other
|
||||
tick. If it's within 55 blocks, it gets ticked once every three ticks.
|
||||
(these numbers have since been changed, but the idea is the same.)
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/io/papermc/paper/entity/activation/ActivationRange.java b/io/papermc/paper/entity/activation/ActivationRange.java
|
||||
index a04302728819f28ab724d474a3d06a916f3d1d99..47463babd445763c861ac5c4713b5bd3be5cbeec 100644
|
||||
--- a/io/papermc/paper/entity/activation/ActivationRange.java
|
||||
+++ b/io/papermc/paper/entity/activation/ActivationRange.java
|
||||
@@ -171,6 +171,22 @@ public final class ActivationRange {
|
||||
}
|
||||
|
||||
ActivationRange.activateEntity(entity);
|
||||
+
|
||||
+ // Pufferfish start
|
||||
+ if (org.dreeam.leaf.config.modules.opt.DynamicActivationofBrain.enabled && entity.getType().dabEnabled &&
|
||||
+ (!org.dreeam.leaf.config.modules.opt.DynamicActivationofBrain.dontEnableIfInWater || entity.getType().is(net.minecraft.tags.EntityTypeTags.CAN_BREATHE_UNDER_WATER) || !entity.isInWaterOrBubble())) { // Leaf - Option for dontEnableIfInWater
|
||||
+ if (!entity.activatedPriorityReset) {
|
||||
+ entity.activatedPriorityReset = true;
|
||||
+ entity.activatedPriority = org.dreeam.leaf.config.modules.opt.DynamicActivationofBrain.maximumActivationPrio;
|
||||
+ }
|
||||
+ int squaredDistance = (int) player.distanceToSqr(entity);
|
||||
+ entity.activatedPriority = squaredDistance > org.dreeam.leaf.config.modules.opt.DynamicActivationofBrain.startDistanceSquared ?
|
||||
+ Math.max(1, Math.min(squaredDistance >> org.dreeam.leaf.config.modules.opt.DynamicActivationofBrain.activationDistanceMod, entity.activatedPriority)) :
|
||||
+ 1;
|
||||
+ } else {
|
||||
+ entity.activatedPriority = 1;
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -182,11 +198,11 @@ public final class ActivationRange {
|
||||
*/
|
||||
private static void activateEntity(final Entity entity) {
|
||||
if (MinecraftServer.currentTick > entity.activatedTick) {
|
||||
- if (entity.defaultActivationState) {
|
||||
+ if (entity.defaultActivationState) { // Pufferfish - diff on change
|
||||
entity.activatedTick = MinecraftServer.currentTick;
|
||||
return;
|
||||
}
|
||||
- if (entity.activationType.boundingBox.intersects(entity.getBoundingBox())) {
|
||||
+ if (entity.activationType.boundingBox.intersects(entity.getBoundingBox())) { // Pufferfish - diff on change
|
||||
entity.activatedTick = MinecraftServer.currentTick;
|
||||
}
|
||||
}
|
||||
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
||||
index ba0b5961535f0dbffda5216a6e4657ea85f30eb7..e52d976f0c1c5eacdc8608b204c3a178b9b17446 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -781,6 +781,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
this.entityTickList
|
||||
.forEach(
|
||||
entity -> {
|
||||
+ entity.activatedPriorityReset = false; // Pufferfish - DAB
|
||||
if (!entity.isRemoved()) {
|
||||
if (!tickRateManager.isEntityFrozen(entity)) {
|
||||
entity.checkDespawn();
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 8470698181040b5d164a353aeb1dfa907765b80e..36f5c28fa2fb3ba2cb5a4b2614c6b8d934659892 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -335,6 +335,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
public boolean freezeLocked = false; // Paper - Freeze Tick Lock API
|
||||
public boolean fixedPose = false; // Paper - Expand Pose API
|
||||
private final int despawnTime; // Paper - entity despawn time limit
|
||||
+ public boolean activatedPriorityReset = false; // Pufferfish - DAB
|
||||
+ public int activatedPriority = org.dreeam.leaf.config.modules.opt.DynamicActivationofBrain.maximumActivationPrio; // Pufferfish - DAB (golf score)
|
||||
public final io.papermc.paper.entity.activation.ActivationType activationType = io.papermc.paper.entity.activation.ActivationType.activationTypeFor(this); // Paper - EAR 2/tracking ranges
|
||||
// Paper start - EAR 2
|
||||
public final boolean defaultActivationState;
|
||||
diff --git a/net/minecraft/world/entity/EntityType.java b/net/minecraft/world/entity/EntityType.java
|
||||
index 13cfe61fe500e6798b9129c7c559a7af65378a22..303bd2d3ea5c313477c8ab48359a01f230327447 100644
|
||||
--- a/net/minecraft/world/entity/EntityType.java
|
||||
+++ b/net/minecraft/world/entity/EntityType.java
|
||||
@@ -1063,6 +1063,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
|
||||
private final boolean canSpawnFarFromPlayer;
|
||||
private final int clientTrackingRange;
|
||||
private final int updateInterval;
|
||||
+ public boolean dabEnabled = false; // Pufferfish
|
||||
private final String descriptionId;
|
||||
@Nullable
|
||||
private Component description;
|
||||
diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java
|
||||
index f3eec8b75fcda47e6632a2a7db9a238b515bc8a0..cc452ca41c336891473fae98b8681768c52f822d 100644
|
||||
--- a/net/minecraft/world/entity/Mob.java
|
||||
+++ b/net/minecraft/world/entity/Mob.java
|
||||
@@ -217,10 +217,10 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
super.inactiveTick();
|
||||
- if (this.goalSelector.inactiveTick()) {
|
||||
+ if (this.goalSelector.inactiveTick(this.activatedPriority, true)) { // Pufferfish - pass activated priroity
|
||||
this.goalSelector.tick();
|
||||
}
|
||||
- if (this.targetSelector.inactiveTick()) {
|
||||
+ if (this.targetSelector.inactiveTick(this.activatedPriority, true)) { // Pufferfish - pass activated priority
|
||||
this.targetSelector.tick();
|
||||
}
|
||||
}
|
||||
@@ -847,10 +847,14 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
this.sensing.tick();
|
||||
int i = this.tickCount + this.getId();
|
||||
if (i % 2 != 0 && this.tickCount > 1) {
|
||||
+ if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
||||
this.targetSelector.tickRunningGoals(false);
|
||||
+ if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
||||
this.goalSelector.tickRunningGoals(false);
|
||||
} else {
|
||||
+ if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
||||
this.targetSelector.tick();
|
||||
+ if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
||||
this.goalSelector.tick();
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/behavior/VillagerPanicTrigger.java b/net/minecraft/world/entity/ai/behavior/VillagerPanicTrigger.java
|
||||
index f6c673b1abe53afcb14fd68d590431027ed29f67..21deb221b87ecb70c8a0dc963ab79124b26ac930 100644
|
||||
--- a/net/minecraft/world/entity/ai/behavior/VillagerPanicTrigger.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/VillagerPanicTrigger.java
|
||||
@@ -36,7 +36,11 @@ public class VillagerPanicTrigger extends Behavior<Villager> {
|
||||
|
||||
@Override
|
||||
protected void tick(ServerLevel level, Villager owner, long gameTime) {
|
||||
- if (gameTime % 100L == 0L) {
|
||||
+ // Pufferfish start
|
||||
+ if (owner.nextGolemPanic < 0) owner.nextGolemPanic = gameTime + 100;
|
||||
+ if (--owner.nextGolemPanic < gameTime) {
|
||||
+ owner.nextGolemPanic = -1;
|
||||
+ // Pufferfish end
|
||||
owner.spawnGolemIfNeeded(level, gameTime, 3);
|
||||
}
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/ai/goal/GoalSelector.java b/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
||||
index b816b2de8eb327060ca6ea7c4afc17373fa77ff6..e82e32407cec6109b9c3b0106295217f4a3f4aa2 100644
|
||||
--- a/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
||||
+++ b/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
||||
@@ -36,9 +36,13 @@ public class GoalSelector {
|
||||
}
|
||||
|
||||
// Paper start - EAR 2
|
||||
- public boolean inactiveTick() {
|
||||
+ public boolean inactiveTick(int tickRate, boolean inactive) { // Pufferfish start
|
||||
+ if (inactive && !org.dreeam.leaf.config.modules.opt.DynamicActivationofBrain.enabled) tickRate = 4; // reset to Paper's
|
||||
+ tickRate = Math.min(tickRate, 3); // Dreeam TODO - Waiting Paper
|
||||
this.curRate++;
|
||||
- return this.curRate % 3 == 0; // TODO newGoalRate was already unused in 1.20.4, check if this is correct
|
||||
+ //return this.curRate % 3 == 0; // TODO newGoalRate was already unused in 1.20.4, check if this is correct
|
||||
+ return this.curRate % tickRate == 0;
|
||||
+ // Pufferfish end
|
||||
}
|
||||
|
||||
public boolean hasTasks() {
|
||||
diff --git a/net/minecraft/world/entity/animal/allay/Allay.java b/net/minecraft/world/entity/animal/allay/Allay.java
|
||||
index 0c863f8b4683516916d51a0c49921c6bb5608e9f..8f1d66d005413fe4eadb993b61568fa84336345a 100644
|
||||
--- a/net/minecraft/world/entity/animal/allay/Allay.java
|
||||
+++ b/net/minecraft/world/entity/animal/allay/Allay.java
|
||||
@@ -241,8 +241,10 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS
|
||||
return 0.4F;
|
||||
}
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel level) {
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick(level, this);
|
||||
AllayAi.updateActivity(this);
|
||||
super.customServerAiStep(level);
|
||||
diff --git a/net/minecraft/world/entity/animal/axolotl/Axolotl.java b/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
index c351b0808422221b5358d6e546a206ef75e8173f..4fb36e2a6d71b79219e10f5089eb0daebf830ee7 100644
|
||||
--- a/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
+++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
@@ -298,8 +298,10 @@ public class Axolotl extends Animal implements VariantHolder<Axolotl.Variant>, B
|
||||
return true;
|
||||
}
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel level) {
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick(level, this);
|
||||
AxolotlAi.updateActivity(this);
|
||||
if (!this.isNoAi()) {
|
||||
diff --git a/net/minecraft/world/entity/animal/frog/Frog.java b/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
index 67df4c0f47b2809c912f1dfb52124ca5e2c30b7b..10a0779bf8611ade19e64031bb00beb277e98598 100644
|
||||
--- a/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
+++ b/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
@@ -182,8 +182,10 @@ public class Frog extends Animal implements VariantHolder<Holder<FrogVariant>> {
|
||||
.ifPresent(this::setVariant);
|
||||
}
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel level) {
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick(level, this);
|
||||
FrogAi.updateActivity(this);
|
||||
super.customServerAiStep(level);
|
||||
diff --git a/net/minecraft/world/entity/animal/frog/Tadpole.java b/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||
index a04d71967976731b4858d44ac138b7ac390ef7e7..77691e10f7c511eca4384f2974e538d78d55c2ca 100644
|
||||
--- a/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||
+++ b/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||
@@ -93,8 +93,10 @@ public class Tadpole extends AbstractFish {
|
||||
return SoundEvents.TADPOLE_FLOP;
|
||||
}
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel level) {
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick(level, this);
|
||||
TadpoleAi.updateActivity(this);
|
||||
super.customServerAiStep(level);
|
||||
diff --git a/net/minecraft/world/entity/animal/goat/Goat.java b/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
index 25c0c27979f49f08d0cc150de9afe6112f115666..35d492106506c28412fea5c59c7b67c809ce231c 100644
|
||||
--- a/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
+++ b/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
@@ -182,8 +182,10 @@ public class Goat extends Animal {
|
||||
return (Brain<Goat>)super.getBrain();
|
||||
}
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel level) {
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick(level, this);
|
||||
GoatAi.updateActivity(this);
|
||||
super.customServerAiStep(level);
|
||||
diff --git a/net/minecraft/world/entity/monster/hoglin/Hoglin.java b/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
||||
index fe0cd6790875631cb98a73457d53d782b369bf1d..f93d6564c59ae9a144b56ea3355c4c7425b99eeb 100644
|
||||
--- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
||||
+++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
||||
@@ -154,8 +154,10 @@ public class Hoglin extends Animal implements Enemy, HoglinBase {
|
||||
return (Brain<Hoglin>)super.getBrain();
|
||||
}
|
||||
|
||||
+ private int behaviorTick; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel level) {
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick(level, this);
|
||||
HoglinAi.updateActivity(this);
|
||||
if (this.isConverting()) {
|
||||
diff --git a/net/minecraft/world/entity/monster/piglin/Piglin.java b/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||
index daef9043d0eacea948e39b1daa2618287aa40f14..4c30f967c12e11c2e7ae24977509762747dd36de 100644
|
||||
--- a/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||
+++ b/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||
@@ -340,8 +340,10 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento
|
||||
return !this.cannotHunt;
|
||||
}
|
||||
|
||||
+ private int behaviorTick; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel level) {
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick(level, this);
|
||||
PiglinAi.updateActivity(this);
|
||||
super.customServerAiStep(level);
|
||||
diff --git a/net/minecraft/world/entity/monster/warden/Warden.java b/net/minecraft/world/entity/monster/warden/Warden.java
|
||||
index 1c56355fe9c216a7cc8afbbbe94988a0079c8244..f7b9824519fc22b35a7b5f4f0ef9f9891162a493 100644
|
||||
--- a/net/minecraft/world/entity/monster/warden/Warden.java
|
||||
+++ b/net/minecraft/world/entity/monster/warden/Warden.java
|
||||
@@ -280,8 +280,10 @@ public class Warden extends Monster implements VibrationSystem {
|
||||
}
|
||||
}
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel level) {
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick(level, this);
|
||||
super.customServerAiStep(level);
|
||||
if ((this.tickCount + this.getId()) % 120 == 0) {
|
||||
diff --git a/net/minecraft/world/entity/npc/Villager.java b/net/minecraft/world/entity/npc/Villager.java
|
||||
index ee7b4080a9e1e51273f4b48f61caaa21ad7e59d9..a02cd34bcd643c7abad3a355043cb88d035143a0 100644
|
||||
--- a/net/minecraft/world/entity/npc/Villager.java
|
||||
+++ b/net/minecraft/world/entity/npc/Villager.java
|
||||
@@ -178,6 +178,8 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
(villager, holder) -> holder.is(PoiTypes.MEETING)
|
||||
);
|
||||
|
||||
+ public long nextGolemPanic = -1; // Pufferfish
|
||||
+
|
||||
public Villager(EntityType<? extends Villager> entityType, Level level) {
|
||||
this(entityType, level, VillagerType.PLAINS);
|
||||
}
|
||||
@@ -282,6 +284,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
}
|
||||
// Paper end - EAR 2
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel level) {
|
||||
// Paper start - EAR 2
|
||||
@@ -289,7 +292,11 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
}
|
||||
protected void customServerAiStep(ServerLevel level, final boolean inactive) {
|
||||
// Paper end - EAR 2
|
||||
- if (!inactive) this.getBrain().tick(level, this); // Paper - EAR 2
|
||||
+ // Pufferfish start
|
||||
+ if (!inactive && this.behaviorTick++ % this.activatedPriority == 0) {
|
||||
+ this.getBrain().tick(level, this); // Paper - EAR 2
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
if (this.assignProfessionWhenSpawned) {
|
||||
this.assignProfessionWhenSpawned = false;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Kevin Raneri <kevin.raneri@gmail.com>
|
||||
Date: Sat, 11 Dec 2021 22:20:45 -0500
|
||||
Subject: [PATCH] Pufferfish: Throttle goal selector during inactive ticking
|
||||
|
||||
Original license: GPL v3
|
||||
Original project: https://github.com/pufferfish-gg/Pufferfish
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java
|
||||
index cc452ca41c336891473fae98b8681768c52f822d..1b74114d0833eb9ca2c854122727d4bf76a11071 100644
|
||||
--- a/net/minecraft/world/entity/Mob.java
|
||||
+++ b/net/minecraft/world/entity/Mob.java
|
||||
@@ -213,11 +213,13 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
return this.lookControl;
|
||||
}
|
||||
|
||||
+ int _pufferfish_inactiveTickDisableCounter = 0; // Pufferfish - throttle inactive goal selector ticking
|
||||
// Paper start
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
super.inactiveTick();
|
||||
- if (this.goalSelector.inactiveTick(this.activatedPriority, true)) { // Pufferfish - pass activated priroity
|
||||
+ boolean isThrottled = org.dreeam.leaf.config.modules.opt.ThrottleInactiveGoalSelectorTick.enabled && _pufferfish_inactiveTickDisableCounter++ % 20 != 0; // Pufferfish - throttle inactive goal selector ticking
|
||||
+ if (this.goalSelector.inactiveTick(this.activatedPriority, true) && !isThrottled) { // Pufferfish - pass activated priroity // Pufferfish - throttle inactive goal selector ticking
|
||||
this.goalSelector.tick();
|
||||
}
|
||||
if (this.targetSelector.inactiveTick(this.activatedPriority, true)) { // Pufferfish - pass activated priority
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,227 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Mon, 29 Apr 2024 14:18:58 -0400
|
||||
Subject: [PATCH] Fix Pufferfish and Purpur patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index f348202ae2cc78586cf4b7926180c659b5fca56f..66418672e548a022980a403de912e05984137f37 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -278,7 +278,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
public static final int TICK_TIME = 1000000000 / MinecraftServer.TPS;
|
||||
private static final int SAMPLE_INTERVAL = 20; // Paper - improve server tick loop
|
||||
@Deprecated(forRemoval = true) // Paper
|
||||
- public final double[] recentTps = new double[3];
|
||||
+ public final double[] recentTps = new double[4]; // Leaf - Purpur - Add 5 second tps average in /tps
|
||||
// Spigot end
|
||||
public volatile boolean hasFullyShutdown; // Paper - Improved watchdog support
|
||||
public volatile boolean abnormalExit; // Paper - Improved watchdog support
|
||||
@@ -290,7 +290,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
public boolean lagging = false; // Purpur - Lagging threshold
|
||||
public static final long SERVER_INIT = System.nanoTime(); // Paper - Lag compensation
|
||||
protected boolean upnp = false; // Purpur - UPnP Port Forwarding
|
||||
- public gg.pufferfish.pufferfish.util.AsyncExecutor mobSpawnExecutor = new gg.pufferfish.pufferfish.util.AsyncExecutor("MobSpawning"); // Pufferfish - optimize mob spawning
|
||||
+ public gg.pufferfish.pufferfish.util.AsyncExecutor mobSpawnExecutor = new gg.pufferfish.pufferfish.util.AsyncExecutor("Leaf Async Mob Spawn Thread"); // Pufferfish - optimize mob spawning // Leaf - Fix Pufferfish and Purpur patches - Unify thread name
|
||||
|
||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> threadFunction) {
|
||||
ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.init(); // Paper - rewrite data converter system
|
||||
@@ -1256,9 +1256,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
tps15.add(currentTps, diff);
|
||||
|
||||
// Backwards compat with bad plugins
|
||||
- this.recentTps[0] = tps1.getAverage();
|
||||
- this.recentTps[1] = tps5.getAverage();
|
||||
- this.recentTps[2] = tps15.getAverage();
|
||||
+ // Leaf start - Purpur - Add 5 second tps average in /tps
|
||||
+ this.recentTps[0] = tps5s.getAverage();
|
||||
+ this.recentTps[1] = tps1.getAverage();
|
||||
+ this.recentTps[2] = tps5.getAverage();
|
||||
+ this.recentTps[3] = tps15.getAverage();
|
||||
+ // Leaf end - Purpur - Add 5 second tps average in /tps
|
||||
lagging = recentTps[0] < org.purpurmc.purpur.PurpurConfig.laggingThreshold; // Purpur - Lagging threshold
|
||||
tickSection = currentTime;
|
||||
}
|
||||
@@ -1286,7 +1289,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
this.mayHaveDelayedTasks = true;
|
||||
this.delayedTasksMaxNextTickTimeNanos = Math.max(Util.getNanos() + l, this.nextTickTimeNanos);
|
||||
// Purpur start - Configurable TPS Catchup
|
||||
- if (!org.purpurmc.purpur.PurpurConfig.tpsCatchup /*|| !gg.pufferfish.pufferfish.PufferfishConfig.tpsCatchup*/) { // Purpur - Configurable TPS Catchup
|
||||
+ if (!org.purpurmc.purpur.PurpurConfig.tpsCatchup) { // Purpur - Configurable TPS Catchup // Leaf - Fix Pufferfish and Purpur patches
|
||||
this.nextTickTimeNanos = currentTime + l;
|
||||
this.delayedTasksMaxNextTickTimeNanos = nextTickTimeNanos;
|
||||
}
|
||||
diff --git a/net/minecraft/server/gui/StatsComponent.java b/net/minecraft/server/gui/StatsComponent.java
|
||||
index 35fd539eb2bfe60ad17ab1e558a01273666acc54..445bbdc8da7f1fdbddfc4d8787d78fea9328fb65 100644
|
||||
--- a/net/minecraft/server/gui/StatsComponent.java
|
||||
+++ b/net/minecraft/server/gui/StatsComponent.java
|
||||
@@ -43,7 +43,7 @@ public class StatsComponent extends JComponent {
|
||||
}
|
||||
this.msgs[0] = "Memory use: " + l / 1024L / 1024L + " mb (" + Runtime.getRuntime().freeMemory() * 100L / Runtime.getRuntime().maxMemory() + "% free)";
|
||||
this.msgs[1] = "Avg tick: " + DECIMAL_FORMAT.format((double)this.server.getAverageTickTimeNanos() / TimeUtil.NANOSECONDS_PER_MILLISECOND) + " ms";
|
||||
- this.msgs[2] = "TPS from last 1m, 5m, 15m: " + String.join(", ", tpsAvg);
|
||||
+ this.msgs[2] = "TPS from last 5s, 1m, 5m, 15m: " + String.join(", ", tpsAvg); // Leaf - Purpur - Add 5 second tps average in /tps
|
||||
// Paper end - Improve ServerGUI
|
||||
this.values[this.vp++ & 0xFF] = (int)(l * 100L / Runtime.getRuntime().maxMemory());
|
||||
this.repaint();
|
||||
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
||||
index fde7de56f46502a1cc268318684e67ac2fbd5157..77676b38912e558a4ba0c65a009af4cdc531c5fa 100644
|
||||
--- a/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -625,7 +625,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
//this.lastSpawnState = spawnState; // Pufferfish - this is managed asynchronously
|
||||
// Gale start - MultiPaper - skip unnecessary mob spawning computations
|
||||
} else {
|
||||
- spawnState = null;
|
||||
+ lastSpawnState = null; // Leaf - Pufferfish - Optimize mob spawning
|
||||
}
|
||||
// Gale end - MultiPaper - skip unnecessary mob spawning computations
|
||||
int _int = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING);
|
||||
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 1a9664a3b00dcb8171145c3bb3f3f704272aaa73..ec6276f3335fd963c8554dbc43adf5bdfe3d2412 100644
|
||||
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1225,7 +1225,7 @@ public class ServerGamePacketListenerImpl
|
||||
}
|
||||
|
||||
if (byteTotal > byteAllowed) {
|
||||
- ServerGamePacketListenerImpl.LOGGER.warn("{} tried to send too large of a book. Book size: {} - Allowed: {} - Pages: {}", this.player.getScoreboardName(), byteTotal, byteAllowed, pageList.size());
|
||||
+ ServerGamePacketListenerImpl.LOGGER.warn("{} tried to send a book too large. Book size: {} - Allowed: {} - Pages: {}", this.player.getScoreboardName(), byteTotal, byteAllowed, pageList.size()); // Leaf - Fix Pufferfish and Purpur patches
|
||||
org.purpurmc.purpur.event.player.PlayerBookTooLargeEvent event = new org.purpurmc.purpur.event.player.PlayerBookTooLargeEvent(player.getBukkitEntity(), itemstack.asBukkitCopy()); if (event.shouldKickPlayer()) // Purpur - PlayerBookTooLargeEvent
|
||||
this.disconnectAsync(Component.literal("Book too large!"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause // Paper - add proper async disconnect
|
||||
return;
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 3f97182bc9ef86476c25deb3106dab7152014edf..3e1a5ef63d97e2ad43d98c5736a185ade7afb4bd 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -536,21 +536,31 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
// Purpur end - Add canSaveToDisk to Entity
|
||||
|
||||
+ // Gale start - JettPack - optimize sun burn tick - cache eye blockpos
|
||||
+ private BlockPos cached_eye_blockpos;
|
||||
+ private net.minecraft.world.phys.Vec3 cached_position;
|
||||
+ // Gale end - JettPack - optimize sun burn tick - cache eye blockpos
|
||||
+
|
||||
// Purpur start - copied from Mob - API for any mob to burn daylight
|
||||
public boolean isSunBurnTick() {
|
||||
if (this.level().isDay() && !this.level().isClientSide) {
|
||||
- float lightLevelDependentMagicValue = this.getLightLevelDependentMagicValue();
|
||||
- BlockPos blockPos = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ());
|
||||
- boolean flag = this.isInWaterRainOrBubble() || this.isInPowderSnow || this.wasInPowderSnow;
|
||||
- if (lightLevelDependentMagicValue > 0.5F
|
||||
- && this.random.nextFloat() * 30.0F < (lightLevelDependentMagicValue - 0.4F) * 2.0F
|
||||
- && !flag
|
||||
- && this.level().canSeeSky(blockPos)) {
|
||||
- return true;
|
||||
+ // Gale start - JettPack - optimize sun burn tick - optimizations and cache eye blockpos
|
||||
+ if (this.cached_position != this.position) {
|
||||
+ this.cached_eye_blockpos = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ());
|
||||
+ this.cached_position = this.position;
|
||||
}
|
||||
+
|
||||
+ float lightLevelDependentMagicValue = this.getLightLevelDependentMagicValue(cached_eye_blockpos); // Pass BlockPos to getBrightness
|
||||
+
|
||||
+ // Check brightness first
|
||||
+ if (lightLevelDependentMagicValue <= 0.5F) return false;
|
||||
+ if (this.random.nextFloat() * 30.0F >= (lightLevelDependentMagicValue - 0.4F) * 2.0F) return false;
|
||||
+ // Gale end - JettPack - optimize sun burn tick - optimizations and cache eye blockpos
|
||||
+ boolean flag = this.isInWaterRainOrBubble() || this.isInPowderSnow || this.wasInPowderSnow;
|
||||
+ return !flag && this.level().canSeeSky(this.cached_eye_blockpos); // Gale - JettPack - optimize sun burn tick - optimizations and cache eye blockpos
|
||||
}
|
||||
|
||||
- return false;
|
||||
+ return false; // Gale - JettPack - optimize sun burn tick - optimizations and cache eye blockpos - diff on change
|
||||
}
|
||||
// Purpur end - copied from Mob - API for any mob to burn daylight
|
||||
|
||||
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
||||
index 8728aba69ac24b52e6221ea2ddd8fc6d5a26f3f3..956c1b5422c177e0da5140c4184720d10aa4e790 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -1024,13 +1024,13 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
// Gale start - Petal - reduce skull ItemStack lookups for reduced visibility
|
||||
EntityType<?> type = lookingEntity.getType();
|
||||
// Purpur start - Mob head visibility percent
|
||||
- if (type == EntityType.SKELETON && itemBySlot.is(Items.SKELETON_SKULL)) {
|
||||
+ if (type == EntityType.SKELETON && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.SKELETON_SKULL)) {
|
||||
d *= lookingEntity.level().purpurConfig.skeletonHeadVisibilityPercent;
|
||||
- } else if (type == EntityType.ZOMBIE && itemBySlot.is(Items.ZOMBIE_HEAD)) {
|
||||
+ } else if (type == EntityType.ZOMBIE && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.ZOMBIE_HEAD)) {
|
||||
d *= lookingEntity.level().purpurConfig.zombieHeadVisibilityPercent;
|
||||
- } else if ((type == EntityType.PIGLIN || type == EntityType.PIGLIN_BRUTE) && itemBySlot.is(Items.PIGLIN_HEAD)) {
|
||||
+ } else if ((type == EntityType.PIGLIN || type == EntityType.PIGLIN_BRUTE) && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.PIGLIN_HEAD)) {
|
||||
d *= lookingEntity.level().purpurConfig.piglinHeadVisibilityPercent;
|
||||
- } else if (type == EntityType.CREEPER && itemBySlot.is(Items.CREEPER_HEAD)) {
|
||||
+ } else if (type == EntityType.CREEPER && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.CREEPER_HEAD)) {
|
||||
d *= lookingEntity.level().purpurConfig.creeperHeadVisibilityPercent;
|
||||
}
|
||||
// Purpur end - Mob head visibility percent
|
||||
diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java
|
||||
index 7b8804844ab5636323bc8d136c775f1e9591e89c..14d9dceacc82cc6c085dab8f52e59a318dd8cae5 100644
|
||||
--- a/net/minecraft/world/entity/Mob.java
|
||||
+++ b/net/minecraft/world/entity/Mob.java
|
||||
@@ -1630,11 +1630,6 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
protected void playAttackSound() {
|
||||
}
|
||||
|
||||
- // Gale start - JettPack - optimize sun burn tick - cache eye blockpos
|
||||
- private BlockPos cached_eye_blockpos;
|
||||
- private net.minecraft.world.phys.Vec3 cached_position;
|
||||
- // Gale end - JettPack - optimize sun burn tick - cache eye blockpos
|
||||
-
|
||||
public boolean isSunBurnTick() {
|
||||
// Purpur - implemented in Entity - API for any mob to burn daylight
|
||||
return super.isSunBurnTick();
|
||||
diff --git a/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java b/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
|
||||
index 6f96551ba91da214054b89a255254ca597977cc0..3f1a80db81c0f0cd7bb1d5df4a2c2cb1b6a8d2d9 100644
|
||||
--- a/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
|
||||
+++ b/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
|
||||
@@ -22,19 +22,15 @@ public class SecondaryPoiSensor extends Sensor<Villager> {
|
||||
|
||||
@Override
|
||||
protected void doTick(ServerLevel level, Villager entity) {
|
||||
+ // Purpur start - Option for Villager Clerics to farm Nether Wart - make sure clerics don't wander to soul sand when the option is off
|
||||
// Gale start - Lithium - skip secondary POI sensor if absent
|
||||
var secondaryPoi = entity.getVillagerData().getProfession().secondaryPoi();
|
||||
- if (secondaryPoi.isEmpty()) {
|
||||
- entity.getBrain().eraseMemory(MemoryModuleType.SECONDARY_JOB_SITE);
|
||||
- return;
|
||||
- }
|
||||
- // Gale end - Lithium - skip secondary POI sensor if absent
|
||||
- // Purpur start - Option for Villager Clerics to farm Nether Wart - make sure clerics don't wander to soul sand when the option is off
|
||||
Brain<?> brain = entity.getBrain();
|
||||
- if (!level.purpurConfig.villagerClericsFarmWarts && entity.getVillagerData().getProfession() == net.minecraft.world.entity.npc.VillagerProfession.CLERIC) {
|
||||
+ if (secondaryPoi.isEmpty() || (!level.purpurConfig.villagerClericsFarmWarts && entity.getVillagerData().getProfession() == net.minecraft.world.entity.npc.VillagerProfession.CLERIC)) {
|
||||
brain.eraseMemory(MemoryModuleType.SECONDARY_JOB_SITE);
|
||||
return;
|
||||
}
|
||||
+ // Gale end - Lithium - skip secondary POI sensor if absent
|
||||
// Purpur end - Option for Villager Clerics to farm Nether Wart
|
||||
ResourceKey<Level> resourceKey = level.dimension();
|
||||
BlockPos blockPos = entity.blockPosition();
|
||||
diff --git a/net/minecraft/world/entity/npc/Villager.java b/net/minecraft/world/entity/npc/Villager.java
|
||||
index 347affae3cc18e01474734d2da2699c9b7b17e26..5dbf28c15f828505d42dc31c1a2185e01a7542c1 100644
|
||||
--- a/net/minecraft/world/entity/npc/Villager.java
|
||||
+++ b/net/minecraft/world/entity/npc/Villager.java
|
||||
@@ -404,6 +404,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
this.getBrain().tick(level, this); // Paper - EAR 2
|
||||
}
|
||||
// Pufferfish end
|
||||
+ else if (this.isLobotomized && shouldRestock()) restock(); // Leaf - Purpur - Lobotomize stuck villagers
|
||||
if (this.assignProfessionWhenSpawned) {
|
||||
this.assignProfessionWhenSpawned = false;
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/projectile/Projectile.java b/net/minecraft/world/entity/projectile/Projectile.java
|
||||
index bd93ee97982038789114f17ee369208fc6413796..0b1263000f872431e44abfdd57134b6efe245641 100644
|
||||
--- a/net/minecraft/world/entity/projectile/Projectile.java
|
||||
+++ b/net/minecraft/world/entity/projectile/Projectile.java
|
||||
@@ -74,7 +74,7 @@ public abstract class Projectile extends Entity implements TraceableEntity {
|
||||
int maxChunkLoadsPerProjectile = maxProjectileChunkLoadsConfig.perProjectile.max;
|
||||
if (maxChunkLoadsPerProjectile >= 0 && this.chunksLoadedByProjectile >= maxChunkLoadsPerProjectile) {
|
||||
if (maxProjectileChunkLoadsConfig.perProjectile.removeFromWorldAfterReachLimit) {
|
||||
- this.discard();
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD); // Leaf - Purpur
|
||||
} else if (maxProjectileChunkLoadsConfig.perProjectile.resetMovementAfterReachLimit) {
|
||||
this.setDeltaMovement(0, this.getDeltaMovement().y, 0);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Mon, 17 Jul 2023 08:31:51 +0800
|
||||
Subject: [PATCH] Purpur: Configurable server mod name
|
||||
|
||||
Original license: MIT
|
||||
Original project: https://github.com/PurpurMC/Purpur
|
||||
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 66418672e548a022980a403de912e05984137f37..919dc4dddea64f97161b5e0d417dc06875f8318c 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1855,7 +1855,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
- return io.papermc.paper.ServerBuildInfo.buildInfo().brandName(); // Paper
|
||||
+ return org.dreeam.leaf.config.modules.misc.ServerBrand.serverModName; // Paper // Leaf - Configurable server mod name
|
||||
}
|
||||
|
||||
public SystemReport fillSystemReport(SystemReport systemReport) {
|
||||
@@ -0,0 +1,37 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Sun, 14 Jan 2024 05:14:09 -0500
|
||||
Subject: [PATCH] Configurable server GUI name
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/gui/MinecraftServerGui.java b/net/minecraft/server/gui/MinecraftServerGui.java
|
||||
index 614c7d9f673c926562acc8fa3b3788623900db41..51f37d026382369ac0d53b0ce64495dafe5084af 100644
|
||||
--- a/net/minecraft/server/gui/MinecraftServerGui.java
|
||||
+++ b/net/minecraft/server/gui/MinecraftServerGui.java
|
||||
@@ -51,7 +51,7 @@ public class MinecraftServerGui extends JComponent {
|
||||
} catch (Exception var3) {
|
||||
}
|
||||
|
||||
- final JFrame jFrame = new JFrame("Purpur Minecraft server"); // Purpur - Improve GUI
|
||||
+ final JFrame jFrame = new JFrame(org.dreeam.leaf.config.modules.misc.ServerBrand.serverGUIName); // Purpur - Improve GUI // Leaf - Configurable server GUI name
|
||||
final MinecraftServerGui minecraftServerGui = new MinecraftServerGui(server);
|
||||
jFrame.setDefaultCloseOperation(2);
|
||||
jFrame.add(minecraftServerGui);
|
||||
@@ -59,7 +59,7 @@ public class MinecraftServerGui extends JComponent {
|
||||
jFrame.setLocationRelativeTo(null);
|
||||
jFrame.setVisible(true);
|
||||
// Paper start - Improve ServerGUI
|
||||
- jFrame.setName("Purpur Minecraft server"); // Purpur - Improve GUI
|
||||
+ jFrame.setName(org.dreeam.leaf.config.modules.misc.ServerBrand.serverGUIName); // Purpur - Improve GUI // Leaf - Configurable server GUI name
|
||||
try {
|
||||
jFrame.setIconImage(javax.imageio.ImageIO.read(java.util.Objects.requireNonNull(MinecraftServerGui.class.getClassLoader().getResourceAsStream("logo.png"))));
|
||||
} catch (java.io.IOException ignore) {
|
||||
@@ -69,7 +69,7 @@ public class MinecraftServerGui extends JComponent {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent event) {
|
||||
if (!minecraftServerGui.isClosing.getAndSet(true)) {
|
||||
- jFrame.setTitle("Purpur Minecraft server - shutting down!"); // Purpur - Improve GUI
|
||||
+ jFrame.setTitle(org.dreeam.leaf.config.modules.misc.ServerBrand.serverGUIName + " - shutting down!"); // Purpur - Improve GUI // Leaf - Configurable server GUI name
|
||||
server.halt(true);
|
||||
minecraftServerGui.runFinalizers();
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Wed, 12 Oct 2022 14:36:58 -0400
|
||||
Subject: [PATCH] Remove vanilla username check
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
index 634933a6c98a0043cfe3ff4122dfc53e3c20a192..780d85f4afe221f8861b248457bfe6462f0b8a2a 100644
|
||||
--- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
@@ -183,7 +183,8 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||
public void handleHello(ServerboundHelloPacket packet) {
|
||||
Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet");
|
||||
// Paper start - Validate usernames
|
||||
- if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode()
|
||||
+ if (!org.dreeam.leaf.config.modules.misc.RemoveVanillaUsernameCheck.enabled // Leaf - Remove Vanilla username check
|
||||
+ && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode()
|
||||
&& io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation
|
||||
&& !this.iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation) {
|
||||
Validate.validState(StringUtil.isReasonablePlayerName(packet.name()), "Invalid characters in username");
|
||||
diff --git a/net/minecraft/server/players/GameProfileCache.java b/net/minecraft/server/players/GameProfileCache.java
|
||||
index 6fb3712f33a84a3612752dcfd9e97d67066f610e..c01e998c97e1226e7e10984493d67612dfe7ae15 100644
|
||||
--- a/net/minecraft/server/players/GameProfileCache.java
|
||||
+++ b/net/minecraft/server/players/GameProfileCache.java
|
||||
@@ -77,7 +77,7 @@ public class GameProfileCache {
|
||||
}
|
||||
|
||||
private static Optional<GameProfile> lookupGameProfile(GameProfileRepository profileRepo, String name) {
|
||||
- if (!StringUtil.isValidPlayerName(name)) {
|
||||
+ if (!StringUtil.isValidPlayerName(name, false)) { // Leaf start - Remove Vanilla username check - Directly return, skip unnecessary following logic
|
||||
return createUnknownProfile(name);
|
||||
} else {
|
||||
final AtomicReference<GameProfile> atomicReference = new AtomicReference<>();
|
||||
diff --git a/net/minecraft/util/StringUtil.java b/net/minecraft/util/StringUtil.java
|
||||
index c3a99fe7b49858bc0ca9a7f800b0db40465f6901..43f62ce3d967f534cdc4e388233933a5ad4af762 100644
|
||||
--- a/net/minecraft/util/StringUtil.java
|
||||
+++ b/net/minecraft/util/StringUtil.java
|
||||
@@ -64,6 +64,13 @@ public class StringUtil {
|
||||
}
|
||||
|
||||
public static boolean isValidPlayerName(String playerName) {
|
||||
+ // Leaf start - Remove Vanilla username check
|
||||
+ return isValidPlayerName(playerName, org.dreeam.leaf.config.modules.misc.RemoveVanillaUsernameCheck.enabled);
|
||||
+ }
|
||||
+
|
||||
+ public static boolean isValidPlayerName(String playerName, boolean bypassCheck) {
|
||||
+ if (bypassCheck) return playerName.length() <= 16;
|
||||
+ // Leaf end- Remove Vanilla username check
|
||||
return playerName.length() <= 16 && playerName.chars().filter(i -> i <= 32 || i >= 127).findAny().isEmpty();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Wed, 12 Oct 2022 14:48:45 -0400
|
||||
Subject: [PATCH] Remove Spigot Check for Broken BungeeCord Configurations
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
index c166091d1b33c8f0ea57fb723e9d9b0c83bcedfb..cbd71a13ad64edbcb6d01fd024d53b3d8d163f5d 100644
|
||||
--- a/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
@@ -172,7 +172,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
||||
if (split.length == 4) {
|
||||
this.connection.spoofedProfile = ServerHandshakePacketListenerImpl.gson.fromJson(split[3], com.mojang.authlib.properties.Property[].class);
|
||||
}
|
||||
- } else if ((split.length == 3 || split.length == 4) && (ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher(split[1]).matches())) {
|
||||
+ } else if (!org.dreeam.leaf.config.modules.misc.RemoveSpigotCheckBungee.enabled && (split.length == 3 || split.length == 4) && (ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher(split[1]).matches())) { // Leaf - Remove Spigot check for broken BungeeCord configurations
|
||||
Component message = Component.literal("Unknown data in login hostname, did you forget to enable BungeeCord in spigot.yml?");
|
||||
this.connection.send(new ClientboundLoginDisconnectPacket(message));
|
||||
this.connection.disconnect(message);
|
||||
@@ -0,0 +1,29 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Fri, 18 Nov 2022 23:26:16 -0500
|
||||
Subject: [PATCH] Remove UseItemOnPacket Too Far Check
|
||||
|
||||
This Check is added in 1.17.x -> 1.18.x that updated by Mojang.
|
||||
By removing this check, it gives ability for hackers to use some modules of hack clients.
|
||||
|
||||
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index ec6276f3335fd963c8554dbc43adf5bdfe3d2412..162617ea984e54898f19c16ff8e7d759bddcc190 100644
|
||||
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1998,8 +1998,14 @@ public class ServerGamePacketListenerImpl
|
||||
BlockPos blockPos = hitResult.getBlockPos();
|
||||
if (this.player.canInteractWithBlock(blockPos, 1.0)) {
|
||||
Vec3 vec3 = location.subtract(Vec3.atCenterOf(blockPos));
|
||||
- double d = 1.0000001;
|
||||
- if (Math.abs(vec3.x()) < 1.0000001 && Math.abs(vec3.y()) < 1.0000001 && Math.abs(vec3.z()) < 1.0000001) {
|
||||
+ // Leaf start - Remove UseItemOnPacket Too Far Check and make it configurable
|
||||
+ //double d = 1.0000001;
|
||||
+ if (org.dreeam.leaf.config.modules.gameplay.ConfigurableMaxUseItemDistance.maxUseItemDistance <= 0
|
||||
+ || (Math.abs(vec3.x()) < org.dreeam.leaf.config.modules.gameplay.ConfigurableMaxUseItemDistance.maxUseItemDistance
|
||||
+ && Math.abs(vec3.y()) < org.dreeam.leaf.config.modules.gameplay.ConfigurableMaxUseItemDistance.maxUseItemDistance
|
||||
+ && Math.abs(vec3.z()) < org.dreeam.leaf.config.modules.gameplay.ConfigurableMaxUseItemDistance.maxUseItemDistance)
|
||||
+ ) {
|
||||
+ // Leaf end - Remove UseItemOnPacket Too Far Check and make it configurable
|
||||
Direction direction = hitResult.getDirection();
|
||||
this.player.resetLastActionTime();
|
||||
int maxY = this.player.level().getMaxY();
|
||||
@@ -0,0 +1,21 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: nostalgic853 <yuu8583@proton.me>
|
||||
Date: Sun, 23 Oct 2022 23:21:45 +0800
|
||||
Subject: [PATCH] KeYi: Add an option for spigot item merging mechanism
|
||||
|
||||
Original license: MIT
|
||||
Original project: https://github.com/KeYiMC/KeYi
|
||||
|
||||
diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java
|
||||
index 88f55f9ea0a98a07ba8277b4b43f6957e6f16283..0e21c644d62597cf3425c8717ab1e70c766e22f2 100644
|
||||
--- a/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -313,7 +313,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
||||
ItemStack item = this.getItem();
|
||||
ItemStack item1 = itemEntity.getItem();
|
||||
if (Objects.equals(this.target, itemEntity.target) && areMergable(item, item1)) {
|
||||
- if (true || item1.getCount() < item.getCount()) { // Spigot
|
||||
+ if (org.dreeam.leaf.config.modules.gameplay.UseSpigotItemMergingMech.enabled || item1.getCount() < item.getCount()) { // Spigot // Leaf - KeYi - Configurable spigot item merging mechanism
|
||||
merge(this, item, itemEntity, item1);
|
||||
} else {
|
||||
merge(itemEntity, item1, this, item);
|
||||
@@ -9,48 +9,33 @@ Original project: https://github.com/fxmorin/carpet-fixes
|
||||
Optimized the getBiome call to be 25% - 75% faster
|
||||
This is a fully vanilla optimization.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/biome/BiomeManager.java b/src/main/java/net/minecraft/world/level/biome/BiomeManager.java
|
||||
index 90f8360f547ce709fd13ee34f8e67d8bfa94b498..7750c0fe4416943ac82fc9682767e34fce6d8388 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/biome/BiomeManager.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/biome/BiomeManager.java
|
||||
diff --git a/net/minecraft/world/level/biome/BiomeManager.java b/net/minecraft/world/level/biome/BiomeManager.java
|
||||
index 73962e79a0f3d892e3155443a1b84508b0f4042e..a48175a7ebb1788ace46395621ed78d910178a53 100644
|
||||
--- a/net/minecraft/world/level/biome/BiomeManager.java
|
||||
+++ b/net/minecraft/world/level/biome/BiomeManager.java
|
||||
@@ -14,6 +14,7 @@ public class BiomeManager {
|
||||
private static final int ZOOM_MASK = 3;
|
||||
private final BiomeManager.NoiseBiomeSource noiseBiomeSource;
|
||||
private final long biomeZoomSeed;
|
||||
+ private static final double maxOffset = 0.4500000001D; // KeYi
|
||||
+ private static final double maxOffset = 0.4500000001D; // Leaf - Carpet-Fixes - Optimized getBiome method
|
||||
|
||||
public BiomeManager(BiomeManager.NoiseBiomeSource storage, long seed) {
|
||||
this.noiseBiomeSource = storage;
|
||||
@@ -29,39 +30,68 @@ public class BiomeManager {
|
||||
public BiomeManager(BiomeManager.NoiseBiomeSource noiseBiomeSource, long biomeZoomSeed) {
|
||||
this.noiseBiomeSource = noiseBiomeSource;
|
||||
@@ -29,39 +30,67 @@ public class BiomeManager {
|
||||
}
|
||||
|
||||
public Holder<Biome> getBiome(BlockPos pos) {
|
||||
- int i = pos.getX() - 2;
|
||||
- int j = pos.getY() - 2;
|
||||
- int k = pos.getZ() - 2;
|
||||
- int l = i >> 2;
|
||||
- int m = j >> 2;
|
||||
- int n = k >> 2;
|
||||
- double d = (double)(i & 3) / 4.0;
|
||||
- double e = (double)(j & 3) / 4.0;
|
||||
- double f = (double)(k & 3) / 4.0;
|
||||
- int o = 0;
|
||||
- double g = Double.POSITIVE_INFINITY;
|
||||
-
|
||||
- for (int p = 0; p < 8; p++) {
|
||||
- boolean bl = (p & 4) == 0;
|
||||
- boolean bl2 = (p & 2) == 0;
|
||||
- boolean bl3 = (p & 1) == 0;
|
||||
- int q = bl ? l : l + 1;
|
||||
- int r = bl2 ? m : m + 1;
|
||||
- int s = bl3 ? n : n + 1;
|
||||
- double h = bl ? d : d - 1.0;
|
||||
- double t = bl2 ? e : e - 1.0;
|
||||
- double u = bl3 ? f : f - 1.0;
|
||||
- double v = getFiddledDistance(this.biomeZoomSeed, q, r, s, h, t, u);
|
||||
- if (g > v) {
|
||||
- o = p;
|
||||
- g = v;
|
||||
- int i1 = pos.getY() - 2;
|
||||
- int i2 = pos.getZ() - 2;
|
||||
- int i3 = i >> 2;
|
||||
- int i4 = i1 >> 2;
|
||||
- int i5 = i2 >> 2;
|
||||
- double d = (i & 3) / 4.0;
|
||||
- double d1 = (i1 & 3) / 4.0;
|
||||
- double d2 = (i2 & 3) / 4.0;
|
||||
- int i6 = 0;
|
||||
- double d3 = Double.POSITIVE_INFINITY;
|
||||
+ // Leaf start - Carpet-Fixes - Optimized getBiome method
|
||||
+ int xMinus2 = pos.getX() - 2;
|
||||
+ int yMinus2 = pos.getY() - 2;
|
||||
@@ -70,7 +55,21 @@ index 90f8360f547ce709fd13ee34f8e67d8bfa94b498..7750c0fe4416943ac82fc9682767e34f
|
||||
+ double quartXX = everyOtherQuad ? quartX : quartX - 1.0; //[-1.0,-0.75,-0.5,-0.25,0.0,0.25,0.5,0.75]
|
||||
+ double quartYY = everyOtherPair ? quartY : quartY - 1.0;
|
||||
+ double quartZZ = everyOther ? quartZ : quartZ - 1.0;
|
||||
+
|
||||
|
||||
- for (int i7 = 0; i7 < 8; i7++) {
|
||||
- boolean flag = (i7 & 4) == 0;
|
||||
- boolean flag1 = (i7 & 2) == 0;
|
||||
- boolean flag2 = (i7 & 1) == 0;
|
||||
- int i8 = flag ? i3 : i3 + 1;
|
||||
- int i9 = flag1 ? i4 : i4 + 1;
|
||||
- int i10 = flag2 ? i5 : i5 + 1;
|
||||
- double d4 = flag ? d : d - 1.0;
|
||||
- double d5 = flag1 ? d1 : d1 - 1.0;
|
||||
- double d6 = flag2 ? d2 : d2 - 1.0;
|
||||
- double fiddledDistance = getFiddledDistance(this.biomeZoomSeed, i8, i9, i10, d4, d5, d6);
|
||||
- if (d3 > fiddledDistance) {
|
||||
- i6 = i7;
|
||||
- d3 = fiddledDistance;
|
||||
+ //This code block is new
|
||||
+ double maxQuartYY = 0.0, maxQuartZZ = 0.0;
|
||||
+ if (biomeX != 0) {
|
||||
@@ -80,11 +79,6 @@ index 90f8360f547ce709fd13ee34f8e67d8bfa94b498..7750c0fe4416943ac82fc9682767e34f
|
||||
+ if (smallestDist < maxQuartXX + maxQuartYY + maxQuartZZ) continue;
|
||||
}
|
||||
- }
|
||||
|
||||
- int w = (o & 4) == 0 ? l : l + 1;
|
||||
- int x = (o & 2) == 0 ? m : m + 1;
|
||||
- int y = (o & 1) == 0 ? n : n + 1;
|
||||
- return this.noiseBiomeSource.getNoiseBiome(w, x, y);
|
||||
+ int xx = everyOtherQuad ? x : x + 1;
|
||||
+ int yy = everyOtherPair ? y : y + 1;
|
||||
+ int zz = everyOther ? z : z + 1;
|
||||
@@ -106,7 +100,11 @@ index 90f8360f547ce709fd13ee34f8e67d8bfa94b498..7750c0fe4416943ac82fc9682767e34f
|
||||
+ seed = LinearCongruentialGenerator.next(seed, this.biomeZoomSeed);
|
||||
+ double offsetZ = getFiddle(seed);
|
||||
+ double biomeDist = sqrX + sqrY + Mth.square(quartZZ + offsetZ);
|
||||
+
|
||||
|
||||
- int i7x = (i6 & 4) == 0 ? i3 : i3 + 1;
|
||||
- int i11 = (i6 & 2) == 0 ? i4 : i4 + 1;
|
||||
- int i12 = (i6 & 1) == 0 ? i5 : i5 + 1;
|
||||
- return this.noiseBiomeSource.getNoiseBiome(i7x, i11, i12);
|
||||
+ if (smallestDist > biomeDist) {
|
||||
+ smallestX = biomeX;
|
||||
+ smallestDist = biomeDist;
|
||||
@@ -14,30 +14,30 @@ Optimized the RecipeManager getFirstMatch call to be up to 3x faster
|
||||
This is a fully vanilla optimization. Improves: [Blast]Furnace/Campfire/Smoker/Stonecutter/Crafting/Sheep Color Choosing
|
||||
This was mostly made for the auto crafting table, since the performance boost is much more visible while using that mod
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
index f6dd363ececf967d282f5ba713013085da1ddf37..1e05a89a4e4e3a5d2fa9f7dc72fd89a9e0d93468 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
@@ -195,7 +195,7 @@ public class RecipeManager extends SimplePreparableReloadListener<RecipeMap> imp
|
||||
diff --git a/net/minecraft/world/item/crafting/RecipeManager.java b/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
index aefaac550b58be479cc282f52dea91d4b1e530f6..400d11b0a7266cee642546aa190553e60ad0723b 100644
|
||||
--- a/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
@@ -167,7 +167,7 @@ public class RecipeManager extends SimplePreparableReloadListener<RecipeMap> imp
|
||||
|
||||
public <I extends RecipeInput, T extends Recipe<I>> Optional<RecipeHolder<T>> getRecipeFor(RecipeType<T> type, I input, Level world) {
|
||||
public <I extends RecipeInput, T extends Recipe<I>> Optional<RecipeHolder<T>> getRecipeFor(RecipeType<T> recipeType, I input, Level level) {
|
||||
// CraftBukkit start
|
||||
- List<RecipeHolder<T>> list = this.recipes.getRecipesFor(type, input, world).toList();
|
||||
+ List<RecipeHolder<T>> list = this.recipes.getRecipesForList(type, input, world); // Leaf - Carpet-Fixes - Remove streams to be faster
|
||||
- List<RecipeHolder<T>> list = this.recipes.getRecipesFor(recipeType, input, level).toList();
|
||||
+ List<RecipeHolder<T>> list = this.recipes.getRecipesForList(recipeType, input, level); // Leaf - Carpet-Fixes - Remove streams to be faster
|
||||
return (list.isEmpty()) ? Optional.empty() : Optional.of(list.getLast()); // CraftBukkit - SPIGOT-4638: last recipe gets priority
|
||||
// CraftBukkit end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/item/crafting/RecipeMap.java b/src/main/java/net/minecraft/world/item/crafting/RecipeMap.java
|
||||
index c4067fbf827fed882772962a0e4b3ead0d642e62..c62ecec9bbc40f66b84d384bacf39d6d09e10a61 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeMap.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeMap.java
|
||||
@@ -105,4 +105,24 @@ public class RecipeMap {
|
||||
return recipeholder.value().matches(input, world);
|
||||
});
|
||||
diff --git a/net/minecraft/world/item/crafting/RecipeMap.java b/net/minecraft/world/item/crafting/RecipeMap.java
|
||||
index 098753ddd215b6ef5915fac71d8c4f0b19cf4142..c888daa9a8cdc8168cca173acb69b3c3919c5bda 100644
|
||||
--- a/net/minecraft/world/item/crafting/RecipeMap.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeMap.java
|
||||
@@ -75,4 +75,24 @@ public class RecipeMap {
|
||||
public <I extends RecipeInput, T extends Recipe<I>> Stream<RecipeHolder<T>> getRecipesFor(RecipeType<T> type, I input, Level level) {
|
||||
return input.isEmpty() ? Stream.empty() : this.byType(type).stream().filter(recipeHolder -> recipeHolder.value().matches(input, level));
|
||||
}
|
||||
+
|
||||
+ // Leaf start - Carpet-Fixes - Remove streams to be faster
|
||||
+ public <I extends RecipeInput, T extends Recipe<I>> java.util.List<RecipeHolder<T>> getRecipesForList(RecipeType<T> type, I input, Level world) {
|
||||
+ public <I extends RecipeInput, T extends Recipe<I>> java.util.List<RecipeHolder<T>> getRecipesForList(RecipeType<T> type, I input, Level level) {
|
||||
+ java.util.List<RecipeHolder<T>> list;
|
||||
+
|
||||
+ if (input.isEmpty()) {
|
||||
@@ -47,7 +47,7 @@ index c4067fbf827fed882772962a0e4b3ead0d642e62..c62ecec9bbc40f66b84d384bacf39d6d
|
||||
+ }
|
||||
+
|
||||
+ for (RecipeHolder<T> recipeholder : this.byType(type)) {
|
||||
+ if (recipeholder.value().matches(input, world)) {
|
||||
+ if (recipeholder.value().matches(input, level)) {
|
||||
+ list.add(recipeholder);
|
||||
+ }
|
||||
+ }
|
||||
@@ -0,0 +1,37 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?=E3=84=97=E3=84=A0=CB=8B=20=E3=84=91=E3=84=A7=CB=8A?=
|
||||
<tsao-chi@the-lingo.org>
|
||||
Date: Thu, 5 Jan 2023 09:08:17 +0800
|
||||
Subject: [PATCH] Akarin: Save Json list asynchronously
|
||||
|
||||
Original license: GPL v3
|
||||
Original project: https://github.com/Akarin-project/Akarin
|
||||
|
||||
diff --git a/net/minecraft/server/players/StoredUserList.java b/net/minecraft/server/players/StoredUserList.java
|
||||
index 39483f7b453d6faedeccc1ab1eda76669395ea5a..7f2031559fe84e9b57fb4c3fb55cee022b442ebb 100644
|
||||
--- a/net/minecraft/server/players/StoredUserList.java
|
||||
+++ b/net/minecraft/server/players/StoredUserList.java
|
||||
@@ -97,13 +97,23 @@ public abstract class StoredUserList<K, V extends StoredUserEntry<K>> {
|
||||
}
|
||||
|
||||
public void save() throws IOException {
|
||||
+ Runnable saveTask = () -> {// Leaf - Akarin - Save json list async
|
||||
this.removeExpired(); // Paper - remove expired values before saving
|
||||
JsonArray jsonArray = new JsonArray();
|
||||
this.map.values().stream().map(storedEntry -> Util.make(new JsonObject(), storedEntry::serialize)).forEach(jsonArray::add);
|
||||
|
||||
+ try { // Leaf - Akarin - Save json list async
|
||||
try (BufferedWriter writer = Files.newWriter(this.file, StandardCharsets.UTF_8)) {
|
||||
GSON.toJson(jsonArray, GSON.newJsonWriter(writer));
|
||||
}
|
||||
+
|
||||
+ // Leaf start - Akarin - Save json list async
|
||||
+ } catch (Exception e) {
|
||||
+ StoredUserList.LOGGER.warn("Failed to async save {}", this.file, e);
|
||||
+ }
|
||||
+ };
|
||||
+ io.papermc.paper.util.MCUtil.scheduleAsyncTask(saveTask);
|
||||
+ // Leaf end - Akarin - Save json list async
|
||||
}
|
||||
|
||||
public void load() throws IOException {
|
||||
@@ -0,0 +1,49 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Cryptite <cryptite@gmail.com>
|
||||
Date: Sat, 13 Aug 2022 08:58:14 -0500
|
||||
Subject: [PATCH] Slice: Smooth Teleports
|
||||
|
||||
Original license: MIT
|
||||
Original project: https://github.com/Cryptite/Slice
|
||||
|
||||
Co-authored-by: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index b7829a91a7ef79706ec6d90b8b2673fd369b9931..c798869665397de5b435e992873b566f766c2ff9 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -396,6 +396,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
private boolean tpsBar = false; // Purpur - Implement TPSBar
|
||||
private boolean compassBar = false; // Purpur - Add compass command
|
||||
private boolean ramBar = false; // Purpur - Implement rambar commands
|
||||
+ public boolean smoothWorldTeleport; // Slice
|
||||
|
||||
// Paper start - rewrite chunk system
|
||||
private ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader;
|
||||
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
||||
index b4f2b794ca0c6e04da0355e02c19493c892ebccf..9c323dbaff302ca37850af70ee42c2588f85b20d 100644
|
||||
--- a/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/net/minecraft/server/players/PlayerList.java
|
||||
@@ -798,11 +798,11 @@ public abstract class PlayerList {
|
||||
byte b = (byte)(keepInventory ? 1 : 0);
|
||||
ServerLevel serverLevel = serverPlayer.serverLevel();
|
||||
LevelData levelData = serverLevel.getLevelData();
|
||||
- serverPlayer.connection.send(new ClientboundRespawnPacket(serverPlayer.createCommonSpawnInfo(serverLevel), b));
|
||||
+ if (!serverPlayer.smoothWorldTeleport || !isSameLogicalHeight((ServerLevel) fromWorld, level)) serverPlayer.connection.send(new ClientboundRespawnPacket(serverPlayer.createCommonSpawnInfo(serverLevel), b)); // Leaf - Slice
|
||||
// serverPlayer.connection.teleport(serverPlayer.getX(), serverPlayer.getY(), serverPlayer.getZ(), serverPlayer.getYRot(), serverPlayer.getXRot());
|
||||
serverPlayer.connection.send(new ClientboundSetChunkCacheRadiusPacket(serverLevel.spigotConfig.viewDistance)); // Spigot
|
||||
serverPlayer.connection.send(new ClientboundSetSimulationDistancePacket(serverLevel.spigotConfig.simulationDistance)); // Spigot
|
||||
- serverPlayer.connection.teleport(org.bukkit.craftbukkit.util.CraftLocation.toBukkit(serverPlayer.position(), serverLevel.getWorld(), serverPlayer.getYRot(), serverPlayer.getXRot())); // CraftBukkit
|
||||
+ if (!serverPlayer.smoothWorldTeleport || !isSameLogicalHeight((ServerLevel) fromWorld, level)) serverPlayer.connection.teleport(org.bukkit.craftbukkit.util.CraftLocation.toBukkit(serverPlayer.position(), serverLevel.getWorld(), serverPlayer.getYRot(), serverPlayer.getXRot())); // CraftBukkit // Leaf - Slice
|
||||
serverPlayer.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getSharedSpawnPos(), level.getSharedSpawnAngle()));
|
||||
serverPlayer.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked()));
|
||||
serverPlayer.connection
|
||||
@@ -876,6 +876,8 @@ public abstract class PlayerList {
|
||||
return serverPlayer;
|
||||
}
|
||||
|
||||
+ private boolean isSameLogicalHeight(ServerLevel fromLevel, ServerLevel toLevel) { return fromLevel.getLogicalHeight() == toLevel.getLogicalHeight(); } // Leaf - Slice - Check world height before smooth teleport
|
||||
+
|
||||
public void sendActivePlayerEffects(ServerPlayer player) {
|
||||
this.sendActiveEffects(player, player.connection);
|
||||
}
|
||||
@@ -6,10 +6,10 @@ Subject: [PATCH] Parchment: Make FixLight use action bar
|
||||
Original license: GPLv3
|
||||
Original project: https://github.com/ProjectEdenGG/Parchment
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java b/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java
|
||||
diff --git a/io/papermc/paper/command/subcommands/FixLightCommand.java b/io/papermc/paper/command/subcommands/FixLightCommand.java
|
||||
index 85950a1aa732ab8c01ad28bec9e0de140e1a172e..8e8d1a38290c2dc3f88deda64d050e89273a5b89 100644
|
||||
--- a/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java
|
||||
+++ b/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java
|
||||
--- a/io/papermc/paper/command/subcommands/FixLightCommand.java
|
||||
+++ b/io/papermc/paper/command/subcommands/FixLightCommand.java
|
||||
@@ -95,17 +95,20 @@ public final class FixLightCommand implements PaperSubcommand {
|
||||
((StarLightLightingProvider)lightengine).starlight$serverRelightChunks(chunks,
|
||||
(final ChunkPos chunkPos) -> {
|
||||
@@ -0,0 +1,113 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
||||
Date: Tue, 26 Sep 2023 19:00:41 +0800
|
||||
Subject: [PATCH] Leaves: Protocol Core
|
||||
|
||||
TODO: Check whether Leaves's Return-nether-portal-fix.patch improves performance
|
||||
and change store way to sql maybe?
|
||||
|
||||
Original license: GPLv3
|
||||
Original project: https://github.com/LeavesMC/Leaves
|
||||
|
||||
Commit: 41476d86922416c45f703df2871890831fc42bb5
|
||||
|
||||
diff --git a/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java b/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java
|
||||
index fb263fa1f30a7dfcb7ec2656abfb38e5fe88eac9..96ec0a0133ec244a5eb79dfcb34e7f9de22ea0f4 100644
|
||||
--- a/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java
|
||||
+++ b/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java
|
||||
@@ -40,13 +40,23 @@ public interface CustomPacketPayload {
|
||||
|
||||
@Override
|
||||
public void encode(B buffer, CustomPacketPayload value) {
|
||||
+ // Leaves start - protocol core
|
||||
+ if (value instanceof org.leavesmc.leaves.protocol.core.LeavesCustomPayload<?> leavesCustomPayload) {
|
||||
+ buffer.writeResourceLocation(leavesCustomPayload.id());
|
||||
+ leavesCustomPayload.write(buffer);
|
||||
+ return;
|
||||
+ }
|
||||
+ // Leaves end - protocol core
|
||||
this.writeCap(buffer, value.type(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomPacketPayload decode(B buffer) {
|
||||
ResourceLocation resourceLocation = buffer.readResourceLocation();
|
||||
- return (CustomPacketPayload)this.findCodec(resourceLocation).decode(buffer);
|
||||
+ // Leaves start - protocol core
|
||||
+ var leavesCustomPayload = org.leavesmc.leaves.protocol.core.LeavesProtocolManager.decode(resourceLocation, buffer);
|
||||
+ return java.util.Objects.requireNonNullElseGet(leavesCustomPayload, () -> this.findCodec(resourceLocation).decode(buffer));
|
||||
+ // Leaves end - protocol core
|
||||
}
|
||||
};
|
||||
}
|
||||
diff --git a/net/minecraft/resources/ResourceLocation.java b/net/minecraft/resources/ResourceLocation.java
|
||||
index ea8cfa76093c70a44d065c1f80adaa9127fe4e07..7435e2c3f0defe98cbaa488219974887ee572c57 100644
|
||||
--- a/net/minecraft/resources/ResourceLocation.java
|
||||
+++ b/net/minecraft/resources/ResourceLocation.java
|
||||
@@ -36,7 +36,7 @@ public final class ResourceLocation implements Comparable<ResourceLocation> {
|
||||
private final String namespace;
|
||||
private final String path;
|
||||
|
||||
- private ResourceLocation(String namespace, String path) {
|
||||
+ public ResourceLocation(String namespace, String path) { // Leaves - private -> public
|
||||
assert isValidNamespace(namespace);
|
||||
|
||||
assert isValidPath(path);
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 919dc4dddea64f97161b5e0d417dc06875f8318c..4f307671699b0dfbdab61257e28c5a90bcf2e049 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1753,6 +1753,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
GameTestTicker.SINGLETON.tick();
|
||||
}
|
||||
|
||||
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleTick(); // Leaves - protocol
|
||||
+
|
||||
for (int i = 0; i < this.tickables.size(); i++) {
|
||||
this.tickables.get(i).run();
|
||||
}
|
||||
diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
index de115ee71fa240440b54c553e0d3ddaf4c0dfca0..ee8cdd532b73180cb484fcc37c36f09c40faacda 100644
|
||||
--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
@@ -151,6 +151,11 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
|
||||
@Override
|
||||
public void handleCustomPayload(ServerboundCustomPayloadPacket packet) {
|
||||
+ // Leaves start - protocol
|
||||
+ if (packet.payload() instanceof org.leavesmc.leaves.protocol.core.LeavesCustomPayload<?> leavesPayload) {
|
||||
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePayload(player, leavesPayload);
|
||||
+ }
|
||||
+ // Leaves end - protocol
|
||||
// CraftBukkit start
|
||||
// Paper start - Brand support
|
||||
if (packet.payload() instanceof net.minecraft.network.protocol.common.custom.BrandPayload(String brand)) {
|
||||
@@ -169,6 +174,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
String channels = payload.toString(com.google.common.base.Charsets.UTF_8);
|
||||
for (String channel : channels.split("\0")) {
|
||||
this.getCraftPlayer().addChannel(channel);
|
||||
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleMinecraftRegister(channel, player); // Leaves - protocol
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ServerGamePacketListenerImpl.LOGGER.error("Couldn't register custom payload", ex);
|
||||
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
||||
index 9c323dbaff302ca37850af70ee42c2588f85b20d..e8d458ab8094434d4af3441f6ade2bb47e30868f 100644
|
||||
--- a/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/net/minecraft/server/players/PlayerList.java
|
||||
@@ -341,6 +341,8 @@ public abstract class PlayerList {
|
||||
|
||||
player.didPlayerJoinEvent = true; // Gale - EMC - do not process chat/commands before player has joined
|
||||
|
||||
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); // Leaves - protocol
|
||||
+
|
||||
final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage();
|
||||
|
||||
if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure
|
||||
@@ -518,6 +520,7 @@ public abstract class PlayerList {
|
||||
return this.remove(player, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? player.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(player.getDisplayName())));
|
||||
}
|
||||
public net.kyori.adventure.text.Component remove(ServerPlayer player, net.kyori.adventure.text.Component leaveMessage) {
|
||||
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerLeave(player); // Leaves - protocol
|
||||
// Paper end - Fix kick event leave message not being sent
|
||||
org.purpurmc.purpur.task.BossBarTask.removeFromAll(player.getBukkitEntity()); // Purpur - Implement TPSBar
|
||||
ServerLevel serverLevel = player.serverLevel();
|
||||
@@ -0,0 +1,127 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
||||
Date: Sat, 3 Dec 2022 08:57:15 +0800
|
||||
Subject: [PATCH] Leaves: Jade Protocol
|
||||
|
||||
Original license: GPLv3
|
||||
Original project: https://github.com/LeavesMC/Leaves
|
||||
|
||||
This patch is Powered by Jade (https://github.com/Snownee/Jade)
|
||||
|
||||
diff --git a/net/minecraft/world/entity/animal/armadillo/Armadillo.java b/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
||||
index a24ed1747fb8836927ac41b822dc666862701516..d840577023d42dc986e2b811382dfc433083ffb3 100644
|
||||
--- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
||||
+++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
||||
@@ -59,7 +59,7 @@ public class Armadillo extends Animal {
|
||||
public final AnimationState rollOutAnimationState = new AnimationState();
|
||||
public final AnimationState rollUpAnimationState = new AnimationState();
|
||||
public final AnimationState peekAnimationState = new AnimationState();
|
||||
- private int scuteTime;
|
||||
+ public int scuteTime; // Leaves - private -> public
|
||||
private boolean peekReceivedClient = false;
|
||||
|
||||
public Armadillo(EntityType<? extends Animal> entityType, Level level) {
|
||||
diff --git a/net/minecraft/world/entity/animal/frog/Tadpole.java b/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||
index 0ca35514a920dddf230d749bc1a5fe15f1c7940a..669f7d6e5f481fb209e800c8e4acc52cf0c6dfce 100644
|
||||
--- a/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||
+++ b/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||
@@ -286,7 +286,7 @@ public class Tadpole extends AbstractFish {
|
||||
}
|
||||
}
|
||||
|
||||
- private int getTicksLeftUntilAdult() {
|
||||
+ public int getTicksLeftUntilAdult() { // Leaves - private -> public
|
||||
return Math.max(0, ticksToBeFrog - this.age);
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java
|
||||
index 3e3c72a4a52e72c15e0d3288f805d7887dcac351..38cd62d1a3c17913fdadf02e3c3871dac7619f82 100644
|
||||
--- a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java
|
||||
+++ b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java
|
||||
@@ -67,7 +67,7 @@ public class TrialSpawnerData {
|
||||
);
|
||||
public final Set<UUID> detectedPlayers = new HashSet<>();
|
||||
public final Set<UUID> currentMobs = new HashSet<>();
|
||||
- protected long cooldownEndsAt;
|
||||
+ public long cooldownEndsAt; // Leaves - protected -> public
|
||||
protected long nextMobSpawnsAt;
|
||||
protected int totalMobsSpawned;
|
||||
public Optional<SpawnData> nextSpawnData;
|
||||
diff --git a/net/minecraft/world/level/storage/loot/LootPool.java b/net/minecraft/world/level/storage/loot/LootPool.java
|
||||
index 29ad43245a310756c4227acd7532e905f7f8b8ee..ad422817593449b8e914628b51d760e732e2d50c 100644
|
||||
--- a/net/minecraft/world/level/storage/loot/LootPool.java
|
||||
+++ b/net/minecraft/world/level/storage/loot/LootPool.java
|
||||
@@ -36,7 +36,7 @@ public class LootPool {
|
||||
)
|
||||
.apply(instance, LootPool::new)
|
||||
);
|
||||
- private final List<LootPoolEntryContainer> entries;
|
||||
+ public final List<LootPoolEntryContainer> entries; // Leaves - private -> public
|
||||
private final List<LootItemCondition> conditions;
|
||||
private final Predicate<LootContext> compositeCondition;
|
||||
private final List<LootItemFunction> functions;
|
||||
diff --git a/net/minecraft/world/level/storage/loot/LootTable.java b/net/minecraft/world/level/storage/loot/LootTable.java
|
||||
index f95d0f2da3d958519d28278079555c800aad02f8..bebffd07047e41c53b9e4f1ad5917680b8e8c796 100644
|
||||
--- a/net/minecraft/world/level/storage/loot/LootTable.java
|
||||
+++ b/net/minecraft/world/level/storage/loot/LootTable.java
|
||||
@@ -45,7 +45,7 @@ public class LootTable {
|
||||
public static final Codec<Holder<LootTable>> CODEC = RegistryFileCodec.create(Registries.LOOT_TABLE, DIRECT_CODEC);
|
||||
private final ContextKeySet paramSet;
|
||||
private final Optional<ResourceLocation> randomSequence;
|
||||
- private final List<LootPool> pools;
|
||||
+ public final List<LootPool> pools; // Leaves - private -> public
|
||||
private final List<LootItemFunction> functions;
|
||||
private final BiFunction<ItemStack, LootContext, ItemStack> compositeFunction;
|
||||
public org.bukkit.craftbukkit.CraftLootTable craftLootTable; // CraftBukkit
|
||||
diff --git a/net/minecraft/world/level/storage/loot/entries/CompositeEntryBase.java b/net/minecraft/world/level/storage/loot/entries/CompositeEntryBase.java
|
||||
index 8e91ddc6c0e492d165ad8322b4a3d5c3bad5409c..6e420bfb3c223b094157bdfec7dad20d8eab4968 100644
|
||||
--- a/net/minecraft/world/level/storage/loot/entries/CompositeEntryBase.java
|
||||
+++ b/net/minecraft/world/level/storage/loot/entries/CompositeEntryBase.java
|
||||
@@ -9,7 +9,7 @@ import net.minecraft.world.level.storage.loot.ValidationContext;
|
||||
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
|
||||
|
||||
public abstract class CompositeEntryBase extends LootPoolEntryContainer {
|
||||
- protected final List<LootPoolEntryContainer> children;
|
||||
+ public final List<LootPoolEntryContainer> children; // Leaves - private -> public
|
||||
private final ComposableEntryContainer composedChildren;
|
||||
|
||||
protected CompositeEntryBase(List<LootPoolEntryContainer> children, List<LootItemCondition> conditions) {
|
||||
diff --git a/net/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer.java b/net/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer.java
|
||||
index e0e933245e038b7229eeddbda272b081161ab603..c5e3834fa970ac909cefea43420378394153d781 100644
|
||||
--- a/net/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer.java
|
||||
+++ b/net/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer.java
|
||||
@@ -13,7 +13,7 @@ import net.minecraft.world.level.storage.loot.predicates.ConditionUserBuilder;
|
||||
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
|
||||
|
||||
public abstract class LootPoolEntryContainer implements ComposableEntryContainer {
|
||||
- protected final List<LootItemCondition> conditions;
|
||||
+ public final List<LootItemCondition> conditions; // Leaves - private -> public
|
||||
private final Predicate<LootContext> compositeCondition;
|
||||
|
||||
protected LootPoolEntryContainer(List<LootItemCondition> conditions) {
|
||||
diff --git a/net/minecraft/world/level/storage/loot/entries/NestedLootTable.java b/net/minecraft/world/level/storage/loot/entries/NestedLootTable.java
|
||||
index d5e697a0cf6091a7f37c68e3c2a52851535735b1..a8a5a872a8647896e80f91cb5a89adead4005cf7 100644
|
||||
--- a/net/minecraft/world/level/storage/loot/entries/NestedLootTable.java
|
||||
+++ b/net/minecraft/world/level/storage/loot/entries/NestedLootTable.java
|
||||
@@ -25,7 +25,7 @@ public class NestedLootTable extends LootPoolSingletonContainer {
|
||||
.and(singletonFields(instance))
|
||||
.apply(instance, NestedLootTable::new)
|
||||
);
|
||||
- private final Either<ResourceKey<LootTable>, LootTable> contents;
|
||||
+ public final Either<ResourceKey<LootTable>, LootTable> contents; // Leaves - private -> public
|
||||
|
||||
private NestedLootTable(
|
||||
Either<ResourceKey<LootTable>, LootTable> contents, int weight, int quality, List<LootItemCondition> conditions, List<LootItemFunction> functions
|
||||
diff --git a/net/minecraft/world/level/storage/loot/predicates/CompositeLootItemCondition.java b/net/minecraft/world/level/storage/loot/predicates/CompositeLootItemCondition.java
|
||||
index 7134c54984a12949cd6a2e8dc35c2e1c0431e524..52f36fbb9bfcad81004e531efab85e9b87d3284d 100644
|
||||
--- a/net/minecraft/world/level/storage/loot/predicates/CompositeLootItemCondition.java
|
||||
+++ b/net/minecraft/world/level/storage/loot/predicates/CompositeLootItemCondition.java
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.ValidationContext;
|
||||
|
||||
public abstract class CompositeLootItemCondition implements LootItemCondition {
|
||||
- protected final List<LootItemCondition> terms;
|
||||
+ public final List<LootItemCondition> terms; // Leaves - private -> public
|
||||
private final Predicate<LootContext> composedPredicate;
|
||||
|
||||
protected CompositeLootItemCondition(List<LootItemCondition> terms, Predicate<LootContext> composedPredicate) {
|
||||
@@ -0,0 +1,22 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
||||
Date: Fri, 27 Jan 2023 09:42:57 +0800
|
||||
Subject: [PATCH] Leaves: Xaero Map Protocol
|
||||
|
||||
Original license: GPLv3
|
||||
Original project: https://github.com/LeavesMC/Leaves
|
||||
|
||||
This patch is Powered by Xaero Map
|
||||
|
||||
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
||||
index e8d458ab8094434d4af3441f6ade2bb47e30868f..f4ac7a383ea9732a915d100ec9a83e225a1a383d 100644
|
||||
--- a/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/net/minecraft/server/players/PlayerList.java
|
||||
@@ -1216,6 +1216,7 @@ public abstract class PlayerList {
|
||||
player.connection.send(new ClientboundInitializeBorderPacket(worldBorder));
|
||||
player.connection.send(new ClientboundSetTimePacket(level.getGameTime(), level.getDayTime(), level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)));
|
||||
player.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getSharedSpawnPos(), level.getSharedSpawnAngle()));
|
||||
+ org.leavesmc.leaves.protocol.XaeroMapProtocol.onSendWorldInfo(player); // Leaves - xaero map protocol
|
||||
if (level.isRaining()) {
|
||||
// CraftBukkit start - handle player weather
|
||||
// player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.START_RAINING, 0.0F));
|
||||
@@ -0,0 +1,31 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
||||
Date: Thu, 18 May 2023 16:16:56 +0800
|
||||
Subject: [PATCH] Leaves: Syncmatica Protocol
|
||||
|
||||
Original license: GPLv3
|
||||
Original project: https://github.com/LeavesMC/Leaves
|
||||
|
||||
This patch is Powered by Syncmatica (https://github.com/End-Tech/syncmatica)
|
||||
|
||||
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 162617ea984e54898f19c16ff8e7d759bddcc190..7e656b426aafc2581e13e8a1ae9e304530f3d05b 100644
|
||||
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -324,6 +324,7 @@ public class ServerGamePacketListenerImpl
|
||||
player.getTextFilter().join();
|
||||
this.signedMessageDecoder = SignedMessageChain.Decoder.unsigned(player.getUUID(), server::enforceSecureProfile);
|
||||
this.chatMessageChain = new FutureChain(server.chatExecutor); // CraftBukkit - async chat
|
||||
+ this.exchangeTarget = new org.leavesmc.leaves.protocol.syncmatica.exchange.ExchangeTarget(this); // Leaves - Syncmatica Protocol
|
||||
}
|
||||
|
||||
// Purpur start - AFK API
|
||||
@@ -340,6 +341,8 @@ public class ServerGamePacketListenerImpl
|
||||
);
|
||||
// Purpur end - AFK API
|
||||
|
||||
+ public final org.leavesmc.leaves.protocol.syncmatica.exchange.ExchangeTarget exchangeTarget; // Leaves - Syncmatica Protocol
|
||||
+
|
||||
@Override
|
||||
public void tick() {
|
||||
if (this.ackBlockChangesUpTo > -1) {
|
||||
@@ -0,0 +1,423 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
||||
Date: Thu, 3 Aug 2023 20:36:38 +0800
|
||||
Subject: [PATCH] Leaves: Replay Mod API
|
||||
|
||||
Co-authored-by: alazeprt <nono135246@126.com>
|
||||
|
||||
Original license: GPLv3
|
||||
Original project: https://github.com/LeavesMC/Leaves
|
||||
|
||||
This patch is Powered by ReplayMod(https://github.com/ReplayMod)
|
||||
|
||||
diff --git a/net/minecraft/commands/CommandSourceStack.java b/net/minecraft/commands/CommandSourceStack.java
|
||||
index 59c70c567051bc7dba0d308387352d1b15f3c842..6c13bf624bbb1af62f879ea08b72346a9932d75e 100644
|
||||
--- a/net/minecraft/commands/CommandSourceStack.java
|
||||
+++ b/net/minecraft/commands/CommandSourceStack.java
|
||||
@@ -629,6 +629,13 @@ public class CommandSourceStack implements ExecutionCommandSource<CommandSourceS
|
||||
return this.entity instanceof ServerPlayer sourcePlayer && !sourcePlayer.getBukkitEntity().hasPermission("paper.bypass-visibility.tab-completion") ? this.getServer().getPlayerList().getPlayers().stream().filter(serverPlayer -> sourcePlayer.getBukkitEntity().canSee(serverPlayer.getBukkitEntity())).map(serverPlayer -> serverPlayer.getGameProfile().getName()).toList() : Lists.newArrayList(this.server.getPlayerNames()); // Paper - Make CommandSourceStack respect hidden players
|
||||
}
|
||||
|
||||
+ // Leaves start - skip photographer
|
||||
+ @Override
|
||||
+ public Collection<String> getOnlineRealPlayerNames() {
|
||||
+ return this.entity instanceof ServerPlayer sourcePlayer && !sourcePlayer.getBukkitEntity().hasPermission("paper.bypass-visibility.tab-completion") ? this.getServer().getPlayerList().getPlayers().stream().filter(serverPlayer -> !(serverPlayer instanceof org.leavesmc.leaves.replay.ServerPhotographer) && sourcePlayer.getBukkitEntity().canSee(serverPlayer.getBukkitEntity())).map(serverPlayer -> serverPlayer.getGameProfile().getName()).toList() : Lists.newArrayList(this.server.getPlayerNames()); // Paper - Make CommandSourceStack respect hidden players
|
||||
+ }
|
||||
+ // Leaves end - skip photographer
|
||||
+
|
||||
@Override
|
||||
public Collection<String> getAllTeams() {
|
||||
return this.server.getScoreboard().getTeamNames();
|
||||
diff --git a/net/minecraft/commands/SharedSuggestionProvider.java b/net/minecraft/commands/SharedSuggestionProvider.java
|
||||
index a2f13a86c635acef24ded974c96a400e1439011d..78e7948dfc99dda55455e964c3356b6c5002869c 100644
|
||||
--- a/net/minecraft/commands/SharedSuggestionProvider.java
|
||||
+++ b/net/minecraft/commands/SharedSuggestionProvider.java
|
||||
@@ -29,6 +29,8 @@ public interface SharedSuggestionProvider {
|
||||
|
||||
Collection<String> getOnlinePlayerNames();
|
||||
|
||||
+ Collection<String> getOnlineRealPlayerNames(); // Leaves - skip photographer
|
||||
+
|
||||
default Collection<String> getCustomTabSugggestions() {
|
||||
return this.getOnlinePlayerNames();
|
||||
}
|
||||
diff --git a/net/minecraft/commands/arguments/EntityArgument.java b/net/minecraft/commands/arguments/EntityArgument.java
|
||||
index 0a01df6ebd14afe79bc76364cb1df5e0c5c08074..7eea7e3345b889b885e9a118bb23fa08bc237150 100644
|
||||
--- a/net/minecraft/commands/arguments/EntityArgument.java
|
||||
+++ b/net/minecraft/commands/arguments/EntityArgument.java
|
||||
@@ -149,7 +149,7 @@ public class EntityArgument implements ArgumentType<EntitySelector> {
|
||||
return entitySelectorParser.fillSuggestions(
|
||||
builder,
|
||||
offsetBuilder -> {
|
||||
- Collection<String> onlinePlayerNames = sharedSuggestionProvider.getOnlinePlayerNames();
|
||||
+ Collection<String> onlinePlayerNames = sharedSuggestionProvider.getOnlineRealPlayerNames(); // Leaves - skip photographer
|
||||
Iterable<String> iterable = (Iterable<String>)(this.playersOnly
|
||||
? onlinePlayerNames
|
||||
: Iterables.concat(onlinePlayerNames, sharedSuggestionProvider.getSelectedEntities()));
|
||||
diff --git a/net/minecraft/commands/arguments/selector/EntitySelector.java b/net/minecraft/commands/arguments/selector/EntitySelector.java
|
||||
index b305ba9bab617bf4e52d0e6ddf160bacc5751a94..b8215b71971d16705bc11f19343823acf9970a3a 100644
|
||||
--- a/net/minecraft/commands/arguments/selector/EntitySelector.java
|
||||
+++ b/net/minecraft/commands/arguments/selector/EntitySelector.java
|
||||
@@ -128,11 +128,12 @@ public class EntitySelector {
|
||||
return this.findPlayers(source);
|
||||
} else if (this.playerName != null) {
|
||||
ServerPlayer playerByName = source.getServer().getPlayerList().getPlayerByName(this.playerName);
|
||||
+ playerByName = playerByName instanceof org.leavesmc.leaves.replay.ServerPhotographer ? null : playerByName; // Leaves - skip photographer
|
||||
return playerByName == null ? List.of() : List.of(playerByName);
|
||||
} else if (this.entityUUID != null) {
|
||||
for (ServerLevel serverLevel : source.getServer().getAllLevels()) {
|
||||
Entity entity = serverLevel.getEntity(this.entityUUID);
|
||||
- if (entity != null) {
|
||||
+ if (entity != null && !(entity instanceof org.leavesmc.leaves.replay.ServerPhotographer)) { // Leaves - skip photographer
|
||||
if (entity.getType().isEnabled(source.enabledFeatures())) {
|
||||
return List.of(entity);
|
||||
}
|
||||
@@ -146,7 +147,7 @@ public class EntitySelector {
|
||||
AABB absoluteAabb = this.getAbsoluteAabb(vec3);
|
||||
if (this.currentEntity) {
|
||||
Predicate<Entity> predicate = this.getPredicate(vec3, absoluteAabb, null);
|
||||
- return source.getEntity() != null && predicate.test(source.getEntity()) ? List.of(source.getEntity()) : List.of();
|
||||
+ return source.getEntity() != null && !(source.getEntity() instanceof org.leavesmc.leaves.replay.ServerPhotographer) && predicate.test(source.getEntity()) ? List.of(source.getEntity()) : List.of(); // Leaves - skip photographer
|
||||
} else {
|
||||
Predicate<Entity> predicate = this.getPredicate(vec3, absoluteAabb, source.enabledFeatures());
|
||||
List<Entity> list = new ObjectArrayList<>();
|
||||
@@ -157,6 +158,7 @@ public class EntitySelector {
|
||||
this.addEntities(list, serverLevel1, absoluteAabb, predicate);
|
||||
}
|
||||
}
|
||||
+ list.removeIf(entity -> entity instanceof org.leavesmc.leaves.replay.ServerPhotographer); // Leaves - skip photographer
|
||||
|
||||
return this.sortAndLimit(vec3, list);
|
||||
}
|
||||
@@ -192,27 +194,29 @@ public class EntitySelector {
|
||||
this.checkPermissions(source);
|
||||
if (this.playerName != null) {
|
||||
ServerPlayer playerByName = source.getServer().getPlayerList().getPlayerByName(this.playerName);
|
||||
+ playerByName = playerByName instanceof org.leavesmc.leaves.replay.ServerPhotographer ? null : playerByName; // Leaves - skip photographer
|
||||
return playerByName == null || !canSee(source, playerByName) ? List.of() : List.of(playerByName); // Purpur - Hide hidden players from entity selector
|
||||
} else if (this.entityUUID != null) {
|
||||
ServerPlayer playerByName = source.getServer().getPlayerList().getPlayer(this.entityUUID);
|
||||
+ playerByName = playerByName instanceof org.leavesmc.leaves.replay.ServerPhotographer ? null : playerByName; // Leaves - skip photographer
|
||||
return playerByName == null || !canSee(source, playerByName) ? List.of() : List.of(playerByName); // Purpur - Hide hidden players from entity selector
|
||||
} else {
|
||||
Vec3 vec3 = this.position.apply(source.getPosition());
|
||||
AABB absoluteAabb = this.getAbsoluteAabb(vec3);
|
||||
Predicate<Entity> predicate = this.getPredicate(vec3, absoluteAabb, null);
|
||||
if (this.currentEntity) {
|
||||
- return source.getEntity() instanceof ServerPlayer serverPlayer && predicate.test(serverPlayer) && canSee(source, serverPlayer) ? List.of(serverPlayer) : List.of(); // Purpur - Hide hidden players from entity selector
|
||||
+ return source.getEntity() instanceof ServerPlayer serverPlayer && predicate.test(serverPlayer) && !(serverPlayer instanceof org.leavesmc.leaves.replay.ServerPhotographer) && canSee(source, serverPlayer) ? List.of(serverPlayer) : List.of(); // Purpur - Hide hidden players from entity selector // Leaves - skip photographer
|
||||
} else {
|
||||
int resultLimit = this.getResultLimit();
|
||||
List<ServerPlayer> players;
|
||||
if (this.isWorldLimited()) {
|
||||
players = source.getLevel().getPlayers(predicate, resultLimit);
|
||||
- players.removeIf(entityplayer3 -> !canSee(source, entityplayer3)); // Purpur - Hide hidden players from entity selector
|
||||
+ players.removeIf(entityplayer3 -> entityplayer3 instanceof org.leavesmc.leaves.replay.ServerPhotographer || !canSee(source, entityplayer3)); // Purpur - Hide hidden players from entity selector // Leaves - skip photographer
|
||||
} else {
|
||||
players = new ObjectArrayList<>();
|
||||
|
||||
for (ServerPlayer serverPlayer1 : source.getServer().getPlayerList().getPlayers()) {
|
||||
- if (predicate.test(serverPlayer1) && canSee(source, serverPlayer1)) { // Purpur - Hide hidden players from entity selector
|
||||
+ if (!(serverPlayer1 instanceof org.leavesmc.leaves.replay.ServerPhotographer) && predicate.test(serverPlayer1) && canSee(source, serverPlayer1)) { // Purpur - Hide hidden players from entity selector // Leaves - skip photographer
|
||||
players.add(serverPlayer1);
|
||||
if (players.size() >= resultLimit) {
|
||||
return players;
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 4f307671699b0dfbdab61257e28c5a90bcf2e049..449cfd4f6282f28d7470403c0063874b906a6003 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1656,7 +1656,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
|
||||
private ServerStatus.Players buildPlayerStatus() {
|
||||
- List<ServerPlayer> players = this.playerList.getPlayers();
|
||||
+ List<ServerPlayer> players = this.playerList.realPlayers; // Leaves - only real player
|
||||
int maxPlayers = this.getMaxPlayers();
|
||||
if (this.hidesOnlinePlayers()) {
|
||||
return new ServerStatus.Players(maxPlayers, players.size(), List.of());
|
||||
diff --git a/net/minecraft/server/PlayerAdvancements.java b/net/minecraft/server/PlayerAdvancements.java
|
||||
index 792ba93b531e9586e26aafa00830022a8996fc04..e4ea26ae84efde7ce54e08a246a6ea2ae2a17151 100644
|
||||
--- a/net/minecraft/server/PlayerAdvancements.java
|
||||
+++ b/net/minecraft/server/PlayerAdvancements.java
|
||||
@@ -168,6 +168,11 @@ public class PlayerAdvancements {
|
||||
}
|
||||
|
||||
public boolean award(AdvancementHolder advancement, String criterionKey) {
|
||||
+ // Leaves start - photographer can't get advancement
|
||||
+ if (player instanceof org.leavesmc.leaves.replay.ServerPhotographer) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Leaves end - photographer can't get advancement
|
||||
boolean flag = false;
|
||||
AdvancementProgress orStartProgress = this.getOrStartProgress(advancement);
|
||||
boolean isDone = orStartProgress.isDone();
|
||||
diff --git a/net/minecraft/server/commands/OpCommand.java b/net/minecraft/server/commands/OpCommand.java
|
||||
index 5c0a04db38821dbb0cba2bb6f0787f113d167efd..8a071166262fbb7d24735fec394cb19d4dd98096 100644
|
||||
--- a/net/minecraft/server/commands/OpCommand.java
|
||||
+++ b/net/minecraft/server/commands/OpCommand.java
|
||||
@@ -25,7 +25,7 @@ public class OpCommand {
|
||||
(context, builder) -> {
|
||||
PlayerList playerList = context.getSource().getServer().getPlayerList();
|
||||
return SharedSuggestionProvider.suggest(
|
||||
- playerList.getPlayers()
|
||||
+ playerList.realPlayers // Leaves - skip
|
||||
.stream()
|
||||
.filter(player -> !playerList.isOp(player.getGameProfile()))
|
||||
.map(player -> player.getGameProfile().getName()),
|
||||
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
||||
index a13aa7b896a998975d2ee14eafb86a85db988e69..bf364e3fad2823400ec671bc632ba50751a3f473 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -216,6 +216,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
public boolean hasEntityMoveEvent; // Paper - Add EntityMoveEvent
|
||||
private final alternate.current.wire.WireHandler wireHandler = new alternate.current.wire.WireHandler(this); // Paper - optimize redstone (Alternate Current)
|
||||
public boolean hasRidableMoveEvent = false; // Purpur - Ridables
|
||||
+ final List<ServerPlayer> realPlayers; // Leaves - skip
|
||||
|
||||
public LevelChunk getChunkIfLoaded(int x, int z) {
|
||||
return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper - Use getChunkIfLoadedImmediately
|
||||
@@ -700,6 +701,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
// Paper end - rewrite chunk system
|
||||
this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
|
||||
this.preciseTime = this.serverLevelData.getDayTime(); // Purpur - Configurable daylight cycle
|
||||
+ this.realPlayers = Lists.newArrayList(); // Leaves - skip
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@@ -2669,6 +2671,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
// ServerLevel.this.getChunkSource().addEntity(entity); // Paper - ignore and warn about illegal addEntity calls instead of crashing server; moved down below valid=true
|
||||
if (entity instanceof ServerPlayer serverPlayer) {
|
||||
ServerLevel.this.players.add(serverPlayer);
|
||||
+ // Leaves start - skip
|
||||
+ if (!(serverPlayer instanceof org.leavesmc.leaves.replay.ServerPhotographer)) {
|
||||
+ ServerLevel.this.realPlayers.add(serverPlayer);
|
||||
+ }
|
||||
+ // Leaves end - skip
|
||||
ServerLevel.this.updateSleepingPlayerList();
|
||||
}
|
||||
|
||||
@@ -2739,6 +2746,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
ServerLevel.this.getChunkSource().removeEntity(entity);
|
||||
if (entity instanceof ServerPlayer serverPlayer) {
|
||||
ServerLevel.this.players.remove(serverPlayer);
|
||||
+ // Leaves start - skip
|
||||
+ if (!(serverPlayer instanceof org.leavesmc.leaves.replay.ServerPhotographer)) {
|
||||
+ ServerLevel.this.realPlayers.remove(serverPlayer);
|
||||
+ }
|
||||
+ // Leaves end - skip
|
||||
ServerLevel.this.updateSleepingPlayerList();
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index c798869665397de5b435e992873b566f766c2ff9..08578d7398658d226318a28324a1eae0d4453add 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -195,7 +195,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
);
|
||||
public ServerGamePacketListenerImpl connection;
|
||||
public final MinecraftServer server;
|
||||
- public final ServerPlayerGameMode gameMode;
|
||||
+ public ServerPlayerGameMode gameMode; // Leaves - final -> null
|
||||
private final PlayerAdvancements advancements;
|
||||
private final ServerStatsCounter stats;
|
||||
private float lastRecordedHealthAndAbsorption = Float.MIN_VALUE;
|
||||
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
||||
index f4ac7a383ea9732a915d100ec9a83e225a1a383d..3b679578858b869425dc60ae73fa12ac19d253ef 100644
|
||||
--- a/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/net/minecraft/server/players/PlayerList.java
|
||||
@@ -132,6 +132,7 @@ public abstract class PlayerList {
|
||||
private boolean allowCommandsForAllPlayers;
|
||||
private static final boolean ALLOW_LOGOUTIVATOR = false;
|
||||
private int sendAllPlayerInfoIn;
|
||||
+ public final List<ServerPlayer> realPlayers = new java.util.concurrent.CopyOnWriteArrayList(); // Leaves - replay api
|
||||
|
||||
// CraftBukkit start
|
||||
private org.bukkit.craftbukkit.CraftServer cserver;
|
||||
@@ -150,6 +151,105 @@ public abstract class PlayerList {
|
||||
|
||||
abstract public void loadAndSaveFiles(); // Paper - fix converting txt to json file; moved from DedicatedPlayerList constructor
|
||||
|
||||
+ // Leaves start - replay api
|
||||
+ public void placeNewPhotographer(Connection connection, org.leavesmc.leaves.replay.ServerPhotographer player, ServerLevel worldserver, org.bukkit.Location location) {
|
||||
+ player.isRealPlayer = true; // Paper
|
||||
+ player.loginTime = System.currentTimeMillis(); // Paper
|
||||
+
|
||||
+ ServerLevel worldserver1 = worldserver;
|
||||
+
|
||||
+ player.setServerLevel(worldserver1);
|
||||
+ player.spawnIn(worldserver1);
|
||||
+ player.gameMode.setLevel((ServerLevel) player.level());
|
||||
+
|
||||
+ LevelData worlddata = worldserver1.getLevelData();
|
||||
+
|
||||
+ player.loadGameTypes(null);
|
||||
+ ServerGamePacketListenerImpl playerconnection = new ServerGamePacketListenerImpl(this.server, connection, player, CommonListenerCookie.createInitial(player.gameProfile, false));
|
||||
+ GameRules gamerules = worldserver1.getGameRules();
|
||||
+ boolean flag = gamerules.getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN);
|
||||
+ boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO);
|
||||
+ boolean flag2 = gamerules.getBoolean(GameRules.RULE_LIMITED_CRAFTING);
|
||||
+
|
||||
+ playerconnection.send(new ClientboundLoginPacket(player.getId(), worlddata.isHardcore(), this.server.levelKeys(), this.getMaxPlayers(), worldserver1.getWorld().getSendViewDistance(), worldserver1.getWorld().getSimulationDistance(), flag1, !flag, flag2, player.createCommonSpawnInfo(worldserver1), this.server.enforceSecureProfile())); // Paper - replace old player chunk management
|
||||
+ player.getBukkitEntity().sendSupportedChannels(); // CraftBukkit
|
||||
+ playerconnection.send(new ClientboundChangeDifficultyPacket(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
|
||||
+ playerconnection.send(new ClientboundPlayerAbilitiesPacket(player.getAbilities()));
|
||||
+ playerconnection.send(new ClientboundSetHeldSlotPacket(player.getInventory().selected));
|
||||
+ RecipeManager craftingmanager = this.server.getRecipeManager();
|
||||
+ playerconnection.send(new ClientboundUpdateRecipesPacket(craftingmanager.getSynchronizedItemProperties(), craftingmanager.getSynchronizedStonecutterRecipes()));
|
||||
+ this.sendPlayerPermissionLevel(player);
|
||||
+ player.getStats().markAllDirty();
|
||||
+ player.getRecipeBook().sendInitialRecipeBook(player);
|
||||
+ this.updateEntireScoreboard(worldserver1.getScoreboard(), player);
|
||||
+ this.server.invalidateStatus();
|
||||
+
|
||||
+ playerconnection.teleport(player.getX(), player.getY(), player.getZ(), player.getYRot(), player.getXRot());
|
||||
+ ServerStatus serverping = this.server.getStatus();
|
||||
+
|
||||
+ if (serverping != null) {
|
||||
+ player.sendServerStatus(serverping);
|
||||
+ }
|
||||
+
|
||||
+ this.players.add(player);
|
||||
+ this.playersByName.put(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT), player); // Spigot
|
||||
+ this.playersByUUID.put(player.getUUID(), player);
|
||||
+
|
||||
+ player.supressTrackerForLogin = true;
|
||||
+ worldserver1.addNewPlayer(player);
|
||||
+ this.server.getCustomBossEvents().onPlayerConnect(player);
|
||||
+ org.bukkit.craftbukkit.entity.CraftPlayer bukkitPlayer = player.getBukkitEntity();
|
||||
+
|
||||
+ player.containerMenu.transferTo(player.containerMenu, bukkitPlayer);
|
||||
+ if (!player.connection.isAcceptingMessages()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); // Leaves - protocol
|
||||
+
|
||||
+ final List<ServerPlayer> onlinePlayers = Lists.newArrayListWithExpectedSize(this.players.size() - 1);
|
||||
+ for (int i = 0; i < this.players.size(); ++i) {
|
||||
+ ServerPlayer entityplayer1 = this.players.get(i);
|
||||
+
|
||||
+ if (entityplayer1 == player || !bukkitPlayer.canSee(entityplayer1.getBukkitEntity())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ onlinePlayers.add(entityplayer1);
|
||||
+ }
|
||||
+ if (!onlinePlayers.isEmpty()) {
|
||||
+ player.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(onlinePlayers, player));
|
||||
+ }
|
||||
+
|
||||
+ player.sentListPacket = true;
|
||||
+ player.supressTrackerForLogin = false;
|
||||
+ ((ServerLevel) player.level()).getChunkSource().chunkMap.addEntity(player);
|
||||
+
|
||||
+ this.sendLevelInfo(player, worldserver1);
|
||||
+
|
||||
+ if (player.level() == worldserver1 && !worldserver1.players().contains(player)) {
|
||||
+ worldserver1.addNewPlayer(player);
|
||||
+ this.server.getCustomBossEvents().onPlayerConnect(player);
|
||||
+ }
|
||||
+
|
||||
+ worldserver1 = player.serverLevel();
|
||||
+ java.util.Iterator<MobEffectInstance> iterator = player.getActiveEffects().iterator();
|
||||
+ while (iterator.hasNext()) {
|
||||
+ MobEffectInstance mobeffect = iterator.next();
|
||||
+ playerconnection.send(new ClientboundUpdateMobEffectPacket(player.getId(), mobeffect, false));
|
||||
+ }
|
||||
+
|
||||
+ if (player.isDeadOrDying()) {
|
||||
+ net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome> plains = worldserver1.registryAccess().lookupOrThrow(net.minecraft.core.registries.Registries.BIOME)
|
||||
+ .getOrThrow(net.minecraft.world.level.biome.Biomes.PLAINS);
|
||||
+ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket(
|
||||
+ new net.minecraft.world.level.chunk.EmptyLevelChunk(worldserver1, player.chunkPosition(), plains),
|
||||
+ worldserver1.getLightEngine(), null, null, false)
|
||||
+ );
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaves end - replay api
|
||||
+
|
||||
public void placeNewPlayer(Connection connection, ServerPlayer player, CommonListenerCookie cookie) {
|
||||
player.isRealPlayer = true; // Paper
|
||||
player.loginTime = System.currentTimeMillis(); // Paper - Replace OfflinePlayer#getLastPlayed
|
||||
@@ -315,6 +415,7 @@ public abstract class PlayerList {
|
||||
|
||||
// player.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(this.players)); // CraftBukkit - replaced with loop below
|
||||
this.players.add(player);
|
||||
+ this.realPlayers.add(player); // Leaves - replay api
|
||||
this.playersByName.put(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT), player); // Spigot
|
||||
this.playersByUUID.put(player.getUUID(), player);
|
||||
this.addToSendAllPlayerInfoBuckets(player); // Gale - Purpur - spread out sending all player info
|
||||
@@ -374,6 +475,12 @@ public abstract class PlayerList {
|
||||
continue;
|
||||
}
|
||||
|
||||
+ // Leaves start - skip photographer
|
||||
+ if (entityplayer1 instanceof org.leavesmc.leaves.replay.ServerPhotographer) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ // Leaves end - skip photographer
|
||||
+
|
||||
onlinePlayers.add(entityplayer1); // Paper - Use single player info update packet on join
|
||||
}
|
||||
// Paper start - Use single player info update packet on join
|
||||
@@ -515,6 +622,43 @@ public abstract class PlayerList {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Leaves start - replay mod api
|
||||
+ public void removePhotographer(org.leavesmc.leaves.replay.ServerPhotographer entityplayer) {
|
||||
+ ServerLevel worldserver = entityplayer.serverLevel();
|
||||
+
|
||||
+ entityplayer.awardStat(Stats.LEAVE_GAME);
|
||||
+
|
||||
+ if (entityplayer.containerMenu != entityplayer.inventoryMenu) {
|
||||
+ entityplayer.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT);
|
||||
+ }
|
||||
+
|
||||
+ if (server.isSameThread()) entityplayer.doTick();
|
||||
+
|
||||
+ if (this.collideRuleTeamName != null) {
|
||||
+ final net.minecraft.world.scores.Scoreboard scoreBoard = this.server.getLevel(Level.OVERWORLD).getScoreboard();
|
||||
+ final PlayerTeam team = scoreBoard.getPlayersTeam(this.collideRuleTeamName);
|
||||
+ if (entityplayer.getTeam() == team && team != null) {
|
||||
+ scoreBoard.removePlayerFromTeam(entityplayer.getScoreboardName(), team);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ worldserver.removePlayerImmediately(entityplayer, Entity.RemovalReason.UNLOADED_WITH_PLAYER);
|
||||
+ entityplayer.retireScheduler();
|
||||
+ entityplayer.getAdvancements().stopListening();
|
||||
+ this.players.remove(entityplayer);
|
||||
+ this.playersByName.remove(entityplayer.getScoreboardName().toLowerCase(java.util.Locale.ROOT));
|
||||
+ this.server.getCustomBossEvents().onPlayerDisconnect(entityplayer);
|
||||
+ UUID uuid = entityplayer.getUUID();
|
||||
+ ServerPlayer entityplayer1 = this.playersByUUID.get(uuid);
|
||||
+
|
||||
+ if (entityplayer1 == entityplayer) {
|
||||
+ this.playersByUUID.remove(uuid);
|
||||
+ }
|
||||
+
|
||||
+ this.cserver.getScoreboardManager().removePlayer(entityplayer.getBukkitEntity());
|
||||
+ }
|
||||
+ // Leaves stop - replay mod api
|
||||
+
|
||||
public net.kyori.adventure.text.Component remove(ServerPlayer player) { // CraftBukkit - return string // Paper - return Component
|
||||
// Paper start - Fix kick event leave message not being sent
|
||||
return this.remove(player, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? player.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(player.getDisplayName())));
|
||||
@@ -591,6 +735,7 @@ public abstract class PlayerList {
|
||||
player.retireScheduler(); // Paper - Folia schedulers
|
||||
player.getAdvancements().stopListening();
|
||||
this.players.remove(player);
|
||||
+ this.realPlayers.remove(player); // Leaves - replay api
|
||||
this.playersByName.remove(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot
|
||||
this.removeFromSendAllPlayerInfoBuckets(player); // Gale - Purpur - spread out sending all player info
|
||||
this.server.getCustomBossEvents().onPlayerDisconnect(player);
|
||||
@@ -688,7 +833,7 @@ public abstract class PlayerList {
|
||||
// return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameProfile)
|
||||
// ? Component.translatable("multiplayer.disconnect.server_full")
|
||||
// : null;
|
||||
- if (this.players.size() >= this.maxPlayers && !(player.hasPermission("purpur.joinfullserver") || this.canBypassPlayerLimit(gameProfile))) { // Purpur - Allow player join full server by permission
|
||||
+ if (this.realPlayers.size() >= this.maxPlayers && !(player.hasPermission("purpur.joinfullserver") || this.canBypassPlayerLimit(gameProfile))) { // Purpur - Allow player join full server by permission // Leaves - only real player
|
||||
event.disallow(org.bukkit.event.player.PlayerLoginEvent.Result.KICK_FULL, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.serverFullMessage)); // Spigot // Paper - Adventure
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
||||
Date: Thu, 28 Sep 2023 20:30:46 +0800
|
||||
Subject: [PATCH] Leaves: Disable moved wrongly threshold
|
||||
|
||||
Original license: GPLv3
|
||||
Original project: https://github.com/LeavesMC/Leaves
|
||||
|
||||
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 7e656b426aafc2581e13e8a1ae9e304530f3d05b..465e34eb906ec78f49ff1183b635e77a1fcaa758 100644
|
||||
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -575,7 +575,7 @@ public class ServerGamePacketListenerImpl
|
||||
return;
|
||||
}
|
||||
// Paper end - Prevent moving into unloaded chunks
|
||||
- if (d7 - d6 > Math.max(100.0, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) {
|
||||
+ if (!org.dreeam.leaf.config.modules.gameplay.DisableMovedWronglyThreshold.enabled && d7 - d6 > Math.max(100.0, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { // Leaves - disable can
|
||||
// CraftBukkit end
|
||||
LOGGER.warn(
|
||||
"{} (vehicle of {}) moved too quickly! {},{},{}", rootVehicle.getName().getString(), this.player.getName().getString(), d3, d4, d5
|
||||
@@ -605,7 +605,7 @@ public class ServerGamePacketListenerImpl
|
||||
d5 = d2 - rootVehicle.getZ();
|
||||
d7 = d3 * d3 + d4 * d4 + d5 * d5;
|
||||
boolean flag2 = false;
|
||||
- if (d7 > org.spigotmc.SpigotConfig.movedWronglyThreshold) { // Spigot
|
||||
+ if (!org.dreeam.leaf.config.modules.gameplay.DisableMovedWronglyThreshold.enabled && d7 > org.spigotmc.SpigotConfig.movedWronglyThreshold) { // Spigot // Leaves - disable can
|
||||
flag2 = true; // Paper - diff on change, this should be moved wrongly
|
||||
LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", rootVehicle.getName().getString(), this.player.getName().getString(), Math.sqrt(d7));
|
||||
}
|
||||
@@ -1450,7 +1450,7 @@ public class ServerGamePacketListenerImpl
|
||||
io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_TOO_QUICKLY,
|
||||
toX, toY, toZ, toYaw, toPitch, true);
|
||||
if (!event.isAllowed()) {
|
||||
- if (event.getLogWarning()) {
|
||||
+ if (event.getLogWarning()) { // Leaves - disable can
|
||||
LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getName().getString(), d3, d4, d5);
|
||||
}
|
||||
this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
|
||||
@@ -1516,7 +1516,8 @@ public class ServerGamePacketListenerImpl
|
||||
d5 = d2 - this.player.getZ();
|
||||
d7 = d3 * d3 + d4 * d4 + d5 * d5;
|
||||
boolean movedWrongly = false; // Paper - Add fail move event; rename
|
||||
- if (!this.player.isChangingDimension()
|
||||
+ if (!org.dreeam.leaf.config.modules.gameplay.DisableMovedWronglyThreshold.enabled // Leaves - disable can
|
||||
+ && !this.player.isChangingDimension()
|
||||
&& d7 > org.spigotmc.SpigotConfig.movedWronglyThreshold // Spigot
|
||||
&& !this.player.isSleeping()
|
||||
&& !this.player.gameMode.isCreative()
|
||||
@@ -0,0 +1,851 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: peaches94 <peachescu94@gmail.com>
|
||||
Date: Sun, 26 Jun 2022 16:51:37 -0500
|
||||
Subject: [PATCH] Petal: Async Pathfinding
|
||||
|
||||
Fixed & Updated by KaiijuMC
|
||||
Original license: GPLv3
|
||||
Original project: https://github.com/KaiijuMC/Kaiiju
|
||||
|
||||
Original license: GPLv3
|
||||
Original project: https://github.com/Bloom-host/Petal
|
||||
|
||||
This patch was ported downstream from the Petal fork.
|
||||
|
||||
Makes most pathfinding-related work happen asynchronously
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java
|
||||
index 14d9dceacc82cc6c085dab8f52e59a318dd8cae5..8b3dfb1385a2252a4aaead5558c0ffbd5c204971 100644
|
||||
--- a/net/minecraft/world/entity/Mob.java
|
||||
+++ b/net/minecraft/world/entity/Mob.java
|
||||
@@ -255,6 +255,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
@Nullable
|
||||
@Override
|
||||
public LivingEntity getTarget() {
|
||||
+ //if (Thread.currentThread().getName().contains("petal-async-pathfinding-thread")) return this.target; // Kaiiju - Don't reset target when async pathfinding! // Leaf - Don't need this
|
||||
return this.target;
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/behavior/AcquirePoi.java b/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
||||
index 7f0975f8bd6d5f8ca28f503f93c8cb5c42557420..eb71f045d3e8698a8a9e9f51176c2884f71a034c 100644
|
||||
--- a/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
||||
@@ -102,21 +102,20 @@ public class AcquirePoi {
|
||||
}
|
||||
}
|
||||
// Paper end - optimise POI access
|
||||
- Path path = findPathToPois(mob, set);
|
||||
- if (path != null && path.canReach()) {
|
||||
- BlockPos target = path.getTarget();
|
||||
- poiManager.getType(target).ifPresent(holder -> {
|
||||
- poiManager.take(acquirablePois, (holder1, blockPos) -> blockPos.equals(target), target, 1);
|
||||
- memoryAccessor.set(GlobalPos.of(level.dimension(), target));
|
||||
- entityEventId.ifPresent(id -> level.broadcastEntityEvent(mob, id));
|
||||
- map.clear();
|
||||
- DebugPackets.sendPoiTicketCountPacket(level, target);
|
||||
+ // Kaiiju start - petal - Async path processing
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) {
|
||||
+ // await on path async
|
||||
+ Path possiblePath = findPathToPois(mob, set);
|
||||
+
|
||||
+ // wait on the path to be processed
|
||||
+ org.dreeam.leaf.async.path.AsyncPathProcessor.awaitProcessing(possiblePath, path -> {
|
||||
+ processPath(acquirablePois, entityEventId, (Long2ObjectMap<JitteredLinearRetry>) map, memoryAccessor, level, mob, time, poiManager, set, path);
|
||||
});
|
||||
} else {
|
||||
- for (Pair<Holder<PoiType>, BlockPos> pair : set) {
|
||||
- map.computeIfAbsent(pair.getSecond().asLong(), l -> new AcquirePoi.JitteredLinearRetry(level.random, time));
|
||||
- }
|
||||
- }
|
||||
+ // Kaiiju end
|
||||
+ Path path = findPathToPois(mob, set);
|
||||
+ processPath(acquirablePois, entityEventId, (Long2ObjectMap<JitteredLinearRetry>) map, memoryAccessor, level, mob, time, poiManager, set, path);
|
||||
+ } // Kaiiju - Async path processing
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -128,6 +127,34 @@ public class AcquirePoi {
|
||||
: BehaviorBuilder.create(instance -> instance.group(instance.absent(existingAbsentMemory)).apply(instance, memoryAccessor -> oneShot));
|
||||
}
|
||||
|
||||
+ // Leaf start - Kaiiju - Async path processing
|
||||
+ private static void processPath(Predicate<Holder<PoiType>> acquirablePois,
|
||||
+ Optional<Byte> entityEventId,
|
||||
+ Long2ObjectMap<JitteredLinearRetry> map,
|
||||
+ net.minecraft.world.entity.ai.behavior.declarative.MemoryAccessor<com.mojang.datafixers.kinds.Const.Mu<com.mojang.datafixers.util.Unit>, GlobalPos> memoryAccessor,
|
||||
+ ServerLevel level,
|
||||
+ PathfinderMob mob,
|
||||
+ long time,
|
||||
+ PoiManager poiManager,
|
||||
+ Set<Pair<Holder<PoiType>, BlockPos>> set,
|
||||
+ Path path) {
|
||||
+ if (path != null && path.canReach()) {
|
||||
+ BlockPos target = path.getTarget();
|
||||
+ poiManager.getType(target).ifPresent(holder -> {
|
||||
+ poiManager.take(acquirablePois, (holder1, blockPos) -> blockPos.equals(target), target, 1);
|
||||
+ memoryAccessor.set(GlobalPos.of(level.dimension(), target));
|
||||
+ entityEventId.ifPresent(id -> level.broadcastEntityEvent(mob, id));
|
||||
+ map.clear();
|
||||
+ DebugPackets.sendPoiTicketCountPacket(level, target);
|
||||
+ });
|
||||
+ } else {
|
||||
+ for (Pair<Holder<PoiType>, BlockPos> pair : set) {
|
||||
+ map.computeIfAbsent(pair.getSecond().asLong(), l -> new JitteredLinearRetry(level.random, time));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaf end - Kaiiju - Async path processing
|
||||
+
|
||||
@Nullable
|
||||
public static Path findPathToPois(Mob mob, Set<Pair<Holder<PoiType>, BlockPos>> poiPositions) {
|
||||
if (poiPositions.isEmpty()) {
|
||||
diff --git a/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java b/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
||||
index 621ba76784f2b92790eca62be4d0688834335ab6..e2e1532d2ffb709e347db42b1b5b6cae5e7e9700 100644
|
||||
--- a/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
||||
@@ -21,6 +21,7 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
||||
private int remainingCooldown;
|
||||
@Nullable
|
||||
private Path path;
|
||||
+ private boolean finishedProcessing; // Kaiiju - petal - track when path is processed
|
||||
@Nullable
|
||||
private BlockPos lastTargetPos;
|
||||
private float speedModifier;
|
||||
@@ -53,9 +54,10 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
||||
Brain<?> brain = owner.getBrain();
|
||||
WalkTarget walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET).get();
|
||||
boolean flag = this.reachedTarget(owner, walkTarget);
|
||||
- if (!flag && this.tryComputePath(owner, walkTarget, level.getGameTime())) {
|
||||
+ if (!org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled && !flag && this.tryComputePath(owner, walkTarget, level.getGameTime())) { // Kaiiju - petal - async path processing means we can't know if the path is reachable here
|
||||
this.lastTargetPos = walkTarget.getTarget().currentBlockPosition();
|
||||
return true;
|
||||
+ } else if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled && !flag) { return true; // Kaiiju - async pathfinding
|
||||
} else {
|
||||
brain.eraseMemory(MemoryModuleType.WALK_TARGET);
|
||||
if (flag) {
|
||||
@@ -69,6 +71,7 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
||||
|
||||
@Override
|
||||
protected boolean canStillUse(ServerLevel level, Mob entity, long gameTime) {
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled && !this.finishedProcessing) return true; // Kaiiju - petal - wait for processing
|
||||
if (this.path != null && this.lastTargetPos != null) {
|
||||
Optional<WalkTarget> memory = entity.getBrain().getMemory(MemoryModuleType.WALK_TARGET);
|
||||
boolean flag = memory.map(MoveToTargetSink::isWalkTargetSpectator).orElse(false);
|
||||
@@ -95,12 +98,68 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
||||
|
||||
@Override
|
||||
protected void start(ServerLevel level, Mob entity, long gameTime) {
|
||||
+ // Kaiiju start - petal - start processing
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) {
|
||||
+ Brain<?> brain = entity.getBrain();
|
||||
+ WalkTarget walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET).get();
|
||||
+
|
||||
+ this.finishedProcessing = false;
|
||||
+ this.lastTargetPos = walkTarget.getTarget().currentBlockPosition();
|
||||
+ this.path = this.computePath(entity, walkTarget);
|
||||
+ return;
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
entity.getBrain().setMemory(MemoryModuleType.PATH, this.path);
|
||||
entity.getNavigation().moveTo(this.path, (double)this.speedModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tick(ServerLevel level, Mob owner, long gameTime) {
|
||||
+ // Kaiiju start - petal - Async path processing
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) {
|
||||
+ if (this.path != null && !this.path.isProcessed()) return; // wait for processing
|
||||
+
|
||||
+ if (!this.finishedProcessing) {
|
||||
+ this.finishedProcessing = true;
|
||||
+
|
||||
+ Brain<?> brain = owner.getBrain();
|
||||
+ boolean canReach = this.path != null && this.path.canReach();
|
||||
+ if (canReach) {
|
||||
+ brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE);
|
||||
+ } else if (!brain.hasMemoryValue(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE)) {
|
||||
+ brain.setMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, gameTime);
|
||||
+ }
|
||||
+
|
||||
+ if (!canReach) {
|
||||
+ Optional<WalkTarget> walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET);
|
||||
+
|
||||
+ if (!walkTarget.isPresent()) return;
|
||||
+
|
||||
+ BlockPos blockPos = walkTarget.get().getTarget().currentBlockPosition();
|
||||
+ Vec3 vec3 = DefaultRandomPos.getPosTowards((PathfinderMob) owner, 10, 7, Vec3.atBottomCenterOf(blockPos), (float) Math.PI / 2F);
|
||||
+ if (vec3 != null) {
|
||||
+ // try recalculating the path using a random position
|
||||
+ this.path = owner.getNavigation().createPath(vec3.x, vec3.y, vec3.z, 0);
|
||||
+ this.finishedProcessing = false;
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ owner.getBrain().setMemory(MemoryModuleType.PATH, this.path);
|
||||
+ owner.getNavigation().moveTo(this.path, this.speedModifier);
|
||||
+ }
|
||||
+
|
||||
+ Path path = owner.getNavigation().getPath();
|
||||
+ Brain<?> brain = owner.getBrain();
|
||||
+
|
||||
+ if (path != null && this.lastTargetPos != null && brain.hasMemoryValue(MemoryModuleType.WALK_TARGET)) {
|
||||
+ WalkTarget walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET).get(); // we know isPresent = true
|
||||
+ if (walkTarget.getTarget().currentBlockPosition().distSqr(this.lastTargetPos) > 4.0D) {
|
||||
+ this.start(level, owner, gameTime);
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ // Kaiiju end
|
||||
Path path = owner.getNavigation().getPath();
|
||||
Brain<?> brain = owner.getBrain();
|
||||
if (this.path != path) {
|
||||
@@ -115,7 +174,23 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
||||
this.start(level, owner, gameTime);
|
||||
}
|
||||
}
|
||||
+ } // Kaiiju - async path processing
|
||||
+ }
|
||||
+
|
||||
+ // Kaiiju start - petal - Async path processing
|
||||
+ @Nullable
|
||||
+ private Path computePath(Mob entity, WalkTarget walkTarget) {
|
||||
+ BlockPos blockPos = walkTarget.getTarget().currentBlockPosition();
|
||||
+ // don't pathfind outside region
|
||||
+ //if (!io.papermc.paper.util.TickThread.isTickThreadFor((ServerLevel) entity.level(), blockPos)) return null; // Leaf - Don't need this
|
||||
+ this.speedModifier = walkTarget.getSpeedModifier();
|
||||
+ Brain<?> brain = entity.getBrain();
|
||||
+ if (this.reachedTarget(entity, walkTarget)) {
|
||||
+ brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE);
|
||||
+ }
|
||||
+ return entity.getNavigation().createPath(blockPos, 0);
|
||||
}
|
||||
+ // Kaiiju end
|
||||
|
||||
private boolean tryComputePath(Mob mob, WalkTarget target, long time) {
|
||||
BlockPos blockPos = target.getTarget().currentBlockPosition();
|
||||
diff --git a/net/minecraft/world/entity/ai/behavior/SetClosestHomeAsWalkTarget.java b/net/minecraft/world/entity/ai/behavior/SetClosestHomeAsWalkTarget.java
|
||||
index 4f9f3367b1ca3903df03a80fa2b01a3d24e6e77d..51413df5cd61b3ff59c6c6c3ec69d6732ab07d83 100644
|
||||
--- a/net/minecraft/world/entity/ai/behavior/SetClosestHomeAsWalkTarget.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/SetClosestHomeAsWalkTarget.java
|
||||
@@ -60,17 +60,20 @@ public class SetClosestHomeAsWalkTarget {
|
||||
poi -> poi.is(PoiTypes.HOME), predicate, mob.blockPosition(), 48, PoiManager.Occupancy.ANY
|
||||
)
|
||||
.collect(Collectors.toSet());
|
||||
+ // Kaiiju start - petal - Async path processing
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) {
|
||||
+ // await on path async
|
||||
+ Path possiblePath = AcquirePoi.findPathToPois(mob, set);
|
||||
+
|
||||
+ // wait on the path to be processed
|
||||
+ org.dreeam.leaf.async.path.AsyncPathProcessor.awaitProcessing(possiblePath, path -> {
|
||||
+ processPath(speedModifier, map, mutableLong, walkTarget, level, poiManager, mutableInt, path);
|
||||
+ });
|
||||
+ } else {
|
||||
+ // Kaiiju end
|
||||
Path path = AcquirePoi.findPathToPois(mob, set);
|
||||
- if (path != null && path.canReach()) {
|
||||
- BlockPos target = path.getTarget();
|
||||
- Optional<Holder<PoiType>> type = poiManager.getType(target);
|
||||
- if (type.isPresent()) {
|
||||
- walkTarget.set(new WalkTarget(target, speedModifier, 1));
|
||||
- DebugPackets.sendPoiTicketCountPacket(level, target);
|
||||
- }
|
||||
- } else if (mutableInt.getValue() < 5) {
|
||||
- map.long2LongEntrySet().removeIf(entry -> entry.getLongValue() < mutableLong.getValue());
|
||||
- }
|
||||
+ processPath(speedModifier, map, mutableLong, walkTarget, level, poiManager, mutableInt, path);
|
||||
+ } // Kaiiju - async path processing
|
||||
|
||||
return true;
|
||||
} else {
|
||||
@@ -81,4 +84,26 @@ public class SetClosestHomeAsWalkTarget {
|
||||
)
|
||||
);
|
||||
}
|
||||
+
|
||||
+ // Leaf start - Kaiiju - petal - Async path processing
|
||||
+ private static void processPath(float speedModifier,
|
||||
+ Long2LongMap map,
|
||||
+ MutableLong mutableLong,
|
||||
+ net.minecraft.world.entity.ai.behavior.declarative.MemoryAccessor<com.mojang.datafixers.kinds.Const.Mu<com.mojang.datafixers.util.Unit>, WalkTarget> walkTarget,
|
||||
+ net.minecraft.server.level.ServerLevel level,
|
||||
+ PoiManager poiManager,
|
||||
+ MutableInt mutableInt,
|
||||
+ @org.jetbrains.annotations.Nullable Path path) {
|
||||
+ if (path != null && path.canReach()) {
|
||||
+ BlockPos target = path.getTarget();
|
||||
+ Optional<Holder<PoiType>> type = poiManager.getType(target);
|
||||
+ if (type.isPresent()) {
|
||||
+ walkTarget.set(new WalkTarget(target, speedModifier, 1));
|
||||
+ DebugPackets.sendPoiTicketCountPacket(level, target);
|
||||
+ }
|
||||
+ } else if (mutableInt.getValue() < 5) {
|
||||
+ map.long2LongEntrySet().removeIf(entry -> entry.getLongValue() < mutableLong.getValue());
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaf end - Kaiiju - petal - Async path processing
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/ai/goal/DoorInteractGoal.java b/net/minecraft/world/entity/ai/goal/DoorInteractGoal.java
|
||||
index d8f532c5e68ff4dff933556c4f981e9474c044e6..95733482a647935e1e7f81fa71a0e99ea52e9a9b 100644
|
||||
--- a/net/minecraft/world/entity/ai/goal/DoorInteractGoal.java
|
||||
+++ b/net/minecraft/world/entity/ai/goal/DoorInteractGoal.java
|
||||
@@ -56,7 +56,7 @@ public abstract class DoorInteractGoal extends Goal {
|
||||
} else {
|
||||
GroundPathNavigation groundPathNavigation = (GroundPathNavigation)this.mob.getNavigation();
|
||||
Path path = groundPathNavigation.getPath();
|
||||
- if (path != null && !path.isDone()) {
|
||||
+ if (path != null && path.isProcessed() && !path.isDone()) { // Kaiiju - async pathfinding - ensure path is processed
|
||||
for (int i = 0; i < Math.min(path.getNextNodeIndex() + 2, path.getNodeCount()); i++) {
|
||||
Node node = path.getNode(i);
|
||||
this.doorPos = new BlockPos(node.x, node.y + 1, node.z);
|
||||
diff --git a/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java b/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java
|
||||
index 66a02fe7594522ef391d67e09856bf3f70fe597d..55e4e6542ac05d89b8d062c546de85b29fb0099f 100644
|
||||
--- a/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java
|
||||
+++ b/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java
|
||||
@@ -12,9 +12,25 @@ public class AmphibiousPathNavigation extends PathNavigation {
|
||||
super(mob, level);
|
||||
}
|
||||
|
||||
+ // Kaiiju start - petal - async path processing
|
||||
+ private static final org.dreeam.leaf.async.path.NodeEvaluatorGenerator nodeEvaluatorGenerator = (org.dreeam.leaf.async.path.NodeEvaluatorFeatures nodeEvaluatorFeatures) -> {
|
||||
+ AmphibiousNodeEvaluator nodeEvaluator = new AmphibiousNodeEvaluator(false);
|
||||
+ nodeEvaluator.setCanPassDoors(nodeEvaluatorFeatures.canPassDoors());
|
||||
+ nodeEvaluator.setCanFloat(nodeEvaluatorFeatures.canFloat());
|
||||
+ nodeEvaluator.setCanWalkOverFences(nodeEvaluatorFeatures.canWalkOverFences());
|
||||
+ nodeEvaluator.setCanOpenDoors(nodeEvaluatorFeatures.canOpenDoors());
|
||||
+ return nodeEvaluator;
|
||||
+ };
|
||||
+ // Kaiiju end
|
||||
+
|
||||
@Override
|
||||
protected PathFinder createPathFinder(int maxVisitedNodes) {
|
||||
this.nodeEvaluator = new AmphibiousNodeEvaluator(false);
|
||||
+ // Kaiiju start - petal - async path processing
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) {
|
||||
+ return new PathFinder(this.nodeEvaluator, maxVisitedNodes, nodeEvaluatorGenerator);
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
return new PathFinder(this.nodeEvaluator, maxVisitedNodes);
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java b/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java
|
||||
index 71ea68b56b3069bdf8e47931156b6ef49ea8ce5d..5de4c1138c7092ff8240fcb30cd64ff1f4d12088 100644
|
||||
--- a/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java
|
||||
+++ b/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java
|
||||
@@ -16,9 +16,25 @@ public class FlyingPathNavigation extends PathNavigation {
|
||||
super(mob, level);
|
||||
}
|
||||
|
||||
+ // Kaiiju start - petal - async path processing
|
||||
+ private static final org.dreeam.leaf.async.path.NodeEvaluatorGenerator nodeEvaluatorGenerator = (org.dreeam.leaf.async.path.NodeEvaluatorFeatures nodeEvaluatorFeatures) -> {
|
||||
+ FlyNodeEvaluator nodeEvaluator = new FlyNodeEvaluator();
|
||||
+ nodeEvaluator.setCanPassDoors(nodeEvaluatorFeatures.canPassDoors());
|
||||
+ nodeEvaluator.setCanFloat(nodeEvaluatorFeatures.canFloat());
|
||||
+ nodeEvaluator.setCanWalkOverFences(nodeEvaluatorFeatures.canWalkOverFences());
|
||||
+ nodeEvaluator.setCanOpenDoors(nodeEvaluatorFeatures.canOpenDoors());
|
||||
+ return nodeEvaluator;
|
||||
+ };
|
||||
+ // Kaiiju end
|
||||
+
|
||||
@Override
|
||||
protected PathFinder createPathFinder(int maxVisitedNodes) {
|
||||
this.nodeEvaluator = new FlyNodeEvaluator();
|
||||
+ // Kaiiju start - petal - async path processing
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) {
|
||||
+ return new PathFinder(this.nodeEvaluator, maxVisitedNodes, nodeEvaluatorGenerator);
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
return new PathFinder(this.nodeEvaluator, maxVisitedNodes);
|
||||
}
|
||||
|
||||
@@ -48,6 +64,7 @@ public class FlyingPathNavigation extends PathNavigation {
|
||||
if (this.hasDelayedRecomputation) {
|
||||
this.recomputePath();
|
||||
}
|
||||
+ if (this.path != null && !this.path.isProcessed()) return; // Kaiiju - petal - async path processing
|
||||
|
||||
if (!this.isDone()) {
|
||||
if (this.canUpdatePath()) {
|
||||
diff --git a/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java b/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java
|
||||
index 045cfafb3afe8271d60852ae3c7cdcb039b44d4f..3f55b00e2f8924a8450df8a3f9812a4ae2983df3 100644
|
||||
--- a/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java
|
||||
+++ b/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java
|
||||
@@ -24,9 +24,25 @@ public class GroundPathNavigation extends PathNavigation {
|
||||
super(mob, level);
|
||||
}
|
||||
|
||||
+ // Kaiiju start - petal - async path processing
|
||||
+ protected static final org.dreeam.leaf.async.path.NodeEvaluatorGenerator nodeEvaluatorGenerator = (org.dreeam.leaf.async.path.NodeEvaluatorFeatures nodeEvaluatorFeatures) -> {
|
||||
+ WalkNodeEvaluator nodeEvaluator = new WalkNodeEvaluator();
|
||||
+ nodeEvaluator.setCanPassDoors(nodeEvaluatorFeatures.canPassDoors());
|
||||
+ nodeEvaluator.setCanFloat(nodeEvaluatorFeatures.canFloat());
|
||||
+ nodeEvaluator.setCanWalkOverFences(nodeEvaluatorFeatures.canWalkOverFences());
|
||||
+ nodeEvaluator.setCanOpenDoors(nodeEvaluatorFeatures.canOpenDoors());
|
||||
+ return nodeEvaluator;
|
||||
+ };
|
||||
+ // Kaiiju end
|
||||
+
|
||||
@Override
|
||||
protected PathFinder createPathFinder(int maxVisitedNodes) {
|
||||
this.nodeEvaluator = new WalkNodeEvaluator();
|
||||
+ // Kaiiju start - petal - async path processing
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) {
|
||||
+ return new PathFinder(this.nodeEvaluator, maxVisitedNodes, nodeEvaluatorGenerator);
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
return new PathFinder(this.nodeEvaluator, maxVisitedNodes);
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
index 6c8fb611943aee8cabc471c63166f9b44ef14826..25ef9b67eee01c6df466031c5dbc728b1a754ab2 100644
|
||||
--- a/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
+++ b/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
@@ -167,6 +167,10 @@ public abstract class PathNavigation {
|
||||
return null;
|
||||
} else if (!this.canUpdatePath()) {
|
||||
return null;
|
||||
+ // Kaiiju start - petal - catch early if it's still processing these positions let it keep processing
|
||||
+ } else if (this.path instanceof org.dreeam.leaf.async.path.AsyncPath asyncPath && !asyncPath.isProcessed() && asyncPath.hasSameProcessingPositions(targets)) {
|
||||
+ return this.path;
|
||||
+ // Kaiiju end
|
||||
} else if (this.path != null && !this.path.isDone() && targets.contains(this.targetPos)) {
|
||||
return this.path;
|
||||
} else {
|
||||
@@ -191,11 +195,29 @@ public abstract class PathNavigation {
|
||||
int i = (int)(followRange + regionOffset);
|
||||
PathNavigationRegion pathNavigationRegion = new PathNavigationRegion(this.level, blockPos.offset(-i, -i, -i), blockPos.offset(i, i, i));
|
||||
Path path = this.pathFinder.findPath(pathNavigationRegion, this.mob, targets, followRange, accuracy, this.maxVisitedNodesMultiplier);
|
||||
+ // Kaiiju start - petal - async path processing
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) {
|
||||
+ // assign early a target position. most calls will only have 1 position
|
||||
+ if (!targets.isEmpty()) this.targetPos = targets.iterator().next();
|
||||
+
|
||||
+ org.dreeam.leaf.async.path.AsyncPathProcessor.awaitProcessing(path, processedPath -> {
|
||||
+ // check that processing didn't take so long that we calculated a new path
|
||||
+ if (processedPath != this.path) return;
|
||||
+
|
||||
+ if (processedPath != null && processedPath.getTarget() != null) {
|
||||
+ this.targetPos = processedPath.getTarget();
|
||||
+ this.reachRange = accuracy;
|
||||
+ this.resetStuckTimeout();
|
||||
+ }
|
||||
+ });
|
||||
+ } else {
|
||||
+ // Kaiiju end
|
||||
if (path != null && path.getTarget() != null) {
|
||||
this.targetPos = path.getTarget();
|
||||
this.reachRange = accuracy;
|
||||
this.resetStuckTimeout();
|
||||
}
|
||||
+ } // Kaiiju - async path processing
|
||||
|
||||
return path;
|
||||
}
|
||||
@@ -246,8 +268,8 @@ public abstract class PathNavigation {
|
||||
if (this.isDone()) {
|
||||
return false;
|
||||
} else {
|
||||
- this.trimPath();
|
||||
- if (this.path.getNodeCount() <= 0) {
|
||||
+ if (path.isProcessed()) this.trimPath(); // Kaiiju - petal - only trim if processed
|
||||
+ if (path.isProcessed() && this.path.getNodeCount() <= 0) { // Kaiiju - petal - only check node count if processed
|
||||
return false;
|
||||
} else {
|
||||
this.speedModifier = speed;
|
||||
@@ -270,6 +292,7 @@ public abstract class PathNavigation {
|
||||
if (this.hasDelayedRecomputation) {
|
||||
this.recomputePath();
|
||||
}
|
||||
+ if (this.path != null && !this.path.isProcessed()) return; // Kaiiju - petal - skip pathfinding if we're still processing
|
||||
|
||||
if (!this.isDone()) {
|
||||
if (this.canUpdatePath()) {
|
||||
@@ -299,6 +322,7 @@ public abstract class PathNavigation {
|
||||
}
|
||||
|
||||
protected void followThePath() {
|
||||
+ if (!this.path.isProcessed()) return; // Kaiiju - petal - skip if not processed
|
||||
Vec3 tempMobPos = this.getTempMobPos();
|
||||
this.maxDistanceToWaypoint = this.mob.getBbWidth() > 0.75F ? this.mob.getBbWidth() / 2.0F : 0.75F - this.mob.getBbWidth() / 2.0F;
|
||||
Vec3i nextNodePos = this.path.getNextNodePos();
|
||||
@@ -455,7 +479,7 @@ public abstract class PathNavigation {
|
||||
public boolean shouldRecomputePath(BlockPos pos) {
|
||||
if (this.hasDelayedRecomputation) {
|
||||
return false;
|
||||
- } else if (this.path != null && !this.path.isDone() && this.path.getNodeCount() != 0) {
|
||||
+ } else if (this.path != null && this.path.isProcessed() && !this.path.isDone() && this.path.getNodeCount() != 0) { // Kaiiju - petal - Skip if not processed
|
||||
Node endNode = this.path.getEndNode();
|
||||
Vec3 vec3 = new Vec3((endNode.x + this.mob.getX()) / 2.0, (endNode.y + this.mob.getY()) / 2.0, (endNode.z + this.mob.getZ()) / 2.0);
|
||||
return pos.closerToCenterThan(vec3, this.path.getNodeCount() - this.path.getNextNodeIndex());
|
||||
diff --git a/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java b/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java
|
||||
index 2979846853898d78a2df19df2287da16dbe4ae71..1289a6e85f3fdb9187323343b6c20e17b6a7e296 100644
|
||||
--- a/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java
|
||||
+++ b/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java
|
||||
@@ -15,11 +15,27 @@ public class WaterBoundPathNavigation extends PathNavigation {
|
||||
super(mob, level);
|
||||
}
|
||||
|
||||
+ // Kaiiju start - petal - async path processing
|
||||
+ private static final org.dreeam.leaf.async.path.NodeEvaluatorGenerator nodeEvaluatorGenerator = (org.dreeam.leaf.async.path.NodeEvaluatorFeatures nodeEvaluatorFeatures) -> {
|
||||
+ SwimNodeEvaluator nodeEvaluator = new SwimNodeEvaluator(nodeEvaluatorFeatures.allowBreaching());
|
||||
+ nodeEvaluator.setCanPassDoors(nodeEvaluatorFeatures.canPassDoors());
|
||||
+ nodeEvaluator.setCanFloat(nodeEvaluatorFeatures.canFloat());
|
||||
+ nodeEvaluator.setCanWalkOverFences(nodeEvaluatorFeatures.canWalkOverFences());
|
||||
+ nodeEvaluator.setCanOpenDoors(nodeEvaluatorFeatures.canOpenDoors());
|
||||
+ return nodeEvaluator;
|
||||
+ };
|
||||
+ // Kaiiju end
|
||||
+
|
||||
@Override
|
||||
protected PathFinder createPathFinder(int maxVisitedNodes) {
|
||||
this.allowBreaching = this.mob.getType() == EntityType.DOLPHIN;
|
||||
this.nodeEvaluator = new SwimNodeEvaluator(this.allowBreaching);
|
||||
this.nodeEvaluator.setCanPassDoors(false);
|
||||
+ // Kaiiju start - async path processing
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) {
|
||||
+ return new PathFinder(this.nodeEvaluator, maxVisitedNodes, nodeEvaluatorGenerator);
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
return new PathFinder(this.nodeEvaluator, maxVisitedNodes);
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java b/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java
|
||||
index 1f96fd5085bacb4c584576c7cb9f51e7898e9b03..8819717c5307a90abc493cf801b4e795c13b3460 100644
|
||||
--- a/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java
|
||||
+++ b/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java
|
||||
@@ -57,17 +57,32 @@ public class NearestBedSensor extends Sensor<Mob> {
|
||||
java.util.List<Pair<Holder<PoiType>, BlockPos>> poiposes = new java.util.ArrayList<>();
|
||||
// don't ask me why it's unbounded. ask mojang.
|
||||
io.papermc.paper.util.PoiAccess.findAnyPoiPositions(poiManager, type -> type.is(PoiTypes.HOME), predicate, entity.blockPosition(), level.purpurConfig.villagerNearestBedSensorSearchRadius, PoiManager.Occupancy.ANY, false, Integer.MAX_VALUE, poiposes); // Purpur - Configurable villager search radius
|
||||
- Path path = AcquirePoi.findPathToPois(entity, new java.util.HashSet<>(poiposes));
|
||||
- // Paper end - optimise POI access
|
||||
- if (path != null && path.canReach()) {
|
||||
- BlockPos target = path.getTarget();
|
||||
- Optional<Holder<PoiType>> type = poiManager.getType(target);
|
||||
- if (type.isPresent()) {
|
||||
- entity.getBrain().setMemory(MemoryModuleType.NEAREST_BED, target);
|
||||
- }
|
||||
- } else if (this.triedCount < 5) {
|
||||
- this.batchCache.long2LongEntrySet().removeIf(entry -> entry.getLongValue() < this.lastUpdate);
|
||||
+ // Kaiiju start - await on async path processing
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) {
|
||||
+ Path possiblePath = AcquirePoi.findPathToPois(entity, new java.util.HashSet<>(poiposes));
|
||||
+ org.dreeam.leaf.async.path.AsyncPathProcessor.awaitProcessing(possiblePath, path -> {
|
||||
+ processPath(entity, poiManager, path);
|
||||
+ });
|
||||
+ } else {
|
||||
+ // Kaiiju end
|
||||
+ Path path = AcquirePoi.findPathToPois(entity, new java.util.HashSet<>(poiposes));
|
||||
+ // Paper end - optimise POI access
|
||||
+ processPath(entity, poiManager, path);
|
||||
+ } // Kaiiju - async path processing
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Leaf start - Kaiiju - await on async path processing
|
||||
+ private void processPath(Mob entity, PoiManager poiManager, @org.jetbrains.annotations.Nullable Path path) {
|
||||
+ if (path != null && path.canReach()) {
|
||||
+ BlockPos target = path.getTarget();
|
||||
+ Optional<Holder<PoiType>> type = poiManager.getType(target);
|
||||
+ if (type.isPresent()) {
|
||||
+ entity.getBrain().setMemory(MemoryModuleType.NEAREST_BED, target);
|
||||
}
|
||||
+ } else if (this.triedCount < 5) {
|
||||
+ this.batchCache.long2LongEntrySet().removeIf(entry -> entry.getLongValue() < this.lastUpdate);
|
||||
}
|
||||
}
|
||||
+ // Leaf end - Kaiiju - await on async path processing
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/animal/Bee.java b/net/minecraft/world/entity/animal/Bee.java
|
||||
index 57c50ce5724b073b1aedf4df3129285143097303..91635b344ac02b66e51aa5620acf9ca481004853 100644
|
||||
--- a/net/minecraft/world/entity/animal/Bee.java
|
||||
+++ b/net/minecraft/world/entity/animal/Bee.java
|
||||
@@ -934,7 +934,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
} else {
|
||||
Bee.this.pathfindRandomlyTowards(Bee.this.hivePos);
|
||||
}
|
||||
- } else {
|
||||
+ } else if (navigation.getPath() != null && navigation.getPath().isProcessed()) { // Kaiiju - petal - check processing
|
||||
boolean flag = this.pathfindDirectlyTowards(Bee.this.hivePos);
|
||||
if (!flag) {
|
||||
this.dropAndBlacklistHive();
|
||||
@@ -988,7 +988,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
return true;
|
||||
} else {
|
||||
Path path = Bee.this.navigation.getPath();
|
||||
- return path != null && path.getTarget().equals(pos) && path.canReach() && path.isDone();
|
||||
+ return path != null && path.isProcessed() && path.getTarget().equals(pos) && path.canReach() && path.isDone(); // Kaiiju - petal - ensure path is processed
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/animal/frog/Frog.java b/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
index 4ecc6b6247a6ab14a5d46f9a05d5df8412ae2a5f..2c28e97e76155fe4de309422f4913c1269972ff4 100644
|
||||
--- a/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
+++ b/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
@@ -479,9 +479,25 @@ public class Frog extends Animal implements VariantHolder<Holder<FrogVariant>> {
|
||||
return pathType != PathType.WATER_BORDER && super.canCutCorner(pathType);
|
||||
}
|
||||
|
||||
+ // Kaiiju start - petal - async path processing
|
||||
+ private static final org.dreeam.leaf.async.path.NodeEvaluatorGenerator nodeEvaluatorGenerator = (org.dreeam.leaf.async.path.NodeEvaluatorFeatures nodeEvaluatorFeatures) -> {
|
||||
+ Frog.FrogNodeEvaluator nodeEvaluator = new Frog.FrogNodeEvaluator(true);
|
||||
+ nodeEvaluator.setCanPassDoors(nodeEvaluatorFeatures.canPassDoors());
|
||||
+ nodeEvaluator.setCanFloat(nodeEvaluatorFeatures.canFloat());
|
||||
+ nodeEvaluator.setCanWalkOverFences(nodeEvaluatorFeatures.canWalkOverFences());
|
||||
+ nodeEvaluator.setCanOpenDoors(nodeEvaluatorFeatures.canOpenDoors());
|
||||
+ return nodeEvaluator;
|
||||
+ };
|
||||
+ // Kaiiju end
|
||||
+
|
||||
@Override
|
||||
protected PathFinder createPathFinder(int maxVisitedNodes) {
|
||||
this.nodeEvaluator = new Frog.FrogNodeEvaluator(true);
|
||||
+ // Kaiiju start - petal - async path processing
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) {
|
||||
+ return new PathFinder(this.nodeEvaluator, maxVisitedNodes, nodeEvaluatorGenerator);
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
return new PathFinder(this.nodeEvaluator, maxVisitedNodes);
|
||||
}
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/monster/Drowned.java b/net/minecraft/world/entity/monster/Drowned.java
|
||||
index 6c73245b8d04f194e72165aa0000ca79a95db59d..f5e6673ff2bd3029585b9ffea10df5d549f1cdd6 100644
|
||||
--- a/net/minecraft/world/entity/monster/Drowned.java
|
||||
+++ b/net/minecraft/world/entity/monster/Drowned.java
|
||||
@@ -313,7 +313,7 @@ public class Drowned extends Zombie implements RangedAttackMob {
|
||||
|
||||
protected boolean closeToNextPos() {
|
||||
Path path = this.getNavigation().getPath();
|
||||
- if (path != null) {
|
||||
+ if (path != null && path.isProcessed()) { // Kaiiju - petal - ensure path is processed
|
||||
BlockPos target = path.getTarget();
|
||||
if (target != null) {
|
||||
double d = this.distanceToSqr(target.getX(), target.getY(), target.getZ());
|
||||
diff --git a/net/minecraft/world/entity/monster/Strider.java b/net/minecraft/world/entity/monster/Strider.java
|
||||
index 241526239bdbd5d9276f85e7fca46a7051f46a25..ae4ee948971e931e4fdc4ec2187f5182195c626c 100644
|
||||
--- a/net/minecraft/world/entity/monster/Strider.java
|
||||
+++ b/net/minecraft/world/entity/monster/Strider.java
|
||||
@@ -579,9 +579,25 @@ public class Strider extends Animal implements ItemSteerable, Saddleable {
|
||||
super(strider, level);
|
||||
}
|
||||
|
||||
+ // Kaiiju start - petal - async path processing
|
||||
+ private static final org.dreeam.leaf.async.path.NodeEvaluatorGenerator nodeEvaluatorGenerator = (org.dreeam.leaf.async.path.NodeEvaluatorFeatures nodeEvaluatorFeatures) -> {
|
||||
+ WalkNodeEvaluator nodeEvaluator = new WalkNodeEvaluator();
|
||||
+ nodeEvaluator.setCanPassDoors(nodeEvaluatorFeatures.canPassDoors());
|
||||
+ nodeEvaluator.setCanFloat(nodeEvaluatorFeatures.canFloat());
|
||||
+ nodeEvaluator.setCanWalkOverFences(nodeEvaluatorFeatures.canWalkOverFences());
|
||||
+ nodeEvaluator.setCanOpenDoors(nodeEvaluatorFeatures.canOpenDoors());
|
||||
+ return nodeEvaluator;
|
||||
+ };
|
||||
+ // Kaiiju end
|
||||
+
|
||||
@Override
|
||||
protected PathFinder createPathFinder(int maxVisitedNodes) {
|
||||
this.nodeEvaluator = new WalkNodeEvaluator();
|
||||
+ // Kaiiju start - async path processing
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) {
|
||||
+ return new PathFinder(this.nodeEvaluator, maxVisitedNodes, nodeEvaluatorGenerator);
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
return new PathFinder(this.nodeEvaluator, maxVisitedNodes);
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/world/entity/monster/warden/Warden.java b/net/minecraft/world/entity/monster/warden/Warden.java
|
||||
index 26f3fe1c80b0d87b96076432f35fe4f95f92ce13..3a43790fb91e778f4fc0730aecd0dde4a6d301c8 100644
|
||||
--- a/net/minecraft/world/entity/monster/warden/Warden.java
|
||||
+++ b/net/minecraft/world/entity/monster/warden/Warden.java
|
||||
@@ -599,6 +599,16 @@ public class Warden extends Monster implements VibrationSystem {
|
||||
@Override
|
||||
protected PathFinder createPathFinder(int maxVisitedNodes) {
|
||||
this.nodeEvaluator = new WalkNodeEvaluator();
|
||||
+ // Kaiiju start - petal - async path processing
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) {
|
||||
+ return new PathFinder(this.nodeEvaluator, maxVisitedNodes, GroundPathNavigation.nodeEvaluatorGenerator) {
|
||||
+ @Override
|
||||
+ protected float distance(Node first, Node second) {
|
||||
+ return first.distanceToXZ(second);
|
||||
+ }
|
||||
+ };
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
return new PathFinder(this.nodeEvaluator, maxVisitedNodes) {
|
||||
@Override
|
||||
protected float distance(Node first, Node second) {
|
||||
diff --git a/net/minecraft/world/level/block/ShulkerBoxBlock.java b/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
||||
index cdf835ff107bc1eadde706d69384e687626fce70..31066accd82da2b8b36d9a9d8676dc887af31fed 100644
|
||||
--- a/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
||||
+++ b/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
||||
@@ -217,9 +217,16 @@ public class ShulkerBoxBlock extends BaseEntityBlock {
|
||||
|
||||
@Override
|
||||
protected VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
|
||||
+ //if (Thread.currentThread().getName().contains("petal-async-pathfinding-thread")) return Shapes.block(); // Kaiiju - async pathfinding - we cannot get block entities // Leaf - Don't need this
|
||||
return level.getBlockEntity(pos) instanceof ShulkerBoxBlockEntity shulkerBoxBlockEntity
|
||||
? Shapes.create(shulkerBoxBlockEntity.getBoundingBox(state))
|
||||
: Shapes.block();
|
||||
+ // Kaiiju start - async pathfinding - workaround // Leaf - Don't need this
|
||||
+ /*
|
||||
+ } catch (NullPointerException e) {
|
||||
+ return Shapes.block();
|
||||
+ }
|
||||
+ */
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/net/minecraft/world/level/pathfinder/Path.java b/net/minecraft/world/level/pathfinder/Path.java
|
||||
index d6d3c8f5e5dd4a8cab0d3fcc131c3a59f06130c6..add5b8b98e4d09617cbd4e7dd2710dc50781613a 100644
|
||||
--- a/net/minecraft/world/level/pathfinder/Path.java
|
||||
+++ b/net/minecraft/world/level/pathfinder/Path.java
|
||||
@@ -26,6 +26,17 @@ public class Path {
|
||||
this.reached = reached;
|
||||
}
|
||||
|
||||
+ // Kaiiju start - petal - async path processing
|
||||
+ /**
|
||||
+ * checks if the path is completely processed in the case of it being computed async
|
||||
+ *
|
||||
+ * @return true if the path is processed
|
||||
+ */
|
||||
+ public boolean isProcessed() {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
+
|
||||
public void advance() {
|
||||
this.nextNodeIndex++;
|
||||
}
|
||||
@@ -99,6 +110,7 @@ public class Path {
|
||||
}
|
||||
|
||||
public boolean sameAs(@Nullable Path pathentity) {
|
||||
+ if (pathentity == this) return true; // Kaiiju - petal - short circuit
|
||||
if (pathentity == null) {
|
||||
return false;
|
||||
} else if (pathentity.nodes.size() != this.nodes.size()) {
|
||||
diff --git a/net/minecraft/world/level/pathfinder/PathFinder.java b/net/minecraft/world/level/pathfinder/PathFinder.java
|
||||
index d48057d387b6937a0194e5300eb1cb46dec2896b..9912ba3bc165dfbdd55fbf02dcec28dc2902b30a 100644
|
||||
--- a/net/minecraft/world/level/pathfinder/PathFinder.java
|
||||
+++ b/net/minecraft/world/level/pathfinder/PathFinder.java
|
||||
@@ -22,10 +22,18 @@ public class PathFinder {
|
||||
public final NodeEvaluator nodeEvaluator;
|
||||
private static final boolean DEBUG = false;
|
||||
private final BinaryHeap openSet = new BinaryHeap();
|
||||
+ private final @Nullable org.dreeam.leaf.async.path.NodeEvaluatorGenerator nodeEvaluatorGenerator; // Kaiiju - petal - we use this later to generate an evaluator
|
||||
|
||||
- public PathFinder(NodeEvaluator nodeEvaluator, int maxVisitedNodes) {
|
||||
+ public PathFinder(NodeEvaluator nodeEvaluator, int maxVisitedNodes, @Nullable org.dreeam.leaf.async.path.NodeEvaluatorGenerator nodeEvaluatorGenerator) { // Kaiiju - petal - add nodeEvaluatorGenerator
|
||||
this.nodeEvaluator = nodeEvaluator;
|
||||
this.maxVisitedNodes = maxVisitedNodes;
|
||||
+ // Kaiiju start - petal - support nodeEvaluatorgenerators
|
||||
+ this.nodeEvaluatorGenerator = nodeEvaluatorGenerator;
|
||||
+ }
|
||||
+
|
||||
+ public PathFinder(NodeEvaluator nodeEvaluator, int maxVisitedNodes) {
|
||||
+ this(nodeEvaluator, maxVisitedNodes, null);
|
||||
+ // Kaiiju end
|
||||
}
|
||||
|
||||
public void setMaxVisitedNodes(int maxVisitedNodes) {
|
||||
@@ -34,26 +42,63 @@ public class PathFinder {
|
||||
|
||||
@Nullable
|
||||
public Path findPath(PathNavigationRegion region, Mob mob, Set<BlockPos> targetPositions, float maxRange, int accuracy, float searchDepthMultiplier) {
|
||||
- this.openSet.clear();
|
||||
- this.nodeEvaluator.prepare(region, mob);
|
||||
- Node start = this.nodeEvaluator.getStart();
|
||||
+ if (!org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled)
|
||||
+ this.openSet.clear(); // Kaiiju - petal - it's always cleared in processPath
|
||||
+ // Kaiiju start - petal - use a generated evaluator if we have one otherwise run sync
|
||||
+ NodeEvaluator nodeEvaluator = this.nodeEvaluatorGenerator == null
|
||||
+ ? this.nodeEvaluator
|
||||
+ : org.dreeam.leaf.async.path.NodeEvaluatorCache.takeNodeEvaluator(this.nodeEvaluatorGenerator, this.nodeEvaluator);
|
||||
+ nodeEvaluator.prepare(region, mob);
|
||||
+ Node start = nodeEvaluator.getStart();
|
||||
+ // Kaiiju end
|
||||
if (start == null) {
|
||||
+ org.dreeam.leaf.async.path.NodeEvaluatorCache.removeNodeEvaluator(nodeEvaluator); // Kaiiju - petal - handle nodeEvaluatorGenerator
|
||||
return null;
|
||||
} else {
|
||||
// Paper start - Perf: remove streams and optimize collection
|
||||
List<Map.Entry<Target, BlockPos>> map = Lists.newArrayList();
|
||||
for (BlockPos pos : targetPositions) {
|
||||
- map.add(new java.util.AbstractMap.SimpleEntry<>(this.nodeEvaluator.getTarget(pos.getX(), pos.getY(), pos.getZ()), pos));
|
||||
+ map.add(new java.util.AbstractMap.SimpleEntry<>(nodeEvaluator.getTarget(pos.getX(), pos.getY(), pos.getZ()), pos)); // Kaiiju - petal - handle nodeEvaluatorGenerator
|
||||
}
|
||||
// Paper end - Perf: remove streams and optimize collection
|
||||
- Path path = this.findPath(start, map, maxRange, accuracy, searchDepthMultiplier);
|
||||
- this.nodeEvaluator.done();
|
||||
- return path;
|
||||
+ // Kaiiju start - petal - async path processing
|
||||
+ if (this.nodeEvaluatorGenerator == null) {
|
||||
+ // run sync :(
|
||||
+ org.dreeam.leaf.async.path.NodeEvaluatorCache.removeNodeEvaluator(nodeEvaluator);
|
||||
+ return this.findPath(start, map, maxRange, accuracy, searchDepthMultiplier);
|
||||
+ }
|
||||
+
|
||||
+ return new org.dreeam.leaf.async.path.AsyncPath(Lists.newArrayList(), targetPositions, () -> {
|
||||
+ try {
|
||||
+ return this.processPath(nodeEvaluator, start, map, maxRange, accuracy, searchDepthMultiplier);
|
||||
+ } catch (Exception e) {
|
||||
+ e.printStackTrace();
|
||||
+ return null;
|
||||
+ } finally {
|
||||
+ nodeEvaluator.done();
|
||||
+ org.dreeam.leaf.async.path.NodeEvaluatorCache.returnNodeEvaluator(nodeEvaluator);
|
||||
+ }
|
||||
+ });
|
||||
+ // Kaiiju end
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Path findPath(Node node, List<Map.Entry<Target, BlockPos>> positions, float maxRange, int accuracy, float searchDepthMultiplier) { // Paper - optimize collection
|
||||
+ // Kaiiju start - petal - split pathfinding into the original sync method for compat and processing for delaying
|
||||
+ try {
|
||||
+ return this.processPath(this.nodeEvaluator, node, positions, maxRange, accuracy, searchDepthMultiplier);
|
||||
+ } catch (Exception e) {
|
||||
+ e.printStackTrace();
|
||||
+ return null;
|
||||
+ } finally {
|
||||
+ this.nodeEvaluator.done();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private synchronized @org.jetbrains.annotations.NotNull Path processPath(NodeEvaluator nodeEvaluator, Node node, List<Map.Entry<Target, BlockPos>> positions, float maxRange, int accuracy, float searchDepthMultiplier) { // sync to only use the caching functions in this class on a single thread
|
||||
+ org.apache.commons.lang3.Validate.isTrue(!positions.isEmpty()); // ensure that we have at least one position, which means we'll always return a path
|
||||
+ // Kaiiju end
|
||||
// Set<Target> set = targetPositions.keySet(); // Paper
|
||||
node.g = 0.0F;
|
||||
node.h = this.getBestH(node, positions); // Paper - optimize collection
|
||||
@@ -89,7 +134,7 @@ public class PathFinder {
|
||||
}
|
||||
|
||||
if (!(node1.distanceTo(node) >= maxRange)) {
|
||||
- int neighbors = this.nodeEvaluator.getNeighbors(this.neighbors, node1);
|
||||
+ int neighbors = nodeEvaluator.getNeighbors(this.neighbors, node1); // Kaiiju - petal - use provided nodeEvaluator
|
||||
|
||||
for (int i2 = 0; i2 < neighbors; i2++) {
|
||||
Node node2 = this.neighbors[i2];
|
||||
@@ -124,6 +169,7 @@ public class PathFinder {
|
||||
}
|
||||
}
|
||||
|
||||
+ //noinspection ConstantConditions // Kaiiju - petal - ignore this warning, we know that the above loop always runs at least once since positions is not empty
|
||||
return best;
|
||||
// Paper end - Perf: remove streams and optimize collection
|
||||
}
|
||||
diff --git a/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java b/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java
|
||||
index f18aa938692a1c29228ff5e98ab9d58c4bfff094..6495dd7ace05dda1e8e39fa5ae682797dd5980bf 100644
|
||||
--- a/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java
|
||||
+++ b/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java
|
||||
@@ -15,7 +15,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
|
||||
public class SwimNodeEvaluator extends NodeEvaluator {
|
||||
- private final boolean allowBreaching;
|
||||
+ public final boolean allowBreaching; // Kaiiju - make this public
|
||||
private final Long2ObjectMap<PathType> pathTypesByPosCache = new Long2ObjectOpenHashMap<>();
|
||||
|
||||
public SwimNodeEvaluator(boolean allowBreaching) {
|
||||
@@ -10,21 +10,21 @@ Original project: https://github.com/Bloom-host/Petal
|
||||
|
||||
2. EuclideanGameEventListenerRegistry is not used concurrently so we ban that usage for improved performance with allays
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java
|
||||
index 4729befa12732a9fd65cce243b33b3b479026c41..f61295465d89d6aaab83666677617f5198b75f3c 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java
|
||||
@@ -68,7 +68,7 @@ public class SculkCatalystBlockEntity extends BlockEntity implements GameEventLi
|
||||
diff --git a/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java b/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java
|
||||
index 1638eccef431fb68775af624110f1968f0c6dabd..1b63730f508813f380460860a6193d419112c08f 100644
|
||||
--- a/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java
|
||||
@@ -65,7 +65,7 @@ public class SculkCatalystBlockEntity extends BlockEntity implements GameEventLi
|
||||
return this.catalystListener;
|
||||
}
|
||||
|
||||
- public static class CatalystListener implements GameEventListener {
|
||||
+ public class CatalystListener implements GameEventListener { // Leaf - petal
|
||||
|
||||
public static final int PULSE_TICKS = 8;
|
||||
final SculkSpreader sculkSpreader;
|
||||
@@ -139,6 +139,13 @@ public class SculkCatalystBlockEntity extends BlockEntity implements GameEventLi
|
||||
world.playSound((Player) null, pos, SoundEvents.SCULK_CATALYST_BLOOM, SoundSource.BLOCKS, 2.0F, 0.6F + random.nextFloat() * 0.4F);
|
||||
private final BlockState blockState;
|
||||
@@ -127,6 +127,13 @@ public class SculkCatalystBlockEntity extends BlockEntity implements GameEventLi
|
||||
level.playSound(null, pos, SoundEvents.SCULK_CATALYST_BLOOM, SoundSource.BLOCKS, 2.0F, 0.6F + random.nextFloat() * 0.4F);
|
||||
}
|
||||
|
||||
+ // Leaf start - petal
|
||||
@@ -34,14 +34,14 @@ index 4729befa12732a9fd65cce243b33b3b479026c41..f61295465d89d6aaab83666677617f51
|
||||
+ }
|
||||
+ // Leaf end - petal
|
||||
+
|
||||
private void tryAwardItSpreadsAdvancement(Level world, LivingEntity deadEntity) {
|
||||
LivingEntity entityliving1 = deadEntity.getLastHurtByMob();
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
index 370266dfa461432b9e22b3ce35d6094949dc2f49..b8246d7255bffc7e12a67772df2ceac1925b2a05 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
@@ -81,7 +81,18 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
private void tryAwardItSpreadsAdvancement(Level level, LivingEntity entity) {
|
||||
if (entity.getLastHurtByMob() instanceof ServerPlayer serverPlayer) {
|
||||
DamageSource damageSource = entity.getLastDamageSource() == null
|
||||
diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
index a5f76c81dfb148fc184d137395d5961229cb799b..d97d8e79034eb1484d4e3646faacc6f11289bb28 100644
|
||||
--- a/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
@@ -79,7 +79,19 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
private Supplier<FullChunkStatus> fullStatus;
|
||||
@Nullable
|
||||
private LevelChunk.PostLoadProcessor postLoad;
|
||||
@@ -57,28 +57,31 @@ index 370266dfa461432b9e22b3ce35d6094949dc2f49..b8246d7255bffc7e12a67772df2ceac1
|
||||
+ private static int getGameEventSectionLength(int sectionCount) {
|
||||
+ return sectionCount + (GAME_EVENT_DISPATCHER_RADIUS * 2);
|
||||
+ }
|
||||
+
|
||||
+ // Leaf end - petal
|
||||
private final LevelChunkTicks<Block> blockTicks;
|
||||
private final LevelChunkTicks<Fluid> fluidTicks;
|
||||
private LevelChunk.UnsavedListener unsavedListener;
|
||||
@@ -108,7 +119,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
this.unsavedListener = (chunkcoordintpair1) -> {
|
||||
};
|
||||
this.level = (ServerLevel) world; // CraftBukkit - type
|
||||
- this.gameEventListenerRegistrySections = new Int2ObjectOpenHashMap();
|
||||
private LevelChunk.UnsavedListener unsavedListener = chunkPos -> {};
|
||||
@@ -154,7 +166,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
) {
|
||||
super(pos, data, level, net.minecraft.server.MinecraftServer.getServer().registryAccess().lookupOrThrow(Registries.BIOME), inhabitedTime, sections, blendingData); // Paper - Anti-Xray - The world isn't ready yet, use server singleton for registry
|
||||
this.level = (ServerLevel) level; // CraftBukkit - type
|
||||
- this.gameEventListenerRegistrySections = new Int2ObjectOpenHashMap<>();
|
||||
+ this.gameEventListenerRegistrySections = new GameEventListenerRegistry[getGameEventSectionLength(this.getSectionsCount())]; // Leaf - petal
|
||||
Heightmap.Types[] aheightmap_type = Heightmap.Types.values();
|
||||
int j = aheightmap_type.length;
|
||||
|
||||
@@ -266,9 +277,23 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
Level world = this.level;
|
||||
for (Heightmap.Types types : Heightmap.Types.values()) {
|
||||
if (ChunkStatus.FULL.heightmapsAfter().contains(types)) {
|
||||
@@ -268,10 +280,27 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
|
||||
if (world instanceof ServerLevel worldserver) {
|
||||
- return (GameEventListenerRegistry) this.gameEventListenerRegistrySections.computeIfAbsent(ySectionCoord, (j) -> {
|
||||
- return new EuclideanGameEventListenerRegistry(worldserver, ySectionCoord, this::removeGameEventListenerRegistry);
|
||||
- });
|
||||
@Override
|
||||
public GameEventListenerRegistry getListenerRegistry(int sectionY) {
|
||||
- return this.level instanceof ServerLevel serverLevel
|
||||
- ? this.gameEventListenerRegistrySections
|
||||
- .computeIfAbsent(sectionY, i -> new EuclideanGameEventListenerRegistry(serverLevel, sectionY, this::removeGameEventListenerRegistry))
|
||||
- : super.getListenerRegistry(sectionY);
|
||||
+ // Leaf start - petal
|
||||
+ int sectionIndex = getGameEventSectionIndex(this.getSectionIndexFromSectionY(ySectionCoord));
|
||||
+ if (this.level instanceof ServerLevel serverLevel) {
|
||||
+ int sectionIndex = getGameEventSectionIndex(this.getSectionIndexFromSectionY(sectionY));
|
||||
+
|
||||
+ // drop game events that are too far away (32 blocks) from loaded sections
|
||||
+ // this matches the highest radius of game events in the game
|
||||
@@ -89,27 +92,30 @@ index 370266dfa461432b9e22b3ce35d6094949dc2f49..b8246d7255bffc7e12a67772df2ceac1
|
||||
+ var dispatcher = this.gameEventListenerRegistrySections[sectionIndex];
|
||||
+
|
||||
+ if (dispatcher == null) {
|
||||
+ dispatcher = this.gameEventListenerRegistrySections[sectionIndex] = new EuclideanGameEventListenerRegistry(worldserver, ySectionCoord, this::removeGameEventListenerRegistry);
|
||||
+ dispatcher = this.gameEventListenerRegistrySections[sectionIndex] = new EuclideanGameEventListenerRegistry(serverLevel, sectionY, this::removeGameEventListenerRegistry);
|
||||
+ }
|
||||
+
|
||||
+ return dispatcher;
|
||||
+ }
|
||||
+
|
||||
+ return super.getListenerRegistry(sectionY);
|
||||
+ // Leaf end - petal
|
||||
} else {
|
||||
return super.getListenerRegistry(ySectionCoord);
|
||||
}
|
||||
@@ -659,7 +684,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
}
|
||||
|
||||
private void removeGameEventListenerRegistry(int ySectionCoord) {
|
||||
- this.gameEventListenerRegistrySections.remove(ySectionCoord);
|
||||
+ this.gameEventListenerRegistrySections[getGameEventSectionIndex(this.getSectionIndexFromSectionY(ySectionCoord))] = null; // Leaf - petal
|
||||
// Paper start - Perf: Reduce instructions and provide final method
|
||||
@@ -611,7 +640,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
}
|
||||
|
||||
private void removeGameEventListenerRegistry(int sectionY) {
|
||||
- this.gameEventListenerRegistrySections.remove(sectionY);
|
||||
+ this.gameEventListenerRegistrySections[getGameEventSectionIndex(this.getSectionIndexFromSectionY(sectionY))] = null; // Leaf - petal
|
||||
}
|
||||
|
||||
private void removeBlockEntityTicker(BlockPos pos) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/gameevent/EuclideanGameEventListenerRegistry.java b/src/main/java/net/minecraft/world/level/gameevent/EuclideanGameEventListenerRegistry.java
|
||||
index 1e93f3a1b11196a431a1f5a0957036fe0c9191a4..f1f0dbb20d4ee2f3f47e202f2cb3dd4bde9ac0b3 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/gameevent/EuclideanGameEventListenerRegistry.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/gameevent/EuclideanGameEventListenerRegistry.java
|
||||
diff --git a/net/minecraft/world/level/gameevent/EuclideanGameEventListenerRegistry.java b/net/minecraft/world/level/gameevent/EuclideanGameEventListenerRegistry.java
|
||||
index 5175fc90a1fc61c832c6697997a97ae199b195ac..17ba3e94021365f0ea28126b5bef61cafc58461f 100644
|
||||
--- a/net/minecraft/world/level/gameevent/EuclideanGameEventListenerRegistry.java
|
||||
+++ b/net/minecraft/world/level/gameevent/EuclideanGameEventListenerRegistry.java
|
||||
@@ -14,8 +14,8 @@ import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class EuclideanGameEventListenerRegistry implements GameEventListenerRegistry {
|
||||
@@ -147,7 +153,7 @@ index 1e93f3a1b11196a431a1f5a0957036fe0c9191a4..f1f0dbb20d4ee2f3f47e202f2cb3dd4b
|
||||
+ if (false) { // Leaf - petal - Disallow concurrent modification
|
||||
iterator.remove();
|
||||
} else {
|
||||
Optional<Vec3> optional = getPostableListenerPosition(this.level, pos, gameEventListener);
|
||||
Optional<Vec3> postableListenerPosition = getPostableListenerPosition(this.level, pos, gameEventListener);
|
||||
@@ -80,6 +80,8 @@ public class EuclideanGameEventListenerRegistry implements GameEventListenerRegi
|
||||
this.processing = false;
|
||||
}
|
||||
@@ -164,24 +170,24 @@ index 1e93f3a1b11196a431a1f5a0957036fe0c9191a4..f1f0dbb20d4ee2f3f47e202f2cb3dd4b
|
||||
+ */
|
||||
+ // Leaf end - petal
|
||||
|
||||
return bl;
|
||||
return flag;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java b/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java
|
||||
index df6c97be1b278c97a20390be5d3e60f429383702..75a34d60d6729f3767dc9bef283db6e9e3baf3a7 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java
|
||||
@@ -45,6 +45,7 @@ public class GameEventDispatcher {
|
||||
int k1 = SectionPos.blockToSectionCoord(blockposition.getZ() + i);
|
||||
List<GameEvent.ListenerInfo> list = new ArrayList();
|
||||
GameEventListenerRegistry.ListenerVisitor gameeventlistenerregistry_a = (gameeventlistener, vec3d1) -> {
|
||||
+ if (!gameeventlistener.listensToEvent(event.value(), emitter)) return; // Leaf - petal - If they don't listen, ignore
|
||||
if (gameeventlistener.getDeliveryMode() == GameEventListener.DeliveryMode.BY_DISTANCE) {
|
||||
list.add(new GameEvent.ListenerInfo(event, emitterPos, emitter, gameeventlistener, vec3d1));
|
||||
diff --git a/net/minecraft/world/level/gameevent/GameEventDispatcher.java b/net/minecraft/world/level/gameevent/GameEventDispatcher.java
|
||||
index 1e9b066ef468ae840eda3c1f6c4b68111a5e862c..a0c7debc62cbbc3f8911e06d453f51d239917d8d 100644
|
||||
--- a/net/minecraft/world/level/gameevent/GameEventDispatcher.java
|
||||
+++ b/net/minecraft/world/level/gameevent/GameEventDispatcher.java
|
||||
@@ -44,6 +44,7 @@ public class GameEventDispatcher {
|
||||
int sectionPosCoord5 = SectionPos.blockToSectionCoord(blockPos.getZ() + notificationRadius);
|
||||
List<GameEvent.ListenerInfo> list = new ArrayList<>();
|
||||
GameEventListenerRegistry.ListenerVisitor listenerVisitor = (listener, pos1) -> {
|
||||
+ if (!listener.listensToEvent(gameEvent.value(), context)) return; // Leaf - petal - If they don't listen, ignore
|
||||
if (listener.getDeliveryMode() == GameEventListener.DeliveryMode.BY_DISTANCE) {
|
||||
list.add(new GameEvent.ListenerInfo(gameEvent, pos, context, listener, pos1));
|
||||
} else {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/gameevent/GameEventListener.java b/src/main/java/net/minecraft/world/level/gameevent/GameEventListener.java
|
||||
index 0f3a79cc644a5b89fa35fdd413ff5781987c4ef3..9751ddc24899fd4d854899de209e24d9264baebc 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/gameevent/GameEventListener.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/gameevent/GameEventListener.java
|
||||
diff --git a/net/minecraft/world/level/gameevent/GameEventListener.java b/net/minecraft/world/level/gameevent/GameEventListener.java
|
||||
index 5a31b5f1e75dd7b412ab577ea6621b7e87fc0590..6411c12392c4989ed3ce9ead52d42c49dfdfa201 100644
|
||||
--- a/net/minecraft/world/level/gameevent/GameEventListener.java
|
||||
+++ b/net/minecraft/world/level/gameevent/GameEventListener.java
|
||||
@@ -23,4 +23,10 @@ public interface GameEventListener {
|
||||
public interface Provider<T extends GameEventListener> {
|
||||
T getListener();
|
||||
@@ -6,11 +6,11 @@ Subject: [PATCH] Reduce canSee work
|
||||
Co-authored by: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||
Co-authored by: MachineBreaker <machinebreaker>
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index c3b9a9904f7b34df3dbd0a25e52946ab45f0f4d6..859708f1ab4b9f1bd318ca08c73cb67b1c3fe010 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -993,17 +993,19 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
|
||||
index 78654e7ae26c0b2b2512f4e29a331e2ead2d6916..b7cbf1c7bb56668763c4f968ea0d69f730cb5285 100644
|
||||
--- a/net/minecraft/world/level/Level.java
|
||||
+++ b/net/minecraft/world/level/Level.java
|
||||
@@ -1006,17 +1006,19 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
for (int i = 0, len = entities.size(); i < len; ++i) {
|
||||
Entity entity = entities.get(i);
|
||||
|
||||
@@ -4,11 +4,11 @@ Date: Mon, 4 Dec 2023 16:11:36 +0200
|
||||
Subject: [PATCH] Fix sprint glitch
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 6f3986ba57ce794a1f78b8960a7c8de8a3508c19..d5395553034c148bdc12b065328f52ef72b9bd86 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -1456,7 +1456,8 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
||||
index 956c1b5422c177e0da5140c4184720d10aa4e790..c041cba43b4687e2f2f057edfae448a42f6d8753 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -1379,7 +1379,8 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
player.setRealHealth(health);
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ Date: Sun, 17 Dec 2023 19:34:46 -0500
|
||||
Subject: [PATCH] Configurable movement speed of more entities
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Drowned.java b/src/main/java/net/minecraft/world/entity/monster/Drowned.java
|
||||
index 53ebc584a7eb8b18e959aff75a11a37fd0b8ace2..03de4f06c461a17ec7a3516ca579f79472bb3919 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Drowned.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Drowned.java
|
||||
@@ -93,6 +93,7 @@ public class Drowned extends Zombie implements RangedAttackMob {
|
||||
diff --git a/net/minecraft/world/entity/monster/Drowned.java b/net/minecraft/world/entity/monster/Drowned.java
|
||||
index f5e6673ff2bd3029585b9ffea10df5d549f1cdd6..6b328ea277bb3adcb674b05845f82f7427237555 100644
|
||||
--- a/net/minecraft/world/entity/monster/Drowned.java
|
||||
+++ b/net/minecraft/world/entity/monster/Drowned.java
|
||||
@@ -97,6 +97,7 @@ public class Drowned extends Zombie implements RangedAttackMob {
|
||||
public void initAttributes() {
|
||||
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(this.level().purpurConfig.drownedMaxHealth);
|
||||
this.getAttribute(Attributes.SCALE).setBaseValue(this.level().purpurConfig.drownedScale);
|
||||
@@ -16,11 +16,11 @@ index 53ebc584a7eb8b18e959aff75a11a37fd0b8ace2..03de4f06c461a17ec7a3516ca579f794
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Husk.java b/src/main/java/net/minecraft/world/entity/monster/Husk.java
|
||||
index 7c8ec5cd88fb2083f458a945e716b6f118555db8..108a0874cf9c17809d31d0f3cf64ceeb52746f32 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Husk.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Husk.java
|
||||
@@ -44,6 +44,7 @@ public class Husk extends Zombie {
|
||||
diff --git a/net/minecraft/world/entity/monster/Husk.java b/net/minecraft/world/entity/monster/Husk.java
|
||||
index a5bfc6f5caba1da8cfcb345524e05e8676672cb0..a500584a3736d289bca2f7a76fec2d1567065229 100644
|
||||
--- a/net/minecraft/world/entity/monster/Husk.java
|
||||
+++ b/net/minecraft/world/entity/monster/Husk.java
|
||||
@@ -43,6 +43,7 @@ public class Husk extends Zombie {
|
||||
@Override
|
||||
public void initAttributes() {
|
||||
this.getAttribute(net.minecraft.world.entity.ai.attributes.Attributes.MAX_HEALTH).setBaseValue(this.level().purpurConfig.huskMaxHealth);
|
||||
@@ -28,40 +28,32 @@ index 7c8ec5cd88fb2083f458a945e716b6f118555db8..108a0874cf9c17809d31d0f3cf64ceeb
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Zombie.java b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
|
||||
index 85b03e0bf7436cb846df13c575ad78ac6a17a151..5924509cbe36d3fee9d2f119d58e67c4b083e4c4 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
|
||||
@@ -132,6 +132,7 @@ public class Zombie extends Monster {
|
||||
diff --git a/net/minecraft/world/entity/monster/Zombie.java b/net/minecraft/world/entity/monster/Zombie.java
|
||||
index 7af71c777dca26cd94b1807a2a77ea0d30e92976..cab69c308a0524137636fd50dc7a0dd0d2a4a2c3 100644
|
||||
--- a/net/minecraft/world/entity/monster/Zombie.java
|
||||
+++ b/net/minecraft/world/entity/monster/Zombie.java
|
||||
@@ -123,6 +123,7 @@ public class Zombie extends Monster {
|
||||
public void initAttributes() {
|
||||
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(this.level().purpurConfig.zombieMaxHealth);
|
||||
this.getAttribute(Attributes.SCALE).setBaseValue(this.level().purpurConfig.zombieScale);
|
||||
+ this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(this.level().purpurConfig.zombieMovementSpeed); // Leaf - Configurable zombie movement speed
|
||||
}
|
||||
// Purpur end - Configurable entity base attributes
|
||||
|
||||
public boolean jockeyOnlyBaby() {
|
||||
@@ -189,9 +190,15 @@ public class Zombie extends Monster {
|
||||
this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<>(this, Turtle.class, 10, true, false, Turtle.BABY_ON_LAND_SELECTOR));
|
||||
}
|
||||
|
||||
+ // Leaf start - Configurable zombie movement speed
|
||||
@@ -190,7 +191,7 @@ public class Zombie extends Monster {
|
||||
public static AttributeSupplier.Builder createAttributes() {
|
||||
- return Monster.createMonsterAttributes().add(Attributes.FOLLOW_RANGE, 35.0D).add(Attributes.MOVEMENT_SPEED, 0.23000000417232513D).add(Attributes.ATTACK_DAMAGE, 3.0D).add(Attributes.ARMOR, 2.0D).add(Attributes.SPAWN_REINFORCEMENTS_CHANCE);
|
||||
+ return Monster.createMonsterAttributes()
|
||||
+ .add(Attributes.FOLLOW_RANGE, 35.0D)
|
||||
+ .add(Attributes.ATTACK_DAMAGE, 3.0D)
|
||||
+ .add(Attributes.ARMOR, 2.0D)
|
||||
+ .add(Attributes.SPAWN_REINFORCEMENTS_CHANCE);
|
||||
}
|
||||
+ // Leaf end
|
||||
|
||||
@Override
|
||||
protected void defineSynchedData(SynchedEntityData.Builder builder) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java b/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java
|
||||
index 6f6b32bf7f68d05e4173c31f2e631a409b858a05..160fcd1f8917d69dde01089111661337827da20a 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java
|
||||
@@ -105,6 +105,7 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder {
|
||||
return Monster.createMonsterAttributes()
|
||||
.add(Attributes.FOLLOW_RANGE, 35.0)
|
||||
- .add(Attributes.MOVEMENT_SPEED, 0.23F)
|
||||
+ //.add(Attributes.MOVEMENT_SPEED, 0.23F) // Leaf - Configurable zombie movement speed
|
||||
.add(Attributes.ATTACK_DAMAGE, 3.0)
|
||||
.add(Attributes.ARMOR, 2.0)
|
||||
.add(Attributes.SPAWN_REINFORCEMENTS_CHANCE);
|
||||
diff --git a/net/minecraft/world/entity/monster/ZombieVillager.java b/net/minecraft/world/entity/monster/ZombieVillager.java
|
||||
index 1ca0514732916d325c4a76d73120aaf613c3f780..750f63e337661b5448d0d863ab4dc99398fd5655 100644
|
||||
--- a/net/minecraft/world/entity/monster/ZombieVillager.java
|
||||
+++ b/net/minecraft/world/entity/monster/ZombieVillager.java
|
||||
@@ -99,6 +99,7 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder {
|
||||
@Override
|
||||
public void initAttributes() {
|
||||
this.getAttribute(net.minecraft.world.entity.ai.attributes.Attributes.MAX_HEALTH).setBaseValue(this.level().purpurConfig.zombieVillagerMaxHealth);
|
||||
@@ -69,46 +61,40 @@ index 6f6b32bf7f68d05e4173c31f2e631a409b858a05..160fcd1f8917d69dde01089111661337
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/ZombifiedPiglin.java b/src/main/java/net/minecraft/world/entity/monster/ZombifiedPiglin.java
|
||||
index 8c3271dcc8c9aa58e2e007eba282c11e42b4e0c9..8afc2234a179840308ad371296d6f3247c80f3ae 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/ZombifiedPiglin.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/ZombifiedPiglin.java
|
||||
@@ -84,6 +84,7 @@ public class ZombifiedPiglin extends Zombie implements NeutralMob {
|
||||
diff --git a/net/minecraft/world/entity/monster/ZombifiedPiglin.java b/net/minecraft/world/entity/monster/ZombifiedPiglin.java
|
||||
index fddbbffafea275dad187b7908386cf4c05c86743..10eac072872b9e61c25d368d19e86b18bc3d19e7 100644
|
||||
--- a/net/minecraft/world/entity/monster/ZombifiedPiglin.java
|
||||
+++ b/net/minecraft/world/entity/monster/ZombifiedPiglin.java
|
||||
@@ -85,6 +85,7 @@ public class ZombifiedPiglin extends Zombie implements NeutralMob {
|
||||
public void initAttributes() {
|
||||
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(this.level().purpurConfig.zombifiedPiglinMaxHealth);
|
||||
this.getAttribute(Attributes.SCALE).setBaseValue(this.level().purpurConfig.zombifiedPiglinScale);
|
||||
+ this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(this.level().purpurConfig.zombifiedPiglinMovementSpeed); // Leaf - Configurable zombifiedPiglin movement speed
|
||||
}
|
||||
// Purpur end - Configurable entity base attributes
|
||||
|
||||
@Override
|
||||
@@ -125,9 +126,13 @@ public class ZombifiedPiglin extends Zombie implements NeutralMob {
|
||||
this.targetSelector.addGoal(3, new ResetUniversalAngerTargetGoal<>(this, true));
|
||||
}
|
||||
|
||||
+ // Leaf start - Configurable zombieVillager movement speed
|
||||
@@ -136,7 +137,7 @@ public class ZombifiedPiglin extends Zombie implements NeutralMob {
|
||||
public static AttributeSupplier.Builder createAttributes() {
|
||||
- return Zombie.createAttributes().add(Attributes.SPAWN_REINFORCEMENTS_CHANCE, 0.0D).add(Attributes.MOVEMENT_SPEED, 0.23000000417232513D).add(Attributes.ATTACK_DAMAGE, 5.0D);
|
||||
+ return Zombie.createAttributes()
|
||||
+ .add(Attributes.SPAWN_REINFORCEMENTS_CHANCE, 0.0D)
|
||||
+ .add(Attributes.ATTACK_DAMAGE, 5.0D);
|
||||
return Zombie.createAttributes()
|
||||
.add(Attributes.SPAWN_REINFORCEMENTS_CHANCE, 0.0)
|
||||
- .add(Attributes.MOVEMENT_SPEED, 0.23F)
|
||||
+ //.add(Attributes.MOVEMENT_SPEED, 0.23F) // Leaf - Configurable zombie movement speed
|
||||
.add(Attributes.ATTACK_DAMAGE, 5.0);
|
||||
}
|
||||
+ // Leaf end
|
||||
|
||||
@Override
|
||||
public EntityDimensions getDefaultDimensions(Pose pose) {
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
index 36b875a1cb10f1704e8530b6eb7b7e9dc51ef995..8c9a6084f09f644bf22ac98edac797eea753277f 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
@@ -1554,6 +1554,7 @@ public class PurpurWorldConfig {
|
||||
diff --git a/org/purpurmc/purpur/PurpurWorldConfig.java b/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
index 2aac26f50958d8653eb1472daa7761d36093cf4c..fd5a5b9cb9958e96ecfeb4846e290c756265b300 100644
|
||||
--- a/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
+++ b/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
@@ -1563,6 +1563,7 @@ public class PurpurWorldConfig {
|
||||
public boolean drownedTakeDamageFromWater = false;
|
||||
public boolean drownedBreakDoors = false;
|
||||
public boolean drownedAlwaysDropExp = false;
|
||||
+ public double drownedMovementSpeed = 0.23000000417232513D; // Leaf - Configurable drowned movement speed
|
||||
+ public double drownedMovementSpeed = 0.23F; // Leaf - Configurable drowned movement speed
|
||||
private void drownedSettings() {
|
||||
drownedRidable = getBoolean("mobs.drowned.ridable", drownedRidable);
|
||||
drownedRidableInWater = getBoolean("mobs.drowned.ridable-in-water", drownedRidableInWater);
|
||||
@@ -1572,6 +1573,7 @@ public class PurpurWorldConfig {
|
||||
@@ -1581,6 +1582,7 @@ public class PurpurWorldConfig {
|
||||
drownedTakeDamageFromWater = getBoolean("mobs.drowned.takes-damage-from-water", drownedTakeDamageFromWater);
|
||||
drownedBreakDoors = getBoolean("mobs.drowned.can-break-doors", drownedBreakDoors);
|
||||
drownedAlwaysDropExp = getBoolean("mobs.drowned.always-drop-exp", drownedAlwaysDropExp);
|
||||
@@ -116,15 +102,15 @@ index 36b875a1cb10f1704e8530b6eb7b7e9dc51ef995..8c9a6084f09f644bf22ac98edac797ee
|
||||
}
|
||||
|
||||
public boolean elderGuardianRidable = false;
|
||||
@@ -1946,6 +1948,7 @@ public class PurpurWorldConfig {
|
||||
@@ -1955,6 +1957,7 @@ public class PurpurWorldConfig {
|
||||
public boolean huskJockeyTryExistingChickens = true;
|
||||
public boolean huskTakeDamageFromWater = false;
|
||||
public boolean huskAlwaysDropExp = false;
|
||||
+ public double huskMovementSpeed = 0.23000000417232513D; // Leaf - Configurable husk movement speed
|
||||
+ public double huskMovementSpeed = 0.23F; // Leaf - Configurable husk movement speed
|
||||
private void huskSettings() {
|
||||
huskRidable = getBoolean("mobs.husk.ridable", huskRidable);
|
||||
huskRidableInWater = getBoolean("mobs.husk.ridable-in-water", huskRidableInWater);
|
||||
@@ -1963,6 +1966,7 @@ public class PurpurWorldConfig {
|
||||
@@ -1972,6 +1975,7 @@ public class PurpurWorldConfig {
|
||||
huskJockeyTryExistingChickens = getBoolean("mobs.husk.jockey.try-existing-chickens", huskJockeyTryExistingChickens);
|
||||
huskTakeDamageFromWater = getBoolean("mobs.husk.takes-damage-from-water", huskTakeDamageFromWater);
|
||||
huskAlwaysDropExp = getBoolean("mobs.husk.always-drop-exp", huskAlwaysDropExp);
|
||||
@@ -132,15 +118,15 @@ index 36b875a1cb10f1704e8530b6eb7b7e9dc51ef995..8c9a6084f09f644bf22ac98edac797ee
|
||||
}
|
||||
|
||||
public boolean illusionerRidable = false;
|
||||
@@ -3260,6 +3264,7 @@ public class PurpurWorldConfig {
|
||||
@@ -3269,6 +3273,7 @@ public class PurpurWorldConfig {
|
||||
public boolean zombieTakeDamageFromWater = false;
|
||||
public boolean zombieAlwaysDropExp = false;
|
||||
public double zombieHeadVisibilityPercent = 0.5D;
|
||||
+ public double zombieMovementSpeed = 0.23000000417232513D; // Leaf - Configurable zombie movement speed
|
||||
+ public double zombieMovementSpeed = 0.23F; // Leaf - Configurable zombie movement speed
|
||||
private void zombieSettings() {
|
||||
zombieRidable = getBoolean("mobs.zombie.ridable", zombieRidable);
|
||||
zombieRidableInWater = getBoolean("mobs.zombie.ridable-in-water", zombieRidableInWater);
|
||||
@@ -3280,6 +3285,7 @@ public class PurpurWorldConfig {
|
||||
@@ -3289,6 +3294,7 @@ public class PurpurWorldConfig {
|
||||
zombieTakeDamageFromWater = getBoolean("mobs.zombie.takes-damage-from-water", zombieTakeDamageFromWater);
|
||||
zombieAlwaysDropExp = getBoolean("mobs.zombie.always-drop-exp", zombieAlwaysDropExp);
|
||||
zombieHeadVisibilityPercent = getDouble("mobs.zombie.head-visibility-percent", zombieHeadVisibilityPercent);
|
||||
@@ -148,15 +134,15 @@ index 36b875a1cb10f1704e8530b6eb7b7e9dc51ef995..8c9a6084f09f644bf22ac98edac797ee
|
||||
}
|
||||
|
||||
public boolean zombieHorseRidable = false;
|
||||
@@ -3329,6 +3335,7 @@ public class PurpurWorldConfig {
|
||||
@@ -3338,6 +3344,7 @@ public class PurpurWorldConfig {
|
||||
public int zombieVillagerCuringTimeMax = 6000;
|
||||
public boolean zombieVillagerCureEnabled = true;
|
||||
public boolean zombieVillagerAlwaysDropExp = false;
|
||||
+ public double zombieVillagerMovementSpeed = 0.23000000417232513D; // Leaf - Configurable zombieVillager movement speed
|
||||
+ public double zombieVillagerMovementSpeed = 0.23F; // Leaf - Configurable zombieVillager movement speed
|
||||
private void zombieVillagerSettings() {
|
||||
zombieVillagerRidable = getBoolean("mobs.zombie_villager.ridable", zombieVillagerRidable);
|
||||
zombieVillagerRidableInWater = getBoolean("mobs.zombie_villager.ridable-in-water", zombieVillagerRidableInWater);
|
||||
@@ -3349,6 +3356,7 @@ public class PurpurWorldConfig {
|
||||
@@ -3358,6 +3365,7 @@ public class PurpurWorldConfig {
|
||||
zombieVillagerCuringTimeMax = getInt("mobs.zombie_villager.curing_time.max", zombieVillagerCuringTimeMax);
|
||||
zombieVillagerCureEnabled = getBoolean("mobs.zombie_villager.cure.enabled", zombieVillagerCureEnabled);
|
||||
zombieVillagerAlwaysDropExp = getBoolean("mobs.zombie_villager.always-drop-exp", zombieVillagerAlwaysDropExp);
|
||||
@@ -164,15 +150,15 @@ index 36b875a1cb10f1704e8530b6eb7b7e9dc51ef995..8c9a6084f09f644bf22ac98edac797ee
|
||||
}
|
||||
|
||||
public boolean zombifiedPiglinRidable = false;
|
||||
@@ -3363,6 +3371,7 @@ public class PurpurWorldConfig {
|
||||
@@ -3372,6 +3380,7 @@ public class PurpurWorldConfig {
|
||||
public boolean zombifiedPiglinCountAsPlayerKillWhenAngry = true;
|
||||
public boolean zombifiedPiglinTakeDamageFromWater = false;
|
||||
public boolean zombifiedPiglinAlwaysDropExp = false;
|
||||
+ public double zombifiedPiglinMovementSpeed = 0.23000000417232513D; // Leaf - Configurable zombifiedPiglin movement speed
|
||||
+ public double zombifiedPiglinMovementSpeed = 0.23F; // Leaf - Configurable zombifiedPiglin movement speed
|
||||
private void zombifiedPiglinSettings() {
|
||||
zombifiedPiglinRidable = getBoolean("mobs.zombified_piglin.ridable", zombifiedPiglinRidable);
|
||||
zombifiedPiglinRidableInWater = getBoolean("mobs.zombified_piglin.ridable-in-water", zombifiedPiglinRidableInWater);
|
||||
@@ -3381,6 +3390,7 @@ public class PurpurWorldConfig {
|
||||
@@ -3390,6 +3399,7 @@ public class PurpurWorldConfig {
|
||||
zombifiedPiglinCountAsPlayerKillWhenAngry = getBoolean("mobs.zombified_piglin.count-as-player-kill-when-angry", zombifiedPiglinCountAsPlayerKillWhenAngry);
|
||||
zombifiedPiglinTakeDamageFromWater = getBoolean("mobs.zombified_piglin.takes-damage-from-water", zombifiedPiglinTakeDamageFromWater);
|
||||
zombifiedPiglinAlwaysDropExp = getBoolean("mobs.zombified_piglin.always-drop-exp", zombifiedPiglinAlwaysDropExp);
|
||||
@@ -0,0 +1,83 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Tue, 2 Jan 2024 21:13:53 -0500
|
||||
Subject: [PATCH] Faster sequencing of futures for chunk structure gen
|
||||
|
||||
Replace `thenApply` with `thenCompose`. Once one task is completed then the next task starts immediately,
|
||||
to prevent blocking threads while waiting to complete all tasks. But may cause the sequence of future compose disorder.
|
||||
|
||||
diff --git a/net/minecraft/Util.java b/net/minecraft/Util.java
|
||||
index 80a7a85e1a03a1ca406259207e1ae3b909b3284f..ad41d6d5723d1194344fd9c5a9151356be8bb602 100644
|
||||
--- a/net/minecraft/Util.java
|
||||
+++ b/net/minecraft/Util.java
|
||||
@@ -607,17 +607,44 @@ public class Util {
|
||||
return map;
|
||||
}
|
||||
|
||||
+ // Leaf start - Faster sequencing of futures for chunk structure gen
|
||||
public static <V> CompletableFuture<List<V>> sequence(List<? extends CompletableFuture<V>> futures) {
|
||||
+ return sequence(futures, false);
|
||||
+ }
|
||||
+ public static <V> CompletableFuture<List<V>> sequence(List<? extends CompletableFuture<V>> futures, boolean useFaster) {
|
||||
+ // Leaf end - Faster sequencing of futures for chunk structure gen
|
||||
if (futures.isEmpty()) {
|
||||
return CompletableFuture.completedFuture(List.of());
|
||||
} else if (futures.size() == 1) {
|
||||
return futures.get(0).thenApply(List::of);
|
||||
} else {
|
||||
CompletableFuture<Void> completableFuture = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
|
||||
+ // Leaf start - Faster sequencing of futures for chunk structure gen
|
||||
+ if (org.dreeam.leaf.config.modules.opt.FasterStructureGenFutureSequencing.enabled && useFaster) {
|
||||
+ return sequenceFaster(futures, completableFuture);
|
||||
+ }
|
||||
+ // Leaf end - Faster sequencing of futures for chunk structure gen
|
||||
+
|
||||
return completableFuture.thenApply(_void -> futures.stream().map(CompletableFuture::join).toList());
|
||||
}
|
||||
}
|
||||
|
||||
+ // Leaf start - Faster sequencing of futures for chunk structure gen
|
||||
+ private static <V> CompletableFuture<List<V>> sequenceFaster(List<? extends CompletableFuture<V>> futures, CompletableFuture<Void> completableFuture) {
|
||||
+ return completableFuture.thenCompose(void_ ->
|
||||
+ CompletableFuture.supplyAsync(() -> {
|
||||
+ List<V> list = new java.util.ArrayList<>();
|
||||
+
|
||||
+ for (CompletableFuture<V> future : futures) {
|
||||
+ list.add(future.join());
|
||||
+ }
|
||||
+
|
||||
+ return list;
|
||||
+ }
|
||||
+ ));
|
||||
+ }
|
||||
+ // Leaf end - Faster sequencing of futures for chunk structure gen
|
||||
+
|
||||
public static <V> CompletableFuture<List<V>> sequenceFailFast(List<? extends CompletableFuture<? extends V>> completableFutures) {
|
||||
CompletableFuture<List<V>> completableFuture = new CompletableFuture<>();
|
||||
return fallibleSequence(completableFutures, completableFuture::completeExceptionally).applyToEither(completableFuture, Function.identity());
|
||||
diff --git a/net/minecraft/server/ReloadableServerRegistries.java b/net/minecraft/server/ReloadableServerRegistries.java
|
||||
index d8c472b8c6aadcaadef14abd8ab43f466e94417e..bc079b6c3d751f2a63d089bf209cf7d8e0da76e8 100644
|
||||
--- a/net/minecraft/server/ReloadableServerRegistries.java
|
||||
+++ b/net/minecraft/server/ReloadableServerRegistries.java
|
||||
@@ -52,7 +52,7 @@ public class ReloadableServerRegistries {
|
||||
List<CompletableFuture<WritableRegistry<?>>> list1 = LootDataType.values()
|
||||
.map(lootDataType -> scheduleRegistryLoad((LootDataType<?>)lootDataType, registryOps, resourceManager, backgroundExecutor, conversions)) // Paper
|
||||
.toList();
|
||||
- CompletableFuture<List<WritableRegistry<?>>> completableFuture = Util.sequence(list1);
|
||||
+ CompletableFuture<List<WritableRegistry<?>>> completableFuture = Util.sequence(list1, false); // Leaf - Faster sequencing of futures for chunk structure gen
|
||||
return completableFuture.thenApplyAsync(
|
||||
list2 -> createAndValidateFullContext(registryAccess, provider, (List<WritableRegistry<?>>)list2), backgroundExecutor
|
||||
);
|
||||
diff --git a/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java b/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
||||
index 619b98e42e254c0c260c171a26a2472ddf59b885..4483d7764ddca635fb6fb841fdc2185357106fc5 100644
|
||||
--- a/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
||||
+++ b/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
||||
@@ -255,7 +255,7 @@ public class ChunkGeneratorStructureState {
|
||||
}
|
||||
}
|
||||
|
||||
- return Util.sequence(list).thenApply(completed -> {
|
||||
+ return Util.sequence(list, true).thenApply(completed -> { // Leaf - Faster sequencing of futures for chunk structure gen
|
||||
double d2 = stopwatch.stop().elapsed(TimeUnit.MILLISECONDS) / 1000.0;
|
||||
LOGGER.debug("Calculation for {} took {}s", structureSet, d2);
|
||||
return completed;
|
||||
@@ -0,0 +1,25 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Mon, 15 Jan 2024 10:53:10 -0500
|
||||
Subject: [PATCH] Reduce items finding hopper nearby check
|
||||
|
||||
This patch add a toggle for items checking MinecraftHopper nearby,
|
||||
|
||||
But still recommend to turn-off `checkForMinecartNearItemWhileActive`
|
||||
Since `Reduce-hopper-item-checks.patch` will cause lag under massive dropped items
|
||||
|
||||
diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java
|
||||
index 0e21c644d62597cf3425c8717ab1e70c766e22f2..6287f5d84f961968b82d350c3d15b587e8d19236 100644
|
||||
--- a/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -241,7 +241,9 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
||||
this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
return; // Gale - EMC - reduce hopper item checks
|
||||
}
|
||||
- this.markNearbyHopperCartsAsImmune(); // Gale - EMC - reduce hopper item checks
|
||||
+ if (level().galeConfig().smallOptimizations.reducedIntervals.checkNearbyItem.hopper.minecart.temporaryImmunity.checkForMinecartNearItemWhileActive) { // Leaf - Reduce items finding hopper nearby check
|
||||
+ this.markNearbyHopperCartsAsImmune(); // Gale - EMC - reduce hopper item checks
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,368 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
Date: Sun, 30 Jun 2024 00:35:19 +0800
|
||||
Subject: [PATCH] Linear region file format
|
||||
|
||||
Original license: MIT
|
||||
Original project: https://github.com/LuminolMC/Luminol
|
||||
|
||||
Linear is a region file format that uses ZSTD compression instead of
|
||||
ZLIB.
|
||||
This format saves about 50% of disk space.
|
||||
Documentation: https://github.com/xymb-endcrystalme/LinearRegionFileFormatTools
|
||||
|
||||
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/io/ChunkSystemRegionFileStorage.java b/ca/spottedleaf/moonrise/patches/chunk_system/io/ChunkSystemRegionFileStorage.java
|
||||
index a814512fcfb85312474ae2c2c21443843bf57831..f80c75c561313625b694b433692aa429b8f8fde9 100644
|
||||
--- a/ca/spottedleaf/moonrise/patches/chunk_system/io/ChunkSystemRegionFileStorage.java
|
||||
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/io/ChunkSystemRegionFileStorage.java
|
||||
@@ -8,9 +8,9 @@ public interface ChunkSystemRegionFileStorage {
|
||||
|
||||
public boolean moonrise$doesRegionFileNotExistNoIO(final int chunkX, final int chunkZ);
|
||||
|
||||
- public RegionFile moonrise$getRegionFileIfLoaded(final int chunkX, final int chunkZ);
|
||||
+ public org.stupidcraft.linearpaper.region.IRegionFile moonrise$getRegionFileIfLoaded(final int chunkX, final int chunkZ); // LinearPaper
|
||||
|
||||
- public RegionFile moonrise$getRegionFileIfExists(final int chunkX, final int chunkZ) throws IOException;
|
||||
+ public org.stupidcraft.linearpaper.region.IRegionFile moonrise$getRegionFileIfExists(final int chunkX, final int chunkZ) throws IOException; // LinearPaper
|
||||
|
||||
public MoonriseRegionFileIO.RegionDataController.WriteData moonrise$startWrite(
|
||||
final int chunkX, final int chunkZ, final CompoundTag compound
|
||||
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/io/MoonriseRegionFileIO.java b/ca/spottedleaf/moonrise/patches/chunk_system/io/MoonriseRegionFileIO.java
|
||||
index 1acea58838f057ab87efd103cbecb6f5aeaef393..48a6d8b534943393c26180fbf341b77bd2d5bc48 100644
|
||||
--- a/ca/spottedleaf/moonrise/patches/chunk_system/io/MoonriseRegionFileIO.java
|
||||
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/io/MoonriseRegionFileIO.java
|
||||
@@ -1462,7 +1462,7 @@ public final class MoonriseRegionFileIO {
|
||||
|
||||
public static interface IORunnable {
|
||||
|
||||
- public void run(final RegionFile regionFile) throws IOException;
|
||||
+ public void run(final org.stupidcraft.linearpaper.region.IRegionFile regionFile) throws IOException; // LinearPaper
|
||||
|
||||
}
|
||||
}
|
||||
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemChunkBuffer.java b/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemChunkBuffer.java
|
||||
index 51c126735ace8fdde89ad97b5cab62f244212db0..4046f0aaa153e00277bf14f009fbe14aa8859fec 100644
|
||||
--- a/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemChunkBuffer.java
|
||||
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemChunkBuffer.java
|
||||
@@ -8,5 +8,5 @@ public interface ChunkSystemChunkBuffer {
|
||||
|
||||
public void moonrise$setWriteOnClose(final boolean value);
|
||||
|
||||
- public void moonrise$write(final RegionFile regionFile) throws IOException;
|
||||
+ public void moonrise$write(final org.stupidcraft.linearpaper.region.IRegionFile regionFile) throws IOException; // LinearPaper
|
||||
}
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 449cfd4f6282f28d7470403c0063874b906a6003..742835ecfa0cba6dc3114dbe584409183ade9228 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -941,10 +941,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
// CraftBukkit end
|
||||
if (flush) {
|
||||
for (ServerLevel serverLevel2 : this.getAllLevels()) {
|
||||
- LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", serverLevel2.getChunkSource().chunkMap.getStorageName());
|
||||
+ LOGGER.info("ThreadedChunkStorage ({}): All chunks are saved", serverLevel2.getChunkSource().chunkMap.getStorageName()); // LinearPaper
|
||||
}
|
||||
|
||||
- LOGGER.info("ThreadedAnvilChunkStorage: All dimensions are saved");
|
||||
+ LOGGER.info("ThreadedChunkStorage: All dimensions are saved"); // LinearPaper
|
||||
}
|
||||
|
||||
return flag;
|
||||
diff --git a/net/minecraft/util/worldupdate/WorldUpgrader.java b/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||
index e0bcda2ddea0d6633445a7440fbf0d18e50a7653..17cdff80683de3fc166cc38d27a9e80dd1fc8272 100644
|
||||
--- a/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||
+++ b/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||
@@ -72,7 +72,7 @@ public class WorldUpgrader implements AutoCloseable {
|
||||
volatile int skipped;
|
||||
final Reference2FloatMap<ResourceKey<Level>> progressMap = Reference2FloatMaps.synchronize(new Reference2FloatOpenHashMap<>());
|
||||
volatile Component status = Component.translatable("optimizeWorld.stage.counting");
|
||||
- static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
|
||||
+ static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.(linear | mca)$"); // LinearPaper
|
||||
final DimensionDataStorage overworldDataStorage;
|
||||
|
||||
public WorldUpgrader(
|
||||
@@ -261,7 +261,7 @@ public class WorldUpgrader implements AutoCloseable {
|
||||
}
|
||||
|
||||
private static List<WorldUpgrader.FileToUpgrade> getAllChunkPositions(RegionStorageInfo regionStorageInfo, Path path) {
|
||||
- File[] files = path.toFile().listFiles((directory, filename) -> filename.endsWith(".mca"));
|
||||
+ File[] files = path.toFile().listFiles((directory, filename) -> filename.endsWith(".linear") || filename.endsWith(".mca")); // LinearPaper
|
||||
if (files == null) {
|
||||
return List.of();
|
||||
} else {
|
||||
@@ -274,7 +274,7 @@ public class WorldUpgrader implements AutoCloseable {
|
||||
int i1 = Integer.parseInt(matcher.group(2)) << 5;
|
||||
List<ChunkPos> list1 = Lists.newArrayList();
|
||||
|
||||
- try (RegionFile regionFile = new RegionFile(regionStorageInfo, file.toPath(), path, true)) {
|
||||
+ try (org.stupidcraft.linearpaper.region.IRegionFile regionFile = org.stupidcraft.linearpaper.region.IRegionFileFactory.getAbstractRegionFile(regionStorageInfo, file.toPath(), path, true)) { // LinearPaper
|
||||
for (int i2 = 0; i2 < 32; i2++) {
|
||||
for (int i3 = 0; i3 < 32; i3++) {
|
||||
ChunkPos chunkPos = new ChunkPos(i2 + i, i3 + i1);
|
||||
@@ -322,7 +322,7 @@ public class WorldUpgrader implements AutoCloseable {
|
||||
|
||||
protected abstract boolean tryProcessOnePosition(T chunkStorage, ChunkPos chunkPos, ResourceKey<Level> dimension);
|
||||
|
||||
- private void onFileFinished(RegionFile regionFile) {
|
||||
+ private void onFileFinished(org.stupidcraft.linearpaper.region.IRegionFile regionFile) { // LinearPaper
|
||||
if (WorldUpgrader.this.recreateRegionFiles) {
|
||||
if (this.previousWriteFuture != null) {
|
||||
this.previousWriteFuture.join();
|
||||
@@ -424,7 +424,7 @@ public class WorldUpgrader implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
- record FileToUpgrade(RegionFile file, List<ChunkPos> chunksToUpgrade) {
|
||||
+ record FileToUpgrade(org.stupidcraft.linearpaper.region.IRegionFile file, List<ChunkPos> chunksToUpgrade) { // LinearPaper
|
||||
}
|
||||
|
||||
class PoiUpgrader extends WorldUpgrader.SimpleRegionStorageUpgrader {
|
||||
diff --git a/net/minecraft/world/level/chunk/storage/RegionFile.java b/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
index 231d1905092532acf7e632197ba0e727adc4b1d7..dac802a8c70ff8ab96c000a48e1c5e1095ef7a79 100644
|
||||
--- a/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
+++ b/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
@@ -22,7 +22,7 @@ import net.minecraft.util.profiling.jfr.JvmProfiler;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
-public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemRegionFile { // Paper - rewrite chunk system
|
||||
+public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemRegionFile, org.stupidcraft.linearpaper.region.IRegionFile { // Paper - rewrite chunk system // LinearPaper
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
public static final int MAX_CHUNK_SIZE = 500 * 1024 * 1024; // Paper - don't write garbage data to disk if writing serialization fails
|
||||
private static final int SECTOR_BYTES = 4096;
|
||||
@@ -124,7 +124,7 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche
|
||||
}
|
||||
|
||||
// note: only call for CHUNK regionfiles
|
||||
- boolean recalculateHeader() throws IOException {
|
||||
+ public boolean recalculateHeader() throws IOException { // LinearPaper - make public
|
||||
if (!this.canRecalcHeader) {
|
||||
return false;
|
||||
}
|
||||
@@ -786,7 +786,7 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche
|
||||
}
|
||||
}
|
||||
|
||||
- protected synchronized void write(ChunkPos chunkPos, ByteBuffer chunkData) throws IOException {
|
||||
+ public synchronized void write(ChunkPos chunkPos, ByteBuffer chunkData) throws IOException { // LinearPaper - protected -> public
|
||||
int offsetIndex = getOffsetIndex(chunkPos);
|
||||
int i = this.offsets.get(offsetIndex);
|
||||
int sectorNumber = getSectorNumber(i);
|
||||
@@ -904,7 +904,7 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche
|
||||
}
|
||||
|
||||
@Override
|
||||
- public final void moonrise$write(final RegionFile regionFile) throws IOException {
|
||||
+ public final void moonrise$write(final org.stupidcraft.linearpaper.region.IRegionFile regionFile) throws IOException { // LinearPaper
|
||||
regionFile.write(this.pos, ByteBuffer.wrap(this.buf, 0, this.count));
|
||||
}
|
||||
// Paper end - rewrite chunk system
|
||||
@@ -970,11 +970,11 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche
|
||||
return (x & 31) + (z & 31) * 32;
|
||||
}
|
||||
|
||||
- synchronized boolean isOversized(int x, int z) {
|
||||
+ public synchronized boolean isOversized(int x, int z) { // LinearPaper - make public
|
||||
return this.oversized[getChunkIndex(x, z)] == 1;
|
||||
}
|
||||
|
||||
- synchronized void setOversized(int x, int z, boolean oversized) throws IOException {
|
||||
+ public synchronized void setOversized(int x, int z, boolean oversized) throws IOException { // LinearPaper - make public
|
||||
final int offset = getChunkIndex(x, z);
|
||||
boolean previous = this.oversized[offset] == 1;
|
||||
this.oversized[offset] = (byte) (oversized ? 1 : 0);
|
||||
@@ -1013,7 +1013,7 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche
|
||||
return this.path.getParent().resolve(this.path.getFileName().toString().replaceAll("\\.mca$", "") + "_oversized_" + x + "_" + z + ".nbt");
|
||||
}
|
||||
|
||||
- synchronized net.minecraft.nbt.CompoundTag getOversizedData(int x, int z) throws IOException {
|
||||
+ public synchronized net.minecraft.nbt.CompoundTag getOversizedData(int x, int z) throws IOException { // LinearPaper - make public
|
||||
Path file = getOversizedFile(x, z);
|
||||
try (DataInputStream out = new DataInputStream(new java.io.BufferedInputStream(new java.util.zip.InflaterInputStream(Files.newInputStream(file))))) {
|
||||
return net.minecraft.nbt.NbtIo.read((java.io.DataInput) out);
|
||||
diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
index 7fff86a4956f59b2f4a9f7e283256879c034c1b8..58d9840d2557fbb9b357bf4e3d5ad19ef40d73c9 100644
|
||||
--- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
+++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
@@ -18,7 +18,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger(); // Paper
|
||||
public static final String ANVIL_EXTENSION = ".mca";
|
||||
private static final int MAX_CACHE_SIZE = 256;
|
||||
- public final Long2ObjectLinkedOpenHashMap<RegionFile> regionCache = new Long2ObjectLinkedOpenHashMap<>();
|
||||
+ public final Long2ObjectLinkedOpenHashMap<org.stupidcraft.linearpaper.region.IRegionFile> regionCache = new Long2ObjectLinkedOpenHashMap<>(); // LinearPaper
|
||||
private final RegionStorageInfo info;
|
||||
private final Path folder;
|
||||
private final boolean sync;
|
||||
@@ -33,7 +33,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
@Nullable
|
||||
public static ChunkPos getRegionFileCoordinates(Path file) {
|
||||
String fileName = file.getFileName().toString();
|
||||
- if (!fileName.startsWith("r.") || !fileName.endsWith(".mca")) {
|
||||
+ if (!fileName.startsWith("r.") || !fileName.endsWith(".mca") || !fileName.endsWith(".linear")) { // LinearPaper
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,11 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
private static final int REGION_SHIFT = 5;
|
||||
private static final int MAX_NON_EXISTING_CACHE = 1024 * 4;
|
||||
private final it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet nonExistingRegionFiles = new it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet();
|
||||
+ // Leaf start - Linear region format
|
||||
private static String getRegionFileName(final int chunkX, final int chunkZ) {
|
||||
+ if (org.dreeam.leaf.config.modules.misc.RegionFormatConfig.regionFormatType == org.stupidcraft.linearpaper.region.EnumRegionFileExtension.LINEAR) {
|
||||
+ return "r." + (chunkX >> REGION_SHIFT) + "." + (chunkZ >> REGION_SHIFT) + ".linear";
|
||||
+ }
|
||||
return "r." + (chunkX >> REGION_SHIFT) + "." + (chunkZ >> REGION_SHIFT) + ".mca";
|
||||
}
|
||||
|
||||
@@ -93,15 +97,15 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
}
|
||||
|
||||
@Override
|
||||
- public synchronized final RegionFile moonrise$getRegionFileIfLoaded(final int chunkX, final int chunkZ) {
|
||||
+ public synchronized final org.stupidcraft.linearpaper.region.IRegionFile moonrise$getRegionFileIfLoaded(final int chunkX, final int chunkZ) { // LinearPaper
|
||||
return this.regionCache.getAndMoveToFirst(ChunkPos.asLong(chunkX >> REGION_SHIFT, chunkZ >> REGION_SHIFT));
|
||||
}
|
||||
|
||||
@Override
|
||||
- public synchronized final RegionFile moonrise$getRegionFileIfExists(final int chunkX, final int chunkZ) throws IOException {
|
||||
+ public synchronized final org.stupidcraft.linearpaper.region.IRegionFile moonrise$getRegionFileIfExists(final int chunkX, final int chunkZ) throws IOException { // LinearPaper
|
||||
final long key = ChunkPos.asLong(chunkX >> REGION_SHIFT, chunkZ >> REGION_SHIFT);
|
||||
|
||||
- RegionFile ret = this.regionCache.getAndMoveToFirst(key);
|
||||
+ org.stupidcraft.linearpaper.region.IRegionFile ret = this.regionCache.getAndMoveToFirst(key); // LinearPaper
|
||||
if (ret != null) {
|
||||
return ret;
|
||||
}
|
||||
@@ -125,7 +129,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
|
||||
FileUtil.createDirectoriesSafe(this.folder);
|
||||
|
||||
- ret = new RegionFile(this.info, regionPath, this.folder, this.sync);
|
||||
+ ret = org.stupidcraft.linearpaper.region.IRegionFileFactory.getAbstractRegionFile(this.info, regionPath, this.folder, this.sync); // LinearPaper
|
||||
|
||||
this.regionCache.putAndMoveToFirst(key, ret);
|
||||
|
||||
@@ -144,7 +148,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
}
|
||||
|
||||
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
|
||||
- final RegionFile regionFile = this.getRegionFile(pos);
|
||||
+ final org.stupidcraft.linearpaper.region.IRegionFile regionFile = this.getRegionFile(pos); // LinearPaper
|
||||
|
||||
// note: not required to keep regionfile loaded after this call, as the write param takes a regionfile as input
|
||||
// (and, the regionfile parameter is unused for writing until the write call)
|
||||
@@ -178,7 +182,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
) throws IOException {
|
||||
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
|
||||
if (writeData.result() == ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.WriteData.WriteResult.DELETE) {
|
||||
- final RegionFile regionFile = this.moonrise$getRegionFileIfExists(chunkX, chunkZ);
|
||||
+ final org.stupidcraft.linearpaper.region.IRegionFile regionFile = this.moonrise$getRegionFileIfExists(chunkX, chunkZ); // LinearPaper
|
||||
if (regionFile != null) {
|
||||
regionFile.clear(pos);
|
||||
} // else: didn't exist
|
||||
@@ -193,7 +197,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
public final ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.ReadData moonrise$readData(
|
||||
final int chunkX, final int chunkZ
|
||||
) throws IOException {
|
||||
- final RegionFile regionFile = this.moonrise$getRegionFileIfExists(chunkX, chunkZ);
|
||||
+ final org.stupidcraft.linearpaper.region.IRegionFile regionFile = this.moonrise$getRegionFileIfExists(chunkX, chunkZ); // LinearPaper
|
||||
|
||||
final DataInputStream input = regionFile == null ? null : regionFile.getChunkDataInputStream(new ChunkPos(chunkX, chunkZ));
|
||||
|
||||
@@ -237,7 +241,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
}
|
||||
// Paper end - rewrite chunk system
|
||||
// Paper start - rewrite chunk system
|
||||
- public RegionFile getRegionFile(ChunkPos chunkcoordintpair) throws IOException {
|
||||
+ public org.stupidcraft.linearpaper.region.IRegionFile getRegionFile(ChunkPos chunkcoordintpair) throws IOException { // LinearPaper
|
||||
return this.getRegionFile(chunkcoordintpair, false);
|
||||
}
|
||||
// Paper end - rewrite chunk system
|
||||
@@ -249,7 +253,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
this.isChunkData = isChunkDataFolder(this.folder); // Paper - recalculate region file headers
|
||||
}
|
||||
|
||||
- @org.jetbrains.annotations.Contract("_, false -> !null") @Nullable private RegionFile getRegionFile(ChunkPos chunkPos, boolean existingOnly) throws IOException { // CraftBukkit
|
||||
+ @org.jetbrains.annotations.Contract("_, false -> !null") @Nullable private org.stupidcraft.linearpaper.region.IRegionFile getRegionFile(ChunkPos chunkPos, boolean existingOnly) throws IOException { // CraftBukkit // LinearPaper
|
||||
// Paper start - rewrite chunk system
|
||||
if (existingOnly) {
|
||||
return this.moonrise$getRegionFileIfExists(chunkPos.x, chunkPos.z);
|
||||
@@ -257,7 +261,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
synchronized (this) {
|
||||
final long key = ChunkPos.asLong(chunkPos.x >> REGION_SHIFT, chunkPos.z >> REGION_SHIFT);
|
||||
|
||||
- RegionFile ret = this.regionCache.getAndMoveToFirst(key);
|
||||
+ org.stupidcraft.linearpaper.region.IRegionFile ret = this.regionCache.getAndMoveToFirst(key); // LinearPaper
|
||||
if (ret != null) {
|
||||
return ret;
|
||||
}
|
||||
@@ -266,13 +270,13 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
this.regionCache.removeLast().close();
|
||||
}
|
||||
|
||||
- final Path regionPath = this.folder.resolve(getRegionFileName(chunkPos.x, chunkPos.z));
|
||||
+ final Path regionPath = this.folder.resolve(getRegionFileName(chunkPos.x, chunkPos.z)); // LinearPaper
|
||||
|
||||
this.createRegionFile(key);
|
||||
|
||||
FileUtil.createDirectoriesSafe(this.folder);
|
||||
|
||||
- ret = new RegionFile(this.info, regionPath, this.folder, this.sync);
|
||||
+ ret = org.stupidcraft.linearpaper.region.IRegionFileFactory.getAbstractRegionFile(this.info, regionPath, this.folder, this.sync); // LinearPaper
|
||||
|
||||
this.regionCache.putAndMoveToFirst(key, ret);
|
||||
|
||||
@@ -292,7 +296,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
// Gale end - branding changes
|
||||
}
|
||||
|
||||
- private static CompoundTag readOversizedChunk(RegionFile regionfile, ChunkPos chunkCoordinate) throws IOException {
|
||||
+ private static CompoundTag readOversizedChunk(org.stupidcraft.linearpaper.region.IRegionFile regionfile, ChunkPos chunkCoordinate) throws IOException { // LinearPaper
|
||||
synchronized (regionfile) {
|
||||
try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) {
|
||||
CompoundTag oversizedData = regionfile.getOversizedData(chunkCoordinate.x, chunkCoordinate.z);
|
||||
@@ -327,7 +331,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
@Nullable
|
||||
public CompoundTag read(ChunkPos chunkPos) throws IOException {
|
||||
// CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
|
||||
- RegionFile regionFile = this.getRegionFile(chunkPos, true);
|
||||
+ org.stupidcraft.linearpaper.region.IRegionFile regionFile = this.getRegionFile(chunkPos, true); // LinearPaper
|
||||
if (regionFile == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -366,7 +370,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
|
||||
public void scanChunk(ChunkPos chunkPos, StreamTagVisitor visitor) throws IOException {
|
||||
// CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
|
||||
- RegionFile regionFile = this.getRegionFile(chunkPos, true);
|
||||
+ org.stupidcraft.linearpaper.region.IRegionFile regionFile = this.getRegionFile(chunkPos, true); // LinearPaper
|
||||
if (regionFile == null) {
|
||||
return;
|
||||
}
|
||||
@@ -380,7 +384,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
}
|
||||
|
||||
public void write(ChunkPos chunkPos, @Nullable CompoundTag chunkData) throws IOException { // Paper - rewrite chunk system - public
|
||||
- RegionFile regionFile = this.getRegionFile(chunkPos, chunkData == null); // CraftBukkit // Paper - rewrite chunk system
|
||||
+ org.stupidcraft.linearpaper.region.IRegionFile regionFile = this.getRegionFile(chunkPos, chunkData == null); // CraftBukkit // Paper - rewrite chunk system // LinearPaper
|
||||
// Paper start - rewrite chunk system
|
||||
if (regionFile == null) {
|
||||
// if the RegionFile doesn't exist, no point in deleting from it
|
||||
@@ -410,7 +414,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
// Paper start - rewrite chunk system
|
||||
synchronized (this) {
|
||||
final ExceptionCollector<IOException> exceptionCollector = new ExceptionCollector<>();
|
||||
- for (final RegionFile regionFile : this.regionCache.values()) {
|
||||
+ for (final org.stupidcraft.linearpaper.region.IRegionFile regionFile : this.regionCache.values()) { // LinearPaper
|
||||
try {
|
||||
regionFile.close();
|
||||
} catch (final IOException ex) {
|
||||
@@ -426,7 +430,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
// Paper start - rewrite chunk system
|
||||
synchronized (this) {
|
||||
final ExceptionCollector<IOException> exceptionCollector = new ExceptionCollector<>();
|
||||
- for (final RegionFile regionFile : this.regionCache.values()) {
|
||||
+ for (final org.stupidcraft.linearpaper.region.IRegionFile regionFile : this.regionCache.values()) { // LinearPaper
|
||||
try {
|
||||
regionFile.flush();
|
||||
} catch (final IOException ex) {
|
||||
@@ -0,0 +1,87 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AlphaKR93 <dev@alpha93.kr>
|
||||
Date: Wed, 27 Sep 2023 18:29:51 +0900
|
||||
Subject: [PATCH] Plazma: Add some missing Pufferfish configurations
|
||||
|
||||
Original license: MIT
|
||||
Original project: https://github.com/PlazmaMC/PlazmaBukkit
|
||||
|
||||
Add Pufferfish DAB support for Camel, Sniffer
|
||||
https://github.com/pufferfish-gg/Pufferfish/issues/83
|
||||
|
||||
diff --git a/net/minecraft/world/entity/animal/armadillo/Armadillo.java b/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
||||
index d840577023d42dc986e2b811382dfc433083ffb3..6aa8c94f6ce00cd948cd5edef80906f74c19ae25 100644
|
||||
--- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
||||
+++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
||||
@@ -161,8 +161,10 @@ public class Armadillo extends Animal {
|
||||
return ArmadilloAi.makeBrain(this.brainProvider().makeBrain(dynamic));
|
||||
}
|
||||
|
||||
+ private int behaviorTick; // Leaf - Plazma - Add missing Pufferfish configurations
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel level) {
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Leaf - Plazma - Add missing Pufferfish configurations
|
||||
((Brain<Armadillo>)this.brain).tick(level, this);
|
||||
ArmadilloAi.updateActivity(this);
|
||||
if (this.isAlive() && !this.isBaby() && --this.scuteTime <= 0) {
|
||||
diff --git a/net/minecraft/world/entity/animal/camel/Camel.java b/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
index 64ff0d2923f16a567aa753cad028a1b21c20101b..a7168edb338c5a77c884e9eef1e48bcdc3623fa4 100644
|
||||
--- a/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
+++ b/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
@@ -155,9 +155,11 @@ public class Camel extends AbstractHorse {
|
||||
return pose == Pose.SITTING ? SITTING_DIMENSIONS.scale(this.getAgeScale()) : super.getDefaultDimensions(pose);
|
||||
}
|
||||
|
||||
+ private int behaviorTick = 0; // Leaf - Plazma - Add missing Pufferfish configurations
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel level) {
|
||||
Brain<?> brain = this.getBrain();
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Leaf - Plazma - Add missing Pufferfish configurations
|
||||
((Brain<Camel>)brain).tick(level, this);
|
||||
CamelAi.updateActivity(this);
|
||||
super.customServerAiStep(level);
|
||||
diff --git a/net/minecraft/world/entity/animal/sniffer/Sniffer.java b/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
||||
index 68751f7ed123c3e99f56259ccc23121661f89bc1..fec7ecfe6e692ee74762a6a53e51f92cf66a9177 100644
|
||||
--- a/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
||||
+++ b/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
||||
@@ -482,8 +482,10 @@ public class Sniffer extends Animal {
|
||||
return Brain.provider(SnifferAi.MEMORY_TYPES, SnifferAi.SENSOR_TYPES);
|
||||
}
|
||||
|
||||
+ private int behaviorTick; // Leaf - Plazma - Add missing Pufferfish configurations
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel level) {
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Leaf - Plazma - Add missing Pufferfish configurations
|
||||
this.getBrain().tick(level, this);
|
||||
SnifferAi.updateActivity(this);
|
||||
super.customServerAiStep(level);
|
||||
diff --git a/net/minecraft/world/entity/monster/breeze/Breeze.java b/net/minecraft/world/entity/monster/breeze/Breeze.java
|
||||
index fb643596bd5fb12e4cd323706f51a479d78a5455..542baa54c8b5fbe2d9d71e3ee5d2bd62b69baccc 100644
|
||||
--- a/net/minecraft/world/entity/monster/breeze/Breeze.java
|
||||
+++ b/net/minecraft/world/entity/monster/breeze/Breeze.java
|
||||
@@ -228,8 +228,10 @@ public class Breeze extends Monster {
|
||||
return pos.closerThan(center, 4.0, 10.0);
|
||||
}
|
||||
|
||||
+ private int behaviorTick; // Leaf - Plazma - Add missing Pufferfish configurations
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel level) {
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Leaf - Plazma - Add missing Pufferfish configurations
|
||||
this.getBrain().tick(level, this);
|
||||
BreezeAi.updateActivity(this);
|
||||
super.customServerAiStep(level);
|
||||
diff --git a/net/minecraft/world/entity/monster/creaking/Creaking.java b/net/minecraft/world/entity/monster/creaking/Creaking.java
|
||||
index 2c6833753950f1bb0941b0cbe54bebddb84b137d..07b60f61b4b676cab2072ad0cf1cf94fed9b44d6 100644
|
||||
--- a/net/minecraft/world/entity/monster/creaking/Creaking.java
|
||||
+++ b/net/minecraft/world/entity/monster/creaking/Creaking.java
|
||||
@@ -230,8 +230,10 @@ public class Creaking extends Monster {
|
||||
return (Brain<Creaking>)super.getBrain();
|
||||
}
|
||||
|
||||
+ private int behaviorTick; // Leaf - Plazma - Add missing Pufferfish configurations
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel level) {
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Leaf - Plazma - Add missing Pufferfish configurations
|
||||
this.getBrain().tick((ServerLevel)this.level(), this);
|
||||
CreakingAi.updateActivity(this);
|
||||
}
|
||||
@@ -8,13 +8,13 @@ Original project: https://github.com/PlazmaMC/PlazmaBukkit
|
||||
|
||||
Add more Purpur configurable options for entities
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java
|
||||
index b9f39d873e243da34aafa9f285978d2d9f6b0100..349c444b0c8acc509616de6bc809e2bad9c8e115 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java
|
||||
@@ -160,6 +160,18 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS
|
||||
diff --git a/net/minecraft/world/entity/animal/allay/Allay.java b/net/minecraft/world/entity/animal/allay/Allay.java
|
||||
index 10d2a1138d814b83ce4233205a7f0ab2ed1f399d..86977d359f8eb8fcb2e441a9311f663337175113 100644
|
||||
--- a/net/minecraft/world/entity/animal/allay/Allay.java
|
||||
+++ b/net/minecraft/world/entity/animal/allay/Allay.java
|
||||
@@ -179,6 +179,18 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS
|
||||
}
|
||||
// Purpur end
|
||||
// Purpur end - Configurable entity base attributes
|
||||
|
||||
+ // Leaf start - Plazma
|
||||
+ @Override
|
||||
@@ -30,14 +30,14 @@ index b9f39d873e243da34aafa9f285978d2d9f6b0100..349c444b0c8acc509616de6bc809e2ba
|
||||
+
|
||||
@Override
|
||||
protected Brain.Provider<Allay> brainProvider() {
|
||||
return Brain.provider(Allay.MEMORY_TYPES, Allay.SENSOR_TYPES);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
index c0595b595905e4f876e013a16e75204d9ceeead9..4b54783c004bbf2e6fab3fa65eb64444d009c5bc 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
@@ -96,6 +96,18 @@ public class Camel extends AbstractHorse {
|
||||
return Brain.provider(MEMORY_TYPES, SENSOR_TYPES);
|
||||
diff --git a/net/minecraft/world/entity/animal/camel/Camel.java b/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
index a7168edb338c5a77c884e9eef1e48bcdc3623fa4..96836a1d5edda7e275fe1859e3bd661e7be1266b 100644
|
||||
--- a/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
+++ b/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
@@ -95,6 +95,18 @@ public class Camel extends AbstractHorse {
|
||||
}
|
||||
// Purpur end
|
||||
// Purpur end - Make entity breeding times configurable
|
||||
|
||||
+ // Leaf start - Plazma
|
||||
+ @Override
|
||||
@@ -52,25 +52,26 @@ index c0595b595905e4f876e013a16e75204d9ceeead9..4b54783c004bbf2e6fab3fa65eb64444
|
||||
+ // Leaf start - Plazma
|
||||
+
|
||||
@Override
|
||||
public void addAdditionalSaveData(CompoundTag nbt) {
|
||||
super.addAdditionalSaveData(nbt);
|
||||
@@ -155,7 +167,7 @@ public class Camel extends AbstractHorse {
|
||||
protected void customServerAiStep(ServerLevel world) {
|
||||
Brain<Camel> behaviorcontroller = (Brain<Camel>) this.getBrain(); // CraftBukkit - decompile error
|
||||
|
||||
public void addAdditionalSaveData(CompoundTag compound) {
|
||||
super.addAdditionalSaveData(compound);
|
||||
@@ -159,7 +171,7 @@ public class Camel extends AbstractHorse {
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel level) {
|
||||
Brain<?> brain = this.getBrain();
|
||||
- if (this.behaviorTick++ % this.activatedPriority == 0) // Leaf - Plazma - Add missing Pufferfish configurations
|
||||
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Leaf - Plazma - Add missing Pufferfish configurations // Leaf - Plazma - Add missing purpur configurations
|
||||
behaviorcontroller.tick(world, this);
|
||||
((Brain<Camel>)brain).tick(level, this);
|
||||
CamelAi.updateActivity(this);
|
||||
super.customServerAiStep(world);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
index d8fe42996c8ba3d44e31197b24294b86b845e2a8..6575e5f5e574db5bb4243a9bed426f3316e3e2ec 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
@@ -163,6 +163,23 @@ public class Frog extends Animal implements VariantHolder<Holder<FrogVariant>> {
|
||||
super.customServerAiStep(level);
|
||||
diff --git a/net/minecraft/world/entity/animal/frog/Frog.java b/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
index 2c28e97e76155fe4de309422f4913c1269972ff4..cb8e3e9f0dc7fa8673397e594dea6fd5da3e74aa 100644
|
||||
--- a/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
+++ b/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
@@ -169,6 +169,24 @@ public class Frog extends Animal implements VariantHolder<Holder<FrogVariant>> {
|
||||
return this.level().purpurConfig.frogBreedingTicks;
|
||||
}
|
||||
// Purpur end
|
||||
|
||||
// Purpur end - Make entity breeding times configurable
|
||||
+
|
||||
+ // Leaf start - Plazma
|
||||
+ @Override
|
||||
+ public boolean isSensitiveToWater() {
|
||||
@@ -88,16 +89,16 @@ index d8fe42996c8ba3d44e31197b24294b86b845e2a8..6575e5f5e574db5bb4243a9bed426f33
|
||||
+ }
|
||||
+ // Leaf end - Plazma
|
||||
+
|
||||
public int getPurpurBreedTime() {
|
||||
return this.level().purpurConfig.frogBreedingTicks;
|
||||
@Override
|
||||
protected Brain.Provider<Frog> brainProvider() {
|
||||
return Brain.provider(MEMORY_TYPES, SENSOR_TYPES);
|
||||
diff --git a/net/minecraft/world/entity/animal/frog/Tadpole.java b/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||
index 669f7d6e5f481fb209e800c8e4acc52cf0c6dfce..ec6897093948fc3641138dcf82b7834083fe37fa 100644
|
||||
--- a/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||
+++ b/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||
@@ -105,6 +105,23 @@ public class Tadpole extends AbstractFish {
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java b/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||
index 72a858ac4ebcfa7520a74bd52501521af64ffcab..d20d7eb89ead872ab90a5b43d6298d45b657c902 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||
@@ -93,6 +93,23 @@ public class Tadpole extends AbstractFish {
|
||||
}
|
||||
// Purpur end
|
||||
// Purpur end - Ridables
|
||||
|
||||
+ // Leaf start - Plazma
|
||||
+ @Override
|
||||
@@ -117,15 +118,15 @@ index 72a858ac4ebcfa7520a74bd52501521af64ffcab..d20d7eb89ead872ab90a5b43d6298d45
|
||||
+ // Leaf end - Plazma
|
||||
+
|
||||
@Override
|
||||
protected PathNavigation createNavigation(Level world) {
|
||||
return new WaterBoundPathNavigation(this, world);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java b/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
||||
index dc0f8bf73170f5012a5d4af3a7e823352d684bd9..47bbb60edcca9840f1bc70b90bd8f2a4dee45a21 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
||||
@@ -116,6 +116,18 @@ public class Sniffer extends Animal {
|
||||
protected PathNavigation createNavigation(Level level) {
|
||||
return new WaterBoundPathNavigation(this, level);
|
||||
diff --git a/net/minecraft/world/entity/animal/sniffer/Sniffer.java b/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
||||
index fec7ecfe6e692ee74762a6a53e51f92cf66a9177..16cdd65770b8d70e6bde3d4407d9a71b5d2da8c8 100644
|
||||
--- a/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
||||
+++ b/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
||||
@@ -118,6 +118,18 @@ public class Sniffer extends Animal {
|
||||
}
|
||||
// Purpur end
|
||||
// Purpur end - Make entity breeding times configurable
|
||||
|
||||
+ // Leaf start - Plazma
|
||||
+ @Override
|
||||
@@ -142,22 +143,54 @@ index dc0f8bf73170f5012a5d4af3a7e823352d684bd9..47bbb60edcca9840f1bc70b90bd8f2a4
|
||||
@Override
|
||||
protected void defineSynchedData(SynchedEntityData.Builder builder) {
|
||||
super.defineSynchedData(builder);
|
||||
@@ -494,7 +506,7 @@ public class Sniffer extends Animal {
|
||||
@@ -485,7 +497,7 @@ public class Sniffer extends Animal {
|
||||
private int behaviorTick; // Leaf - Plazma - Add missing Pufferfish configurations
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel world) {
|
||||
protected void customServerAiStep(ServerLevel level) {
|
||||
- if (this.behaviorTick++ % this.activatedPriority == 0) // Leaf - Plazma - Add missing Pufferfish configurations
|
||||
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Leaf - Plazma - Add missing Pufferfish configurations // Leaf - Plazma - Add missing purpur configuration
|
||||
this.getBrain().tick(level, this);
|
||||
SnifferAi.updateActivity(this);
|
||||
super.customServerAiStep(level);
|
||||
diff --git a/net/minecraft/world/entity/monster/creaking/Creaking.java b/net/minecraft/world/entity/monster/creaking/Creaking.java
|
||||
index 07b60f61b4b676cab2072ad0cf1cf94fed9b44d6..f6d58fac537ee1f40d311c3146e89b82b01a6a58 100644
|
||||
--- a/net/minecraft/world/entity/monster/creaking/Creaking.java
|
||||
+++ b/net/minecraft/world/entity/monster/creaking/Creaking.java
|
||||
@@ -131,6 +131,18 @@ public class Creaking extends Monster {
|
||||
}
|
||||
// Purpur end - Configurable entity base attributes
|
||||
|
||||
+ // Leaf start - Plazma
|
||||
+ @Override
|
||||
+ public boolean isSensitiveToWater() {
|
||||
+ return level().purpurConfig.wardenTakeDamageFromWater;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isAlwaysExperienceDropper() {
|
||||
+ return level().purpurConfig.wardenAlwaysDropExp;
|
||||
+ }
|
||||
+ // Leaf end - Plazma
|
||||
+
|
||||
@Override
|
||||
protected BodyRotationControl createBodyControl() {
|
||||
return new Creaking.CreakingBodyRotationControl(this);
|
||||
@@ -233,7 +245,7 @@ public class Creaking extends Monster {
|
||||
private int behaviorTick; // Leaf - Plazma - Add missing Pufferfish configurations
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel level) {
|
||||
- if (this.behaviorTick++ % this.activatedPriority == 0) // Leaf - Plazma - Add missing Pufferfish configurations
|
||||
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Leaf - Plazma - Add missing Pufferfish configurations // Leaf - Plazma - Add missing purpur configurations
|
||||
this.getBrain().tick(world, this);
|
||||
SnifferAi.updateActivity(this);
|
||||
super.customServerAiStep(world);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
||||
index a429de1fdb4823b1f1df42dfe213853cc06ef1c2..ef1bbd47d22a808b3f5bfc715eda3f4d13bd80aa 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
||||
@@ -151,6 +151,23 @@ public class Warden extends Monster implements VibrationSystem {
|
||||
this.getBrain().tick((ServerLevel)this.level(), this);
|
||||
CreakingAi.updateActivity(this);
|
||||
}
|
||||
// Purpur end
|
||||
diff --git a/net/minecraft/world/entity/monster/warden/Warden.java b/net/minecraft/world/entity/monster/warden/Warden.java
|
||||
index 3a43790fb91e778f4fc0730aecd0dde4a6d301c8..7aae3d82ab5dd66f3e85d0a1bf66c9ddaa3d65e9 100644
|
||||
--- a/net/minecraft/world/entity/monster/warden/Warden.java
|
||||
+++ b/net/minecraft/world/entity/monster/warden/Warden.java
|
||||
@@ -153,6 +153,23 @@ public class Warden extends Monster implements VibrationSystem {
|
||||
}
|
||||
// Purpur end - Ridables
|
||||
|
||||
+ // Leaf start - Plazma
|
||||
+ @Override
|
||||
@@ -177,31 +210,31 @@ index a429de1fdb4823b1f1df42dfe213853cc06ef1c2..ef1bbd47d22a808b3f5bfc715eda3f4d
|
||||
+ // Leaf end - Plazma
|
||||
+
|
||||
@Override
|
||||
public Packet<ClientGamePacketListener> getAddEntityPacket(ServerEntity entityTrackerEntry) {
|
||||
return new ClientboundAddEntityPacket(this, entityTrackerEntry, this.hasPose(Pose.EMERGING) ? 1 : 0);
|
||||
@@ -300,7 +317,7 @@ public class Warden extends Monster implements VibrationSystem {
|
||||
public Packet<ClientGamePacketListener> getAddEntityPacket(ServerEntity entity) {
|
||||
return new ClientboundAddEntityPacket(this, entity, this.hasPose(Pose.EMERGING) ? 1 : 0);
|
||||
@@ -307,7 +324,7 @@ public class Warden extends Monster implements VibrationSystem {
|
||||
private int behaviorTick = 0; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel world) {
|
||||
protected void customServerAiStep(ServerLevel level) {
|
||||
- if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Leaf - Plazma - Add missing purpur configurations
|
||||
this.getBrain().tick(world, this);
|
||||
super.customServerAiStep(world);
|
||||
this.getBrain().tick(level, this);
|
||||
super.customServerAiStep(level);
|
||||
if ((this.tickCount + this.getId()) % 120 == 0) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractChestBoat.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractChestBoat.java
|
||||
index 1f4cc08e84a23213bb9786ea09ad77caeec2d336..06d45906924d6470d75445dea23c9b90dac6545f 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractChestBoat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractChestBoat.java
|
||||
@@ -46,7 +46,7 @@ public abstract class AbstractChestBoat extends AbstractBoat implements HasCusto
|
||||
diff --git a/net/minecraft/world/entity/vehicle/AbstractChestBoat.java b/net/minecraft/world/entity/vehicle/AbstractChestBoat.java
|
||||
index b230955ae880d84fde40b4feffa5caf3c4449eb7..ff705de4cd2b126c1a6902a7225b6fef7a6b34d6 100644
|
||||
--- a/net/minecraft/world/entity/vehicle/AbstractChestBoat.java
|
||||
+++ b/net/minecraft/world/entity/vehicle/AbstractChestBoat.java
|
||||
@@ -27,7 +27,7 @@ import net.minecraft.world.level.storage.loot.LootTable;
|
||||
|
||||
public AbstractChestBoat(EntityType<? extends AbstractChestBoat> type, Level world, Supplier<Item> itemSupplier) {
|
||||
super(type, world, itemSupplier);
|
||||
- this.itemStacks = NonNullList.withSize(27, ItemStack.EMPTY);
|
||||
+ this.itemStacks = NonNullList.withSize(org.purpurmc.purpur.PurpurConfig.chestBoatRows * 9, ItemStack.EMPTY); // Leaf - Plazma
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,7 +142,7 @@ public abstract class AbstractChestBoat extends AbstractBoat implements HasCusto
|
||||
public abstract class AbstractChestBoat extends AbstractBoat implements HasCustomInventoryScreen, ContainerEntity {
|
||||
private static final int CONTAINER_SIZE = 27;
|
||||
- private NonNullList<ItemStack> itemStacks = NonNullList.withSize(27, ItemStack.EMPTY);
|
||||
+ private NonNullList<ItemStack> itemStacks = NonNullList.withSize(org.purpurmc.purpur.PurpurConfig.chestBoatRows * 9, ItemStack.EMPTY); // Leaf - Plazma
|
||||
@Nullable
|
||||
private ResourceKey<LootTable> lootTable;
|
||||
private long lootTableSeed;
|
||||
@@ -118,7 +118,7 @@ public abstract class AbstractChestBoat extends AbstractBoat implements HasCusto
|
||||
|
||||
@Override
|
||||
public int getContainerSize() {
|
||||
@@ -210,11 +243,11 @@ index 1f4cc08e84a23213bb9786ea09ad77caeec2d336..06d45906924d6470d75445dea23c9b90
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
index 4401cd919951e92f613e0899f243b0105dd852b7..05d77ccd9bf8ce0534fbac7d4354536e3187229f 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
@@ -321,6 +321,7 @@ public class PurpurConfig {
|
||||
diff --git a/org/purpurmc/purpur/PurpurConfig.java b/org/purpurmc/purpur/PurpurConfig.java
|
||||
index aca85686fb0b9ec78d4e83574bbfe6313785f40f..b084fcbe57a1f57e97919aaa0b0c7d4ab5436bdf 100644
|
||||
--- a/org/purpurmc/purpur/PurpurConfig.java
|
||||
+++ b/org/purpurmc/purpur/PurpurConfig.java
|
||||
@@ -322,6 +322,7 @@ public class PurpurConfig {
|
||||
}
|
||||
|
||||
public static int barrelRows = 3;
|
||||
@@ -222,7 +255,7 @@ index 4401cd919951e92f613e0899f243b0105dd852b7..05d77ccd9bf8ce0534fbac7d4354536e
|
||||
public static boolean enderChestSixRows = false;
|
||||
public static boolean enderChestPermissionRows = false;
|
||||
public static boolean cryingObsidianValidForPortalFrame = false;
|
||||
@@ -363,6 +364,7 @@ public class PurpurConfig {
|
||||
@@ -364,6 +365,7 @@ public class PurpurConfig {
|
||||
case 1 -> 9;
|
||||
default -> 27;
|
||||
});
|
||||
@@ -230,11 +263,11 @@ index 4401cd919951e92f613e0899f243b0105dd852b7..05d77ccd9bf8ce0534fbac7d4354536e
|
||||
enderChestSixRows = getBoolean("settings.blocks.ender_chest.six-rows", enderChestSixRows);
|
||||
org.bukkit.event.inventory.InventoryType.ENDER_CHEST.setDefaultSize(enderChestSixRows ? 54 : 27);
|
||||
enderChestPermissionRows = getBoolean("settings.blocks.ender_chest.use-permissions-for-rows", enderChestPermissionRows);
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
index 8c9a6084f09f644bf22ac98edac797eea753277f..0ff935f36f65d2274156e134684696ebcc404614 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
@@ -1128,12 +1128,20 @@ public class PurpurWorldConfig {
|
||||
diff --git a/org/purpurmc/purpur/PurpurWorldConfig.java b/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
index fd5a5b9cb9958e96ecfeb4846e290c756265b300..e45406d6ec6f075c9c2008bd6cb61dba824dc553 100644
|
||||
--- a/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
+++ b/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
@@ -1137,12 +1137,20 @@ public class PurpurWorldConfig {
|
||||
public boolean allayControllable = true;
|
||||
public double allayMaxHealth = 20.0D;
|
||||
public double allayScale = 1.0D;
|
||||
@@ -255,7 +288,7 @@ index 8c9a6084f09f644bf22ac98edac797eea753277f..0ff935f36f65d2274156e134684696eb
|
||||
}
|
||||
|
||||
public boolean armadilloRidable = false;
|
||||
@@ -1283,6 +1291,10 @@ public class PurpurWorldConfig {
|
||||
@@ -1292,6 +1300,10 @@ public class PurpurWorldConfig {
|
||||
public double camelMovementSpeedMin = 0.09D;
|
||||
public double camelMovementSpeedMax = 0.09D;
|
||||
public int camelBreedingTicks = 6000;
|
||||
@@ -266,7 +299,7 @@ index 8c9a6084f09f644bf22ac98edac797eea753277f..0ff935f36f65d2274156e134684696eb
|
||||
private void camelSettings() {
|
||||
camelRidableInWater = getBoolean("mobs.camel.ridable-in-water", camelRidableInWater);
|
||||
camelMaxHealthMin = getDouble("mobs.camel.attributes.max_health.min", camelMaxHealthMin);
|
||||
@@ -1292,6 +1304,10 @@ public class PurpurWorldConfig {
|
||||
@@ -1301,6 +1313,10 @@ public class PurpurWorldConfig {
|
||||
camelMovementSpeedMin = getDouble("mobs.camel.attributes.movement_speed.min", camelMovementSpeedMin);
|
||||
camelMovementSpeedMax = getDouble("mobs.camel.attributes.movement_speed.max", camelMovementSpeedMax);
|
||||
camelBreedingTicks = getInt("mobs.camel.breeding-delay-ticks", camelBreedingTicks);
|
||||
@@ -277,7 +310,28 @@ index 8c9a6084f09f644bf22ac98edac797eea753277f..0ff935f36f65d2274156e134684696eb
|
||||
}
|
||||
|
||||
public boolean catRidable = false;
|
||||
@@ -1750,12 +1766,22 @@ public class PurpurWorldConfig {
|
||||
@@ -1447,12 +1463,20 @@ public class PurpurWorldConfig {
|
||||
public boolean creakingControllable = true;
|
||||
public double creakingMaxHealth = 1.0D;
|
||||
public double creakingScale = 1.0D;
|
||||
+ // Leaf start - Plazma - Add missing purpur config options
|
||||
+ public boolean creakingTakeDamageFromWater = false;
|
||||
+ public boolean creakingAlwaysDropExp = false;
|
||||
+ // Leaf end - Plazma - Add missing purpur config options
|
||||
private void creakingSettings() {
|
||||
creakingRidable = getBoolean("mobs.creaking.ridable", creakingRidable);
|
||||
creakingRidableInWater = getBoolean("mobs.creaking.ridable-in-water", creakingRidableInWater);
|
||||
creakingControllable = getBoolean("mobs.creaking.controllable", creakingControllable);
|
||||
creakingMaxHealth = getDouble("mobs.creaking.attributes.max_health", creakingMaxHealth);
|
||||
creakingScale = Mth.clamp(getDouble("mobs.creaking.attributes.scale", creakingScale), 0.0625D, 16.0D);
|
||||
+ // Leaf start - Plazma - Add missing purpur config options
|
||||
+ creakingTakeDamageFromWater = getBoolean("mobs.creaking.takes-damage-from-water", creakingTakeDamageFromWater);
|
||||
+ creakingAlwaysDropExp = getBoolean("mobs.creaking.always-drop-exp", creakingAlwaysDropExp);
|
||||
+ // Leaf end - Plazma - Add missing purpur config options
|
||||
}
|
||||
|
||||
public boolean creeperRidable = false;
|
||||
@@ -1759,12 +1783,22 @@ public class PurpurWorldConfig {
|
||||
public boolean frogControllable = true;
|
||||
public float frogRidableJumpHeight = 0.65F;
|
||||
public int frogBreedingTicks = 6000;
|
||||
@@ -300,7 +354,7 @@ index 8c9a6084f09f644bf22ac98edac797eea753277f..0ff935f36f65d2274156e134684696eb
|
||||
}
|
||||
|
||||
public boolean ghastRidable = false;
|
||||
@@ -2764,6 +2790,10 @@ public class PurpurWorldConfig {
|
||||
@@ -2773,6 +2807,10 @@ public class PurpurWorldConfig {
|
||||
public double snifferMaxHealth = 14.0D;
|
||||
public double snifferScale = 1.0D;
|
||||
public int snifferBreedingTicks = 6000;
|
||||
@@ -311,7 +365,7 @@ index 8c9a6084f09f644bf22ac98edac797eea753277f..0ff935f36f65d2274156e134684696eb
|
||||
private void snifferSettings() {
|
||||
snifferRidable = getBoolean("mobs.sniffer.ridable", snifferRidable);
|
||||
snifferRidableInWater = getBoolean("mobs.sniffer.ridable-in-water", snifferRidableInWater);
|
||||
@@ -2771,6 +2801,10 @@ public class PurpurWorldConfig {
|
||||
@@ -2780,6 +2818,10 @@ public class PurpurWorldConfig {
|
||||
snifferMaxHealth = getDouble("mobs.sniffer.attributes.max_health", snifferMaxHealth);
|
||||
snifferScale = Mth.clamp(getDouble("mobs.sniffer.attributes.scale", snifferScale), 0.0625D, 16.0D);
|
||||
snifferBreedingTicks = getInt("mobs.sniffer.breeding-delay-ticks", snifferBreedingTicks);
|
||||
@@ -322,7 +376,7 @@ index 8c9a6084f09f644bf22ac98edac797eea753277f..0ff935f36f65d2274156e134684696eb
|
||||
}
|
||||
|
||||
public boolean squidRidable = false;
|
||||
@@ -2872,10 +2906,20 @@ public class PurpurWorldConfig {
|
||||
@@ -2881,10 +2923,20 @@ public class PurpurWorldConfig {
|
||||
public boolean tadpoleRidable = false;
|
||||
public boolean tadpoleRidableInWater = true;
|
||||
public boolean tadpoleControllable = true;
|
||||
@@ -343,7 +397,7 @@ index 8c9a6084f09f644bf22ac98edac797eea753277f..0ff935f36f65d2274156e134684696eb
|
||||
}
|
||||
|
||||
public boolean traderLlamaRidable = false;
|
||||
@@ -3104,10 +3148,20 @@ public class PurpurWorldConfig {
|
||||
@@ -3113,10 +3165,20 @@ public class PurpurWorldConfig {
|
||||
public boolean wardenRidable = false;
|
||||
public boolean wardenRidableInWater = true;
|
||||
public boolean wardenControllable = true;
|
||||
@@ -0,0 +1,32 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrPowerGamerBR <git@mrpowergamerbr.com>
|
||||
Date: Wed, 15 Nov 2023 23:39:36 -0300
|
||||
Subject: [PATCH] SparklyPaper: Skip "distanceToSqr" call in
|
||||
"ServerEntity#sendChanges" if the delta movement hasn't changed
|
||||
|
||||
Original project: https://github.com/SparklyPower/SparklyPaper
|
||||
|
||||
The "distanceToSqr" call is a bit expensive, so avoiding it is pretty nice, around ~15% calls are skipped with this check
|
||||
|
||||
We could also check if the x,y,z coordinates are equal, but for now, let's just keep the identity check, which also helps us since Minecraft's code does reuse the original delta movement Vec3 object
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java
|
||||
index d985555a029d06ffc73dd10115df47b83c9afafd..ddf2a5e2cfeaa666a081dd857d6a6003d65d0e00 100644
|
||||
--- a/net/minecraft/server/level/ServerEntity.java
|
||||
+++ b/net/minecraft/server/level/ServerEntity.java
|
||||
@@ -201,6 +201,7 @@ public class ServerEntity {
|
||||
|
||||
if (this.entity.hasImpulse || this.trackDelta || this.entity instanceof LivingEntity && ((LivingEntity)this.entity).isFallFlying()) {
|
||||
Vec3 deltaMovement = this.entity.getDeltaMovement();
|
||||
+ if (deltaMovement != this.lastSentMovement) { // SparklyPaper start - skip distanceToSqr call in ServerEntity#sendChanges if the delta movement hasn't changed
|
||||
double d = deltaMovement.distanceToSqr(this.lastSentMovement);
|
||||
if (d > 1.0E-7 || d > 0.0 && deltaMovement.lengthSqr() == 0.0) {
|
||||
this.lastSentMovement = deltaMovement;
|
||||
@@ -218,6 +219,7 @@ public class ServerEntity {
|
||||
this.broadcast.accept(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement));
|
||||
}
|
||||
}
|
||||
+ } // SparklyPaper end
|
||||
}
|
||||
|
||||
if (packet != null) {
|
||||
@@ -0,0 +1,25 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrPowerGamerBR <git@mrpowergamerbr.com>
|
||||
Date: Fri, 17 Nov 2023 14:22:41 -0300
|
||||
Subject: [PATCH] SparklyPaper: Skip "MapItem#update()" if the map does not
|
||||
have the CraftMapRenderer present
|
||||
|
||||
Original project: https://github.com/SparklyPower/SparklyPaper
|
||||
|
||||
Optimizes "image in map" maps, without requiring the map to be locked, which some old map plugins may not do
|
||||
|
||||
This has the disadvantage that the vanilla map data will never be updated while the CraftMapRenderer is not present, but that's not a huuuge problem for u
|
||||
|
||||
diff --git a/net/minecraft/world/item/MapItem.java b/net/minecraft/world/item/MapItem.java
|
||||
index 309392d414ecbe60474abd0af534184740951707..fd8418fc1487b0669907569142955887257f81c0 100644
|
||||
--- a/net/minecraft/world/item/MapItem.java
|
||||
+++ b/net/minecraft/world/item/MapItem.java
|
||||
@@ -278,7 +278,7 @@ public class MapItem extends Item {
|
||||
savedData.tickCarriedBy(player, stack);
|
||||
}
|
||||
|
||||
- if (!savedData.locked && (isSelected || entity instanceof Player && ((Player)entity).getOffhandItem() == stack)) {
|
||||
+ if (!savedData.locked && (!org.dreeam.leaf.config.modules.opt.SkipMapItemDataUpdates.enabled || savedData.mapView.getRenderers().stream().anyMatch(mapRenderer -> mapRenderer.getClass() == org.bukkit.craftbukkit.map.CraftMapRenderer.class)) && (isSelected || entity instanceof Player && ((Player)entity).getOffhandItem() == stack)) { // SparklyPaper - don't update maps if they don't have the CraftMapRenderer in the render list
|
||||
this.update(level, entity, savedData);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrPowerGamerBR <git@mrpowergamerbr.com>
|
||||
Date: Sun, 19 Nov 2023 12:35:16 -0300
|
||||
Subject: [PATCH] SparklyPaper: Skip EntityScheduler's executeTick checks if
|
||||
there isn't any tasks to be run
|
||||
|
||||
Original project: https://github.com/SparklyPower/SparklyPaper
|
||||
|
||||
On each tick, Paper runs EntityScheduler's executeTick of each entity. This is a bit expensive, due to ArrayDeque's size() call because it ain't a simple "get the current queue size" function, due to the thread checks, and because it needs to iterate all entities in all worlds.
|
||||
|
||||
To avoid the hefty ArrayDeque's size() call, we check if we *really* need to execute the executeTick, by adding all entities with scheduled tasks to a global set.
|
||||
|
||||
Most entities won't have any scheduled tasks, so this is a nice performance bonus. These optimizations, however, wouldn't work in a Folia environment, but because in SparklyPaper executeTick is always executed on the main thread, it ain't an issue for us (yay).
|
||||
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 742835ecfa0cba6dc3114dbe584409183ade9228..2ff6059d6bd3fe7c6814603c2ba0e6ccffe1873a 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -291,6 +291,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
public static final long SERVER_INIT = System.nanoTime(); // Paper - Lag compensation
|
||||
protected boolean upnp = false; // Purpur - UPnP Port Forwarding
|
||||
public gg.pufferfish.pufferfish.util.AsyncExecutor mobSpawnExecutor = new gg.pufferfish.pufferfish.util.AsyncExecutor("Leaf Async Mob Spawn Thread"); // Pufferfish - optimize mob spawning // Leaf - Fix Pufferfish and Purpur patches - Unify thread name
|
||||
+ public final Set<net.minecraft.world.entity.Entity> entitiesWithScheduledTasks = java.util.concurrent.ConcurrentHashMap.newKeySet(); // SparklyPaper - skip EntityScheduler's executeTick checks if there isn't any tasks to be run (concurrent because plugins may schedule tasks async)
|
||||
|
||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> threadFunction) {
|
||||
ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.init(); // Paper - rewrite data converter system
|
||||
@@ -1680,6 +1681,18 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
this.server.getScheduler().mainThreadHeartbeat(); // CraftBukkit
|
||||
// Paper start - Folia scheduler API
|
||||
((io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler) org.bukkit.Bukkit.getGlobalRegionScheduler()).tick();
|
||||
+ // SparklyPaper - skip EntityScheduler's executeTick checks if there isn't any tasks to be run
|
||||
+ for (final net.minecraft.world.entity.Entity entity : entitiesWithScheduledTasks) {
|
||||
+ if (entity.isRemoved()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final org.bukkit.craftbukkit.entity.CraftEntity bukkit = entity.getBukkitEntityRaw();
|
||||
+ if (bukkit != null) {
|
||||
+ bukkit.taskScheduler.executeTick();
|
||||
+ }
|
||||
+ }
|
||||
+ /*
|
||||
getAllLevels().forEach(level -> {
|
||||
for (final net.minecraft.world.entity.Entity entity : level.getEntities().getAll()) {
|
||||
if (entity.isRemoved()) {
|
||||
@@ -1691,6 +1704,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
}
|
||||
});
|
||||
+ */
|
||||
+ // SparklyPaper end
|
||||
// Paper end - Folia scheduler API
|
||||
io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.CALLBACK_MANAGER.handleQueue(this.tickCount); // Paper
|
||||
this.getFunctions().tick();
|
||||
@@ -0,0 +1,30 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrPowerGamerBR <git@mrpowergamerbr.com>
|
||||
Date: Thu, 23 Nov 2023 14:36:47 -0300
|
||||
Subject: [PATCH] SparklyPaper: Optimize "canSee" checks
|
||||
|
||||
Original project: https://github.com/SparklyPower/SparklyPaper
|
||||
|
||||
The "canSee" checks is in a hot path, invoked by each entity for each player on the server if they are in tracking range, so optimizing it is pretty nice
|
||||
|
||||
First, we change the original "HashMap" to fastutil's "Object2ObjectOpenHashMap", because the containsKey throughput is better
|
||||
|
||||
Then, we add a "isEmpty()" check before attempting to check if the map contains something
|
||||
|
||||
This seems stupid, but it does seem that it improves the performance a bit, and it makes sense, "containsKey(...)" does not attempt to check the map size before attempting to check if the map contains the key
|
||||
|
||||
We also create a "canSee" method tailored for "ChunkMap#updatePlayer()", a method without the equals check (the "updatePlayer()" already checks if the entity is the same entity) because the CraftPlayer's `equals()` check is a *bit* expensive compared to only checking the object's identity, and because the identity has already been check, we don't need to check it twice.
|
||||
|
||||
diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java
|
||||
index 6a9fdb6329f177aca1274336a8e5be70ca3ce931..5d9d233e3a568aa6297ed9c703fa450f98158602 100644
|
||||
--- a/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -1225,7 +1225,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
flag = flag && this.entity.broadcastToPlayer(player) && ChunkMap.this.isChunkTracked(player, this.entity.chunkPosition().x, this.entity.chunkPosition().z);
|
||||
// Paper end - Configurable entity tracking range by Y
|
||||
// CraftBukkit start - respect vanish API
|
||||
- if (flag && !player.getBukkitEntity().canSee(this.entity.getBukkitEntity())) { // Paper - only consider hits
|
||||
+ if (flag && !player.getBukkitEntity().canSeeChunkMapUpdatePlayer(this.entity.getBukkitEntity())) { // Paper - only consider hits // SparklyPaper - optimize canSee checks
|
||||
flag = false;
|
||||
}
|
||||
// CraftBukkit end
|
||||
@@ -0,0 +1,24 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrPowerGamerBR <git@mrpowergamerbr.com>
|
||||
Date: Fri, 23 Aug 2024 16:20:45 -0300
|
||||
Subject: [PATCH] SparklyPaper: Allow throttling hopper checks if the target
|
||||
container is full
|
||||
|
||||
Original project: https://github.com/SparklyPower/SparklyPaper
|
||||
|
||||
diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
index 276cb0dffaa253a6c13b4c68d8c703732118d0d1..23848df90e7127b1ec11d2aaac68fad17bda238a 100644
|
||||
--- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
@@ -419,6 +419,11 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
} else {
|
||||
Direction opposite = blockEntity.facing.getOpposite();
|
||||
if (isFullContainer(attachedContainer, opposite)) {
|
||||
+ // Leaf start - Throttle hopper when full
|
||||
+ if (org.dreeam.leaf.config.modules.opt.ThrottleHopperWhenFull.enabled && org.dreeam.leaf.config.modules.opt.ThrottleHopperWhenFull.skipTicks > 0) {
|
||||
+ blockEntity.setCooldown(org.dreeam.leaf.config.modules.opt.ThrottleHopperWhenFull.skipTicks);
|
||||
+ }
|
||||
+ // Leaf end - Throttle hopper when full
|
||||
return false;
|
||||
} else {
|
||||
// Paper start - Perf: Optimize Hoppers
|
||||
@@ -0,0 +1,43 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: lilingfengdev <145678359+lilingfengdev@users.noreply.github.com>
|
||||
Date: Thu, 18 Jan 2024 13:30:02 +0800
|
||||
Subject: [PATCH] Polpot: Make egg and snowball can knockback player
|
||||
|
||||
Original project: https://github.com/HaHaWTH/Polpot
|
||||
|
||||
diff --git a/net/minecraft/world/entity/projectile/Snowball.java b/net/minecraft/world/entity/projectile/Snowball.java
|
||||
index 1d399532c67c213c95c06837b0c7855384f1a25c..16fc473415872a626c130c90b1fc76c41a6b2856 100644
|
||||
--- a/net/minecraft/world/entity/projectile/Snowball.java
|
||||
+++ b/net/minecraft/world/entity/projectile/Snowball.java
|
||||
@@ -54,6 +54,12 @@ public class Snowball extends ThrowableItemProjectile {
|
||||
Entity entity = result.getEntity();
|
||||
int i = entity.level().purpurConfig.snowballDamage >= 0 ? entity.level().purpurConfig.snowballDamage : entity instanceof Blaze ? 3 : 0; // Purpur - Add configurable snowball damage
|
||||
entity.hurt(this.damageSources().thrown(this, this.getOwner()), i);
|
||||
+ // Leaf start - Polpot - Make snowball can knockback player
|
||||
+ if (org.dreeam.leaf.config.modules.gameplay.Knockback.snowballCanKnockback && entity instanceof net.minecraft.server.level.ServerPlayer serverPlayer) {
|
||||
+ entity.hurt(this.damageSources().thrown(this, this.getOwner()), 0.0000001F);
|
||||
+ serverPlayer.knockback(0.4000000059604645D, this.getX() - entity.getX(), this.getZ() - entity.getZ());
|
||||
+ }
|
||||
+ // Leaf end - Polpot - Make snowball can knockback player
|
||||
}
|
||||
|
||||
// Purpur start - options to extinguish fire blocks with snowballs - borrowed and modified code from ThrownPotion#onHitBlock and ThrownPotion#dowseFire
|
||||
diff --git a/net/minecraft/world/entity/projectile/ThrownEgg.java b/net/minecraft/world/entity/projectile/ThrownEgg.java
|
||||
index 76481c0e77fc3a2e4be8eeb9de8d1e6de5507c64..46628c2cc23488b921f5ce1fa787712c996d9e21 100644
|
||||
--- a/net/minecraft/world/entity/projectile/ThrownEgg.java
|
||||
+++ b/net/minecraft/world/entity/projectile/ThrownEgg.java
|
||||
@@ -52,7 +52,14 @@ public class ThrownEgg extends ThrowableItemProjectile {
|
||||
@Override
|
||||
protected void onHitEntity(EntityHitResult result) {
|
||||
super.onHitEntity(result);
|
||||
+ net.minecraft.world.entity.Entity entity = result.getEntity(); // Polpot - make egg can knockback player
|
||||
result.getEntity().hurt(this.damageSources().thrown(this, this.getOwner()), 0.0F);
|
||||
+ // Leaf start - Polpot - Make egg can knockback player
|
||||
+ if (org.dreeam.leaf.config.modules.gameplay.Knockback.eggCanKnockback && entity instanceof net.minecraft.server.level.ServerPlayer serverPlayer) {
|
||||
+ entity.hurt(this.damageSources().thrown(this, this.getOwner()), 0.0000001F);
|
||||
+ serverPlayer.knockback(0.4000000059604645D, this.getX() - entity.getX(), this.getZ() - entity.getZ());
|
||||
+ }
|
||||
+ // Leaf end - Polpot - Make egg can knockback player
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -4,10 +4,10 @@ Date: Mon, 19 Feb 2024 13:10:16 -0500
|
||||
Subject: [PATCH] Redirect vanilla getProfiler in PathNavigationRegion
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/PathNavigationRegion.java b/src/main/java/net/minecraft/world/level/PathNavigationRegion.java
|
||||
index 5375ea8dee8f74c843964824ad1a374e15711b60..82c304cf560e4dfd21e1cf9ba038f9029754d8b3 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/PathNavigationRegion.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/PathNavigationRegion.java
|
||||
diff --git a/net/minecraft/world/level/PathNavigationRegion.java b/net/minecraft/world/level/PathNavigationRegion.java
|
||||
index 97a1cb8f30eb1668b1054912789bd100b96bee18..6de84cc2985de45a6375d255f49ddee4bf9776d5 100644
|
||||
--- a/net/minecraft/world/level/PathNavigationRegion.java
|
||||
+++ b/net/minecraft/world/level/PathNavigationRegion.java
|
||||
@@ -150,4 +150,10 @@ public class PathNavigationRegion implements CollisionGetter {
|
||||
public int getHeight() {
|
||||
return this.level.getHeight();
|
||||
@@ -4,25 +4,25 @@ Date: Tue, 27 Feb 2024 03:17:10 -0500
|
||||
Subject: [PATCH] Remove useless creating stats json bases on player name logic
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index a4e8aaf7f35cb1277fc24c4cd240f224e4eedea3..348c3c6a5d99fece14a9eb987a06934c8e8bac59 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -1654,6 +1654,8 @@ public abstract class PlayerList {
|
||||
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
||||
index 3b679578858b869425dc60ae73fa12ac19d253ef..015c4480a60acc252342d58aa129350ab36dc29b 100644
|
||||
--- a/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/net/minecraft/server/players/PlayerList.java
|
||||
@@ -1549,6 +1549,8 @@ public abstract class PlayerList {
|
||||
if (serverStatsCounter == null) {
|
||||
File file = this.server.getWorldPath(LevelResource.PLAYER_STATS_DIR).toFile();
|
||||
File file1 = new File(file, String.valueOf(uuid) + ".json");
|
||||
|
||||
File file1 = new File(file, uuid + ".json");
|
||||
+ // Leaf start - Remove useless creating stats json bases on player name logic
|
||||
+ /*
|
||||
if (!file1.exists()) {
|
||||
File file2 = new File(file, displayName + ".json"); // CraftBukkit
|
||||
Path path = file2.toPath();
|
||||
@@ -1662,6 +1664,8 @@ public abstract class PlayerList {
|
||||
@@ -1556,6 +1558,8 @@ public abstract class PlayerList {
|
||||
file2.renameTo(file1);
|
||||
}
|
||||
}
|
||||
+ */
|
||||
+ // Leaf end - Remove useless creating stats json bases on player name logic
|
||||
|
||||
serverstatisticmanager = new ServerStatsCounter(this.server, file1);
|
||||
// this.stats.put(uuid, serverstatisticmanager); // CraftBukkit
|
||||
serverStatsCounter = new ServerStatsCounter(this.server, file1);
|
||||
// this.stats.put(uuid, serverStatsCounter); // CraftBukkit
|
||||
@@ -6,25 +6,25 @@ Subject: [PATCH] Improve Purpur AFK system
|
||||
AFK command & command cooldown
|
||||
AFK title message
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
|
||||
index 6191930c133758936ffd3cc2588c3f8713145508..11f9ac80dd5e53ae9a43ab5f4e9d3c867ab94b15 100644
|
||||
--- a/src/main/java/net/minecraft/commands/Commands.java
|
||||
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
||||
@@ -252,6 +252,7 @@ public class Commands {
|
||||
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
||||
index a5cc373dbe034560865e196ce12a8361932ea085..d03a6dc74877bc08b170be5add061270dc46549b 100644
|
||||
--- a/net/minecraft/commands/Commands.java
|
||||
+++ b/net/minecraft/commands/Commands.java
|
||||
@@ -243,6 +243,7 @@ public class Commands {
|
||||
StopCommand.register(this.dispatcher);
|
||||
TransferCommand.register(this.dispatcher);
|
||||
WhitelistCommand.register(this.dispatcher);
|
||||
+ org.purpurmc.purpur.command.AFKCommand.register(this.dispatcher); // Leaf - Improve Purpur AFK system
|
||||
org.purpurmc.purpur.command.CreditsCommand.register(this.dispatcher); // Purpur
|
||||
org.purpurmc.purpur.command.DemoCommand.register(this.dispatcher); // Purpur
|
||||
org.purpurmc.purpur.command.PingCommand.register(this.dispatcher); // Purpur
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index df6f21a7cc2be3e006814896c4a80ad53f9b02f5..3eb3cd1089ec46c64f82e99f25d19cee9e0cdfbe 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -2680,6 +2680,10 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
||||
org.purpurmc.purpur.command.CreditsCommand.register(this.dispatcher); // Purpur - Add credits command
|
||||
org.purpurmc.purpur.command.DemoCommand.register(this.dispatcher); // Purpur - Add demo command
|
||||
org.purpurmc.purpur.command.PingCommand.register(this.dispatcher); // Purpur - Add ping command
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index 08578d7398658d226318a28324a1eae0d4453add..09c9ca038f359372bda3a3d8b743d497a530ce97 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -2460,6 +2460,10 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
|
||||
// Purpur Start
|
||||
// Purpur start - AFK API
|
||||
private boolean isAfk = false;
|
||||
+ // Leaf sart - Improve Purpur AFK system
|
||||
+ public boolean isCommandAfk = false;
|
||||
@@ -33,7 +33,7 @@ index df6f21a7cc2be3e006814896c4a80ad53f9b02f5..3eb3cd1089ec46c64f82e99f25d19cee
|
||||
|
||||
@Override
|
||||
public void setAfk(boolean afk) {
|
||||
@@ -2717,6 +2721,22 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
||||
@@ -2497,6 +2501,22 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
String prefix = (split.length > 0 ? split[0] : "").replace(org.purpurmc.purpur.PurpurConfig.afkTabListPrefix, "");
|
||||
String suffix = (split.length > 1 ? split[1] : "").replace(org.purpurmc.purpur.PurpurConfig.afkTabListSuffix, "");
|
||||
if (afk) {
|
||||
@@ -56,21 +56,21 @@ index df6f21a7cc2be3e006814896c4a80ad53f9b02f5..3eb3cd1089ec46c64f82e99f25d19cee
|
||||
getBukkitEntity().setPlayerListName(org.purpurmc.purpur.PurpurConfig.afkTabListPrefix + prefix + scoreboardName + suffix + org.purpurmc.purpur.PurpurConfig.afkTabListSuffix, true);
|
||||
} else {
|
||||
getBukkitEntity().setPlayerListName(prefix + scoreboardName + suffix, true);
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 68cf6f0f0d2d1eb23de070ea8471111a41a9f9bf..615622f3ce63d2150c57cfd9f664bfa8fa5d6124 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2294,6 +2294,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 465e34eb906ec78f49ff1183b635e77a1fcaa758..39b01b3d96d03bca4c33eaddfc54edef23c3df0c 100644
|
||||
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2255,6 +2255,8 @@ public class ServerGamePacketListenerImpl
|
||||
}
|
||||
}
|
||||
|
||||
+ public static final Map<UUID, Long> afkCooldown = new java.util.concurrent.ConcurrentHashMap<>(); // Leaf - Improve Purpur AFK system
|
||||
+ public static final Map<java.util.UUID, Long> afkCooldown = new java.util.concurrent.ConcurrentHashMap<>(); // Leaf - Improve Purpur AFK system
|
||||
+
|
||||
@Override
|
||||
public void handleChatCommand(ServerboundChatCommandPacket packet) {
|
||||
this.tryHandleChat(packet.command(), () -> {
|
||||
@@ -2314,6 +2316,32 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
ServerGamePacketListenerImpl.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + command1);
|
||||
@@ -2275,6 +2277,32 @@ public class ServerGamePacketListenerImpl
|
||||
LOGGER.info("{} issued server command: {}", this.player.getScoreboardName(), prefixedCommand);
|
||||
}
|
||||
|
||||
+ // Leaf start - Improve Purpur AFK system
|
||||
@@ -79,7 +79,7 @@ index 68cf6f0f0d2d1eb23de070ea8471111a41a9f9bf..615622f3ce63d2150c57cfd9f664bfa8
|
||||
+ this.player.isCommandAfk = true;
|
||||
+
|
||||
+ if (org.purpurmc.purpur.PurpurConfig.afkCommandCooldown > 0) {
|
||||
+ UUID uuid = this.player.getUUID();
|
||||
+ java.util.UUID uuid = this.player.getUUID();
|
||||
+ Long cooldown = afkCooldown.get(uuid);
|
||||
+ long currentTime = System.nanoTime();
|
||||
+
|
||||
@@ -99,17 +99,17 @@ index 68cf6f0f0d2d1eb23de070ea8471111a41a9f9bf..615622f3ce63d2150c57cfd9f664bfa8
|
||||
+ }
|
||||
+ // Leaf end - Improve Purpur AFK system
|
||||
+
|
||||
PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(this.getCraftPlayer(), command1, new LazyPlayerSet(this.server));
|
||||
PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(this.getCraftPlayer(), prefixedCommand, new LazyPlayerSet(this.server));
|
||||
this.cserver.getPluginManager().callEvent(event);
|
||||
|
||||
@@ -2351,11 +2379,37 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
@@ -2312,11 +2340,37 @@ public class ServerGamePacketListenerImpl
|
||||
|
||||
private void performSignedChatCommand(ServerboundChatCommandSignedPacket packet, LastSeenMessages lastSeenMessages) {
|
||||
// CraftBukkit start
|
||||
- String command = "/" + packet.command();
|
||||
+ String command = "/" + packet.command(); // Leaf start - Improve Purpur AFK system - diff on change
|
||||
if (org.spigotmc.SpigotConfig.logCommands) { // Paper - Add missing SpigotConfig logCommands check
|
||||
ServerGamePacketListenerImpl.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + command);
|
||||
LOGGER.info("{} issued server command: {}", this.player.getScoreboardName(), command);
|
||||
} // Paper - Add missing SpigotConfig logCommands check
|
||||
|
||||
+ // Leaf start - Improve Purpur AFK system
|
||||
@@ -118,7 +118,7 @@ index 68cf6f0f0d2d1eb23de070ea8471111a41a9f9bf..615622f3ce63d2150c57cfd9f664bfa8
|
||||
+ this.player.isCommandAfk = true;
|
||||
+
|
||||
+ if (org.purpurmc.purpur.PurpurConfig.afkCommandCooldown > 0) {
|
||||
+ UUID uuid = this.player.getUUID();
|
||||
+ java.util.UUID uuid = this.player.getUUID();
|
||||
+ Long cooldown = afkCooldown.get(uuid);
|
||||
+ long currentTime = System.nanoTime();
|
||||
+
|
||||
@@ -141,23 +141,23 @@ index 68cf6f0f0d2d1eb23de070ea8471111a41a9f9bf..615622f3ce63d2150c57cfd9f664bfa8
|
||||
PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(this.getCraftPlayer(), command, new LazyPlayerSet(this.server));
|
||||
this.cserver.getPluginManager().callEvent(event);
|
||||
command = event.getMessage().substring(1);
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 348c3c6a5d99fece14a9eb987a06934c8e8bac59..8efd2183309c285e0a7760922bf1b4766248d5f0 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -706,6 +706,7 @@ public abstract class PlayerList {
|
||||
org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerLeave(entityplayer); // Leaves - protocol
|
||||
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
||||
index 015c4480a60acc252342d58aa129350ab36dc29b..e4c3819de8af08f36cd30fafb6ce859005c5cb43 100644
|
||||
--- a/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/net/minecraft/server/players/PlayerList.java
|
||||
@@ -667,6 +667,7 @@ public abstract class PlayerList {
|
||||
org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerLeave(player); // Leaves - protocol
|
||||
// Paper end - Fix kick event leave message not being sent
|
||||
org.purpurmc.purpur.task.BossBarTask.removeFromAll(entityplayer.getBukkitEntity()); // Purpur
|
||||
+ net.minecraft.server.network.ServerGamePacketListenerImpl.afkCooldown.remove(entityplayer.getBukkitEntity().getUniqueId()); // Leaf - Improve Purpur AFK system
|
||||
ServerLevel worldserver = entityplayer.serverLevel();
|
||||
|
||||
entityplayer.awardStat(Stats.LEAVE_GAME);
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
index 05d77ccd9bf8ce0534fbac7d4354536e3187229f..aa1f5f69346a75af8e9b8dd185f211682a74db2c 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
@@ -179,9 +179,14 @@ public class PurpurConfig {
|
||||
org.purpurmc.purpur.task.BossBarTask.removeFromAll(player.getBukkitEntity()); // Purpur - Implement TPSBar
|
||||
+ net.minecraft.server.network.ServerGamePacketListenerImpl.afkCooldown.remove(player.getBukkitEntity().getUniqueId()); // Leaf - Improve Purpur AFK system
|
||||
ServerLevel serverLevel = player.serverLevel();
|
||||
player.awardStat(Stats.LEAVE_GAME);
|
||||
// CraftBukkit start - Quitting must be before we do final save of data, in case plugins need to modify it
|
||||
diff --git a/org/purpurmc/purpur/PurpurConfig.java b/org/purpurmc/purpur/PurpurConfig.java
|
||||
index b084fcbe57a1f57e97919aaa0b0c7d4ab5436bdf..7da226524f726fefee1dcd4e048661948074b49b 100644
|
||||
--- a/org/purpurmc/purpur/PurpurConfig.java
|
||||
+++ b/org/purpurmc/purpur/PurpurConfig.java
|
||||
@@ -175,9 +175,14 @@ public class PurpurConfig {
|
||||
public static String cannotRideMob = "<red>You cannot mount that mob";
|
||||
public static String afkBroadcastAway = "<yellow><italic>%s is now AFK";
|
||||
public static String afkBroadcastBack = "<yellow><italic>%s is no longer AFK";
|
||||
@@ -172,7 +172,7 @@ index 05d77ccd9bf8ce0534fbac7d4354536e3187229f..aa1f5f69346a75af8e9b8dd185f21168
|
||||
public static String creditsCommandOutput = "<green>%s has been shown the end credits";
|
||||
public static String demoCommandOutput = "<green>%s has been shown the demo screen";
|
||||
public static String pingCommandOutput = "<green>%s's ping is %sms";
|
||||
@@ -198,9 +203,14 @@ public class PurpurConfig {
|
||||
@@ -194,9 +199,14 @@ public class PurpurConfig {
|
||||
cannotRideMob = getString("settings.messages.cannot-ride-mob", cannotRideMob);
|
||||
afkBroadcastAway = getString("settings.messages.afk-broadcast-away", afkBroadcastAway);
|
||||
afkBroadcastBack = getString("settings.messages.afk-broadcast-back", afkBroadcastBack);
|
||||
@@ -187,46 +187,3 @@ index 05d77ccd9bf8ce0534fbac7d4354536e3187229f..aa1f5f69346a75af8e9b8dd185f21168
|
||||
creditsCommandOutput = getString("settings.messages.credits-command-output", creditsCommandOutput);
|
||||
demoCommandOutput = getString("settings.messages.demo-command-output", demoCommandOutput);
|
||||
pingCommandOutput = getString("settings.messages.ping-command-output", pingCommandOutput);
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/command/AFKCommand.java b/src/main/java/org/purpurmc/purpur/command/AFKCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..1b8eee9cce3ae069be7c97bd0840338e9287ce4e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/command/AFKCommand.java
|
||||
@@ -0,0 +1,37 @@
|
||||
+package org.purpurmc.purpur.command;
|
||||
+
|
||||
+import com.mojang.brigadier.CommandDispatcher;
|
||||
+import net.minecraft.commands.CommandSourceStack;
|
||||
+import net.minecraft.commands.Commands;
|
||||
+import net.minecraft.commands.arguments.EntityArgument;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+
|
||||
+import java.util.Collection;
|
||||
+import java.util.Collections;
|
||||
+
|
||||
+public class AFKCommand {
|
||||
+ public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
|
||||
+ dispatcher.register(Commands.literal("afk")
|
||||
+ .requires((listener) -> listener.hasPermission(2, "bukkit.command.afk"))
|
||||
+ .executes((context) -> execute(context.getSource(), Collections.singleton(context.getSource().getPlayerOrException())))
|
||||
+ .then(Commands.argument("targets", EntityArgument.players())
|
||||
+ .requires(listener -> listener.hasPermission(2, "bukkit.command.afk.other"))
|
||||
+ .executes((context) -> execute(context.getSource(), EntityArgument.getPlayers(context, "targets")))
|
||||
+ )
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
+ private static int execute(CommandSourceStack sender, Collection<ServerPlayer> targets) {
|
||||
+ for (ServerPlayer player : targets) {
|
||||
+ boolean afk = player.isCommandAfk
|
||||
+ ? !player.commandAfkStatus
|
||||
+ : !player.isAfk();
|
||||
+
|
||||
+ if (afk) player.setAfk(true);
|
||||
+
|
||||
+ player.isCommandAfk = false;
|
||||
+ }
|
||||
+
|
||||
+ return targets.size();
|
||||
+ }
|
||||
+}
|
||||
@@ -0,0 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
Date: Fri, 25 Oct 2024 02:27:21 +0800
|
||||
Subject: [PATCH] Virtual thread for chat executor
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 2ff6059d6bd3fe7c6814603c2ba0e6ccffe1873a..99fb4faa6e8f099ee216eb44793a1df0e6b8c137 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -2680,7 +2680,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
|
||||
public final java.util.concurrent.ExecutorService chatExecutor = java.util.concurrent.Executors.newCachedThreadPool(
|
||||
- new com.google.common.util.concurrent.ThreadFactoryBuilder().setDaemon(true).setNameFormat("Async Chat Thread - #%d").setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER)).build()); // Paper
|
||||
+ new com.google.common.util.concurrent.ThreadFactoryBuilder().setDaemon(true).setNameFormat("Async Chat Thread - #%d").setThreadFactory(org.dreeam.leaf.config.modules.opt.VT4ChatExecutor.enabled ? Thread.ofVirtual().factory() : java.util.concurrent.Executors.defaultThreadFactory()).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER)).build()); // Paper // Leaf - Virtual thread for chatExecutor
|
||||
public final ChatDecorator improvedChatDecorator = new io.papermc.paper.adventure.ImprovedChatDecorator(this); // Paper - adventure
|
||||
|
||||
public ChatDecorator getChatDecorator() {
|
||||
@@ -0,0 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
Date: Tue, 31 Dec 2024 00:00:00 -0800
|
||||
Subject: [PATCH] Virtual thread for User Authenticator
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
index 780d85f4afe221f8861b248457bfe6462f0b8a2a..b6f44bff24f48419a3a0157bb0ade9aa7c21e35e 100644
|
||||
--- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
@@ -55,7 +55,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||
// CraftBukkit end
|
||||
private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0);
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
- private static final java.util.concurrent.ExecutorService authenticatorPool = java.util.concurrent.Executors.newCachedThreadPool(new com.google.common.util.concurrent.ThreadFactoryBuilder().setNameFormat("User Authenticator #%d").setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)).build()); // Paper - Cache authenticator threads
|
||||
+ private static final java.util.concurrent.ExecutorService authenticatorPool = java.util.concurrent.Executors.newCachedThreadPool(new com.google.common.util.concurrent.ThreadFactoryBuilder().setNameFormat("User Authenticator #%d").setThreadFactory(org.dreeam.leaf.config.modules.opt.VT4UserAuthenticator.enabled ? Thread.ofVirtual().factory() : java.util.concurrent.Executors.defaultThreadFactory()).setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)).build()); // Paper - Cache authenticator threads // Leaf - Virtual thread for User Authenticator
|
||||
private static final int MAX_TICKS_BEFORE_LOGIN = 600;
|
||||
private final byte[] challenge;
|
||||
final MinecraftServer server;
|
||||
@@ -0,0 +1,195 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: etil2jz <81570777+etil2jz@users.noreply.github.com>
|
||||
Date: Tue, 2 Aug 2022 14:48:12 +0200
|
||||
Subject: [PATCH] Mirai: Configurable chat message signatures
|
||||
|
||||
Fixed & Updated by Dreeam-qwq
|
||||
Original license: GPLv3
|
||||
Original project: https://github.com/Dreeam-qwq/Mirai
|
||||
|
||||
Original license: GPLv3
|
||||
Original project: https://github.com/etil2jz/Mirai
|
||||
|
||||
diff --git a/net/minecraft/network/FriendlyByteBuf.java b/net/minecraft/network/FriendlyByteBuf.java
|
||||
index e5e5d9bc095ccd9fbf1c8aaa09e5c4ebb1d1c920..6a9373ceb14733504c433b5ab10f1f9da7cbbb37 100644
|
||||
--- a/net/minecraft/network/FriendlyByteBuf.java
|
||||
+++ b/net/minecraft/network/FriendlyByteBuf.java
|
||||
@@ -114,6 +114,16 @@ public class FriendlyByteBuf extends ByteBuf {
|
||||
public <T> void writeJsonWithCodec(Codec<T> codec, T value, int maxLength) {
|
||||
// Paper end - Adventure; add max length parameter
|
||||
DataResult<JsonElement> dataResult = codec.encodeStart(JsonOps.INSTANCE, value);
|
||||
+ // Leaf start - Configurable chat message signatures
|
||||
+ if (!org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled && codec == net.minecraft.network.protocol.status.ServerStatus.CODEC) {
|
||||
+ JsonElement element = dataResult.getOrThrow(string -> new EncoderException("Failed to encode: " + string + " " + value));
|
||||
+ element.getAsJsonObject().addProperty("preventsChatReports", true);
|
||||
+
|
||||
+ this.writeUtf(GSON.toJson(element));
|
||||
+ return;
|
||||
+ }
|
||||
+ // Leaf end - Configurable chat message signatures
|
||||
+
|
||||
this.writeUtf(GSON.toJson(dataResult.getOrThrow(exception -> new EncoderException("Failed to encode: " + exception + " " + value))), maxLength); // Paper - Adventure; add max length parameter
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/network/protocol/game/ClientboundLoginPacket.java b/net/minecraft/network/protocol/game/ClientboundLoginPacket.java
|
||||
index 89f06581e2b1f9f0240e7841db2f57dedc5d81b7..ba4ec05a9c9dfa958fdfa4a68ee85bcd9c379883 100644
|
||||
--- a/net/minecraft/network/protocol/game/ClientboundLoginPacket.java
|
||||
+++ b/net/minecraft/network/protocol/game/ClientboundLoginPacket.java
|
||||
@@ -55,7 +55,7 @@ public record ClientboundLoginPacket(
|
||||
buffer.writeBoolean(this.showDeathScreen);
|
||||
buffer.writeBoolean(this.doLimitedCrafting);
|
||||
this.commonPlayerSpawnInfo.write(buffer);
|
||||
- buffer.writeBoolean(this.enforcesSecureChat);
|
||||
+ buffer.writeBoolean(!org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled || this.enforcesSecureChat); // Leaf - Mirai - Configurable chat message signatures
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/net/minecraft/network/protocol/game/ServerboundChatPacket.java b/net/minecraft/network/protocol/game/ServerboundChatPacket.java
|
||||
index b5afc05924ae899e020c303c8b86398e1d4ab8a0..73c2ed488c34cddbafdcbb6f2636264ebcc7286b 100644
|
||||
--- a/net/minecraft/network/protocol/game/ServerboundChatPacket.java
|
||||
+++ b/net/minecraft/network/protocol/game/ServerboundChatPacket.java
|
||||
@@ -23,7 +23,7 @@ public record ServerboundChatPacket(String message, Instant timeStamp, long salt
|
||||
buffer.writeUtf(this.message, 256);
|
||||
buffer.writeInstant(this.timeStamp);
|
||||
buffer.writeLong(this.salt);
|
||||
- buffer.writeNullable(this.signature, MessageSignature::write);
|
||||
+ if (org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled) buffer.writeNullable(this.signature, MessageSignature::write); // Leaf - Mirai - Configurable chat message signatures
|
||||
this.lastSeenMessages.write(buffer);
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/network/protocol/status/ServerStatus.java b/net/minecraft/network/protocol/status/ServerStatus.java
|
||||
index 30bd254542d631676494f349ff3f44f52d54ab2f..63e6411d8bac1629e143cc620fe35dbac39346e9 100644
|
||||
--- a/net/minecraft/network/protocol/status/ServerStatus.java
|
||||
+++ b/net/minecraft/network/protocol/status/ServerStatus.java
|
||||
@@ -23,7 +23,10 @@ public record ServerStatus(
|
||||
boolean enforcesSecureChat
|
||||
) {
|
||||
public static final Codec<ServerStatus> CODEC = RecordCodecBuilder.create(
|
||||
- instance -> instance.group(
|
||||
+ // Leaf start - Mirai - Configurable chat message signatures
|
||||
+ instance ->
|
||||
+ org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled
|
||||
+ ? instance.group(
|
||||
ComponentSerialization.CODEC.lenientOptionalFieldOf("description", CommonComponents.EMPTY).forGetter(ServerStatus::description),
|
||||
ServerStatus.Players.CODEC.lenientOptionalFieldOf("players").forGetter(ServerStatus::players),
|
||||
ServerStatus.Version.CODEC.lenientOptionalFieldOf("version").forGetter(ServerStatus::version),
|
||||
@@ -31,6 +34,15 @@ public record ServerStatus(
|
||||
Codec.BOOL.lenientOptionalFieldOf("enforcesSecureChat", Boolean.valueOf(false)).forGetter(ServerStatus::enforcesSecureChat)
|
||||
)
|
||||
.apply(instance, ServerStatus::new)
|
||||
+ : instance.group(
|
||||
+ ComponentSerialization.CODEC.lenientOptionalFieldOf("description", CommonComponents.EMPTY).forGetter(ServerStatus::description),
|
||||
+ ServerStatus.Players.CODEC.lenientOptionalFieldOf("players").forGetter(ServerStatus::players),
|
||||
+ ServerStatus.Version.CODEC.lenientOptionalFieldOf("version").forGetter(ServerStatus::version),
|
||||
+ ServerStatus.Favicon.CODEC.lenientOptionalFieldOf("favicon").forGetter(ServerStatus::favicon),
|
||||
+ Codec.BOOL.lenientOptionalFieldOf("enforcesSecureChat", Boolean.FALSE).forGetter(x -> true)
|
||||
+ )
|
||||
+ .apply(instance, ServerStatus::new)
|
||||
+ // Leaf end- Mirai - Configurable chat message signatures
|
||||
);
|
||||
|
||||
public record Favicon(byte[] iconBytes) {
|
||||
diff --git a/net/minecraft/network/protocol/status/ServerStatus.java.rej b/net/minecraft/network/protocol/status/ServerStatus.java.rej
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..04a6f2fe6563665d8432789e3cbb3278a9408669
|
||||
--- /dev/null
|
||||
+++ b/net/minecraft/network/protocol/status/ServerStatus.java.rej
|
||||
@@ -0,0 +1,31 @@
|
||||
+diff a/net/minecraft/network/protocol/status/ServerStatus.java b/net/minecraft/network/protocol/status/ServerStatus.java (rejected hunks)
|
||||
+@@ -22,8 +22,11 @@ public record ServerStatus(
|
||||
+ Optional<ServerStatus.Favicon> favicon,
|
||||
+ boolean enforcesSecureChat
|
||||
+ ) {
|
||||
++ // Leaf start - Mirai - Configurable chat message signatures
|
||||
+ public static final Codec<ServerStatus> CODEC = RecordCodecBuilder.create(
|
||||
+- instance -> instance.group(
|
||||
++ instance ->
|
||||
++ org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled
|
||||
++ ? instance.group(
|
||||
+ ComponentSerialization.CODEC.lenientOptionalFieldOf("description", CommonComponents.EMPTY).forGetter(ServerStatus::description),
|
||||
+ ServerStatus.Players.CODEC.lenientOptionalFieldOf("players").forGetter(ServerStatus::players),
|
||||
+ ServerStatus.Version.CODEC.lenientOptionalFieldOf("version").forGetter(ServerStatus::version),
|
||||
+@@ -31,7 +34,16 @@ public record ServerStatus(
|
||||
+ Codec.BOOL.lenientOptionalFieldOf("enforcesSecureChat", Boolean.valueOf(false)).forGetter(ServerStatus::enforcesSecureChat)
|
||||
+ )
|
||||
+ .apply(instance, ServerStatus::new)
|
||||
++ : instance.group(
|
||||
++ ComponentSerialization.CODEC.lenientOptionalFieldOf("description", CommonComponents.EMPTY).forGetter(ServerStatus::description),
|
||||
++ ServerStatus.Players.CODEC.lenientOptionalFieldOf("players").forGetter(ServerStatus::players),
|
||||
++ ServerStatus.Version.CODEC.lenientOptionalFieldOf("version").forGetter(ServerStatus::version),
|
||||
++ ServerStatus.Favicon.CODEC.lenientOptionalFieldOf("favicon").forGetter(ServerStatus::favicon),
|
||||
++ Codec.BOOL.lenientOptionalFieldOf("enforcesSecureChat", Boolean.FALSE).forGetter(x -> true)
|
||||
++ )
|
||||
++ .apply(instance, ServerStatus::new)
|
||||
+ );
|
||||
++ // Leaf end- Mirai - Configurable chat message signatures
|
||||
+
|
||||
+ public static record Favicon(byte[] iconBytes) {
|
||||
+ private static final String PREFIX = "data:image/png;base64,";
|
||||
diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 22b0f33dc3ef9f51ba2ca3cb665b07a16bd1c9d9..7b1e5addd6a1b815498233ba9032f224494af12a 100644
|
||||
--- a/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -667,6 +667,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
|
||||
@Override
|
||||
public boolean enforceSecureProfile() {
|
||||
+ if (!org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled) return false; // Leaf - Mirai - Configurable chat message signatures
|
||||
DedicatedServerProperties properties = this.getProperties();
|
||||
// Paper start - Add setting for proxy online mode status
|
||||
return properties.enforceSecureProfile
|
||||
diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
index ee8cdd532b73180cb484fcc37c36f09c40faacda..eb388c1c94bc6feda6c8757b1800d158fbf48a12 100644
|
||||
--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
@@ -318,10 +318,29 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
}
|
||||
|
||||
public void send(Packet<?> packet) {
|
||||
+ // Leaf start - Mirai - Configurable chat message signatures
|
||||
+ if (!org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled) {
|
||||
+ if (packet instanceof net.minecraft.network.protocol.game.ClientboundPlayerChatPacket chat) {
|
||||
+ packet = new net.minecraft.network.protocol.game.ClientboundSystemChatPacket(
|
||||
+ chat.chatType().decorate(chat.unsignedContent() != null ? chat.unsignedContent() : Component.literal(chat.body().content())), false);
|
||||
+
|
||||
+ this.send(packet);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaf end - Mirai - Configurable chat message signatures
|
||||
this.send(packet, null);
|
||||
}
|
||||
|
||||
public void send(Packet<?> packet, @Nullable PacketSendListener listener) {
|
||||
+ // Leaf start - Mirai - Configurable chat message signatures
|
||||
+ if (!org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled) {
|
||||
+ if (packet instanceof net.minecraft.network.protocol.game.ClientboundPlayerChatPacket chat && listener != null) {
|
||||
+ this.send(chat);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaf end - Mirai - Configurable chat message signatures
|
||||
// CraftBukkit start
|
||||
if (packet == null || this.processedDisconnect) { // Spigot
|
||||
return;
|
||||
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
||||
index e4c3819de8af08f36cd30fafb6ce859005c5cb43..b98e854fb9fad65b176b4915214a0a4c5e424d6c 100644
|
||||
--- a/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/net/minecraft/server/players/PlayerList.java
|
||||
@@ -1509,7 +1509,7 @@ public abstract class PlayerList {
|
||||
public void broadcastChatMessage(PlayerChatMessage message, Predicate<ServerPlayer> shouldFilterMessageTo, @Nullable ServerPlayer sender, ChatType.Bound boundChatType, @Nullable Function<net.kyori.adventure.audience.Audience, Component> unsignedFunction) {
|
||||
// Paper end
|
||||
boolean flag = this.verifyChatTrusted(message);
|
||||
- this.server.logChatMessage((unsignedFunction == null ? message.decoratedContent() : unsignedFunction.apply(this.server.console)), boundChatType, flag || !org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.chat.notSecureMarker ? null : "Not Secure"); // Paper // Gale - do not log Not Secure marker
|
||||
+ this.server.logChatMessage((unsignedFunction == null ? message.decoratedContent() : unsignedFunction.apply(this.server.console)), boundChatType, !org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled || flag || !org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.chat.notSecureMarker ? null : "Not Secure"); // Paper // Gale - do not log Not Secure marker // Leaf - Mirai - Configurable chat message signatures
|
||||
OutgoingChatMessage outgoingChatMessage = OutgoingChatMessage.create(message);
|
||||
boolean flag1 = false;
|
||||
|
||||
@@ -1534,6 +1534,7 @@ public abstract class PlayerList {
|
||||
}
|
||||
|
||||
public boolean verifyChatTrusted(PlayerChatMessage message) { // Paper - private -> public
|
||||
+ if (!org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled) return true; // Leaf - Mirai - Configurable chat message signatures
|
||||
return message.hasSignature() && !message.hasExpiredServer(Instant.now());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Thu, 28 Mar 2024 13:36:09 -0400
|
||||
Subject: [PATCH] Cache player profileResult
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
index b6f44bff24f48419a3a0157bb0ade9aa7c21e35e..b049304a80dc29c3087cff56c45c2c83679e47ff 100644
|
||||
--- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
@@ -71,6 +71,11 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||
private net.minecraft.server.level.ServerPlayer player; // CraftBukkit
|
||||
public boolean iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation = false; // Paper - username validation overriding
|
||||
private int velocityLoginMessageId = -1; // Paper - Add Velocity IP Forwarding Support
|
||||
+ // Leaf start - Cache player profileResult
|
||||
+ private static final com.github.benmanes.caffeine.cache.Cache<String, ProfileResult> playerProfileResultCahce = com.github.benmanes.caffeine.cache.Caffeine.newBuilder()
|
||||
+ .expireAfterWrite(org.dreeam.leaf.config.modules.misc.Cache.cachePlayerProfileResultTimeout, java.util.concurrent.TimeUnit.MINUTES)
|
||||
+ .build();
|
||||
+ // Leaf end - Cache player profileResult
|
||||
|
||||
public ServerLoginPacketListenerImpl(MinecraftServer server, Connection connection, boolean transferred) {
|
||||
this.server = server;
|
||||
@@ -302,9 +307,23 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||
String string1 = Objects.requireNonNull(ServerLoginPacketListenerImpl.this.requestedUsername, "Player name not initialized");
|
||||
|
||||
try {
|
||||
- ProfileResult profileResult = ServerLoginPacketListenerImpl.this.server
|
||||
- .getSessionService()
|
||||
- .hasJoinedServer(string1, string, this.getAddress());
|
||||
+ // Leaf start - Cache player profileResult
|
||||
+ ProfileResult profileResult;
|
||||
+ if (org.dreeam.leaf.config.modules.misc.Cache.cachePlayerProfileResult) {
|
||||
+ profileResult = playerProfileResultCahce.getIfPresent(string1);
|
||||
+
|
||||
+ if (profileResult == null) {
|
||||
+ profileResult = ServerLoginPacketListenerImpl.this.server
|
||||
+ .getSessionService()
|
||||
+ .hasJoinedServer(string1, string, this.getAddress());
|
||||
+ playerProfileResultCahce.put(string1, profileResult);
|
||||
+ }
|
||||
+ } else {
|
||||
+ profileResult = ServerLoginPacketListenerImpl.this.server
|
||||
+ .getSessionService()
|
||||
+ .hasJoinedServer(string1, string, this.getAddress());
|
||||
+ }
|
||||
+ // Leaf end - Cache player profileResult
|
||||
if (profileResult != null) {
|
||||
GameProfile gameProfile = profileResult.profile();
|
||||
// CraftBukkit start - fire PlayerPreLoginEvent
|
||||
@@ -0,0 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Thu, 28 Mar 2024 14:04:35 -0400
|
||||
Subject: [PATCH] Prevent change non-editable sign warning spam in console
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/level/block/entity/SignBlockEntity.java b/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||
index 662f53ca5826fb5b68eb4d426f1d9c5d83906eaf..e0a519af9a567eb660fad5ae55c95900fc2472f5 100644
|
||||
--- a/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||
@@ -152,7 +152,7 @@ public class SignBlockEntity extends BlockEntity {
|
||||
this.setAllowedPlayerEditor(null);
|
||||
this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), 3);
|
||||
} else {
|
||||
- LOGGER.warn("Player {} just tried to change non-editable sign", player.getName().getString());
|
||||
+ if (!org.dreeam.leaf.config.modules.misc.RemoveChangeNonEditableSignWarning.enabled) LOGGER.warn("Player {} just tried to change non-editable sign", player.getName().getString()); // Leaf - Remove change non-editable sign warning
|
||||
if (player.distanceToSqr(this.getBlockPos().getX(), this.getBlockPos().getY(), this.getBlockPos().getZ()) < Mth.square(32)) // Paper - Don't send far away sign update
|
||||
((net.minecraft.server.level.ServerPlayer) player).connection.send(this.getUpdatePacket()); // CraftBukkit
|
||||
}
|
||||
@@ -0,0 +1,436 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Apehum <apehumchik@gmail.com>
|
||||
Date: Thu, 9 Dec 2021 02:18:17 +0800
|
||||
Subject: [PATCH] Matter: Secure Seed
|
||||
|
||||
TODO - Dreeam:
|
||||
Update to BLAKE3
|
||||
|
||||
Original license: GPLv3
|
||||
Original project: https://github.com/plasmoapp/matter
|
||||
|
||||
Co-authored-by: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Co-authored-by: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
|
||||
diff --git a/net/minecraft/server/dedicated/DedicatedServerProperties.java b/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||
index 5748658abf0b90812005ae9d426df92daf5532f0..bb404b4cfdc364b21cb322bc142f9e72384397d0 100644
|
||||
--- a/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||
+++ b/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||
@@ -114,7 +114,17 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
||||
String string = this.get("level-seed", "");
|
||||
boolean flag = this.get("generate-structures", true);
|
||||
long l = WorldOptions.parseSeed(string).orElse(WorldOptions.randomSeed());
|
||||
- this.worldOptions = new WorldOptions(l, flag, false);
|
||||
+ // Leaf start - Matter - Feature Secure Seed
|
||||
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||
+ String featureSeedStr = this.get("feature-level-seed", "");
|
||||
+ long[] featureSeed = su.plo.matter.Globals.parseSeed(featureSeedStr)
|
||||
+ .orElse(su.plo.matter.Globals.createRandomWorldSeed());
|
||||
+
|
||||
+ this.worldOptions = new WorldOptions(l, featureSeed, flag, false);
|
||||
+ } else {
|
||||
+ this.worldOptions = new WorldOptions(l, flag, false);
|
||||
+ }
|
||||
+ // Leaf end - Matter - Feature Secure Seed
|
||||
this.worldDimensionData = new DedicatedServerProperties.WorldDimensionData(
|
||||
this.get("generator-settings", property -> GsonHelper.parse(!property.isEmpty() ? property : "{}"), new JsonObject()),
|
||||
this.get("level-type", property -> property.toLowerCase(Locale.ROOT), WorldPresets.NORMAL.location().toString())
|
||||
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 77676b38912e558a4ba0c65a009af4cdc531c5fa..eacebc190a1f598314a8b812629fecd86d87ff7c 100644
|
||||
--- a/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -697,6 +697,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
}
|
||||
|
||||
public ChunkGenerator getGenerator() {
|
||||
+ su.plo.matter.Globals.setupGlobals(level); // Leaf - Matter - Feature Secure Seed
|
||||
return this.chunkMap.generator();
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
||||
index bf364e3fad2823400ec671bc632ba50751a3f473..b3c388f6108360708baf275121af18f46622494f 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -633,6 +633,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
chunkGenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkGenerator, gen);
|
||||
}
|
||||
// CraftBukkit end
|
||||
+ su.plo.matter.Globals.setupGlobals(this); // Leaf - Matter - Feature Secure Seed
|
||||
boolean flag = server.forceSynchronousWrites();
|
||||
DataFixer fixerUpper = server.getFixerUpper();
|
||||
// Paper - rewrite chunk system
|
||||
diff --git a/net/minecraft/world/entity/monster/Slime.java b/net/minecraft/world/entity/monster/Slime.java
|
||||
index 240a54b210e23d5b79e6bcaf3806aa454668135d..d075c7afaddc7102eed64ef4bd2b096e4972153a 100644
|
||||
--- a/net/minecraft/world/entity/monster/Slime.java
|
||||
+++ b/net/minecraft/world/entity/monster/Slime.java
|
||||
@@ -424,7 +424,12 @@ public class Slime extends Mob implements Enemy {
|
||||
}
|
||||
|
||||
ChunkPos chunkPos = new ChunkPos(pos);
|
||||
- boolean flag = level.getMinecraftWorld().paperConfig().entities.spawning.allChunksAreSlimeChunks || WorldgenRandom.seedSlimeChunk(chunkPos.x, chunkPos.z, ((WorldGenLevel) level).getSeed(), level.getMinecraftWorld().spigotConfig.slimeSeed).nextInt(10) == 0; // Spigot // Paper
|
||||
+ // Leaf start - Matter - Feature Secure Seed
|
||||
+ boolean isSlimeChunk = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled
|
||||
+ ? level.getChunk(chunkPos.x, chunkPos.z).isSlimeChunk()
|
||||
+ : WorldgenRandom.seedSlimeChunk(chunkPos.x, chunkPos.z, ((WorldGenLevel) level).getSeed(), level.getMinecraftWorld().spigotConfig.slimeSeed).nextInt(10) == 0; // Spigot // Paper
|
||||
+ boolean flag = level.getMinecraftWorld().paperConfig().entities.spawning.allChunksAreSlimeChunks || isSlimeChunk;
|
||||
+ // Leaf end - Matter - Feature Secure Seed
|
||||
// Paper start - Replace rules for Height in Slime Chunks
|
||||
final double maxHeightSlimeChunk = level.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.slimeChunk.maximum;
|
||||
if (random.nextInt(10) == 0 && flag && pos.getY() < maxHeightSlimeChunk) {
|
||||
diff --git a/net/minecraft/world/level/chunk/ChunkAccess.java b/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
index 6d565b52552534ce9cacfc35ad1bf4adcb69eac3..1e7df840abb7aab466770ff35429e7c300dff4ac 100644
|
||||
--- a/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
+++ b/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
@@ -87,6 +87,10 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh
|
||||
public org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer(ChunkAccess.DATA_TYPE_REGISTRY);
|
||||
// CraftBukkit end
|
||||
public final Registry<Biome> biomeRegistry; // CraftBukkit
|
||||
+ // Leaf start - Matter - Feature Secure Seed
|
||||
+ private boolean slimeChunk;
|
||||
+ private boolean hasComputedSlimeChunk;
|
||||
+ // Leaf end - Matter - Feature Secure Seed
|
||||
|
||||
// Paper start - rewrite chunk system
|
||||
private volatile ca.spottedleaf.moonrise.patches.starlight.light.SWMRNibbleArray[] blockNibbles;
|
||||
@@ -191,6 +195,17 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh
|
||||
return GameEventListenerRegistry.NOOP;
|
||||
}
|
||||
|
||||
+ // Leaf start - Matter - Feature Secure Seed
|
||||
+ public boolean isSlimeChunk() {
|
||||
+ if (!hasComputedSlimeChunk) {
|
||||
+ hasComputedSlimeChunk = true;
|
||||
+ slimeChunk = su.plo.matter.WorldgenCryptoRandom.seedSlimeChunk(chunkPos.x, chunkPos.z).nextInt(10) == 0;
|
||||
+ }
|
||||
+
|
||||
+ return slimeChunk;
|
||||
+ }
|
||||
+ // Leaf end - Matter - Feature Secure Seed
|
||||
+
|
||||
public abstract BlockState getBlockState(final int x, final int y, final int z); // Paper
|
||||
@Nullable
|
||||
public abstract BlockState setBlockState(BlockPos pos, BlockState state, boolean isMoving);
|
||||
diff --git a/net/minecraft/world/level/chunk/ChunkGenerator.java b/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||
index 6ed51cf42b5864194d671b5b56f5b9bdf0291dc0..2b19e989b4475e905d77bf9d47403c724b81fccd 100644
|
||||
--- a/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||
+++ b/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||
@@ -343,7 +343,11 @@ public abstract class ChunkGenerator {
|
||||
Registry<Structure> registry = level.registryAccess().lookupOrThrow(Registries.STRUCTURE);
|
||||
Map<Integer, List<Structure>> map = registry.stream().collect(Collectors.groupingBy(structure1 -> structure1.step().ordinal()));
|
||||
List<FeatureSorter.StepFeatureData> list = this.featuresPerStep.get();
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new XoroshiroRandomSource(RandomSupport.generateUniqueSeed()));
|
||||
+ // Leaf start - Matter - Feature Secure Seed
|
||||
+ WorldgenRandom worldgenRandom = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled
|
||||
+ ? new su.plo.matter.WorldgenCryptoRandom(blockPos.getX(), blockPos.getZ(), su.plo.matter.Globals.Salt.UNDEFINED, 0)
|
||||
+ : new WorldgenRandom(new XoroshiroRandomSource(RandomSupport.generateUniqueSeed()));
|
||||
+ // Leaf end - Matter - Feature Secure Seed
|
||||
long l = worldgenRandom.setDecorationSeed(level.getSeed(), blockPos.getX(), blockPos.getZ());
|
||||
Set<Holder<Biome>> set = new ObjectArraySet<>();
|
||||
ChunkPos.rangeClosed(sectionPos.chunk(), 1).forEach(chunkPos -> {
|
||||
@@ -556,8 +560,17 @@ public abstract class ChunkGenerator {
|
||||
} else {
|
||||
ArrayList<StructureSet.StructureSelectionEntry> list1 = new ArrayList<>(list.size());
|
||||
list1.addAll(list);
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
- worldgenRandom.setLargeFeatureSeed(structureState.getLevelSeed(), pos.x, pos.z);
|
||||
+ // Leaf start - Matter - Feature Secure Seed
|
||||
+ WorldgenRandom worldgenRandom;
|
||||
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||
+ worldgenRandom = new su.plo.matter.WorldgenCryptoRandom(
|
||||
+ pos.x, pos.z, su.plo.matter.Globals.Salt.GENERATE_FEATURE, 0
|
||||
+ );
|
||||
+ } else {
|
||||
+ worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
+ worldgenRandom.setLargeFeatureSeed(structureState.getLevelSeed(), pos.x, pos.z);
|
||||
+ }
|
||||
+ // Leaf end - Matter - Feature Secure Seed
|
||||
int i = 0;
|
||||
|
||||
for (StructureSet.StructureSelectionEntry structureSelectionEntry1 : list1) {
|
||||
diff --git a/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java b/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
||||
index 4483d7764ddca635fb6fb841fdc2185357106fc5..19b5d09d4f185a4f1600baade21bd897a6c8b849 100644
|
||||
--- a/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
||||
+++ b/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
||||
@@ -205,7 +205,11 @@ public class ChunkGeneratorStructureState {
|
||||
List<CompletableFuture<ChunkPos>> list = new ArrayList<>(count);
|
||||
int spread = placement.spread();
|
||||
HolderSet<Biome> holderSet = placement.preferredBiomes();
|
||||
- RandomSource randomSource = RandomSource.create();
|
||||
+ // Leaf start - Matter - Feature Secure Seed
|
||||
+ RandomSource randomSource = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled
|
||||
+ ? new su.plo.matter.WorldgenCryptoRandom(0, 0, su.plo.matter.Globals.Salt.STRONGHOLDS, 0)
|
||||
+ : RandomSource.create();
|
||||
+ if (!org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||
// Paper start - Add missing structure set seed configs
|
||||
if (this.conf.strongholdSeed != null && structureSet.is(net.minecraft.world.level.levelgen.structure.BuiltinStructureSets.STRONGHOLDS)) {
|
||||
randomSource.setSeed(this.conf.strongholdSeed);
|
||||
@@ -213,6 +217,7 @@ public class ChunkGeneratorStructureState {
|
||||
// Paper end - Add missing structure set seed configs
|
||||
randomSource.setSeed(this.concentricRingsSeed);
|
||||
} // Paper - Add missing structure set seed configs
|
||||
+ } // Leaf end - Matter - Feature Secure Seed
|
||||
double d = randomSource.nextDouble() * Math.PI * 2.0;
|
||||
int i = 0;
|
||||
int i1 = 0;
|
||||
diff --git a/net/minecraft/world/level/chunk/status/ChunkStep.java b/net/minecraft/world/level/chunk/status/ChunkStep.java
|
||||
index b8348976e80578d9eff64eea68c04c603fed49ad..37735784e26651456c32c6b392bce53a8416529d 100644
|
||||
--- a/net/minecraft/world/level/chunk/status/ChunkStep.java
|
||||
+++ b/net/minecraft/world/level/chunk/status/ChunkStep.java
|
||||
@@ -60,6 +60,7 @@ public final class ChunkStep implements ca.spottedleaf.moonrise.patches.chunk_sy
|
||||
}
|
||||
|
||||
public CompletableFuture<ChunkAccess> apply(WorldGenContext worldGenContext, StaticCache2D<GenerationChunkHolder> cache, ChunkAccess chunk) {
|
||||
+ su.plo.matter.Globals.setupGlobals(worldGenContext.level()); // Leaf - Matter - Feature Secure Seed
|
||||
if (chunk.getPersistedStatus().isBefore(this.targetStatus)) {
|
||||
ProfiledDuration profiledDuration = JvmProfiler.INSTANCE
|
||||
.onChunkGenerate(chunk.getPos(), worldGenContext.level().dimension(), this.targetStatus.getName());
|
||||
diff --git a/net/minecraft/world/level/levelgen/WorldOptions.java b/net/minecraft/world/level/levelgen/WorldOptions.java
|
||||
index c92508741439a8d0d833ea02d0104416adb83c92..782769443515fa084c51f2f6a3c711cfd830b926 100644
|
||||
--- a/net/minecraft/world/level/levelgen/WorldOptions.java
|
||||
+++ b/net/minecraft/world/level/levelgen/WorldOptions.java
|
||||
@@ -9,8 +9,20 @@ import net.minecraft.util.RandomSource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class WorldOptions {
|
||||
+ // Leaf start - Matter - Feature Secure Seed
|
||||
+ private static final com.google.gson.Gson gson = new com.google.gson.Gson();
|
||||
+ private static final boolean isSecureSeedEnabled = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled;
|
||||
public static final MapCodec<WorldOptions> CODEC = RecordCodecBuilder.mapCodec(
|
||||
- instance -> instance.group(
|
||||
+ instance -> isSecureSeedEnabled
|
||||
+ ? instance.group(
|
||||
+ Codec.LONG.fieldOf("seed").stable().forGetter(WorldOptions::seed),
|
||||
+ Codec.STRING.fieldOf("feature_seed").orElse(gson.toJson(su.plo.matter.Globals.createRandomWorldSeed())).stable().forGetter(WorldOptions::featureSeedSerialize),
|
||||
+ Codec.BOOL.fieldOf("generate_features").orElse(true).stable().forGetter(WorldOptions::generateStructures),
|
||||
+ Codec.BOOL.fieldOf("bonus_chest").orElse(false).stable().forGetter(WorldOptions::generateBonusChest),
|
||||
+ Codec.STRING.lenientOptionalFieldOf("legacy_custom_options").stable().forGetter(worldOptions -> worldOptions.legacyCustomOptions)
|
||||
+ )
|
||||
+ .apply(instance, instance.stable(WorldOptions::new))
|
||||
+ : instance.group(
|
||||
Codec.LONG.fieldOf("seed").stable().forGetter(WorldOptions::seed),
|
||||
Codec.BOOL.fieldOf("generate_features").orElse(true).stable().forGetter(WorldOptions::generateStructures),
|
||||
Codec.BOOL.fieldOf("bonus_chest").orElse(false).stable().forGetter(WorldOptions::generateBonusChest),
|
||||
@@ -18,8 +30,14 @@ public class WorldOptions {
|
||||
)
|
||||
.apply(instance, instance.stable(WorldOptions::new))
|
||||
);
|
||||
- public static final WorldOptions DEMO_OPTIONS = new WorldOptions("North Carolina".hashCode(), true, true);
|
||||
+ // Leaf end - Matter - Feature Secure Seed
|
||||
+ // Leaf start - Matter - Feature Secure Seed
|
||||
+ public static final WorldOptions DEMO_OPTIONS = isSecureSeedEnabled
|
||||
+ ? new WorldOptions((long) "North Carolina".hashCode(), su.plo.matter.Globals.createRandomWorldSeed(), true, true)
|
||||
+ : new WorldOptions("North Carolina".hashCode(), true, true);
|
||||
+ // Leaf end - Matter - Feature Secure Seed
|
||||
private final long seed;
|
||||
+ private long[] featureSeed = su.plo.matter.Globals.createRandomWorldSeed(); // Leaf - Matter - Feature Secure Seed
|
||||
private final boolean generateStructures;
|
||||
private final boolean generateBonusChest;
|
||||
private final Optional<String> legacyCustomOptions;
|
||||
@@ -28,14 +46,35 @@ public class WorldOptions {
|
||||
this(seed, generateStructures, generateBonusChest, Optional.empty());
|
||||
}
|
||||
|
||||
+ // Leaf start - Matter - Feature Secure Seed
|
||||
+ public WorldOptions(long seed, long[] featureSeed, boolean generateStructures, boolean bonusChest) {
|
||||
+ this(seed, featureSeed, generateStructures, bonusChest, Optional.empty());
|
||||
+ }
|
||||
+
|
||||
+ private WorldOptions(long seed, String featureSeedJson, boolean generateStructures, boolean bonusChest, Optional<String> legacyCustomOptions) {
|
||||
+ this(seed, gson.fromJson(featureSeedJson, long[].class), generateStructures, bonusChest, legacyCustomOptions);
|
||||
+ }
|
||||
+ // Leaf end - Matter - Feature Secure Seed
|
||||
+
|
||||
public static WorldOptions defaultWithRandomSeed() {
|
||||
- return new WorldOptions(randomSeed(), true, false);
|
||||
+ // Leaf start - Matter - Feature Secure Seed
|
||||
+ return isSecureSeedEnabled
|
||||
+ ? new WorldOptions(randomSeed(), su.plo.matter.Globals.createRandomWorldSeed(), true, false)
|
||||
+ : new WorldOptions(randomSeed(), true, false);
|
||||
+ // Leaf end - Matter - Feature Secure Seed
|
||||
}
|
||||
|
||||
public static WorldOptions testWorldWithRandomSeed() {
|
||||
return new WorldOptions(randomSeed(), false, false);
|
||||
}
|
||||
|
||||
+ // Leaf start - Matter - Feature Secure Seed
|
||||
+ private WorldOptions(long seed, long[] featureSeed, boolean generateStructures, boolean bonusChest, Optional<String> legacyCustomOptions) {
|
||||
+ this(seed, generateStructures, bonusChest, legacyCustomOptions);
|
||||
+ this.featureSeed = featureSeed;
|
||||
+ }
|
||||
+ // Leaf end - Matter - Feature Secure Seed
|
||||
+
|
||||
private WorldOptions(long seed, boolean generateStructures, boolean generateBonusChest, Optional<String> legacyCustomOptions) {
|
||||
this.seed = seed;
|
||||
this.generateStructures = generateStructures;
|
||||
@@ -47,6 +86,16 @@ public class WorldOptions {
|
||||
return this.seed;
|
||||
}
|
||||
|
||||
+ // Leaf start - Matter - Feature Secure Seed
|
||||
+ public long[] featureSeed() {
|
||||
+ return this.featureSeed;
|
||||
+ }
|
||||
+
|
||||
+ public String featureSeedSerialize() {
|
||||
+ return gson.toJson(this.featureSeed);
|
||||
+ }
|
||||
+ // Leaf end - Matter - Feature Secure Seed
|
||||
+
|
||||
public boolean generateStructures() {
|
||||
return this.generateStructures;
|
||||
}
|
||||
@@ -59,17 +108,25 @@ public class WorldOptions {
|
||||
return this.legacyCustomOptions.isPresent();
|
||||
}
|
||||
|
||||
+ // Leaf start - Matter - Feature Secure Seed
|
||||
public WorldOptions withBonusChest(boolean generateBonusChest) {
|
||||
- return new WorldOptions(this.seed, this.generateStructures, generateBonusChest, this.legacyCustomOptions);
|
||||
+ return isSecureSeedEnabled
|
||||
+ ? new WorldOptions(this.seed, this.featureSeed, this.generateStructures, generateBonusChest, this.legacyCustomOptions)
|
||||
+ : new WorldOptions(this.seed, this.generateStructures, generateBonusChest, this.legacyCustomOptions);
|
||||
}
|
||||
|
||||
public WorldOptions withStructures(boolean generateStructures) {
|
||||
- return new WorldOptions(this.seed, generateStructures, this.generateBonusChest, this.legacyCustomOptions);
|
||||
+ return isSecureSeedEnabled
|
||||
+ ? new WorldOptions(this.seed, this.featureSeed, generateStructures, this.generateBonusChest, this.legacyCustomOptions)
|
||||
+ : new WorldOptions(this.seed, generateStructures, this.generateBonusChest, this.legacyCustomOptions);
|
||||
}
|
||||
|
||||
public WorldOptions withSeed(OptionalLong seed) {
|
||||
- return new WorldOptions(seed.orElse(randomSeed()), this.generateStructures, this.generateBonusChest, this.legacyCustomOptions);
|
||||
+ return isSecureSeedEnabled
|
||||
+ ? new WorldOptions(seed.orElse(randomSeed()), su.plo.matter.Globals.createRandomWorldSeed(), this.generateStructures, this.generateBonusChest, this.legacyCustomOptions)
|
||||
+ : new WorldOptions(seed.orElse(randomSeed()), this.generateStructures, this.generateBonusChest, this.legacyCustomOptions);
|
||||
}
|
||||
+ // Leaf end - Matter - Feature Secure Seed
|
||||
|
||||
public static OptionalLong parseSeed(String seed) {
|
||||
seed = seed.trim();
|
||||
diff --git a/net/minecraft/world/level/levelgen/feature/GeodeFeature.java b/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
||||
index 38475f6975533909924c8d54f438cf43cdfe31a3..e416b27c7f6604349766d44284ee004d5f62d9b2 100644
|
||||
--- a/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
||||
+++ b/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
||||
@@ -41,7 +41,11 @@ public class GeodeFeature extends Feature<GeodeConfiguration> {
|
||||
int i1 = geodeConfiguration.maxGenOffset;
|
||||
List<Pair<BlockPos, Integer>> list = Lists.newLinkedList();
|
||||
int i2 = geodeConfiguration.distributionPoints.sample(randomSource);
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(worldGenLevel.getSeed()));
|
||||
+ // Leaf start - Matter - Feature Secure Seed
|
||||
+ WorldgenRandom worldgenRandom = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled
|
||||
+ ? new su.plo.matter.WorldgenCryptoRandom(0, 0, su.plo.matter.Globals.Salt.GEODE_FEATURE, 0)
|
||||
+ : new WorldgenRandom(new LegacyRandomSource(worldGenLevel.getSeed()));
|
||||
+ // Leaf end - Matter - Feature Secure Seed
|
||||
NormalNoise normalNoise = NormalNoise.create(worldgenRandom, -4, 1.0);
|
||||
List<BlockPos> list1 = Lists.newLinkedList();
|
||||
double d = (double)i2 / geodeConfiguration.outerWallDistance.getMaxValue();
|
||||
diff --git a/net/minecraft/world/level/levelgen/structure/Structure.java b/net/minecraft/world/level/levelgen/structure/Structure.java
|
||||
index 8328e864c72b7a358d6bb1f33459b8c4df2ecb1a..533dc888e4c1febe4e4b71bd6e1c1affbeb492a9 100644
|
||||
--- a/net/minecraft/world/level/levelgen/structure/Structure.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/Structure.java
|
||||
@@ -249,6 +249,13 @@ public abstract class Structure {
|
||||
}
|
||||
|
||||
private static WorldgenRandom makeRandom(long seed, ChunkPos chunkPos) {
|
||||
+ // Leaf start - Matter - Feature Secure Seed
|
||||
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||
+ return new su.plo.matter.WorldgenCryptoRandom(
|
||||
+ chunkPos.x, chunkPos.z, su.plo.matter.Globals.Salt.GENERATE_FEATURE, seed
|
||||
+ );
|
||||
+ }
|
||||
+ // Leaf end - Matter - Feature Secure Seed
|
||||
WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
worldgenRandom.setLargeFeatureSeed(seed, chunkPos.x, chunkPos.z);
|
||||
return worldgenRandom;
|
||||
diff --git a/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java b/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java
|
||||
index ee0d9dddb36b6879fa113299e24f1aa3b2b151cc..d7040165f2b5bb8c60bf32c7bd57ddc0b49faec8 100644
|
||||
--- a/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java
|
||||
@@ -67,8 +67,17 @@ public class RandomSpreadStructurePlacement extends StructurePlacement {
|
||||
public ChunkPos getPotentialStructureChunk(long seed, int regionX, int regionZ) {
|
||||
int i = Math.floorDiv(regionX, this.spacing);
|
||||
int i1 = Math.floorDiv(regionZ, this.spacing);
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
- worldgenRandom.setLargeFeatureWithSalt(seed, i, i1, this.salt());
|
||||
+ // Leaf start - Matter - Feature Secure Seed
|
||||
+ WorldgenRandom worldgenRandom;
|
||||
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||
+ worldgenRandom = new su.plo.matter.WorldgenCryptoRandom(
|
||||
+ i, i1, su.plo.matter.Globals.Salt.POTENTIONAL_FEATURE, this.salt
|
||||
+ );
|
||||
+ } else {
|
||||
+ worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
+ worldgenRandom.setLargeFeatureWithSalt(seed, i, i1, this.salt());
|
||||
+ }
|
||||
+ // Leaf end - Matter - Feature Secure Seed
|
||||
int i2 = this.spacing - this.separation;
|
||||
int i3 = this.spreadType.evaluate(worldgenRandom, i2);
|
||||
int i4 = this.spreadType.evaluate(worldgenRandom, i2);
|
||||
diff --git a/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java b/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
||||
index 670335a7bbfbc9da64c389977498c22dfcd03251..03247c55e0448cabc24ff281e2d1c7df527161da 100644
|
||||
--- a/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
||||
@@ -118,8 +118,18 @@ public abstract class StructurePlacement {
|
||||
public abstract StructurePlacementType<?> type();
|
||||
|
||||
private static boolean probabilityReducer(long levelSeed, int regionX, int regionZ, int salt, float probability, @org.jetbrains.annotations.Nullable Integer saltOverride) { // Paper - Add missing structure set seed configs; ignore here
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
- worldgenRandom.setLargeFeatureWithSalt(levelSeed, regionX, regionZ, salt);
|
||||
+ // Leaf start - Matter - Feature Secure Seed
|
||||
+ WorldgenRandom worldgenRandom;
|
||||
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||
+ worldgenRandom = new su.plo.matter.WorldgenCryptoRandom(
|
||||
+ regionX, regionZ, su.plo.matter.Globals.Salt.UNDEFINED, salt
|
||||
+ );
|
||||
+ } else {
|
||||
+ worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
+ worldgenRandom.setLargeFeatureWithSalt(levelSeed, salt, regionX, regionZ);
|
||||
+ }
|
||||
+ // Leaf end - Matter - Feature Secure Seed
|
||||
+
|
||||
return worldgenRandom.nextFloat() < probability;
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/world/level/levelgen/structure/pools/JigsawPlacement.java b/net/minecraft/world/level/levelgen/structure/pools/JigsawPlacement.java
|
||||
index eb85edaa3b7fab4f11545b0fa8bfea882dedb67d..4633408a710f6e3a9a6545f181ee37f305daa0e4 100644
|
||||
--- a/net/minecraft/world/level/levelgen/structure/pools/JigsawPlacement.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/pools/JigsawPlacement.java
|
||||
@@ -64,7 +64,11 @@ public class JigsawPlacement {
|
||||
ChunkGenerator chunkGenerator = context.chunkGenerator();
|
||||
StructureTemplateManager structureTemplateManager = context.structureTemplateManager();
|
||||
LevelHeightAccessor levelHeightAccessor = context.heightAccessor();
|
||||
- WorldgenRandom worldgenRandom = context.random();
|
||||
+ // Leaf start - Matter - Feature Secure Seed
|
||||
+ WorldgenRandom worldgenRandom = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled
|
||||
+ ? new su.plo.matter.WorldgenCryptoRandom(context.chunkPos().x, context.chunkPos().z, su.plo.matter.Globals.Salt.JIGSAW_PLACEMENT, 0)
|
||||
+ : context.random();
|
||||
+ // Leaf end - Matter - Feature Secure Seed
|
||||
Registry<StructureTemplatePool> registry = registryAccess.lookupOrThrow(Registries.TEMPLATE_POOL);
|
||||
Rotation random = Rotation.getRandom(worldgenRandom);
|
||||
StructureTemplatePool structureTemplatePool = startPool.unwrapKey()
|
||||
diff --git a/net/minecraft/world/level/levelgen/structure/structures/EndCityStructure.java b/net/minecraft/world/level/levelgen/structure/structures/EndCityStructure.java
|
||||
index 653c03d214d2e690852adc4d697e2b24c39ea3d0..81b9f0a07cc2b06770c23f04de5d087c041bd9da 100644
|
||||
--- a/net/minecraft/world/level/levelgen/structure/structures/EndCityStructure.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/structures/EndCityStructure.java
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
import net.minecraft.world.level.levelgen.structure.StructurePiece;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureType;
|
||||
import net.minecraft.world.level.levelgen.structure.pieces.StructurePiecesBuilder;
|
||||
+//import su.plo.matter.WorldgenCryptoRandom; // Leaf - Matter - Feature Secure Seed
|
||||
|
||||
public class EndCityStructure extends Structure {
|
||||
public static final MapCodec<EndCityStructure> CODEC = simpleCodec(EndCityStructure::new);
|
||||
diff --git a/net/minecraft/world/level/levelgen/structure/structures/MineshaftStructure.java b/net/minecraft/world/level/levelgen/structure/structures/MineshaftStructure.java
|
||||
index 5f2118f664c1013b99137c6d34a11c40c2559156..9f80eff88f540e54eb792cc2899cfcb7d75ca0ff 100644
|
||||
--- a/net/minecraft/world/level/levelgen/structure/structures/MineshaftStructure.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/structures/MineshaftStructure.java
|
||||
@@ -20,6 +20,7 @@ import net.minecraft.world.level.levelgen.WorldgenRandom;
|
||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureType;
|
||||
import net.minecraft.world.level.levelgen.structure.pieces.StructurePiecesBuilder;
|
||||
+//import su.plo.matter.WorldgenCryptoRandom; // Leaf - Matter - Feature Secure Seed
|
||||
|
||||
public class MineshaftStructure extends Structure {
|
||||
public static final MapCodec<MineshaftStructure> CODEC = RecordCodecBuilder.mapCodec(
|
||||
@@ -6,13 +6,13 @@ Subject: [PATCH] Matter: Seed Command
|
||||
Original license: GPLv3
|
||||
Original project: https://github.com/plasmoapp/matter
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/commands/SeedCommand.java b/src/main/java/net/minecraft/server/commands/SeedCommand.java
|
||||
index 0b500b19a99fa6c2740c0db350a166462668df9c..a34f06460ac8eb2ee05cd0e6facc3f08418aff70 100644
|
||||
--- a/src/main/java/net/minecraft/server/commands/SeedCommand.java
|
||||
+++ b/src/main/java/net/minecraft/server/commands/SeedCommand.java
|
||||
diff --git a/net/minecraft/server/commands/SeedCommand.java b/net/minecraft/server/commands/SeedCommand.java
|
||||
index a65affc41a4fc299bc2281f0f53f2e075633899d..d67afc17ccaa01a32aa4d810739cc4161e4bede6 100644
|
||||
--- a/net/minecraft/server/commands/SeedCommand.java
|
||||
+++ b/net/minecraft/server/commands/SeedCommand.java
|
||||
@@ -12,6 +12,17 @@ public class SeedCommand {
|
||||
long l = context.getSource().getLevel().getSeed();
|
||||
Component component = ComponentUtils.copyOnClickText(String.valueOf(l));
|
||||
long seed = context.getSource().getLevel().getSeed();
|
||||
Component component = ComponentUtils.copyOnClickText(String.valueOf(seed));
|
||||
context.getSource().sendSuccess(() -> Component.translatable("commands.seed.success", component), false);
|
||||
+
|
||||
+ // Leaf start - Matter - SecureSeed Command
|
||||
@@ -25,6 +25,6 @@ index 0b500b19a99fa6c2740c0db350a166462668df9c..a34f06460ac8eb2ee05cd0e6facc3f08
|
||||
+ }
|
||||
+ // Leaf end - Matter - SecureSeed Command
|
||||
+
|
||||
return (int)l;
|
||||
return (int)seed;
|
||||
}));
|
||||
}
|
||||
@@ -0,0 +1,290 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
Date: Tue, 9 Nov 2077 00:00:00 +0800
|
||||
Subject: [PATCH] Faster Random Generator
|
||||
|
||||
This patch replaces LegacyRandomSource with FasterRandomSource by default,
|
||||
which is faster in general.
|
||||
|
||||
Benchmark results (10,000,000 iterations) (GraalVM 21)
|
||||
SimpleRandom (Moonrise): 80ms
|
||||
FasterRandomSource (Leaf) (Backed by Xoroshiro128PlusPlus): 35ms
|
||||
LegacyRandomSource (Vanilla): 200ms
|
||||
XoroshiroRandomSource (Vanilla): 47ms
|
||||
|
||||
diff --git a/net/minecraft/util/RandomSource.java b/net/minecraft/util/RandomSource.java
|
||||
index 98a54bc4de251014342cda6d0951b7fea79ce553..6d56134cc9ed9d73104ae77b1a0baa5a0a45759c 100644
|
||||
--- a/net/minecraft/util/RandomSource.java
|
||||
+++ b/net/minecraft/util/RandomSource.java
|
||||
@@ -15,18 +15,32 @@ public interface RandomSource {
|
||||
return create(RandomSupport.generateUniqueSeed());
|
||||
}
|
||||
|
||||
+ // Leaf start - Faster random generator
|
||||
@Deprecated
|
||||
static RandomSource createThreadSafe() {
|
||||
- return new ThreadSafeLegacyRandomSource(RandomSupport.generateUniqueSeed());
|
||||
+ return org.dreeam.leaf.config.modules.opt.FastRNG.enabled
|
||||
+ ? new org.dreeam.leaf.util.math.random.FasterRandomSource(RandomSupport.generateUniqueSeed())
|
||||
+ : new ThreadSafeLegacyRandomSource(RandomSupport.generateUniqueSeed());
|
||||
}
|
||||
|
||||
static RandomSource create(long seed) {
|
||||
- return new LegacyRandomSource(seed);
|
||||
+ return org.dreeam.leaf.config.modules.opt.FastRNG.enabled
|
||||
+ ? new org.dreeam.leaf.util.math.random.FasterRandomSource(seed)
|
||||
+ : new LegacyRandomSource(seed);
|
||||
+ }
|
||||
+
|
||||
+ static RandomSource createForSlimeChunk(long seed) {
|
||||
+ return org.dreeam.leaf.config.modules.opt.FastRNG.enabled && !org.dreeam.leaf.config.modules.opt.FastRNG.useLegacyForSlimeChunk
|
||||
+ ? new org.dreeam.leaf.util.math.random.FasterRandomSource(seed)
|
||||
+ : new LegacyRandomSource(seed);
|
||||
}
|
||||
|
||||
static RandomSource createNewThreadLocalInstance() {
|
||||
- return new SingleThreadedRandomSource(ThreadLocalRandom.current().nextLong());
|
||||
+ return org.dreeam.leaf.config.modules.opt.FastRNG.enabled
|
||||
+ ? new org.dreeam.leaf.util.math.random.FasterRandomSource(RandomSupport.generateUniqueSeed())
|
||||
+ : new SingleThreadedRandomSource(ThreadLocalRandom.current().nextLong());
|
||||
}
|
||||
+ // Leaf end - Faster random generator
|
||||
|
||||
RandomSource fork();
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 3e1a5ef63d97e2ad43d98c5736a185ade7afb4bd..f7f330758dce7c38e0e0e8ba420df4d83f765cf1 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -143,7 +143,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
|
||||
// Paper start - Share random for entities to make them more random
|
||||
- public static RandomSource SHARED_RANDOM = new RandomRandomSource();
|
||||
+ public static RandomSource SHARED_RANDOM = org.dreeam.leaf.config.modules.opt.FastRNG.enabled ? org.dreeam.leaf.util.math.random.FasterRandomSource.SHARED_INSTANCE : new RandomRandomSource(); // Leaf - Faster random generator
|
||||
// Paper start - replace random
|
||||
private static final class RandomRandomSource extends ca.spottedleaf.moonrise.common.util.ThreadUnsafeRandom {
|
||||
public RandomRandomSource() {
|
||||
diff --git a/net/minecraft/world/level/biome/Biome.java b/net/minecraft/world/level/biome/Biome.java
|
||||
index f44461f92a10cbfdb8fcdbc3a2442e526b9d3d33..b4c5eea26e87ee6f466c53a6dd0867909df7e848 100644
|
||||
--- a/net/minecraft/world/level/biome/Biome.java
|
||||
+++ b/net/minecraft/world/level/biome/Biome.java
|
||||
@@ -54,14 +54,14 @@ public final class Biome {
|
||||
);
|
||||
public static final Codec<Holder<Biome>> CODEC = RegistryFileCodec.create(Registries.BIOME, DIRECT_CODEC);
|
||||
public static final Codec<HolderSet<Biome>> LIST_CODEC = RegistryCodecs.homogeneousList(Registries.BIOME, DIRECT_CODEC);
|
||||
- private static final PerlinSimplexNoise TEMPERATURE_NOISE = new PerlinSimplexNoise(new WorldgenRandom(new LegacyRandomSource(1234L)), ImmutableList.of(0));
|
||||
+ private static final PerlinSimplexNoise TEMPERATURE_NOISE = new PerlinSimplexNoise(new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(1234L) : new LegacyRandomSource(1234L)), ImmutableList.of(0)); // Leaf - Faster random generator
|
||||
static final PerlinSimplexNoise FROZEN_TEMPERATURE_NOISE = new PerlinSimplexNoise(
|
||||
- new WorldgenRandom(new LegacyRandomSource(3456L)), ImmutableList.of(-2, -1, 0)
|
||||
+ new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(3456L) : new LegacyRandomSource(3456L)), ImmutableList.of(-2, -1, 0) // Leaf - Faster random generator
|
||||
);
|
||||
@Deprecated(
|
||||
forRemoval = true
|
||||
)
|
||||
- public static final PerlinSimplexNoise BIOME_INFO_NOISE = new PerlinSimplexNoise(new WorldgenRandom(new LegacyRandomSource(2345L)), ImmutableList.of(0));
|
||||
+ public static final PerlinSimplexNoise BIOME_INFO_NOISE = new PerlinSimplexNoise(new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(2345L) : new LegacyRandomSource(2345L)), ImmutableList.of(0)); // Leaf - Faster random generator
|
||||
private static final int TEMPERATURE_CACHE_SIZE = 1024;
|
||||
public final Biome.ClimateSettings climateSettings;
|
||||
private final BiomeGenerationSettings generationSettings;
|
||||
diff --git a/net/minecraft/world/level/chunk/ChunkGenerator.java b/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||
index 2b19e989b4475e905d77bf9d47403c724b81fccd..472105a1e392f2e1b080483f3038de4f303919ce 100644
|
||||
--- a/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||
+++ b/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||
@@ -458,7 +458,7 @@ public abstract class ChunkGenerator {
|
||||
int x = chunk.getPos().x;
|
||||
int z = chunk.getPos().z;
|
||||
for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) {
|
||||
- WorldgenRandom seededrandom = new WorldgenRandom(new net.minecraft.world.level.levelgen.LegacyRandomSource(level.getSeed()));
|
||||
+ WorldgenRandom seededrandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(level.getSeed()) : new net.minecraft.world.level.levelgen.LegacyRandomSource(level.getSeed())); // Leaf - Faster random generator
|
||||
seededrandom.setDecorationSeed(level.getSeed(), x, z);
|
||||
populator.populate(world, new org.bukkit.craftbukkit.util.RandomSourceWrapper.RandomWrapper(seededrandom), x, z, limitedRegion);
|
||||
}
|
||||
@@ -567,7 +567,7 @@ public abstract class ChunkGenerator {
|
||||
pos.x, pos.z, su.plo.matter.Globals.Salt.GENERATE_FEATURE, 0
|
||||
);
|
||||
} else {
|
||||
- worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
+ worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L)); // Leaf - Faster random generator
|
||||
worldgenRandom.setLargeFeatureSeed(structureState.getLevelSeed(), pos.x, pos.z);
|
||||
}
|
||||
// Leaf end - Matter - Feature Secure Seed
|
||||
diff --git a/net/minecraft/world/level/levelgen/DensityFunctions.java b/net/minecraft/world/level/levelgen/DensityFunctions.java
|
||||
index 04527a5c65ad630f794fed9071d485aedd02257a..15fc39f9c77fdd03a0ca4a39d173c851b9454f08 100644
|
||||
--- a/net/minecraft/world/level/levelgen/DensityFunctions.java
|
||||
+++ b/net/minecraft/world/level/levelgen/DensityFunctions.java
|
||||
@@ -518,7 +518,7 @@ public final class DensityFunctions {
|
||||
// Paper end - Perf: Optimize end generation
|
||||
|
||||
public EndIslandDensityFunction(long seed) {
|
||||
- RandomSource randomSource = new LegacyRandomSource(seed);
|
||||
+ RandomSource randomSource = org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(seed) : new LegacyRandomSource(seed); // Leaf - Faster random generator
|
||||
randomSource.consumeCount(17292);
|
||||
this.islandNoise = new SimplexNoise(randomSource);
|
||||
}
|
||||
diff --git a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
||||
index 65728ef17e63d71833677fdcbd5bb90794b4822b..57ae4aaf1431021daf77c5638038d4910a358155 100644
|
||||
--- a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
||||
+++ b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
||||
@@ -254,7 +254,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator {
|
||||
WorldGenRegion level, long seed, RandomState random, BiomeManager biomeManager, StructureManager structureManager, ChunkAccess chunk
|
||||
) {
|
||||
BiomeManager biomeManager1 = biomeManager.withDifferentSource((x, y, z) -> this.biomeSource.getNoiseBiome(x, y, z, random.sampler()));
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(RandomSupport.generateUniqueSeed()));
|
||||
+ WorldgenRandom worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(RandomSupport.generateUniqueSeed()) : new LegacyRandomSource(RandomSupport.generateUniqueSeed())); // Leaf - Faster random generator
|
||||
int i = 8;
|
||||
ChunkPos pos = chunk.getPos();
|
||||
NoiseChunk noiseChunk = chunk.getOrCreateNoiseChunk(chunkAccess -> this.createNoiseChunk(chunkAccess, structureManager, Blender.of(level), random));
|
||||
@@ -420,7 +420,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator {
|
||||
if (!this.settings.value().disableMobGeneration()) {
|
||||
ChunkPos center = level.getCenter();
|
||||
Holder<Biome> biome = level.getBiome(center.getWorldPosition().atY(level.getMaxY()));
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(RandomSupport.generateUniqueSeed()));
|
||||
+ WorldgenRandom worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(RandomSupport.generateUniqueSeed()) : new LegacyRandomSource(RandomSupport.generateUniqueSeed())); // Leaf - Faster random generator
|
||||
worldgenRandom.setDecorationSeed(level.getSeed(), center.getMinBlockX(), center.getMinBlockZ());
|
||||
NaturalSpawner.spawnMobsForChunkGeneration(level, biome, center, worldgenRandom);
|
||||
}
|
||||
diff --git a/net/minecraft/world/level/levelgen/WorldgenRandom.java b/net/minecraft/world/level/levelgen/WorldgenRandom.java
|
||||
index c2d7cd788071e25b8ba2503c30ae80c7a9f353ed..08cf526ae87dd2560fcb50d5786701701e34ec00 100644
|
||||
--- a/net/minecraft/world/level/levelgen/WorldgenRandom.java
|
||||
+++ b/net/minecraft/world/level/levelgen/WorldgenRandom.java
|
||||
@@ -69,7 +69,7 @@ public class WorldgenRandom extends LegacyRandomSource {
|
||||
}
|
||||
|
||||
public static RandomSource seedSlimeChunk(int chunkX, int chunkZ, long levelSeed, long salt) {
|
||||
- return RandomSource.create(levelSeed + chunkX * chunkX * 4987142 + chunkX * 5947611 + chunkZ * chunkZ * 4392871L + chunkZ * 389711 ^ salt);
|
||||
+ return RandomSource.createForSlimeChunk(levelSeed + chunkX * chunkX * 4987142 + chunkX * 5947611 + chunkZ * chunkZ * 4392871L + chunkZ * 389711 ^ salt); // Leaf - Faster RNG
|
||||
}
|
||||
|
||||
public static enum Algorithm {
|
||||
diff --git a/net/minecraft/world/level/levelgen/feature/GeodeFeature.java b/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
||||
index e416b27c7f6604349766d44284ee004d5f62d9b2..1d27550bb5f29b6bfe8e0ad4fc4c9d39a9d7b29e 100644
|
||||
--- a/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
||||
+++ b/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
||||
@@ -44,7 +44,7 @@ public class GeodeFeature extends Feature<GeodeConfiguration> {
|
||||
// Leaf start - Matter - Feature Secure Seed
|
||||
WorldgenRandom worldgenRandom = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled
|
||||
? new su.plo.matter.WorldgenCryptoRandom(0, 0, su.plo.matter.Globals.Salt.GEODE_FEATURE, 0)
|
||||
- : new WorldgenRandom(new LegacyRandomSource(worldGenLevel.getSeed()));
|
||||
+ : new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(worldGenLevel.getSeed()) : new LegacyRandomSource(worldGenLevel.getSeed())); // Leaf - Faster random generator
|
||||
// Leaf end - Matter - Feature Secure Seed
|
||||
NormalNoise normalNoise = NormalNoise.create(worldgenRandom, -4, 1.0);
|
||||
List<BlockPos> list1 = Lists.newLinkedList();
|
||||
diff --git a/net/minecraft/world/level/levelgen/feature/stateproviders/DualNoiseProvider.java b/net/minecraft/world/level/levelgen/feature/stateproviders/DualNoiseProvider.java
|
||||
index 48ab8a568d97052fe205e6a1f89862ee23d65abb..a190b5e890cf34dd1aa46cb9e283f05154fbe3e5 100644
|
||||
--- a/net/minecraft/world/level/levelgen/feature/stateproviders/DualNoiseProvider.java
|
||||
+++ b/net/minecraft/world/level/levelgen/feature/stateproviders/DualNoiseProvider.java
|
||||
@@ -43,7 +43,7 @@ public class DualNoiseProvider extends NoiseProvider {
|
||||
this.variety = variety;
|
||||
this.slowNoiseParameters = slowNoiseParameters;
|
||||
this.slowScale = slowScale;
|
||||
- this.slowNoise = NormalNoise.create(new WorldgenRandom(new LegacyRandomSource(seed)), slowNoiseParameters);
|
||||
+ this.slowNoise = NormalNoise.create(new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(seed) : new LegacyRandomSource(seed)), slowNoiseParameters); // Leaf - Faster random generator
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/net/minecraft/world/level/levelgen/feature/stateproviders/NoiseBasedStateProvider.java b/net/minecraft/world/level/levelgen/feature/stateproviders/NoiseBasedStateProvider.java
|
||||
index f685372a39976f823202f2d9015c14f835b94a0c..bdd1b4ab758fc653df4adad7633ef430ebb89dbe 100644
|
||||
--- a/net/minecraft/world/level/levelgen/feature/stateproviders/NoiseBasedStateProvider.java
|
||||
+++ b/net/minecraft/world/level/levelgen/feature/stateproviders/NoiseBasedStateProvider.java
|
||||
@@ -28,7 +28,7 @@ public abstract class NoiseBasedStateProvider extends BlockStateProvider {
|
||||
this.seed = seed;
|
||||
this.parameters = parameters;
|
||||
this.scale = scale;
|
||||
- this.noise = NormalNoise.create(new WorldgenRandom(new LegacyRandomSource(seed)), parameters);
|
||||
+ this.noise = NormalNoise.create(new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(seed) : new LegacyRandomSource(seed)), parameters); // Leaf - Faster random generator
|
||||
}
|
||||
|
||||
protected double getNoiseValue(BlockPos pos, double delta) {
|
||||
diff --git a/net/minecraft/world/level/levelgen/structure/Structure.java b/net/minecraft/world/level/levelgen/structure/Structure.java
|
||||
index 533dc888e4c1febe4e4b71bd6e1c1affbeb492a9..7f8293497912532fd6b83a0962a722b0e6267721 100644
|
||||
--- a/net/minecraft/world/level/levelgen/structure/Structure.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/Structure.java
|
||||
@@ -256,7 +256,7 @@ public abstract class Structure {
|
||||
);
|
||||
}
|
||||
// Leaf end - Matter - Feature Secure Seed
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
+ WorldgenRandom worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L)); // Leaf - Faster random generator
|
||||
worldgenRandom.setLargeFeatureSeed(seed, chunkPos.x, chunkPos.z);
|
||||
return worldgenRandom;
|
||||
}
|
||||
diff --git a/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java b/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java
|
||||
index d7040165f2b5bb8c60bf32c7bd57ddc0b49faec8..ebba2592726356eb837b733c36148f444c2d7f13 100644
|
||||
--- a/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java
|
||||
@@ -74,7 +74,7 @@ public class RandomSpreadStructurePlacement extends StructurePlacement {
|
||||
i, i1, su.plo.matter.Globals.Salt.POTENTIONAL_FEATURE, this.salt
|
||||
);
|
||||
} else {
|
||||
- worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
+ worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L)); // Leaf - Faster random generator
|
||||
worldgenRandom.setLargeFeatureWithSalt(seed, i, i1, this.salt());
|
||||
}
|
||||
// Leaf end - Matter - Feature Secure Seed
|
||||
diff --git a/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java b/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
||||
index 03247c55e0448cabc24ff281e2d1c7df527161da..2a9f66ac0fe8f664d404c68df7414be6b0396082 100644
|
||||
--- a/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
||||
@@ -125,7 +125,7 @@ public abstract class StructurePlacement {
|
||||
regionX, regionZ, su.plo.matter.Globals.Salt.UNDEFINED, salt
|
||||
);
|
||||
} else {
|
||||
- worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
+ worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L)); // Leaf - Faster random generator
|
||||
worldgenRandom.setLargeFeatureWithSalt(levelSeed, salt, regionX, regionZ);
|
||||
}
|
||||
// Leaf end - Matter - Feature Secure Seed
|
||||
@@ -134,7 +134,7 @@ public abstract class StructurePlacement {
|
||||
}
|
||||
|
||||
private static boolean legacyProbabilityReducerWithDouble(long baseSeed, int salt, int chunkX, int chunkZ, float probability, @org.jetbrains.annotations.Nullable Integer saltOverride) { // Paper - Add missing structure set seed configs
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
+ WorldgenRandom worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L)); // Leaf - Faster random generator
|
||||
if (saltOverride == null) { // Paper - Add missing structure set seed configs
|
||||
worldgenRandom.setLargeFeatureSeed(baseSeed, chunkX, chunkZ);
|
||||
// Paper start - Add missing structure set seed configs
|
||||
@@ -146,7 +146,7 @@ public abstract class StructurePlacement {
|
||||
}
|
||||
|
||||
private static boolean legacyArbitrarySaltProbabilityReducer(long levelSeed, int salt, int regionX, int regionZ, float probability, @org.jetbrains.annotations.Nullable Integer saltOverride) { // Paper - Add missing structure set seed configs
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
+ WorldgenRandom worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L)); // Leaf - Faster random generator
|
||||
worldgenRandom.setLargeFeatureWithSalt(levelSeed, regionX, regionZ, saltOverride != null ? saltOverride : HIGHLY_ARBITRARY_RANDOM_SALT); // Paper - Add missing structure set seed configs
|
||||
return worldgenRandom.nextFloat() < probability;
|
||||
}
|
||||
@@ -154,7 +154,7 @@ public abstract class StructurePlacement {
|
||||
private static boolean legacyPillagerOutpostReducer(long levelSeed, int salt, int regionX, int regionZ, float probability, @org.jetbrains.annotations.Nullable Integer saltOverride) { // Paper - Add missing structure set seed configs; ignore here
|
||||
int i = regionX >> 4;
|
||||
int i1 = regionZ >> 4;
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
+ WorldgenRandom worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L)); // Leaf - Faster random generator
|
||||
worldgenRandom.setSeed(i ^ i1 << 4 ^ levelSeed);
|
||||
worldgenRandom.nextInt();
|
||||
return worldgenRandom.nextInt((int)(1.0F / probability)) == 0;
|
||||
diff --git a/net/minecraft/world/level/levelgen/structure/structures/OceanMonumentStructure.java b/net/minecraft/world/level/levelgen/structure/structures/OceanMonumentStructure.java
|
||||
index 6941b2c89df8a7c77166e3fb76150cbc852371d9..661c26c4b981d504988c7498be45a5ddacaf90d8 100644
|
||||
--- a/net/minecraft/world/level/levelgen/structure/structures/OceanMonumentStructure.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/structures/OceanMonumentStructure.java
|
||||
@@ -56,7 +56,7 @@ public class OceanMonumentStructure extends Structure {
|
||||
if (piecesContainer.isEmpty()) {
|
||||
return piecesContainer;
|
||||
} else {
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(RandomSupport.generateUniqueSeed()));
|
||||
+ WorldgenRandom worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(RandomSupport.generateUniqueSeed()) : new LegacyRandomSource(RandomSupport.generateUniqueSeed())); // Leaf - Faster random generator
|
||||
worldgenRandom.setLargeFeatureSeed(seed, chunkPos.x, chunkPos.z);
|
||||
StructurePiece structurePiece = piecesContainer.pieces().get(0);
|
||||
BoundingBox boundingBox = structurePiece.getBoundingBox();
|
||||
diff --git a/net/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.java b/net/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.java
|
||||
index 434e72fd770a259d67e5e7f110f49b09bab6c54e..720098d50ecefeff25e8f032e33742ad6bd6ab21 100644
|
||||
--- a/net/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.java
|
||||
+++ b/net/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.java
|
||||
@@ -43,7 +43,7 @@ public class PerlinSimplexNoise {
|
||||
|
||||
if (i1 > 0) {
|
||||
long l = (long)(simplexNoise.getValue(simplexNoise.xo, simplexNoise.yo, simplexNoise.zo) * 9.223372E18F);
|
||||
- RandomSource randomSource = new WorldgenRandom(new LegacyRandomSource(l));
|
||||
+ RandomSource randomSource = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(l) : new LegacyRandomSource(l)); // Leaf - Faster random generator
|
||||
|
||||
for (int i5 = i3 - 1; i5 >= 0; i5--) {
|
||||
if (i5 < i2 && octaves.contains(i3 - i5)) {
|
||||
@@ -0,0 +1,22 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: nostalfinals <yuu8583@proton.me>
|
||||
Date: Mon, 29 Apr 2024 23:30:21 +0800
|
||||
Subject: [PATCH] Don't save primed tnt entity
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
index 40f5534b425ef57c435b365f156d3b988b74f911..c96f458994818392857642282ec3d492124885da 100644
|
||||
--- a/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
+++ b/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
@@ -279,4 +279,11 @@ public class PrimedTnt extends Entity implements TraceableEntity {
|
||||
return super.interact(player, hand);
|
||||
}
|
||||
// Purpur end - Shears can defuse TNT
|
||||
+
|
||||
+ // Leaf start - PMC - Don't save primed tnt entity
|
||||
+ @Override
|
||||
+ public boolean shouldBeSaved() {
|
||||
+ return !org.dreeam.leaf.config.modules.opt.DontSaveEntity.dontSavePrimedTNT && super.shouldBeSaved();
|
||||
+ }
|
||||
+ // Leaf - PMC - Don't save primed tnt entity
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: nostalfinals <yuu8583@proton.me>
|
||||
Date: Mon, 29 Apr 2024 23:31:25 +0800
|
||||
Subject: [PATCH] Don't save falling block entity
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
index 5746587666c7cb788764aab2f6ccf0f3ac5c282f..fd2f93b070f96d28a8c694a6d943d92d257d0c9e 100644
|
||||
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
@@ -404,4 +404,11 @@ public class FallingBlockEntity extends Entity {
|
||||
this.forceTickAfterTeleportToDuplicate = entity != null && flag && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowUnsafeEndPortalTeleportation; // Paper
|
||||
return entity;
|
||||
}
|
||||
+
|
||||
+ // Leaf start - PMC - Don't save falling block entity
|
||||
+ @Override
|
||||
+ public boolean shouldBeSaved() {
|
||||
+ return !org.dreeam.leaf.config.modules.opt.DontSaveEntity.dontSaveFallingBlock && super.shouldBeSaved();
|
||||
+ }
|
||||
+ // Leaf end - PMC - Don't save falling block entity
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Sun, 2 Jun 2024 01:21:36 +0800
|
||||
Subject: [PATCH] Configurable connection message
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
||||
index b98e854fb9fad65b176b4915214a0a4c5e424d6c..5fe6a295f5b5285a20c535a026e1342f89896fd7 100644
|
||||
--- a/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/net/minecraft/server/players/PlayerList.java
|
||||
@@ -433,7 +433,7 @@ public abstract class PlayerList {
|
||||
// Ensure that player inventory is populated with its viewer
|
||||
player.containerMenu.transferTo(player.containerMenu, bukkitPlayer);
|
||||
|
||||
- org.bukkit.event.player.PlayerJoinEvent playerJoinEvent = new org.bukkit.event.player.PlayerJoinEvent(bukkitPlayer, io.papermc.paper.adventure.PaperAdventure.asAdventure(mutableComponent)); // Paper - Adventure
|
||||
+ org.bukkit.event.player.PlayerJoinEvent playerJoinEvent = new org.bukkit.event.player.PlayerJoinEvent(bukkitPlayer, getJoinMsg(mutableComponent, bukkitPlayer)); // Paper - Adventure
|
||||
this.cserver.getPluginManager().callEvent(playerJoinEvent);
|
||||
|
||||
if (!player.connection.isAcceptingMessages()) {
|
||||
@@ -446,7 +446,7 @@ public abstract class PlayerList {
|
||||
|
||||
final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage();
|
||||
|
||||
- if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure
|
||||
+ if (org.dreeam.leaf.config.modules.misc.ConnectionMessage.joinEnabled && jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure // Leaf - Configurable connection message - join message
|
||||
joinMessage = io.papermc.paper.adventure.PaperAdventure.asVanilla(jm); // Paper - Adventure
|
||||
this.server.getPlayerList().broadcastSystemMessage(joinMessage, false); // Paper - Adventure
|
||||
}
|
||||
@@ -676,7 +676,7 @@ public abstract class PlayerList {
|
||||
player.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper - Inventory close reason
|
||||
}
|
||||
|
||||
- org.bukkit.event.player.PlayerQuitEvent playerQuitEvent = new org.bukkit.event.player.PlayerQuitEvent(player.getBukkitEntity(), leaveMessage, player.quitReason); // Paper - Adventure & Add API for quit reason
|
||||
+ org.bukkit.event.player.PlayerQuitEvent playerQuitEvent = new org.bukkit.event.player.PlayerQuitEvent(player.getBukkitEntity(), getQuitMsg(leaveMessage, player.getBukkitEntity()), player.quitReason); // Paper - Adventure & Add API for quit reason
|
||||
this.cserver.getPluginManager().callEvent(playerQuitEvent);
|
||||
player.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage());
|
||||
|
||||
@@ -1661,4 +1661,33 @@ public abstract class PlayerList {
|
||||
public boolean isAllowCommandsForAllPlayers() {
|
||||
return this.allowCommandsForAllPlayers;
|
||||
}
|
||||
+
|
||||
+ // Leaf start - Configurable connection message
|
||||
+ private net.kyori.adventure.text.Component getJoinMsg(MutableComponent defaultJoinMsg, org.bukkit.craftbukkit.entity.CraftPlayer craftPlayer) {
|
||||
+ if (org.dreeam.leaf.config.modules.misc.ConnectionMessage.joinEnabled) {
|
||||
+ if ("default".equals(org.dreeam.leaf.config.modules.misc.ConnectionMessage.joinMessage)) {
|
||||
+ return io.papermc.paper.adventure.PaperAdventure.asAdventure(defaultJoinMsg);
|
||||
+ }
|
||||
+
|
||||
+ return net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(org.dreeam.leaf.config.modules.misc.ConnectionMessage.joinMessage)
|
||||
+ .replaceText(net.kyori.adventure.text.TextReplacementConfig.builder().matchLiteral("%player_name%").replacement(craftPlayer.getName()).build())
|
||||
+ .replaceText(net.kyori.adventure.text.TextReplacementConfig.builder().matchLiteral("%player_displayname%").replacement(craftPlayer.displayName()).build());
|
||||
+ }
|
||||
+
|
||||
+ return net.kyori.adventure.text.Component.empty();
|
||||
+ }
|
||||
+ private net.kyori.adventure.text.Component getQuitMsg(net.kyori.adventure.text.Component defaultJoinMsg, org.bukkit.craftbukkit.entity.CraftPlayer craftPlayer) {
|
||||
+ if (org.dreeam.leaf.config.modules.misc.ConnectionMessage.quitEnabled) {
|
||||
+ if ("default".equals(org.dreeam.leaf.config.modules.misc.ConnectionMessage.quitMessage)) {
|
||||
+ return defaultJoinMsg;
|
||||
+ }
|
||||
+
|
||||
+ return net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(org.dreeam.leaf.config.modules.misc.ConnectionMessage.quitMessage)
|
||||
+ .replaceText(net.kyori.adventure.text.TextReplacementConfig.builder().matchLiteral("%player_name%").replacement(craftPlayer.getName()).build())
|
||||
+ .replaceText(net.kyori.adventure.text.TextReplacementConfig.builder().matchLiteral("%player_displayname%").replacement(craftPlayer.displayName()).build());
|
||||
+ }
|
||||
+
|
||||
+ return net.kyori.adventure.text.Component.empty();
|
||||
+ }
|
||||
+ // Leaf end - Configurable connection message
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Wed, 7 Aug 2024 18:54:01 +0800
|
||||
Subject: [PATCH] Configurable unknown command message
|
||||
|
||||
|
||||
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
||||
index d03a6dc74877bc08b170be5add061270dc46549b..76f26f4fb93dd84a9b15ea662eeeadbc44a99ac5 100644
|
||||
--- a/net/minecraft/commands/Commands.java
|
||||
+++ b/net/minecraft/commands/Commands.java
|
||||
@@ -390,31 +390,9 @@ public class Commands {
|
||||
// Paper start - Add UnknownCommandEvent
|
||||
final net.kyori.adventure.text.TextComponent.Builder builder = net.kyori.adventure.text.Component.text();
|
||||
// source.sendFailure(ComponentUtils.fromMessage(var7.getRawMessage()));
|
||||
- builder.color(net.kyori.adventure.text.format.NamedTextColor.RED).append(io.papermc.paper.command.brigadier.MessageComponentSerializer.message().deserialize(var7.getRawMessage()));
|
||||
+ final net.kyori.adventure.text.TextComponent message = getUnknownCommandMessage(builder, var7, label); // Leaf - Configurable unknown command message
|
||||
// Paper end - Add UnknownCommandEvent
|
||||
- if (var7.getInput() != null && var7.getCursor() >= 0) {
|
||||
- int min = Math.min(var7.getInput().length(), var7.getCursor());
|
||||
- MutableComponent mutableComponent = Component.empty()
|
||||
- .withStyle(ChatFormatting.GRAY)
|
||||
- .withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + label))); // CraftBukkit // Paper
|
||||
- if (min > 10) {
|
||||
- mutableComponent.append(CommonComponents.ELLIPSIS);
|
||||
- }
|
||||
-
|
||||
- mutableComponent.append(var7.getInput().substring(Math.max(0, min - 10), min));
|
||||
- if (min < var7.getInput().length()) {
|
||||
- Component component = Component.literal(var7.getInput().substring(min)).withStyle(ChatFormatting.RED, ChatFormatting.UNDERLINE);
|
||||
- mutableComponent.append(component);
|
||||
- }
|
||||
-
|
||||
- mutableComponent.append(Component.translatable("command.context.here").withStyle(ChatFormatting.RED, ChatFormatting.ITALIC));
|
||||
- // Paper start - Add UnknownCommandEvent
|
||||
- // source.sendFailure(mutableComponent);
|
||||
- builder
|
||||
- .append(net.kyori.adventure.text.Component.newline())
|
||||
- .append(io.papermc.paper.adventure.PaperAdventure.asAdventure(mutableComponent));
|
||||
- }
|
||||
- org.bukkit.event.command.UnknownCommandEvent event = new org.bukkit.event.command.UnknownCommandEvent(source.getBukkitSender(), command, org.spigotmc.SpigotConfig.unknownCommandMessage.isEmpty() ? null : builder.build());
|
||||
+ org.bukkit.event.command.UnknownCommandEvent event = new org.bukkit.event.command.UnknownCommandEvent(source.getBukkitSender(), command, message); // Leaf - Configurable unknown command message
|
||||
org.bukkit.Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.message() != null) {
|
||||
source.sendFailure(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.message()), false);
|
||||
@@ -677,6 +655,86 @@ public class Commands {
|
||||
};
|
||||
}
|
||||
|
||||
+ // Leaf start - Configurable unknown command message
|
||||
+ private static net.kyori.adventure.text.TextComponent getUnknownCommandMessage(
|
||||
+ net.kyori.adventure.text.TextComponent.Builder builder, CommandSyntaxException commandSyntaxException, String label
|
||||
+ ) {
|
||||
+ String rawMessage = org.dreeam.leaf.config.modules.misc.UnknownCommandMessage.unknownCommandMessage;
|
||||
+
|
||||
+ if (!"default".equals(rawMessage)) {
|
||||
+ final String input = commandSyntaxException.getInput();
|
||||
+ final int cursor = commandSyntaxException.getCursor();
|
||||
+
|
||||
+ if (rawMessage.contains("<detail>") && input != null && cursor >= 0) {
|
||||
+ final int min = Math.min(input.length(), cursor);
|
||||
+ final net.kyori.adventure.text.TextComponent.Builder detail = net.kyori.adventure.text.Component.text();
|
||||
+ final net.kyori.adventure.text.Component context = net.kyori.adventure.text.Component.translatable("command.context.here")
|
||||
+ .color(net.kyori.adventure.text.format.NamedTextColor.RED)
|
||||
+ .decorate(net.kyori.adventure.text.format.TextDecoration.ITALIC);
|
||||
+ final net.kyori.adventure.text.event.ClickEvent event = net.kyori.adventure.text.event.ClickEvent.suggestCommand("/" + label);
|
||||
+
|
||||
+ detail.color(net.kyori.adventure.text.format.NamedTextColor.GRAY);
|
||||
+
|
||||
+ if (min > 10) {
|
||||
+ detail.append(net.kyori.adventure.text.Component.text("..."));
|
||||
+ }
|
||||
+
|
||||
+ detail.append(net.kyori.adventure.text.Component.text(input.substring(Math.max(0, min - 10), min)));
|
||||
+ if (min < input.length()) {
|
||||
+ net.kyori.adventure.text.Component commandInput = net.kyori.adventure.text.Component.text(input.substring(min))
|
||||
+ .color(net.kyori.adventure.text.format.NamedTextColor.RED)
|
||||
+ .decorate(net.kyori.adventure.text.format.TextDecoration.UNDERLINED);
|
||||
+
|
||||
+ detail.append(commandInput);
|
||||
+ }
|
||||
+
|
||||
+ detail.append(context);
|
||||
+ detail.clickEvent(event);
|
||||
+
|
||||
+ builder.append(net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(rawMessage, net.kyori.adventure.text.minimessage.tag.resolver.Placeholder.component("detail", detail.build())));
|
||||
+ } else {
|
||||
+ rawMessage = rawMessage.replace("<detail>", "");
|
||||
+ builder.append(net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(rawMessage));
|
||||
+ }
|
||||
+
|
||||
+ return builder.build();
|
||||
+ }
|
||||
+
|
||||
+ return getVanillaUnknownCommandMessage(builder, commandSyntaxException, label);
|
||||
+ }
|
||||
+
|
||||
+ private static net.kyori.adventure.text.TextComponent getVanillaUnknownCommandMessage(
|
||||
+ net.kyori.adventure.text.TextComponent.Builder builder, CommandSyntaxException var7, String label
|
||||
+ ) {
|
||||
+ builder.color(net.kyori.adventure.text.format.NamedTextColor.RED).append(io.papermc.paper.command.brigadier.MessageComponentSerializer.message().deserialize(var7.getRawMessage()));
|
||||
+
|
||||
+ if (var7.getInput() != null && var7.getCursor() >= 0) {
|
||||
+ int min = Math.min(var7.getInput().length(), var7.getCursor());
|
||||
+ MutableComponent mutableComponent = Component.empty()
|
||||
+ .withStyle(ChatFormatting.GRAY)
|
||||
+ .withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + label))); // CraftBukkit // Paper
|
||||
+ if (min > 10) {
|
||||
+ mutableComponent.append(CommonComponents.ELLIPSIS);
|
||||
+ }
|
||||
+
|
||||
+ mutableComponent.append(var7.getInput().substring(Math.max(0, min - 10), min));
|
||||
+ if (min < var7.getInput().length()) {
|
||||
+ Component component = Component.literal(var7.getInput().substring(min)).withStyle(ChatFormatting.RED, ChatFormatting.UNDERLINE);
|
||||
+ mutableComponent.append(component);
|
||||
+ }
|
||||
+
|
||||
+ mutableComponent.append(Component.translatable("command.context.here").withStyle(ChatFormatting.RED, ChatFormatting.ITALIC));
|
||||
+ // Paper start - Add UnknownCommandEvent
|
||||
+ // source.sendFailure(mutableComponent);
|
||||
+ builder
|
||||
+ .append(net.kyori.adventure.text.Component.newline())
|
||||
+ .append(io.papermc.paper.adventure.PaperAdventure.asAdventure(mutableComponent));
|
||||
+ }
|
||||
+
|
||||
+ return builder.build();
|
||||
+ }
|
||||
+ // Leaf end - Configurable unknown command message
|
||||
+
|
||||
public static void validate() {
|
||||
CommandBuildContext commandBuildContext = createValidationContext(VanillaRegistries.createLookup());
|
||||
CommandDispatcher<CommandSourceStack> dispatcher = new Commands(Commands.CommandSelection.ALL, commandBuildContext).getDispatcher();
|
||||
@@ -0,0 +1,36 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Fri, 7 Jun 2024 17:43:43 +0800
|
||||
Subject: [PATCH] Remove stream in BlockBehaviour cache blockstate
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
index b631e35e965b1914cdeeddab8bd6bdbfd2465079..c13c8c82bf7bd0a9a33fd4027884ad852a7c64b6 100644
|
||||
--- a/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
+++ b/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
@@ -1051,7 +1051,7 @@ public abstract class BlockBehaviour implements FeatureElement {
|
||||
private static final Direction[] DIRECTIONS = Direction.values();
|
||||
private static final int SUPPORT_TYPE_COUNT = SupportType.values().length;
|
||||
protected final VoxelShape collisionShape;
|
||||
- protected final boolean largeCollisionShape;
|
||||
+ protected boolean largeCollisionShape; // Leaf - not final
|
||||
private final boolean[] faceSturdy;
|
||||
protected final boolean isCollisionShapeFullBlock;
|
||||
|
||||
@@ -1067,8 +1067,14 @@ public abstract class BlockBehaviour implements FeatureElement {
|
||||
)
|
||||
);
|
||||
} else {
|
||||
- this.largeCollisionShape = Arrays.stream(Direction.Axis.values())
|
||||
- .anyMatch(dir -> this.collisionShape.min(dir) < 0.0 || this.collisionShape.max(dir) > 1.0);
|
||||
+ // Leaf start - Remove stream
|
||||
+ for (Direction.Axis axis : Direction.Axis.values()) {
|
||||
+ if (this.collisionShape.min(axis) < 0.0 || this.collisionShape.max(axis) > 1.0) {
|
||||
+ this.largeCollisionShape = true;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaf end - Remove stream
|
||||
this.faceSturdy = new boolean[DIRECTIONS.length * SUPPORT_TYPE_COUNT];
|
||||
|
||||
for (Direction direction : DIRECTIONS) {
|
||||
@@ -0,0 +1,32 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Tue, 17 Sep 2024 02:26:44 -0400
|
||||
Subject: [PATCH] Remove stream in entity visible effects filter
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
||||
index c041cba43b4687e2f2f057edfae448a42f6d8753..8b096a0f9f23a9b90ef88414e8749a514e3910cf 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -988,12 +988,15 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
|
||||
private void updateSynchronizedMobEffectParticles() {
|
||||
- List<ParticleOptions> list = this.activeEffects
|
||||
- .values()
|
||||
- .stream()
|
||||
- .filter(MobEffectInstance::isVisible)
|
||||
- .map(MobEffectInstance::getParticleOptions)
|
||||
- .toList();
|
||||
+ // Leaf start - Remove stream in entity visible effects filter
|
||||
+ List<ParticleOptions> list = new ArrayList<>();
|
||||
+
|
||||
+ for (MobEffectInstance effect : this.activeEffects.values()) {
|
||||
+ if (effect.isVisible()) {
|
||||
+ list.add(effect.getParticleOptions());
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaf end - Remove stream in entity visible effects filter
|
||||
this.entityData.set(DATA_EFFECT_PARTICLES, list);
|
||||
this.entityData.set(DATA_EFFECT_AMBIENCE_ID, areAllEffectsAmbient(this.activeEffects.values()));
|
||||
}
|
||||
@@ -5,34 +5,34 @@ Subject: [PATCH] Remove stream and double iteration in enough deep sleeping
|
||||
player check
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/players/SleepStatus.java b/src/main/java/net/minecraft/server/players/SleepStatus.java
|
||||
index caa8a69bde0c212c36dd990a67836ac2f95548c0..5ae435dcc078a5b9af90f01fa70f1a9d6f34e2be 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/SleepStatus.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/SleepStatus.java
|
||||
@@ -19,10 +19,24 @@ public class SleepStatus {
|
||||
diff --git a/net/minecraft/server/players/SleepStatus.java b/net/minecraft/server/players/SleepStatus.java
|
||||
index 3a3e6992563236141db687084aeec9684437a7db..e6827e90b685f88d945010f2c8c5aead52b0856e 100644
|
||||
--- a/net/minecraft/server/players/SleepStatus.java
|
||||
+++ b/net/minecraft/server/players/SleepStatus.java
|
||||
@@ -15,9 +15,24 @@ public class SleepStatus {
|
||||
|
||||
public boolean areEnoughDeepSleeping(int percentage, List<ServerPlayer> players) {
|
||||
public boolean areEnoughDeepSleeping(int requiredSleepPercentage, List<ServerPlayer> sleepingPlayers) {
|
||||
// CraftBukkit start
|
||||
- int j = (int) players.stream().filter((eh) -> { return eh.isSleepingLongEnough() || eh.fauxSleeping || (eh.level().purpurConfig.idleTimeoutCountAsSleeping && eh.isAfk()); }).count(); // Purpur
|
||||
- boolean anyDeepSleep = players.stream().anyMatch(Player::isSleepingLongEnough);
|
||||
- int i = (int) sleepingPlayers.stream().filter(player -> player.isSleepingLongEnough() || player.fauxSleeping || (player.level().purpurConfig.idleTimeoutCountAsSleeping && player.isAfk())).count(); // Purpur - AFK API
|
||||
- boolean anyDeepSleep = sleepingPlayers.stream().anyMatch(Player::isSleepingLongEnough);
|
||||
- return anyDeepSleep && i >= this.sleepersNeeded(requiredSleepPercentage);
|
||||
+ // Leaf start - Remove stream and double iteration in enough deep sleeping player check
|
||||
+ int count = 0;
|
||||
+ boolean anyPlayerSleeping = false;
|
||||
|
||||
- return anyDeepSleep && j >= this.sleepersNeeded(percentage);
|
||||
+ for (ServerPlayer player : players) {
|
||||
+
|
||||
+ for (ServerPlayer player : sleepingPlayers) {
|
||||
+ final boolean isSleepingLongEnough = player.isSleepingLongEnough();
|
||||
+
|
||||
+ if (isSleepingLongEnough) {
|
||||
+ anyPlayerSleeping = true;
|
||||
+ }
|
||||
+
|
||||
+ if (isSleepingLongEnough || player.fauxSleeping || (player.level().purpurConfig.idleTimeoutCountAsSleeping && player.isAfk())) { // Purpur
|
||||
+ if (isSleepingLongEnough || player.fauxSleeping || (player.level().purpurConfig.idleTimeoutCountAsSleeping && player.isAfk())) { // Purpur - AFK API
|
||||
+ count++;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return anyPlayerSleeping && count >= this.sleepersNeeded(percentage);
|
||||
+ return anyPlayerSleeping && count >= this.sleepersNeeded(requiredSleepPercentage);
|
||||
+ // Leaf end - Remove stream and double iteration in enough deep sleeping player check
|
||||
// CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Sat, 5 Oct 2024 15:39:15 -0400
|
||||
Subject: [PATCH] Remove stream in trial spawner ticking
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerState.java b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerState.java
|
||||
index 02723e61684fcf36094d7b9c81f6ab87ad6f620a..fc340def138824c7f922788e3dce48adfc1258dd 100644
|
||||
--- a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerState.java
|
||||
+++ b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerState.java
|
||||
@@ -173,17 +173,21 @@ public enum TrialSpawnerState implements StringRepresentable {
|
||||
}
|
||||
|
||||
private static Optional<Vec3> calculatePositionToSpawnSpawner(ServerLevel level, BlockPos pos, TrialSpawner spawner, TrialSpawnerData spawnerData) {
|
||||
- List<Player> list = spawnerData.detectedPlayers
|
||||
- .stream()
|
||||
- .map(level::getPlayerByUUID)
|
||||
- .filter(Objects::nonNull)
|
||||
- .filter(
|
||||
- player -> !player.isCreative()
|
||||
- && !player.isSpectator()
|
||||
- && player.isAlive()
|
||||
- && player.distanceToSqr(pos.getCenter()) <= Mth.square(spawner.getRequiredPlayerRange())
|
||||
- )
|
||||
- .toList();
|
||||
+ // Leaf start - Remove stream in trial spawner ticking
|
||||
+ List<Player> list = new java.util.ArrayList<>();
|
||||
+
|
||||
+ for (UUID uuid : spawnerData.detectedPlayers) {
|
||||
+ Player player = level.getPlayerByUUID(uuid);
|
||||
+
|
||||
+ if (player != null
|
||||
+ && !player.isCreative()
|
||||
+ && !player.isSpectator()
|
||||
+ && player.isAlive()
|
||||
+ && player.distanceToSqr(pos.getCenter()) <= Mth.square(spawner.getRequiredPlayerRange())) {
|
||||
+ list.add(player);
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaf end - Remove stream in trial spawner ticking
|
||||
if (list.isEmpty()) {
|
||||
return Optional.empty();
|
||||
} else {
|
||||
@@ -203,16 +207,29 @@ public enum TrialSpawnerState implements StringRepresentable {
|
||||
|
||||
@Nullable
|
||||
private static Entity selectEntityToSpawnItemAbove(List<Player> player, Set<UUID> currentMobs, TrialSpawner spawner, BlockPos pos, ServerLevel level) {
|
||||
- Stream<Entity> stream = currentMobs.stream()
|
||||
- .map(level::getEntity)
|
||||
- .filter(Objects::nonNull)
|
||||
- .filter(entity -> entity.isAlive() && entity.distanceToSqr(pos.getCenter()) <= Mth.square(spawner.getRequiredPlayerRange()));
|
||||
- List<? extends Entity> list = level.random.nextBoolean() ? stream.toList() : player;
|
||||
- if (list.isEmpty()) {
|
||||
- return null;
|
||||
+ // Leaf start - Remove stream in trial spawner ticking
|
||||
+ if (level.random.nextBoolean()) {
|
||||
+ List<Entity> list = new java.util.ArrayList<>();
|
||||
+ for (UUID uuid : currentMobs) {
|
||||
+ Entity entity = level.getEntity(uuid);
|
||||
+ if (entity != null && entity.isAlive() && entity.distanceToSqr(pos.getCenter()) <= Mth.square(spawner.getRequiredPlayerRange())) {
|
||||
+ list.add(entity);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (list.isEmpty()) {
|
||||
+ return null;
|
||||
+ } else {
|
||||
+ return list.size() == 1 ? list.getFirst() : Util.getRandom(list, level.random);
|
||||
+ }
|
||||
} else {
|
||||
- return list.size() == 1 ? list.getFirst() : Util.getRandom(list, level.random);
|
||||
+ if (player.isEmpty()) {
|
||||
+ return null;
|
||||
+ } else {
|
||||
+ return player.size() == 1 ? player.getFirst() : Util.getRandom(player, level.random);
|
||||
+ }
|
||||
}
|
||||
+ // Leaf end - Remove stream in trial spawner ticking
|
||||
}
|
||||
|
||||
private boolean timeToSpawnItemSpawner(ServerLevel level, TrialSpawnerData spawnerData) {
|
||||
@@ -0,0 +1,79 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
Date: Sat, 26 Oct 2024 00:06:04 +0800
|
||||
Subject: [PATCH] Remove stream in Brain
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/Brain.java b/net/minecraft/world/entity/ai/Brain.java
|
||||
index 450396468b23fd90cb8036dbbdd0927051f907af..402279ff78f9e9eb74c63d35ec1968d239228d70 100644
|
||||
--- a/net/minecraft/world/entity/ai/Brain.java
|
||||
+++ b/net/minecraft/world/entity/ai/Brain.java
|
||||
@@ -70,13 +70,22 @@ public class Brain<E extends LivingEntity> {
|
||||
(new MapCodec<Brain<E>>() {
|
||||
@Override
|
||||
public <T> Stream<T> keys(DynamicOps<T> ops) {
|
||||
- return memoryTypes.stream()
|
||||
- .flatMap(
|
||||
- memoryModuleType -> memoryModuleType.getCodec()
|
||||
- .map(codec -> BuiltInRegistries.MEMORY_MODULE_TYPE.getKey((MemoryModuleType<?>)memoryModuleType))
|
||||
- .stream()
|
||||
- )
|
||||
- .map(resourceLocation -> ops.createString(resourceLocation.toString()));
|
||||
+ // Leaf start - Remove stream in Brain
|
||||
+ List<T> results = new java.util.ArrayList<>();
|
||||
+
|
||||
+ for (MemoryModuleType<?> memoryModuleType : memoryTypes) {
|
||||
+ final Optional<?> codec = memoryModuleType.getCodec();
|
||||
+
|
||||
+ if (codec.isPresent()) {
|
||||
+ final net.minecraft.resources.ResourceLocation resourceLocation = BuiltInRegistries.MEMORY_MODULE_TYPE.getKey(memoryModuleType);
|
||||
+ final T opsResult = ops.createString(resourceLocation.toString());
|
||||
+
|
||||
+ results.add(opsResult);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return results.stream();
|
||||
+ // Leaf end - Remove stream in Brain
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,7 +120,7 @@ public class Brain<E extends LivingEntity> {
|
||||
|
||||
@Override
|
||||
public <T> RecordBuilder<T> encode(Brain<E> input, DynamicOps<T> ops, RecordBuilder<T> prefix) {
|
||||
- input.memories().forEach(memoryValue -> memoryValue.serialize(ops, prefix));
|
||||
+ input.serializeMemories(ops, prefix); // Leaf - Remove stream in Brain
|
||||
return prefix;
|
||||
}
|
||||
})
|
||||
@@ -153,8 +162,28 @@ public class Brain<E extends LivingEntity> {
|
||||
}
|
||||
|
||||
Stream<Brain.MemoryValue<?>> memories() {
|
||||
- return this.memories.entrySet().stream().map(memory -> Brain.MemoryValue.createUnchecked(memory.getKey(), memory.getValue()));
|
||||
+ // Leaf start - Remove stream in Brain
|
||||
+ return memoriesList().stream();
|
||||
+ }
|
||||
+
|
||||
+ List<Brain.MemoryValue<?>> memoriesList() {
|
||||
+ List<Brain.MemoryValue<?>> result = new java.util.ArrayList<>();
|
||||
+
|
||||
+ for (Entry<MemoryModuleType<?>, Optional<? extends ExpirableValue<?>>> memory : this.memories.entrySet()) {
|
||||
+ result.add(Brain.MemoryValue.createUnchecked(memory.getKey(), memory.getValue()));
|
||||
+ }
|
||||
+
|
||||
+ return result;
|
||||
+ }
|
||||
+
|
||||
+ <T> void serializeMemories(DynamicOps<T> dynamicOps, RecordBuilder<T> recordBuilder) {
|
||||
+ for (Entry<MemoryModuleType<?>, Optional<? extends ExpirableValue<?>>> memory : this.memories.entrySet()) {
|
||||
+ final Brain.MemoryValue<?> result = Brain.MemoryValue.createUnchecked(memory.getKey(), memory.getValue());
|
||||
+
|
||||
+ result.serialize(dynamicOps, recordBuilder);
|
||||
+ }
|
||||
}
|
||||
+ // Leaf end - Remove stream in Brain
|
||||
|
||||
public boolean hasMemoryValue(MemoryModuleType<?> type) {
|
||||
return this.checkMemory(type, MemoryStatus.VALUE_PRESENT);
|
||||
@@ -0,0 +1,36 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
Date: Sat, 26 Oct 2024 00:56:24 +0800
|
||||
Subject: [PATCH] Remove stream in BehaviorUtils
|
||||
|
||||
Dreeam TODO: Check this
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java b/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
|
||||
index 800bc29502ed46bd77cb04c0a79143898f109a48..77fa472d970c0f187f228b06e0b459ebdcaeb7fd 100644
|
||||
--- a/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
|
||||
@@ -109,10 +109,20 @@ public class BehaviorUtils {
|
||||
|
||||
public static SectionPos findSectionClosestToVillage(ServerLevel serverLevel, SectionPos sectionPos, int radius) {
|
||||
int i = serverLevel.sectionsToVillage(sectionPos);
|
||||
- return SectionPos.cube(sectionPos, radius)
|
||||
- .filter(pos -> serverLevel.sectionsToVillage(pos) < i)
|
||||
- .min(Comparator.comparingInt(serverLevel::sectionsToVillage))
|
||||
- .orElse(sectionPos);
|
||||
+ // Leaf start - Remove stream in BehaviorUtils
|
||||
+ SectionPos closestSection = sectionPos;
|
||||
+ int closestDistance = i;
|
||||
+
|
||||
+ for (SectionPos pos : SectionPos.cube(sectionPos, radius).toList()) {
|
||||
+ int distance = serverLevel.sectionsToVillage(pos);
|
||||
+ if (distance < closestDistance) {
|
||||
+ closestDistance = distance;
|
||||
+ closestSection = pos;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return closestSection;
|
||||
+ // Leaf end - Remove stream in BehaviorUtils
|
||||
}
|
||||
|
||||
public static boolean isWithinAttackRange(Mob mob, LivingEntity target, int cooldown) {
|
||||
@@ -0,0 +1,54 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
Date: Sat, 26 Oct 2024 14:04:54 +0800
|
||||
Subject: [PATCH] Remove stream in YieldJobSite
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/behavior/YieldJobSite.java b/net/minecraft/world/entity/ai/behavior/YieldJobSite.java
|
||||
index 37ad79e201e36a1a9520219e3faa4dcffa7b4dfd..ccfbbdfe6860d6a211b07d384eba03f857ebf6b0 100644
|
||||
--- a/net/minecraft/world/entity/ai/behavior/YieldJobSite.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/YieldJobSite.java
|
||||
@@ -38,23 +38,27 @@ public class YieldJobSite {
|
||||
if (type.isEmpty()) {
|
||||
return true;
|
||||
} else {
|
||||
- instance.<List<LivingEntity>>get(nearestLivingEntities)
|
||||
- .stream()
|
||||
- .filter(nearEntity -> nearEntity instanceof Villager && nearEntity != villager)
|
||||
- .map(nearEntity -> (Villager)nearEntity)
|
||||
- .filter(LivingEntity::isAlive)
|
||||
- .filter(nearVillager -> nearbyWantsJobsite(type.get(), nearVillager, blockPos))
|
||||
- .findFirst()
|
||||
- .ifPresent(nearVillager -> {
|
||||
- walkTarget.erase();
|
||||
- lookTarget.erase();
|
||||
- potentialJobSite.erase();
|
||||
- if (nearVillager.getBrain().getMemory(MemoryModuleType.JOB_SITE).isEmpty()) {
|
||||
- BehaviorUtils.setWalkAndLookTargetMemories(nearVillager, blockPos, speedModifier, 1);
|
||||
- nearVillager.getBrain().setMemory(MemoryModuleType.POTENTIAL_JOB_SITE, GlobalPos.of(level.dimension(), blockPos));
|
||||
- DebugPackets.sendPoiTicketCountPacket(level, blockPos);
|
||||
+ // Leaf start - Remove stream in YieldJobSite
|
||||
+ List<LivingEntity> mobsList = instance.get(nearestLivingEntities);
|
||||
+ for (LivingEntity nearEntity : mobsList) {
|
||||
+ if (nearEntity instanceof Villager nearVillager && nearEntity != villager && nearEntity.isAlive()) {
|
||||
+ if (nearbyWantsJobsite(type.get(), nearVillager, blockPos)) {
|
||||
+ walkTarget.erase();
|
||||
+ lookTarget.erase();
|
||||
+ potentialJobSite.erase();
|
||||
+
|
||||
+ if (nearVillager.getBrain().getMemory(MemoryModuleType.JOB_SITE).isEmpty()) {
|
||||
+ BehaviorUtils.setWalkAndLookTargetMemories(nearVillager, blockPos, speedModifier, 1);
|
||||
+ nearVillager.getBrain().setMemory(MemoryModuleType.POTENTIAL_JOB_SITE, GlobalPos.of(level.dimension(), blockPos));
|
||||
+ DebugPackets.sendPoiTicketCountPacket(level, blockPos);
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ break;
|
||||
}
|
||||
- });
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaf end - Remove stream in YieldJobSite
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -8,50 +8,51 @@ while ticking Villager farms, so just replace it with for loop =-=
|
||||
Before: 164ms
|
||||
After: 18ms
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java
|
||||
index e1ff702e56adef6c8a572b078b49de2143c4ce7e..aa1a59bdaad5ac7b735524c3595a8589a92618cd 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java
|
||||
@@ -22,17 +22,39 @@ public class PlayerSensor extends Sensor<LivingEntity> {
|
||||
diff --git a/net/minecraft/world/entity/ai/sensing/PlayerSensor.java b/net/minecraft/world/entity/ai/sensing/PlayerSensor.java
|
||||
index 6233e6b48aaa69ba9f577d0b480b1cdf2f55d16e..996c93f2b7ffd83134535f75c0ead45cc34ef13c 100644
|
||||
--- a/net/minecraft/world/entity/ai/sensing/PlayerSensor.java
|
||||
+++ b/net/minecraft/world/entity/ai/sensing/PlayerSensor.java
|
||||
@@ -22,17 +22,40 @@ public class PlayerSensor extends Sensor<LivingEntity> {
|
||||
|
||||
@Override
|
||||
protected void doTick(ServerLevel world, LivingEntity entity) {
|
||||
- List<Player> list = world.players()
|
||||
protected void doTick(ServerLevel level, LivingEntity entity) {
|
||||
- List<Player> list = level.players()
|
||||
- .stream()
|
||||
- .filter(EntitySelector.NO_SPECTATORS)
|
||||
- .filter(player -> entity.closerThan(player, this.getFollowDistance(entity)))
|
||||
- .filter(serverPlayer -> entity.closerThan(serverPlayer, this.getFollowDistance(entity)))
|
||||
- .sorted(Comparator.comparingDouble(entity::distanceToSqr))
|
||||
- .collect(Collectors.toList());
|
||||
+ // Leaf start - Remove stream in PlayerSensor
|
||||
+ List<Player> list = new java.util.ArrayList<>();
|
||||
+ for (Player player : world.players()) {
|
||||
+ if (!EntitySelector.NO_SPECTATORS.test(player)) {
|
||||
+ for (Player serverPlayer : level.players()) {
|
||||
+ if (!EntitySelector.NO_SPECTATORS.test(serverPlayer)) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (!entity.closerThan(player, this.getFollowDistance(entity))) {
|
||||
+ if (!entity.closerThan(serverPlayer, this.getFollowDistance(entity))) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ list.add(player);
|
||||
+
|
||||
+ list.add(serverPlayer);
|
||||
+ }
|
||||
+ list.sort(Comparator.comparingDouble(entity::distanceToSqr));
|
||||
+ // Leaf end - Remove stream in PlayerSensor
|
||||
Brain<?> brain = entity.getBrain();
|
||||
brain.setMemory(MemoryModuleType.NEAREST_PLAYERS, list);
|
||||
- List<Player> list2 = list.stream().filter(player -> isEntityTargetable(world, entity, player)).collect(Collectors.toList());
|
||||
- List<Player> list1 = list.stream().filter(player -> isEntityTargetable(level, entity, player)).collect(Collectors.toList());
|
||||
+ // Leaf start - Remove stream in PlayerSensor
|
||||
+ List<Player> list2 = new java.util.ArrayList<>();
|
||||
+ List<Player> list1 = new java.util.ArrayList<>();
|
||||
+ for (Player player : list) {
|
||||
+ if (isEntityTargetable(world, entity, player)) {
|
||||
+ list2.add(player);
|
||||
+ if (isEntityTargetable(level, entity, player)) {
|
||||
+ list1.add(player);
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaf end - Remove stream in PlayerSensor
|
||||
brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_PLAYER, list2.isEmpty() ? null : list2.get(0));
|
||||
- Optional<Player> optional = list2.stream().filter(player -> isEntityAttackable(world, entity, player)).findFirst();
|
||||
brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_PLAYER, list1.isEmpty() ? null : list1.get(0));
|
||||
- Optional<Player> optional = list1.stream().filter(player -> isEntityAttackable(level, entity, player)).findFirst();
|
||||
+ // Leaf start - Remove stream in PlayerSensor
|
||||
+ Optional<Player> optional = Optional.empty();
|
||||
+ for (Player player : list2) {
|
||||
+ if (isEntityAttackable(world, entity, player)) {
|
||||
+ for (Player player : list1) {
|
||||
+ if (isEntityAttackable(level, entity, player)) {
|
||||
+ optional = Optional.of(player);
|
||||
+ break;
|
||||
+ }
|
||||
@@ -0,0 +1,31 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
Date: Tue, 9 Nov 2077 00:00:00 +0800
|
||||
Subject: [PATCH] Remove stream in GolemSensor
|
||||
|
||||
Stream operations in GolemSensor is really expensive and takes
|
||||
up 80% time per method call.
|
||||
Before: 192ms
|
||||
After: 17ms
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/sensing/GolemSensor.java b/net/minecraft/world/entity/ai/sensing/GolemSensor.java
|
||||
index 84d9e2a43adbabda8401e8ad8dd8d87f7dbeeea7..ed277d93254a30a817dd8246539c292240dc9669 100644
|
||||
--- a/net/minecraft/world/entity/ai/sensing/GolemSensor.java
|
||||
+++ b/net/minecraft/world/entity/ai/sensing/GolemSensor.java
|
||||
@@ -34,7 +34,15 @@ public class GolemSensor extends Sensor<LivingEntity> {
|
||||
public static void checkForNearbyGolem(LivingEntity livingEntity) {
|
||||
Optional<List<LivingEntity>> memory = livingEntity.getBrain().getMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES);
|
||||
if (!memory.isEmpty()) {
|
||||
- boolean flag = memory.get().stream().anyMatch(entity -> entity.getType().equals(EntityType.IRON_GOLEM));
|
||||
+ // Leaf start - Remove stream in GolemSensor
|
||||
+ boolean flag = false;
|
||||
+ for (LivingEntity entity : memory.get()) {
|
||||
+ if (entity.getType().equals(EntityType.IRON_GOLEM)) {
|
||||
+ flag = true;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaf end - Remove stream in GolemSensor
|
||||
if (flag) {
|
||||
golemDetected(livingEntity);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Taiyou06 <kaandindar21@gmail.com>
|
||||
Date: Tue, 9 Nov 2077 00:00:00 +0800
|
||||
Subject: [PATCH] Remove stream in GateBehavior
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/behavior/GateBehavior.java b/net/minecraft/world/entity/ai/behavior/GateBehavior.java
|
||||
index bd31d1cac0d022a72bd536c41d1ef811886e7068..2830792cd98c0849280aa1e2116fa89f3c8d2c85 100644
|
||||
--- a/net/minecraft/world/entity/ai/behavior/GateBehavior.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/GateBehavior.java
|
||||
@@ -73,9 +73,19 @@ public class GateBehavior<E extends LivingEntity> implements BehaviorControl<E>
|
||||
}
|
||||
}
|
||||
// Paper end - Perf: Remove streams from hot code
|
||||
- if (this.behaviors.stream().noneMatch(behavior -> behavior.getStatus() == Behavior.Status.RUNNING)) {
|
||||
+ // Leaf start - Remove more streams in GateBehavior
|
||||
+ boolean hasRunningTask = false;
|
||||
+ for (final BehaviorControl<? super E> behavior : this.behaviors) {
|
||||
+ if (behavior.getStatus() == Behavior.Status.RUNNING) {
|
||||
+ hasRunningTask = true;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!hasRunningTask) {
|
||||
this.doStop(level, entity, gameTime);
|
||||
}
|
||||
+ // Leaf end - Remove more streams in GateBehavior
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,76 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Taiyou06 <kaandindar21@gmail.com>
|
||||
Date: Mon, 11 Nov 2024 16:55:50 -0500
|
||||
Subject: [PATCH] Remove stream in updateFluidOnEyes
|
||||
|
||||
|
||||
diff --git a/net/minecraft/core/Holder.java b/net/minecraft/core/Holder.java
|
||||
index 6c7edbbf3935c40ccb78bee680ea75431718b9bd..a1b4dc70d555cce5e06c0298736d8b89e04a96be 100644
|
||||
--- a/net/minecraft/core/Holder.java
|
||||
+++ b/net/minecraft/core/Holder.java
|
||||
@@ -29,6 +29,8 @@ public interface Holder<T> {
|
||||
|
||||
Stream<TagKey<T>> tags();
|
||||
|
||||
+ Set<TagKey<T>> tagsAsSet(); // Leaf - Remove stream in updateFluidOnEyes
|
||||
+
|
||||
Either<ResourceKey<T>, T> unwrap();
|
||||
|
||||
Optional<ResourceKey<T>> unwrapKey();
|
||||
@@ -105,6 +107,13 @@ public interface Holder<T> {
|
||||
public Stream<TagKey<T>> tags() {
|
||||
return Stream.of();
|
||||
}
|
||||
+
|
||||
+ // Leaf start - Remove stream in updateFluidOnEyes
|
||||
+ @Override
|
||||
+ public Set<TagKey<T>> tagsAsSet() {
|
||||
+ return Set.of();
|
||||
+ }
|
||||
+ // Leaf end - Remove stream in updateFluidOnEyes
|
||||
}
|
||||
|
||||
public static enum Kind {
|
||||
@@ -238,6 +247,13 @@ public interface Holder<T> {
|
||||
return this.boundTags().stream();
|
||||
}
|
||||
|
||||
+ // Leaf start - Remove stream in updateFluidOnEyes
|
||||
+ @Override
|
||||
+ public Set<TagKey<T>> tagsAsSet() {
|
||||
+ return this.boundTags();
|
||||
+ }
|
||||
+ // Leaf end - Remove stream in updateFluidOnEyes
|
||||
+
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Reference{" + this.key + "=" + this.value + "}";
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index f7f330758dce7c38e0e0e8ba420df4d83f765cf1..42a6b0b6fe13b448583988b3d2f840540b5670e7 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -1982,7 +1982,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
FluidState fluidState = this.level().getFluidState(blockPos);
|
||||
double d = blockPos.getY() + fluidState.getHeight(this.level(), blockPos);
|
||||
if (d > eyeY) {
|
||||
- fluidState.getTags().forEach(this.fluidOnEyes::add);
|
||||
+ this.fluidOnEyes.addAll(fluidState.getTagsAsSet()); // Leaf - Remove stream in updateFluidOnEyes
|
||||
+
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/net/minecraft/world/level/material/FluidState.java b/net/minecraft/world/level/material/FluidState.java
|
||||
index 481cb46973acb9785fdee5732e98aac560c6ec08..06581fe010ca722d62d0b6d3c44d845f9db0231f 100644
|
||||
--- a/net/minecraft/world/level/material/FluidState.java
|
||||
+++ b/net/minecraft/world/level/material/FluidState.java
|
||||
@@ -158,4 +158,10 @@ public final class FluidState extends StateHolder<Fluid, FluidState> implements
|
||||
public Stream<TagKey<Fluid>> getTags() {
|
||||
return this.owner.builtInRegistryHolder().tags();
|
||||
}
|
||||
+
|
||||
+ // Leaf start - Remove stream in updateFluidOnEyes
|
||||
+ public java.util.Set<TagKey<Fluid>> getTagsAsSet() {
|
||||
+ return this.owner.builtInRegistryHolder().tagsAsSet();
|
||||
+ }
|
||||
+ // Leaf end - Remove stream in updateFluidOnEyes
|
||||
}
|
||||
@@ -4,18 +4,18 @@ Date: Tue, 26 Nov 2024 19:58:29 -0500
|
||||
Subject: [PATCH] Remove stream in matchingSlot
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/enchantment/Enchantment.java b/src/main/java/net/minecraft/world/item/enchantment/Enchantment.java
|
||||
index e2a928b0271a280debe684f09c6ed8c7655aa4a2..bcec7370b875e403ffd4cec179ba07d80b1bc3a0 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/enchantment/Enchantment.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/enchantment/Enchantment.java
|
||||
diff --git a/net/minecraft/world/item/enchantment/Enchantment.java b/net/minecraft/world/item/enchantment/Enchantment.java
|
||||
index 7a620eb92b1e672cedd72ec4d986c01eba337686..183874d90d576d740c5d924accc5c0d7fdb8450c 100644
|
||||
--- a/net/minecraft/world/item/enchantment/Enchantment.java
|
||||
+++ b/net/minecraft/world/item/enchantment/Enchantment.java
|
||||
@@ -126,7 +126,15 @@ public record Enchantment(Component description, Enchantment.EnchantmentDefiniti
|
||||
}
|
||||
|
||||
public boolean matchingSlot(EquipmentSlot slot) {
|
||||
- return this.definition.slots().stream().anyMatch(slotx -> slotx.test(slot));
|
||||
- return this.definition.slots().stream().anyMatch(equipmentSlotGroup -> equipmentSlotGroup.test(slot));
|
||||
+ // Leaf start - Remove stream in matchingSlot
|
||||
+ for (EquipmentSlotGroup slotx : this.definition.slots()) {
|
||||
+ if (slotx.test(slot)) {
|
||||
+ for (EquipmentSlotGroup equipmentSlotGroup : this.definition.slots()) {
|
||||
+ if (equipmentSlotGroup.test(slot)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
@@ -5,11 +5,11 @@ Subject: [PATCH] Replace Entity active effects map with optimized collection
|
||||
|
||||
Dreeam TODO: check this
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 39c898e0b5ec7203491982ef56cfdcf507d040d7..7aab6970bf73108435e79a6ef39896e9fca8659e 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -208,6 +208,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
||||
index 8b096a0f9f23a9b90ef88414e8749a514e3910cf..d8a93bd85580c4bdc52d6f368b78ad210c265ae5 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -211,6 +211,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
};
|
||||
private final AttributeMap attributes;
|
||||
public CombatTracker combatTracker = new CombatTracker(this);
|
||||
@@ -18,9 +18,9 @@ index 39c898e0b5ec7203491982ef56cfdcf507d040d7..7aab6970bf73108435e79a6ef39896e9
|
||||
+ // Also need to check whether call from out of main using bukkit api
|
||||
+ //public final Map<Holder<MobEffect>, MobEffectInstance> activeEffects = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(0); // Leaf - Replace Entity active effects map with optimized collection
|
||||
public final Map<Holder<MobEffect>, MobEffectInstance> activeEffects = Maps.newHashMap();
|
||||
private final NonNullList<ItemStack> lastHandItemStacks;
|
||||
private final NonNullList<ItemStack> lastArmorItemStacks;
|
||||
@@ -1031,8 +1035,9 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
private final NonNullList<ItemStack> lastHandItemStacks = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
private final NonNullList<ItemStack> lastArmorItemStacks = NonNullList.withSize(4, ItemStack.EMPTY);
|
||||
@@ -990,15 +994,16 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
private void updateSynchronizedMobEffectParticles() {
|
||||
// Leaf start - Remove stream in entity visible effects filter
|
||||
List<ParticleOptions> list = new ArrayList<>();
|
||||
@@ -31,12 +31,11 @@ index 39c898e0b5ec7203491982ef56cfdcf507d040d7..7aab6970bf73108435e79a6ef39896e9
|
||||
if (effect.isVisible()) {
|
||||
list.add(effect.getParticleOptions());
|
||||
}
|
||||
@@ -1040,7 +1045,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
// Leaf end - Remove stream in entity visible effects filter
|
||||
|
||||
this.entityData.set(LivingEntity.DATA_EFFECT_PARTICLES, list);
|
||||
- this.entityData.set(LivingEntity.DATA_EFFECT_AMBIENCE_ID, LivingEntity.areAllEffectsAmbient(this.activeEffects.values()));
|
||||
+ this.entityData.set(LivingEntity.DATA_EFFECT_AMBIENCE_ID, LivingEntity.areAllEffectsAmbient(effectsValues)); // Leaf - Replace Entity active effects map with optimized collection
|
||||
this.entityData.set(DATA_EFFECT_PARTICLES, list);
|
||||
- this.entityData.set(DATA_EFFECT_AMBIENCE_ID, areAllEffectsAmbient(this.activeEffects.values()));
|
||||
+ this.entityData.set(DATA_EFFECT_AMBIENCE_ID, areAllEffectsAmbient(effectsValues)); // Leaf - Replace Entity active effects map with optimized collection
|
||||
}
|
||||
|
||||
private void updateGlowingStatus() {
|
||||
@@ -4,16 +4,16 @@ Date: Sat, 7 Sep 2024 02:12:55 -0400
|
||||
Subject: [PATCH] Replace criterion map with optimized collection
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java
|
||||
index d92fa5893fa030cedf63cab9cc5f2b941af02290..134946144b60a3f400652302c90e3ec0ed035a40 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerAdvancements.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java
|
||||
@@ -63,7 +63,7 @@ public class PlayerAdvancements {
|
||||
diff --git a/net/minecraft/server/PlayerAdvancements.java b/net/minecraft/server/PlayerAdvancements.java
|
||||
index e4ea26ae84efde7ce54e08a246a6ea2ae2a17151..26de042df58bcf486ed538f66edf2d37caab6ed6 100644
|
||||
--- a/net/minecraft/server/PlayerAdvancements.java
|
||||
+++ b/net/minecraft/server/PlayerAdvancements.java
|
||||
@@ -60,7 +60,7 @@ public class PlayerAdvancements {
|
||||
private AdvancementHolder lastSelectedTab;
|
||||
private boolean isFirstPacket = true;
|
||||
private final Codec<PlayerAdvancements.Data> codec;
|
||||
- public final Map<net.minecraft.advancements.critereon.SimpleCriterionTrigger<?>, Set<CriterionTrigger.Listener<?>>> criterionData = new java.util.IdentityHashMap<>(); // Paper - fix advancement data player leakage
|
||||
+ public final Map<net.minecraft.advancements.critereon.SimpleCriterionTrigger<?>, Set<CriterionTrigger.Listener<?>>> criterionData = new it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap<>(); // Paper - fix advancement data player leakage // Leaf - Replace criterion map with optimized collection
|
||||
|
||||
public PlayerAdvancements(DataFixer dataFixer, PlayerList playerManager, ServerAdvancementManager advancementLoader, Path filePath, ServerPlayer owner) {
|
||||
this.playerList = playerManager;
|
||||
public PlayerAdvancements(DataFixer dataFixer, PlayerList playerList, ServerAdvancementManager manager, Path playerSavePath, ServerPlayer player) {
|
||||
this.playerList = playerList;
|
||||
@@ -4,10 +4,10 @@ Date: Sat, 26 Oct 2024 00:06:04 +0800
|
||||
Subject: [PATCH] Replace brain maps with optimized collection
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/Brain.java b/src/main/java/net/minecraft/world/entity/ai/Brain.java
|
||||
index 88ba505fc5ca084317aaf6be402472ccd42413d8..65bd8c2cccd0a4a68984ea8ff4cd3cf365330630 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/Brain.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/Brain.java
|
||||
diff --git a/net/minecraft/world/entity/ai/Brain.java b/net/minecraft/world/entity/ai/Brain.java
|
||||
index 402279ff78f9e9eb74c63d35ec1968d239228d70..5eaa1dec9fbe72a22c34331a28f7b7115fb3aeba 100644
|
||||
--- a/net/minecraft/world/entity/ai/Brain.java
|
||||
+++ b/net/minecraft/world/entity/ai/Brain.java
|
||||
@@ -45,14 +45,18 @@ public class Brain<E extends LivingEntity> {
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
private final Supplier<Codec<Brain<E>>> codec;
|
||||
@@ -0,0 +1,97 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
Date: Fri, 14 Jun 2024 23:19:55 +0800
|
||||
Subject: [PATCH] Reduce worldgen allocations
|
||||
|
||||
This change optimizes the way SurfaceRules update their biome supplier,avoiding unnecessary object creations and thus reducing memory allocations
|
||||
during world generation. The update method now reuses the existing PositionalBiomeGetter object if it's already present, otherwise it
|
||||
initializes a new one.
|
||||
Additionally, the tryApply method in SurfaceRules now avoids iterator
|
||||
allocation by directly accessing the rules list, which further contributes
|
||||
to reducing garbage collection pressure during world generation.
|
||||
|
||||
diff --git a/net/minecraft/world/level/levelgen/NoiseChunk.java b/net/minecraft/world/level/levelgen/NoiseChunk.java
|
||||
index f861f9e087182470a3bbb22678dbdacb8a73e943..18304ff64a3b06713deac192cf0555bc651ec2b8 100644
|
||||
--- a/net/minecraft/world/level/levelgen/NoiseChunk.java
|
||||
+++ b/net/minecraft/world/level/levelgen/NoiseChunk.java
|
||||
@@ -362,7 +362,16 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
|
||||
}
|
||||
|
||||
protected DensityFunction wrap(DensityFunction densityFunction) {
|
||||
- return this.wrapped.computeIfAbsent(densityFunction, this::wrapNew);
|
||||
+ // Leaf start - Avoid lambda allocation
|
||||
+ DensityFunction func = this.wrapped.get(densityFunction);
|
||||
+
|
||||
+ if (func == null) {
|
||||
+ func = this.wrapNew(densityFunction);
|
||||
+ this.wrapped.put(densityFunction, func);
|
||||
+ }
|
||||
+
|
||||
+ return func;
|
||||
+ // Leaf end - Avoid lambda allocation
|
||||
}
|
||||
|
||||
private DensityFunction wrapNew(DensityFunction densityFunction) {
|
||||
diff --git a/net/minecraft/world/level/levelgen/SurfaceRules.java b/net/minecraft/world/level/levelgen/SurfaceRules.java
|
||||
index 0948c8db90605a15a043b5c5bc74edecd7f9db1b..1d3dc17a5ba48ae03681d769c78238732f5f56bf 100644
|
||||
--- a/net/minecraft/world/level/levelgen/SurfaceRules.java
|
||||
+++ b/net/minecraft/world/level/levelgen/SurfaceRules.java
|
||||
@@ -313,8 +313,14 @@ public class SurfaceRules {
|
||||
}
|
||||
|
||||
protected void updateY(int stoneDepthAbove, int stoneDepthBelow, int waterHeight, int blockX, int blockY, int blockZ) {
|
||||
- this.lastUpdateY++;
|
||||
- this.biome = Suppliers.memoize(() -> this.biomeGetter.apply(this.pos.set(blockX, blockY, blockZ)));
|
||||
+ // Leaf start - Reuse supplier object instead of creating new ones every time
|
||||
+ ++this.lastUpdateY;
|
||||
+ Supplier<Holder<Biome>> getter = this.biome;
|
||||
+ if (getter == null) {
|
||||
+ this.biome = getter = new org.dreeam.leaf.util.biome.PositionalBiomeGetter(this.biomeGetter, this.pos);
|
||||
+ }
|
||||
+ ((org.dreeam.leaf.util.biome.PositionalBiomeGetter) getter).update(blockX, blockY, blockZ);
|
||||
+ // Leaf end - Reuse supplier object instead of creating new ones every time
|
||||
this.blockY = blockY;
|
||||
this.waterHeight = waterHeight;
|
||||
this.stoneDepthBelow = stoneDepthBelow;
|
||||
@@ -582,8 +588,12 @@ public class SurfaceRules {
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockState tryApply(int x, int y, int z) {
|
||||
- for (SurfaceRules.SurfaceRule surfaceRule : this.rules) {
|
||||
- BlockState blockState = surfaceRule.tryApply(x, y, z);
|
||||
+ // Leaf start - Avoid iterator allocation
|
||||
+ int size = this.rules.size();
|
||||
+ //noinspection ForLoopReplaceableByForEach
|
||||
+ for (int i = 0; i < size; i++) {
|
||||
+ BlockState blockState = this.rules.get(i).tryApply(x, y, z);
|
||||
+ // Leaf end - Avoid iterator allocation
|
||||
if (blockState != null) {
|
||||
return blockState;
|
||||
}
|
||||
diff --git a/net/minecraft/world/level/levelgen/material/MaterialRuleList.java b/net/minecraft/world/level/levelgen/material/MaterialRuleList.java
|
||||
index 1605cc013d5a89a5d3cb68365bdcc18e2dd0a921..923f1d2058d66822e28cf3aca2b0dba6150c24fb 100644
|
||||
--- a/net/minecraft/world/level/levelgen/material/MaterialRuleList.java
|
||||
+++ b/net/minecraft/world/level/levelgen/material/MaterialRuleList.java
|
||||
@@ -9,13 +9,16 @@ public record MaterialRuleList(NoiseChunk.BlockStateFiller[] materialRuleList) i
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockState calculate(DensityFunction.FunctionContext context) {
|
||||
- for (NoiseChunk.BlockStateFiller blockStateFiller : this.materialRuleList) {
|
||||
- BlockState blockState = blockStateFiller.calculate(context);
|
||||
- if (blockState != null) {
|
||||
- return blockState;
|
||||
- }
|
||||
+ // Leaf start - Avoid iterator allocation
|
||||
+ BlockState blockState = null;
|
||||
+ int length = this.materialRuleList.length;
|
||||
+
|
||||
+ for (int i = 0; blockState == null && i < length; i++) {
|
||||
+ NoiseChunk.BlockStateFiller blockStateFiller = this.materialRuleList[i];
|
||||
+ blockState = blockStateFiller.calculate(context);
|
||||
}
|
||||
|
||||
- return null;
|
||||
+ return blockState;
|
||||
+ // Leaf end - Avoid iterator allocation
|
||||
}
|
||||
}
|
||||
@@ -5,38 +5,38 @@ Subject: [PATCH] Use caffeine cache kickPermission instead of using
|
||||
google.common.cache
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 615622f3ce63d2150c57cfd9f664bfa8fa5d6124..4ecefd90defffeac792d4cb2375ee2d68513b170 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -344,17 +344,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
// CraftBukkit end
|
||||
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 39b01b3d96d03bca4c33eaddfc54edef23c3df0c..14c75c85c062fb9d2b576bb1cd24f942642fbf8c 100644
|
||||
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -328,17 +328,12 @@ public class ServerGamePacketListenerImpl
|
||||
}
|
||||
|
||||
// Purpur start
|
||||
- private final com.google.common.cache.LoadingCache<CraftPlayer, Boolean> kickPermissionCache = com.google.common.cache.CacheBuilder.newBuilder()
|
||||
// Purpur start - AFK API
|
||||
- private final com.google.common.cache.LoadingCache<org.bukkit.craftbukkit.entity.CraftPlayer, Boolean> kickPermissionCache = com.google.common.cache.CacheBuilder.newBuilder()
|
||||
+ // Leaf start - Use caffeine cache kickPermission instead of using google.common.cache
|
||||
+ private final com.github.benmanes.caffeine.cache.LoadingCache<CraftPlayer, Boolean> kickPermissionCache = com.github.benmanes.caffeine.cache.Caffeine.newBuilder()
|
||||
+ private final com.github.benmanes.caffeine.cache.LoadingCache<org.bukkit.craftbukkit.entity.CraftPlayer, Boolean> kickPermissionCache = com.github.benmanes.caffeine.cache.Caffeine.newBuilder()
|
||||
.maximumSize(1000)
|
||||
.expireAfterWrite(1, java.util.concurrent.TimeUnit.MINUTES)
|
||||
- .build(
|
||||
- new com.google.common.cache.CacheLoader<>() {
|
||||
- @Override
|
||||
- public Boolean load(CraftPlayer player) {
|
||||
- public Boolean load(org.bukkit.craftbukkit.entity.CraftPlayer player) {
|
||||
- return player.hasPermission("purpur.bypassIdleKick");
|
||||
- }
|
||||
- }
|
||||
- );
|
||||
+ .build(player -> player.hasPermission("purpur.bypassIdleKick"));
|
||||
+ // Leaf - Use caffeine cache kickPermission instead of using google.common.cache
|
||||
// Purpur end
|
||||
// Purpur end - AFK API
|
||||
|
||||
public final org.leavesmc.leaves.protocol.syncmatica.exchange.ExchangeTarget exchangeTarget; // Leaves - Syncmatica Protocol
|
||||
@@ -417,7 +412,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L && !this.player.wonGame) { // Paper - Prevent AFK kick while watching end credits
|
||||
// Purpur start
|
||||
@@ -403,7 +398,7 @@ public class ServerGamePacketListenerImpl
|
||||
&& Util.getMillis() - this.player.getLastActionTime() > this.server.getPlayerIdleTimeout() * 1000L * 60L && !this.player.wonGame) { // Paper - Prevent AFK kick while watching end credits
|
||||
// Purpur start - AFK API
|
||||
this.player.setAfk(true);
|
||||
- if (!this.player.level().purpurConfig.idleTimeoutKick || (!Boolean.parseBoolean(System.getenv("PURPUR_FORCE_IDLE_KICK")) && kickPermissionCache.getUnchecked(this.player.getBukkitEntity()))) {
|
||||
+ if (!this.player.level().purpurConfig.idleTimeoutKick || (!Boolean.parseBoolean(System.getenv("PURPUR_FORCE_IDLE_KICK")) && kickPermissionCache.get(this.player.getBukkitEntity()))) { // Leaf - Use caffeine cache kickPermission instead of using google.common.cache
|
||||
return;
|
||||
}
|
||||
// Purpur end
|
||||
// Purpur end - AFK API
|
||||
@@ -0,0 +1,34 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Mon, 24 Jun 2024 10:49:04 +0800
|
||||
Subject: [PATCH] Do not place player if the server is full
|
||||
|
||||
Fix https://github.com/PaperMC/Paper/issues/10668
|
||||
|
||||
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
||||
index 5fe6a295f5b5285a20c535a026e1342f89896fd7..8233b250a8d0e9f26302f6756931d2edfe017504 100644
|
||||
--- a/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/net/minecraft/server/players/PlayerList.java
|
||||
@@ -340,6 +340,13 @@ public abstract class PlayerList {
|
||||
return;
|
||||
}
|
||||
// Gale end - MultiPaper - do not place player in world if kicked before being spawned in
|
||||
+ // Leaf start - Do not place player if the server is full - copied from canPlayerLogin
|
||||
+ if (org.dreeam.leaf.config.modules.fixes.DontPlacePlayerIfFull.enabled && this.realPlayers.size() >= this.maxPlayers && !(player.getBukkitEntity().hasPermission("purpur.joinfullserver") || this.canBypassPlayerLimit(gameProfile))) { // Purpur - Allow player join full server by permission // Leaves - only real player
|
||||
+ connection.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.serverFullMessage)));
|
||||
+ //playerconnection.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.serverFullMessage)), org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT);
|
||||
+ return;
|
||||
+ }
|
||||
+ // Leaf end - Do not place player if the server is full - copied from canPlayerLogin
|
||||
|
||||
org.bukkit.Location loc = ev.getSpawnLocation();
|
||||
serverLevel = ((org.bukkit.craftbukkit.CraftWorld) loc.getWorld()).getHandle();
|
||||
@@ -834,7 +841,7 @@ public abstract class PlayerList {
|
||||
// return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameProfile)
|
||||
// ? Component.translatable("multiplayer.disconnect.server_full")
|
||||
// : null;
|
||||
- if (this.realPlayers.size() >= this.maxPlayers && !(player.hasPermission("purpur.joinfullserver") || this.canBypassPlayerLimit(gameProfile))) { // Purpur - Allow player join full server by permission // Leaves - only real player
|
||||
+ if (this.realPlayers.size() >= this.maxPlayers && !(player.hasPermission("purpur.joinfullserver") || this.canBypassPlayerLimit(gameProfile))) { // Purpur - Allow player join full server by permission // Leaves - only real player // Leaf - Do not place player if the server is full - diff on change
|
||||
event.disallow(org.bukkit.event.player.PlayerLoginEvent.Result.KICK_FULL, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.serverFullMessage)); // Spigot // Paper - Adventure
|
||||
}
|
||||
}
|
||||
199
Leaf-Server/paper-patches/features/0001-Rebrand.patch
Normal file
199
Leaf-Server/paper-patches/features/0001-Rebrand.patch
Normal file
@@ -0,0 +1,199 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Thu, 16 Sep 2021 20:39:45 -0400
|
||||
Subject: [PATCH] Rebrand
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
index 3d8ed4ff9a5a30d123508aeb485250271b528a6e..aa7c5d765114a008e815fcece8c108e95f02293d 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
@@ -592,7 +592,7 @@ public class Metrics {
|
||||
boolean logFailedRequests = config.getBoolean("logFailedRequests", false);
|
||||
// Only start Metrics, if it's enabled in the config
|
||||
if (config.getBoolean("enabled", true)) {
|
||||
- Metrics metrics = new Metrics("Gale", serverUUID, logFailedRequests, Bukkit.getLogger()); // Gale - branding changes - metrics
|
||||
+ Metrics metrics = new Metrics("Leaf", serverUUID, logFailedRequests, Bukkit.getLogger()); // Gale - branding changes - metrics // Leaf
|
||||
|
||||
metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> {
|
||||
String minecraftVersion = Bukkit.getVersion();
|
||||
@@ -602,15 +602,15 @@ public class Metrics {
|
||||
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("players", () -> Bukkit.getOnlinePlayers().size()));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("online_mode", () -> Bukkit.getOnlineMode() ? "online" : "offline"));
|
||||
- final String galeVersion; // Gale - branding changes - metrics
|
||||
+ final String leafVersion; // Gale - branding changes - metrics // Leaf
|
||||
final String implVersion = org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion();
|
||||
if (implVersion != null) {
|
||||
final String buildOrHash = implVersion.substring(implVersion.lastIndexOf('-') + 1);
|
||||
- galeVersion = "git-Gale-%s-%s".formatted(Bukkit.getServer().getMinecraftVersion(), buildOrHash); // Gale - branding changes - metrics
|
||||
+ leafVersion = "git-Leaf-%s-%s".formatted(Bukkit.getServer().getMinecraftVersion(), buildOrHash); // Gale - branding changes - metrics // Leaf
|
||||
} else {
|
||||
- galeVersion = "unknown"; // Gale - branding changes - metrics
|
||||
+ leafVersion = "unknown"; // Gale - branding changes - metrics // Leaf
|
||||
}
|
||||
- metrics.addCustomChart(new Metrics.SimplePie("gale_version", () -> galeVersion)); // Gale - branding changes - metrics
|
||||
+ metrics.addCustomChart(new Metrics.SimplePie("leaf_version", () -> leafVersion)); // Gale - branding changes - metrics // Leaf
|
||||
|
||||
metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> {
|
||||
Map<String, Map<String, Integer>> map = new HashMap<>(2); // Gale - metrics - reduce HashMap capacity
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
||||
index b78828e83d8128eace986aeb73213da3b3f905e4..9869bec65f4d0fbd5ed5aff896a8956e7ea2747f 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
||||
@@ -20,7 +20,7 @@ public final class PaperConsole extends SimpleTerminalConsole {
|
||||
@Override
|
||||
protected LineReader buildReader(LineReaderBuilder builder) {
|
||||
builder
|
||||
- .appName("Gale") // Gale - branding changes
|
||||
+ .appName("Leaf") // Gale - branding changes // Leaf
|
||||
.variable(LineReader.HISTORY_FILE, java.nio.file.Paths.get(".console_history"))
|
||||
.completer(new ConsoleCommandCompleter(this.server))
|
||||
.option(LineReader.Option.COMPLETE_IN_WORD, true);
|
||||
diff --git a/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java b/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java
|
||||
index 2596e0ee4df5b96f181e28a742ef345981fc97e3..ea2bca6e0bbc56156c2f744769abd677e6fb0c18 100644
|
||||
--- a/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java
|
||||
+++ b/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java
|
||||
@@ -32,6 +32,7 @@ public record ServerBuildInfoImpl(
|
||||
|
||||
private static final String BRAND_PAPER_NAME = "Paper";
|
||||
private static final String BRAND_GALE_NAME = "Gale"; // Gale - branding changes
|
||||
+ private static final String BRAND_LEAF_NAME = "Leaf"; // Leaf
|
||||
|
||||
private static final String BUILD_DEV = "DEV";
|
||||
|
||||
@@ -43,9 +44,9 @@ public record ServerBuildInfoImpl(
|
||||
this(
|
||||
getManifestAttribute(manifest, ATTRIBUTE_BRAND_ID)
|
||||
.map(Key::key)
|
||||
- .orElse(BRAND_GALE_ID), // Gale - branding changes
|
||||
+ .orElse(BRAND_LEAF_ID), // Gale - branding changes // Leaf
|
||||
getManifestAttribute(manifest, ATTRIBUTE_BRAND_NAME)
|
||||
- .orElse(BRAND_GALE_NAME), // Gale - branding changes
|
||||
+ .orElse(BRAND_LEAF_NAME), // Gale - branding changes // Leaf
|
||||
SharedConstants.getCurrentVersion().getId(),
|
||||
SharedConstants.getCurrentVersion().getName(),
|
||||
getManifestAttribute(manifest, ATTRIBUTE_BUILD_NUMBER)
|
||||
@@ -62,7 +63,9 @@ public record ServerBuildInfoImpl(
|
||||
|
||||
@Override
|
||||
public boolean isBrandCompatible(final @NotNull Key brandId) {
|
||||
- return brandId.equals(this.brandId) || brandId.equals(BRAND_PAPER_ID); // Gale - branding changes
|
||||
+ return brandId.equals(this.brandId)
|
||||
+ || brandId.equals(BRAND_PAPER_ID)
|
||||
+ || brandId.equals(BRAND_GALE_ID); // Gale - branding changes // Leaf
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
index f6bc955c3496b52cda1a20aabd78769803ef471f..bbeb271fb19091897e99970198a8a110a4aa0858 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
@@ -491,7 +491,7 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
this.parsePending();
|
||||
} else {
|
||||
// this.debugTail = this.debugTail.setNext(new CraftAsyncDebugger(this.currentTick + CraftScheduler.RECENT_TICKS, task.getOwner(), task.getTaskClass())); // Paper
|
||||
- task.getOwner().getLogger().log(Level.SEVERE, "Unexpected Async Task in the Sync Scheduler. Report this to Gale"); // Paper // Gale - branding changes
|
||||
+ task.getOwner().getLogger().log(Level.SEVERE, "Unexpected Async Task in the Sync Scheduler. Report this to Leaf"); // Paper // Gale - branding changes // Leaf
|
||||
// We don't need to parse pending
|
||||
// (async tasks must live with race-conditions if they attempt to cancel between these few lines of code)
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
index ebe1136e2487d0d13e5a924a644f2237900a86a6..1b54fb1a321f0538c0ecded9fa14b2bc588416b9 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -508,7 +508,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
// Paper start
|
||||
@Override
|
||||
public com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() {
|
||||
- return new org.galemc.gale.version.GaleVersionFetcher(); // Gale - branding changes - version fetcher
|
||||
+ return new org.dreeam.leaf.version.LeafVersionFetcher(); // Gale - branding changes - version fetcher // Leaf
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
||||
index 0b5979723bb30f9011ac64c36d894aa41713ec9b..e220f5601f6b92b7b280ce8ebe64117d30192b0e 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
||||
@@ -11,7 +11,7 @@ public final class Versioning {
|
||||
public static String getBukkitVersion() {
|
||||
String result = "Unknown-Version";
|
||||
|
||||
- InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/org.galemc.gale/gale-api/pom.properties"); // Gale - branding changes
|
||||
+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/cn.dreeam.leaf/leaf-api/pom.properties"); // Gale - branding changes // Leaf
|
||||
Properties properties = new Properties();
|
||||
|
||||
if (stream != null) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java.rej b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java.rej
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0d8c2c5d1c88f635a1f0b6a9fc311d9921a0a3d7
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java.rej
|
||||
@@ -0,0 +1,10 @@
|
||||
+diff a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java (rejected hunks)
|
||||
+@@ -11,7 +11,7 @@ public final class Versioning {
|
||||
+ public static String getBukkitVersion() {
|
||||
+ String result = "Unknown-Version";
|
||||
+
|
||||
+- InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/org.galemc.gale/gale-api/pom.properties"); // Gale - branding changes
|
||||
++ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/cn.dreeam.leaf/leaf-api/pom.properties"); // Gale - branding changes // Leaf
|
||||
+ Properties properties = new Properties();
|
||||
+
|
||||
+ if (stream != null) {
|
||||
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
|
||||
index 64e3c7bd0a1ff93dd87e688f9e49e213c8f6670e..6bc6a318286cd6a1d5464a9b139fb9b8ca4a219e 100644
|
||||
--- a/src/main/java/org/spigotmc/WatchdogThread.java
|
||||
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
|
||||
@@ -25,7 +25,7 @@ public class WatchdogThread extends Thread {
|
||||
private volatile boolean stopping;
|
||||
|
||||
private WatchdogThread(long timeoutTime, boolean restart) {
|
||||
- super("Paper Watchdog Thread");
|
||||
+ super("Watchdog Thread"); // Leaf - Purpur - use a generic name
|
||||
this.timeoutTime = timeoutTime;
|
||||
this.restart = restart;
|
||||
this.earlyWarningEvery = Math.min(GlobalConfiguration.get().watchdog.earlyWarningEvery, timeoutTime); // Paper
|
||||
@@ -82,15 +82,15 @@ public class WatchdogThread extends Thread {
|
||||
We do not want people to report thread issues to Paper,
|
||||
but we do want people to report thread issues to Gale.
|
||||
*/
|
||||
- logger.log(Level.SEVERE, "The server has stopped responding! This is (probably) not a Paper bug. This could be a Gale bug."); // Paper
|
||||
+ logger.log(Level.SEVERE, "The server has stopped responding! This is (probably) not a Paper bug. This could be a Leaf bug."); // Paper // Leaf
|
||||
// Gale end - branding changes
|
||||
logger.log(Level.SEVERE, "If you see a plugin in the Server thread dump below, then please report it to that author");
|
||||
logger.log(Level.SEVERE, "\t *Especially* if it looks like HTTP or MySQL operations are occurring");
|
||||
logger.log(Level.SEVERE, "If you see a world save or edit, then it means you did far more than your server can handle at once");
|
||||
logger.log(Level.SEVERE, "\t If this is the case, consider increasing timeout-time in spigot.yml but note that this will replace the crash with LARGE lag spikes");
|
||||
- logger.log(Level.SEVERE, "If you are unsure or think this is a Gale bug, please report this to https://github.com/GaleMC/Gale/issues - and if you think this is a Paper bug, please report this to https://github.com/PaperMC/Paper/issues"); // Gale - branding changes
|
||||
+ logger.log(Level.SEVERE, "If you are unsure or think this is a Leaf bug, please report this to https://github.com/Winds-Studio/Leaf/issues - and if you think this is a Paper bug, please report this to https://github.com/PaperMC/Paper/issues"); // Gale - branding changes // Leaf
|
||||
logger.log(Level.SEVERE, "Be sure to include ALL relevant console errors and Minecraft crash reports");
|
||||
- logger.log(Level.SEVERE, "Gale version: " + Bukkit.getServer().getVersion()); // Gale - branding changes
|
||||
+ logger.log(Level.SEVERE, "Leaf version: " + Bukkit.getServer().getVersion()); // Gale - branding changes // Leaf
|
||||
|
||||
if (net.minecraft.world.level.Level.lastPhysicsProblem != null) {
|
||||
logger.log(Level.SEVERE, "------------------------------");
|
||||
@@ -115,13 +115,13 @@ public class WatchdogThread extends Thread {
|
||||
We do not want people to report thread issues to Paper,
|
||||
but we do want people to report thread issues to Gale.
|
||||
*/
|
||||
- logger.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - If you think this is a Gale bug, please report it at https://github.com/GaleMC/Gale/issues - THIS IS NOT A PAPER BUG OR CRASH - " + Bukkit.getServer().getVersion() + " ---");
|
||||
+ logger.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - If you think this is a Leaf bug, please report it at https://github.com/Winds-Studio/Leaf/issues - THIS IS NOT A PAPER BUG OR CRASH - " + Bukkit.getServer().getVersion() + " ---"); // Leaf
|
||||
// Gale end - branding changes
|
||||
logger.log(Level.SEVERE, "The server has not responded for " + (currentTime - lastTick) / 1000 + " seconds! Creating thread dump");
|
||||
}
|
||||
// Paper end - Different message for short timeout
|
||||
logger.log(Level.SEVERE, "------------------------------");
|
||||
- logger.log(Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Gale!):"); // Paper // Gale - branding changes
|
||||
+ logger.log(Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Leaf!):"); // Paper // Gale - branding changes // Leaf
|
||||
FeatureHooks.dumpAllChunkLoadInfo(MinecraftServer.getServer(), isLongTimeout); // Paper - log detailed tick information
|
||||
WatchdogThread.dumpThread(ManagementFactory.getThreadMXBean().getThreadInfo(MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE), logger);
|
||||
logger.log(Level.SEVERE, "------------------------------");
|
||||
@@ -139,7 +139,7 @@ public class WatchdogThread extends Thread {
|
||||
We do not want people to report thread issues to Paper,
|
||||
but we do want people to report thread issues to Gale.
|
||||
*/
|
||||
- logger.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - If you think this is a Gale bug, please report it at https://github.com/GaleMC/Gale/issues - THIS IS NOT A PAPER BUG OR CRASH ---");
|
||||
+ logger.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - If you think this is a Leaf bug, please report it at https://github.com/Winds-Studio/Leaf/issues - THIS IS NOT A PAPER BUG OR CRASH ---"); // Leaf
|
||||
// Gale end - branding changes
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ Subject: [PATCH] Leaf Bootstrap
|
||||
org.bukkit.craftbukkit.Main#main -> LeafBootstrap -> PaperBootstrap -> ...
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
index be0d38544395a9b3befb898bb961f34e32fe9509..50a2b6e73ba4d8ad65582b2544fa409fd44f36d5 100644
|
||||
index ecb0fcd1f3b3f3d7751eded3cdf0977c1889c9ed..1df9bed6d3dc1e28898af8d5ad6a854dd5ccab1b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
@@ -278,7 +278,8 @@ public class Main {
|
||||
@@ -19,25 +19,3 @@ index be0d38544395a9b3befb898bb961f34e32fe9509..50a2b6e73ba4d8ad65582b2544fa409f
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
diff --git a/src/main/java/org/dreeam/leaf/LeafBootstrap.java b/src/main/java/org/dreeam/leaf/LeafBootstrap.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..316654051b80ac0fd62cf3b7a0e1b91010ec24b7
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/dreeam/leaf/LeafBootstrap.java
|
||||
@@ -0,0 +1,16 @@
|
||||
+package org.dreeam.leaf;
|
||||
+
|
||||
+import io.papermc.paper.PaperBootstrap;
|
||||
+import joptsimple.OptionSet;
|
||||
+
|
||||
+public class LeafBootstrap {
|
||||
+
|
||||
+ public static void boot(final OptionSet options) {
|
||||
+ runPreBootTasks();
|
||||
+
|
||||
+ PaperBootstrap.boot(options);
|
||||
+ }
|
||||
+
|
||||
+ private static void runPreBootTasks() {
|
||||
+ }
|
||||
+}
|
||||
@@ -0,0 +1,72 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Kevin Raneri <kevin.raneri@gmail.com>
|
||||
Date: Wed, 10 Nov 2021 00:37:03 -0500
|
||||
Subject: [PATCH] Pufferfish: Optimize mob spawning
|
||||
|
||||
Original license: GPL v3
|
||||
Original project: https://github.com/pufferfish-gg/Pufferfish
|
||||
|
||||
Co-authored-by: booky10 <boooky10@gmail.com>
|
||||
|
||||
This patch aims to reduce the main-thread impact of mob spawning by
|
||||
offloading as much work as possible to other threads. It is possible for
|
||||
inconsistencies to come up, but when they happen they never interfere
|
||||
with the server's operation (they don't produce errors), and side
|
||||
effects are limited to more or less mobs being spawned in any particular
|
||||
tick.
|
||||
|
||||
It is possible to disable this optimization if it is not required or if
|
||||
it interferes with any plugins. On servers with thousands of entities,
|
||||
this can result in performance gains of up to 15%, which is significant
|
||||
and, in my opinion, worth the low risk of minor mob-spawning-related
|
||||
inconsistencies.
|
||||
|
||||
diff --git a/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java b/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java
|
||||
index c21e00812f1aaa1279834a0562d360d6b89e146c..877d2095a066854939f260ca4b0b8c7b5abb620f 100644
|
||||
--- a/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java
|
||||
+++ b/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java
|
||||
@@ -18,7 +18,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
|
||||
|
||||
private final double maxFragFactor;
|
||||
|
||||
- private int iteratorCount;
|
||||
+ private final java.util.concurrent.atomic.AtomicInteger iteratorCount = new java.util.concurrent.atomic.AtomicInteger(); // Pufferfish - async mob spawning
|
||||
|
||||
public IteratorSafeOrderedReferenceSet() {
|
||||
this(16, 0.75f, 16, 0.2);
|
||||
@@ -79,7 +79,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
|
||||
}
|
||||
|
||||
public int createRawIterator() {
|
||||
- ++this.iteratorCount;
|
||||
+ this.iteratorCount.incrementAndGet(); // Pufferfish - async mob spawning
|
||||
if (this.indexMap.isEmpty()) {
|
||||
return -1;
|
||||
} else {
|
||||
@@ -100,7 +100,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
|
||||
}
|
||||
|
||||
public void finishRawIterator() {
|
||||
- if (--this.iteratorCount == 0) {
|
||||
+ if (this.iteratorCount.decrementAndGet() == 0) { // Pufferfish - async mob spawning
|
||||
if (this.getFragFactor() >= this.maxFragFactor) {
|
||||
this.defrag();
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
this.listElements[index] = null;
|
||||
- if (this.iteratorCount == 0 && this.getFragFactor() >= this.maxFragFactor) {
|
||||
+ if (this.iteratorCount.get() == 0 && this.getFragFactor() >= this.maxFragFactor) { // Pufferfish - async mob spawning
|
||||
this.defrag();
|
||||
}
|
||||
//this.check();
|
||||
@@ -219,7 +219,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
|
||||
}
|
||||
|
||||
public IteratorSafeOrderedReferenceSet.Iterator<E> iterator(final int flags) {
|
||||
- ++this.iteratorCount;
|
||||
+ this.iteratorCount.incrementAndGet(); // Pufferfish - async mob spawning
|
||||
return new BaseIterator<>(this, true, (flags & ITERATOR_FLAG_SEE_ADDITIONS) != 0 ? Integer.MAX_VALUE : this.listSize);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,30 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Mon, 29 Apr 2024 14:18:58 -0400
|
||||
Subject: [PATCH] Fix Pufferfish and Purpur patches
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java b/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java
|
||||
index ea2bca6e0bbc56156c2f744769abd677e6fb0c18..aa80daab4917e22bc3849eb9b0915b1c705091af 100644
|
||||
--- a/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java
|
||||
+++ b/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java
|
||||
@@ -32,6 +32,8 @@ public record ServerBuildInfoImpl(
|
||||
|
||||
private static final String BRAND_PAPER_NAME = "Paper";
|
||||
private static final String BRAND_GALE_NAME = "Gale"; // Gale - branding changes
|
||||
+ private static final String BRAND_PUFFERFISH_NAME = "Pufferfish"; // Leaf
|
||||
+ private static final String BRAND_PURPUR_NAME = "Purpur"; // Leaf - Purpur - Rebrand
|
||||
private static final String BRAND_LEAF_NAME = "Leaf"; // Leaf
|
||||
|
||||
private static final String BUILD_DEV = "DEV";
|
||||
@@ -65,7 +67,9 @@ public record ServerBuildInfoImpl(
|
||||
public boolean isBrandCompatible(final @NotNull Key brandId) {
|
||||
return brandId.equals(this.brandId)
|
||||
|| brandId.equals(BRAND_PAPER_ID)
|
||||
- || brandId.equals(BRAND_GALE_ID); // Gale - branding changes // Leaf
|
||||
+ || brandId.equals(BRAND_GALE_ID) // Gale - branding changes // Leaf
|
||||
+ || brandId.equals(BRAND_PUFFERFISH_ID) // Leaf
|
||||
+ || brandId.equals(BRAND_PURPUR_ID); // Leaf
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -6,7 +6,7 @@ Subject: [PATCH] Remove Timings
|
||||
Completely remove the Timings, since it wastes too much performance. Use Spark instead.
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
index 7ce9ebba8ce304d1f3f21d4f15ee5f3560d7700b..a1c9726d25479b5326fe2fa2b0f5a98d6b2da4c5 100644
|
||||
index 7ce9ebba8ce304d1f3f21d4f15ee5f3560d7700b..4c003acccdd2dd17918b15316001e52e7670123e 100644
|
||||
--- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
@@ -1,6 +1,5 @@
|
||||
@@ -29,7 +29,7 @@ index 7ce9ebba8ce304d1f3f21d4f15ee5f3560d7700b..a1c9726d25479b5326fe2fa2b0f5a98d
|
||||
}
|
||||
|
||||
- EventExecutor executor = new TimedEventExecutor(EventExecutor.create(method, eventClass), plugin, method, eventClass);
|
||||
+ EventExecutor executor = EventExecutor.create(method, eventClass);
|
||||
+ EventExecutor executor = EventExecutor.create(method, eventClass); // Leaf - Remove Timings
|
||||
eventSet.add(new RegisteredListener(listener, executor, eh.priority(), plugin, eh.ignoreCancelled()));
|
||||
}
|
||||
return ret;
|
||||
@@ -46,23 +46,11 @@ index 097500a59336db1bbfffcd1aa4cff7a8586e46ec..f06076864582ed153c6154fd7f3e9101
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index a7a8273a21434fc04b01d06708b65e80487a95d3..2550e0e4e40eccb6e01cd0b8287358c105abaebf 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -3,7 +3,6 @@ package net.minecraft.server;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
-import co.aikar.timings.Timings;
|
||||
import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.google.common.collect.Lists;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index ef8041877456316fc32a382e28ee81161d962353..b4986e322cb05ad6f98bbf5eee2b571c67e4d9d3 100644
|
||||
index de2c10a18869d3fcfc1ae1329489155d7bdc4dd8..911bb12bcbcae2b8046d786e7b828cc1e1bcdb3a 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -1047,10 +1047,8 @@ public final class CraftServer implements Server {
|
||||
@@ -1048,10 +1048,8 @@ public final class CraftServer implements Server {
|
||||
commands.performCommand(results, commandLine, commandLine, true);
|
||||
} catch (CommandException ex) {
|
||||
this.pluginManager.callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerCommandException(ex, target, sender, args))); // Paper
|
||||
@@ -7,13 +7,13 @@ Original license: MIT
|
||||
Original project: https://github.com/KeYiMC/KeYi
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 63065a22ff359c142bab23fccacfd5ebd86f81a5..d0bdce91b073344f218c1624cd66fdda5d3e5b0e 100644
|
||||
index 9fbbdc9664353fd2be8eae112e5cfe8880d51d08..b60982fa6e11c1f72e2c7021059ebbd04e064364 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -3675,4 +3675,31 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@@ -3640,4 +3640,31 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundPlayerCombatKillPacket(getEntityId(), io.papermc.paper.adventure.PaperAdventure.asVanilla(message)));
|
||||
}
|
||||
// Purpur end
|
||||
// Purpur end - Death screen API
|
||||
+
|
||||
+ // Leaf start - KeYi - Player Skull API
|
||||
+ @Override
|
||||
@@ -0,0 +1,40 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Cryptite <cryptite@gmail.com>
|
||||
Date: Sat, 13 Aug 2022 08:58:14 -0500
|
||||
Subject: [PATCH] Slice: Smooth Teleports
|
||||
|
||||
Original license: MIT
|
||||
Original project: https://github.com/Cryptite/Slice
|
||||
|
||||
Co-authored-by: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index b60982fa6e11c1f72e2c7021059ebbd04e064364..7729f49719ce1d42fcbc33452d2b4f8f027283da 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -1376,6 +1376,25 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
// Paper end - Teleportation API
|
||||
}
|
||||
|
||||
+ // Slice start
|
||||
+ @Override
|
||||
+ public void teleportWithoutRespawn(Location location) {
|
||||
+ ServerPlayer serverPlayer = getHandle();
|
||||
+ serverPlayer.smoothWorldTeleport = true;
|
||||
+ teleport(location);
|
||||
+ serverPlayer.smoothWorldTeleport = false;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean teleportWithoutRespawnOptionally(Location location) {
|
||||
+ ServerPlayer serverPlayer = getHandle();
|
||||
+ serverPlayer.smoothWorldTeleport = true;
|
||||
+ boolean teleportResult = teleport(location);
|
||||
+ serverPlayer.smoothWorldTeleport = false;
|
||||
+ return teleportResult;
|
||||
+ }
|
||||
+ // Slice end
|
||||
+
|
||||
@Override
|
||||
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
|
||||
// Paper start - Teleport API
|
||||
@@ -0,0 +1,33 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
||||
Date: Tue, 26 Sep 2023 19:00:41 +0800
|
||||
Subject: [PATCH] Leaves: Protocol Core
|
||||
|
||||
TODO: Check whether Leaves's Return-nether-portal-fix.patch improves performance
|
||||
and change store way to sql maybe?
|
||||
|
||||
Original license: GPLv3
|
||||
Original project: https://github.com/LeavesMC/Leaves
|
||||
|
||||
Commit: 41476d86922416c45f703df2871890831fc42bb5
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 911bb12bcbcae2b8046d786e7b828cc1e1bcdb3a..dd054c184095644a122be0f610ade1d47d9be74a 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -507,6 +507,7 @@ public final class CraftServer implements Server {
|
||||
this.potionBrewer = new io.papermc.paper.potion.PaperPotionBrewer(console); // Paper - custom potion mixes
|
||||
datapackManager = new io.papermc.paper.datapack.PaperDatapackManager(console.getPackRepository()); // Paper
|
||||
this.spark = new io.papermc.paper.SparksFly(this); // Paper - spark
|
||||
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.init(); // Leaves - protocol
|
||||
}
|
||||
|
||||
public boolean getCommandBlockOverride(String command) {
|
||||
@@ -1138,6 +1139,7 @@ public final class CraftServer implements Server {
|
||||
org.purpurmc.purpur.PurpurConfig.registerCommands(); // Purpur - Purpur config files
|
||||
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
||||
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
|
||||
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleServerReload(); // Leaves - protocol
|
||||
|
||||
int pollCount = 0;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user