Compare commits
167 Commits
1.20.4-b1f
...
dev/1.21.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95d9f5e3c1 | ||
|
|
6fb1f6934b | ||
|
|
ab28422974 | ||
|
|
1247d8bf89 | ||
|
|
76ce141d63 | ||
|
|
f9514f1866 | ||
|
|
3102b1c581 | ||
|
|
770e4b848d | ||
|
|
78cfb0a760 | ||
|
|
98552da7aa | ||
|
|
a50e2f5be9 | ||
|
|
c275bd7e93 | ||
|
|
6825d1dbd1 | ||
|
|
cad01d6368 | ||
|
|
dacd3c5a29 | ||
|
|
4f051b3c62 | ||
|
|
a0f4d02bc9 | ||
|
|
63a8beaafc | ||
|
|
5905dbad61 | ||
|
|
bfe835b8b9 | ||
|
|
bf5c6d04d4 | ||
|
|
e20088ff17 | ||
|
|
62470e9097 | ||
|
|
b96655d098 | ||
|
|
f3b16cb314 | ||
|
|
0296cd03b1 | ||
|
|
791d374a94 | ||
|
|
065b78f0d5 | ||
|
|
156837d199 | ||
|
|
5a60f7395f | ||
|
|
973b437ad6 | ||
|
|
051ed97668 | ||
|
|
4918bb98e5 | ||
|
|
8d491c23a9 | ||
|
|
16eca828f1 | ||
|
|
7c312e7851 | ||
|
|
76f1b9d02d | ||
|
|
896fd7bf1a | ||
|
|
81f17dc7b0 | ||
|
|
5f694869c2 | ||
|
|
dc0f1f9933 | ||
|
|
1a6ea9fc98 | ||
|
|
f175359ad9 | ||
|
|
e6a76b5794 | ||
|
|
d170436ff0 | ||
|
|
cc907e891d | ||
|
|
5b9d44ee94 | ||
|
|
c749ca011a | ||
|
|
72f6717b13 | ||
|
|
55be3489f0 | ||
|
|
d547f8ab3f | ||
|
|
a22472fe99 | ||
|
|
d15f2774ea | ||
|
|
b27cf9614e | ||
|
|
98bbcd67e4 | ||
|
|
1ed71f5812 | ||
|
|
14de6bf8c7 | ||
|
|
d0d9ce0c46 | ||
|
|
2e520168e1 | ||
|
|
58d45e32c5 | ||
|
|
8830d65945 | ||
|
|
fb55d3e201 | ||
|
|
892dfcd2a0 | ||
|
|
6c600853dd | ||
|
|
1299dbfeea | ||
|
|
8e876b48f2 | ||
|
|
a4794fb096 | ||
|
|
064679fd22 | ||
|
|
2541ddfd7b | ||
|
|
c5cb9503c9 | ||
|
|
ab71de6298 | ||
|
|
7bba0412a3 | ||
|
|
b56f9723e7 | ||
|
|
190e5e094a | ||
|
|
17e9d04db0 | ||
|
|
09861230f7 | ||
|
|
a92cfa3637 | ||
|
|
84cf8fbb38 | ||
|
|
620e093735 | ||
|
|
d01eef55ec | ||
|
|
05101da67b | ||
|
|
32db7a453c | ||
|
|
576d488a36 | ||
|
|
4959ecceba | ||
|
|
6614f67647 | ||
|
|
85f3a4a123 | ||
|
|
99e29a0596 | ||
|
|
0a0cdb8d54 | ||
|
|
aa49ca63a4 | ||
|
|
fefc53dd71 | ||
|
|
0e049306c9 | ||
|
|
e991f0b80f | ||
|
|
4752f00d09 | ||
|
|
e6027bdfbf | ||
|
|
1f881dd409 | ||
|
|
be0d1b1bb2 | ||
|
|
3fd73145d6 | ||
|
|
b8963f9862 | ||
|
|
83a868e3d2 | ||
|
|
9153d07d43 | ||
|
|
fcf4731fa2 | ||
|
|
0795ae027d | ||
|
|
f2a13748e8 | ||
|
|
acc31af9f6 | ||
|
|
9121c2ba4e | ||
|
|
0cc6f1cdb3 | ||
|
|
ac1cc484c2 | ||
|
|
b208bcc81f | ||
|
|
43eda55b88 | ||
|
|
e6ee20986b | ||
|
|
46aec00348 | ||
|
|
3deaf5f7fb | ||
|
|
81dd04e018 | ||
|
|
bd26f9aeab | ||
|
|
6b2a9d25c8 | ||
|
|
15bb0f42d0 | ||
|
|
841c0b9cd3 | ||
|
|
63ef3ce0b9 | ||
|
|
92b9d91fdf | ||
|
|
a02d29c6a7 | ||
|
|
7b971faccc | ||
|
|
b952734d6b | ||
|
|
5e86abed12 | ||
|
|
266ea43135 | ||
|
|
a33f5c92bb | ||
|
|
1238ec3bf9 | ||
|
|
dec6cf5fd3 | ||
|
|
bb679c51fc | ||
|
|
0f1fee37ef | ||
|
|
5a852d792e | ||
|
|
4333f80871 | ||
|
|
45e119a5ad | ||
|
|
b027e4cd03 | ||
|
|
1e5e540795 | ||
|
|
a020b181cc | ||
|
|
7ea76f4f74 | ||
|
|
787c3793c6 | ||
|
|
39c74a5409 | ||
|
|
fca5e33fa4 | ||
|
|
2d14daaa87 | ||
|
|
0a63aeaca2 | ||
|
|
729312415f | ||
|
|
96499c26ff | ||
|
|
7645ef08e8 | ||
|
|
e7dde4f240 | ||
|
|
dbb30dc4f3 | ||
|
|
65de2ae23e | ||
|
|
ec74075cc5 | ||
|
|
e5379a2042 | ||
|
|
67ba24ec92 | ||
|
|
943c084de6 | ||
|
|
8d3c7e7807 | ||
|
|
fbd9d9f48f | ||
|
|
512da58f92 | ||
|
|
b239c97db1 | ||
|
|
650ce2770d | ||
|
|
ce500bf638 | ||
|
|
48f34a6146 | ||
|
|
40cae40b09 | ||
|
|
38a8161c1a | ||
|
|
dced86a404 | ||
|
|
a983ac00e5 | ||
|
|
e2b21e0f69 | ||
|
|
07ef8e01c5 | ||
|
|
77cb94ae5f | ||
|
|
14e7cbe186 | ||
|
|
49be774d83 |
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@@ -11,4 +11,4 @@ issuehunt: # Replace with a single IssueHunt username
|
||||
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||
polar: # Replace with a single Polar username
|
||||
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
|
||||
custom: https://afdian.net/a/Luminol
|
||||
custom: https://afdian.com/a/Luminol
|
||||
|
||||
72
.github/workflows/build_1.21.1.yml
vendored
Normal file
72
.github/workflows/build_1.21.1.yml
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
name: Luminol CI - dev/1.21.1
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "dev/1.21.1" ]
|
||||
pull_request:
|
||||
branches: [ "de/1.21.1" ]
|
||||
|
||||
permissions: write-all
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
environment: default
|
||||
steps:
|
||||
- name: Checkout Git Repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Validate Gradle wrapper
|
||||
uses: gradle/actions/wrapper-validation@v3
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v3
|
||||
with:
|
||||
gradle-version: 8.7
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '21'
|
||||
- name: Configure Git User Details
|
||||
run: git config --global user.email "ci@luminolmc.com" && git config --global user.name "LuminolMC CI"
|
||||
- name: Apply Patches
|
||||
run: gradle applyPatches
|
||||
- name: CreateJar
|
||||
run: gradle createMojmapBundlerJar createMojmapPaperclipJar
|
||||
- name: Publish to repo
|
||||
run: |
|
||||
export MAVEN_REPO_USER=${{ secrets.MAVEN_REPO_USER }}
|
||||
export MAVEN_REPO_PASSWORD=${{ secrets.MAVEN_REPO_PASSWORD }}
|
||||
./gradlew publish -PpublishDevBundle=true
|
||||
- name: SetENV
|
||||
run: sh scripts/SetENV.sh
|
||||
- name: Upload Artifact
|
||||
uses: "actions/upload-artifact@v4"
|
||||
with:
|
||||
name: "${{ env.project_id_b }} CI Artifacts"
|
||||
path: "build/libs/*.jar"
|
||||
- name: Create Release
|
||||
if: "!contains(github.event.commits[0].message, '[release skip]')"
|
||||
uses: ncipollo/release-action@v1.14.0
|
||||
with:
|
||||
tag: ${{ env.tag }}
|
||||
name: ${{ env.project_id_b }} ${{ env.mcversion }} - ${{ env.commit_id }}
|
||||
body: |
|
||||
📦Version: `${{ env.mcversion }}` | Commit ${{ env.commit_id }} [](https://github.com/LuminolMC/${{ env.project_id }}/download/${{ env.tag }}/${{ env.jar }})
|
||||
This release is automatically compiled by GitHub Actions
|
||||
### Commit Message
|
||||
${{ env.commit_msg }}
|
||||
artifacts: |
|
||||
${{ env.jar_dir }}
|
||||
${{ env.jar_dir_bundler }}
|
||||
generateReleaseNotes: true
|
||||
prerelease: ${{ env.pre }}
|
||||
makeLatest: ${{ env.make_latest }}
|
||||
token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
- name: Push to API
|
||||
if: "!contains(github.event.commits[0].message, '[release skip]')"
|
||||
continue-on-error: true
|
||||
env:
|
||||
secret_v2: ${{ secrets.API_KEY }}
|
||||
tag: ${{ env.tag }}
|
||||
project_id: ${{ env.project_id }}
|
||||
run: sh scripts/PushToAPI.sh
|
||||
63
.github/workflows/build_1_20_4.yml
vendored
63
.github/workflows/build_1_20_4.yml
vendored
@@ -1,63 +0,0 @@
|
||||
# This workflow uses actions that are not certified by GitHub.
|
||||
# They are provided by a third-party and are governed by
|
||||
# separate terms of service, privacy policy, and support
|
||||
# documentation.
|
||||
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
|
||||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
|
||||
|
||||
name: LuminolCI - Ver/1.20.4
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "ver/1.20.4" ]
|
||||
pull_request:
|
||||
branches: [ "ver/1.20.4" ]
|
||||
|
||||
permissions: write-all
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up git
|
||||
run: git config --global user.email "noreply@github.com" && git config --global user.name "ci"
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
- name: Make gradlew executable
|
||||
run: chmod 777 ./gradlew
|
||||
- name: Setup project
|
||||
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0
|
||||
with:
|
||||
arguments: applyPatches
|
||||
- name: Build project to paperclip jar
|
||||
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0
|
||||
with:
|
||||
arguments: createReobfPaperclipJar
|
||||
- name: Capture build artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Artifacts
|
||||
path: build/libs/
|
||||
- name: Publish All
|
||||
run: |
|
||||
echo "GITHUB_USERNAME=LuminolCI" >> $GITHUB_ENV
|
||||
export GITHUB_USERNAME=LuminolCI
|
||||
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
|
||||
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
|
||||
./gradlew publish -PpublishDevBundle=true
|
||||
- name: Rename jar file
|
||||
run: mv build/libs/luminol-paperclip-1.20.4-R0.1-SNAPSHOT-reobf.jar build/libs/luminol-1.20.4-paperclip.jar
|
||||
- name: Release Artifacts
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
release_name: "Luminol MC1.20.4 - ${{ github.event.repository.updated_at}}"
|
||||
tag: "1.20.4-${{ github.run_id }}"
|
||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
file: "build/libs/luminol-1.20.4-paperclip.jar"
|
||||
file_glob: true
|
||||
prerelease: true
|
||||
38
README.md
38
README.md
@@ -9,12 +9,11 @@
|
||||

|
||||

|
||||
|
||||
[English](./README_EN) | **中文**
|
||||
[English](./README_EN.md) | **中文**
|
||||
|
||||
## 特性
|
||||
- 可配置的原版特性
|
||||
- Tpsbar 支持
|
||||
- 线性区域文件格式 (from kaiiju)
|
||||
- 对单线程区域性能的优化
|
||||
- 更多的插件开发API支持(进行中)
|
||||
|
||||
@@ -22,38 +21,51 @@
|
||||
任何版本都可以在 [Release](https://github.com/LuminolMC/Luminol/releases) 中找到,你也可以通过[以下步骤](./README.md#构建)自己构建。
|
||||
|
||||
## 构建
|
||||
要构建一个paperclip jar,你需要运行以下命令。你可以在build/libs中找到jar(注意:需要`JDK17`)
|
||||
要构建一个paperclip jar,你需要运行以下命令。你可以在build/libs中找到jar(注意:需要`JDK21`)
|
||||
|
||||
```shell
|
||||
./gradlew applyPatches && ./gradlew createReobfPaperclipJar
|
||||
./gradlew applyPatches && ./gradlew createMojmapPaperclipJar
|
||||
```
|
||||
|
||||
## 使用API
|
||||
使用 Gradle:
|
||||
|
||||
```kotlin
|
||||
repositories {
|
||||
maven {
|
||||
url = "https://maven.nostal.ink/repository/maven-snapshots/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("me.earthme.luminol:luminol-api:1.20.4-R0.1-SNAPSHOT")
|
||||
compileOnly("me.earthme.luminol:luminol-api:1.21.1-R0.1-20241001.135225-1")
|
||||
}
|
||||
```
|
||||
|
||||
使用 Maven
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>me.earthme.luminol</groupId>
|
||||
<artifactId>luminol-api</artifactId>
|
||||
<version>1.20.4-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nostal</id>
|
||||
<url>https://maven.nostal.ink/repository/maven-snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>me.earthme.luminol</groupId>
|
||||
<artifactId>luminol-api</artifactId>
|
||||
<version>1.21.1-R0.1-20241001.135225-1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
```
|
||||
|
||||
## 联系方式
|
||||
> 如果您对这个项目感兴趣或有任何问题,请随时向我们提问。
|
||||
|
||||
QQ群: [368632360](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=MfosKhcDd8Fdxn1MREuZ8Krbf9T6jiBC&authKey=3cm6qdHohON3gHnuD63FK4k07fIbrWnY4hdyq8OmELsfjMVP1kbFTJY9mRyM2Rkj&noverify=0&group_code=368632360) | QQ频道: [点击加入](https://pd.qq.com/s/eq9krf9j) | Telegram: [点击加入](https://t.me/LuminolMC) | Discord: [点击加入](https://discord.gg/5hgtU72w33)
|
||||
**QQ群: [368632360](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=MfosKhcDd8Fdxn1MREuZ8Krbf9T6jiBC&authKey=3cm6qdHohON3gHnuD63FK4k07fIbrWnY4hdyq8OmELsfjMVP1kbFTJY9mRyM2Rkj&noverify=0&group_code=368632360)** | QQ频道: [点击加入](https://pd.qq.com/s/eq9krf9j) | Telegram: [点击加入](https://t.me/LuminolMC) | Discord: [点击加入](https://discord.gg/Qd7m3V6eDx)
|
||||
|
||||
> [!WARNING]
|
||||
> **此项目与Leaves无关。不要向Leaves报告任何有关协议支持的错误,因为协议支持已经重构**
|
||||
|
||||
## 关于 Issue
|
||||
当您遇到任何问题时,请向我们提问,我们将尽力解决,但请记得清楚地描述您的问题并提供足够的日志等信息。
|
||||
|
||||
38
README_EN.md
38
README_EN.md
@@ -9,7 +9,7 @@
|
||||

|
||||

|
||||
|
||||
**English** | [中文](./README)
|
||||
**English** | [中文](./README.md)
|
||||
|
||||
## Features
|
||||
- Configurable vanilla features
|
||||
@@ -22,38 +22,50 @@
|
||||
Any versions are available in the [release](https://github.com/LuminolMC/Luminol/releases), also you can build it by yourself through [the following steps](./README_EN.md#build).
|
||||
|
||||
## Build
|
||||
To build a paperclip jar, you need to run the following command. You can find the jar in build/libs(Note: JDK17 is needed)
|
||||
To build a paperclip jar, you need to run the following command. You can find the jar in build/libs(Note: JDK21 is needed)
|
||||
|
||||
```shell
|
||||
./gradlew applyPatches && ./gradlew createReobfPaperclipJar
|
||||
./gradlew applyPatches && ./gradlew createMojmapPaperclipJar
|
||||
```
|
||||
|
||||
## Using API
|
||||
For gradle:
|
||||
|
||||
```kotlin
|
||||
repositories {
|
||||
maven {
|
||||
url = "https://maven.nostal.ink/repository/maven-snapshots/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("me.earthme.luminol:luminol-api:1.20.4-R0.1-SNAPSHOT")
|
||||
compileOnly("me.earthme.luminol:luminol-api:1.21.1-R0.1-20241001.135225-1")
|
||||
}
|
||||
```
|
||||
|
||||
For maven
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>me.earthme.luminol</groupId>
|
||||
<artifactId>luminol-api</artifactId>
|
||||
<version>1.20.4-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nostal</id>
|
||||
<url>https://maven.nostal.ink/repository/maven-snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>me.earthme.luminol</groupId>
|
||||
<artifactId>luminol-api</artifactId>
|
||||
<version>1.21.1-R0.1-20241001.135225-1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
```
|
||||
|
||||
## Contact
|
||||
> If you are interested in this project or have any issue, feel free to ask us.
|
||||
|
||||
QQ Group: [368632360](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=MfosKhcDd8Fdxn1MREuZ8Krbf9T6jiBC&authKey=3cm6qdHohON3gHnuD63FK4k07fIbrWnY4hdyq8OmELsfjMVP1kbFTJY9mRyM2Rkj&noverify=0&group_code=368632360) | QQ Channel: [Click To Join](https://pd.qq.com/s/eq9krf9j) | Telegram: [Click To Join](https://t.me/LuminolMC) | Discord: [Click To Join](https://discord.gg/5hgtU72w33)
|
||||
|
||||
> [!WARNING]
|
||||
> **This project is not related to Leaves.Do not report any bugs about protocol support to leaves because the protocol supports are already refactored.**
|
||||
**QQ Group: [368632360](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=MfosKhcDd8Fdxn1MREuZ8Krbf9T6jiBC&authKey=3cm6qdHohON3gHnuD63FK4k07fIbrWnY4hdyq8OmELsfjMVP1kbFTJY9mRyM2Rkj&noverify=0&group_code=368632360)** | QQ Channel: [Click To Join](https://pd.qq.com/s/eq9krf9j) | Telegram: [Click To Join](https://t.me/LuminolMC) | Discord: [Click To Join](https://discord.gg/Qd7m3V6eDx)
|
||||
|
||||
## About Issue
|
||||
When you meet any problems, just ask us, we will do our best to solve it, but remember to state your problem clear and provide enough logs etc.</br>
|
||||
|
||||
262
build.gradle.kts
262
build.gradle.kts
@@ -1,140 +1,122 @@
|
||||
plugins {
|
||||
java
|
||||
`maven-publish`
|
||||
id("com.github.johnrengelman.shadow") version "8.1.1" apply false
|
||||
id("io.papermc.paperweight.patcher") version "1.5.11"
|
||||
}
|
||||
|
||||
val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven(paperMavenPublicUrl) {
|
||||
content { onlyForConfigurations(configurations.paperclip.name) }
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
remapper("net.fabricmc:tiny-remapper:0.8.6:fat")
|
||||
decompiler("org.quiltmc:quiltflower:1.9.0")
|
||||
paperclip("io.papermc:paperclip:3.0.3-SNAPSHOT")
|
||||
}
|
||||
|
||||
subprojects {
|
||||
apply(plugin = "java")
|
||||
apply(plugin = "maven-publish")
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.release.set(17)
|
||||
}
|
||||
|
||||
tasks.withType<Javadoc> {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
}
|
||||
|
||||
tasks.withType<ProcessResources> {
|
||||
filteringCharset = Charsets.UTF_8.name()
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven(paperMavenPublicUrl)
|
||||
maven("https://oss.sonatype.org/content/groups/public/")
|
||||
maven("https://ci.emc.gs/nexus/content/groups/aikar/")
|
||||
maven("https://repo.aikar.co/content/groups/aikar")
|
||||
maven("https://repo.md-5.net/content/repositories/releases/")
|
||||
maven("https://hub.spigotmc.org/nexus/content/groups/public/")
|
||||
maven("https://jitpack.io")
|
||||
maven("https://repo.codemc.io/repository/maven-public/")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
tasks.generateDevelopmentBundle {
|
||||
apiCoordinates.set("me.earthme.luminol:luminol-api")
|
||||
mojangApiCoordinates.set("io.papermc.paper:paper-mojangapi")
|
||||
libraryRepositories.set(
|
||||
listOf(
|
||||
"https://repo.maven.apache.org/maven2/",
|
||||
"https://maven.pkg.github.com/LuminolMC/Luminol",
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
paperweight {
|
||||
serverProject.set(project(":luminol-server"))
|
||||
|
||||
remapRepo.set("https://maven.fabricmc.net/")
|
||||
decompileRepo.set("https://maven.quiltmc.org/")
|
||||
|
||||
useStandardUpstream("folia") {
|
||||
url.set(github("PaperMC", "Folia"))
|
||||
ref.set(providers.gradleProperty("foliaCommit"))
|
||||
|
||||
withStandardPatcher {
|
||||
apiSourceDirPath.set("Folia-API")
|
||||
serverSourceDirPath.set("Folia-Server")
|
||||
|
||||
|
||||
apiPatchDir.set(layout.projectDirectory.dir("patches/api"))
|
||||
apiOutputDir.set(layout.projectDirectory.dir("Luminol-API"))
|
||||
|
||||
serverPatchDir.set(layout.projectDirectory.dir("patches/server"))
|
||||
serverOutputDir.set(layout.projectDirectory.dir("Luminol-Server"))
|
||||
}
|
||||
|
||||
patchTasks.register("generatedApi") {
|
||||
isBareDirectory = true
|
||||
upstreamDirPath = "paper-api-generator/generated"
|
||||
patchDir = layout.projectDirectory.dir("patches/generatedApi")
|
||||
outputDir = layout.projectDirectory.dir("paper-api-generator/generated")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.generateDevelopmentBundle {
|
||||
apiCoordinates.set("me.earthme.luminol:luminol-api")
|
||||
mojangApiCoordinates.set("io.papermc.paper:paper-mojangapi")
|
||||
libraryRepositories.addAll(
|
||||
"https://repo.maven.apache.org/maven2/",
|
||||
paperMavenPublicUrl,
|
||||
)
|
||||
}
|
||||
|
||||
allprojects {
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
name = "githubPackage"
|
||||
url = uri("https://maven.pkg.github.com/LuminolMC/Luminol")
|
||||
|
||||
credentials.username = System.getenv("GITHUB_USERNAME")
|
||||
credentials.password = System.getenv("GITHUB_TOKEN")
|
||||
}
|
||||
|
||||
publications {
|
||||
register<MavenPublication>("gpr") {
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
if (project.hasProperty("publishDevBundle")) {
|
||||
publications.create<MavenPublication>("devBundle") {
|
||||
artifact(tasks.generateDevelopmentBundle) {
|
||||
artifactId = "dev-bundle"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
java
|
||||
`maven-publish`
|
||||
id("io.papermc.paperweight.patcher") version "1.7.3"
|
||||
}
|
||||
|
||||
val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven(paperMavenPublicUrl) {
|
||||
content { onlyForConfigurations(configurations.paperclip.name) }
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
remapper("net.fabricmc:tiny-remapper:0.10.3:fat")
|
||||
decompiler("org.vineflower:vineflower:1.10.1")
|
||||
paperclip("io.papermc:paperclip:3.0.3")
|
||||
}
|
||||
|
||||
subprojects {
|
||||
apply(plugin = "java")
|
||||
apply(plugin = "maven-publish")
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.release.set(21)
|
||||
}
|
||||
|
||||
tasks.withType<Javadoc> {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
}
|
||||
|
||||
tasks.withType<ProcessResources> {
|
||||
filteringCharset = Charsets.UTF_8.name()
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven(paperMavenPublicUrl)
|
||||
maven("https://oss.sonatype.org/content/groups/public/")
|
||||
maven("https://ci.emc.gs/nexus/content/groups/aikar/")
|
||||
maven("https://repo.aikar.co/content/groups/aikar")
|
||||
maven("https://repo.md-5.net/content/repositories/releases/")
|
||||
maven("https://hub.spigotmc.org/nexus/content/groups/public/")
|
||||
maven("https://jitpack.io")
|
||||
maven("https://repo.codemc.io/repository/maven-public/")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
paperweight {
|
||||
serverProject.set(project(":luminol-server"))
|
||||
|
||||
remapRepo.set("https://maven.fabricmc.net/")
|
||||
decompileRepo.set("https://maven.quiltmc.org/")
|
||||
|
||||
useStandardUpstream("folia") {
|
||||
url.set(github("PaperMC", "Folia"))
|
||||
ref.set(providers.gradleProperty("foliaCommit"))
|
||||
|
||||
withStandardPatcher {
|
||||
apiSourceDirPath.set("Folia-API")
|
||||
serverSourceDirPath.set("Folia-Server")
|
||||
|
||||
|
||||
apiPatchDir.set(layout.projectDirectory.dir("patches/api"))
|
||||
apiOutputDir.set(layout.projectDirectory.dir("Luminol-API"))
|
||||
|
||||
serverPatchDir.set(layout.projectDirectory.dir("patches/server"))
|
||||
serverOutputDir.set(layout.projectDirectory.dir("Luminol-Server"))
|
||||
}
|
||||
|
||||
patchTasks.register("generatedApi") {
|
||||
isBareDirectory = true
|
||||
upstreamDirPath = "paper-api-generator/generated"
|
||||
patchDir = layout.projectDirectory.dir("patches/generatedApi")
|
||||
outputDir = layout.projectDirectory.dir("paper-api-generator/generated")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.generateDevelopmentBundle {
|
||||
apiCoordinates.set("me.earthme.luminol:luminol-api")
|
||||
libraryRepositories.addAll(
|
||||
"https://repo.maven.apache.org/maven2/",
|
||||
"https://maven.pkg.github.com/LuminolMC/Luminol",
|
||||
paperMavenPublicUrl,
|
||||
)
|
||||
}
|
||||
|
||||
allprojects {
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
name = "moliaMavenRepo"
|
||||
url = uri("https://maven.nostal.ink/repository/maven-snapshots/")
|
||||
|
||||
credentials.username = System.getenv("MAVEN_REPO_USER")
|
||||
credentials.password = System.getenv("MAVEN_REPO_PASSWORD")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
if (project.hasProperty("publishDevBundle")) {
|
||||
publications.create<MavenPublication>("devBundle") {
|
||||
artifact(tasks.generateDevelopmentBundle) {
|
||||
artifactId = "dev-bundle"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
group = me.earthme.luminol
|
||||
version = 1.20.4-R0.1-SNAPSHOT
|
||||
version = 1.21.1-R0.1-SNAPSHOT
|
||||
|
||||
foliaCommit = ef2c6971891b7571261591cd22d27ff555c5d3f2
|
||||
foliaCommit = 2e7bc0721af95196c85500c7bb136aeea0bc12ce
|
||||
|
||||
org.gradle.caching = true
|
||||
org.gradle.parallel = true
|
||||
org.gradle.vfs.watch = false
|
||||
org.gradle.jvmargs = -Xmx3G
|
||||
|
||||
mcVersion = 1.21.1
|
||||
GroupMCV = 1.21
|
||||
preVersion = true
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
29
gradlew
vendored
29
gradlew
vendored
@@ -83,10 +83,8 @@ done
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -133,10 +131,13 @@ location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
@@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
@@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
|
||||
20
gradlew.bat
vendored
20
gradlew.bat
vendored
@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
|
||||
24
patches/api/0001-Rebrand-to-Luminol.patch
Normal file
24
patches/api/0001-Rebrand-to-Luminol.patch
Normal file
@@ -0,0 +1,24 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Tue, 21 May 2024 21:31:53 +0800
|
||||
Subject: [PATCH] Rebrand to Luminol
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/ServerBuildInfo.java b/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
index 652ff54e7c50412503725d628bfe72ed03059790..ee163b9fa8f441aa4b3e2309f33e8f932dfc02d7 100644
|
||||
--- a/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
+++ b/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
@@ -19,6 +19,13 @@ public interface ServerBuildInfo {
|
||||
*/
|
||||
Key BRAND_PAPER_ID = Key.key("papermc", "paper");
|
||||
|
||||
+ // Luminol start
|
||||
+ /**
|
||||
+ * The brand id for Luminol.
|
||||
+ */
|
||||
+ Key BRAND_LUMINOL_ID = Key.key("luminolmc", "luminol");
|
||||
+ // Luminol end
|
||||
+
|
||||
/**
|
||||
* Gets the {@code ServerBuildInfo}.
|
||||
*
|
||||
@@ -1,129 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sun, 17 Mar 2024 00:00:45 +0000
|
||||
Subject: [PATCH] Leaves Replay Mod API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||
index 4d6de4f2c67b1f122768806443766bd20c5ae617..b5155ffe86c490252fd0fcd1a00581e09808eeee 100644
|
||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||
@@ -2886,4 +2886,10 @@ public final class Bukkit {
|
||||
public static Server.Spigot spigot() {
|
||||
return server.spigot();
|
||||
}
|
||||
+
|
||||
+ // Leaves start - Photographer API
|
||||
+ public static @NotNull top.leavesmc.leaves.entity.PhotographerManager getPhotographerManager() {
|
||||
+ return server.getPhotographerManager();
|
||||
+ }
|
||||
+ // Leaves end - Photographer API
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index d46f932b595495816ea038cf161bc7f2d85f177e..7d8a9bab880656e34d8c4dceb4dea3b0c1ced4c8 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -2518,4 +2518,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
*/
|
||||
public boolean isGlobalTickThread();
|
||||
// Folia end - region threading API
|
||||
+
|
||||
+ // Leaves start - Photographer API
|
||||
+ @NotNull top.leavesmc.leaves.entity.PhotographerManager getPhotographerManager();
|
||||
+ // Leaves end - Photographer API
|
||||
}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/entity/Photographer.java b/src/main/java/top/leavesmc/leaves/entity/Photographer.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..bfa6fe2a0ca095170aa5e073251402cf83a53ba0
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/entity/Photographer.java
|
||||
@@ -0,0 +1,27 @@
|
||||
+package top.leavesmc.leaves.entity;
|
||||
+
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+import java.io.File;
|
||||
+
|
||||
+public interface Photographer extends Player {
|
||||
+
|
||||
+ @NotNull
|
||||
+ public String getId();
|
||||
+
|
||||
+ public void setRecordFile(@NotNull File file);
|
||||
+
|
||||
+ public void stopRecording();
|
||||
+
|
||||
+ public void stopRecording(boolean async);
|
||||
+
|
||||
+ public void stopRecording(boolean async, boolean save);
|
||||
+
|
||||
+ public void pauseRecording();
|
||||
+
|
||||
+ public void resumeRecording();
|
||||
+
|
||||
+ public void setFollowPlayer(@Nullable Player player);
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/entity/PhotographerManager.java b/src/main/java/top/leavesmc/leaves/entity/PhotographerManager.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..2889a4835edea4254a3d35fc7861983644a1dc4b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/entity/PhotographerManager.java
|
||||
@@ -0,0 +1,32 @@
|
||||
+package top.leavesmc.leaves.entity;
|
||||
+
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.util.Consumer;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+import top.leavesmc.leaves.replay.BukkitRecorderOption;
|
||||
+
|
||||
+import java.util.Collection;
|
||||
+import java.util.UUID;
|
||||
+
|
||||
+public interface PhotographerManager {
|
||||
+ @Nullable
|
||||
+ public Photographer getPhotographer(@NotNull UUID uuid);
|
||||
+
|
||||
+ @Nullable
|
||||
+ public Photographer getPhotographer(@NotNull String id);
|
||||
+
|
||||
+ @Nullable
|
||||
+ public Photographer createPhotographer(@NotNull String id, @NotNull Location location);
|
||||
+
|
||||
+ @Nullable
|
||||
+ public Photographer createPhotographer(@NotNull String id, @NotNull Location location, @NotNull BukkitRecorderOption recorderOption);
|
||||
+
|
||||
+ public void removePhotographer(@NotNull String id);
|
||||
+
|
||||
+ public void removePhotographer(@NotNull UUID uuid);
|
||||
+
|
||||
+ public void removeAllPhotographers();
|
||||
+
|
||||
+ public Collection<Photographer> getPhotographers();
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/replay/BukkitRecorderOption.java b/src/main/java/top/leavesmc/leaves/replay/BukkitRecorderOption.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..3df4a6055b91c28e273d6fb2697b608778f40a9c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/replay/BukkitRecorderOption.java
|
||||
@@ -0,0 +1,18 @@
|
||||
+package top.leavesmc.leaves.replay;
|
||||
+
|
||||
+public class BukkitRecorderOption {
|
||||
+
|
||||
+ // public int recordDistance = -1;
|
||||
+ public String serverName = "Leaves";
|
||||
+ public BukkitRecordWeather forceWeather = BukkitRecordWeather.NULL;
|
||||
+ public int forceDayTime = -1;
|
||||
+ public boolean ignoreChat = false;
|
||||
+ // public boolean ignoreItem = false;
|
||||
+
|
||||
+ public enum BukkitRecordWeather {
|
||||
+ CLEAR,
|
||||
+ RAIN,
|
||||
+ THUNDER,
|
||||
+ NULL
|
||||
+ }
|
||||
+}
|
||||
28
patches/api/0003-KioCG-Chunk-API.patch
Normal file
28
patches/api/0003-KioCG-Chunk-API.patch
Normal file
@@ -0,0 +1,28 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Fri, 25 Oct 2024 00:07:15 +0800
|
||||
Subject: [PATCH] KioCG Chunk API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Chunk.java b/src/main/java/org/bukkit/Chunk.java
|
||||
index bc8b5bc17706250b8535b1b309134843d2ce2bb1..1cfe84ad1094e3c4fab96487f328be53e035a64c 100644
|
||||
--- a/src/main/java/org/bukkit/Chunk.java
|
||||
+++ b/src/main/java/org/bukkit/Chunk.java
|
||||
@@ -389,4 +389,6 @@ public interface Chunk extends PersistentDataHolder {
|
||||
*/
|
||||
UNLOADED;
|
||||
}
|
||||
+
|
||||
+ long getChunkHotAvg(); // KioCG
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||
index 8086acceacbceb2c5a7228fff005e41a86d37008..16ab3c58adcd801d052d93cbf27279d01404cdfd 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -3871,4 +3871,6 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||
*/
|
||||
void sendEntityEffect(org.bukkit.@NotNull EntityEffect effect, @NotNull Entity target);
|
||||
// Paper end - entity effect API
|
||||
+
|
||||
+ long getNearbyChunkHot(); // KioCG
|
||||
}
|
||||
68
patches/api/0004-FoliaPR-Add-TPS-From-Region.patch
Normal file
68
patches/api/0004-FoliaPR-Add-TPS-From-Region.patch
Normal file
@@ -0,0 +1,68 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Tue, 30 Jul 2024 17:58:25 +0800
|
||||
Subject: [PATCH] FoliaPR Add TPS From Region
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||
index 63eb35aebc4551355ea1ea5cd1305d93502f0dbc..de5922397c7d424715e812819b14030639211846 100644
|
||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||
@@ -2405,6 +2405,28 @@ public final class Bukkit {
|
||||
}
|
||||
// Paper end
|
||||
|
||||
+ // Folia start
|
||||
+ /**
|
||||
+ * Gets the current location TPS.
|
||||
+ *
|
||||
+ * @param location the location for which to get the TPS
|
||||
+ * @return current location TPS (5s, 15s, 1m, 5m, 15m in Folia-Server), or null if the region doesn't exist
|
||||
+ */
|
||||
+ public double @Nullable [] getTPS(Location location) {
|
||||
+ return server.getTPS(location);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the current chunk TPS.
|
||||
+ *
|
||||
+ * @param chunk the chunk for which to get the TPS
|
||||
+ * @return current chunk TPS (5s, 15s, 1m, 5m, 15m in Folia-Server), or null if the region doesn't exist
|
||||
+ */
|
||||
+ public double @Nullable [] getTPS(Chunk chunk){
|
||||
+ return server.getTPS(chunk);
|
||||
+ }
|
||||
+ // Folia end
|
||||
+
|
||||
/**
|
||||
* Get the advancement specified by this key.
|
||||
*
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index 8a7ba7d14f20b8169854daaf26e8f4da4563f166..11025aaab88f109f03cd6cda897fc80488cee060 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -2058,6 +2058,24 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
double getAverageTickTime();
|
||||
// Paper end
|
||||
|
||||
+ // Folia start
|
||||
+ /**
|
||||
+ * Gets the current location TPS.
|
||||
+ *
|
||||
+ * @param location the location for which to get the TPS
|
||||
+ * @return current location TPS (5s, 15s, 1m, 5m, 15m in Folia-Server), or null if the region doesn't exist
|
||||
+ */
|
||||
+ public double @Nullable [] getTPS(Location location);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the current chunk TPS.
|
||||
+ *
|
||||
+ * @param chunk the chunk for which to get the TPS
|
||||
+ * @return current chunk TPS (5s, 15s, 1m, 5m, 15m in Folia-Server), or null if the region doesn't exist
|
||||
+ */
|
||||
+ public double @Nullable [] getTPS(Chunk chunk);
|
||||
+ // Folia end
|
||||
+
|
||||
// Paper start
|
||||
/**
|
||||
* Gets the active {@link org.bukkit.command.CommandMap}
|
||||
118
patches/api/0005-Pufferfish-SIMD-Utilities.patch
Normal file
118
patches/api/0005-Pufferfish-SIMD-Utilities.patch
Normal file
@@ -0,0 +1,118 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Tue, 6 Aug 2024 14:32:22 +0800
|
||||
Subject: [PATCH] Pufferfish SIMD Utilities
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index e7c96be769fde8375b9a1b128cc7ce474144d16d..73e0b4a9af5803198e42fa74af5b05654d9a934a 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -131,6 +131,13 @@ val generateApiVersioningFile by tasks.registering {
|
||||
}
|
||||
}
|
||||
|
||||
+// Pufferfish Start
|
||||
+tasks.withType<JavaCompile> {
|
||||
+ val compilerArgs = options.compilerArgs
|
||||
+ compilerArgs.add("--add-modules=jdk.incubator.vector")
|
||||
+}
|
||||
+// Pufferfish End
|
||||
+
|
||||
tasks.jar {
|
||||
from(generateApiVersioningFile.map { it.outputs.files.singleFile }) {
|
||||
into("META-INF/maven/${project.group}/${project.name}")
|
||||
@@ -190,6 +197,7 @@ tasks.withType<Javadoc> {
|
||||
into("build/docs/javadoc")
|
||||
}
|
||||
}
|
||||
+ options.addStringOption("-add-modules", "jdk.incubator.vector") // Pufferfish - SIMD support
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..f00c008c03e2533f568085838cf13cb9b5b32cd9
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
|
||||
@@ -0,0 +1,39 @@
|
||||
+package gg.pufferfish.pufferfish.simd;
|
||||
+
|
||||
+import jdk.incubator.vector.FloatVector;
|
||||
+import jdk.incubator.vector.IntVector;
|
||||
+import jdk.incubator.vector.VectorSpecies;
|
||||
+import org.slf4j.Logger;
|
||||
+
|
||||
+/**
|
||||
+ * Basically, java is annoying and we have to push this out to its own class.
|
||||
+ */
|
||||
+@Deprecated
|
||||
+public class SIMDChecker {
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public static boolean canEnable(Logger logger) {
|
||||
+ try {
|
||||
+ if (SIMDDetection.getJavaVersion() < 17 || SIMDDetection.getJavaVersion() > 21) {
|
||||
+ return false;
|
||||
+ } else {
|
||||
+ SIMDDetection.testRun = true;
|
||||
+
|
||||
+ VectorSpecies<Integer> ISPEC = IntVector.SPECIES_PREFERRED;
|
||||
+ VectorSpecies<Float> FSPEC = FloatVector.SPECIES_PREFERRED;
|
||||
+
|
||||
+ logger.info("Max SIMD vector size on this system is {} bits (int)", ISPEC.vectorBitSize());
|
||||
+ logger.info("Max SIMD vector size on this system is " + FSPEC.vectorBitSize() + " bits (float)");
|
||||
+
|
||||
+ if (ISPEC.elementSize() < 2 || FSPEC.elementSize() < 2) {
|
||||
+ logger.warn("SIMD is not properly supported on this system!");
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+ } catch (NoClassDefFoundError | Exception ignored) {} // Basically, we don't do anything. This lets us detect if it's not functional and disable it.
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..cd953435a6179eaae7c9cc250a791cae26c5567b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java
|
||||
@@ -0,0 +1,35 @@
|
||||
+package gg.pufferfish.pufferfish.simd;
|
||||
+
|
||||
+import org.slf4j.Logger;
|
||||
+
|
||||
+@Deprecated
|
||||
+public class SIMDDetection {
|
||||
+
|
||||
+ public static boolean isEnabled = false;
|
||||
+ public static boolean versionLimited = false;
|
||||
+ public static boolean testRun = false;
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public static boolean canEnable(Logger logger) {
|
||||
+ try {
|
||||
+ return SIMDChecker.canEnable(logger);
|
||||
+ } catch (NoClassDefFoundError | Exception ignored) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public static int getJavaVersion() {
|
||||
+ // https://stackoverflow.com/a/2591122
|
||||
+ String version = System.getProperty("java.version");
|
||||
+ if(version.startsWith("1.")) {
|
||||
+ version = version.substring(2, 3);
|
||||
+ } else {
|
||||
+ int dot = version.indexOf(".");
|
||||
+ if(dot != -1) { version = version.substring(0, dot); }
|
||||
+ }
|
||||
+ version = version.split("-")[0]; // Azul is stupid
|
||||
+ return Integer.parseInt(version);
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
45
patches/api/0006-Disable-timings-warn-msg-and-commands.patch
Normal file
45
patches/api/0006-Disable-timings-warn-msg-and-commands.patch
Normal file
@@ -0,0 +1,45 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Fri, 29 Nov 2024 23:32:23 +0800
|
||||
Subject: [PATCH] Disable timings warn msg and commands
|
||||
|
||||
|
||||
diff --git a/src/main/java/co/aikar/timings/Timings.java b/src/main/java/co/aikar/timings/Timings.java
|
||||
index 7760c779e97a0e95d5c3d255b25d949ac20df235..e1b5dcf0d54d3eaa489949f12874ade0e32cdf2f 100644
|
||||
--- a/src/main/java/co/aikar/timings/Timings.java
|
||||
+++ b/src/main/java/co/aikar/timings/Timings.java
|
||||
@@ -147,7 +147,7 @@ public final class Timings {
|
||||
public static void setTimingsEnabled(boolean enabled) {
|
||||
enabled = false; // Folia - region threading - disable timings
|
||||
timingsEnabled = enabled;
|
||||
- warnAboutDeprecationOnEnable();
|
||||
+ // warnAboutDeprecationOnEnable(); // Luminol - Disable timings warn msg and commands
|
||||
reset();
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||
index 5df19bd701c67506689fc7f49d91f99ebfbc83f0..baf0cbd2f995ebe2e4382244eff6e15ec125d790 100644
|
||||
--- a/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||
+++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||
@@ -39,7 +39,7 @@ public class SimpleCommandMap implements CommandMap {
|
||||
register("bukkit", new VersionCommand("version"));
|
||||
register("bukkit", new ReloadCommand("reload"));
|
||||
//register("bukkit", new PluginsCommand("plugins")); // Paper
|
||||
- register("bukkit", new co.aikar.timings.TimingsCommand("timings")); // Paper
|
||||
+ //register("bukkit", new co.aikar.timings.TimingsCommand("timings")); // Paper // Luminol - Disable timings warn msg and commands
|
||||
}
|
||||
|
||||
public void setFallbackCommands() {
|
||||
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
index 065352b383d6398382b4f14641859dbfe2e6a355..adb9734f6977583a0cf4a8d81d0c36d463456a0f 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
@@ -965,7 +965,7 @@ public final class SimplePluginManager implements PluginManager {
|
||||
* @param use True if per event timing code should be used
|
||||
*/
|
||||
public void useTimings(boolean use) {
|
||||
- co.aikar.timings.Timings.setTimingsEnabled(use); // Paper
|
||||
+ // co.aikar.timings.Timings.setTimingsEnabled(use); // Paper // Luminol - Disable timings warn msg and commands
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@@ -5,24 +5,15 @@ Subject: [PATCH] Fix build
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 905262067dabc7cbe5b08639fcefd3a996a937e0..c0608731dd7a352628a1e31997d0658dfa9f2ea8 100644
|
||||
index eb2f9941b24af591f1e56339b97f5284a765cf81..32bfe781e5298e5ad1bd2ed4471fb824c49f0ab4 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -14,7 +14,7 @@ val alsoShade: Configuration by configurations.creating
|
||||
@@ -13,7 +13,7 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) {
|
||||
val alsoShade: Configuration by configurations.creating
|
||||
|
||||
dependencies {
|
||||
// Folia start
|
||||
- implementation(project(":folia-api"))
|
||||
+ implementation(project(":luminol-api"))//Luminol
|
||||
implementation("io.papermc.paper:paper-mojangapi:${project.version}") {
|
||||
exclude("io.papermc.paper", "paper-api")
|
||||
}
|
||||
@@ -75,7 +75,7 @@ tasks.jar {
|
||||
attributes(
|
||||
"Main-Class" to "org.bukkit.craftbukkit.Main",
|
||||
"Implementation-Title" to "CraftBukkit",
|
||||
- "Implementation-Version" to "git-Folia-$implementationVersion", // Folia
|
||||
+ "Implementation-Version" to "git-Luminol-$implementationVersion", // Folia //Luminol
|
||||
"Implementation-Vendor" to date, // Paper
|
||||
"Specification-Title" to "Bukkit",
|
||||
"Specification-Version" to project.version,
|
||||
- implementation(project(":folia-api")) // Folia
|
||||
+ implementation(project(":luminol-api")) // Folia // Luminol
|
||||
// Paper start
|
||||
implementation("org.jline:jline-terminal-jansi:3.21.0")
|
||||
implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
||||
|
||||
@@ -4,6 +4,30 @@ Date: Tue, 6 Feb 2024 01:35:36 +0000
|
||||
Subject: [PATCH] Rebrand to Luminol
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 28726c59088d98923b9ecb3221ca254385d142fd..f07a002ab51a4aadfea65c3258406edc19b5078e 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -85,14 +85,14 @@ tasks.jar {
|
||||
val gitBranch = git("rev-parse", "--abbrev-ref", "HEAD").getText().trim() // Paper
|
||||
attributes(
|
||||
"Main-Class" to "org.bukkit.craftbukkit.Main",
|
||||
- "Implementation-Title" to "Folia", // Folia
|
||||
+ "Implementation-Title" to "Luminol", // Folia // Luminol
|
||||
"Implementation-Version" to implementationVersion,
|
||||
"Implementation-Vendor" to date, // Paper
|
||||
- "Specification-Title" to "Folia", // Folia
|
||||
+ "Specification-Title" to "Luminol", // Folia // Luminol
|
||||
"Specification-Version" to project.version,
|
||||
- "Specification-Vendor" to "Paper Team",
|
||||
- "Brand-Id" to "papermc:folia", // Folia
|
||||
- "Brand-Name" to "Folia", // Folia
|
||||
+ "Specification-Vendor" to "LuminolMC Team", // Luminol
|
||||
+ "Brand-Id" to "luminolmc:luminol", // Folia // Luminol
|
||||
+ "Brand-Name" to "Luminol", // Folia // Luminol
|
||||
"Build-Number" to (build ?: ""),
|
||||
"Build-Time" to Instant.now().toString(),
|
||||
"Git-Branch" to gitBranch, // Paper
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
index cb60d58d4a7556dd896f31d0cd249f860bb3ef84..b52a805150e95d7d27403d3c18088b335a355011 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
@@ -27,55 +51,60 @@ index cb60d58d4a7556dd896f31d0cd249f860bb3ef84..b52a805150e95d7d27403d3c18088b33
|
||||
metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> {
|
||||
Map<String, Map<String, Integer>> map = new HashMap<>();
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||
index e2f704c115fd6e00960bb56bb0779f1100c89c17..72b9343979de5aa8bb399cbe7cb8a795df9830ab 100644
|
||||
index 29bd788ae8bc61c1e62a4f84b9e259931a7041ce..2f37873738ab542980d13f36356b04b4904e625b 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||
@@ -20,7 +20,7 @@ import java.util.stream.StreamSupport;
|
||||
public class PaperVersionFetcher implements VersionFetcher {
|
||||
private static final java.util.regex.Pattern VER_PATTERN = java.util.regex.Pattern.compile("^([0-9\\.]*)\\-.*R"); // R is an anchor, will always give '-R' at end
|
||||
private static final String GITHUB_BRANCH_NAME = "master";
|
||||
@@ -35,7 +35,7 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||
private static final Logger LOGGER = LogUtils.getClassLogger();
|
||||
private static final int DISTANCE_ERROR = -1;
|
||||
private static final int DISTANCE_UNKNOWN = -2;
|
||||
- private static final String DOWNLOAD_PAGE = "https://papermc.io/downloads/paper";
|
||||
+ private static final String DOWNLOAD_PAGE = "https://github.com/LuminolMC/Luminol"; //Luminol
|
||||
private static @Nullable String mcVer;
|
||||
|
||||
@Override
|
||||
@@ -31,8 +31,8 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||
@Nonnull
|
||||
public long getCacheTime() {
|
||||
@@ -49,7 +49,7 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||
if (build.buildNumber().isEmpty() && build.gitCommit().isEmpty()) {
|
||||
updateMessage = text("You are running a development version without access to version information", color(0xFF5300));
|
||||
} else {
|
||||
- updateMessage = getUpdateStatusMessage("PaperMC/Folia", build); // Folia
|
||||
+ updateMessage = getUpdateStatusMessage("LuminolMC/Luminol", build); // Folia // Luminol
|
||||
}
|
||||
final @Nullable Component history = this.getHistory();
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java b/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java
|
||||
index e741201fdbea0dbbc0e42313ebd33368014c9dc4..673a81734a0903a0790f3007772642d3d9a044cc 100644
|
||||
--- a/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java
|
||||
+++ b/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java
|
||||
@@ -31,6 +31,7 @@ public record ServerBuildInfoImpl(
|
||||
private static final String ATTRIBUTE_GIT_COMMIT = "Git-Commit";
|
||||
|
||||
private static final String BRAND_PAPER_NAME = "Paper";
|
||||
+ private static final String BRAND_LUMINOL_NAME = "Luminol";
|
||||
|
||||
private static final String BUILD_DEV = "DEV";
|
||||
|
||||
@@ -42,9 +43,9 @@ public record ServerBuildInfoImpl(
|
||||
this(
|
||||
getManifestAttribute(manifest, ATTRIBUTE_BRAND_ID)
|
||||
.map(Key::key)
|
||||
- .orElse(Key.key("papermc", "folia")), // Folia
|
||||
+ .orElse(BRAND_LUMINOL_ID), // Folia // Luminol
|
||||
getManifestAttribute(manifest, ATTRIBUTE_BRAND_NAME)
|
||||
- .orElse("Folia"), // Folia
|
||||
+ .orElse(BRAND_LUMINOL_NAME), // Folia // Luminol
|
||||
SharedConstants.getCurrentVersion().getId(),
|
||||
SharedConstants.getCurrentVersion().getName(),
|
||||
getManifestAttribute(manifest, ATTRIBUTE_BUILD_NUMBER)
|
||||
@@ -61,7 +62,7 @@ public record ServerBuildInfoImpl(
|
||||
|
||||
@Override
|
||||
public Component getVersionMessage(@Nonnull String serverVersion) {
|
||||
- String[] parts = serverVersion.substring("git-Folia-".length()).split("[-\\s]"); // Folia
|
||||
- final Component updateMessage = getUpdateStatusMessage("PaperMC/Folia", GITHUB_BRANCH_NAME, parts[0]); // Folia
|
||||
+ String[] parts = serverVersion.substring("git-Luminol-".length()).split("[-\\s]"); // Folia //Luminol
|
||||
+ final Component updateMessage = getUpdateStatusMessage("LuminolMC/Luminol", GITHUB_BRANCH_NAME, parts[0]); // Folia //Luminol
|
||||
final Component history = getHistory();
|
||||
|
||||
return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage;
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index d6a7188227cee9072976db98613324ee2d3dcdc8..8c9a80197247a384dd80747bf23fdd809d08b341 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1963,7 +1963,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
- return "Folia"; // Paper // Folia - Folia
|
||||
+ return "Luminol"; // Paper // Folia - Folia //Luminol - Luminol
|
||||
public boolean isBrandCompatible(final @NotNull Key brandId) {
|
||||
- return brandId.equals(this.brandId);
|
||||
+ return brandId.equals(this.brandId) || brandId.equals(BRAND_PAPER_ID); // Luminol
|
||||
}
|
||||
|
||||
public SystemReport fillSystemReport(SystemReport details) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 9dd9e86a5f7f30ce37b906ebfe4bccad0e52577f..c70eb23d9745bdbfcc340bb554cf0bf2db71f5de 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -266,7 +266,7 @@ import javax.annotation.Nullable; // Paper
|
||||
import javax.annotation.Nonnull; // Paper
|
||||
|
||||
public final class CraftServer implements Server {
|
||||
- private final String serverName = "Folia"; // Folia // Paper
|
||||
+ private final String serverName = "Luminol"; // Folia // Paper //Luminol
|
||||
private final String serverVersion;
|
||||
private final String bukkitVersion = Versioning.getBukkitVersion();
|
||||
private final Logger logger = Logger.getLogger("Minecraft");
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
||||
index e9b6ca3aa25e140467ae866d572483050ea3fa0e..9699d7dcca5cf67f50ad05c0e875de424a4e00c5 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 00:45:19 +0000
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 11:49:53 +0800
|
||||
Subject: [PATCH] Empty config file base
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 48e9f6ff317bfc7077563e9c651d2a90da6bb37a..d4baa7a193eba22be23921029ca4808a73de063d 100644
|
||||
index de5a43db5f0c7c507c492db8789ad2d4a4cff3c8..f657ee64810d1c02a967b9262b95fbc65eb3fce2 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -19,6 +19,7 @@ dependencies {
|
||||
exclude("io.papermc.paper", "paper-api")
|
||||
}
|
||||
// Folia end
|
||||
+ implementation("com.electronwill.night-config:toml:3.6.6") //Luminol - Night config
|
||||
@@ -14,6 +14,7 @@ val alsoShade: Configuration by configurations.creating
|
||||
|
||||
dependencies {
|
||||
implementation(project(":luminol-api")) // Folia // Luminol
|
||||
+ implementation("com.electronwill.night-config:toml:3.6.6") // Luminol - Night config
|
||||
// Paper start
|
||||
implementation("org.jline:jline-terminal-jansi:3.21.0")
|
||||
implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
||||
@@ -125,17 +125,18 @@ index 0000000000000000000000000000000000000000..fffc5eb4be4b78a886f3c340bd60f3a2
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/EnumConfigCategory.java b/src/main/java/me/earthme/luminol/config/EnumConfigCategory.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ac2a92fe0ddbebb71ea4dd8c96f461d06ec29a4c
|
||||
index 0000000000000000000000000000000000000000..7b75405c468d24ed8aea5aa54ae5ac339118bf60
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/EnumConfigCategory.java
|
||||
@@ -0,0 +1,18 @@
|
||||
@@ -0,0 +1,19 @@
|
||||
+package me.earthme.luminol.config;
|
||||
+
|
||||
+public enum EnumConfigCategory {
|
||||
+ OPTIMIZATIONS("optimizations"),
|
||||
+ FIXES("fixes"),
|
||||
+ MISC("misc"),
|
||||
+ GAMEPLAY("gameplay");
|
||||
+ GAMEPLAY("gameplay"),
|
||||
+ EXPERIMENT("experiment");
|
||||
+
|
||||
+ private final String baseKeyName;
|
||||
+
|
||||
@@ -191,20 +192,18 @@ index 0000000000000000000000000000000000000000..9f6896711907ac30fe0c00130207b970
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/LuminolConfig.java b/src/main/java/me/earthme/luminol/config/LuminolConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..2b4e64796bf01b0a5fcb306850cd60837ed4d36b
|
||||
index 0000000000000000000000000000000000000000..976cc572861174787b37992388a03ab01f8703a4
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/LuminolConfig.java
|
||||
@@ -0,0 +1,218 @@
|
||||
@@ -0,0 +1,220 @@
|
||||
+package me.earthme.luminol.config;
|
||||
+
|
||||
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import io.papermc.paper.threadedregions.RegionizedServer;
|
||||
+import me.earthme.luminol.commands.LuminolConfigCommand;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.scheduler.MinecraftInternalPlugin;
|
||||
+import org.jetbrains.annotations.Contract;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.io.IOException;
|
||||
+import java.lang.reflect.Field;
|
||||
@@ -218,7 +217,6 @@ index 0000000000000000000000000000000000000000..2b4e64796bf01b0a5fcb306850cd6083
|
||||
+import java.util.concurrent.CompletableFuture;
|
||||
+import java.util.jar.JarEntry;
|
||||
+import java.util.jar.JarFile;
|
||||
+
|
||||
+import org.apache.logging.log4j.LogManager;
|
||||
+import org.apache.logging.log4j.Logger;
|
||||
+
|
||||
@@ -229,7 +227,6 @@ index 0000000000000000000000000000000000000000..2b4e64796bf01b0a5fcb306850cd6083
|
||||
+ private static final Set<IConfigModule> allInstanced = new HashSet<>();
|
||||
+ private static CommentedFileConfig configFileInstance;
|
||||
+ public static boolean alreadyInited = false;
|
||||
+ private static MinecraftInternalPlugin NULL_PLUGIN = new MinecraftInternalPlugin();
|
||||
+
|
||||
+ public static void setupLatch(){
|
||||
+ Bukkit.getCommandMap().register("luminolconfig","luminol",new LuminolConfigCommand());
|
||||
@@ -249,7 +246,13 @@ index 0000000000000000000000000000000000000000..2b4e64796bf01b0a5fcb306850cd6083
|
||||
+
|
||||
+ @Contract(" -> new")
|
||||
+ public static @NotNull CompletableFuture<Void> reloadAsync(){
|
||||
+ return CompletableFuture.runAsync(LuminolConfig::reload,task -> Bukkit.getGlobalRegionScheduler().run(NULL_PLUGIN,scheduled -> task.run()));
|
||||
+ return CompletableFuture.runAsync(LuminolConfig::reload,task -> RegionizedServer.getInstance().addTask(() -> {
|
||||
+ try{
|
||||
+ task.run();
|
||||
+ }catch (Exception e){
|
||||
+ logger.error(e);
|
||||
+ }
|
||||
+ }));
|
||||
+ }
|
||||
+
|
||||
+ public static void dropAllInstanced(){
|
||||
@@ -413,25 +416,175 @@ index 0000000000000000000000000000000000000000..2b4e64796bf01b0a5fcb306850cd6083
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/utils/NullPlugin.java b/src/main/java/me/earthme/luminol/utils/NullPlugin.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..de94c8e39f0ae0da80d5a79af63413e287f5d190
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/utils/NullPlugin.java
|
||||
@@ -0,0 +1,152 @@
|
||||
+package me.earthme.luminol.utils;
|
||||
+
|
||||
+import io.papermc.paper.plugin.configuration.PluginMeta;
|
||||
+import io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager;
|
||||
+import org.bukkit.Server;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.configuration.file.FileConfiguration;
|
||||
+import org.bukkit.generator.BiomeProvider;
|
||||
+import org.bukkit.generator.ChunkGenerator;
|
||||
+import org.bukkit.plugin.*;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.io.InputStream;
|
||||
+import java.util.List;
|
||||
+import java.util.logging.Logger;
|
||||
+
|
||||
+public class NullPlugin extends PluginBase {
|
||||
+ private boolean enabled = true;
|
||||
+
|
||||
+ private final String pluginName;
|
||||
+ private PluginDescriptionFile pdf;
|
||||
+
|
||||
+ public NullPlugin() {
|
||||
+ this.pluginName = "Minecraft";
|
||||
+ pdf = new PluginDescriptionFile(pluginName, "1.0", "nms");
|
||||
+ }
|
||||
+
|
||||
+ public void setEnabled(boolean enabled) {
|
||||
+ this.enabled = enabled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public File getDataFolder() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public PluginDescriptionFile getDescription() {
|
||||
+ return pdf;
|
||||
+ }
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public io.papermc.paper.plugin.configuration.PluginMeta getPluginMeta() {
|
||||
+ return pdf;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
+ @Override
|
||||
+ public FileConfiguration getConfig() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public InputStream getResource(String filename) {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void saveConfig() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void saveDefaultConfig() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void saveResource(String resourcePath, boolean replace) {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void reloadConfig() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public PluginLogger getLogger() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public PluginLoader getPluginLoader() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Server getServer() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isEnabled() {
|
||||
+ return enabled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onDisable() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onLoad() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onEnable() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isNaggable() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setNaggable(boolean canNag) {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @Nullable BiomeProvider getDefaultBiomeProvider(@NotNull String worldName, @Nullable String id) {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ // Paper start - lifecycle events
|
||||
+ @Override
|
||||
+ public @NotNull io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager<org.bukkit.plugin.Plugin> getLifecycleManager() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+ // Paper end - lifecycle events
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 6b3242117d62175de462d04e4d178b49ae2521e9..4744ace98d1741db80ac2aea198f332d95c0ba33 100644
|
||||
index 301d7fa29fce2997a5881b3852896eff5af33672..0755e8f460f59e2dbc00cac73026bb441c04e9ea 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -19,6 +19,8 @@ import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.earthme.luminol.config.LuminolConfig;
|
||||
import net.minecraft.DefaultUncaughtExceptionHandler;
|
||||
import net.minecraft.DefaultUncaughtExceptionHandlerWithName;
|
||||
import net.minecraft.SharedConstants;
|
||||
@@ -209,6 +211,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -226,6 +226,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
this.paperConfigurations.initializeGlobalConfiguration(this.registryAccess());
|
||||
this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess());
|
||||
// Paper end - initialize global and world-defaults configuration
|
||||
+ LuminolConfig.loadConfig(); //Luminol - load config file
|
||||
+ LuminolConfig.setupLatch(); //Luminol - load config file
|
||||
+ me.earthme.luminol.config.LuminolConfig.loadConfig(); //Luminol - load config file
|
||||
+ me.earthme.luminol.config.LuminolConfig.setupLatch(); //Luminol - load config file
|
||||
this.server.spark.enableEarlyIfRequested(); // Paper - spark
|
||||
// Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save
|
||||
if (this.convertOldUsers()) {
|
||||
this.getProfileCache().save(false); // Paper
|
||||
|
||||
@@ -47,15 +47,15 @@ index 0000000000000000000000000000000000000000..94e7c8910e3623163528a844fd7a08b3
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 8c9a80197247a384dd80747bf23fdd809d08b341..0d756dd5181a2444175184227bef648d07c17236 100644
|
||||
index 511992c31d70e806bba68737048ca760bef1def0..5bd02c4f65327b9b848b08e61820c262e0a71731 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1963,7 +1963,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -2032,7 +2032,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
- return "Luminol"; // Paper // Folia - Folia //Luminol - Luminol
|
||||
+ return me.earthme.luminol.config.modules.misc.ServerModNameConfig.fakeVanilla ? "vanilla" : me.earthme.luminol.config.modules.misc.ServerModNameConfig.serverModName; // Paper // Folia - Folia //Luminol - Luminol //Luminol - Add config for this
|
||||
- return io.papermc.paper.ServerBuildInfo.buildInfo().brandName(); // Paper
|
||||
+ return me.earthme.luminol.config.modules.misc.ServerModNameConfig.fakeVanilla ? "vanilla" : me.earthme.luminol.config.modules.misc.ServerModNameConfig.serverModName; // Paper // Luminol - Add config for this
|
||||
}
|
||||
|
||||
public SystemReport fillSystemReport(SystemReport details) {
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 00:53:03 +0000
|
||||
Subject: [PATCH] Add config for unsafe teleportation
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/UnsafeTeleportationConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/UnsafeTeleportationConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..1b0de6f0ccab72c409a63dc1904829008e30328e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/UnsafeTeleportationConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.fixes;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class UnsafeTeleportationConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled", comments = "If you want to use sand duping,please turn on this")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.FIXES;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "allow_unsafe_teleportation";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 1d77bc6bdb87de1ad6c8740376391dedcaa73089..5e3a5e6b05254481ad413069b249ef554b591f8c 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -4065,6 +4065,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
|
||||
protected boolean tryEndPortal() {
|
||||
io.papermc.paper.util.TickThread.ensureTickThread(this, "Cannot portal entity async");
|
||||
+ if (me.earthme.luminol.config.modules.fixes.UnsafeTeleportationConfig.enabled && !(this instanceof Player)) return false; //Luminol - Unsafe teleportation
|
||||
BlockPos pos = this.portalBlock;
|
||||
ServerLevel world = this.portalWorld;
|
||||
this.portalBlock = null;
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
index afc9445941b984cc1122839e4a8a17cf27aa966e..0eb328e2b32179ebeefc90063441a1510e0058b8 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
@@ -61,6 +61,13 @@ public class EndPortalBlock extends BaseEntityBlock {
|
||||
// return; // CraftBukkit - always fire event in case plugins wish to change it
|
||||
}
|
||||
|
||||
+ //Luminol start - Unsafe teleportation
|
||||
+ if (me.earthme.luminol.config.modules.fixes.UnsafeTeleportationConfig.enabled && !(entity instanceof net.minecraft.world.entity.player.Player)){
|
||||
+ entity.endPortalLogicAsync();
|
||||
+ return;
|
||||
+ }
|
||||
+ //Luminol end - Unsafe teleportation
|
||||
+
|
||||
// Paper start - move all of this logic into portal tick
|
||||
entity.portalWorld = ((ServerLevel)world);
|
||||
entity.portalBlock = pos.immutable();
|
||||
@@ -1,6 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 00:59:18 +0000
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 12:01:17 +0800
|
||||
Subject: [PATCH] Add config for void trading
|
||||
|
||||
|
||||
@@ -31,15 +31,15 @@ index 0000000000000000000000000000000000000000..22f3c6c70e4287f1bdd0b18f87f57efe
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 81749b8da7182abd1bf35629f33388e813dbeac0..10df17ad79092f3e226df08e58620694b3581758 100644
|
||||
index 90d78ddf8518c0df307cdaa8b7cfb5549491c6e5..94d855f14c91ca164f1728be1df4e83dfed8b005 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -3045,7 +3045,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
@@ -2816,7 +2816,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
|
||||
// Spigot Start
|
||||
if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message
|
||||
// Paper start - Fix merchant inventory not closing on entity removal
|
||||
- if (entity.getBukkitEntity() instanceof org.bukkit.inventory.Merchant merchant && merchant.getTrader() != null) {
|
||||
+ if (!me.earthme.luminol.config.modules.fixes.VoidTradingFixConfig.enabled && (entity.getBukkitEntity() instanceof org.bukkit.inventory.Merchant merchant && merchant.getTrader() != null)) { //Luminol - Add config for void trading
|
||||
+ if (!me.earthme.luminol.config.modules.fixes.VoidTradingFixConfig.enabled && (entity.getBukkitEntity() instanceof org.bukkit.inventory.Merchant merchant && merchant.getTrader() != null)) { // Luminol - Add config for void trading
|
||||
merchant.getTrader().closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED);
|
||||
}
|
||||
// Paper end - Fix merchant inventory not closing on entity removal
|
||||
@@ -0,0 +1,71 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Fri, 25 Oct 2024 00:05:33 +0800
|
||||
Subject: [PATCH] Add config for unsafe teleportation
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/UnsafeTeleportationConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/UnsafeTeleportationConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ea374875f529b30db17e8b8cb07b99a600b722dc
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/UnsafeTeleportationConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.fixes;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class UnsafeTeleportationConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled", comments = "Allow non player entities enter end portals if enabled.If you want to use sand duping,please turn on this")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.FIXES;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "allow_unsafe_teleportation";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
index 5d6b1a63a2a213f8a4e81c5e574847007a82007b..77ff2a526a1d2b9307dfc696f9862bfda7407475 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
@@ -69,7 +69,7 @@ public class FallingBlockEntity extends Entity {
|
||||
public float fallDamagePerDistance;
|
||||
@Nullable
|
||||
public CompoundTag blockData;
|
||||
- public boolean forceTickAfterTeleportToDuplicate;
|
||||
+ public boolean forceTickAfterTeleportToDuplicate = me.earthme.luminol.config.modules.fixes.UnsafeTeleportationConfig.enabled; // Luminol - Unsafe teleportation
|
||||
protected static final EntityDataAccessor<BlockPos> DATA_START_POS = SynchedEntityData.defineId(FallingBlockEntity.class, EntityDataSerializers.BLOCK_POS);
|
||||
public boolean autoExpire = true; // Paper - Expand FallingBlock API
|
||||
|
||||
@@ -419,7 +419,7 @@ public class FallingBlockEntity extends Entity {
|
||||
boolean flag = (resourcekey1 == Level.END || resourcekey == Level.END) && resourcekey1 != resourcekey;
|
||||
Entity entity = super.changeDimension(teleportTarget);
|
||||
|
||||
- this.forceTickAfterTeleportToDuplicate = entity != null && flag && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowUnsafeEndPortalTeleportation; // Paper
|
||||
+ this.forceTickAfterTeleportToDuplicate = entity != null && flag && (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowUnsafeEndPortalTeleportation || me.earthme.luminol.config.modules.fixes.UnsafeTeleportationConfig.enabled); // Paper // Luminol - Unsafe teleportation
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
index e1c071e0b25c4678bf08313b6c60cf895a54aa02..13c3527cd4852356ce8f39c739d1c5015ef69b16 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
@@ -71,7 +71,11 @@ public class EndPortalBlock extends BaseEntityBlock implements Portal {
|
||||
if (event.isCancelled()) return; // Paper - make cancellable
|
||||
// CraftBukkit end
|
||||
// Folia - region threading - do not show credits
|
||||
-
|
||||
+ // Luminol start - unsafe teleportation
|
||||
+ if (me.earthme.luminol.config.modules.fixes.UnsafeTeleportationConfig.enabled && !(entity instanceof net.minecraft.world.entity.player.Player)) {
|
||||
+ entity.endPortalLogicAsync(pos);
|
||||
+ }
|
||||
+ // Luminol end
|
||||
entity.setAsInsidePortal(this, pos);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 02:33:00 +0000
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 12:02:01 +0800
|
||||
Subject: [PATCH] Add config for vanilla random
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/VanillaRandomSourceConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/VanillaRandomSourceConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ee247014c9a2ec1bbb7f25ef41da110a270154d6
|
||||
index 0000000000000000000000000000000000000000..0e6bfc03be660415c333024b56ac6565e3b61ab1
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/VanillaRandomSourceConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
@@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..ee247014c9a2ec1bbb7f25ef41da110a
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class VanillaRandomSourceConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enable_for_player_entity")
|
||||
+ @ConfigInfo(baseName = "enable_for_player_entity",comments = "Related with RNG cracks")
|
||||
+ public static boolean useLegacyRandomSourceForPlayers = false;
|
||||
+
|
||||
+ @Override
|
||||
@@ -31,10 +31,10 @@ index 0000000000000000000000000000000000000000..ee247014c9a2ec1bbb7f25ef41da110a
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 5e3a5e6b05254481ad413069b249ef554b591f8c..9bbfac91f97331b1b558264c867b7e00185291f2 100644
|
||||
index de5263b0261ed2f8f97b9525936be8067ddb79b2..dfac4257d8de1a607ff952a1b27f61f3b4329516 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -567,7 +567,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -570,7 +570,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
this.bb = Entity.INITIAL_AABB;
|
||||
this.stuckSpeedMultiplier = Vec3.ZERO;
|
||||
this.nextStep = 1.0F;
|
||||
|
||||
@@ -31,10 +31,10 @@ index 0000000000000000000000000000000000000000..1e03e51e51f56c38abaad100274e25c9
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/commands/arguments/ArgumentSignatures.java b/src/main/java/net/minecraft/commands/arguments/ArgumentSignatures.java
|
||||
index 72a8aa676836fcb3b4578689d16af65e18f55bbe..9408747cb254a99d5cb3fc26fde16ddb80168894 100644
|
||||
index 479e6e2aa88a22ef7f8fccb06add6806f5b71d9d..22dae23a0c2fa4c85befd670637b1e592d889b58 100644
|
||||
--- a/src/main/java/net/minecraft/commands/arguments/ArgumentSignatures.java
|
||||
+++ b/src/main/java/net/minecraft/commands/arguments/ArgumentSignatures.java
|
||||
@@ -14,9 +14,17 @@ public record ArgumentSignatures(List<ArgumentSignatures.Entry> entries) {
|
||||
@@ -14,9 +14,16 @@ public record ArgumentSignatures(List<ArgumentSignatures.Entry> entries) {
|
||||
private static final int MAX_ARGUMENT_NAME_LENGTH = 16;
|
||||
|
||||
public ArgumentSignatures(FriendlyByteBuf buf) {
|
||||
@@ -49,21 +49,20 @@ index 72a8aa676836fcb3b4578689d16af65e18f55bbe..9408747cb254a99d5cb3fc26fde16ddb
|
||||
+ }
|
||||
+ //Luminol end
|
||||
+
|
||||
+
|
||||
@Nullable
|
||||
public MessageSignature get(String argumentName) {
|
||||
for(ArgumentSignatures.Entry entry : this.entries) {
|
||||
public void write(FriendlyByteBuf buf) {
|
||||
buf.writeCollection(this.entries, (buf2, entry) -> entry.write(buf2));
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/network/FriendlyByteBuf.java b/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
||||
index b863249ff7e13cf4939c8961601f0564c62fd661..6ab73b0568c3f9df8090be992736a14d49e0286c 100644
|
||||
index aafeb9c61ddba6a8671f0238eda47b227619f1af..dc00ad0cc7f0c5c069a8d15dfdc926f2a1487319 100644
|
||||
--- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
||||
+++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
||||
@@ -143,6 +143,16 @@ public class FriendlyByteBuf extends ByteBuf {
|
||||
@@ -129,6 +129,16 @@ public class FriendlyByteBuf extends ByteBuf {
|
||||
// Paper end - Adventure; add max length parameter
|
||||
DataResult<JsonElement> dataresult = codec.encodeStart(JsonOps.INSTANCE, value);
|
||||
|
||||
+ //Luminol start - Add config for chat sign
|
||||
+ if (codec == net.minecraft.network.protocol.status.ServerStatus.CODEC) {
|
||||
+ JsonElement element = Util.getOrThrow(dataresult, string -> new EncoderException("Failed to encode: " + string + " " + value));
|
||||
+ JsonElement element = dataresult.getOrThrow(string -> new EncoderException("Failed to encode: " + string + " " + value));
|
||||
+ element.getAsJsonObject().addProperty("preventsChatReports", !me.earthme.luminol.config.modules.misc.ChatSignConfig.enabled);
|
||||
+
|
||||
+ this.writeUtf(GSON.toJson(element));
|
||||
@@ -71,6 +70,6 @@ index b863249ff7e13cf4939c8961601f0564c62fd661..6ab73b0568c3f9df8090be992736a14d
|
||||
+ }
|
||||
+ //Luminol end
|
||||
+
|
||||
this.writeUtf(FriendlyByteBuf.GSON.toJson((JsonElement) Util.getOrThrow(dataresult, (s) -> {
|
||||
return new EncoderException("Failed to encode: " + s + " " + value);
|
||||
this.writeUtf(FriendlyByteBuf.GSON.toJson((JsonElement) dataresult.getOrThrow((s) -> {
|
||||
return new EncoderException("Failed to encode: " + s + " " + String.valueOf(value));
|
||||
})), maxLength); // Paper - Adventure; add max length parameter
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 04:39:56 +0000
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 12:05:39 +0800
|
||||
Subject: [PATCH] Add a simple tpsbar
|
||||
|
||||
|
||||
@@ -117,39 +117,38 @@ index 0000000000000000000000000000000000000000..aafb2f5052c7c8e5971a47308253badb
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java b/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..3f1478dde900d671c4bfa43df80f629519cd602e
|
||||
index 0000000000000000000000000000000000000000..026807e0851d67c6d57e81f573ac1bf8fedc6109
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java
|
||||
@@ -0,0 +1,225 @@
|
||||
@@ -0,0 +1,224 @@
|
||||
+package me.earthme.luminol.functions;
|
||||
+
|
||||
+import com.mojang.logging.LogUtils;
|
||||
+import io.papermc.paper.threadedregions.ThreadedRegionizer;
|
||||
+import io.papermc.paper.threadedregions.TickData;
|
||||
+import io.papermc.paper.threadedregions.TickRegions;
|
||||
+import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
||||
+import me.earthme.luminol.config.modules.misc.TpsBarConfig;
|
||||
+import me.earthme.luminol.utils.NullPlugin;
|
||||
+import net.kyori.adventure.bossbar.BossBar;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
+import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
+import net.minecraft.server.level.ServerLevel;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import org.apache.logging.log4j.LogManager;
|
||||
+import org.apache.logging.log4j.Logger;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
+import org.bukkit.craftbukkit.scheduler.MinecraftInternalPlugin;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.slf4j.Logger;
|
||||
+
|
||||
+import java.util.*;
|
||||
+import java.util.concurrent.TimeUnit;
|
||||
+
|
||||
+public class GlobalServerTpsBar {
|
||||
+ protected static final MinecraftInternalPlugin NULL_PLUGIN = new MinecraftInternalPlugin();
|
||||
+ protected static final NullPlugin NULL_PLUGIN = new NullPlugin();
|
||||
+ protected static final Map<UUID,BossBar> uuid2Bossbars = new HashMap<>();
|
||||
+ protected static volatile ScheduledTask tpsbarTask = null;
|
||||
+ private static final Logger logger = LogManager.getLogger();
|
||||
+ private static final Logger logger = LogUtils.getLogger();
|
||||
+
|
||||
+ public static void init(){
|
||||
+ cancelBarUpdateTask();
|
||||
@@ -159,7 +158,7 @@ index 0000000000000000000000000000000000000000..3f1478dde900d671c4bfa43df80f6295
|
||||
+ try {
|
||||
+ update();
|
||||
+ }catch (Exception e){
|
||||
+ logger.error(e);
|
||||
+ logger.error(e.getLocalizedMessage());
|
||||
+ }
|
||||
+ },1,TpsBarConfig.updateInterval);
|
||||
+ }
|
||||
@@ -233,7 +232,7 @@ index 0000000000000000000000000000000000000000..3f1478dde900d671c4bfa43df80f6295
|
||||
+ private static void updateBarValues(){
|
||||
+ for (Player apiPlayer : Bukkit.getOnlinePlayers()){
|
||||
+ final ServerPlayer nmsPlayer = ((CraftPlayer) apiPlayer).getHandle();
|
||||
+ final ThreadedRegionizer.ThreadedRegion<TickRegions.TickRegionData, TickRegions.TickRegionSectionData> region = ((ServerLevel) nmsPlayer.level()).regioniser.getRegionAtUnsynchronised(nmsPlayer.sectionX,nmsPlayer.sectionZ);
|
||||
+ final ThreadedRegionizer.ThreadedRegion<TickRegions.TickRegionData, TickRegions.TickRegionSectionData> region = ((ServerLevel) nmsPlayer.level()).regioniser.getRegionAtUnsynchronised(nmsPlayer.moonrise$getSectionX(),nmsPlayer.moonrise$getSectionZ());
|
||||
+
|
||||
+ if (region == null){
|
||||
+ continue;
|
||||
@@ -347,10 +346,10 @@ index 0000000000000000000000000000000000000000..3f1478dde900d671c4bfa43df80f6295
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 4744ace98d1741db80ac2aea198f332d95c0ba33..550fb11c64e3adb35bb7f78c53f0b5ae5ce9ff58 100644
|
||||
index 0755e8f460f59e2dbc00cac73026bb441c04e9ea..690d0f59daf8c4630c3d70b6fb690c2e1cedd402 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -832,6 +832,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -855,6 +855,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
|
||||
@Override
|
||||
public void stopServer() {
|
||||
@@ -359,22 +358,23 @@ index 4744ace98d1741db80ac2aea198f332d95c0ba33..550fb11c64e3adb35bb7f78c53f0b5ae
|
||||
//Util.shutdownExecutors(); // Paper - moved into super
|
||||
SkullBlockEntity.clear();
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index cbc89b8898f9243776af88c2b04ad3c2e4e23fb6..318cb1e98a3d73b7893f07c9f0db3adab801b67e 100644
|
||||
index e4a68f43c1a48fe8193623c646eb40bc5f664c76..59a4937363a2404fe0b852b0ac851ef0c9c528ce 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -285,6 +285,7 @@ public class ServerPlayer extends Player {
|
||||
// Paper start - replace player chunk loader
|
||||
private final java.util.concurrent.atomic.AtomicReference<io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances> viewDistances = new java.util.concurrent.atomic.AtomicReference<>(new io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances(-1, -1, -1));
|
||||
public io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader;
|
||||
@@ -303,7 +303,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
||||
public com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent
|
||||
public @Nullable String clientBrandName = null; // Paper - Brand support
|
||||
public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event
|
||||
-
|
||||
+ public volatile boolean isTpsBarVisible = false; //Luminol - Tps bar
|
||||
|
||||
public io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances getViewDistances() {
|
||||
return this.viewDistances.get();
|
||||
// Paper start - rewrite chunk system
|
||||
private ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader;
|
||||
private final ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.ViewDistanceHolder viewDistanceHolder = new ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.ViewDistanceHolder();
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index d2902fc7f3b7af59f181bd1e12435d946db7ad23..26f70965b45fa3c344781b569a651a4668d0621d 100644
|
||||
index 12a2da086f249b3dbd61e5749b9856a2fce9ac7b..b954a5a3d8c589a0261202f21f1430c8790e874a 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -2287,6 +2287,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@@ -2393,6 +2393,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
handle.expToDrop = data.getInt("expToDrop");
|
||||
handle.keepLevel = data.getBoolean("keepLevel");
|
||||
}
|
||||
@@ -384,7 +384,7 @@ index d2902fc7f3b7af59f181bd1e12435d946db7ad23..26f70965b45fa3c344781b569a651a46
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2308,6 +2311,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@@ -2414,6 +2417,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
data.putLong("lastPlayed", System.currentTimeMillis());
|
||||
data.putString("lastKnownName", handle.getScoreboardName());
|
||||
|
||||
|
||||
355
patches/server/0010-Add-a-simple-membar.patch
Normal file
355
patches/server/0010-Add-a-simple-membar.patch
Normal file
@@ -0,0 +1,355 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 12:18:09 +0800
|
||||
Subject: [PATCH] Add a simple membar
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/commands/MembarCommand.java b/src/main/java/me/earthme/luminol/commands/MembarCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..a5cbad6b947b1c3e1499bc6d311e17a5eb570c2f
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/commands/MembarCommand.java
|
||||
@@ -0,0 +1,47 @@
|
||||
+package me.earthme.luminol.commands;
|
||||
+
|
||||
+import me.earthme.luminol.config.modules.misc.MembarConfig;
|
||||
+import me.earthme.luminol.functions.GlobalServerMemoryBar;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.text.format.TextColor;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+public class MembarCommand extends Command {
|
||||
+ public MembarCommand(@NotNull String name) {
|
||||
+ super(name);
|
||||
+ this.setPermission("luminol.commands.membar");
|
||||
+ this.setDescription("Show the memory usage through a bossbar");
|
||||
+ this.setUsage("/membar");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
|
||||
+ if (!testPermission(sender)){
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ if (!MembarConfig.memoryBarEnabled){
|
||||
+ sender.sendMessage(Component.text("Membar was already disabled!").color(TextColor.color(255,0,0)));
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ if (!(sender instanceof Player player)){
|
||||
+ sender.sendMessage(Component.text("Only player can use this command!").color(TextColor.color(255,0,0)));
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ if (GlobalServerMemoryBar.isPlayerVisible(player)) {
|
||||
+ player.sendMessage(Component.text("Disabled mem bar").color(TextColor.color(0,255,0)));
|
||||
+ GlobalServerMemoryBar.setVisibilityForPlayer(player,false);
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ player.sendMessage(Component.text("Enabled mem bar").color(TextColor.color(0,255,0)));
|
||||
+ GlobalServerMemoryBar.setVisibilityForPlayer(player,true);
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/MembarConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/MembarConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..b632c4a636974535bf001f010de1dcb6b25868c0
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/MembarConfig.java
|
||||
@@ -0,0 +1,50 @@
|
||||
+package me.earthme.luminol.config.modules.misc;
|
||||
+
|
||||
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import me.earthme.luminol.commands.MembarCommand;
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.DoNotLoad;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+import me.earthme.luminol.functions.GlobalServerMemoryBar;
|
||||
+import org.bukkit.Bukkit;
|
||||
+
|
||||
+import java.util.List;
|
||||
+
|
||||
+public class MembarConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean memoryBarEnabled = false;
|
||||
+ @ConfigInfo(baseName = "format")
|
||||
+ public static String memBarFormat = "<gray>Memory usage <yellow>:</yellow> <used>MB<yellow>/</yellow><available>MB";
|
||||
+ @ConfigInfo(baseName = "memory_color_list")
|
||||
+ public static List<String> memColors = List.of("GREEN","YELLOW","RED","PURPLE");
|
||||
+ @ConfigInfo(baseName = "update_interval_ticks")
|
||||
+ public static int updateInterval = 15;
|
||||
+
|
||||
+ @DoNotLoad
|
||||
+ private static boolean inited = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "membar";
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onLoaded(CommentedFileConfig configInstance){
|
||||
+ if (memoryBarEnabled){
|
||||
+ GlobalServerMemoryBar.init();
|
||||
+ }else{
|
||||
+ GlobalServerMemoryBar.cancelBarUpdateTask();
|
||||
+ }
|
||||
+
|
||||
+ if (!inited){
|
||||
+ Bukkit.getCommandMap().register("membar","luminol",new MembarCommand("membar"));
|
||||
+ inited = true;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/functions/GlobalServerMemoryBar.java b/src/main/java/me/earthme/luminol/functions/GlobalServerMemoryBar.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..47809d78392fe0cb30ad68ca1c331784f1843269
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/functions/GlobalServerMemoryBar.java
|
||||
@@ -0,0 +1,186 @@
|
||||
+package me.earthme.luminol.functions;
|
||||
+
|
||||
+import com.mojang.logging.LogUtils;
|
||||
+import io.papermc.paper.threadedregions.ThreadedRegionizer;
|
||||
+import io.papermc.paper.threadedregions.TickRegions;
|
||||
+import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
||||
+import me.earthme.luminol.config.modules.misc.MembarConfig;
|
||||
+import me.earthme.luminol.utils.NullPlugin;
|
||||
+import net.kyori.adventure.bossbar.BossBar;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
+import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
+import net.minecraft.server.level.ServerLevel;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.slf4j.Logger;
|
||||
+
|
||||
+import java.lang.management.ManagementFactory;
|
||||
+import java.lang.management.MemoryUsage;
|
||||
+import java.util.*;
|
||||
+
|
||||
+public class GlobalServerMemoryBar {
|
||||
+ protected static final NullPlugin NULL_PLUGIN = new NullPlugin();
|
||||
+ protected static final Map<UUID, BossBar> uuid2Bossbars = new HashMap<>();
|
||||
+ protected static volatile ScheduledTask membarTask = null;
|
||||
+ private static final Logger logger = LogUtils.getLogger();
|
||||
+
|
||||
+ public static void init(){
|
||||
+ cancelBarUpdateTask();
|
||||
+
|
||||
+ Bukkit.getGlobalRegionScheduler().runAtFixedRate(NULL_PLUGIN, c -> {
|
||||
+ membarTask = c;
|
||||
+ try {
|
||||
+ update();
|
||||
+ }catch (Exception e){
|
||||
+ logger.error(e.getLocalizedMessage());
|
||||
+ }
|
||||
+ },1, MembarConfig.updateInterval);
|
||||
+ }
|
||||
+
|
||||
+ public static void removeAllBars(){
|
||||
+ for (Map.Entry<UUID,BossBar> barEntry : uuid2Bossbars.entrySet()){
|
||||
+ final UUID playerUUID = barEntry.getKey();
|
||||
+ final BossBar memBar = barEntry.getValue();
|
||||
+
|
||||
+ final Player targetPlayer = Bukkit.getPlayer(playerUUID);{
|
||||
+ if (targetPlayer != null){
|
||||
+ targetPlayer.hideBossBar(memBar);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ uuid2Bossbars.clear();
|
||||
+ }
|
||||
+
|
||||
+ public static void cancelBarUpdateTask(){
|
||||
+ removeAllBars();
|
||||
+
|
||||
+ if (membarTask == null || membarTask.isCancelled()){
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ membarTask.cancel();
|
||||
+ }
|
||||
+
|
||||
+ public static boolean isPlayerVisible(Player player){
|
||||
+ return ((CraftPlayer) player).getHandle().isMemBarVisible;
|
||||
+ }
|
||||
+
|
||||
+ public static void setVisibilityForPlayer(Player target,boolean canSee){
|
||||
+ ((CraftPlayer) target).getHandle().isMemBarVisible = canSee;
|
||||
+ }
|
||||
+
|
||||
+ private static void update(){
|
||||
+ updateBarValues();
|
||||
+ cleanUpPlayers();
|
||||
+ }
|
||||
+
|
||||
+ private static void cleanUpPlayers(){
|
||||
+ final List<UUID> toRemove = new ArrayList<>();
|
||||
+
|
||||
+ for (Map.Entry<UUID,BossBar> bossBarEntry : uuid2Bossbars.entrySet()){
|
||||
+ final UUID uuid = bossBarEntry.getKey();
|
||||
+ boolean shouldRemove = true;
|
||||
+
|
||||
+ final Player target = Bukkit.getPlayer(uuid);
|
||||
+ if (target != null){
|
||||
+ shouldRemove = !isPlayerVisible(target);
|
||||
+ }
|
||||
+
|
||||
+ if (shouldRemove){
|
||||
+ toRemove.add(uuid);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ for (UUID uuid : toRemove){
|
||||
+ final BossBar removed = uuid2Bossbars.remove(uuid);
|
||||
+ if (removed != null){
|
||||
+ final Player targetPlayer = Bukkit.getPlayer(uuid);
|
||||
+ if (targetPlayer != null){
|
||||
+ targetPlayer.hideBossBar(removed);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static void updateBarValues(){
|
||||
+ MemoryUsage heap = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
|
||||
+
|
||||
+ long used = heap.getUsed();
|
||||
+ long xmx = heap.getMax();
|
||||
+
|
||||
+
|
||||
+
|
||||
+ for (Player apiPlayer : Bukkit.getOnlinePlayers()){
|
||||
+ final ServerPlayer nmsPlayer = ((CraftPlayer) apiPlayer).getHandle();
|
||||
+ final ThreadedRegionizer.ThreadedRegion<TickRegions.TickRegionData, TickRegions.TickRegionSectionData> region = ((ServerLevel) nmsPlayer.level()).regioniser.getRegionAtUnsynchronised(nmsPlayer.moonrise$getSectionX(),nmsPlayer.moonrise$getSectionZ());
|
||||
+
|
||||
+ if (region == null){
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ BossBar targetBossbar = uuid2Bossbars.get(nmsPlayer.getUUID());
|
||||
+
|
||||
+ if (targetBossbar == null && isPlayerVisible(apiPlayer)){
|
||||
+ targetBossbar = BossBar.bossBar(Component.text(""),0.0F, BossBar.Color.valueOf(MembarConfig.memColors.get(3)), BossBar.Overlay.NOTCHED_20);
|
||||
+ uuid2Bossbars.put(nmsPlayer.getUUID(),targetBossbar);
|
||||
+ apiPlayer.showBossBar(targetBossbar);
|
||||
+ }
|
||||
+
|
||||
+ if (targetBossbar != null){
|
||||
+ updateMembar(targetBossbar,used,xmx);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static void updateMembar(@NotNull BossBar bar, long used, long xmx){
|
||||
+ double percent = Math.max(Math.min((float) used / xmx, 1.0F), 0.0F);
|
||||
+ bar.name(MiniMessage.miniMessage().deserialize(
|
||||
+ MembarConfig.memBarFormat,
|
||||
+ Placeholder.component("used", getMemoryComponent(used,xmx)),
|
||||
+ Placeholder.component("available",getMaxMemComponent(xmx))
|
||||
+ ));
|
||||
+ bar.color(barColorFromMemory(percent));
|
||||
+ bar.progress((float) percent);
|
||||
+ }
|
||||
+
|
||||
+ private static @NotNull Component getMaxMemComponent(double max){
|
||||
+ final BossBar.Color colorBukkit = BossBar.Color.GREEN;
|
||||
+ final String colorString = colorBukkit.name();
|
||||
+
|
||||
+ final String content = "<%s><text></%s>";
|
||||
+ final String replaced = String.format(content,colorString,colorString);
|
||||
+
|
||||
+ return MiniMessage.miniMessage().deserialize(replaced,Placeholder.parsed("text", String.format("%.2f", (double)max / (1024 * 1024))));
|
||||
+ }
|
||||
+
|
||||
+ private static @NotNull Component getMemoryComponent(long used,long max){
|
||||
+ final BossBar.Color colorBukkit = barColorFromMemory(Math.max(Math.min((float) used / max, 1.0F), 0.0F));
|
||||
+ final String colorString = colorBukkit.name();
|
||||
+
|
||||
+ final String content = "<%s><text></%s>";
|
||||
+ final String replaced = String.format(content,colorString,colorString);
|
||||
+
|
||||
+ return MiniMessage.miniMessage().deserialize(replaced,Placeholder.parsed("text", String.format("%.2f", (double)used / (1024 * 1024))));
|
||||
+ }
|
||||
+
|
||||
+ private static BossBar.Color barColorFromMemory(double memPercent){
|
||||
+ if (memPercent == -1){
|
||||
+ return BossBar.Color.valueOf(MembarConfig.memColors.get(3));
|
||||
+ }
|
||||
+
|
||||
+ if (memPercent <= 50){
|
||||
+ return BossBar.Color.valueOf(MembarConfig.memColors.getFirst());
|
||||
+ }
|
||||
+
|
||||
+ if (memPercent <= 70){
|
||||
+ return BossBar.Color.valueOf(MembarConfig.memColors.get(1));
|
||||
+ }
|
||||
+
|
||||
+ return BossBar.Color.valueOf(MembarConfig.memColors.get(2));
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 690d0f59daf8c4630c3d70b6fb690c2e1cedd402..8bd9baba560051e681277b8cea9d1374ea3ee825 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -856,6 +856,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@Override
|
||||
public void stopServer() {
|
||||
me.earthme.luminol.functions.GlobalServerTpsBar.cancelBarUpdateTask(); //Luminol - Tpsbar
|
||||
+ me.earthme.luminol.functions.GlobalServerMemoryBar.cancelBarUpdateTask(); //Luminol - Memory bar
|
||||
super.stopServer();
|
||||
//Util.shutdownExecutors(); // Paper - moved into super
|
||||
SkullBlockEntity.clear();
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 59a4937363a2404fe0b852b0ac851ef0c9c528ce..023ffc81f9363eb2fc7c3b3382c843b064c889e3 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -304,6 +304,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
||||
public @Nullable String clientBrandName = null; // Paper - Brand support
|
||||
public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event
|
||||
public volatile boolean isTpsBarVisible = false; //Luminol - Tps bar
|
||||
+ public volatile boolean isMemBarVisible = false; //Luminol - Memory bar
|
||||
// Paper start - rewrite chunk system
|
||||
private ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader;
|
||||
private final ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.ViewDistanceHolder viewDistanceHolder = new ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.ViewDistanceHolder();
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index b954a5a3d8c589a0261202f21f1430c8790e874a..77576c06ffc0a677b1bfb63d48d39fba2aa2050d 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -2396,6 +2396,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
//Luminol start - Tpsbar
|
||||
getHandle().isTpsBarVisible = data.getBoolean("tpsbarVisible");
|
||||
//Luminol end
|
||||
+ //Luminol start - Membar
|
||||
+ getHandle().isMemBarVisible = data.getBoolean("membarVisible");
|
||||
+ //Luminol end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2420,6 +2423,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
//Luminol start - Tpsbar
|
||||
data.putBoolean("tpsbarVisible",handle.isTpsBarVisible);
|
||||
//Luminol end
|
||||
+ //Luminol start - Membar
|
||||
+ data.putBoolean("membarVisible", handle.isMemBarVisible);
|
||||
+ //Luminol end
|
||||
// Paper start - persist for use in offline save data
|
||||
if (!nbttagcompound.contains("Paper")) {
|
||||
nbttagcompound.put("Paper", new CompoundTag());
|
||||
@@ -31,15 +31,16 @@ index 0000000000000000000000000000000000000000..c7e4724cc4ab8d911bcaf0106c098b26
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
index aa4b461bbb2c8c4753f7c9057bab1740de2c0284..1ff6c82925417932df856bf1e5866519327f018e 100644
|
||||
index 8098b1a447a7c054e15edc09d2fa50e48f73e926..b6a65bdddc8eaf64931d9aa3f4801dc8e128801b 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
@@ -143,7 +143,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||
@Override
|
||||
@@ -178,7 +178,8 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||
public void handleHello(ServerboundHelloPacket packet) {
|
||||
Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet", new Object[0]);
|
||||
- if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation && !this.iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation) Validate.validState(Player.isValidUsername(packet.name()), "Invalid characters in username", new Object[0]); // Paper - config username validation
|
||||
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation && !this.iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation && me.earthme.luminol.config.modules.misc.UsernameCheckConfig.enabled) Validate.validState(Player.isValidUsername(packet.name()), "Invalid characters in username", new Object[0]); // Paper - config username validation //Luminol - Add config for username check
|
||||
this.requestedUsername = packet.name();
|
||||
GameProfile gameprofile = this.server.getSingleplayerProfile();
|
||||
|
||||
// Paper start - Validate usernames
|
||||
- if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode()
|
||||
+ if (me.earthme.luminol.config.modules.misc.UsernameCheckConfig.enabled //Luminol - Add config for 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", new Object[0]);
|
||||
@@ -31,15 +31,15 @@ index 0000000000000000000000000000000000000000..502b93c7bda9e8577a1901a8777b7cf9
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 550fb11c64e3adb35bb7f78c53f0b5ae5ce9ff58..71151811c36c75ace1e41837123b320ae48a4b53 100644
|
||||
index 8bd9baba560051e681277b8cea9d1374ea3ee825..79b79a5d41dc3568ae6a3d7701e6ac6b91045e36 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -284,7 +284,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -300,7 +300,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
String proxyFlavor = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "Velocity" : "BungeeCord";
|
||||
String proxyLink = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "https://docs.papermc.io/velocity/security" : "http://www.spigotmc.org/wiki/firewall-guide/";
|
||||
// Paper end - Add Velocity IP Forwarding Support
|
||||
- if (!this.usesAuthentication()) {
|
||||
+ if (!this.usesAuthentication() && !me.earthme.luminol.config.modules.misc.OfflineModeWarningConfig.enabled) { //Luminol - Add config for offline mod warning
|
||||
+ if (!this.usesAuthentication() && me.earthme.luminol.config.modules.misc.OfflineModeWarningConfig.enabled) { //Luminol - Add config for offline mod warning
|
||||
DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
|
||||
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
|
||||
// Spigot start
|
||||
@@ -1,257 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sun, 10 Mar 2024 05:04:33 +0000
|
||||
Subject: [PATCH] Add a simple watchdog for tick regions
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/RegionizedServer.java b/src/main/java/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||
index fc3d332aa1c1d469cedfe2aaa7102dcd78e25642..1ae61bc6603dd3ac290e3ead20416f9c5b63ff02 100644
|
||||
--- a/src/main/java/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||
+++ b/src/main/java/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||
@@ -279,6 +279,7 @@ public final class RegionizedServer {
|
||||
*/
|
||||
|
||||
private void globalTick(final int tickCount) {
|
||||
+ me.earthme.luminol.utils.LuminolWatchDog.globalRegionHeartBeat(); //Luminol
|
||||
/*
|
||||
if (false) {
|
||||
io.papermc.paper.threadedregions.ThreadedTicketLevelPropagator.main(null);
|
||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/ThreadedRegionizer.java b/src/main/java/io/papermc/paper/threadedregions/ThreadedRegionizer.java
|
||||
index 531aa50f2c84e13358e8918bb0c15ea3cd036cb5..fd0053369eb68f0fd596d8acfba4a5247ef8105a 100644
|
||||
--- a/src/main/java/io/papermc/paper/threadedregions/ThreadedRegionizer.java
|
||||
+++ b/src/main/java/io/papermc/paper/threadedregions/ThreadedRegionizer.java
|
||||
@@ -167,6 +167,8 @@ public final class ThreadedRegionizer<R extends ThreadedRegionizer.ThreadedRegio
|
||||
if (removed != region) {
|
||||
throw new IllegalStateException("Expected to remove " + region + ", but removed " + removed);
|
||||
}
|
||||
+
|
||||
+ me.earthme.luminol.utils.LuminolWatchDog.onRegionDeath(region); //Luminol - Simple watchdog
|
||||
}
|
||||
|
||||
public int getSectionCoordinate(final int chunkCoordinate) {
|
||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/TickRegions.java b/src/main/java/io/papermc/paper/threadedregions/TickRegions.java
|
||||
index 2ad25dd345ab42125d456f2b9cf67d8c4515c8b7..78c50292fb25e8703e9c91db892f05456f07d72f 100644
|
||||
--- a/src/main/java/io/papermc/paper/threadedregions/TickRegions.java
|
||||
+++ b/src/main/java/io/papermc/paper/threadedregions/TickRegions.java
|
||||
@@ -402,6 +402,7 @@ public final class TickRegions implements ThreadedRegionizer.RegionCallbacks<Tic
|
||||
|
||||
@Override
|
||||
protected void tickRegion(final int tickCount, final long startTime, final long scheduledEnd) {
|
||||
+ me.earthme.luminol.utils.LuminolWatchDog.tickRegionHeartBeat(); //Luminol - Simple watchdog
|
||||
final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); // Folia - profiler
|
||||
profiler.startTick(); try { // Folia - profiler
|
||||
MinecraftServer.getServer().tickServer(startTime, scheduledEnd, TimeUnit.MILLISECONDS.toMillis(10L), this.region);
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/WatchdogConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/WatchdogConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..71d80b401470db777a86274d32f178bb2aa023d5
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/WatchdogConfig.java
|
||||
@@ -0,0 +1,27 @@
|
||||
+package me.earthme.luminol.config.modules.misc;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.HotReloadUnsupported;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class WatchdogConfig implements IConfigModule {
|
||||
+
|
||||
+ @HotReloadUnsupported
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+ @ConfigInfo(baseName = "warn_period_ticks")
|
||||
+ public static long warnPeriodTicks = 5 * 20;
|
||||
+ @ConfigInfo(baseName = "timeout_ticks")
|
||||
+ public static long timeOutTicks = 30 * 20;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "watchdog";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/utils/LuminolWatchDog.java b/src/main/java/me/earthme/luminol/utils/LuminolWatchDog.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..6b4368cdf9762ad981345fef0f26cd008a4236ee
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/utils/LuminolWatchDog.java
|
||||
@@ -0,0 +1,161 @@
|
||||
+package me.earthme.luminol.utils;
|
||||
+
|
||||
+import com.google.common.collect.Maps;
|
||||
+import io.papermc.paper.threadedregions.ThreadedRegionizer;
|
||||
+import io.papermc.paper.threadedregions.TickRegionScheduler;
|
||||
+import io.papermc.paper.util.StacktraceDeobfuscator;
|
||||
+import me.earthme.luminol.config.modules.misc.WatchdogConfig;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import org.apache.commons.lang3.tuple.Pair;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+import org.slf4j.Logger;
|
||||
+
|
||||
+import java.lang.management.ManagementFactory;
|
||||
+import java.lang.management.ThreadInfo;
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.List;
|
||||
+import java.util.Map;
|
||||
+import java.util.concurrent.CompletableFuture;
|
||||
+import java.util.concurrent.Executor;
|
||||
+import java.util.concurrent.TimeUnit;
|
||||
+
|
||||
+public class LuminolWatchDog {
|
||||
+ private static final Object keepaliveDataLock = new Object();
|
||||
+ private static Pair<Thread,Long> globalRegionLastKeepalive = null;
|
||||
+ private static final Map<Thread,Pair<ThreadedRegionizer.ThreadedRegion<?,?>,Long>> otherTickRegionKeepalive = Maps.newHashMap();
|
||||
+ private static final Executor checkTimer = CompletableFuture.delayedExecutor(50, TimeUnit.MILLISECONDS);
|
||||
+ private static final Logger logger = MinecraftServer.LOGGER;
|
||||
+ private static int tickCount = 0;
|
||||
+ private static boolean runScheduleNext = true;
|
||||
+
|
||||
+ public static void boot(){
|
||||
+ runCheck();
|
||||
+ }
|
||||
+
|
||||
+ private static void scheduleCheck(){
|
||||
+ checkTimer.execute(LuminolWatchDog::runCheck);
|
||||
+ }
|
||||
+
|
||||
+ private static void runCheck(){
|
||||
+ try {
|
||||
+ if (MinecraftServer.getServer().isStopped() || !runScheduleNext){
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ tickCount++;
|
||||
+
|
||||
+ final List<Pair<Thread,Long>> threadsToWarn = new ArrayList<>();
|
||||
+ final long currentTimeNano = System.nanoTime();
|
||||
+ boolean shouldStopServer = false;
|
||||
+
|
||||
+ synchronized (keepaliveDataLock){
|
||||
+ if (globalRegionLastKeepalive != null){
|
||||
+ final Thread lastGlobalRegionThread = globalRegionLastKeepalive.getLeft();
|
||||
+ final long lastTicked = globalRegionLastKeepalive.getRight();
|
||||
+
|
||||
+ final long timeEscaped = currentTimeNano - lastTicked;
|
||||
+
|
||||
+ if (timeEscaped >= WatchdogConfig.warnPeriodTicks * 50 * 1000 * 1000){
|
||||
+ threadsToWarn.add(Pair.of(lastGlobalRegionThread,timeEscaped));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ for(Pair<Thread,Long> warnInfo : threadsToWarn){
|
||||
+ final Thread targetThread = warnInfo.getLeft();
|
||||
+ final long timeEscaped = warnInfo.getRight();
|
||||
+
|
||||
+ final ThreadedRegionizer.ThreadedRegion<?,?> targetRegion;
|
||||
+
|
||||
+ synchronized (keepaliveDataLock){
|
||||
+ targetRegion = otherTickRegionKeepalive.get(targetThread).getLeft();
|
||||
+ }
|
||||
+
|
||||
+ if (tickCount % WatchdogConfig.warnPeriodTicks == 0){
|
||||
+ dumpSingleRegion(targetThread,targetRegion,timeEscaped);
|
||||
+ }
|
||||
+
|
||||
+ if (timeEscaped > WatchdogConfig.timeOutTicks * 50 * 1000 * 1000){
|
||||
+ shouldStopServer = true;
|
||||
+ runScheduleNext = false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (shouldStopServer){
|
||||
+ MinecraftServer.getServer().stopServer();
|
||||
+ }
|
||||
+ }
|
||||
+ }finally {
|
||||
+ if (runScheduleNext){
|
||||
+ scheduleCheck();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static void dumpSingleRegion(@NotNull Thread thread, @Nullable ThreadedRegionizer.ThreadedRegion<?,?> region,long timeEscaped){
|
||||
+ final StringBuilder messageBuilder = new StringBuilder();
|
||||
+ messageBuilder.append("====================================").append("\n");
|
||||
+ messageBuilder.append("There is a single region that has no responding in " + TimeUnit.NANOSECONDS.toSeconds(timeEscaped) + " seconds!").append("\n");
|
||||
+ messageBuilder.append("If you believe this is a bug,please send it to github issue after checking your plugins!").append("\n");
|
||||
+ messageBuilder.append("Tick Region: ").append(region == null ? "Global Region" : "ChunkX(Center): " + region.getCenterChunk().x + " ChunkZ(Center): " + region.getCenterChunk().z).append("\n");
|
||||
+ messageBuilder.append("Thread Name: ").append(thread.getName()).append("\n");
|
||||
+ messageBuilder.append("Thread Id: ").append(thread.getId()).append("\n");
|
||||
+
|
||||
+ final ThreadInfo targetThreadInfo = ManagementFactory.getThreadMXBean().getThreadInfo(thread.getId());
|
||||
+
|
||||
+ messageBuilder.append("Is Suspend: ").append(targetThreadInfo.isSuspended()).append("\n");
|
||||
+ messageBuilder.append("Thread State: ").append(targetThreadInfo.getThreadState()).append("\n");
|
||||
+ messageBuilder.append("Thread Priority: ").append(targetThreadInfo.getPriority()).append("\n");
|
||||
+ messageBuilder.append("Thread Stack Trace:").append("\n");
|
||||
+
|
||||
+ for (StackTraceElement stackTraceElement : StacktraceDeobfuscator.INSTANCE.deobfuscateStacktrace(thread.getStackTrace())){
|
||||
+ messageBuilder.append("\t\t").append(stackTraceElement).append("\n");
|
||||
+ }
|
||||
+
|
||||
+ messageBuilder.append("\n");
|
||||
+ messageBuilder.append("====================================");
|
||||
+
|
||||
+ logger.error(messageBuilder.toString());
|
||||
+ }
|
||||
+
|
||||
+ public static void globalRegionHeartBeat(){
|
||||
+ if (!WatchdogConfig.enabled){
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ synchronized (keepaliveDataLock){
|
||||
+ globalRegionLastKeepalive = Pair.of(Thread.currentThread(),System.nanoTime());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void tickRegionHeartBeat(){
|
||||
+ if (!WatchdogConfig.enabled){
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ final ThreadedRegionizer.ThreadedRegion<?,?> currentRegion = TickRegionScheduler.getCurrentRegion();
|
||||
+
|
||||
+ if (currentRegion == null) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ synchronized (keepaliveDataLock){
|
||||
+ if (!otherTickRegionKeepalive.containsKey(Thread.currentThread())){
|
||||
+ otherTickRegionKeepalive.put(Thread.currentThread(),Pair.of(currentRegion,System.nanoTime()));
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ otherTickRegionKeepalive.replace(Thread.currentThread(),Pair.of(currentRegion,System.nanoTime()));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void onRegionDeath(ThreadedRegionizer.ThreadedRegion<?,?> currentRegion){
|
||||
+ if (!WatchdogConfig.enabled){
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ synchronized (keepaliveDataLock){
|
||||
+ otherTickRegionKeepalive.remove(Thread.currentThread());
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 0d756dd5181a2444175184227bef648d07c17236..59b1da130e519cbe06ed5eedf9e4dc881e45ba36 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1222,6 +1222,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
this.statusIcon = (ServerStatus.Favicon) this.loadStatusIcon().orElse(null); // CraftBukkit - decompile error
|
||||
this.status = this.buildServerStatus();
|
||||
|
||||
+ me.earthme.luminol.utils.LuminolWatchDog.boot(); //Luminol - Simple watchdog
|
||||
+
|
||||
// Folia start - region threading
|
||||
if (true) {
|
||||
io.papermc.paper.threadedregions.RegionizedServer.getInstance().init(); // Folia - region threading - only after loading worlds
|
||||
@@ -31,15 +31,15 @@ index 0000000000000000000000000000000000000000..83176a8a7e993b51a0663b0f76161884
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||||
index ba12919c3f9aec34a9e64993b143ae92be5eb172..ba983d557ae16b3fbb7d0ea6ff67666a809d2e99 100644
|
||||
index 300929a406905f5ff1ede664d5b99fb0938d4d2e..7c82730e9a66f9b44dd559d7b8da511f9c5f8ca8 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||||
@@ -38,7 +38,7 @@ public class SignedMessageChain {
|
||||
throw new SignedMessageChain.DecodeException(Component.translatable("chat.disabled.chain_broken"), false); // Paper - diff on change (if disconnects, need a new kick event cause)
|
||||
} else if (playerPublicKey.data().hasExpired()) {
|
||||
throw new SignedMessageChain.DecodeException(Component.translatable("chat.disabled.expiredProfileKey"), false, org.bukkit.event.player.PlayerKickEvent.Cause.EXPIRED_PROFILE_PUBLIC_KEY); // Paper - kick event causes
|
||||
- } else if (body.timeStamp().isBefore(this.lastTimeStamp)) {
|
||||
+ } else if (me.earthme.luminol.config.modules.misc.InorderChatConfig.enabled && body.timeStamp().isBefore(this.lastTimeStamp)) { // Luminol - Add config for out-of-order chat checks
|
||||
throw new SignedMessageChain.DecodeException(Component.translatable("multiplayer.disconnect.out_of_order_chat"), true, org.bukkit.event.player.PlayerKickEvent.Cause.OUT_OF_ORDER_CHAT); // Paper - kick event causes
|
||||
} else {
|
||||
this.lastTimeStamp = body.timeStamp();
|
||||
@@ -45,7 +45,7 @@ public class SignedMessageChain {
|
||||
SignedMessageLink signedMessageLink = SignedMessageChain.this.nextLink;
|
||||
if (signedMessageLink == null) {
|
||||
throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.CHAIN_BROKEN);
|
||||
- } else if (body.timeStamp().isBefore(SignedMessageChain.this.lastTimeStamp)) {
|
||||
+ } else if (me.earthme.luminol.config.modules.misc.InorderChatConfig.enabled && body.timeStamp().isBefore(SignedMessageChain.this.lastTimeStamp)) { // Luminol - Add config for out-of-order chat checks
|
||||
this.setChainBroken();
|
||||
throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.OUT_OF_ORDER_CHAT, org.bukkit.event.player.PlayerKickEvent.Cause.OUT_OF_ORDER_CHAT); // Paper - kick event causes
|
||||
} else {
|
||||
@@ -1,51 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Mon, 25 Mar 2024 13:16:04 +0000
|
||||
Subject: [PATCH] Add config for incorrect tripwire updating fixing
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/IncorrectTripwireFixConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/IncorrectTripwireFixConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..79ce93a1e97f176c7b0e5b00d7f0880f0d157d03
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/IncorrectTripwireFixConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.fixes;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class IncorrectTripwireFixConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.FIXES;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "allow_update_incorrect_trip_wire";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
|
||||
index 8bf94fcf5c46ffe6d90f8431338b768ef1a2dd61..25e069bd660720232737031fe1630765cce9a1b1 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
|
||||
@@ -201,8 +201,13 @@ public class TripWireHookBlock extends Block {
|
||||
BlockState iblockdata4 = aiblockdata[l];
|
||||
|
||||
if (iblockdata4 != null) {
|
||||
- if (world.getBlockState(blockposition2).is(Blocks.TRIPWIRE)) { // Paper - Fix tripwire disarming not working as intended
|
||||
+ if (me.earthme.luminol.config.modules.fixes.IncorrectTripwireFixConfig.enabled || world.getBlockState(blockposition2).is(Blocks.TRIPWIRE)) { // Paper - Fix tripwire disarming not working as intended //Luminol - Add config for this
|
||||
world.setBlock(blockposition2, (BlockState) iblockdata4.trySetValue(TripWireHookBlock.ATTACHED, flag4), 3);
|
||||
+ //Luminol start - Add config for incorrect tripwire updating
|
||||
+ if (me.earthme.luminol.config.modules.fixes.IncorrectTripwireFixConfig.enabled){
|
||||
+ world.getBlockState(blockposition2).isAir();
|
||||
+ }
|
||||
+ //Luminol end
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stabrinai <wujiaxin752@outlook.com>
|
||||
Date: Sun, 30 Jun 2024 20:46:42 +0800
|
||||
Subject: [PATCH] Add config to verify signature only in online-mode
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/PublickeyVerifyConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/PublickeyVerifyConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e45ce3abf49684c911678abcefd69586246cc0e3
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/PublickeyVerifyConfig.java
|
||||
@@ -0,0 +1,21 @@
|
||||
+package me.earthme.luminol.config.modules.misc;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class PublickeyVerifyConfig implements IConfigModule {
|
||||
+
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "verify_publickey_only_in_online_mode";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/player/ProfilePublicKey.java b/src/main/java/net/minecraft/world/entity/player/ProfilePublicKey.java
|
||||
index 2fa51c3a70f43cd23b8f494fc643d66cecfda7d2..2c541f300ea1657e2d75d0eeb36809aaf437b205 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/player/ProfilePublicKey.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/player/ProfilePublicKey.java
|
||||
@@ -9,12 +9,15 @@ import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
+
|
||||
+import me.earthme.luminol.config.modules.misc.PublickeyVerifyConfig;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.ThrowingComponent;
|
||||
import net.minecraft.util.Crypt;
|
||||
import net.minecraft.util.ExtraCodecs;
|
||||
import net.minecraft.util.SignatureValidator;
|
||||
+import org.bukkit.Bukkit;
|
||||
|
||||
public record ProfilePublicKey(ProfilePublicKey.Data data) {
|
||||
public static final Component EXPIRED_PROFILE_PUBLIC_KEY = Component.translatable("multiplayer.disconnect.expired_public_key");
|
||||
@@ -23,7 +26,7 @@ public record ProfilePublicKey(ProfilePublicKey.Data data) {
|
||||
public static final Codec<ProfilePublicKey> TRUSTED_CODEC = ProfilePublicKey.Data.CODEC.xmap(ProfilePublicKey::new, ProfilePublicKey::data);
|
||||
|
||||
public static ProfilePublicKey createValidated(SignatureValidator servicesSignatureVerifier, UUID playerUuid, ProfilePublicKey.Data publicKeyData) throws ProfilePublicKey.ValidationException {
|
||||
- if (!publicKeyData.validateSignature(servicesSignatureVerifier, playerUuid)) {
|
||||
+ if ((!PublickeyVerifyConfig.enabled || Bukkit.getServer().getOnlineMode()) && !publicKeyData.validateSignature(servicesSignatureVerifier, playerUuid)) { // Luminol - Verify signature only in online-mode
|
||||
throw new ProfilePublicKey.ValidationException(INVALID_SIGNATURE, org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PUBLIC_KEY_SIGNATURE); // Paper - kick event causes
|
||||
} else {
|
||||
return new ProfilePublicKey(publicKeyData);
|
||||
@@ -0,0 +1,45 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 7 Aug 2024 14:27:24 +0800
|
||||
Subject: [PATCH] Add config to disable entity tick catchers
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/experiment/DisableEntityCatchConfig.java b/src/main/java/me/earthme/luminol/config/modules/experiment/DisableEntityCatchConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0fd71151a85dd87c2294033e2e7512ac365caa62
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/experiment/DisableEntityCatchConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.experiment;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class DisableEntityCatchConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.EXPERIMENT;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "disable_entity_exception_catchers";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 4bb14874912557008fab7361754f2d2eb98fc5aa..38725e383cce13e372dacfa59f8668235ff6e3a5 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -1468,7 +1468,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
try {
|
||||
tickConsumer.accept(entity);
|
||||
} catch (Throwable throwable) {
|
||||
- if (throwable instanceof ThreadDeath) throw throwable; // Paper
|
||||
+ if (throwable instanceof ThreadDeath || me.earthme.luminol.config.modules.experiment.DisableEntityCatchConfig.enabled) throw throwable; // Paper // Luminol
|
||||
// Paper start - Prevent block entity and entity crashes
|
||||
final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level().getWorld().getName(), entity.getX(), entity.getY(), entity.getZ());
|
||||
MinecraftServer.LOGGER.error(msg, throwable);
|
||||
@@ -1,77 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 07:41:47 +0000
|
||||
Subject: [PATCH] Io_uring channel type support
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 66c34f883a93dd86fcac8029cce63ffe7340c89b..66cb23bce8bf0a96867144874643f771f7440034 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -35,6 +35,7 @@ dependencies {
|
||||
log4jPlugins.annotationProcessorConfigurationName("org.apache.logging.log4j:log4j-core:2.19.0") // Paper - Needed to generate meta for our Log4j plugins
|
||||
runtimeOnly(log4jPlugins.output)
|
||||
alsoShade(log4jPlugins.output)
|
||||
+ implementation("io.netty.incubator:netty-incubator-transport-native-io_uring:0.0.21.Final:linux-x86_64") //Luminol - io_uring Libraries
|
||||
implementation("io.netty:netty-codec-haproxy:4.1.97.Final") // Paper - Add support for proxy protocol
|
||||
// Paper end
|
||||
implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/IOUringSupportConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/IOUringSupportConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..f3090b6e11d82d02528c7afd358ef4db61707092
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/IOUringSupportConfig.java
|
||||
@@ -0,0 +1,22 @@
|
||||
+package me.earthme.luminol.config.modules.misc;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.HotReloadUnsupported;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class IOUringSupportConfig implements IConfigModule {
|
||||
+ @HotReloadUnsupported
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "io_uring_support";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
|
||||
index 6e95017f4c36208abdf344e3b7d55efe2d5b4e10..bf87a55d78155ea5c303ec28d6a0154e80d7fce3 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
|
||||
@@ -73,6 +73,10 @@ public class ServerConnectionListener {
|
||||
}
|
||||
// Paper end - prevent blocking on adding a new connection while the server is ticking
|
||||
|
||||
+ //Luminol start - io_uring support
|
||||
+ public static final Supplier<io.netty.incubator.channel.uring.IOUringEventLoopGroup> SERVER_IO_URING_WORKER_GROUP = Suppliers.memoize(() -> new io.netty.incubator.channel.uring.IOUringEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty IO_URING Server IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()));
|
||||
+ //Luminol end
|
||||
+
|
||||
public ServerConnectionListener(MinecraftServer server) {
|
||||
this.server = server;
|
||||
this.running = true;
|
||||
@@ -90,7 +94,14 @@ public class ServerConnectionListener {
|
||||
Class oclass;
|
||||
EventLoopGroup eventloopgroup;
|
||||
|
||||
- if (Epoll.isAvailable() && this.server.isEpollEnabled()) {
|
||||
+ //Luminol start - io_uring support
|
||||
+ if (io.netty.incubator.channel.uring.IOUring.isAvailable() && me.earthme.luminol.config.modules.misc.IOUringSupportConfig.enabled){
|
||||
+ eventloopgroup = SERVER_IO_URING_WORKER_GROUP.get();
|
||||
+ oclass = io.netty.incubator.channel.uring.IOUringServerSocketChannel.class;
|
||||
+ ServerConnectionListener.LOGGER.info("Using io_uring channel type");
|
||||
+ }
|
||||
+ else if (Epoll.isAvailable() && this.server.isEpollEnabled()) {
|
||||
+ //Luminol end
|
||||
// Paper start - Unix domain socket support
|
||||
if (address instanceof io.netty.channel.unix.DomainSocketAddress) {
|
||||
oclass = io.netty.channel.epoll.EpollServerDomainSocketChannel.class;
|
||||
106
patches/server/0016-Add-config-to-disable-async-catchers.patch
Normal file
106
patches/server/0016-Add-config-to-disable-async-catchers.patch
Normal file
@@ -0,0 +1,106 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 7 Aug 2024 14:34:15 +0800
|
||||
Subject: [PATCH] Add config to disable async catchers
|
||||
|
||||
|
||||
diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java b/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java
|
||||
index 7d626bec6f0a4497026de6c0311e27cf95cfd757..2760e66046a37327d279a5bcdfb56a5b073b82a5 100644
|
||||
--- a/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java
|
||||
+++ b/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java
|
||||
@@ -26,49 +26,49 @@ public class TickThread extends Thread {
|
||||
*/
|
||||
@Deprecated
|
||||
public static void ensureTickThread(final String reason) {
|
||||
- if (!isTickThread()) {
|
||||
+ if (!isTickThread() && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Luminol
|
||||
LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||
throw new IllegalStateException(reason);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ensureTickThread(final Level world, final BlockPos pos, final String reason) {
|
||||
- if (!isTickThreadFor(world, pos)) {
|
||||
+ if (!isTickThreadFor(world, pos) && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Luminol
|
||||
LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||
throw new IllegalStateException(reason);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ensureTickThread(final Level world, final ChunkPos pos, final String reason) {
|
||||
- if (!isTickThreadFor(world, pos)) {
|
||||
+ if (!isTickThreadFor(world, pos) && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Luminol
|
||||
LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||
throw new IllegalStateException(reason);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ensureTickThread(final Level world, final int chunkX, final int chunkZ, final String reason) {
|
||||
- if (!isTickThreadFor(world, chunkX, chunkZ)) {
|
||||
+ if (!isTickThreadFor(world, chunkX, chunkZ) && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Luminol
|
||||
LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||
throw new IllegalStateException(reason);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ensureTickThread(final Entity entity, final String reason) {
|
||||
- if (!isTickThreadFor(entity)) {
|
||||
+ if (!isTickThreadFor(entity) && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Luminol
|
||||
LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||
throw new IllegalStateException(reason);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ensureTickThread(final Level world, final AABB aabb, final String reason) {
|
||||
- if (!isTickThreadFor(world, aabb)) {
|
||||
+ if (!isTickThreadFor(world, aabb) && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Luminol
|
||||
LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||
throw new IllegalStateException(reason);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ensureTickThread(final Level world, final double blockX, final double blockZ, final String reason) {
|
||||
- if (!isTickThreadFor(world, blockX, blockZ)) {
|
||||
+ if (!isTickThreadFor(world, blockX, blockZ) && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Luminol
|
||||
LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||
throw new IllegalStateException(reason);
|
||||
}
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/experiment/DisableAsyncCatcherConfig.java b/src/main/java/me/earthme/luminol/config/modules/experiment/DisableAsyncCatcherConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..61f653eeca366672ded88c491cf5c59e546e7301
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/experiment/DisableAsyncCatcherConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.experiment;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class DisableAsyncCatcherConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.EXPERIMENT;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "disable_async_catchers";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/spigotmc/AsyncCatcher.java b/src/main/java/org/spigotmc/AsyncCatcher.java
|
||||
index 1f23e775eba1c34e01145bd91b0ce26fed6ca9de..3e0dbf379fc1b5baa27936cb902b3c54f9b0f4c9 100644
|
||||
--- a/src/main/java/org/spigotmc/AsyncCatcher.java
|
||||
+++ b/src/main/java/org/spigotmc/AsyncCatcher.java
|
||||
@@ -9,7 +9,7 @@ public class AsyncCatcher
|
||||
|
||||
public static void catchOp(String reason)
|
||||
{
|
||||
- if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThread()) // Paper // Paper - rewrite chunk system
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThread() && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) // Paper // Paper - rewrite chunk system // Luminol
|
||||
{
|
||||
MinecraftServer.LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable()); // Paper
|
||||
throw new IllegalStateException( "Asynchronous " + reason + "!" );
|
||||
@@ -1,57 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 06:30:03 +0000
|
||||
Subject: [PATCH] Try fixing folia spector teleportation
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaSpectorTeleportationFixConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaSpectorTeleportationFixConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..8487799cdfb776eaca33b57f7c99ae3aeadb890d
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaSpectorTeleportationFixConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.fixes;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class FoliaSpectorTeleportationFixConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean fixSpectorTeleportFolia = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.FIXES;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "folia.fix_spector_teleportation";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 318cb1e98a3d73b7893f07c9f0db3adab801b67e..9cbf17436b4cf52aae374767aafe79ea4f60c3ce 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -17,6 +17,8 @@ import java.util.OptionalInt;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.earthme.luminol.config.modules.fixes.FoliaSpectorTeleportationFixConfig;
|
||||
import net.minecraft.BlockUtil;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.CrashReport;
|
||||
@@ -842,6 +844,11 @@ public class ServerPlayer extends Player {
|
||||
}
|
||||
|
||||
Entity entity = this.getCamera();
|
||||
+ //Luminol start - Fix folia spector teleportation
|
||||
+ if (!io.papermc.paper.util.TickThread.isTickThreadFor(entity) && FoliaSpectorTeleportationFixConfig.fixSpectorTeleportFolia){
|
||||
+ this.setCamera(this);
|
||||
+ }
|
||||
+ //Luminol end
|
||||
|
||||
if (entity != this) {
|
||||
if (entity.isAlive()) {
|
||||
@@ -0,0 +1,45 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sat, 31 Aug 2024 10:56:58 +0800
|
||||
Subject: [PATCH] Add experiment config for command block command execution
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/experiment/CommandBlockConfig.java b/src/main/java/me/earthme/luminol/config/modules/experiment/CommandBlockConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..3eafc59cc015569d3da8b1d8c4bfd046af17e0be
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/experiment/CommandBlockConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.experiment;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class CommandBlockConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enable")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.EXPERIMENT;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "force_enable_command_block_execution";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
|
||||
index b8a571fcc44f67ac8f6089e039a8620bf6c40603..c973535eba031f102c6cae8f9b75547ba3a95376 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
|
||||
@@ -117,7 +117,7 @@ public abstract class BaseCommandBlock implements CommandSource {
|
||||
}
|
||||
|
||||
public boolean performCommand(Level world) {
|
||||
- if (true) return false; // Folia - region threading
|
||||
+ if (!me.earthme.luminol.config.modules.experiment.CommandBlockConfig.enabled) return false; // Folia - region threading // Luminol
|
||||
if (!world.isClientSide && world.getGameTime() != this.lastExecution) {
|
||||
if ("Searge".equalsIgnoreCase(this.command)) {
|
||||
this.lastOutput = Component.literal("#itzlipofutzli");
|
||||
45
patches/server/0018-Add-config-for-watchdog-timeout.patch
Normal file
45
patches/server/0018-Add-config-for-watchdog-timeout.patch
Normal file
@@ -0,0 +1,45 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Tue, 31 Dec 2024 21:23:37 +0800
|
||||
Subject: [PATCH] Add config for watchdog timeout
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/FoliaWatchdogThread.java b/src/main/java/io/papermc/paper/threadedregions/FoliaWatchdogThread.java
|
||||
index 258d82ab2c78482e1561343e8e1f81fc33f1895e..967107c0f4a18a29877883ccddb4d7962f4b5788 100644
|
||||
--- a/src/main/java/io/papermc/paper/threadedregions/FoliaWatchdogThread.java
|
||||
+++ b/src/main/java/io/papermc/paper/threadedregions/FoliaWatchdogThread.java
|
||||
@@ -65,7 +65,7 @@ public final class FoliaWatchdogThread extends Thread {
|
||||
|
||||
for (final RunningTick tick : ticks) {
|
||||
final long elapsed = now - tick.lastPrint;
|
||||
- if (elapsed <= TimeUnit.SECONDS.toNanos(5L)) {
|
||||
+ if (elapsed <= TimeUnit.MILLISECONDS.toNanos(me.earthme.luminol.config.modules.misc.FoliaWatchogConfig.tickRegionTimeOutMs)) { // Luminol - Add config for watchdog timeout
|
||||
continue;
|
||||
}
|
||||
tick.lastPrint = now;
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/FoliaWatchogConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/FoliaWatchogConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..de58b5bf9dedf35bc56a9211d0769b988704a7fe
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/FoliaWatchogConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.misc;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class FoliaWatchogConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "tick_region_time_out_ms")
|
||||
+ public static int tickRegionTimeOutMs = 5000;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "folia_watchdog";
|
||||
+ }
|
||||
+}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,67 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 06:30:03 +0000
|
||||
Subject: [PATCH] Try fixing folia spector teleportation
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaSpectorTeleportationFixConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaSpectorTeleportationFixConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..01f8c6ff3662569be5a4ff998bcd4fbbcb555105
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaSpectorTeleportationFixConfig.java
|
||||
@@ -0,0 +1,25 @@
|
||||
+package me.earthme.luminol.config.modules.fixes;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class FoliaSpectorTeleportationFixConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled", comments =
|
||||
+ """
|
||||
+ The teleportation of spector players would call absMoveTo directly.\s
|
||||
+ And when the camera teleported to another region,this would call absMoveTo\s
|
||||
+ to let the spector player move to another region without any checks, which \s
|
||||
+ would trigger the async catcher and crash the server""")
|
||||
+ public static boolean fixSpectorTeleportFolia = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.FIXES;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "folia.fix_spector_teleportation";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 023ffc81f9363eb2fc7c3b3382c843b064c889e3..d57fd6e4aacb611526a741fbd98165f124b7b8ef 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -929,9 +929,24 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
||||
}
|
||||
|
||||
Entity entity = this.getCamera();
|
||||
+ //Luminol start - Fix folia spector teleportation
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(entity) && me.earthme.luminol.config.modules.fixes.FoliaSpectorTeleportationFixConfig.fixSpectorTeleportFolia){
|
||||
+ this.setCamera(this);
|
||||
+ }
|
||||
+ //Luminol end
|
||||
|
||||
if (entity != this) {
|
||||
- if (entity.isAlive()) {
|
||||
+ // Luminol start - Fix folia spector teleportation
|
||||
+ var flag = false;
|
||||
+ var cameraPos = entity.blockPosition();
|
||||
+ var cameraLevel = entity.level();
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(cameraLevel, cameraPos) && me.earthme.luminol.config.modules.fixes.FoliaSpectorTeleportationFixConfig.fixSpectorTeleportFolia){
|
||||
+ this.setCamera(this);
|
||||
+ flag = true;
|
||||
+ }
|
||||
+ // Luminol end
|
||||
+
|
||||
+ if (entity.isAlive() && !flag) { // Luminol - Fix folia spector teleportation
|
||||
this.absMoveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot());
|
||||
this.serverLevel().getChunkSource().move(this);
|
||||
if (this.wantsToStopRiding()) {
|
||||
@@ -6,10 +6,10 @@ Subject: [PATCH] Teleport async if entity was moving to another region at once
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaEntityMovingFixConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaEntityMovingFixConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..73d99a105a18231901e691922b0c283adae0cc79
|
||||
index 0000000000000000000000000000000000000000..0e51d465db3554ac80d00c6b85cc1f013f3949ba
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaEntityMovingFixConfig.java
|
||||
@@ -0,0 +1,22 @@
|
||||
@@ -0,0 +1,28 @@
|
||||
+package me.earthme.luminol.config.modules.fixes;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
@@ -17,7 +17,13 @@ index 0000000000000000000000000000000000000000..73d99a105a18231901e691922b0c283a
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class FoliaEntityMovingFixConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ @ConfigInfo(baseName = "enabled", comments =
|
||||
+ """
|
||||
+ A simple fix of a issue on folia\s
|
||||
+ (Some times the entity would\s
|
||||
+ have a large moment that cross the\s
|
||||
+ different tick regions and it would\s
|
||||
+ make the server crashed) but sometimes it might doesn't work""")
|
||||
+ public static boolean enabled = false;
|
||||
+ @ConfigInfo(baseName = "warn_on_detected")
|
||||
+ public static boolean warnOnDetected = true;
|
||||
@@ -33,27 +39,10 @@ index 0000000000000000000000000000000000000000..73d99a105a18231901e691922b0c283a
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 9bbfac91f97331b1b558264c867b7e00185291f2..dfb1b8c3af93bfcddb976c003c6ac2d52afc41c6 100644
|
||||
index 537fc5c169ab2e519277b95d456aab51b5b7fbb5..25a5f36ff19ff3f9cea051a1a6bf671b6288b799 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -7,6 +7,7 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.collect.UnmodifiableIterator;
|
||||
import com.mojang.logging.LogUtils;
|
||||
+import io.papermc.paper.util.TickThread;
|
||||
import it.unimi.dsi.fastutil.objects.Object2DoubleArrayMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2DoubleMap;
|
||||
import java.util.Arrays;
|
||||
@@ -24,6 +25,8 @@ import java.util.function.BiConsumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.earthme.luminol.config.modules.fixes.FoliaEntityMovingFixConfig;
|
||||
import net.minecraft.BlockUtil;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.CrashReportCategory;
|
||||
@@ -1086,10 +1089,40 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -1125,6 +1125,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
// Paper end - detailed watchdog information
|
||||
|
||||
@@ -64,15 +53,18 @@ index 9bbfac91f97331b1b558264c867b7e00185291f2..dfb1b8c3af93bfcddb976c003c6ac2d5
|
||||
public void move(MoverType movementType, Vec3 movement) {
|
||||
final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity
|
||||
// Paper start - detailed watchdog information
|
||||
io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main");
|
||||
@@ -1135,6 +1139,32 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
this.moveStartZ = this.getZ();
|
||||
this.moveVector = movement;
|
||||
}
|
||||
+ //Luminol start - Fix high position moving
|
||||
+ if (me.earthme.luminol.config.modules.fixes.FoliaEntityMovingFixConfig.enabled && TickThread.isTickThread()){ //Except the threads because it may be called by the chunk system worker thread
|
||||
+ if (this.preventMoving){
|
||||
+ if (me.earthme.luminol.config.modules.fixes.FoliaEntityMovingFixConfig.enabled && ca.spottedleaf.moonrise.common.util.TickThread.isTickThread()){ //Except the threads because it may be called by the chunk system worker thread
|
||||
+ var finalPosition = movement.add(this.position);
|
||||
+ if (this.preventMoving || Double.isNaN(finalPosition.x) || Double.isNaN(finalPosition.y) || Double.isNaN(finalPosition.z)){
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ var finalPosition = movement.add(this.position);
|
||||
+ if (!TickThread.isTickThreadFor(((ServerLevel) this.level),finalPosition)){
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(((ServerLevel) this.level),finalPosition)){
|
||||
+ this.preventMoving = true;
|
||||
+ this.teleportAsync(
|
||||
+ (ServerLevel) this.level(),
|
||||
@@ -84,13 +76,13 @@ index 9bbfac91f97331b1b558264c867b7e00185291f2..dfb1b8c3af93bfcddb976c003c6ac2d5
|
||||
+ this.preventMoving = false;
|
||||
+ }
|
||||
+ );
|
||||
+ if (FoliaEntityMovingFixConfig.warnOnDetected){
|
||||
+ if (me.earthme.luminol.config.modules.fixes.FoliaEntityMovingFixConfig.warnOnDetected){
|
||||
+ MinecraftServer.LOGGER.warn("Entity {} with entityId {} has tried moving to another region!",this.type.getCategory().getName(),this.getId());
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ //Luminol end
|
||||
synchronized (this.posLock) {
|
||||
this.moveStartX = this.getX();
|
||||
this.moveStartY = this.getY();
|
||||
try {
|
||||
// Paper end - detailed watchdog information
|
||||
if (this.noPhysics) {
|
||||
@@ -1,50 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 20:25:38 +0800
|
||||
Subject: [PATCH] Kaiiju Vanilla end portal teleportation
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 09cdd28dcb2357ba3d7be316b7ca94dc93ac5dd0..d955a555d260d39812b84eb5319db619ec0f8d28 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -4195,12 +4195,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
targetPos, 16, // load 16 blocks to be safe from block physics
|
||||
ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.HIGH,
|
||||
(chunks) -> {
|
||||
- ServerLevel.makeObsidianPlatform(destination, null, targetPos);
|
||||
+ //ServerLevel.makeObsidianPlatform(destination, null, targetPos); // Kaiiju - Vanilla end teleportation - moved down
|
||||
|
||||
+ // Kaiiju start - Vanilla end teleportation
|
||||
+ Vec3 finalPos;
|
||||
+ if (this instanceof Player) finalPos = Vec3.atBottomCenterOf(targetPos.below());
|
||||
+ else finalPos = Vec3.atBottomCenterOf(targetPos);
|
||||
+ // Kaiiju end
|
||||
// the portal obsidian is placed at targetPos.y - 2, so if we want to place the entity
|
||||
// on the obsidian, we need to spawn at targetPos.y - 1
|
||||
portalInfoCompletable.complete(
|
||||
- new PortalInfo(Vec3.atBottomCenterOf(targetPos.below()), Vec3.ZERO, 90.0f, 0.0f, destination, null)
|
||||
+ new PortalInfo(finalPos, this.getDeltaMovement(), 90.0f, 0.0f, destination, null) // Kaiiju - Vanilla end teleportation
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -4387,6 +4392,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
if (!this.canPortalAsync(takePassengers)) {
|
||||
return false;
|
||||
}
|
||||
+ // Kaiiju start - sync end platform spawning & entity teleportation
|
||||
+ final java.util.function.Consumer<Entity> tpComplete = type == PortalType.END && destination.getTypeKey() == LevelStem.END ?
|
||||
+ e -> ServerLevel.makeObsidianPlatform(destination, null, ServerLevel.END_SPAWN_POINT) : teleportComplete;
|
||||
+ // Kaiiju end
|
||||
|
||||
Vec3 initialPosition = this.position();
|
||||
ChunkPos initialPositionChunk = new ChunkPos(
|
||||
@@ -4445,7 +4454,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
// place
|
||||
passengerTree.root.placeInAsync(
|
||||
originWorld, destination, Entity.TELEPORT_FLAG_LOAD_CHUNK | (takePassengers ? Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS : 0L),
|
||||
- passengerTree, teleportComplete
|
||||
+ passengerTree, tpComplete // Kaiiju - vanilla end teleportation
|
||||
);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Mon, 10 Jun 2024 10:51:08 +0000
|
||||
Subject: [PATCH] Try fixing folia off region POI accessing issue
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaPOIAccessOffRegionFixConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaPOIAccessOffRegionFixConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7812a71f05dd32646037afd22cdabf72bb23b0d1
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaPOIAccessOffRegionFixConfig.java
|
||||
@@ -0,0 +1,25 @@
|
||||
+package me.earthme.luminol.config.modules.fixes;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class FoliaPOIAccessOffRegionFixConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled", comments =
|
||||
+ """
|
||||
+ The POIManager of folia has something which has not been patched\s
|
||||
+ for regionized ticking and these would trigger the async catcher\s
|
||||
+ and make the server crash.If you would like to prevent it and didn't\s
|
||||
+ mind the side effect(currently unknown), you can enable this""")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.FIXES;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "folia.fix_poi_access_off_region";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/GoToPotentialJobSite.java b/src/main/java/net/minecraft/world/entity/ai/behavior/GoToPotentialJobSite.java
|
||||
index aac1df9e2c0652bc6348af0404deba7465f82d42..ad812fd30d21ee3b7727105c66f2fc495a44f6ca 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/GoToPotentialJobSite.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/GoToPotentialJobSite.java
|
||||
@@ -49,10 +49,17 @@ public class GoToPotentialJobSite extends Behavior<Villager> {
|
||||
ServerLevel serverLevel2 = serverLevel.getServer().getLevel(pos.dimension());
|
||||
if (serverLevel2 != null) {
|
||||
PoiManager poiManager = serverLevel2.getPoiManager();
|
||||
+ //Luminol start - Fix off region POI accessing
|
||||
+ java.lang.Runnable scheduledRelease = () -> {
|
||||
if (poiManager.exists(blockPos, poiType -> true)) {
|
||||
poiManager.release(blockPos);
|
||||
}
|
||||
-
|
||||
+ };
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(serverLevel2, blockPos) && me.earthme.luminol.config.modules.fixes.FoliaPOIAccessOffRegionFixConfig.enabled)
|
||||
+ io.papermc.paper.threadedregions.RegionizedServer.getInstance().taskQueue.queueTickTaskQueue(serverLevel2, blockPos.getX() >> 4, blockPos.getZ() >> 4, scheduledRelease);
|
||||
+ else
|
||||
+ scheduledRelease.run();
|
||||
+ //Luminol end
|
||||
DebugPackets.sendPoiTicketCountPacket(serverLevel, blockPos);
|
||||
}
|
||||
});
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/YieldJobSite.java b/src/main/java/net/minecraft/world/entity/ai/behavior/YieldJobSite.java
|
||||
index d1a9b62d3304916275dd6b4c4e783cf1563b5e21..7d90e57b59ca1be1cc64ff6b53c64ea1f1767ad0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/YieldJobSite.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/YieldJobSite.java
|
||||
@@ -33,7 +33,10 @@ public class YieldJobSite {
|
||||
} else if (entity.getVillagerData().getProfession() != VillagerProfession.NONE) {
|
||||
return false;
|
||||
} else {
|
||||
- BlockPos blockPos = context.<GlobalPos>get(potentialJobSite).pos();
|
||||
+ final GlobalPos globalPos = context.<GlobalPos>get(potentialJobSite); //Luminol - Try fixing off main POI accessing
|
||||
+ final net.minecraft.server.level.ServerLevel targetLevel = net.minecraft.server.MinecraftServer.getServer().getLevel(globalPos.dimension()); //Luminol - Try fixing off main POI accessing
|
||||
+ BlockPos blockPos = globalPos.pos(); //Luminol - Try fixing off main POI accessing
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(targetLevel, blockPos) && me.earthme.luminol.config.modules.fixes.FoliaPOIAccessOffRegionFixConfig.enabled) return true; //Luminol - Try fixing off main POI accessing
|
||||
Optional<Holder<PoiType>> optional = world.getPoiManager().getType(blockPos);
|
||||
if (optional.isEmpty()) {
|
||||
return true;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
||||
index 1e7f11e5dda502fde6ca122f3edb2d2a161f3469..e57b5a3fddb890efc0245be5efb57c91d1e05f87 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
||||
@@ -226,7 +226,7 @@ public class PoiManager extends SectionStorage<PoiSection> implements ca.spotted
|
||||
|
||||
public Stream<PoiRecord> getInSquare(Predicate<Holder<PoiType>> typePredicate, BlockPos pos, int radius, PoiManager.Occupancy occupationStatus) {
|
||||
int i = Math.floorDiv(radius, 16) + 1;
|
||||
- return ChunkPos.rangeClosed(new ChunkPos(pos), i).flatMap(chunkPos -> this.getInChunk(typePredicate, chunkPos, occupationStatus)).filter(poi -> {
|
||||
+ return ChunkPos.rangeClosed(new ChunkPos(pos), i).filter(cpos -> me.earthme.luminol.config.modules.fixes.FoliaPOIAccessOffRegionFixConfig.enabled ? ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(this.world,cpos) : true).flatMap(chunkPos -> this.getInChunk(typePredicate, chunkPos, occupationStatus)).filter(poi -> { //Luminol - Fix off region POI access
|
||||
BlockPos blockPos2 = poi.getPos();
|
||||
return Math.abs(blockPos2.getX() - pos.getX()) <= radius && Math.abs(blockPos2.getZ() - pos.getZ()) <= radius;
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,15 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 06:58:52 +0000
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 12:33:32 +0800
|
||||
Subject: [PATCH] Prevent teleportAsync calling during moving event being
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaTeleportAsyncFixConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaTeleportAsyncFixConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..b8aceab54bb60000e7c56810140271022f5147a2
|
||||
index 0000000000000000000000000000000000000000..8f1449545d6d217b46a9ffae705123daefe55b25
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaTeleportAsyncFixConfig.java
|
||||
@@ -0,0 +1,22 @@
|
||||
@@ -0,0 +1,24 @@
|
||||
+package me.earthme.luminol.config.modules.fixes;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
@@ -17,7 +17,9 @@ index 0000000000000000000000000000000000000000..b8aceab54bb60000e7c5681014027102
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class FoliaTeleportAsyncFixConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ @ConfigInfo(baseName = "enabled", comments =
|
||||
+ "A fix which fixed some bugs of teleportAsync " +
|
||||
+ "that caused by plugins(such as Residence)")
|
||||
+ public static boolean enabled = false;
|
||||
+ @ConfigInfo(baseName = "throw_on_detected")
|
||||
+ public static boolean throwOnDetected = true;
|
||||
@@ -33,12 +35,12 @@ index 0000000000000000000000000000000000000000..b8aceab54bb60000e7c5681014027102
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 9cbf17436b4cf52aae374767aafe79ea4f60c3ce..f2068e7608ed765e35759eb981db6c95b07a06d8 100644
|
||||
index d57fd6e4aacb611526a741fbd98165f124b7b8ef..8cfaa94da67bcdd5c3d30479379d384c20b4a1ac 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -332,6 +332,10 @@ public class ServerPlayer extends Player {
|
||||
public double lastEntitySpawnRadiusSquared = -1.0;
|
||||
// Paper end - optimise chunk tick iteration
|
||||
@@ -335,6 +335,10 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
||||
}
|
||||
// Paper end - rewrite chunk system
|
||||
|
||||
+ //Luminol start - Prevent teleportAsync calling during moving event being handled
|
||||
+ public boolean handlingMoveEvent = false;
|
||||
@@ -48,10 +50,10 @@ index 9cbf17436b4cf52aae374767aafe79ea4f60c3ce..f2068e7608ed765e35759eb981db6c95
|
||||
super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile);
|
||||
this.chatVisibility = ChatVisiblity.FULL;
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 3b2508dc6cd4f70b09dce3b7e745e6efabaaa74e..b3ff8ed6d0f0414c15b9d2e6a51a0e34c361f92a 100644
|
||||
index 18d9e92f2fdc2cb25229005ffc08bffe555e0583..f0e063afa941aae051e950808fa7435e52d39456 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -675,7 +675,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
@@ -695,7 +695,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
|
||||
Location oldTo = to.clone();
|
||||
PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
|
||||
@@ -61,7 +63,7 @@ index 3b2508dc6cd4f70b09dce3b7e745e6efabaaa74e..b3ff8ed6d0f0414c15b9d2e6a51a0e34
|
||||
|
||||
// If the event is cancelled we move the player back to their old location.
|
||||
if (event.isCancelled()) {
|
||||
@@ -1621,7 +1623,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
@@ -1609,7 +1611,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
|
||||
Location oldTo = to.clone();
|
||||
PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
|
||||
@@ -72,41 +74,17 @@ index 3b2508dc6cd4f70b09dce3b7e745e6efabaaa74e..b3ff8ed6d0f0414c15b9d2e6a51a0e34
|
||||
// If the event is cancelled we move the player back to their old location.
|
||||
if (event.isCancelled()) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index dfb1b8c3af93bfcddb976c003c6ac2d52afc41c6..09cdd28dcb2357ba3d7be316b7ca94dc93ac5dd0 100644
|
||||
index 25a5f36ff19ff3f9cea051a1a6bf671b6288b799..bacc88b735619998927c59ce7b828bfff7574fa8 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -27,6 +27,7 @@ import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import me.earthme.luminol.config.modules.fixes.FoliaEntityMovingFixConfig;
|
||||
+import me.earthme.luminol.config.modules.fixes.FoliaTeleportAsyncFixConfig;
|
||||
import net.minecraft.BlockUtil;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.CrashReportCategory;
|
||||
@@ -59,7 +60,6 @@ import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
-import io.papermc.paper.util.MCUtil;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -132,7 +132,6 @@ import org.joml.Vector3f;
|
||||
import org.slf4j.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
-import org.bukkit.Server;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.event.CraftPortalEvent;
|
||||
@@ -3989,6 +3988,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -4075,6 +4075,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
java.util.function.Consumer<Entity> teleportComplete) {
|
||||
io.papermc.paper.util.TickThread.ensureTickThread(this, "Cannot teleport entity async");
|
||||
ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(this, "Cannot teleport entity async");
|
||||
|
||||
+ //Luminol start - Prevent teleportAsync calling during moving event being handled
|
||||
+ if (this instanceof ServerPlayer player && FoliaTeleportAsyncFixConfig.enabled){
|
||||
+ if (this instanceof ServerPlayer player && me.earthme.luminol.config.modules.fixes.FoliaTeleportAsyncFixConfig.enabled){
|
||||
+ if (player.handlingMoveEvent){
|
||||
+ if (FoliaTeleportAsyncFixConfig.throwOnDetected){
|
||||
+ if (me.earthme.luminol.config.modules.fixes.FoliaTeleportAsyncFixConfig.throwOnDetected){
|
||||
+ throw new IllegalStateException("Player " + player.getScoreboardName() + " is trying to teleport to " + pos + " during move event handling!");
|
||||
+ }
|
||||
+ MinecraftServer.LOGGER.warn("Player {} is trying to teleport to {} during move event handling!",player.getScoreboardName(),pos);
|
||||
@@ -115,37 +93,20 @@ index dfb1b8c3af93bfcddb976c003c6ac2d52afc41c6..09cdd28dcb2357ba3d7be316b7ca94dc
|
||||
+ }
|
||||
+ //Luminol end
|
||||
+
|
||||
if (!ServerLevel.isInSpawnableBounds(new BlockPos(io.papermc.paper.util.CoordinateUtils.getBlockX(pos), io.papermc.paper.util.CoordinateUtils.getBlockY(pos), io.papermc.paper.util.CoordinateUtils.getBlockZ(pos)))) {
|
||||
if (!ServerLevel.isInSpawnableBounds(new BlockPos(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getBlockX(pos), ca.spottedleaf.moonrise.common.util.CoordinateUtils.getBlockY(pos), ca.spottedleaf.moonrise.common.util.CoordinateUtils.getBlockZ(pos)))) {
|
||||
return false;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
index d514ec1e4cbdc579c3a61533998437903afdc8b6..c547376967360402d22657d25e1100366dd50c59 100644
|
||||
index a38ce400550893f63640e3bb5bb801ab40f06266..236e87790fe9357d948af40d411af56d958132c9 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
@@ -5,6 +5,8 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.UnmodifiableIterator;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
+
|
||||
+import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -21,6 +23,7 @@ import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
@@ -378,7 +381,21 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||
@@ -375,7 +375,21 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||
this.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
|
||||
|
||||
if (!from.equals(to)) {
|
||||
+ //Luminol start - Prevent teleportAsync calling during moving event being handled
|
||||
+ for (Entity passenger : this.getPassengers()) {
|
||||
+ if (passenger instanceof ServerPlayer player){
|
||||
+ if (passenger instanceof net.minecraft.server.level.ServerPlayer player){
|
||||
+ player.handlingMoveEvent = true;
|
||||
+ }
|
||||
+ }
|
||||
@@ -153,7 +114,7 @@ index d514ec1e4cbdc579c3a61533998437903afdc8b6..c547376967360402d22657d25e110036
|
||||
this.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to));
|
||||
+ //Luminol start - Prevent teleportAsync calling during moving event being handled
|
||||
+ for (Entity passenger : this.getPassengers()) {
|
||||
+ if (passenger instanceof ServerPlayer player){
|
||||
+ if (passenger instanceof net.minecraft.server.level.ServerPlayer player){
|
||||
+ player.handlingMoveEvent = false;
|
||||
+ }
|
||||
+ }
|
||||
@@ -162,33 +123,16 @@ index d514ec1e4cbdc579c3a61533998437903afdc8b6..c547376967360402d22657d25e110036
|
||||
// CraftBukkit end
|
||||
if (this.getMinecartType() == AbstractMinecart.Type.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
index db6aa75d642f4a7258f197933671907faf79c8f2..b7c792f75dda1c62ee3730b8204c347848710a9c 100644
|
||||
index f1955afc8e367f80ead85bd5ad3b8d66c255565a..19c19532947f785c8538f5bbdc6a88f6e09efbab 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
@@ -2,6 +2,8 @@ package net.minecraft.world.entity.vehicle;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.UnmodifiableIterator;
|
||||
+
|
||||
+import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.function.IntFunction;
|
||||
@@ -16,6 +18,7 @@ import net.minecraft.network.protocol.game.ServerboundPaddleBoatPacket;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.tags.EntityTypeTags;
|
||||
@@ -377,8 +380,22 @@ public class Boat extends VehicleEntity implements VariantHolder<Boat.Type> {
|
||||
@@ -374,8 +374,22 @@ public class Boat extends VehicleEntity implements Leashable, VariantHolder<Boat
|
||||
server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
|
||||
|
||||
if (this.lastLocation != null && !this.lastLocation.equals(to)) {
|
||||
+ //Luminol start - Prevent teleportAsync calling during moving event being handled
|
||||
+ for (Entity passenger : this.getPassengers()) {
|
||||
+ if (passenger instanceof ServerPlayer player){
|
||||
+ if (passenger instanceof net.minecraft.server.level.ServerPlayer player){
|
||||
+ player.handlingMoveEvent = true;
|
||||
+ }
|
||||
+ }
|
||||
@@ -197,7 +141,7 @@ index db6aa75d642f4a7258f197933671907faf79c8f2..b7c792f75dda1c62ee3730b8204c3478
|
||||
server.getPluginManager().callEvent(event);
|
||||
+ //Luminol start - Prevent teleportAsync calling during moving event being handled
|
||||
+ for (Entity passenger : this.getPassengers()) {
|
||||
+ if (passenger instanceof ServerPlayer player){
|
||||
+ if (passenger instanceof net.minecraft.server.level.ServerPlayer player){
|
||||
+ player.handlingMoveEvent = false;
|
||||
+ }
|
||||
+ }
|
||||
123
patches/server/0023-Try-optimizing-the-task-dispatching.patch
Normal file
123
patches/server/0023-Try-optimizing-the-task-dispatching.patch
Normal file
@@ -0,0 +1,123 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Fri, 2 Aug 2024 22:22:18 +0800
|
||||
Subject: [PATCH] Try optimizing the task dispatching
|
||||
|
||||
|
||||
diff --git a/src/main/java/ca/spottedleaf/concurrentutil/scheduler/SchedulerThreadPool.java b/src/main/java/ca/spottedleaf/concurrentutil/scheduler/SchedulerThreadPool.java
|
||||
index 8197ccb1c4e5878dbd8007b5fb514640765ec8e4..81db3c6f330729cb353b198badc86fe29e76bafc 100644
|
||||
--- a/src/main/java/ca/spottedleaf/concurrentutil/scheduler/SchedulerThreadPool.java
|
||||
+++ b/src/main/java/ca/spottedleaf/concurrentutil/scheduler/SchedulerThreadPool.java
|
||||
@@ -366,6 +366,12 @@ public class SchedulerThreadPool {
|
||||
"scheduled_state=" + this.scheduled.get() + ","
|
||||
+ "}";
|
||||
}
|
||||
+
|
||||
+ // Luminol start
|
||||
+ protected boolean flushExtraTask(){
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Luminol end
|
||||
}
|
||||
|
||||
private static final class TickThreadRunner implements Runnable {
|
||||
@@ -526,7 +532,7 @@ public class SchedulerThreadPool {
|
||||
if (diff <= 0L) {
|
||||
break;
|
||||
}
|
||||
- LockSupport.parkNanos(startState, diff);
|
||||
+ if (!me.earthme.luminol.config.modules.experiment.ExtraOptimizationConfig.enabled || !startStateTask.flushExtraTask()) LockSupport.parkNanos(startState, 1_000); // Luminol - Optimize task dispatching
|
||||
if (this.scheduler.halted) {
|
||||
return;
|
||||
}
|
||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/ThreadedRegionizer.java b/src/main/java/io/papermc/paper/threadedregions/ThreadedRegionizer.java
|
||||
index ce388e0ef231d7d73f75f5778c58eb40f6402f0f..7f8473a6db78dc652e0ccfdb7cc038126f1e61ea 100644
|
||||
--- a/src/main/java/io/papermc/paper/threadedregions/ThreadedRegionizer.java
|
||||
+++ b/src/main/java/io/papermc/paper/threadedregions/ThreadedRegionizer.java
|
||||
@@ -682,7 +682,7 @@ public final class ThreadedRegionizer<R extends ThreadedRegionizer.ThreadedRegio
|
||||
|
||||
public final long id;
|
||||
|
||||
- private int state;
|
||||
+ public int state; // Luminol - Optimize task dispatching
|
||||
|
||||
private final Long2ReferenceOpenHashMap<ThreadedRegionSection<R, S>> sectionByKey = new Long2ReferenceOpenHashMap<>();
|
||||
private final ReferenceOpenHashSet<ThreadedRegionSection<R, S>> deadSections = new ReferenceOpenHashSet<>();
|
||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/TickRegionScheduler.java b/src/main/java/io/papermc/paper/threadedregions/TickRegionScheduler.java
|
||||
index 056fb1ca7b07d5e713dcbd951830b14fc9025f4c..4bfa83a6683970657eaaaaa265855f0d2e79a3a9 100644
|
||||
--- a/src/main/java/io/papermc/paper/threadedregions/TickRegionScheduler.java
|
||||
+++ b/src/main/java/io/papermc/paper/threadedregions/TickRegionScheduler.java
|
||||
@@ -364,6 +364,47 @@ public final class TickRegionScheduler {
|
||||
return !this.markNotTicking() || this.cancelled.get() ? null : Boolean.valueOf(ret);
|
||||
}
|
||||
|
||||
+ @Override
|
||||
+ public boolean flushExtraTask(){
|
||||
+ if (this.cancelled.get()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (!this.tryMarkTicking()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (this.cancelled.get()) {
|
||||
+ this.markNotTicking();
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (this.region != null) {
|
||||
+ TickRegionScheduler.setTickingRegion(this.region.region);
|
||||
+ }
|
||||
+
|
||||
+ try {
|
||||
+ if (this.region == null){
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (this.region.region.getData().getTaskQueueData().executeChunkTask()){
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ if (this.region.region.getData().getTaskQueueData().executeTickTask()){
|
||||
+ return true;
|
||||
+ }
|
||||
+ }finally {
|
||||
+ this.markNotTicking();
|
||||
+ if (this.region != null) {
|
||||
+ TickRegionScheduler.setTickingRegion(null);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
@Override
|
||||
public final boolean runTick() {
|
||||
// Remember, we are supposed use setScheduledStart if we return true here, otherwise
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/experiment/ExtraOptimizationConfig.java b/src/main/java/me/earthme/luminol/config/modules/experiment/ExtraOptimizationConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..d908123da05c620586a1defcead423cc519113e9
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/experiment/ExtraOptimizationConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.experiment;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class ExtraOptimizationConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.EXPERIMENT;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "run_extra_tasks_during_waiting";
|
||||
+ }
|
||||
+}
|
||||
132
patches/server/0024-Force-disable-builtin-spark-plugin.patch
Normal file
132
patches/server/0024-Force-disable-builtin-spark-plugin.patch
Normal file
@@ -0,0 +1,132 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Tue, 6 Aug 2024 17:53:07 +0800
|
||||
Subject: [PATCH] Force disable builtin spark plugin
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/plugin/provider/source/FileProviderSource.java b/src/main/java/io/papermc/paper/plugin/provider/source/FileProviderSource.java
|
||||
index 48604e7f96adc9e226e034054c5e2bad0b024eb5..99f0c1e4d3437154a1062b0a8f94b7a04dd935af 100644
|
||||
--- a/src/main/java/io/papermc/paper/plugin/provider/source/FileProviderSource.java
|
||||
+++ b/src/main/java/io/papermc/paper/plugin/provider/source/FileProviderSource.java
|
||||
@@ -88,7 +88,7 @@ public class FileProviderSource implements ProviderSource<Path, Path> {
|
||||
}
|
||||
|
||||
final PluginMeta config = type.getConfig(file);
|
||||
- if ((config.getName().equals("spark") && config.getMainClass().equals("me.lucko.spark.bukkit.BukkitSparkPlugin")) && !SparksFly.isPluginPreferred()) {
|
||||
+ if ((config.getName().equals("spark") && config.getMainClass().equals("me.lucko.spark.bukkit.BukkitSparkPlugin")) && !SparksFly.isPluginPreferred() && false) { // Luminol - Force disable builtin spark
|
||||
LOGGER.info("The spark plugin will not be loaded as this server bundles the spark profiler.");
|
||||
return;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index b6489f9da0bf08e5801be1ce668a422610d2b393..db48812e886bc0110a1e098a98a67a5291e8eed3 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -777,8 +777,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
// Paper end - Configurable player collision
|
||||
|
||||
this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD);
|
||||
- this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark
|
||||
- this.server.spark.enableAfterPlugins(this.server); // Paper - spark
|
||||
+ if (false) this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark // Luminol - Force disable builtin spark
|
||||
+ if (false) this.server.spark.enableAfterPlugins(this.server); // Paper - spark // Luminol - Force disable builtin spark
|
||||
if (io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper != null) io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper.pluginsEnabled(); // Paper - Remap plugins
|
||||
io.papermc.paper.command.brigadier.PaperCommands.INSTANCE.setValid(); // Paper - reset invalid state for event fire below
|
||||
io.papermc.paper.plugin.lifecycle.event.LifecycleEventRunner.INSTANCE.callReloadableRegistrarEvent(io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents.COMMANDS, io.papermc.paper.command.brigadier.PaperCommands.INSTANCE, org.bukkit.plugin.Plugin.class, io.papermc.paper.plugin.lifecycle.event.registrar.ReloadableRegistrarEvent.Cause.INITIAL); // Paper - call commands event for regular plugins
|
||||
@@ -1092,7 +1092,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
MinecraftServer.LOGGER.info("Stopping server");
|
||||
Commands.COMMAND_SENDING_POOL.shutdownNow(); // Paper - Perf: Async command map building; Shutdown and don't bother finishing
|
||||
MinecraftTimings.stopServer(); // Paper
|
||||
- this.server.spark.disable(); // Paper - spark
|
||||
+ if (false) this.server.spark.disable(); // Paper - spark // Luminol - Force disable builtin spark
|
||||
// CraftBukkit start
|
||||
if (this.server != null) {
|
||||
this.server.disablePlugins();
|
||||
@@ -1308,7 +1308,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
// tasks are default scheduled at -1 + delay, and first tick will tick at 1
|
||||
final long actualDoneTimeMs = System.currentTimeMillis() - org.bukkit.craftbukkit.Main.BOOT_TIME.toEpochMilli(); // Paper - Add total time
|
||||
LOGGER.info("Done ({})! For help, type \"help\"", String.format(java.util.Locale.ROOT, "%.3fs", actualDoneTimeMs / 1000.00D)); // Paper - Add total time
|
||||
- this.server.spark.enableBeforePlugins(); // Paper - spark
|
||||
+ if (false) this.server.spark.enableBeforePlugins(); // Paper - spark // Luminol - Force disable builtin spark
|
||||
org.spigotmc.WatchdogThread.tick();
|
||||
// Paper end - Improved Watchdog Support
|
||||
org.spigotmc.WatchdogThread.hasStarted = true; // Paper
|
||||
@@ -1671,7 +1671,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
BooleanSupplier shouldKeepTicking = () -> {
|
||||
return scheduledEnd - System.nanoTime() > targetBuffer;
|
||||
};
|
||||
- this.server.spark.tickStart(); // Paper - spark
|
||||
+ if (false)this.server.spark.tickStart(); // Paper - spark // Luminol - Force disable builtin spark
|
||||
new com.destroystokyo.paper.event.server.ServerTickStartEvent((int)region.getCurrentTick()).callEvent(); // Paper
|
||||
// Folia end - region threading
|
||||
co.aikar.timings.TimingsManager.FULL_SERVER_TICK.startTiming(); // Paper
|
||||
@@ -1757,7 +1757,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
long endTime = System.nanoTime();
|
||||
long remaining = scheduledEnd - endTime; // Folia - region ticking
|
||||
new com.destroystokyo.paper.event.server.ServerTickEndEvent((int)io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick(), ((double)(endTime - startTime) / 1000000D), remaining).callEvent(); // Folia - region ticking
|
||||
- this.server.spark.tickEnd(((double)(endTime - startTime) / 1000000D)); // Paper - spark // Folia - region ticking
|
||||
+ if (false) this.server.spark.tickEnd(((double)(endTime - startTime) / 1000000D)); // Paper - spark // Folia - region ticking // Luminol - Force disable builtin spark
|
||||
// Paper end - Server Tick Events
|
||||
this.profiler.push("tallying");
|
||||
// Folia - region threading
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 79b79a5d41dc3568ae6a3d7701e6ac6b91045e36..cd28f741343c443ff4728fc0aa5526b6d66d2d9b 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -228,7 +228,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
// Paper end - initialize global and world-defaults configuration
|
||||
me.earthme.luminol.config.LuminolConfig.loadConfig(); //Luminol - load config file
|
||||
me.earthme.luminol.config.LuminolConfig.setupLatch(); //Luminol - load config file
|
||||
- this.server.spark.enableEarlyIfRequested(); // Paper - spark
|
||||
+ if (false) this.server.spark.enableEarlyIfRequested(); // Paper - spark // Luminol - Force disable builtin spark
|
||||
// Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save
|
||||
if (this.convertOldUsers()) {
|
||||
this.getProfileCache().save(false); // Paper
|
||||
@@ -238,7 +238,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
org.spigotmc.WatchdogThread.doStart(org.spigotmc.SpigotConfig.timeoutTime, org.spigotmc.SpigotConfig.restartOnCrash); // Paper - start watchdog thread
|
||||
thread.start(); // Paper - Enhance console tab completions for brigadier commands; start console thread after MinecraftServer.console & PaperConfig are initialized
|
||||
io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command
|
||||
- this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark
|
||||
+ if (false) this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark // Luminol - Force disable builtin spark
|
||||
com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics
|
||||
com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index dee23b4b96b7f2c6af54a6affe385b183479f8cc..07c6f858596e4926397b467ef5e22cab7e7f999b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -309,7 +309,7 @@ public final class CraftServer implements Server {
|
||||
public static Exception excessiveVelEx; // Paper - Velocity warnings
|
||||
private final io.papermc.paper.logging.SysoutCatcher sysoutCatcher = new io.papermc.paper.logging.SysoutCatcher(); // Paper
|
||||
private final io.papermc.paper.potion.PaperPotionBrewer potionBrewer; // Paper - Custom Potion Mixes
|
||||
- public final io.papermc.paper.SparksFly spark; // Paper - spark
|
||||
+ public io.papermc.paper.SparksFly spark; // Paper - spark // Luminol - Force disable builtin spark
|
||||
|
||||
// Paper start - Folia region threading API
|
||||
private final io.papermc.paper.threadedregions.scheduler.FoliaRegionScheduler regionizedScheduler = new io.papermc.paper.threadedregions.scheduler.FoliaRegionScheduler(); // Folia - region threading
|
||||
@@ -482,7 +482,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
|
||||
+ if (false) this.spark = new io.papermc.paper.SparksFly(this); // Paper - spark // Luminol - Force disable builtin spark
|
||||
}
|
||||
|
||||
public boolean getCommandBlockOverride(String command) {
|
||||
@@ -1146,7 +1146,7 @@ public final class CraftServer implements Server {
|
||||
this.reloadData();
|
||||
org.spigotmc.SpigotConfig.registerCommands(); // Spigot
|
||||
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
|
||||
- this.spark.registerCommandBeforePlugins(this); // Paper - spark
|
||||
+ if (false) this.spark.registerCommandBeforePlugins(this); // Paper - spark // Luminol - Force disable builtin spark
|
||||
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
||||
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
|
||||
|
||||
@@ -1175,7 +1175,7 @@ public final class CraftServer implements Server {
|
||||
this.loadPlugins();
|
||||
this.enablePlugins(PluginLoadOrder.STARTUP);
|
||||
this.enablePlugins(PluginLoadOrder.POSTWORLD);
|
||||
- this.spark.registerCommandAfterPlugins(this); // Paper - spark
|
||||
+ if (false) this.spark.registerCommandAfterPlugins(this); // Paper - spark // Luminol - Force disable builtin spark
|
||||
if (io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper != null) io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper.pluginsEnabled(); // Paper - Remap plugins
|
||||
// Paper start - brigadier command API
|
||||
io.papermc.paper.command.brigadier.PaperCommands.INSTANCE.setValid(); // to clear invalid state for event fire below
|
||||
@@ -1,19 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 15:59:49 +0800
|
||||
Subject: [PATCH] Pufferfish Optimize entity coordinate key
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
index 08d282400644be5949f28eb879b333cc221da2cc..49ccb27a17bec1d4ff31bc8d72e4724d65adc20c 100644
|
||||
--- a/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
+++ b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
@@ -215,7 +215,7 @@ public final class MCUtil {
|
||||
}
|
||||
|
||||
public static long getCoordinateKey(final Entity entity) {
|
||||
- return ((long)(MCUtil.fastFloor(entity.getZ()) >> 4) << 32) | ((MCUtil.fastFloor(entity.getX()) >> 4) & 0xFFFFFFFFL);
|
||||
+ return ((long)(entity.blockPosition.getZ() >> 4) << 32) | ((entity.blockPosition.getX() >> 4) & 0xFFFFFFFFL); // Pufferfish - eliminate double->long cast in hotpath
|
||||
}
|
||||
|
||||
public static long getCoordinateKey(final ChunkPos pair) {
|
||||
@@ -0,0 +1,20 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Tue, 6 Aug 2024 21:06:31 +0800
|
||||
Subject: [PATCH] Check allow before getting block state while tripwire state
|
||||
updating
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
|
||||
index 76aca266d3f3222502ff4c196228f08fcd88c5f8..82a6d0e3620aea26cd32296128488e13b6d43f44 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
|
||||
@@ -202,7 +202,7 @@ public class TripWireHookBlock extends Block {
|
||||
BlockState iblockdata4 = aiblockdata[l];
|
||||
|
||||
if (iblockdata4 != null) {
|
||||
- if (world.getBlockState(blockposition2).is(Blocks.TRIPWIRE) || io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowTripwireDisarmingExploits) { // Paper - Fix tripwire disarming not working as intended
|
||||
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowTripwireDisarmingExploits || world.getBlockState(blockposition2).is(Blocks.TRIPWIRE)) { // Paper - Fix tripwire disarming not working as intended // Luminol - check allow first
|
||||
world.setBlock(blockposition2, (BlockState) iblockdata4.trySetValue(TripWireHookBlock.ATTACHED, flag4), 3);
|
||||
}
|
||||
}
|
||||
868
patches/server/0026-LinearPurpur-Linear-region-format.patch
Normal file
868
patches/server/0026-LinearPurpur-Linear-region-format.patch
Normal file
@@ -0,0 +1,868 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sun, 4 Aug 2024 09:56:20 +0800
|
||||
Subject: [PATCH] LinearPurpur Linear region format
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 7615702d87b04699b2dd381c3b0c7e700602af8b..7b11c45914392c01b4d28b104f80e6ed34eb9955 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -31,6 +31,10 @@ dependencies {
|
||||
alsoShade(log4jPlugins.output)
|
||||
implementation("io.netty:netty-codec-haproxy:4.1.97.Final") // Paper - Add support for proxy protocol
|
||||
// Paper end
|
||||
+ // LinearPaper start
|
||||
+ implementation("com.github.luben:zstd-jni:1.5.6-3")
|
||||
+ implementation("org.lz4:lz4-java:1.8.0")
|
||||
+ // LinearPaper end
|
||||
implementation("org.apache.logging.log4j:log4j-iostreams:2.22.1") // Paper - remove exclusion
|
||||
implementation("org.ow2.asm:asm-commons:9.7.1")
|
||||
implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") // Paper - config files
|
||||
diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/io/ChunkSystemRegionFileStorage.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/io/ChunkSystemRegionFileStorage.java
|
||||
index 73df26b27146bbad2106d57b22dd3c792ed3dd1d..d2f209dd61f4412478a4b8fbe3489787d30bf74b 100644
|
||||
--- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/io/ChunkSystemRegionFileStorage.java
|
||||
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/io/ChunkSystemRegionFileStorage.java
|
||||
@@ -7,8 +7,8 @@ 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 // Leaf
|
||||
|
||||
- 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 // Leaf
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/io/RegionFileIOThread.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/io/RegionFileIOThread.java
|
||||
index 3218cbf84f54daf06e84442d5eb1a36d8da6b215..ec9b27177dc526510e86d85f48f167b44c01ac62 100644
|
||||
--- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/io/RegionFileIOThread.java
|
||||
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/io/RegionFileIOThread.java
|
||||
@@ -1043,9 +1043,9 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
return ((ChunkSystemRegionFileStorage)(Object)this.getCache()).moonrise$doesRegionFileNotExistNoIO(chunkX, chunkZ);
|
||||
}
|
||||
|
||||
- public <T> T computeForRegionFile(final int chunkX, final int chunkZ, final boolean existingOnly, final Function<RegionFile, T> function) {
|
||||
+ public <T> T computeForRegionFile(final int chunkX, final int chunkZ, final boolean existingOnly, final Function<org.stupidcraft.linearpaper.region.IRegionFile, T> function) { // LinearPaper
|
||||
final RegionFileStorage cache = this.getCache();
|
||||
- final RegionFile regionFile;
|
||||
+ final org.stupidcraft.linearpaper.region.IRegionFile regionFile; // LinearPaper
|
||||
synchronized (cache) {
|
||||
try {
|
||||
if (existingOnly) {
|
||||
@@ -1061,9 +1061,9 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
}
|
||||
}
|
||||
|
||||
- public <T> T computeForRegionFileIfLoaded(final int chunkX, final int chunkZ, final Function<RegionFile, T> function) {
|
||||
+ public <T> T computeForRegionFileIfLoaded(final int chunkX, final int chunkZ, final Function<org.stupidcraft.linearpaper.region.IRegionFile, T> function) { // LinearPaper
|
||||
final RegionFileStorage cache = this.getCache();
|
||||
- final RegionFile regionFile;
|
||||
+ final org.stupidcraft.linearpaper.region.IRegionFile regionFile; // LinearPaper
|
||||
|
||||
synchronized (cache) {
|
||||
regionFile = ((ChunkSystemRegionFileStorage)(Object)cache).moonrise$getRegionFileIfLoaded(chunkX, chunkZ);
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/RegionFormatConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/RegionFormatConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..fda9177bc2c5cc0176f816b9774a2b7de3bb57e9
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/RegionFormatConfig.java
|
||||
@@ -0,0 +1,51 @@
|
||||
+package me.earthme.luminol.config.modules.misc;
|
||||
+
|
||||
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import com.mojang.logging.LogUtils;
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.DoNotLoad;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+import org.slf4j.Logger;
|
||||
+import org.stupidcraft.linearpaper.region.EnumRegionFileExtension;
|
||||
+
|
||||
+public class RegionFormatConfig implements IConfigModule {
|
||||
+ @DoNotLoad
|
||||
+ private static final Logger logger = LogUtils.getLogger();
|
||||
+ @DoNotLoad
|
||||
+ public static EnumRegionFileExtension regionFormatType;
|
||||
+
|
||||
+ @ConfigInfo(baseName = "region_format_name", comments = "Available names: MCA, LINEAR")
|
||||
+ public static String regionFormatTypeName = "MCA";
|
||||
+ @ConfigInfo(baseName = "linear_compression_level", comments = "Compression level for linear region files.Available: 1 - 22")
|
||||
+ public static int linearCompressionLevel = 1;
|
||||
+ @ConfigInfo(baseName = "throw_on_unknown_extension_detected")
|
||||
+ public static boolean throwOnUnknownExtension = false;
|
||||
+ @ConfigInfo(baseName = "flush_per_seconds", comments = "Flush to disk every n seconds")
|
||||
+ public static int linearFlushFrequency = 5;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "region_format_settings";
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onLoaded(CommentedFileConfig config){
|
||||
+ regionFormatType = EnumRegionFileExtension.fromName(RegionFormatConfig.regionFormatTypeName);
|
||||
+ if (RegionFormatConfig.regionFormatType == EnumRegionFileExtension.UNKNOWN) {
|
||||
+ logger.error("Unknown region file type {} ! Falling back to MCA format.", RegionFormatConfig.regionFormatTypeName);
|
||||
+ RegionFormatConfig.regionFormatType = EnumRegionFileExtension.MCA;
|
||||
+ }
|
||||
+
|
||||
+ if (RegionFormatConfig.linearCompressionLevel > 23 || RegionFormatConfig.linearCompressionLevel < 1) {
|
||||
+ logger.error("Linear region compression level should be between 1 and 22 in config: {}", RegionFormatConfig.linearCompressionLevel);
|
||||
+ logger.error("Falling back to compression level 1.");
|
||||
+ RegionFormatConfig.linearCompressionLevel = 1;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index db48812e886bc0110a1e098a98a67a5291e8eed3..29103346dd3e5e69de260c95051c9447fda0da41 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1003,10 +1003,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
while (iterator1.hasNext()) {
|
||||
ServerLevel worldserver2 = (ServerLevel) iterator1.next();
|
||||
|
||||
- MinecraftServer.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", worldserver2.getChunkSource().chunkMap.getStorageName());
|
||||
+ MinecraftServer.LOGGER.info("ThreadedChunkStorage ({}): All chunks are saved", worldserver2.getChunkSource().chunkMap.getStorageName()); // LinearPaper
|
||||
}
|
||||
|
||||
- MinecraftServer.LOGGER.info("ThreadedAnvilChunkStorage: All dimensions are saved");
|
||||
+ MinecraftServer.LOGGER.info("ThreadedChunkStorage: All dimensions are saved"); // LinearPaper
|
||||
}
|
||||
|
||||
return flag3;
|
||||
diff --git a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||
index cb39c629af1827078f35904a373d35a63fea17ff..dc41c7c4616fa925427cd5a862f3923c5fa65902 100644
|
||||
--- a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||
+++ b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||
@@ -76,7 +76,7 @@ public class WorldUpgrader {
|
||||
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(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, RegistryAccess dynamicRegistryManager, boolean eraseCache, boolean recreateRegionFiles) {
|
||||
@@ -400,7 +400,7 @@ public class WorldUpgrader {
|
||||
|
||||
private static List<WorldUpgrader.FileToUpgrade> getAllChunkPositions(RegionStorageInfo key, Path regionDirectory) {
|
||||
File[] afile = regionDirectory.toFile().listFiles((file, s) -> {
|
||||
- return s.endsWith(".mca");
|
||||
+ return s.endsWith(".linear") || s.endsWith(".mca"); // LinearPaper
|
||||
});
|
||||
|
||||
if (afile == null) {
|
||||
@@ -420,7 +420,7 @@ public class WorldUpgrader {
|
||||
List<ChunkPos> list1 = Lists.newArrayList();
|
||||
|
||||
try {
|
||||
- RegionFile regionfile = new RegionFile(key, file.toPath(), regionDirectory, true);
|
||||
+ org.stupidcraft.linearpaper.region.IRegionFile regionfile = org.stupidcraft.linearpaper.region.IRegionFileFactory.getAbstractRegionFile(key, file.toPath(), regionDirectory, true); // LinearPaper
|
||||
|
||||
try {
|
||||
for (int i1 = 0; i1 < 32; ++i1) {
|
||||
@@ -483,7 +483,7 @@ public class WorldUpgrader {
|
||||
|
||||
protected abstract boolean tryProcessOnePosition(T storage, ChunkPos chunkPos, ResourceKey<Level> worldKey);
|
||||
|
||||
- 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();
|
||||
@@ -508,7 +508,7 @@ public class WorldUpgrader {
|
||||
}
|
||||
}
|
||||
|
||||
- static record FileToUpgrade(RegionFile file, List<ChunkPos> chunksToUpgrade) {
|
||||
+ static record FileToUpgrade(org.stupidcraft.linearpaper.region.IRegionFile file, List<ChunkPos> chunksToUpgrade) { // LinearPaper
|
||||
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
index 1e0439cf3f4008fa430acb90b45f5bc4cdd6d7f2..9b217cbfb800df8f72fffaf033ff671c31f3ac98 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
@@ -28,7 +28,7 @@ import net.minecraft.nbt.NbtIo; // Paper
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
-public class RegionFile implements AutoCloseable {
|
||||
+public class RegionFile implements org.stupidcraft.linearpaper.region.IRegionFile, AutoCloseable { // LinearPaper
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static final int SECTOR_BYTES = 4096;
|
||||
@@ -129,7 +129,7 @@ public class RegionFile implements AutoCloseable {
|
||||
}
|
||||
|
||||
// note: only call for CHUNK regionfiles
|
||||
- boolean recalculateHeader() throws IOException {
|
||||
+ public boolean recalculateHeader() throws IOException { // LinearPaper - make public
|
||||
if (!this.canRecalcHeader) {
|
||||
return false;
|
||||
}
|
||||
@@ -928,10 +928,10 @@ public class RegionFile implements AutoCloseable {
|
||||
private static int getChunkIndex(int x, int z) {
|
||||
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);
|
||||
@@ -970,7 +970,7 @@ public class RegionFile implements AutoCloseable {
|
||||
return this.path.getParent().resolve(this.path.getFileName().toString().replaceAll("\\.mca$", "") + "_oversized_" + x + "_" + z + ".nbt");
|
||||
}
|
||||
|
||||
- synchronized CompoundTag getOversizedData(int x, int z) throws IOException {
|
||||
+ public synchronized 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 InflaterInputStream(Files.newInputStream(file))))) {
|
||||
return NbtIo.read((java.io.DataInput) out);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
index 40689256711cc94a806ca1da346f4f62eda31526..f6ecb85d6802e4eadc0e487ae2d8cbfbc38d6f65 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.minecraft.world.level.chunk.storage;
|
||||
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
|
||||
-import it.unimi.dsi.fastutil.objects.ObjectIterator;
|
||||
+
|
||||
import java.io.DataInput;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutput;
|
||||
@@ -9,6 +9,8 @@ import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.earthme.luminol.config.modules.misc.RegionFormatConfig;
|
||||
import net.minecraft.FileUtil;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtAccounter;
|
||||
@@ -21,7 +23,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
|
||||
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;
|
||||
@@ -30,7 +32,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 * 64;
|
||||
private final it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet nonExistingRegionFiles = new it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet(MAX_NON_EXISTING_CACHE+1);
|
||||
+ // Leaf start - Linear region format
|
||||
private static String getRegionFileName(final int chunkX, final int chunkZ) {
|
||||
+ if (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";
|
||||
}
|
||||
|
||||
@@ -66,15 +72,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;
|
||||
}
|
||||
@@ -98,7 +104,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);
|
||||
|
||||
@@ -115,7 +121,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;
|
||||
}
|
||||
|
||||
@@ -143,7 +149,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
this.isChunkData = isChunkDataFolder(this.folder); // Paper - recalculate region file headers
|
||||
}
|
||||
|
||||
- public RegionFile getRegionFile(ChunkPos chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit // Paper - public
|
||||
+ public org.stupidcraft.linearpaper.region.IRegionFile getRegionFile(ChunkPos chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit // Paper - public // LinearPaper
|
||||
// Paper start - rewrite chunk system
|
||||
if (existingOnly) {
|
||||
return this.moonrise$getRegionFileIfExists(chunkcoordintpair.x, chunkcoordintpair.z);
|
||||
@@ -151,7 +157,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
synchronized (this) {
|
||||
final long key = ChunkPos.asLong(chunkcoordintpair.x >> REGION_SHIFT, chunkcoordintpair.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;
|
||||
}
|
||||
@@ -160,13 +166,13 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
this.regionCache.removeLast().close();
|
||||
}
|
||||
|
||||
- final Path regionPath = this.folder.resolve(getRegionFileName(chunkcoordintpair.x, chunkcoordintpair.z));
|
||||
+ final Path regionPath = this.folder.resolve(getRegionFileName(chunkcoordintpair.x, chunkcoordintpair.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);
|
||||
|
||||
@@ -180,7 +186,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
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 - You may ask for help on Discord, but do not file an issue. These error messages can not be removed.");
|
||||
}
|
||||
|
||||
- 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);
|
||||
@@ -215,7 +221,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
@Nullable
|
||||
public CompoundTag read(ChunkPos pos) 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(pos, true);
|
||||
+ org.stupidcraft.linearpaper.region.IRegionFile regionfile = this.getRegionFile(pos, true); // LinearPaper
|
||||
if (regionfile == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -279,7 +285,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
|
||||
public void scanChunk(ChunkPos chunkPos, StreamTagVisitor scanner) 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;
|
||||
}
|
||||
@@ -309,7 +315,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
}
|
||||
|
||||
public void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException { // Paper - public
|
||||
- RegionFile regionfile = this.getRegionFile(pos, nbt == null); // CraftBukkit // Paper - rewrite chunk system
|
||||
+ org.stupidcraft.linearpaper.region.IRegionFile regionfile = this.getRegionFile(pos, nbt == 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
|
||||
@@ -368,7 +374,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) {
|
||||
@@ -385,7 +391,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) {
|
||||
diff --git a/src/main/java/org/stupidcraft/linearpaper/region/EnumRegionFileExtension.java b/src/main/java/org/stupidcraft/linearpaper/region/EnumRegionFileExtension.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..8eba172be9bce7cccd27d27bee2d6c6f917a9e4e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/stupidcraft/linearpaper/region/EnumRegionFileExtension.java
|
||||
@@ -0,0 +1,56 @@
|
||||
+package org.stupidcraft.linearpaper.region;
|
||||
+
|
||||
+import org.jetbrains.annotations.Contract;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.util.Locale;
|
||||
+
|
||||
+public enum EnumRegionFileExtension {
|
||||
+ LINEAR(".linear"),
|
||||
+ MCA(".mca"),
|
||||
+ UNKNOWN(null);
|
||||
+
|
||||
+ private final String extensionName;
|
||||
+
|
||||
+ EnumRegionFileExtension(String extensionName) {
|
||||
+ this.extensionName = extensionName;
|
||||
+ }
|
||||
+
|
||||
+ public String getExtensionName() {
|
||||
+ return this.extensionName;
|
||||
+ }
|
||||
+
|
||||
+ @Contract(pure = true)
|
||||
+ public static EnumRegionFileExtension fromName(@NotNull String name) {
|
||||
+ switch (name.toUpperCase(Locale.ROOT)) {
|
||||
+ default -> {
|
||||
+ return UNKNOWN;
|
||||
+ }
|
||||
+
|
||||
+ case "MCA" -> {
|
||||
+ return MCA;
|
||||
+ }
|
||||
+
|
||||
+ case "LINEAR" -> {
|
||||
+ return LINEAR;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Contract(pure = true)
|
||||
+ public static EnumRegionFileExtension fromExtension(@NotNull String name) {
|
||||
+ switch (name.toLowerCase()) {
|
||||
+ case "mca" -> {
|
||||
+ return MCA;
|
||||
+ }
|
||||
+
|
||||
+ case "linear" -> {
|
||||
+ return LINEAR;
|
||||
+ }
|
||||
+
|
||||
+ default -> {
|
||||
+ return UNKNOWN;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/stupidcraft/linearpaper/region/IRegionFile.java b/src/main/java/org/stupidcraft/linearpaper/region/IRegionFile.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..6417f5b6daa35044995dd0aa9cfc24acd8ce4287
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/stupidcraft/linearpaper/region/IRegionFile.java
|
||||
@@ -0,0 +1,26 @@
|
||||
+package org.stupidcraft.linearpaper.region;
|
||||
+
|
||||
+import java.io.DataInputStream;
|
||||
+import java.io.DataOutputStream;
|
||||
+import java.io.IOException;
|
||||
+import java.nio.file.Path;
|
||||
+
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+import net.minecraft.world.level.ChunkPos;
|
||||
+
|
||||
+public interface IRegionFile {
|
||||
+ Path getPath();
|
||||
+ void flush() throws IOException;
|
||||
+ void clear(ChunkPos pos) throws IOException;
|
||||
+ void close() throws IOException;
|
||||
+ void setOversized(int x, int z, boolean b) throws IOException;
|
||||
+
|
||||
+ boolean hasChunk(ChunkPos pos);
|
||||
+ boolean doesChunkExist(ChunkPos pos) throws Exception;
|
||||
+ boolean isOversized(int x, int z);
|
||||
+ boolean recalculateHeader() throws IOException;
|
||||
+
|
||||
+ DataOutputStream getChunkDataOutputStream(ChunkPos pos) throws IOException;
|
||||
+ DataInputStream getChunkDataInputStream(ChunkPos pos) throws IOException;
|
||||
+ CompoundTag getOversizedData(int x, int z) throws IOException;
|
||||
+}
|
||||
diff --git a/src/main/java/org/stupidcraft/linearpaper/region/IRegionFileFactory.java b/src/main/java/org/stupidcraft/linearpaper/region/IRegionFileFactory.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..4bbce604a0c1650f5584fc16129cdd2da12d28fa
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/stupidcraft/linearpaper/region/IRegionFileFactory.java
|
||||
@@ -0,0 +1,52 @@
|
||||
+package org.stupidcraft.linearpaper.region;
|
||||
+
|
||||
+import java.io.IOException;
|
||||
+import java.nio.file.Path;
|
||||
+
|
||||
+import me.earthme.luminol.config.modules.misc.RegionFormatConfig;
|
||||
+import net.minecraft.world.level.chunk.storage.RegionFile;
|
||||
+import net.minecraft.world.level.chunk.storage.RegionFileVersion;
|
||||
+import net.minecraft.world.level.chunk.storage.RegionStorageInfo;
|
||||
+import org.jetbrains.annotations.Contract;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+public class IRegionFileFactory {
|
||||
+ @Contract("_, _, _, _ -> new")
|
||||
+ public static @NotNull IRegionFile getAbstractRegionFile(RegionStorageInfo storageKey, Path directory, Path path, boolean dsync) throws IOException {
|
||||
+ return getAbstractRegionFile(storageKey, directory, path, RegionFileVersion.getCompressionFormat(), dsync);
|
||||
+ }
|
||||
+
|
||||
+ @Contract("_, _, _, _, _ -> new")
|
||||
+ public static @NotNull IRegionFile getAbstractRegionFile(RegionStorageInfo storageKey, Path directory, Path path, boolean dsync, boolean canRecalcHeader) throws IOException {
|
||||
+ return getAbstractRegionFile(storageKey, directory, path, RegionFileVersion.getCompressionFormat(), dsync, canRecalcHeader);
|
||||
+ }
|
||||
+
|
||||
+ @Contract("_, _, _, _, _ -> new")
|
||||
+ public static @NotNull IRegionFile getAbstractRegionFile(RegionStorageInfo storageKey, Path path, Path directory, RegionFileVersion compressionFormat, boolean dsync) throws IOException {
|
||||
+ return getAbstractRegionFile(storageKey, path, directory, compressionFormat, dsync, true);
|
||||
+ }
|
||||
+
|
||||
+ @Contract("_, _, _, _, _, _ -> new")
|
||||
+ public static @NotNull IRegionFile getAbstractRegionFile(RegionStorageInfo storageKey, @NotNull Path path, Path directory, RegionFileVersion compressionFormat, boolean dsync, boolean canRecalcHeader) throws IOException {
|
||||
+ final String fullFileName = path.getFileName().toString();
|
||||
+ final String[] fullNameSplit = fullFileName.split("\\.");
|
||||
+ final String extensionName = fullNameSplit[fullNameSplit.length - 1];
|
||||
+ switch (EnumRegionFileExtension.fromExtension(extensionName)) {
|
||||
+ case UNKNOWN -> {
|
||||
+ if (RegionFormatConfig.throwOnUnknownExtension) {
|
||||
+ throw new IllegalArgumentException("Unknown region file extension for file: " + fullFileName + "!");
|
||||
+ }
|
||||
+
|
||||
+ return new RegionFile(storageKey, path, directory, compressionFormat, dsync);
|
||||
+ }
|
||||
+
|
||||
+ case LINEAR -> {
|
||||
+ return new LinearRegionFile(path, me.earthme.luminol.config.modules.misc.RegionFormatConfig.linearCompressionLevel);
|
||||
+ }
|
||||
+
|
||||
+ default -> {
|
||||
+ return new RegionFile(storageKey, path, directory, compressionFormat, dsync);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/stupidcraft/linearpaper/region/LinearRegionFile.java b/src/main/java/org/stupidcraft/linearpaper/region/LinearRegionFile.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..685c055619f80554a5e8f85554f86faf2b1f53bf
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/stupidcraft/linearpaper/region/LinearRegionFile.java
|
||||
@@ -0,0 +1,311 @@
|
||||
+package org.stupidcraft.linearpaper.region;
|
||||
+
|
||||
+import com.github.luben.zstd.ZstdInputStream;
|
||||
+import com.github.luben.zstd.ZstdOutputStream;
|
||||
+import com.mojang.logging.LogUtils;
|
||||
+
|
||||
+import java.io.BufferedOutputStream;
|
||||
+import java.io.ByteArrayInputStream;
|
||||
+import java.io.ByteArrayOutputStream;
|
||||
+import java.io.DataInputStream;
|
||||
+import java.io.DataOutputStream;
|
||||
+import java.io.File;
|
||||
+import java.io.FileInputStream;
|
||||
+import java.io.FileOutputStream;
|
||||
+import java.io.IOException;
|
||||
+import java.io.InputStream;
|
||||
+import java.nio.ByteBuffer;
|
||||
+import java.nio.file.Files;
|
||||
+import java.nio.file.Path;
|
||||
+import java.nio.file.StandardCopyOption;
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.List;
|
||||
+import java.util.concurrent.TimeUnit;
|
||||
+import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.earthme.luminol.config.modules.misc.RegionFormatConfig;
|
||||
+import net.jpountz.lz4.LZ4Compressor;
|
||||
+import net.jpountz.lz4.LZ4Factory;
|
||||
+import net.jpountz.lz4.LZ4FastDecompressor;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+import net.minecraft.world.level.ChunkPos;
|
||||
+import org.slf4j.Logger;
|
||||
+
|
||||
+public class LinearRegionFile implements IRegionFile, AutoCloseable {
|
||||
+ private static final long SUPERBLOCK = -4323716122432332390L;
|
||||
+ private static final byte VERSION = 2;
|
||||
+ private static final int HEADER_SIZE = 32;
|
||||
+ private static final int FOOTER_SIZE = 8;
|
||||
+ private static final Logger LOGGER = LogUtils.getLogger();
|
||||
+ private static final List<Byte> SUPPORTED_VERSIONS = Arrays.asList((byte) 1, (byte) 2);
|
||||
+ private final byte[][] buffer = new byte[1024][];
|
||||
+ private final int[] bufferUncompressedSize = new int[1024];
|
||||
+ private final int[] chunkTimestamps = new int[1024];
|
||||
+ private final LZ4Compressor compressor;
|
||||
+ private final LZ4FastDecompressor decompressor;
|
||||
+ private final int compressionLevel;
|
||||
+ public boolean closed = false;
|
||||
+ public Path path;
|
||||
+ private volatile long lastFlushed = System.nanoTime();
|
||||
+
|
||||
+ public LinearRegionFile(Path file, int compression) throws IOException {
|
||||
+ this.path = file;
|
||||
+ this.compressionLevel = compression;
|
||||
+ this.compressor = LZ4Factory.fastestInstance().fastCompressor();
|
||||
+ this.decompressor = LZ4Factory.fastestInstance().fastDecompressor();
|
||||
+
|
||||
+ File regionFile = new File(this.path.toString());
|
||||
+
|
||||
+ Arrays.fill(this.bufferUncompressedSize, 0);
|
||||
+
|
||||
+ if (!regionFile.canRead()) return;
|
||||
+
|
||||
+ try (FileInputStream fileStream = new FileInputStream(regionFile);
|
||||
+ DataInputStream rawDataStream = new DataInputStream(fileStream)) {
|
||||
+
|
||||
+ long superBlock = rawDataStream.readLong();
|
||||
+ if (superBlock != SUPERBLOCK)
|
||||
+ throw new RuntimeException("Invalid superblock: " + superBlock + " in " + file);
|
||||
+
|
||||
+ byte version = rawDataStream.readByte();
|
||||
+ if (!SUPPORTED_VERSIONS.contains(version))
|
||||
+ throw new RuntimeException("Invalid version: " + version + " in " + file);
|
||||
+
|
||||
+ // Skip newestTimestamp (Long) + Compression level (Byte) + Chunk count (Short): Unused.
|
||||
+ rawDataStream.skipBytes(11);
|
||||
+
|
||||
+ int dataCount = rawDataStream.readInt();
|
||||
+ long fileLength = file.toFile().length();
|
||||
+ if (fileLength != HEADER_SIZE + dataCount + FOOTER_SIZE)
|
||||
+ throw new IOException("Invalid file length: " + this.path + " " + fileLength + " " + (HEADER_SIZE + dataCount + FOOTER_SIZE));
|
||||
+
|
||||
+ rawDataStream.skipBytes(8); // Skip data hash (Long): Unused.
|
||||
+
|
||||
+ byte[] rawCompressed = new byte[dataCount];
|
||||
+ rawDataStream.readFully(rawCompressed, 0, dataCount);
|
||||
+
|
||||
+ superBlock = rawDataStream.readLong();
|
||||
+ if (superBlock != SUPERBLOCK)
|
||||
+ throw new IOException("Footer superblock invalid " + this.path);
|
||||
+
|
||||
+ try (DataInputStream dataStream = new DataInputStream(new ZstdInputStream(new ByteArrayInputStream(rawCompressed)))) {
|
||||
+
|
||||
+ int[] starts = new int[1024];
|
||||
+ for (int i = 0; i < 1024; i++) {
|
||||
+ starts[i] = dataStream.readInt();
|
||||
+ dataStream.skipBytes(4); // Skip timestamps (Int): Unused.
|
||||
+ }
|
||||
+
|
||||
+ for (int i = 0; i < 1024; i++) {
|
||||
+ if (starts[i] > 0) {
|
||||
+ int size = starts[i];
|
||||
+ byte[] b = new byte[size];
|
||||
+ dataStream.readFully(b, 0, size);
|
||||
+
|
||||
+ int maxCompressedLength = this.compressor.maxCompressedLength(size);
|
||||
+ byte[] compressed = new byte[maxCompressedLength];
|
||||
+ int compressedLength = this.compressor.compress(b, 0, size, compressed, 0, maxCompressedLength);
|
||||
+ b = new byte[compressedLength];
|
||||
+ System.arraycopy(compressed, 0, b, 0, compressedLength);
|
||||
+
|
||||
+ this.buffer[i] = b;
|
||||
+ this.bufferUncompressedSize[i] = size;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static int getChunkIndex(int x, int z) {
|
||||
+ return (x & 31) + ((z & 31) << 5);
|
||||
+ }
|
||||
+
|
||||
+ private static int getTimestamp() {
|
||||
+ return (int) (System.currentTimeMillis() / 1000L);
|
||||
+ }
|
||||
+
|
||||
+ public void flush() throws IOException {
|
||||
+ flushWrapper(); // sync
|
||||
+ }
|
||||
+
|
||||
+ public void flushWrapper() {
|
||||
+ try {
|
||||
+ save();
|
||||
+ } catch (IOException e) {
|
||||
+ LOGGER.error("Failed to flush region file {}", path.toAbsolutePath(), e);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public boolean doesChunkExist(ChunkPos pos) throws Exception {
|
||||
+ throw new Exception("doesChunkExist is a stub");
|
||||
+ }
|
||||
+
|
||||
+ private synchronized void save() throws IOException {
|
||||
+ long timestamp = getTimestamp();
|
||||
+ short chunkCount = 0;
|
||||
+
|
||||
+ File tempFile = new File(path.toString() + ".tmp");
|
||||
+
|
||||
+ try (FileOutputStream fileStream = new FileOutputStream(tempFile);
|
||||
+ ByteArrayOutputStream zstdByteArray = new ByteArrayOutputStream();
|
||||
+ ZstdOutputStream zstdStream = new ZstdOutputStream(zstdByteArray, this.compressionLevel);
|
||||
+ DataOutputStream zstdDataStream = new DataOutputStream(zstdStream);
|
||||
+ DataOutputStream dataStream = new DataOutputStream(fileStream)) {
|
||||
+
|
||||
+ dataStream.writeLong(SUPERBLOCK);
|
||||
+ dataStream.writeByte(VERSION);
|
||||
+ dataStream.writeLong(timestamp);
|
||||
+ dataStream.writeByte(this.compressionLevel);
|
||||
+
|
||||
+ ArrayList<byte[]> byteBuffers = new ArrayList<>();
|
||||
+ for (int i = 0; i < 1024; i++) {
|
||||
+ if (this.bufferUncompressedSize[i] != 0) {
|
||||
+ chunkCount += 1;
|
||||
+ byte[] content = new byte[bufferUncompressedSize[i]];
|
||||
+ this.decompressor.decompress(buffer[i], 0, content, 0, bufferUncompressedSize[i]);
|
||||
+
|
||||
+ byteBuffers.add(content);
|
||||
+ } else byteBuffers.add(null);
|
||||
+ }
|
||||
+ for (int i = 0; i < 1024; i++) {
|
||||
+ zstdDataStream.writeInt(this.bufferUncompressedSize[i]); // Write uncompressed size
|
||||
+ zstdDataStream.writeInt(this.chunkTimestamps[i]); // Write timestamp
|
||||
+ }
|
||||
+ for (int i = 0; i < 1024; i++) {
|
||||
+ if (byteBuffers.get(i) != null)
|
||||
+ zstdDataStream.write(byteBuffers.get(i), 0, byteBuffers.get(i).length);
|
||||
+ }
|
||||
+ zstdDataStream.close();
|
||||
+
|
||||
+ dataStream.writeShort(chunkCount);
|
||||
+
|
||||
+ byte[] compressed = zstdByteArray.toByteArray();
|
||||
+
|
||||
+ dataStream.writeInt(compressed.length);
|
||||
+ dataStream.writeLong(0);
|
||||
+
|
||||
+ dataStream.write(compressed, 0, compressed.length);
|
||||
+ dataStream.writeLong(SUPERBLOCK);
|
||||
+
|
||||
+ dataStream.flush();
|
||||
+ fileStream.getFD().sync();
|
||||
+ fileStream.getChannel().force(true); // Ensure atomicity on Btrfs
|
||||
+ }
|
||||
+ Files.move(tempFile.toPath(), this.path, StandardCopyOption.REPLACE_EXISTING);
|
||||
+ this.lastFlushed = System.nanoTime();
|
||||
+ }
|
||||
+
|
||||
+ private void checkAndSave(){
|
||||
+ if ((System.nanoTime() - this.lastFlushed) >= TimeUnit.NANOSECONDS.toSeconds(RegionFormatConfig.linearFlushFrequency)) {
|
||||
+ this.flushWrapper();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public synchronized void write(ChunkPos pos, ByteBuffer buffer) {
|
||||
+ try {
|
||||
+ byte[] b = toByteArray(new ByteArrayInputStream(buffer.array()));
|
||||
+ int uncompressedSize = b.length;
|
||||
+
|
||||
+ int maxCompressedLength = this.compressor.maxCompressedLength(b.length);
|
||||
+ byte[] compressed = new byte[maxCompressedLength];
|
||||
+ int compressedLength = this.compressor.compress(b, 0, b.length, compressed, 0, maxCompressedLength);
|
||||
+ b = new byte[compressedLength];
|
||||
+ System.arraycopy(compressed, 0, b, 0, compressedLength);
|
||||
+
|
||||
+ int index = getChunkIndex(pos.x, pos.z);
|
||||
+ this.buffer[index] = b;
|
||||
+ this.chunkTimestamps[index] = getTimestamp();
|
||||
+ this.bufferUncompressedSize[getChunkIndex(pos.x, pos.z)] = uncompressedSize;
|
||||
+ } catch (IOException e) {
|
||||
+ LOGGER.error("Chunk write IOException {} {}", e, this.path);
|
||||
+ }
|
||||
+
|
||||
+ this.checkAndSave();
|
||||
+ }
|
||||
+
|
||||
+ public DataOutputStream getChunkDataOutputStream(ChunkPos pos) {
|
||||
+ try {
|
||||
+ return new DataOutputStream(new BufferedOutputStream(new ChunkBuffer(pos)));
|
||||
+ }finally {
|
||||
+ this.checkAndSave();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private byte[] toByteArray(InputStream in) throws IOException {
|
||||
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
+ byte[] tempBuffer = new byte[4096];
|
||||
+
|
||||
+ int length;
|
||||
+ while ((length = in.read(tempBuffer)) >= 0) {
|
||||
+ out.write(tempBuffer, 0, length);
|
||||
+ }
|
||||
+
|
||||
+ return out.toByteArray();
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public synchronized DataInputStream getChunkDataInputStream(ChunkPos pos) {
|
||||
+ try {
|
||||
+ if (this.bufferUncompressedSize[getChunkIndex(pos.x, pos.z)] != 0) {
|
||||
+ byte[] content = new byte[bufferUncompressedSize[getChunkIndex(pos.x, pos.z)]];
|
||||
+ this.decompressor.decompress(this.buffer[getChunkIndex(pos.x, pos.z)], 0, content, 0, bufferUncompressedSize[getChunkIndex(pos.x, pos.z)]);
|
||||
+ return new DataInputStream(new ByteArrayInputStream(content));
|
||||
+ }
|
||||
+ }finally {
|
||||
+ this.checkAndSave();
|
||||
+ }
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ public void clear(ChunkPos pos) {
|
||||
+ int i = getChunkIndex(pos.x, pos.z);
|
||||
+ this.buffer[i] = null;
|
||||
+ this.bufferUncompressedSize[i] = 0;
|
||||
+ this.chunkTimestamps[i] = getTimestamp();
|
||||
+ this.flushWrapper();
|
||||
+ }
|
||||
+
|
||||
+ public Path getPath() {
|
||||
+ return this.path;
|
||||
+ }
|
||||
+
|
||||
+ public boolean hasChunk(ChunkPos pos) {
|
||||
+ return this.bufferUncompressedSize[getChunkIndex(pos.x, pos.z)] > 0;
|
||||
+ }
|
||||
+
|
||||
+ public void close() throws IOException {
|
||||
+ if (closed) return;
|
||||
+ closed = true;
|
||||
+ flush(); // sync
|
||||
+ }
|
||||
+
|
||||
+ public boolean recalculateHeader() {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ public void setOversized(int x, int z, boolean something) {
|
||||
+ }
|
||||
+
|
||||
+ public CompoundTag getOversizedData(int x, int z) throws IOException {
|
||||
+ throw new IOException("getOversizedData is a stub " + this.path);
|
||||
+ }
|
||||
+
|
||||
+ public boolean isOversized(int x, int z) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ private class ChunkBuffer extends ByteArrayOutputStream {
|
||||
+ private final ChunkPos pos;
|
||||
+
|
||||
+ public ChunkBuffer(ChunkPos chunkcoordintpair) {
|
||||
+ super();
|
||||
+ this.pos = chunkcoordintpair;
|
||||
+ }
|
||||
+
|
||||
+ public void close() {
|
||||
+ ByteBuffer bytebuffer = ByteBuffer.wrap(this.buf, 0, this.count);
|
||||
+ LinearRegionFile.this.write(this.pos, bytebuffer);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
@@ -5,14 +5,14 @@ Subject: [PATCH] Kaiiju Don't pathfind outside region
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java b/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
||||
index 1ab77f3518d1df30f66ae44d7d4fa69e5b32d93a..98bf17441da3169d49de55fe89d79ebe250a2b7e 100644
|
||||
index 2a7a26ca447cc78f24e61a2bf557411c31eb16b2..361e79e13dacc765283b2736324f365400e9860e 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
||||
@@ -107,7 +107,9 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
||||
@@ -120,7 +120,9 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
||||
|
||||
private boolean tryComputePath(Mob entity, WalkTarget walkTarget, long time) {
|
||||
BlockPos blockPos = walkTarget.getTarget().currentBlockPosition();
|
||||
+ if (io.papermc.paper.util.TickThread.isTickThreadFor((ServerLevel) entity.level(), blockPos)) // Kaiiju - Don't pathfind outside region
|
||||
+ if (ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor((ServerLevel) entity.level(), blockPos)) // Kaiiju - Don't pathfind outside region
|
||||
this.path = entity.getNavigation().createPath(blockPos, 0);
|
||||
+ else this.path = null; // Kaiiju - Don't pathfind outside region
|
||||
this.speedModifier = walkTarget.getSpeedModifier();
|
||||
@@ -0,0 +1,66 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Mon, 5 Aug 2024 14:48:18 +0800
|
||||
Subject: [PATCH] Kaiiju Vanilla end portal teleportation
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index bacc88b735619998927c59ce7b828bfff7574fa8..87c2bb5794cf87a5f048779633de0d0bf2f16d5d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -109,6 +109,7 @@ import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.border.WorldBorder;
|
||||
+import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.entity.EntityAccess;
|
||||
import net.minecraft.world.level.entity.EntityInLevelCallback;
|
||||
import net.minecraft.world.level.gameevent.DynamicGameEventListener;
|
||||
@@ -4230,13 +4231,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
targetPos, 16, // load 16 blocks to be safe from block physics
|
||||
ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.HIGH,
|
||||
(chunks) -> {
|
||||
- net.minecraft.world.level.levelgen.feature.EndPlatformFeature.createEndPlatform(destination, targetPos.below(), true, null);
|
||||
+ //net.minecraft.world.level.levelgen.feature.EndPlatformFeature.createEndPlatform(destination, targetPos.below(), true, null); // Kaiiju - Vanilla end teleportation - moved down
|
||||
|
||||
+ // Kaiiju start - Vanilla end teleportation
|
||||
+ Vec3 finalPos;
|
||||
+ if (this instanceof Player) finalPos = Vec3.atBottomCenterOf(targetPos.below());
|
||||
+ else finalPos = Vec3.atBottomCenterOf(targetPos);
|
||||
+ // Kaiiju end
|
||||
// the portal obsidian is placed at targetPos.y - 2, so if we want to place the entity
|
||||
// on the obsidian, we need to spawn at targetPos.y - 1
|
||||
portalInfoCompletable.complete(
|
||||
new net.minecraft.world.level.portal.DimensionTransition(
|
||||
- destination, Vec3.atBottomCenterOf(targetPos.below()), Vec3.ZERO, 90.0f, 0.0f,
|
||||
+ destination, finalPos, this.getDeltaMovement(), 90.0f, 0.0f, // Kaiiju - Vanilla end teleportation
|
||||
DimensionTransition.PLAY_PORTAL_SOUND.then(DimensionTransition.PLACE_PORTAL_TICKET),
|
||||
org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL
|
||||
)
|
||||
@@ -4433,6 +4439,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
if (!this.canPortalAsync(destination, takePassengers)) {
|
||||
return false;
|
||||
}
|
||||
+ // Kaiiju start - sync end platform spawning & entity teleportation
|
||||
+ final java.util.function.Consumer<Entity> tpComplete = type == PortalType.END && destination.getTypeKey() == LevelStem.END ?
|
||||
+ e -> net.minecraft.world.level.levelgen.feature.EndPlatformFeature.createEndPlatform(destination, ServerLevel.END_SPAWN_POINT.below(), true, null) : teleportComplete;
|
||||
+ // Kaiiju end
|
||||
|
||||
Vec3 initialPosition = this.position();
|
||||
ChunkPos initialPositionChunk = new ChunkPos(
|
||||
@@ -4497,9 +4507,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
info.postDimensionTransition().onTransition(teleported);
|
||||
}
|
||||
|
||||
- if (teleportComplete != null) {
|
||||
+ // Kaiiju start - vanilla end teleportation
|
||||
+ /*if (teleportComplete != null) {
|
||||
teleportComplete.accept(teleported);
|
||||
+ }*/
|
||||
+ if (tpComplete != null){
|
||||
+ tpComplete.accept(teleported);
|
||||
}
|
||||
+ // Kaiiju end
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 04:46:30 +0000
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 12:41:14 +0800
|
||||
Subject: [PATCH] Petal Reduce sensor work
|
||||
|
||||
|
||||
@@ -33,20 +33,21 @@ index 0000000000000000000000000000000000000000..dd45cf1fde5ee4cf8347064f106c64b8
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index 67210fc018349ab0a79740dee140fb60c82c431a..b90865dbfb3a4bd83e4cd3ba3b5b965036039f98 100644
|
||||
index 1cb0029739a487d930e4f10371c82d3a03a46de4..a98d47cb24b2664a497863fc0676b2ef95a89ab2 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -927,10 +927,11 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||
@@ -940,12 +940,12 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
return;
|
||||
}
|
||||
// Paper end - Allow nerfed mobs to jump and float
|
||||
+ int i = this.tickCount + this.getId(); // Folia - region threading //Luminol - Petal - Move up
|
||||
+
|
||||
this.level().getProfiler().push("sensing");
|
||||
+ int i = this.tickCount + this.getId(); //Luminol - Petal - Move up
|
||||
ProfilerFiller gameprofilerfiller = this.level().getProfiler();
|
||||
|
||||
gameprofilerfiller.push("sensing");
|
||||
- this.sensing.tick();
|
||||
+ if (i % me.earthme.luminol.config.modules.optimizations.PetalReduceSensorWorkConfig.delayTicks == 0 || !me.earthme.luminol.config.modules.optimizations.PetalReduceSensorWorkConfig.enabled)this.sensing.tick(); //Luminol - Petal - Reduce sensor work
|
||||
this.level().getProfiler().pop();
|
||||
- int i = this.tickCount + this.getId(); // Folia - region threading
|
||||
+ if (i % me.earthme.luminol.config.modules.optimizations.PetalReduceSensorWorkConfig.delayTicks == 0 || !me.earthme.luminol.config.modules.optimizations.PetalReduceSensorWorkConfig.enabled) this.sensing.tick(); // Luminol - Petal - Reduce sensor work
|
||||
gameprofilerfiller.pop();
|
||||
- int i = this.tickCount + this.getId();
|
||||
|
||||
if (i % 2 != 0 && this.tickCount > 1) {
|
||||
this.level().getProfiler().push("targetSelector");
|
||||
gameprofilerfiller.push("targetSelector");
|
||||
@@ -1,6 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16:00:59 +0800
|
||||
From: Paul Sauve <paul@technove.co>
|
||||
Date: Wed, 14 Apr 2021 22:58:15 -0500
|
||||
Subject: [PATCH] Pufferfish Improve fluid direction caching
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ index 0000000000000000000000000000000000000000..aa8467b9dda1f7707e41f50ac7b3e9d7
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||
index 6d8ff6c06af5545634f255ed17dc1e489ece2548..6411aa4ff6bd4cabb25c426fa8f4a7eedb969c03 100644
|
||||
index 1c0712295695727ee9c4d430d4157b8e17cbd71f..6785baf574f233ed1c3bea8d406be8a524d9ff82 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||
@@ -45,6 +45,8 @@ public abstract class FlowingFluid extends Fluid {
|
||||
@@ -174,16 +174,16 @@ index 6d8ff6c06af5545634f255ed17dc1e489ece2548..6411aa4ff6bd4cabb25c426fa8f4a7ee
|
||||
private final Map<FluidState, VoxelShape> shapes = Maps.newIdentityHashMap();
|
||||
|
||||
public FlowingFluid() {}
|
||||
@@ -251,6 +261,8 @@ public abstract class FlowingFluid extends Fluid {
|
||||
return false;
|
||||
}
|
||||
// Paper end - optimise collisions
|
||||
@@ -240,6 +250,8 @@ public abstract class FlowingFluid extends Fluid {
|
||||
}
|
||||
|
||||
private boolean canPassThroughWall(Direction face, BlockGetter world, BlockPos pos, BlockState state, BlockPos fromPos, BlockState fromState) {
|
||||
+ // Pufferfish start - modify to use our cache
|
||||
+ /*
|
||||
Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap;
|
||||
|
||||
if (!state.getBlock().hasDynamicShape() && !fromState.getBlock().hasDynamicShape()) {
|
||||
@@ -258,9 +270,16 @@ public abstract class FlowingFluid extends Fluid {
|
||||
@@ -247,9 +259,16 @@ public abstract class FlowingFluid extends Fluid {
|
||||
} else {
|
||||
object2bytelinkedopenhashmap = null;
|
||||
}
|
||||
@@ -200,7 +200,7 @@ index 6d8ff6c06af5545634f255ed17dc1e489ece2548..6411aa4ff6bd4cabb25c426fa8f4a7ee
|
||||
if (object2bytelinkedopenhashmap != null) {
|
||||
block_a = new Block.BlockStatePairKey(state, fromState, face);
|
||||
byte b0 = object2bytelinkedopenhashmap.getAndMoveToFirst(block_a);
|
||||
@@ -271,11 +290,22 @@ public abstract class FlowingFluid extends Fluid {
|
||||
@@ -260,11 +279,22 @@ public abstract class FlowingFluid extends Fluid {
|
||||
} else {
|
||||
block_a = null;
|
||||
}
|
||||
@@ -223,7 +223,7 @@ index 6d8ff6c06af5545634f255ed17dc1e489ece2548..6411aa4ff6bd4cabb25c426fa8f4a7ee
|
||||
if (object2bytelinkedopenhashmap != null) {
|
||||
if (object2bytelinkedopenhashmap.size() == 200) {
|
||||
object2bytelinkedopenhashmap.removeLastByte();
|
||||
@@ -283,6 +313,11 @@ public abstract class FlowingFluid extends Fluid {
|
||||
@@ -272,6 +302,11 @@ public abstract class FlowingFluid extends Fluid {
|
||||
|
||||
object2bytelinkedopenhashmap.putAndMoveToFirst(block_a, (byte) (flag ? 1 : 0));
|
||||
}
|
||||
@@ -1,27 +1,14 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sun, 14 Jan 2024 00:40:35 +0000
|
||||
From: Paul Sauve <paul@technove.co>
|
||||
Date: Mon, 26 Apr 2021 10:52:56 -0500
|
||||
Subject: [PATCH] Pufferfish Cache climbing check for activation
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index d955a555d260d39812b84eb5319db619ec0f8d28..7834646fd6a894ff85973566d9aeda98e5b0c284 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -311,7 +311,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
public double yo;
|
||||
public double zo;
|
||||
private Vec3 position;
|
||||
- private BlockPos blockPosition;
|
||||
+ public BlockPos blockPosition; // Pufferfish - private->public
|
||||
private ChunkPos chunkPosition;
|
||||
private Vec3 deltaMovement;
|
||||
private float yRot;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index fdb5ef574c14fafa1af50f4f656763119695f00e..bbfbeddcba884ae1964f7421fcdf179923bd0d2b 100644
|
||||
index 9b8fd458c851d72901568845d973330ed58260a9..33ecd65a2787741cc0611ad3100a1bf9d2ce0338 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -143,7 +143,6 @@ import org.bukkit.event.entity.EntityTeleportEvent;
|
||||
@@ -157,7 +157,6 @@ import org.bukkit.event.entity.EntityTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
@@ -29,7 +16,7 @@ index fdb5ef574c14fafa1af50f4f656763119695f00e..bbfbeddcba884ae1964f7421fcdf1799
|
||||
|
||||
public abstract class LivingEntity extends Entity implements Attackable {
|
||||
|
||||
@@ -2043,6 +2042,20 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -2084,6 +2083,20 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
return this.lastClimbablePos;
|
||||
}
|
||||
|
||||
@@ -51,15 +38,15 @@ index fdb5ef574c14fafa1af50f4f656763119695f00e..bbfbeddcba884ae1964f7421fcdf1799
|
||||
if (this.isSpectator()) {
|
||||
return false;
|
||||
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
index f8718d91f4c15c74d6e6dd5f60f7f05f45f63655..50fafff765b2494c075784cc5342d086c8dc97b2 100644
|
||||
index d12f9586602769bd0c692f1cf5820b008cb4bc51..2d26c8109cb942d1856455fd0239290ee1142eb3 100644
|
||||
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
||||
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
@@ -305,7 +305,7 @@ public class ActivationRange
|
||||
@@ -307,7 +307,7 @@ public class ActivationRange
|
||||
if ( entity instanceof LivingEntity )
|
||||
{
|
||||
LivingEntity living = (LivingEntity) entity;
|
||||
- if ( living.onClimbable() || living.jumping || living.hurtTime > 0 || living.activeEffects.size() > 0 || living.isFreezing()) // Paper
|
||||
+ if ( living.onClimableCached() || living.jumping || living.hurtTime > 0 || living.activeEffects.size() > 0 || living.isFreezing()) // Paper // Pufferfish - use cached
|
||||
+ if ( living.onClimableCached() || living.jumping || living.hurtTime > 0 || living.activeEffects.size() > 0 || living.isFreezing() ) // Paper // Pufferfish - use cached
|
||||
{
|
||||
return 1; // Paper
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16:10:26 +0800
|
||||
Subject: [PATCH] Pufferfish Reduce entity fluid lookups if no fluids
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 7834646fd6a894ff85973566d9aeda98e5b0c284..21284dba89c8adbb46086afd9a900fb24ba3e3ea 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -5262,16 +5262,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
}
|
||||
|
||||
public boolean updateFluidHeightAndDoFluidPushing(TagKey<Fluid> tag, double speed) {
|
||||
- if (this.touchingUnloadedChunk()) {
|
||||
+ if (false && this.touchingUnloadedChunk()) { // Pufferfish - cost of a lookup here is the same cost as below, so skip
|
||||
return false;
|
||||
} else {
|
||||
AABB axisalignedbb = this.getBoundingBox().deflate(0.001D);
|
||||
- int i = Mth.floor(axisalignedbb.minX);
|
||||
- int j = Mth.ceil(axisalignedbb.maxX);
|
||||
- int k = Mth.floor(axisalignedbb.minY);
|
||||
- int l = Mth.ceil(axisalignedbb.maxY);
|
||||
- int i1 = Mth.floor(axisalignedbb.minZ);
|
||||
- int j1 = Mth.ceil(axisalignedbb.maxZ);
|
||||
+ // Pufferfish start - rename
|
||||
+ int minBlockX = Mth.floor(axisalignedbb.minX);
|
||||
+ int maxBlockX = Mth.ceil(axisalignedbb.maxX);
|
||||
+ int minBlockY = Mth.floor(axisalignedbb.minY);
|
||||
+ int maxBlockY = Mth.ceil(axisalignedbb.maxY);
|
||||
+ int minBlockZ = Mth.floor(axisalignedbb.minZ);
|
||||
+ int maxBlockZ = Mth.ceil(axisalignedbb.maxZ);
|
||||
+ // Pufferfish end
|
||||
double d1 = 0.0D;
|
||||
boolean flag = this.isPushedByFluid();
|
||||
boolean flag1 = false;
|
||||
@@ -5279,14 +5281,61 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
int k1 = 0;
|
||||
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
|
||||
|
||||
- for (int l1 = i; l1 < j; ++l1) {
|
||||
- for (int i2 = k; i2 < l; ++i2) {
|
||||
- for (int j2 = i1; j2 < j1; ++j2) {
|
||||
- blockposition_mutableblockposition.set(l1, i2, j2);
|
||||
- FluidState fluid = this.level().getFluidState(blockposition_mutableblockposition);
|
||||
+ // Pufferfish start - based off CollisionUtil.getCollisionsForBlocksOrWorldBorder
|
||||
+ final int minSection = io.papermc.paper.util.WorldUtil.getMinSection(this.level());
|
||||
+ final int maxSection = io.papermc.paper.util.WorldUtil.getMaxSection(this.level());
|
||||
+ final int minBlock = minSection << 4;
|
||||
+ final int maxBlock = (maxSection << 4) | 15;
|
||||
+
|
||||
+ // special cases:
|
||||
+ if (minBlockY > maxBlock || maxBlockY < minBlock) {
|
||||
+ // no point in checking
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ int minYIterate = Math.max(minBlock, minBlockY);
|
||||
+ int maxYIterate = Math.min(maxBlock, maxBlockY);
|
||||
+
|
||||
+ int minChunkX = minBlockX >> 4;
|
||||
+ int maxChunkX = maxBlockX >> 4;
|
||||
+
|
||||
+ int minChunkZ = minBlockZ >> 4;
|
||||
+ int maxChunkZ = maxBlockZ >> 4;
|
||||
+
|
||||
+ for (int currChunkZ = minChunkZ; currChunkZ <= maxChunkZ; ++currChunkZ) {
|
||||
+ int minZ = currChunkZ == minChunkZ ? minBlockZ & 15 : 0; // coordinate in chunk
|
||||
+ int maxZ = currChunkZ == maxChunkZ ? maxBlockZ & 15 : 16; // coordinate in chunk
|
||||
+
|
||||
+ for (int currChunkX = minChunkX; currChunkX <= maxChunkX; ++currChunkX) {
|
||||
+ int minX = currChunkX == minChunkX ? minBlockX & 15 : 0; // coordinate in chunk
|
||||
+ int maxX = currChunkX == maxChunkX ? maxBlockX & 15 : 16; // coordinate in chunk
|
||||
+
|
||||
+ net.minecraft.world.level.chunk.ChunkAccess chunk = this.level().getChunkIfLoadedImmediately(currChunkX, currChunkZ);
|
||||
+ if (chunk == null) {
|
||||
+ return false; // if we're touching an unloaded chunk then it's false
|
||||
+ }
|
||||
+
|
||||
+ net.minecraft.world.level.chunk.LevelChunkSection[] sections = chunk.getSections();
|
||||
+
|
||||
+ for (int currY = minYIterate; currY < maxYIterate; ++currY) {
|
||||
+ net.minecraft.world.level.chunk.LevelChunkSection section = sections[(currY >> 4) - minSection];
|
||||
+
|
||||
+ if (section == null || section.hasOnlyAir() || section.fluidStateCount == 0) { // if no fluids, nothing in this section
|
||||
+ // empty
|
||||
+ // skip to next section
|
||||
+ currY = (currY & ~(15)) + 15; // increment by 15: iterator loop increments by the extra one
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ net.minecraft.world.level.chunk.PalettedContainer<BlockState> blocks = section.states;
|
||||
+
|
||||
+ for (int currZ = minZ; currZ < maxZ; ++currZ) {
|
||||
+ for (int currX = minX; currX < maxX; ++currX) {
|
||||
+ FluidState fluid = blocks.get(currX & 15, currY & 15, currZ & 15).getFluidState();
|
||||
|
||||
if (fluid.is(tag)) {
|
||||
- double d2 = (double) ((float) i2 + fluid.getHeight(this.level(), blockposition_mutableblockposition));
|
||||
+ blockposition_mutableblockposition.set((currChunkX << 4) + currX, currY, (currChunkZ << 4) + currZ);
|
||||
+ double d2 = (double) ((float) currY + fluid.getHeight(this.level(), blockposition_mutableblockposition));
|
||||
|
||||
if (d2 >= axisalignedbb.minY) {
|
||||
flag1 = true;
|
||||
@@ -5308,9 +5357,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
// CraftBukkit end
|
||||
}
|
||||
}
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
}
|
||||
}
|
||||
+ // Pufferfish end
|
||||
|
||||
if (vec3d.length() > 0.0D) {
|
||||
if (k1 > 0) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
index 796bbef3544e06b8e7aac7e8ac5f740a2613f4bd..2422ca3ffc6ab7178cacf933b8013f85e7de4bd9 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
@@ -25,6 +25,7 @@ public class LevelChunkSection {
|
||||
public final PalettedContainer<BlockState> states;
|
||||
// CraftBukkit start - read/write
|
||||
private PalettedContainer<Holder<Biome>> biomes;
|
||||
+ public short fluidStateCount; // Pufferfish
|
||||
public final com.destroystokyo.paper.util.maplist.IBlockDataList tickingList = new com.destroystokyo.paper.util.maplist.IBlockDataList(); // Paper
|
||||
// Paper start - optimise collisions
|
||||
private int specialCollidingBlocks;
|
||||
@@ -102,6 +103,7 @@ public class LevelChunkSection {
|
||||
|
||||
if (!fluid.isEmpty()) {
|
||||
--this.tickingFluidCount;
|
||||
+ --this.fluidStateCount; // Pufferfish
|
||||
}
|
||||
|
||||
if (!state.isAir()) {
|
||||
@@ -116,6 +118,7 @@ public class LevelChunkSection {
|
||||
|
||||
if (!fluid1.isEmpty()) {
|
||||
++this.tickingFluidCount;
|
||||
+ ++this.fluidStateCount; // Pufferfish
|
||||
}
|
||||
|
||||
this.updateBlockCallback(x, y, z, iblockdata1, state); // Paper - optimise collisions
|
||||
@@ -162,6 +165,7 @@ public class LevelChunkSection {
|
||||
if (fluid.isRandomlyTicking()) {
|
||||
this.tickingFluidCount = (short) (this.tickingFluidCount + 1);
|
||||
}
|
||||
+ this.fluidStateCount++; // Pufferfish
|
||||
}
|
||||
|
||||
// Paper start - optimise collisions
|
||||
@@ -1,14 +1,14 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16:07:56 +0800
|
||||
From: Paul Sauve <paul@technove.co>
|
||||
Date: Thu, 4 Feb 2021 23:33:52 -0600
|
||||
Subject: [PATCH] Pufferfish Reduce chunk loading & lookups
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
||||
index f33c03e81b7ff643741f56eea055e6af260de618..6563e625ebae47fc68e5010d36bd4b4d327c07b7 100644
|
||||
index 828c51477cd8f35d591367b30bf4feef6a250292..ace4959f818bf56882b290d109b8b97f2c145631 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
||||
@@ -333,11 +333,17 @@ public class EnderMan extends Monster implements NeutralMob {
|
||||
@@ -320,11 +320,17 @@ public class EnderMan extends Monster implements NeutralMob {
|
||||
private boolean teleport(double x, double y, double z) {
|
||||
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(x, y, z);
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Tue, 6 Feb 2024 03:17:39 +0000
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 13:10:18 +0800
|
||||
Subject: [PATCH] Pufferfish Early return optimization for target finding
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
|
||||
index c8a80c1b2fedff22e8a877d466062375ffb2f0d7..3c4f4af85a3f2d4f9f52827164e63727b916c33a 100644
|
||||
index aecb0ad814586bfc5e56755ee14379a69388b38c..6381ef1385f85f0f576ad55b3b58dd62c0823f1c 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
|
||||
@@ -75,9 +75,18 @@ public class TargetingConditions {
|
||||
@@ -76,9 +76,18 @@ public class TargetingConditions {
|
||||
}
|
||||
|
||||
if (this.range > 0.0D) {
|
||||
- double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0D;
|
||||
- double e = Math.max((this.useFollowRange ? this.getFollowRange(baseEntity) : this.range) * d, 2.0D); // Paper - Fix MC-145656
|
||||
if (this.range > 0.0) {
|
||||
- double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0;
|
||||
- double e = Math.max((this.useFollowRange ? this.getFollowRange(baseEntity) : this.range) * d, 2.0); // Paper - Fix MC-145656
|
||||
+ // Pufferfish start - check range before getting visibility
|
||||
+ // d = invisibility percent, e = follow range adjusted for invisibility, f = distance
|
||||
double f = baseEntity.distanceToSqr(targetEntity.getX(), targetEntity.getY(), targetEntity.getZ());
|
||||
@@ -23,8 +23,8 @@ index c8a80c1b2fedff22e8a877d466062375ffb2f0d7..3c4f4af85a3f2d4f9f52827164e63727
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0D;
|
||||
+ double e = Math.max((followRangeRaw) * d, 2.0D); // Paper
|
||||
+ double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0;
|
||||
+ double e = Math.max((followRangeRaw) * d, 2.0D); // Paper - Fix MC-145656
|
||||
+ // Pufferfish end
|
||||
if (f > e * e) {
|
||||
return false;
|
||||
@@ -1,16 +1,16 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Tue, 6 Feb 2024 03:21:56 +0000
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 13:10:52 +0800
|
||||
Subject: [PATCH] Pufferfish Fix Paper#6045, block goal shouldn't load chunks
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
|
||||
index 07519c817cc6de04a98198c43a0c2b02ba3141eb..ee66be6e5aa45ec8448b6d30785a6e71200b09e3 100644
|
||||
index aee0147649d458b87d92496eda0c1723ebe570d2..89e9ea999d2fbd81a1d74382ef3fcd675fc8b94e 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
|
||||
@@ -120,6 +120,7 @@ public abstract class MoveToBlockGoal extends Goal {
|
||||
for(int m = 0; m <= l; m = m > 0 ? -m : 1 - m) {
|
||||
for(int n = m < l && m > -l ? l : 0; n <= l; n = n > 0 ? -n : 1 - n) {
|
||||
@@ -121,6 +121,7 @@ public abstract class MoveToBlockGoal extends Goal {
|
||||
for (int m = 0; m <= l; m = m > 0 ? -m : 1 - m) {
|
||||
for (int n = m < l && m > -l ? l : 0; n <= l; n = n > 0 ? -n : 1 - n) {
|
||||
mutableBlockPos.setWithOffset(blockPos, m, k - 1, n);
|
||||
+ if (!this.mob.level().hasChunkAt(mutableBlockPos)) continue; // Pufferfish - if this block isn't loaded, continue
|
||||
if (this.mob.isWithinRestriction(mutableBlockPos) && this.isValidTarget(this.mob.level(), mutableBlockPos)) {
|
||||
@@ -0,0 +1,23 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Paul <paul@technove.co>
|
||||
Date: Tue, 29 Jun 2021 02:24:23 -0500
|
||||
Subject: [PATCH] Pufferfish Skip cloning loot parameters
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/storage/loot/LootParams.java b/src/main/java/net/minecraft/world/level/storage/loot/LootParams.java
|
||||
index 37a0002bbe6539648db5219bb373e0404ae48dc0..ca0571d232e102c4b177a1ea44b96f5f0f440211 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/storage/loot/LootParams.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/storage/loot/LootParams.java
|
||||
@@ -21,8 +21,10 @@ public class LootParams {
|
||||
|
||||
public LootParams(ServerLevel world, Map<LootContextParam<?>, Object> parameters, Map<ResourceLocation, LootParams.DynamicDrop> dynamicDrops, float luck) {
|
||||
this.level = world;
|
||||
- this.params = parameters;
|
||||
- this.dynamicDrops = dynamicDrops;
|
||||
+ // Pufferfish start - use unmodifiable maps instead of immutable ones to skip the copy
|
||||
+ this.params = java.util.Collections.unmodifiableMap(parameters);
|
||||
+ this.dynamicDrops = java.util.Collections.unmodifiableMap(dynamicDrops);
|
||||
+ // Pufferfish end
|
||||
this.luck = luck;
|
||||
}
|
||||
|
||||
@@ -33,46 +33,41 @@ index 0000000000000000000000000000000000000000..12683ec5a5102e45b6171fea0b833ba5
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
index 10d7c64fb3a9bafdcdae99f8dc87017722341337..c366da764e2e11018460430595c14b17480c6da7 100644
|
||||
index 0e831070fe7a9ac58de4b25b74a53b38334c695a..2f0a40134ef2fcccf407a5381994c3454040097e 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
@@ -4,6 +4,8 @@ import com.google.common.base.MoreObjects;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import io.papermc.paper.threadedregions.TickRegionScheduler;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
@@ -45,6 +47,36 @@ public abstract class Projectile extends Entity implements TraceableEntity {
|
||||
@@ -52,6 +52,40 @@ public abstract class Projectile extends Entity implements TraceableEntity {
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
+ // Pufferfish start
|
||||
+ private static long loadedThisTick = 0;
|
||||
+ private static long loadedTick;
|
||||
+ private static final java.lang.ThreadLocal<Long> loadedThisTick = java.lang.ThreadLocal.withInitial(() -> 0L);
|
||||
+ private static final java.lang.ThreadLocal<Long> loadedTick = java.lang.ThreadLocal.withInitial(() -> 0L);
|
||||
+
|
||||
+ private int loadedLifetime = 0;
|
||||
+ @Override
|
||||
+ public void setPos(double x, double y, double z) {
|
||||
+ long currentTick = TickRegionScheduler.getCurrentRegion().getData().getCurrentTick();
|
||||
+ if (loadedTick != currentTick) {
|
||||
+ loadedTick = currentTick;
|
||||
+ loadedThisTick = 0;
|
||||
+ }
|
||||
+ int previousX = Mth.floor(this.getX()) >> 4, previousZ = Mth.floor(this.getZ()) >> 4;
|
||||
+ int newX = Mth.floor(x) >> 4, newZ = Mth.floor(z) >> 4;
|
||||
+ if (previousX != newX || previousZ != newZ) {
|
||||
+ boolean isLoaded = ((net.minecraft.server.level.ServerChunkCache) this.level().getChunkSource()).getChunkAtIfLoadedMainThread(newX, newZ) != null;
|
||||
+ if (!isLoaded) {
|
||||
+ if (Projectile.loadedThisTick > me.earthme.luminol.config.modules.optimizations.ProjectileChunkReduceConfig.maxProjectileLoadsPerTick) {
|
||||
+ if (++this.loadedLifetime > me.earthme.luminol.config.modules.optimizations.ProjectileChunkReduceConfig.maxProjectileLoadsPerProjectile) {
|
||||
+ this.discard();
|
||||
+ if (io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegion() != null && ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(this)){
|
||||
+ long currentTick = io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegion().getData().getCurrentTick();
|
||||
+
|
||||
+ if (loadedTick.get() != currentTick) {
|
||||
+ loadedTick.set(currentTick);
|
||||
+ loadedThisTick.set(0L);
|
||||
+ }
|
||||
+
|
||||
+ int previousX = Mth.floor(this.getX()) >> 4, previousZ = Mth.floor(this.getZ()) >> 4;
|
||||
+ int newX = Mth.floor(x) >> 4, newZ = Mth.floor(z) >> 4;
|
||||
+ if ((previousX != newX || previousZ != newZ) && ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(this.level(), newX, newZ)) {
|
||||
+ boolean isLoaded = ((net.minecraft.server.level.ServerChunkCache) this.level().getChunkSource()).getChunkAtIfCachedImmediately(newX, newZ) != null;
|
||||
+ if (!isLoaded) {
|
||||
+ if (Projectile.loadedThisTick.get() > me.earthme.luminol.config.modules.optimizations.ProjectileChunkReduceConfig.maxProjectileLoadsPerTick) {
|
||||
+ if (++this.loadedLifetime > me.earthme.luminol.config.modules.optimizations.ProjectileChunkReduceConfig.maxProjectileLoadsPerProjectile) {
|
||||
+ this.discard();
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ return;
|
||||
+ Projectile.loadedThisTick.set(Projectile.loadedThisTick.get() + 1);
|
||||
+ }
|
||||
+ Projectile.loadedThisTick++;
|
||||
+ }
|
||||
+ }
|
||||
+ super.setPos(x, y, z);
|
||||
@@ -1,6 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 05:19:37 +0000
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 13:20:23 +0800
|
||||
Subject: [PATCH] Pufferfish Entity TTL
|
||||
|
||||
|
||||
@@ -49,10 +49,10 @@ index 0000000000000000000000000000000000000000..15697d69659b6e1e776acf5094684b5f
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 21284dba89c8adbb46086afd9a900fb24ba3e3ea..f8a410e9ed04d9a78d1a6a7e63673b1863d715f2 100644
|
||||
index 87c2bb5794cf87a5f048779633de0d0bf2f16d5d..261bcb9cbb8bda07037f40883ddc5381948c66e1 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -814,6 +814,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -858,6 +858,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
@@ -66,12 +66,12 @@ index 21284dba89c8adbb46086afd9a900fb24ba3e3ea..f8a410e9ed04d9a78d1a6a7e63673b18
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
index f921c159c4f7556daf3c8405241de3607ba251ad..8deae3e95a26f4b42b2c2134e22f9649bd7a5391 100644
|
||||
index c74a01a8551457507441d266b6923b4248560abf..293ec464b1cb4db1734d0c059e59f60bfeb2b7eb 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
@@ -313,6 +313,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
|
||||
private ResourceLocation lootTable;
|
||||
@@ -325,6 +325,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
|
||||
private final EntityDimensions dimensions;
|
||||
private final float spawnDimensionsScale;
|
||||
private final FeatureFlagSet requiredFeatures;
|
||||
+ public int ttl = -1; // Pufferfish
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Tue, 20 Feb 2024 13:11:11 +0000
|
||||
Subject: [PATCH] Pufferfish Reduce entity allocations
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||
index 897d7632ecfea40890433474870dd7a5e534d8ab..683c9693754d1a87b7e8fccc757a0d0963351f60 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||
@@ -23,9 +23,11 @@ public class AttributeMap {
|
||||
private final Map<Attribute, AttributeInstance> attributes = Maps.newHashMap();
|
||||
private final Set<AttributeInstance> dirtyAttributes = Sets.newHashSet();
|
||||
private final AttributeSupplier supplier;
|
||||
+ private final java.util.function.Function<Attribute, AttributeInstance> createInstance; // Pufferfish
|
||||
|
||||
public AttributeMap(AttributeSupplier defaultAttributes) {
|
||||
this.supplier = defaultAttributes;
|
||||
+ this.createInstance = attribute -> this.supplier.createInstance(this::onAttributeModified, attribute); // Pufferfish
|
||||
}
|
||||
|
||||
private void onAttributeModified(AttributeInstance instance) {
|
||||
@@ -45,11 +47,10 @@ public class AttributeMap {
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
+
|
||||
@Nullable
|
||||
public AttributeInstance getInstance(Attribute attribute) {
|
||||
- return this.attributes.computeIfAbsent(attribute, (attributex) -> {
|
||||
- return this.supplier.createInstance(this::onAttributeModified, attributex);
|
||||
- });
|
||||
+ return this.attributes.computeIfAbsent(attribute, this.createInstance); // Pufferfish - cache lambda, as for some reason java allocates it anyways
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1,6 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 05:56:56 +0000
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sun, 4 Aug 2024 21:53:48 +0800
|
||||
Subject: [PATCH] Pufferfish Dynamic Activation of Brain
|
||||
|
||||
|
||||
@@ -71,10 +71,10 @@ index 0000000000000000000000000000000000000000..af5893ba1f738ec9827d7b714682c314
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index da6269249a95d78f91e90416a96bf1b776fd9c97..25a2f23618cd02366f71e704638adfbaed9fa8c5 100644
|
||||
index 94d855f14c91ca164f1728be1df4e83dfed8b005..3ebea71bbc6ced0d0a325c519436a0199666fafb 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -987,6 +987,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
@@ -805,6 +805,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
|
||||
this.timings.entityTick.startTiming(); // Spigot
|
||||
profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_TICK); try { // Folia - profiler
|
||||
regionizedWorldData.forEachTickingEntity((entity) -> { // Folia - regionised ticking
|
||||
@@ -83,26 +83,23 @@ index da6269249a95d78f91e90416a96bf1b776fd9c97..25a2f23618cd02366f71e704638adfba
|
||||
if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed
|
||||
entity.discard();
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index f8a410e9ed04d9a78d1a6a7e63673b1863d715f2..4b3acc0de20b246e20e2cc91ba0eca493a675729 100644
|
||||
index 261bcb9cbb8bda07037f40883ddc5381948c66e1..6497ecce4a826776c487e0e2fcb077f21e02ecda 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -483,6 +483,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -430,6 +430,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
private UUID originWorld;
|
||||
public boolean freezeLocked = false; // Paper - Freeze Tick Lock API
|
||||
public boolean fixedPose = false; // Paper - Expand Pose API
|
||||
+ public boolean activatedPriorityReset = false; // Pufferfish - DAB
|
||||
+ public int activatedPriority = me.earthme.luminol.config.modules.optimizations.EntityDABConfig.maximumActivationPrio; // Pufferfish - DAB (golf score)
|
||||
|
||||
// Folia - region ticking
|
||||
// Paper end - optimise entity tracking
|
||||
+ //Pufferfish start
|
||||
+ public boolean activatedPriorityReset = false; // DAB
|
||||
+ public int activatedPriority = me.earthme.luminol.config.modules.optimizations.EntityDABConfig.maximumActivationPrio; // golf score
|
||||
+ // Pufferfish end
|
||||
+
|
||||
public float getBukkitYaw() {
|
||||
return this.yRot;
|
||||
}
|
||||
public void setOrigin(@javax.annotation.Nonnull Location location) {
|
||||
this.origin = location.toVector();
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
index 8deae3e95a26f4b42b2c2134e22f9649bd7a5391..c09357c1ef84a29d972119cb496b0ae97f98e4f4 100644
|
||||
index 293ec464b1cb4db1734d0c059e59f60bfeb2b7eb..5d3e5262d9b7565ddf045ce9f97ec1904e7b0291 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
@@ -305,6 +305,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
|
||||
@@ -316,6 +316,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
|
||||
private final boolean canSpawnFarFromPlayer;
|
||||
private final int clientTrackingRange;
|
||||
private final int updateInterval;
|
||||
@@ -111,10 +108,10 @@ index 8deae3e95a26f4b42b2c2134e22f9649bd7a5391..c09357c1ef84a29d972119cb496b0ae9
|
||||
private String descriptionId;
|
||||
@Nullable
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index b90865dbfb3a4bd83e4cd3ba3b5b965036039f98..66c581585e6ca58eba0e8b7af0fa1f0c9f924f94 100644
|
||||
index a98d47cb24b2664a497863fc0676b2ef95a89ab2..121e9cbeb07a41febac0086f5fce5a172a4ad15e 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -234,10 +234,10 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||
@@ -244,10 +244,10 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
super.inactiveTick();
|
||||
@@ -127,51 +124,68 @@ index b90865dbfb3a4bd83e4cd3ba3b5b965036039f98..66c581585e6ca58eba0e8b7af0fa1f0c
|
||||
this.targetSelector.tick();
|
||||
}
|
||||
}
|
||||
@@ -935,16 +935,20 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||
@@ -949,16 +949,20 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
|
||||
if (i % 2 != 0 && this.tickCount > 1) {
|
||||
this.level().getProfiler().push("targetSelector");
|
||||
gameprofilerfiller.push("targetSelector");
|
||||
+ if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
||||
this.targetSelector.tickRunningGoals(false);
|
||||
this.level().getProfiler().pop();
|
||||
this.level().getProfiler().push("goalSelector");
|
||||
gameprofilerfiller.pop();
|
||||
gameprofilerfiller.push("goalSelector");
|
||||
+ if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
||||
this.goalSelector.tickRunningGoals(false);
|
||||
this.level().getProfiler().pop();
|
||||
gameprofilerfiller.pop();
|
||||
} else {
|
||||
this.level().getProfiler().push("targetSelector");
|
||||
gameprofilerfiller.push("targetSelector");
|
||||
+ if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
||||
this.targetSelector.tick();
|
||||
this.level().getProfiler().pop();
|
||||
this.level().getProfiler().push("goalSelector");
|
||||
gameprofilerfiller.pop();
|
||||
gameprofilerfiller.push("goalSelector");
|
||||
+ if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
||||
this.goalSelector.tick();
|
||||
this.level().getProfiler().pop();
|
||||
gameprofilerfiller.pop();
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/VillagerPanicTrigger.java b/src/main/java/net/minecraft/world/entity/ai/behavior/VillagerPanicTrigger.java
|
||||
index 758f62416ca9c02351348ac0d41deeb4624abc0e..69130969c9a434ec2361e573c9a1ec9f462dfda2 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/VillagerPanicTrigger.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/VillagerPanicTrigger.java
|
||||
@@ -36,7 +36,11 @@ public class VillagerPanicTrigger extends Behavior<Villager> {
|
||||
|
||||
@Override
|
||||
protected void tick(ServerLevel world, Villager entity, long time) {
|
||||
- if (time % 100L == 0L) {
|
||||
+ // Pufferfish start
|
||||
+ if (entity.nextGolemPanic < 0) entity.nextGolemPanic = time + 100;
|
||||
+ if (--entity.nextGolemPanic < time) {
|
||||
+ entity.nextGolemPanic = -1;
|
||||
+ // Pufferfish end
|
||||
entity.spawnGolemIfNeeded(world, time, 3);
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
||||
index 676f5485a4ca9252e911213dcda8d51776b637b6..0f53c206b4c0607e2cda5cfa4edeae5209e897bf 100644
|
||||
index 9bdbf3e9453bc3ce96d52d04b8cde0d05f7356d8..f2da2efb694ee7750720670938cce98720ba2666 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
||||
@@ -53,9 +53,12 @@ public class GoalSelector {
|
||||
@@ -43,9 +43,12 @@ public class GoalSelector {
|
||||
}
|
||||
|
||||
// Paper start
|
||||
- public boolean inactiveTick() {
|
||||
+ public boolean inactiveTick(int tickRate, boolean inactive) { // Pufferfish start
|
||||
+ if (inactive && !me.earthme.luminol.config.modules.optimizations.EntityDABConfig.dearEnabled) tickRate = 4; // reset to Paper's
|
||||
+ tickRate = Math.min(tickRate, this.newGoalRate);
|
||||
+ tickRate = Math.min(tickRate, 3);
|
||||
this.curRate++;
|
||||
- return this.curRate % this.newGoalRate == 0;
|
||||
+ return this.curRate % tickRate == 0;
|
||||
- return this.curRate % 3 == 0; // TODO newGoalRate was already unused in 1.20.4, check if this is correct
|
||||
+ return this.curRate % tickRate == 0; // TODO newGoalRate was already unused in 1.20.4, check if this is correct
|
||||
+ // Pufferfish end
|
||||
}
|
||||
public boolean hasTasks() {
|
||||
for (WrappedGoal task : this.availableGoals) {
|
||||
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 5ad5f22e5aa26445e5eb229958e7bf356bdd460e..d241ca4d0295f9fce39c11197bd435cfac7f6e54 100644
|
||||
index 69986f75d3cf729204cca0c7e5428536af31f695..98a759dbe46e2ead39af0f340c9b73c8f4ddce1e 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
|
||||
@@ -221,9 +221,11 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS
|
||||
@@ -217,9 +217,11 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS
|
||||
return 0.4F;
|
||||
}
|
||||
|
||||
@@ -184,10 +198,10 @@ index 5ad5f22e5aa26445e5eb229958e7bf356bdd460e..d241ca4d0295f9fce39c11197bd435cf
|
||||
this.level().getProfiler().pop();
|
||||
this.level().getProfiler().push("allayActivityUpdate");
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
index b21e180641d17438997a80e5bcb0ec7998d24a2e..33c160994f70f71446d665e7487913437c9f9db4 100644
|
||||
index 01a0731e92d39c8718538244e34a271fb8717fc2..44937570f8e968ba4fe2822f69ca8f09679da89d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
@@ -275,9 +275,11 @@ public class Axolotl extends Animal implements LerpingModel, VariantHolder<Axolo
|
||||
@@ -269,9 +269,11 @@ public class Axolotl extends Animal implements LerpingModel, VariantHolder<Axolo
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -200,11 +214,11 @@ index b21e180641d17438997a80e5bcb0ec7998d24a2e..33c160994f70f71446d665e748791343
|
||||
this.level().getProfiler().pop();
|
||||
this.level().getProfiler().push("axolotlActivityUpdate");
|
||||
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 580da502c62ec5d669cb09932d99d1c7d711c965..b94d775e366f5cb251e9199ff5022ad53129da76 100644
|
||||
index 816977990639ec0559b652fc9666afd5046f0a5d..714703519965e8dae42be7442f292b581cc7c049 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
|
||||
@@ -159,9 +159,11 @@ public class Frog extends Animal implements VariantHolder<FrogVariant> {
|
||||
|
||||
@@ -181,9 +181,11 @@ public class Frog extends Animal implements VariantHolder<Holder<FrogVariant>> {
|
||||
.ifPresent(this::setVariant);
|
||||
}
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@@ -216,10 +230,10 @@ index 580da502c62ec5d669cb09932d99d1c7d711c965..b94d775e366f5cb251e9199ff5022ad5
|
||||
this.level().getProfiler().pop();
|
||||
this.level().getProfiler().push("frogActivityUpdate");
|
||||
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 958816ce2166248b542c96c10c398a52d769b4db..415afe3473d9f8a50b1edab8cfda6158e59836e6 100644
|
||||
index 43046f4a0cff620834ac4647efdcde227185b2ff..90393485ebcf8a4c8c74802fff942b1af8cfbf00 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
|
||||
@@ -80,9 +80,11 @@ public class Tadpole extends AbstractFish {
|
||||
@@ -83,9 +83,11 @@ public class Tadpole extends AbstractFish {
|
||||
return SoundEvents.TADPOLE_FLOP;
|
||||
}
|
||||
|
||||
@@ -232,10 +246,10 @@ index 958816ce2166248b542c96c10c398a52d769b4db..415afe3473d9f8a50b1edab8cfda6158
|
||||
this.level().getProfiler().pop();
|
||||
this.level().getProfiler().push("tadpoleActivityUpdate");
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
index 5d247ac38fe8a61603b3d934f3000bcda773142b..2e4177cfb02616ef6fa689f6d378976e39484cfb 100644
|
||||
index 376bcbc189008464f4d518c1e07643431ba96306..07bdea8a7d6706839a758afe0242202c7e841416 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
@@ -191,9 +191,11 @@ public class Goat extends Animal {
|
||||
@@ -190,9 +190,11 @@ public class Goat extends Animal {
|
||||
return (Brain<Goat>) super.getBrain(); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@@ -248,11 +262,11 @@ index 5d247ac38fe8a61603b3d934f3000bcda773142b..2e4177cfb02616ef6fa689f6d378976e
|
||||
this.level().getProfiler().pop();
|
||||
this.level().getProfiler().push("goatActivityUpdate");
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java b/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
||||
index 01a2016ac82807d28ffe407b7dbb74bdbcde503e..9921b160fb21f72fbd28fe81ea66fbc3dc05f83f 100644
|
||||
index d5e0c493f4c348724958193795ceb987765a465f..7de73564bc73d6504e18977e97a2ef5f46189e15 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
||||
@@ -128,9 +128,11 @@ public class Hoglin extends Animal implements Enemy, HoglinBase {
|
||||
return (Brain<Hoglin>) super.getBrain(); // Paper - decompile fix
|
||||
@@ -153,9 +153,11 @@ public class Hoglin extends Animal implements Enemy, HoglinBase {
|
||||
return (Brain<Hoglin>)super.getBrain();
|
||||
}
|
||||
|
||||
+ private int behaviorTick; // Pufferfish
|
||||
@@ -264,10 +278,10 @@ index 01a2016ac82807d28ffe407b7dbb74bdbcde503e..9921b160fb21f72fbd28fe81ea66fbc3
|
||||
this.level().getProfiler().pop();
|
||||
HoglinAi.updateActivity(this);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java b/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||
index a9813da7f2b248f98f22e0ad2e7842915025ec12..83d83e3f84bb6bd58761671c6cd4c8683545ff4c 100644
|
||||
index bc58323801ee16fe9b63c21332144ec002a902f2..b2ae7088f90bf3cd04a59c6ddfdba60c58c6e1c8 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||
@@ -300,9 +300,11 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento
|
||||
@@ -293,9 +293,11 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento
|
||||
return !this.cannotHunt;
|
||||
}
|
||||
|
||||
@@ -280,10 +294,10 @@ index a9813da7f2b248f98f22e0ad2e7842915025ec12..83d83e3f84bb6bd58761671c6cd4c868
|
||||
this.level().getProfiler().pop();
|
||||
PiglinAi.updateActivity(this);
|
||||
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 7aadd36f0fe986635b495ab8c1426644620400cf..0c947d7509d66647327bce885ad2c6051f41c56f 100644
|
||||
index 38bf417a9ad4647f4af24d969f3bf4fed9c4bad7..40bbd80b1ed4afede6f0769e7f3fcfc61200452f 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
|
||||
@@ -273,11 +273,13 @@ public class Warden extends Monster implements VibrationSystem {
|
||||
@@ -272,11 +272,13 @@ public class Warden extends Monster implements VibrationSystem {
|
||||
|
||||
}
|
||||
|
||||
@@ -298,7 +312,7 @@ index 7aadd36f0fe986635b495ab8c1426644620400cf..0c947d7509d66647327bce885ad2c605
|
||||
this.level().getProfiler().pop();
|
||||
super.customServerAiStep();
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
index 3eeff0cd8563939c656b5ded8470cab016903f25..90d8cd94d987416a3e9f6e6d47a5b366d4687fe0 100644
|
||||
index 91728a992a29bc22e46a260750d5dd88e629bfd1..3f4e4b612e127e51b240bca8776f6fc3743bd2d7 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
@@ -143,6 +143,8 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -332,7 +346,7 @@ index 3eeff0cd8563939c656b5ded8470cab016903f25..90d8cd94d987416a3e9f6e6d47a5b366
|
||||
if (this.assignProfessionWhenSpawned) {
|
||||
this.assignProfessionWhenSpawned = false;
|
||||
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
index 50fafff765b2494c075784cc5342d086c8dc97b2..78b495ffbb1ca753714304e2a18035bcfd84b918 100644
|
||||
index 2d26c8109cb942d1856455fd0239290ee1142eb3..c17e9782850fd88b9a46d31bf9075624ffc11709 100644
|
||||
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
||||
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
@@ -38,6 +38,10 @@ import co.aikar.timings.MinecraftTimings;
|
||||
@@ -346,7 +360,7 @@ index 50fafff765b2494c075784cc5342d086c8dc97b2..78b495ffbb1ca753714304e2a18035bc
|
||||
|
||||
public class ActivationRange
|
||||
{
|
||||
@@ -230,6 +234,25 @@ public class ActivationRange
|
||||
@@ -232,6 +236,24 @@ public class ActivationRange
|
||||
}
|
||||
// Paper end - Configurable marker ticking
|
||||
ActivationRange.activateEntity(entity, bbByType); // Folia - threaded regions
|
||||
@@ -368,22 +382,6 @@ index 50fafff765b2494c075784cc5342d086c8dc97b2..78b495ffbb1ca753714304e2a18035bc
|
||||
+ entity.activatedPriority = 1;
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
+
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
@@ -246,12 +269,12 @@ public class ActivationRange
|
||||
if ( io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick() > entity.activatedTick ) // Folia - threaded regions
|
||||
{
|
||||
if ( entity.defaultActivationState )
|
||||
- {
|
||||
+ { // Pufferfish - diff on change
|
||||
entity.activatedTick = io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick(); // Folia - threaded regions
|
||||
return;
|
||||
}
|
||||
if ( bbByType[entity.activationType.ordinal()].intersects( entity.getBoundingBox() ) ) // Folia - threaded regions
|
||||
- {
|
||||
+ { // Pufferfish - diff on change
|
||||
entity.activatedTick = io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick(); // Folia - threaded regions
|
||||
}
|
||||
}
|
||||
@@ -1,478 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Mon, 25 Mar 2024 13:48:33 +0000
|
||||
Subject: [PATCH] Pufferfish Improve container checking with a bitset
|
||||
|
||||
|
||||
diff --git a/src/main/java/gg/airplane/structs/ItemListWithBitset.java b/src/main/java/gg/airplane/structs/ItemListWithBitset.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..1b7a4ee47f4445d7f2ac91d3a73ae113edbdddb2
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/airplane/structs/ItemListWithBitset.java
|
||||
@@ -0,0 +1,114 @@
|
||||
+package gg.airplane.structs;
|
||||
+
|
||||
+import net.minecraft.core.NonNullList;
|
||||
+import net.minecraft.world.item.ItemStack;
|
||||
+import org.apache.commons.lang.Validate;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+import java.util.AbstractList;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.List;
|
||||
+
|
||||
+public class ItemListWithBitset extends AbstractList<ItemStack> {
|
||||
+ public static ItemListWithBitset fromList(List<ItemStack> list) {
|
||||
+ if (list instanceof ItemListWithBitset ours) {
|
||||
+ return ours;
|
||||
+ }
|
||||
+ return new ItemListWithBitset(list);
|
||||
+ }
|
||||
+
|
||||
+ private static ItemStack[] createArray(int size) {
|
||||
+ ItemStack[] array = new ItemStack[size];
|
||||
+ Arrays.fill(array, ItemStack.EMPTY);
|
||||
+ return array;
|
||||
+ }
|
||||
+
|
||||
+ private final ItemStack[] items;
|
||||
+
|
||||
+ private long bitSet = 0;
|
||||
+ private final long allBits;
|
||||
+
|
||||
+ private static class OurNonNullList extends NonNullList<ItemStack> {
|
||||
+ protected OurNonNullList(List<ItemStack> delegate) {
|
||||
+ super(delegate, ItemStack.EMPTY);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public final NonNullList<ItemStack> nonNullList = new OurNonNullList(this);
|
||||
+
|
||||
+ private ItemListWithBitset(List<ItemStack> list) {
|
||||
+ this(list.size());
|
||||
+
|
||||
+ for (int i = 0; i < list.size(); i++) {
|
||||
+ this.set(i, list.get(i));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public ItemListWithBitset(int size) {
|
||||
+ Validate.isTrue(size < Long.BYTES * 8, "size is too large");
|
||||
+
|
||||
+ this.items = createArray(size);
|
||||
+ this.allBits = ((1L << size) - 1);
|
||||
+ }
|
||||
+
|
||||
+ public boolean isCompletelyEmpty() {
|
||||
+ return this.bitSet == 0;
|
||||
+ }
|
||||
+
|
||||
+ public boolean hasFullStacks() {
|
||||
+ return (this.bitSet & this.allBits) == allBits;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ItemStack set(int index, @NotNull ItemStack itemStack) {
|
||||
+ ItemStack existing = this.items[index];
|
||||
+
|
||||
+ this.items[index] = itemStack;
|
||||
+
|
||||
+ if (itemStack == ItemStack.EMPTY) {
|
||||
+ this.bitSet &= ~(1L << index);
|
||||
+ } else {
|
||||
+ this.bitSet |= 1L << index;
|
||||
+ }
|
||||
+
|
||||
+ return existing;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ public ItemStack get(int var0) {
|
||||
+ return this.items[var0];
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int size() {
|
||||
+ return this.items.length;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void clear() {
|
||||
+ Arrays.fill(this.items, ItemStack.EMPTY);
|
||||
+ }
|
||||
+
|
||||
+ // these are unsupported for block inventories which have a static size
|
||||
+ @Override
|
||||
+ public void add(int var0, ItemStack var1) {
|
||||
+ throw new UnsupportedOperationException();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ItemStack remove(int var0) {
|
||||
+ throw new UnsupportedOperationException();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String toString() {
|
||||
+ return "ItemListWithBitset{" +
|
||||
+ "items=" + Arrays.toString(items) +
|
||||
+ ", bitSet=" + Long.toString(bitSet, 2) +
|
||||
+ ", allBits=" + Long.toString(allBits, 2) +
|
||||
+ ", size=" + this.items.length +
|
||||
+ '}';
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/CompoundContainer.java b/src/main/java/net/minecraft/world/CompoundContainer.java
|
||||
index 241fec02e6869c638d3a160819b32173a081467b..6a8f9e8f5bf108674c47018def28906e2d0a729c 100644
|
||||
--- a/src/main/java/net/minecraft/world/CompoundContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/CompoundContainer.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.world;
|
||||
|
||||
+import net.minecraft.core.Direction; // Pufferfish
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
@@ -64,6 +65,23 @@ public class CompoundContainer implements Container {
|
||||
this.container2 = second;
|
||||
}
|
||||
|
||||
+ // Pufferfish start
|
||||
+ @Override
|
||||
+ public boolean hasEmptySlot(Direction enumdirection) {
|
||||
+ return this.container1.hasEmptySlot(null) || this.container2.hasEmptySlot(null);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCompletelyFull(Direction enumdirection) {
|
||||
+ return this.container1.isCompletelyFull(null) && this.container2.isCompletelyFull(null);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCompletelyEmpty(Direction enumdirection) {
|
||||
+ return this.container1.isCompletelyEmpty(null) && this.container2.isCompletelyEmpty(null);
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
+
|
||||
@Override
|
||||
public int getContainerSize() {
|
||||
return this.container1.getContainerSize() + this.container2.getContainerSize();
|
||||
diff --git a/src/main/java/net/minecraft/world/Container.java b/src/main/java/net/minecraft/world/Container.java
|
||||
index d6cbe98e67fdbf8db46338a88ab1356dd63b50a3..20dd3a63b2f955b05a75eb240e33ae4cf6aef28f 100644
|
||||
--- a/src/main/java/net/minecraft/world/Container.java
|
||||
+++ b/src/main/java/net/minecraft/world/Container.java
|
||||
@@ -3,6 +3,8 @@ package net.minecraft.world;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import net.minecraft.core.BlockPos;
|
||||
+
|
||||
+import net.minecraft.core.Direction; // Pufferfish
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -14,6 +16,63 @@ import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
// CraftBukkit end
|
||||
|
||||
public interface Container extends Clearable {
|
||||
+ // Pufferfish start - allow the inventory to override and optimize these frequent calls
|
||||
+ default boolean hasEmptySlot(@org.jetbrains.annotations.Nullable Direction enumdirection) { // there is a slot with 0 items in it
|
||||
+ if (this instanceof WorldlyContainer worldlyContainer) {
|
||||
+ for (int i : worldlyContainer.getSlotsForFace(enumdirection)) {
|
||||
+ if (this.getItem(i).isEmpty()) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ int size = this.getContainerSize();
|
||||
+ for (int i = 0; i < size; i++) {
|
||||
+ if (this.getItem(i).isEmpty()) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ default boolean isCompletelyFull(@org.jetbrains.annotations.Nullable Direction enumdirection) { // every stack is maxed
|
||||
+ if (this instanceof WorldlyContainer worldlyContainer) {
|
||||
+ for (int i : worldlyContainer.getSlotsForFace(enumdirection)) {
|
||||
+ ItemStack itemStack = this.getItem(i);
|
||||
+ if (itemStack.getCount() < itemStack.getMaxStackSize()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ int size = this.getContainerSize();
|
||||
+ for (int i = 0; i < size; i++) {
|
||||
+ ItemStack itemStack = this.getItem(i);
|
||||
+ if (itemStack.getCount() < itemStack.getMaxStackSize()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ default boolean isCompletelyEmpty(@org.jetbrains.annotations.Nullable Direction enumdirection) {
|
||||
+ if (this instanceof WorldlyContainer worldlyContainer) {
|
||||
+ for (int i : worldlyContainer.getSlotsForFace(enumdirection)) {
|
||||
+ if (!this.getItem(i).isEmpty()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ int size = this.getContainerSize();
|
||||
+ for (int i = 0; i < size; i++) {
|
||||
+ if (!this.getItem(i).isEmpty()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
|
||||
int LARGE_MAX_STACK_SIZE = 64;
|
||||
int DEFAULT_DISTANCE_LIMIT = 8;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
index 756d0434472921992c9d84597d7c9c824e93614c..38c573d440946ca7ee6016ef92e9c1605031e611 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
@@ -28,7 +28,10 @@ import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
public abstract class AbstractMinecartContainer extends AbstractMinecart implements ContainerEntity {
|
||||
|
||||
+ // Pufferfish start
|
||||
private NonNullList<ItemStack> itemStacks;
|
||||
+ private gg.airplane.structs.ItemListWithBitset itemStacksOptimized;
|
||||
+ // Pufferfish end
|
||||
@Nullable
|
||||
public ResourceLocation lootTable;
|
||||
public long lootTableSeed;
|
||||
@@ -90,12 +93,18 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||
|
||||
protected AbstractMinecartContainer(EntityType<?> type, Level world) {
|
||||
super(type, world);
|
||||
- this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513
|
||||
+ // Pufferfish start
|
||||
+ this.itemStacksOptimized = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize()); // CraftBukkit - SPIGOT-3513
|
||||
+ this.itemStacks = this.itemStacksOptimized.nonNullList;
|
||||
+ // Pufferfish end
|
||||
}
|
||||
|
||||
protected AbstractMinecartContainer(EntityType<?> type, double x, double y, double z, Level world) {
|
||||
super(type, world, x, y, z);
|
||||
- this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513
|
||||
+ // Pufferfish start
|
||||
+ this.itemStacksOptimized = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize()); // CraftBukkit - SPIGOT-3513
|
||||
+ this.itemStacks = this.itemStacksOptimized.nonNullList;
|
||||
+ // Pufferfish end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -164,6 +173,10 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||
protected void readAdditionalSaveData(CompoundTag nbt) {
|
||||
super.readAdditionalSaveData(nbt);
|
||||
this.lootableData.loadNbt(nbt); // Paper
|
||||
+ // Pufferfish start
|
||||
+ this.itemStacksOptimized = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize());
|
||||
+ this.itemStacks = this.itemStacksOptimized.nonNullList;
|
||||
+ // Pufferfish end
|
||||
this.readChestVehicleSaveData(nbt);
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
index 9b1243d96e0694c62fc9e82e9be540bce0d2b3ad..3514022d898a24052c917ebf55dcef3e757d6836 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
@@ -31,7 +31,10 @@ import org.bukkit.entity.HumanEntity;
|
||||
public class ChestBlockEntity extends RandomizableContainerBlockEntity implements LidBlockEntity {
|
||||
|
||||
private static final int EVENT_SET_OPEN_COUNT = 1;
|
||||
+ // Pufferfish start
|
||||
private NonNullList<ItemStack> items;
|
||||
+ private gg.airplane.structs.ItemListWithBitset optimizedItems;
|
||||
+ // Pufferfish end
|
||||
public final ContainerOpenersCounter openersCounter;
|
||||
private final ChestLidController chestLidController;
|
||||
|
||||
@@ -65,9 +68,13 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
+ private final boolean isNative = getClass().equals(ChestBlockEntity.class); // Pufferfish
|
||||
protected ChestBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
- this.items = NonNullList.withSize(27, ItemStack.EMPTY);
|
||||
+ // Pufferfish start
|
||||
+ this.optimizedItems = new gg.airplane.structs.ItemListWithBitset(27);
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Pufferfish end
|
||||
this.openersCounter = new ContainerOpenersCounter() {
|
||||
@Override
|
||||
protected void onOpen(Level world, BlockPos pos, BlockState state) {
|
||||
@@ -98,6 +105,23 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
this.chestLidController = new ChestLidController();
|
||||
}
|
||||
|
||||
+ // Pufferfish start
|
||||
+ @Override
|
||||
+ public boolean hasEmptySlot(Direction enumdirection) {
|
||||
+ return isNative ? !this.optimizedItems.hasFullStacks() : super.hasEmptySlot(enumdirection);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCompletelyFull(Direction enumdirection) {
|
||||
+ return isNative ? this.optimizedItems.hasFullStacks() && super.isCompletelyFull(enumdirection) : super.isCompletelyFull(enumdirection);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCompletelyEmpty(Direction enumdirection) {
|
||||
+ return isNative && this.optimizedItems.isCompletelyEmpty() || super.isCompletelyEmpty(enumdirection);
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
+
|
||||
public ChestBlockEntity(BlockPos pos, BlockState state) {
|
||||
this(BlockEntityType.CHEST, pos, state);
|
||||
}
|
||||
@@ -115,7 +139,10 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
@Override
|
||||
public void load(CompoundTag nbt) {
|
||||
super.load(nbt);
|
||||
- this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
|
||||
+ // Pufferfish start
|
||||
+ this.optimizedItems = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize());
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Pufferfish end
|
||||
if (!this.tryLoadLootTable(nbt)) {
|
||||
ContainerHelper.loadAllItems(nbt, this.items);
|
||||
}
|
||||
@@ -187,7 +214,10 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
|
||||
@Override
|
||||
protected void setItems(NonNullList<ItemStack> list) {
|
||||
- this.items = list;
|
||||
+ // Pufferfish start
|
||||
+ this.optimizedItems = gg.airplane.structs.ItemListWithBitset.fromList(list);
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Pufferfish end
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
index 82e7e76fecceb55522b5828a56f036e42ef55201..882e27de852c89c837d7943c5a9ae6fb3c2e896b 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
@@ -48,7 +48,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
|
||||
public static final int MOVE_ITEM_SPEED = 8;
|
||||
public static final int HOPPER_CONTAINER_SIZE = 5;
|
||||
+ // Pufferfish start
|
||||
private NonNullList<ItemStack> items;
|
||||
+ private gg.airplane.structs.ItemListWithBitset optimizedItems; // Pufferfish
|
||||
+ // Pufferfish end
|
||||
public int cooldownTime;
|
||||
private long tickedGameTime = Long.MIN_VALUE; // Folia - region threading
|
||||
|
||||
@@ -94,14 +97,37 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
|
||||
public HopperBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(BlockEntityType.HOPPER, pos, state);
|
||||
- this.items = NonNullList.withSize(5, ItemStack.EMPTY);
|
||||
+ // Pufferfish start
|
||||
+ this.optimizedItems = new gg.airplane.structs.ItemListWithBitset(5);
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Pufferfish end
|
||||
this.cooldownTime = -1;
|
||||
}
|
||||
|
||||
+ // Pufferfish start
|
||||
+ @Override
|
||||
+ public boolean hasEmptySlot(Direction enumdirection) {
|
||||
+ return !this.optimizedItems.hasFullStacks();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCompletelyFull(Direction enumdirection) {
|
||||
+ return this.optimizedItems.hasFullStacks() && super.isCompletelyFull(enumdirection);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCompletelyEmpty(Direction enumdirection) {
|
||||
+ return this.optimizedItems.isCompletelyEmpty() || super.isCompletelyEmpty(enumdirection);
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
+
|
||||
@Override
|
||||
public void load(CompoundTag nbt) {
|
||||
super.load(nbt);
|
||||
- this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
|
||||
+ // Pufferfish start
|
||||
+ this.optimizedItems = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize());
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Pufferfish end
|
||||
if (!this.tryLoadLootTable(nbt)) {
|
||||
ContainerHelper.loadAllItems(nbt, this.items);
|
||||
}
|
||||
@@ -504,6 +530,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
}
|
||||
|
||||
private static boolean isFullContainer(Container inventory, Direction direction) {
|
||||
+ if (true) return inventory.isCompletelyFull(direction); // Pufferfish - use bitsets
|
||||
// Paper start - Perf: Optimize Hoppers
|
||||
if (inventory instanceof WorldlyContainer worldlyContainer) {
|
||||
for (final int slot : worldlyContainer.getSlotsForFace(direction)) {
|
||||
@@ -526,7 +553,11 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
}
|
||||
|
||||
private static boolean isEmptyContainer(Container inv, Direction facing) {
|
||||
- return allMatch(inv, facing, IS_EMPTY_TEST); // Paper - Perf: Optimize Hoppers
|
||||
+ // Paper start
|
||||
+ // Pufferfish start - use bitsets
|
||||
+ //return allMatch(inv, facing, IS_EMPTY_TEST);
|
||||
+ return inv.isCompletelyEmpty(facing);
|
||||
+ // Pufferfish end
|
||||
}
|
||||
|
||||
public static boolean suckInItems(Level world, Hopper hopper) {
|
||||
@@ -727,7 +758,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
|
||||
if (HopperBlockEntity.canPlaceItemInContainer(to, stack, slot, side)) {
|
||||
boolean flag = false;
|
||||
- boolean flag1 = to.isEmpty();
|
||||
+ boolean flag1 = to.isCompletelyEmpty(side); // Pufferfish
|
||||
|
||||
if (itemstack1.isEmpty()) {
|
||||
// Spigot start - SPIGOT-6693, InventorySubcontainer#setItem
|
||||
@@ -922,7 +953,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
|
||||
@Override
|
||||
protected void setItems(NonNullList<ItemStack> list) {
|
||||
- this.items = list;
|
||||
+ // Pufferfish start
|
||||
+ this.optimizedItems = gg.airplane.structs.ItemListWithBitset.fromList(list);
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Pufferfish end
|
||||
}
|
||||
|
||||
public static void entityInside(Level world, BlockPos pos, BlockState state, Entity entity, HopperBlockEntity blockEntity) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
index f52ccd4f3e062af3c7cc6eaea5b074a3bbd21690..a5cd70b6ada2b44f64db0985483ee5eadc67003f 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
@@ -94,12 +94,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
|
||||
public boolean isEmpty() {
|
||||
this.unpackLootTable((Player)null);
|
||||
// Paper start - Perf: Optimize Hoppers
|
||||
- for (final ItemStack itemStack : this.getItems()) {
|
||||
- if (!itemStack.isEmpty()) {
|
||||
- return false;
|
||||
- }
|
||||
- }
|
||||
- return true;
|
||||
+ return this.isCompletelyEmpty(null); // Pufferfish - use super
|
||||
// Paper end - Perf: Optimize Hoppers
|
||||
}
|
||||
|
||||
@@ -1,25 +1,14 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16:15:28 +0800
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 13:13:07 +0800
|
||||
Subject: [PATCH] Pufferfish Only check for spooky season once an hour
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ambient/Bat.java b/src/main/java/net/minecraft/world/entity/ambient/Bat.java
|
||||
index 44fa2d4f90389f5526746bd94a2450c03340bd0b..864c3c72b6881a2a8223a9aa5a593f1a65bcc857 100644
|
||||
index dc27ddf5131e7398a5390a5187261d4c7fb6ccaa..39cc49b746b0a775fde5d173dd4f712ab4a84a97 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ambient/Bat.java
|
||||
@@ -3,6 +3,10 @@ package net.minecraft.world.entity.ambient;
|
||||
import java.time.LocalDate;
|
||||
import java.time.temporal.ChronoField;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import io.papermc.paper.threadedregions.ThreadedRegionizer;
|
||||
+import io.papermc.paper.threadedregions.TickRegionScheduler;
|
||||
+import io.papermc.paper.threadedregions.TickRegions;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
@@ -241,13 +245,25 @@ public class Bat extends AmbientCreature {
|
||||
@@ -239,13 +239,25 @@ public class Bat extends AmbientCreature {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +17,8 @@ index 44fa2d4f90389f5526746bd94a2450c03340bd0b..864c3c72b6881a2a8223a9aa5a593f1a
|
||||
+ private static final int ONE_HOUR = 20 * 60 * 60;
|
||||
+ private static int lastSpookyCheck = -ONE_HOUR;
|
||||
private static boolean isHalloween() {
|
||||
+ final ThreadedRegionizer.ThreadedRegion<TickRegions.TickRegionData, TickRegions.TickRegionSectionData> region =
|
||||
+ TickRegionScheduler.getCurrentRegion();
|
||||
+ final io.papermc.paper.threadedregions.ThreadedRegionizer.ThreadedRegion<io.papermc.paper.threadedregions.TickRegions.TickRegionData, io.papermc.paper.threadedregions.TickRegions.TickRegionSectionData> region =
|
||||
+ io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegion();
|
||||
+ final long tickCount = region.getData().getCurrentTick();
|
||||
+ if (tickCount - lastSpookyCheck > ONE_HOUR) {
|
||||
LocalDate localdate = LocalDate.now();
|
||||
@@ -44,5 +33,5 @@ index 44fa2d4f90389f5526746bd94a2450c03340bd0b..864c3c72b6881a2a8223a9aa5a593f1a
|
||||
}
|
||||
+ // Pufferfish end
|
||||
|
||||
@Override
|
||||
protected float getStandingEyeHeight(Pose pose, EntityDimensions dimensions) {
|
||||
private void setupAnimationStates() {
|
||||
if (this.isResting()) {
|
||||
@@ -1,104 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 06:03:02 +0000
|
||||
Subject: [PATCH] Gale Don't load chunks to activate climbing entities
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/LoadChunksToActiveClimbingEntitiesConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/LoadChunksToActiveClimbingEntitiesConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ed62d25d6cd6dfcf8c5db20ced36eb3d3c79dafd
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/LoadChunksToActiveClimbingEntitiesConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.optimizations;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class LoadChunksToActiveClimbingEntitiesConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "allow")
|
||||
+ public static boolean allow = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.OPTIMIZATIONS;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "load_chunks_to_active_climbing_entities";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 4b3acc0de20b246e20e2cc91ba0eca493a675729..2d78d28120af075bebee4d97428ed48cf27c9d78 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -5460,6 +5460,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
return this.feetBlockState;
|
||||
}
|
||||
|
||||
+ // Gale start - don't load chunks to activate climbing entities
|
||||
+ public @Nullable BlockState getFeetBlockStateIfLoaded() {
|
||||
+ if (this.feetBlockState == null) {
|
||||
+ this.feetBlockState = this.level.getBlockStateIfLoaded(this.blockPosition());
|
||||
+ }
|
||||
+
|
||||
+ return this.feetBlockState;
|
||||
+ }
|
||||
+ // Gale end - don't load chunks to activate climbing entities
|
||||
+
|
||||
public ChunkPos chunkPosition() {
|
||||
return this.chunkPosition;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index df789b13f57200c66ff4cc59e6b63949a6804e3d..c2d155882c94f875c96c13746ff0c5433ab25ed0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -2062,19 +2062,43 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
|
||||
public boolean onClimableCached() {
|
||||
if (!this.blockPosition().equals(this.lastClimbingPosition)) {
|
||||
- this.cachedOnClimable = this.onClimbable();
|
||||
- this.lastClimbingPosition = this.blockPosition();
|
||||
+ // Gale start - don't load chunks to activate climbing entities
|
||||
+ Boolean onClimbableIfLoaded = this.onClimbable(me.earthme.luminol.config.modules.optimizations.LoadChunksToActiveClimbingEntitiesConfig.allow);
|
||||
+ if (onClimbableIfLoaded != null) {
|
||||
+ this.cachedOnClimable = onClimbableIfLoaded;
|
||||
+ this.lastClimbingPosition = this.blockPosition();
|
||||
+ } else {
|
||||
+ this.cachedOnClimable = false;
|
||||
+ this.lastClimbingPosition = null;
|
||||
+ }
|
||||
+ // Gale end - don't load chunks to activate climbing entities
|
||||
}
|
||||
return this.cachedOnClimable;
|
||||
}
|
||||
// Pufferfish end
|
||||
|
||||
public boolean onClimbable() {
|
||||
+ // Gale start - don't load chunks to activate climbing entities
|
||||
+ return onClimbable(true);
|
||||
+ }
|
||||
+
|
||||
+ public Boolean onClimbable(boolean loadChunk) {
|
||||
+ // Gale end - don't load chunks to activate climbing entities
|
||||
if (this.isSpectator()) {
|
||||
return false;
|
||||
} else {
|
||||
BlockPos blockposition = this.blockPosition();
|
||||
- BlockState iblockdata = this.getFeetBlockState();
|
||||
+ // Gale start - don't load chunks to activate climbing entities
|
||||
+ BlockState iblockdata;
|
||||
+ if (loadChunk) {
|
||||
+ iblockdata = this.getFeetBlockState();
|
||||
+ } else {
|
||||
+ iblockdata = this.getFeetBlockStateIfLoaded();
|
||||
+ if (iblockdata == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ }
|
||||
+ // Gale end - don't load chunks to activate climbing entities
|
||||
|
||||
if (iblockdata.is(BlockTags.CLIMBABLE)) {
|
||||
this.lastClimbablePos = Optional.of(blockposition);
|
||||
@@ -1,6 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 04:55:43 +0000
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sun, 4 Aug 2024 21:39:59 +0800
|
||||
Subject: [PATCH] Pufferfish Optimize suffocation
|
||||
|
||||
|
||||
@@ -31,10 +31,10 @@ index 0000000000000000000000000000000000000000..3e48cd297b4869e5c89b6abc43c726d3
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index bbfbeddcba884ae1964f7421fcdf179923bd0d2b..df789b13f57200c66ff4cc59e6b63949a6804e3d 100644
|
||||
index 33ecd65a2787741cc0611ad3100a1bf9d2ce0338..8c155060f5a347e784b9d4ece506e983fdc4057b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -428,7 +428,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -463,7 +463,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
boolean flag = this instanceof net.minecraft.world.entity.player.Player;
|
||||
|
||||
if (!this.level().isClientSide) {
|
||||
@@ -43,7 +43,7 @@ index bbfbeddcba884ae1964f7421fcdf179923bd0d2b..df789b13f57200c66ff4cc59e6b63949
|
||||
this.hurt(this.damageSources().inWall(), 1.0F);
|
||||
} else if (flag && !this.level().getWorldBorder().isWithinBounds(this.getBoundingBox())) {
|
||||
double d0 = this.level().getWorldBorder().getDistanceToBorder(this) + this.level().getWorldBorder().getDamageSafeZone();
|
||||
@@ -1436,6 +1436,19 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -1427,6 +1427,19 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
return this.getHealth() <= 0.0F;
|
||||
}
|
||||
|
||||
@@ -64,10 +64,10 @@ index bbfbeddcba884ae1964f7421fcdf179923bd0d2b..df789b13f57200c66ff4cc59e6b63949
|
||||
public boolean hurt(DamageSource source, float amount) {
|
||||
if (this.isInvulnerableTo(source)) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
index 12440ee2dccc0a697fb403765f2e1b987ccc0283..de2471cfa96a23944f229f33ffdff88b6b7756e4 100644
|
||||
index d3b4d492aee380dc17f4232d90eaae4f07bb9f86..82921c56c49edb0ca07425da563aa4876d4e6fb1 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
@@ -151,6 +151,13 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob
|
||||
@@ -154,6 +154,13 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob
|
||||
this.bossEvent.setName(this.getDisplayName());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Tue, 20 Feb 2024 13:03:42 +0000
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sun, 4 Aug 2024 21:41:52 +0800
|
||||
Subject: [PATCH] Pufferfish Throttle goal selector during inactive ticking
|
||||
|
||||
|
||||
@@ -31,10 +31,10 @@ index 0000000000000000000000000000000000000000..acc032f727e605e79b688efb4873ff47
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index 66c581585e6ca58eba0e8b7af0fa1f0c9f924f94..97e099eea537aea8f8ffd031063949c363820701 100644
|
||||
index 121e9cbeb07a41febac0086f5fce5a172a4ad15e..84281b92b2c02c70702d43ebcf7afa85914e03fb 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -230,11 +230,13 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||
@@ -240,11 +240,13 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
return this.lookControl;
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sun, 28 Jan 2024 09:30:22 +0000
|
||||
Subject: [PATCH] Gale Check frozen ticks before landing block
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index c2d155882c94f875c96c13746ff0c5433ab25ed0..84b47e6cea7ed9730f9c450ba8ba3167d71b2cc9 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -597,11 +597,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
|
||||
protected void tryAddFrost() {
|
||||
- if (!this.getBlockStateOnLegacy().isAir()) {
|
||||
int i = this.getTicksFrozen();
|
||||
|
||||
if (i > 0) {
|
||||
- AttributeInstance attributemodifiable = this.getAttribute(Attributes.MOVEMENT_SPEED);
|
||||
+ AttributeInstance attributemodifiable = this.getBlockStateOnLegacy().isAir() ? null : this.getAttribute(Attributes.MOVEMENT_SPEED); // Gale - Lithium - check frozen ticks before landing block
|
||||
|
||||
if (attributemodifiable == null) {
|
||||
return;
|
||||
@@ -611,7 +610,6 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
|
||||
attributemodifiable.addTransientModifier(new AttributeModifier(LivingEntity.SPEED_MODIFIER_POWDER_SNOW_UUID, "Powder snow slow", (double) f, AttributeModifier.Operation.ADDITION));
|
||||
}
|
||||
- }
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sun, 4 Aug 2024 22:15:50 +0800
|
||||
Subject: [PATCH] Pufferfish Simpler ShapelessRecipes comparison for Vanilla
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java b/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java
|
||||
index 213ee4aa988dd4c2a5a7be99b1d13f67338e5209..8e46753af60aa9fd8e4b4c0f955f7a55a77de314 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
+import net.minecraft.world.inventory.CraftingContainer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
// CraftBukkit start
|
||||
@@ -25,8 +26,13 @@ public class ShapelessRecipe extends io.papermc.paper.inventory.recipe.RecipeBoo
|
||||
final CraftingBookCategory category;
|
||||
final ItemStack result;
|
||||
final NonNullList<Ingredient> ingredients;
|
||||
+ private final boolean isBukkit; // Pufferfish
|
||||
|
||||
+ // Pufferfish start
|
||||
public ShapelessRecipe(String group, CraftingBookCategory category, ItemStack result, NonNullList<Ingredient> ingredients) {
|
||||
+ this(group, category, result, ingredients, false);
|
||||
+ }
|
||||
+ public ShapelessRecipe(String group, CraftingBookCategory category, ItemStack result, NonNullList<Ingredient> ingredients, boolean isBukkit) { this.isBukkit = isBukkit; // Pufferfish end
|
||||
this.group = group;
|
||||
this.category = category;
|
||||
this.result = result;
|
||||
@@ -76,6 +82,28 @@ public class ShapelessRecipe extends io.papermc.paper.inventory.recipe.RecipeBoo
|
||||
}
|
||||
|
||||
public boolean matches(CraftingInput input, Level world) {
|
||||
+ // Pufferfish start
|
||||
+ if (!this.isBukkit) {
|
||||
+ java.util.List<Ingredient> ingredients = com.google.common.collect.Lists.newArrayList(this.ingredients.toArray(new Ingredient[0]));
|
||||
+
|
||||
+ inventory: for (int index = 0; index < input.size(); index++) {
|
||||
+ ItemStack itemStack = input.getItem(index);
|
||||
+
|
||||
+ if (!itemStack.isEmpty()) {
|
||||
+ for (int i = 0; i < ingredients.size(); i++) {
|
||||
+ if (ingredients.get(i).test(itemStack)) {
|
||||
+ ingredients.remove(i);
|
||||
+ continue inventory;
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return ingredients.isEmpty();
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
+
|
||||
// Paper start - unwrap ternary & better exact choice recipes
|
||||
if (input.ingredientCount() != this.ingredients.size()) {
|
||||
return false;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java
|
||||
index 96d772eb02f79f8c478f5e6f065e387aa7665b18..c5ce412f321b8b4f31cc042893659e213b081f29 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java
|
||||
@@ -45,6 +45,6 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe
|
||||
data.set(i, this.toNMS(ingred.get(i), true));
|
||||
}
|
||||
|
||||
- MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.ShapelessRecipe(this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data)));
|
||||
+ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.ShapelessRecipe(this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data, true))); // Pufferfish
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sun, 28 Jan 2024 09:31:27 +0000
|
||||
Subject: [PATCH] Gale Don't trigger lootable refresh for non-player
|
||||
interaction
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
index a5cd70b6ada2b44f64db0985483ee5eadc67003f..e49be65c2d379027c2821c0db7f151bc3cd20a4b 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
@@ -68,6 +68,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
|
||||
|
||||
@Override
|
||||
public void unpackLootTable(@org.jetbrains.annotations.Nullable final Player player) {
|
||||
+ if (player == null) return; // Gale - EMC - don't trigger lootable refresh for non-player interaction
|
||||
// Copied from super with changes, always check the original method
|
||||
net.minecraft.world.level.Level level = this.getLevel();
|
||||
BlockPos blockPos = this.getBlockPos();
|
||||
84
patches/server/0043-Pufferfish-SIMD-Utilities.patch
Normal file
84
patches/server/0043-Pufferfish-SIMD-Utilities.patch
Normal file
@@ -0,0 +1,84 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Tue, 6 Aug 2024 14:31:20 +0800
|
||||
Subject: [PATCH] Pufferfish SIMD Utilities
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 7b11c45914392c01b4d28b104f80e6ed34eb9955..5ea6cccfde29132356548e847be4a1720b64998d 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -77,6 +77,14 @@ paperweight {
|
||||
craftBukkitPackageVersion.set("v1_21_R1") // also needs to be updated in MappingEnvironment
|
||||
}
|
||||
|
||||
+
|
||||
+// Pufferfish Start
|
||||
+tasks.withType<JavaCompile> {
|
||||
+ val compilerArgs = options.compilerArgs
|
||||
+ compilerArgs.add("--add-modules=jdk.incubator.vector")
|
||||
+}
|
||||
+// Pufferfish End
|
||||
+
|
||||
tasks.jar {
|
||||
archiveClassifier.set("dev")
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/SIMDConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/SIMDConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..76cea165bcef0794a66ef7c29721f7716869420f
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/SIMDConfig.java
|
||||
@@ -0,0 +1,53 @@
|
||||
+package me.earthme.luminol.config.modules.optimizations;
|
||||
+
|
||||
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import com.mojang.logging.LogUtils;
|
||||
+import gg.pufferfish.pufferfish.simd.SIMDDetection;
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.DoNotLoad;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+import org.slf4j.Logger;
|
||||
+
|
||||
+public class SIMDConfig implements IConfigModule {
|
||||
+ @DoNotLoad
|
||||
+ private static final Logger LOGGER = LogUtils.getLogger();
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = true;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.OPTIMIZATIONS;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "use_simd";
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onLoaded(CommentedFileConfig configInstance) {
|
||||
+ if (!enabled){
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // Attempt to detect vectorization
|
||||
+ try {
|
||||
+ SIMDDetection.isEnabled = SIMDDetection.canEnable(LOGGER);
|
||||
+ SIMDDetection.versionLimited = SIMDDetection.getJavaVersion() < 17;
|
||||
+ } catch (NoClassDefFoundError | Exception ignored) {
|
||||
+ ignored.printStackTrace();
|
||||
+ }
|
||||
+
|
||||
+ if (SIMDDetection.isEnabled) {
|
||||
+ LOGGER.info("SIMD operations detected as functional. Will replace some operations with faster versions.");
|
||||
+ } else if (SIMDDetection.versionLimited) {
|
||||
+ LOGGER.warn("Will not enable SIMD! These optimizations are only safely supported on Java 17+.");
|
||||
+ } else {
|
||||
+ LOGGER.warn("SIMD operations are available for your server, but are not configured!");
|
||||
+ LOGGER.warn("To enable additional optimizations, add \"--add-modules=jdk.incubator.vector\" to your startup flags, BEFORE the \"-jar\".");
|
||||
+ LOGGER.warn("If you have already added this flag, then SIMD operations are not supported on your JVM or CPU.");
|
||||
+ LOGGER.warn("Debug: Java: {}, test run: {}", System.getProperty("java.version"), SIMDDetection.testRun);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
@@ -1,6 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 06:00:22 +0000
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 13:30:56 +0800
|
||||
Subject: [PATCH] Gale Variable entity wake-up duration
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ index 0000000000000000000000000000000000000000..fa30e8dc39a2d4bd1399e41230b307b1
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
index 78b495ffbb1ca753714304e2a18035bcfd84b918..e9331fe4d524215bbab9a410d16e4f1811f5ad31 100644
|
||||
index c17e9782850fd88b9a46d31bf9075624ffc11709..e1f0aedbc42c6e969ba155c358f4ee30efd8ffe8 100644
|
||||
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
||||
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
@@ -75,28 +75,41 @@ public class ActivationRange
|
||||
@@ -1,23 +1,23 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 17:21:44 +0800
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sun, 4 Aug 2024 22:14:21 +0800
|
||||
Subject: [PATCH] Gale Optimize sun burn tick
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 2d78d28120af075bebee4d97428ed48cf27c9d78..a4682b8bd269f52af26a03347e8d3869d2b1ba41 100644
|
||||
index 6497ecce4a826776c487e0e2fcb077f21e02ecda..9b87aa41f03056721757348151b1119016421650 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -310,7 +310,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -315,7 +315,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
public double xo;
|
||||
public double yo;
|
||||
public double zo;
|
||||
- private Vec3 position;
|
||||
+ public Vec3 position; // Gale - JettPack - optimize sun burn tick - private -> public
|
||||
public BlockPos blockPosition; // Pufferfish - private->public
|
||||
private BlockPos blockPosition;
|
||||
private ChunkPos chunkPosition;
|
||||
private Vec3 deltaMovement;
|
||||
@@ -2068,9 +2068,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -2124,9 +2124,19 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
/** @deprecated */
|
||||
@Deprecated
|
||||
public float getLightLevelDependentMagicValue() {
|
||||
@@ -26,7 +26,9 @@ index 2d78d28120af075bebee4d97428ed48cf27c9d78..a4682b8bd269f52af26a03347e8d3869
|
||||
}
|
||||
|
||||
+ // Gale start - JettPack - optimize sun burn tick - allow passing BlockPos to getLightLevelDependentMagicValue
|
||||
+ /** @deprecated */
|
||||
+ /**
|
||||
+ * @deprecated
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ public float getLightLevelDependentMagicValue(BlockPos pos) {
|
||||
+ return this.level().hasChunkAt(this.getBlockX(), this.getBlockZ()) ? this.level.getLightLevelDependentMagicValue(pos) : 0.0F;
|
||||
@@ -35,14 +37,14 @@ index 2d78d28120af075bebee4d97428ed48cf27c9d78..a4682b8bd269f52af26a03347e8d3869
|
||||
+
|
||||
public void absMoveTo(double x, double y, double z, float yaw, float pitch) {
|
||||
this.absMoveTo(x, y, z);
|
||||
this.setYRot(yaw % 360.0F);
|
||||
this.absRotateTo(yaw, pitch);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index 97e099eea537aea8f8ffd031063949c363820701..71b1f576aff8dcf51dd888280b5b7a25a387d197 100644
|
||||
index 84281b92b2c02c70702d43ebcf7afa85914e03fb..bc20ef314b20de38412522edcab99aaa4ba9ac32 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -1750,13 +1750,29 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||
@@ -1778,13 +1778,29 @@ 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;
|
||||
@@ -1,192 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Fri, 9 Feb 2024 23:43:16 +0000
|
||||
Subject: [PATCH] Gale Optimize world generation chunk and block access
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/util/Pos.java b/src/main/java/me/jellysquid/mods/lithium/common/util/Pos.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..f2f10b651e4fbecdd1ea1bc28ebf40d685a67cee
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/jellysquid/mods/lithium/common/util/Pos.java
|
||||
@@ -0,0 +1,95 @@
|
||||
+// Gale - Lithium - position utility
|
||||
+
|
||||
+package me.jellysquid.mods.lithium.common.util;
|
||||
+
|
||||
+import net.minecraft.core.SectionPos;
|
||||
+import net.minecraft.world.level.LevelHeightAccessor;
|
||||
+
|
||||
+public class Pos {
|
||||
+
|
||||
+ public static class BlockCoord {
|
||||
+ public static int getYSize(LevelHeightAccessor view) {
|
||||
+ return view.getHeight();
|
||||
+ }
|
||||
+ public static int getMinY(LevelHeightAccessor view) {
|
||||
+ return view.getMinBuildHeight();
|
||||
+ }
|
||||
+ public static int getMaxYInclusive(LevelHeightAccessor view) {
|
||||
+ return view.getMaxBuildHeight() - 1;
|
||||
+ }
|
||||
+ public static int getMaxYExclusive(LevelHeightAccessor view) {
|
||||
+ return view.getMaxBuildHeight();
|
||||
+ }
|
||||
+
|
||||
+ public static int getMaxInSectionCoord(int sectionCoord) {
|
||||
+ return 15 + getMinInSectionCoord(sectionCoord);
|
||||
+ }
|
||||
+
|
||||
+ public static int getMaxYInSectionIndex(LevelHeightAccessor view, int sectionIndex){
|
||||
+ return getMaxInSectionCoord(SectionYCoord.fromSectionIndex(view, sectionIndex));
|
||||
+ }
|
||||
+
|
||||
+ public static int getMinInSectionCoord(int sectionCoord) {
|
||||
+ return SectionPos.sectionToBlockCoord(sectionCoord);
|
||||
+ }
|
||||
+
|
||||
+ public static int getMinYInSectionIndex(LevelHeightAccessor view, int sectionIndex) {
|
||||
+ return getMinInSectionCoord(SectionYCoord.fromSectionIndex(view, sectionIndex));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static class ChunkCoord {
|
||||
+ public static int fromBlockCoord(int blockCoord) {
|
||||
+ return SectionPos.blockToSectionCoord(blockCoord);
|
||||
+ }
|
||||
+
|
||||
+ public static int fromBlockSize(int i) {
|
||||
+ return i >> 4; //same method as fromBlockCoord, just be clear about coord/size semantic difference
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static class SectionYCoord {
|
||||
+ public static int getNumYSections(LevelHeightAccessor view) {
|
||||
+ return view.getSectionsCount();
|
||||
+ }
|
||||
+ public static int getMinYSection(LevelHeightAccessor view) {
|
||||
+ return view.getMinSection();
|
||||
+ }
|
||||
+ public static int getMaxYSectionInclusive(LevelHeightAccessor view) {
|
||||
+ return view.getMaxSection() - 1;
|
||||
+ }
|
||||
+ public static int getMaxYSectionExclusive(LevelHeightAccessor view) {
|
||||
+ return view.getMaxSection();
|
||||
+ }
|
||||
+
|
||||
+ public static int fromSectionIndex(LevelHeightAccessor view, int sectionCoord) {
|
||||
+ return sectionCoord + SectionYCoord.getMinYSection(view);
|
||||
+ }
|
||||
+ public static int fromBlockCoord(int blockCoord) {
|
||||
+ return SectionPos.blockToSectionCoord(blockCoord);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static class SectionYIndex {
|
||||
+ public static int getNumYSections(LevelHeightAccessor view) {
|
||||
+ return view.getSectionsCount();
|
||||
+ }
|
||||
+ public static int getMinYSectionIndex(LevelHeightAccessor view) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+ public static int getMaxYSectionIndexInclusive(LevelHeightAccessor view) {
|
||||
+ return view.getSectionsCount() - 1;
|
||||
+ }
|
||||
+ public static int getMaxYSectionIndexExclusive(LevelHeightAccessor view) {
|
||||
+ return view.getSectionsCount();
|
||||
+ }
|
||||
+
|
||||
+ public static int fromSectionCoord(LevelHeightAccessor view, int sectionCoord) {
|
||||
+ return sectionCoord - SectionYCoord.getMinYSection(view);
|
||||
+ }
|
||||
+ public static int fromBlockCoord(LevelHeightAccessor view, int blockCoord) {
|
||||
+ return fromSectionCoord(view, SectionPos.blockToSectionCoord(blockCoord));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
|
||||
index 33c1ef45ed620f8424c2c83dd30b674892ddffe3..60db67956d8455d02c7b315cbdcb952206d776db 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
|
||||
@@ -8,6 +8,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -83,6 +84,10 @@ public class WorldGenRegion implements WorldGenLevel {
|
||||
private Supplier<String> currentlyGenerating;
|
||||
private final AtomicLong subTickCount = new AtomicLong();
|
||||
private static final ResourceLocation WORLDGEN_REGION_RANDOM = new ResourceLocation("worldgen_region_random");
|
||||
+ // Gale start - Lithium - optimize world generation chunk and block access
|
||||
+ private ChunkAccess[] chunksArr;
|
||||
+ private int minChunkX, minChunkZ;
|
||||
+ // Gale end - Lithium - optimize world generation chunk and block access
|
||||
|
||||
// Folia start - region threading
|
||||
@Override
|
||||
@@ -112,6 +117,11 @@ public class WorldGenRegion implements WorldGenLevel {
|
||||
this.lastPos = ((ChunkAccess) chunks.get(chunks.size() - 1)).getPos();
|
||||
this.structureManager = world.structureManager().forWorldGenRegion(this);
|
||||
}
|
||||
+ // Gale start - Lithium - optimize world generation chunk and block access
|
||||
+ this.minChunkX = this.firstPos.x;
|
||||
+ this.minChunkZ = this.firstPos.z;
|
||||
+ this.chunksArr = chunks.toArray(new ChunkAccess[0]);
|
||||
+ // Gale end - Lithium - optimize world generation chunk and block access
|
||||
}
|
||||
|
||||
// Paper start - starlight
|
||||
@@ -150,9 +160,29 @@ public class WorldGenRegion implements WorldGenLevel {
|
||||
|
||||
@Override
|
||||
public ChunkAccess getChunk(int chunkX, int chunkZ) {
|
||||
- return this.getChunk(chunkX, chunkZ, ChunkStatus.EMPTY);
|
||||
+ // Gale start - Lithium - optimize world generation chunk and block access - use the chunk array for faster access
|
||||
+ int x = chunkX - this.minChunkX;
|
||||
+ int z = chunkZ - this.minChunkZ;
|
||||
+ int w = this.size;
|
||||
+
|
||||
+ if (x >= 0 && z >= 0 && x < w && z < w) {
|
||||
+ return this.chunksArr[x + z * w];
|
||||
+ } else {
|
||||
+ throw new NullPointerException("No chunk exists at " + new ChunkPos(chunkX, chunkZ));
|
||||
+ }
|
||||
+ // Gale end - Lithium - optimize world generation chunk and block access - use the chunk array for faster access
|
||||
}
|
||||
|
||||
+ // Gale start - Lithium - optimize world generation chunk and block access
|
||||
+ /**
|
||||
+ * Use our chunk fetch function
|
||||
+ */
|
||||
+ public ChunkAccess getChunk(BlockPos pos) {
|
||||
+ // Skip checking chunk.getStatus().isAtLeast(ChunkStatus.EMPTY) here, because it is always true
|
||||
+ return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ()));
|
||||
+ }
|
||||
+ // Gale end - Lithium - optimize world generation chunk and block access
|
||||
+
|
||||
@Nullable
|
||||
@Override
|
||||
public ChunkAccess getChunk(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) {
|
||||
@@ -210,7 +240,17 @@ public class WorldGenRegion implements WorldGenLevel {
|
||||
|
||||
@Override
|
||||
public BlockState getBlockState(BlockPos pos) {
|
||||
- return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())).getBlockState(pos);
|
||||
+ // Gale start - Lithium - optimize world generation chunk and block access - avoid pointer de-referencing, make method easier to inline
|
||||
+ int x = SectionPos.blockToSectionCoord(pos.getX()) - this.minChunkX;
|
||||
+ int z = SectionPos.blockToSectionCoord(pos.getZ()) - this.minChunkZ;
|
||||
+ int w = this.size;
|
||||
+
|
||||
+ if (x >= 0 && z >= 0 && x < w && z < w) {
|
||||
+ return this.chunksArr[x + z * w].getBlockState(pos);
|
||||
+ } else {
|
||||
+ throw new NullPointerException("No chunk exists at " + new ChunkPos(pos));
|
||||
+ }
|
||||
+ // Gale end - Lithium - optimize world generation chunk and block access - avoid pointer de-referencing, make method easier to inline
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,6 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sun, 28 Jan 2024 09:31:27 +0000
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 13:38:04 +0800
|
||||
Subject: [PATCH] Gale Use platform math functions
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
@@ -98,45 +98,11 @@ public class Main {
|
||||
}
|
||||
```
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
index 49ccb27a17bec1d4ff31bc8d72e4724d65adc20c..34ccd489268c51c0aeecf5918878122b49c8d123 100644
|
||||
--- a/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
+++ b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
@@ -168,13 +168,11 @@ public final class MCUtil {
|
||||
}
|
||||
|
||||
public static int fastFloor(double x) {
|
||||
- int truncated = (int)x;
|
||||
- return x < (double)truncated ? truncated - 1 : truncated;
|
||||
+ return (int) Math.floor(x); // Gale - use platform math functions
|
||||
}
|
||||
|
||||
public static int fastFloor(float x) {
|
||||
- int truncated = (int)x;
|
||||
- return x < (double)truncated ? truncated - 1 : truncated;
|
||||
+ return (int) Math.floor(x); // Gale - use platform math functions
|
||||
}
|
||||
|
||||
public static float normalizeYaw(float f) {
|
||||
@@ -235,11 +233,11 @@ public final class MCUtil {
|
||||
}
|
||||
|
||||
public static int getChunkCoordinate(final double coordinate) {
|
||||
- return MCUtil.fastFloor(coordinate) >> 4;
|
||||
+ return ((int) Math.floor(coordinate)) >> 4; // Gale - use platform math functions
|
||||
}
|
||||
|
||||
public static int getBlockCoordinate(final double coordinate) {
|
||||
- return MCUtil.fastFloor(coordinate);
|
||||
+ return (int) Math.floor(coordinate); // Gale - use platform math functions
|
||||
}
|
||||
|
||||
public static long getBlockKey(final int x, final int y, final int z) {
|
||||
diff --git a/src/main/java/net/minecraft/util/Mth.java b/src/main/java/net/minecraft/util/Mth.java
|
||||
index 03854a2d26a3cfc1817acfdc28cbf151ba59e05b..d9e0224dc108a99c194d4947d18f2d855a341534 100644
|
||||
index f298cdfcf1539e467f57f9f7789de3cf2ca54665..3468b7fbc7440f220fce8039f237658a593df296 100644
|
||||
--- a/src/main/java/net/minecraft/util/Mth.java
|
||||
+++ b/src/main/java/net/minecraft/util/Mth.java
|
||||
@@ -56,13 +56,11 @@ public class Mth {
|
||||
@@ -58,18 +58,15 @@ public class Mth {
|
||||
}
|
||||
|
||||
public static int floor(float value) {
|
||||
@@ -152,7 +118,13 @@ index 03854a2d26a3cfc1817acfdc28cbf151ba59e05b..d9e0224dc108a99c194d4947d18f2d85
|
||||
}
|
||||
|
||||
public static long lfloor(double value) {
|
||||
@@ -79,13 +77,11 @@ public class Mth {
|
||||
- long l = (long)value;
|
||||
- return value < (double)l ? l - 1L : l;
|
||||
+ return (long) Math.floor(value); // Gale - use platform math functions
|
||||
}
|
||||
|
||||
public static float abs(float value) {
|
||||
@@ -81,13 +78,11 @@ public class Mth {
|
||||
}
|
||||
|
||||
public static int ceil(float value) {
|
||||
@@ -168,15 +140,15 @@ index 03854a2d26a3cfc1817acfdc28cbf151ba59e05b..d9e0224dc108a99c194d4947d18f2d85
|
||||
}
|
||||
|
||||
public static int clamp(int value, int min, int max) {
|
||||
@@ -121,15 +117,7 @@ public class Mth {
|
||||
@@ -123,15 +118,7 @@ public class Mth {
|
||||
}
|
||||
|
||||
public static double absMax(double a, double b) {
|
||||
- if (a < 0.0D) {
|
||||
- if (a < 0.0) {
|
||||
- a = -a;
|
||||
- }
|
||||
-
|
||||
- if (b < 0.0D) {
|
||||
- if (b < 0.0) {
|
||||
- b = -b;
|
||||
- }
|
||||
-
|
||||
@@ -1,14 +1,14 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Tue, 6 Feb 2024 04:21:05 +0000
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 13:38:04 +0800
|
||||
Subject: [PATCH] Gale Skip entity move if movement is zero
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index a4682b8bd269f52af26a03347e8d3869d2b1ba41..d78ad18ac3b69c893a23b6bb9a6837b6a82ebdc2 100644
|
||||
index 9b87aa41f03056721757348151b1119016421650..e20533b2ab9f39fc942271b704d644fb382376f7 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -319,6 +319,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -324,6 +324,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
public float yRotO;
|
||||
public float xRotO;
|
||||
private AABB bb;
|
||||
@@ -16,7 +16,7 @@ index a4682b8bd269f52af26a03347e8d3869d2b1ba41..d78ad18ac3b69c893a23b6bb9a6837b6
|
||||
public boolean onGround;
|
||||
public boolean horizontalCollision;
|
||||
public boolean verticalCollision;
|
||||
@@ -1104,6 +1105,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -1139,6 +1140,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
//Luminol end
|
||||
|
||||
public void move(MoverType movementType, Vec3 movement) {
|
||||
@@ -27,8 +27,8 @@ index a4682b8bd269f52af26a03347e8d3869d2b1ba41..d78ad18ac3b69c893a23b6bb9a6837b6
|
||||
+ // Gale end - VMP - skip entity move if movement is zero
|
||||
final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity
|
||||
// Paper start - detailed watchdog information
|
||||
io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main");
|
||||
@@ -4957,6 +4963,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread("Cannot move an entity off-main");
|
||||
@@ -4981,6 +4987,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
|
||||
public final void setBoundingBox(AABB boundingBox) {
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Gale Optimize noise generation
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java b/src/main/java/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java
|
||||
index fb84d703b4461343d50510d7c9be32fc1f09ed22..93a11c95f96f975fafe03e77a2caace57675d130 100644
|
||||
index 9a97e5cd23d839183ac4d243d28df92af3119fe7..0da2d816f0497eae0c055f3929b8194a3473a221 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java
|
||||
@@ -11,6 +11,27 @@ public final class ImprovedNoise {
|
||||
@@ -34,9 +34,9 @@ index fb84d703b4461343d50510d7c9be32fc1f09ed22..93a11c95f96f975fafe03e77a2caace5
|
||||
+ // Gale end - C2ME - optimize noise generation
|
||||
+
|
||||
public ImprovedNoise(RandomSource random) {
|
||||
this.xo = random.nextDouble() * 256.0D;
|
||||
this.yo = random.nextDouble() * 256.0D;
|
||||
@@ -40,12 +61,14 @@ public final class ImprovedNoise {
|
||||
this.xo = random.nextDouble() * 256.0;
|
||||
this.yo = random.nextDouble() * 256.0;
|
||||
@@ -38,12 +59,14 @@ public final class ImprovedNoise {
|
||||
double d = x + this.xo;
|
||||
double e = y + this.yo;
|
||||
double f = z + this.zo;
|
||||
@@ -55,16 +55,16 @@ index fb84d703b4461343d50510d7c9be32fc1f09ed22..93a11c95f96f975fafe03e77a2caace5
|
||||
+ double l = f - k;
|
||||
+ // Gale end - C2ME - optimize noise generation - optimize: remove frequent type conversions
|
||||
double o;
|
||||
if (yScale != 0.0D) {
|
||||
if (yScale != 0.0) {
|
||||
double m;
|
||||
@@ -55,25 +78,27 @@ public final class ImprovedNoise {
|
||||
@@ -53,25 +76,27 @@ public final class ImprovedNoise {
|
||||
m = h;
|
||||
}
|
||||
|
||||
- o = (double)Mth.floor(m / yScale + (double)1.0E-7F) * yScale;
|
||||
- o = (double)Mth.floor(m / yScale + 1.0E-7F) * yScale;
|
||||
+ o = Math.floor(m / yScale + (double)1.0E-7F) * yScale; // Gale - C2ME - optimize noise generation - optimize: remove frequent type conversions
|
||||
} else {
|
||||
o = 0.0D;
|
||||
o = 0.0;
|
||||
}
|
||||
|
||||
- return this.sampleAndLerp(i, j, k, g, h - o, l, h);
|
||||
@@ -94,7 +94,7 @@ index fb84d703b4461343d50510d7c9be32fc1f09ed22..93a11c95f96f975fafe03e77a2caace5
|
||||
}
|
||||
|
||||
private static double gradDot(int hash, double x, double y, double z) {
|
||||
@@ -85,24 +110,69 @@ public final class ImprovedNoise {
|
||||
@@ -83,24 +108,69 @@ public final class ImprovedNoise {
|
||||
}
|
||||
|
||||
private double sampleAndLerp(int sectionX, int sectionY, int sectionZ, double localX, double localY, double localZ, double fadeLocalY) {
|
||||
@@ -105,13 +105,13 @@ index fb84d703b4461343d50510d7c9be32fc1f09ed22..93a11c95f96f975fafe03e77a2caace5
|
||||
- int m = this.p(j + sectionY);
|
||||
- int n = this.p(j + sectionY + 1);
|
||||
- double d = gradDot(this.p(k + sectionZ), localX, localY, localZ);
|
||||
- double e = gradDot(this.p(m + sectionZ), localX - 1.0D, localY, localZ);
|
||||
- double f = gradDot(this.p(l + sectionZ), localX, localY - 1.0D, localZ);
|
||||
- double g = gradDot(this.p(n + sectionZ), localX - 1.0D, localY - 1.0D, localZ);
|
||||
- double h = gradDot(this.p(k + sectionZ + 1), localX, localY, localZ - 1.0D);
|
||||
- double o = gradDot(this.p(m + sectionZ + 1), localX - 1.0D, localY, localZ - 1.0D);
|
||||
- double p = gradDot(this.p(l + sectionZ + 1), localX, localY - 1.0D, localZ - 1.0D);
|
||||
- double q = gradDot(this.p(n + sectionZ + 1), localX - 1.0D, localY - 1.0D, localZ - 1.0D);
|
||||
- double e = gradDot(this.p(m + sectionZ), localX - 1.0, localY, localZ);
|
||||
- double f = gradDot(this.p(l + sectionZ), localX, localY - 1.0, localZ);
|
||||
- double g = gradDot(this.p(n + sectionZ), localX - 1.0, localY - 1.0, localZ);
|
||||
- double h = gradDot(this.p(k + sectionZ + 1), localX, localY, localZ - 1.0);
|
||||
- double o = gradDot(this.p(m + sectionZ + 1), localX - 1.0, localY, localZ - 1.0);
|
||||
- double p = gradDot(this.p(l + sectionZ + 1), localX, localY - 1.0, localZ - 1.0);
|
||||
- double q = gradDot(this.p(n + sectionZ + 1), localX - 1.0, localY - 1.0, localZ - 1.0);
|
||||
- double r = Mth.smoothstep(localX);
|
||||
- double s = Mth.smoothstep(fadeLocalY);
|
||||
- double t = Mth.smoothstep(localZ);
|
||||
@@ -183,7 +183,7 @@ index fb84d703b4461343d50510d7c9be32fc1f09ed22..93a11c95f96f975fafe03e77a2caace5
|
||||
|
||||
private double sampleWithDerivative(int sectionX, int sectionY, int sectionZ, double localX, double localY, double localZ, double[] ds) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinNoise.java b/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinNoise.java
|
||||
index 97ef7288ea935f3d17c5b7a9eba642143c786c2b..6d084145f8529fa8b0439123f9a9812940cc62da 100644
|
||||
index 35820670837376bcad8891241724d5b946fbd31f..eb7aef08bd855416902d3e7988d07576ee13a9cb 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinNoise.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinNoise.java
|
||||
@@ -26,6 +26,10 @@ public class PerlinNoise {
|
||||
@@ -195,12 +195,12 @@ index 97ef7288ea935f3d17c5b7a9eba642143c786c2b..6d084145f8529fa8b0439123f9a98129
|
||||
+ private final double [] amplitudesArray;
|
||||
+ // Gale end - C2ME - optimize noise generation
|
||||
|
||||
/** @deprecated */
|
||||
@Deprecated
|
||||
@@ -131,6 +135,10 @@ public class PerlinNoise {
|
||||
this.lowestFreqInputFactor = Math.pow(2.0D, (double)(-j));
|
||||
this.lowestFreqValueFactor = Math.pow(2.0D, (double)(i - 1)) / (Math.pow(2.0D, (double)i) - 1.0D);
|
||||
this.maxValue = this.edgeValue(2.0D);
|
||||
public static PerlinNoise createLegacyForBlendedNoise(RandomSource random, IntStream octaves) {
|
||||
@@ -127,6 +131,10 @@ public class PerlinNoise {
|
||||
this.lowestFreqInputFactor = Math.pow(2.0, (double)(-j));
|
||||
this.lowestFreqValueFactor = Math.pow(2.0, (double)(i - 1)) / (Math.pow(2.0, (double)i) - 1.0);
|
||||
this.maxValue = this.edgeValue(2.0);
|
||||
+ // Gale start - C2ME - optimize noise generation
|
||||
+ this.octaveSamplersCount = this.noiseLevels.length;
|
||||
+ this.amplitudesArray = this.amplitudes.toDoubleArray();
|
||||
@@ -208,11 +208,11 @@ index 97ef7288ea935f3d17c5b7a9eba642143c786c2b..6d084145f8529fa8b0439123f9a98129
|
||||
}
|
||||
|
||||
protected double maxValue() {
|
||||
@@ -142,7 +150,27 @@ public class PerlinNoise {
|
||||
@@ -138,7 +146,27 @@ public class PerlinNoise {
|
||||
}
|
||||
|
||||
public double getValue(double x, double y, double z) {
|
||||
- return this.getValue(x, y, z, 0.0D, 0.0D, false);
|
||||
- return this.getValue(x, y, z, 0.0, 0.0, false);
|
||||
+ // Gale start - C2ME - optimize noise generation - optimize for common cases
|
||||
+ double d = 0.0;
|
||||
+ double e = this.lowestFreqInputFactor;
|
||||
@@ -236,4 +236,4 @@ index 97ef7288ea935f3d17c5b7a9eba642143c786c2b..6d084145f8529fa8b0439123f9a98129
|
||||
+ // Gale end - C2ME - optimize noise generation - optimize for common cases
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
@Deprecated
|
||||
@@ -1,6 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Tue, 20 Feb 2024 13:21:53 +0000
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 13:42:17 +0800
|
||||
Subject: [PATCH] Gale Faster chunk serialization
|
||||
|
||||
|
||||
@@ -203,21 +203,23 @@ index 0000000000000000000000000000000000000000..349618b7f544bf9a30e0796d4d9a2640
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/util/BitStorage.java b/src/main/java/net/minecraft/util/BitStorage.java
|
||||
index 8bafd5fd7499ba4a04bf706cfd1e156073716e21..f62aab492f231e688b448389b1910e6fc2f5d8e6 100644
|
||||
index 19661e106612b8e4e152085fb398db7bd06acc23..4fd45dc4dca29ac5f0be3b02d8ce17127bdc38cf 100644
|
||||
--- a/src/main/java/net/minecraft/util/BitStorage.java
|
||||
+++ b/src/main/java/net/minecraft/util/BitStorage.java
|
||||
@@ -31,4 +31,6 @@ public interface BitStorage {
|
||||
@@ -21,6 +21,8 @@ public interface BitStorage extends ca.spottedleaf.moonrise.patches.block_counti
|
||||
|
||||
BitStorage copy();
|
||||
|
||||
}
|
||||
// Paper end
|
||||
+
|
||||
+ <T> void compact(net.minecraft.world.level.chunk.Palette<T> srcPalette, net.minecraft.world.level.chunk.Palette<T> dstPalette, short[] out); // Gale - Lithium - faster chunk serialization
|
||||
}
|
||||
+
|
||||
// Paper start - block counting
|
||||
// provide default impl in case mods implement this...
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/util/SimpleBitStorage.java b/src/main/java/net/minecraft/util/SimpleBitStorage.java
|
||||
index 453c1d7e01970fd817d27f59c3b00ffc70e8ca0c..844539798213360831541f49d97f8401d80d030e 100644
|
||||
index 8acf2f2491a8d9d13392c5e89b2bd5c9918285e1..5ff7b2c9d97cb428b7a3a54bd53ab385afe92ce1 100644
|
||||
--- a/src/main/java/net/minecraft/util/SimpleBitStorage.java
|
||||
+++ b/src/main/java/net/minecraft/util/SimpleBitStorage.java
|
||||
@@ -201,4 +201,45 @@ public class SimpleBitStorage implements BitStorage {
|
||||
@@ -401,4 +401,45 @@ public class SimpleBitStorage implements BitStorage {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -264,16 +266,18 @@ index 453c1d7e01970fd817d27f59c3b00ffc70e8ca0c..844539798213360831541f49d97f8401
|
||||
+
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/util/ZeroBitStorage.java b/src/main/java/net/minecraft/util/ZeroBitStorage.java
|
||||
index f8de91393564b3691c17339ac9196cc0fc1cf748..ecfe47110697378d7f7369640cd06b77f6fa0a87 100644
|
||||
index 15c5164d0ef41a978c16ee317fa73e97f2480207..60ffd244d5e1c528d908ee9a5dd2d8907a30bb24 100644
|
||||
--- a/src/main/java/net/minecraft/util/ZeroBitStorage.java
|
||||
+++ b/src/main/java/net/minecraft/util/ZeroBitStorage.java
|
||||
@@ -72,4 +72,6 @@ public class ZeroBitStorage implements BitStorage {
|
||||
public BitStorage copy() {
|
||||
return this;
|
||||
@@ -12,6 +12,8 @@ public class ZeroBitStorage implements BitStorage {
|
||||
this.size = size;
|
||||
}
|
||||
+
|
||||
|
||||
+ @Override public <T> void compact(net.minecraft.world.level.chunk.Palette<T> srcPalette, net.minecraft.world.level.chunk.Palette<T> dstPalette, short[] out) {} // Gale - Lithium - faster chunk serialization
|
||||
}
|
||||
+
|
||||
@Override
|
||||
public final int getAndSet(int index, int value) { // Paper - Perf: Optimize SimpleBitStorage
|
||||
//Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index); // Paper - Perf: Optimize SimpleBitStorage
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/PaletteResize.java b/src/main/java/net/minecraft/world/level/chunk/PaletteResize.java
|
||||
index acae3eb30e0689048937f479dc3070f0688abdad..4b79f0474a9013dd4fdb68c6363ca1942ba8b007 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/PaletteResize.java
|
||||
@@ -286,7 +290,7 @@ index acae3eb30e0689048937f479dc3070f0688abdad..4b79f0474a9013dd4fdb68c6363ca194
|
||||
int onResize(int newBits, T object);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||
index 983799520ce052d98c9231f4f7925492d4f7d5c9..6e7b3ea1819780aef6db3ff0b43998de8f1066bf 100644
|
||||
index 13d3c877b006a4975e7370713e3919c661e7890f..a2e0c9df771483904ffeaf6ef3bd3ab4b189fdb3 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||
@@ -25,6 +25,22 @@ import net.minecraft.util.ThreadingDetector;
|
||||
@@ -310,9 +314,9 @@ index 983799520ce052d98c9231f4f7925492d4f7d5c9..6e7b3ea1819780aef6db3ff0b43998de
|
||||
+ // Gale end - Lithium - faster chunk serialization
|
||||
+
|
||||
private static final int MIN_PALETTE_BITS = 0;
|
||||
private final PaletteResize<T> dummyPaletteResize = (newSize, added) -> {
|
||||
return 0;
|
||||
@@ -302,30 +318,54 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
||||
private final PaletteResize<T> dummyPaletteResize = (newSize, added) -> 0;
|
||||
public final IdMap<T> registry;
|
||||
@@ -304,28 +320,54 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
||||
public synchronized PalettedContainerRO.PackedData<T> pack(IdMap<T> idList, PalettedContainer.Strategy paletteProvider) { // Paper - synchronize
|
||||
this.acquire();
|
||||
|
||||
@@ -325,9 +329,7 @@ index 983799520ce052d98c9231f4f7925492d4f7d5c9..6e7b3ea1819780aef6db3ff0b43998de
|
||||
- int i = paletteProvider.size();
|
||||
- int[] is = new int[i];
|
||||
- this.data.storage.unpack(is);
|
||||
- swapPalette(is, (id) -> {
|
||||
- return hashMapPalette.idFor(this.data.palette.valueFor(id));
|
||||
- });
|
||||
- swapPalette(is, id -> hashMapPalette.idFor(this.data.palette.valueFor(id)));
|
||||
- int j = paletteProvider.calculateBitsForSerialization(idList, hashMapPalette.getSize());
|
||||
- Optional<LongStream> optional;
|
||||
- if (j != 0) {
|
||||
@@ -384,7 +386,7 @@ index 983799520ce052d98c9231f4f7925492d4f7d5c9..6e7b3ea1819780aef6db3ff0b43998de
|
||||
}
|
||||
|
||||
private static <T> void swapPalette(int[] is, IntUnaryOperator applier) {
|
||||
@@ -365,17 +405,37 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
||||
@@ -364,13 +406,33 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
||||
|
||||
@Override
|
||||
public void count(PalettedContainer.CountConsumer<T> counter) {
|
||||
@@ -392,12 +394,8 @@ index 983799520ce052d98c9231f4f7925492d4f7d5c9..6e7b3ea1819780aef6db3ff0b43998de
|
||||
- counter.accept(this.data.palette.valueFor(0), this.data.storage.getSize());
|
||||
- } else {
|
||||
- Int2IntOpenHashMap int2IntOpenHashMap = new Int2IntOpenHashMap();
|
||||
- this.data.storage.getAll((key) -> {
|
||||
- int2IntOpenHashMap.addTo(key, 1);
|
||||
- });
|
||||
- int2IntOpenHashMap.int2IntEntrySet().forEach((entry) -> {
|
||||
- counter.accept(this.data.palette.valueFor(entry.getIntKey()), entry.getIntValue());
|
||||
- });
|
||||
- this.data.storage.getAll(key -> int2IntOpenHashMap.addTo(key, 1));
|
||||
- int2IntOpenHashMap.int2IntEntrySet().forEach(entry -> counter.accept(this.data.palette.valueFor(entry.getIntKey()), entry.getIntValue()));
|
||||
+ // Gale start - Lithium - faster chunk serialization
|
||||
+ int len = this.data.palette().getSize();
|
||||
+
|
||||
@@ -408,12 +406,8 @@ index 983799520ce052d98c9231f4f7925492d4f7d5c9..6e7b3ea1819780aef6db3ff0b43998de
|
||||
+ counter.accept(this.data.palette.valueFor(0), this.data.storage.getSize());
|
||||
+ } else {
|
||||
+ Int2IntOpenHashMap int2IntOpenHashMap = new Int2IntOpenHashMap();
|
||||
+ this.data.storage.getAll((key) -> {
|
||||
+ int2IntOpenHashMap.addTo(key, 1);
|
||||
+ });
|
||||
+ int2IntOpenHashMap.int2IntEntrySet().forEach((entry) -> {
|
||||
+ counter.accept(this.data.palette.valueFor(entry.getIntKey()), entry.getIntValue());
|
||||
+ });
|
||||
+ this.data.storage.getAll(key -> int2IntOpenHashMap.addTo(key, 1));
|
||||
+ int2IntOpenHashMap.int2IntEntrySet().forEach(entry -> counter.accept(this.data.palette.valueFor(entry.getIntKey()), entry.getIntValue()));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@@ -1,21 +1,20 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sat, 6 Apr 2024 05:14:57 +0000
|
||||
Subject: [PATCH] Gale Reduce lambda and Optional allocation in
|
||||
Subject: [PATCH] Gale Reduce lambda and Optional allocation in
|
||||
EntityBasedExplosionDamageCalculator
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java b/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java
|
||||
index 2f9f15d99f8b31e9f13f7f32378b2a9e09bcb5e5..4e4dfb72d5a0b46917999b709c655ccfdae27183 100644
|
||||
index 3527f1621ef9b4f3f8d8bbb93379f13ff141c3be..4e4dfb72d5a0b46917999b709c655ccfdae27183 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java
|
||||
@@ -15,9 +15,17 @@ public class EntityBasedExplosionDamageCalculator extends ExplosionDamageCalcula
|
||||
@@ -15,8 +15,17 @@ public class EntityBasedExplosionDamageCalculator extends ExplosionDamageCalcula
|
||||
|
||||
@Override
|
||||
public Optional<Float> getBlockExplosionResistance(Explosion explosion, BlockGetter world, BlockPos pos, BlockState blockState, FluidState fluidState) {
|
||||
- return super.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState).map((max) -> {
|
||||
- return this.source.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState, max);
|
||||
- });
|
||||
- return super.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState)
|
||||
- .map(max -> this.source.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState, max));
|
||||
+ // Gale start - Lithium - reduce lambda and Optional allocation in EntityBasedExplosionDamageCalculator
|
||||
+ Optional<Float> optionalBlastResistance = super.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState);
|
||||
+ if (optionalBlastResistance.isPresent()) {
|
||||
@@ -1,27 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sat, 6 Apr 2024 05:17:19 +0000
|
||||
Subject: [PATCH] Gale Replace AI goal set with optimized collection
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
||||
index 0f53c206b4c0607e2cda5cfa4edeae5209e897bf..6313020a80cab0b8df8d775431d4aa063c51ce18 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
||||
@@ -13,6 +13,7 @@ import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import org.slf4j.Logger;
|
||||
+import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet;
|
||||
|
||||
public class GoalSelector {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -28,7 +29,7 @@ public class GoalSelector {
|
||||
}
|
||||
};
|
||||
private final Map<Goal.Flag, WrappedGoal> lockedFlags = new EnumMap<>(Goal.Flag.class);
|
||||
- private final Set<WrappedGoal> availableGoals = Sets.newLinkedHashSet();
|
||||
+ private final Set<WrappedGoal> availableGoals = new ObjectLinkedOpenHashSet<>(); // Gale - Lithium - replace AI goal set with optimized collection
|
||||
private final Supplier<ProfilerFiller> profiler;
|
||||
private final EnumSet<Goal.Flag> disabledFlags = EnumSet.noneOf(Goal.Flag.class); // Paper unused, but dummy to prevent plugins from crashing as hard. Theyll need to support paper in a special case if this is super important, but really doesn't seem like it would be.
|
||||
private final com.destroystokyo.paper.util.set.OptimizedSmallEnumSet<net.minecraft.world.entity.ai.goal.Goal.Flag> goalTypes = new com.destroystokyo.paper.util.set.OptimizedSmallEnumSet<>(Goal.Flag.class); // Paper - remove streams from pathfindergoalselector
|
||||
@@ -1,42 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sat, 6 Apr 2024 05:17:42 +0000
|
||||
Subject: [PATCH] Gale Replace AI attributes with optimized collections
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||
index 683c9693754d1a87b7e8fccc757a0d0963351f60..d904cc2d882f62f74ff34f7e8266947798563ed4 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||
@@ -1,8 +1,6 @@
|
||||
package net.minecraft.world.entity.ai.attributes;
|
||||
|
||||
-import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
-import com.google.common.collect.Sets;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
@@ -10,6 +8,9 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap;
|
||||
+import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
@@ -20,8 +21,10 @@ import org.slf4j.Logger;
|
||||
|
||||
public class AttributeMap {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
- private final Map<Attribute, AttributeInstance> attributes = Maps.newHashMap();
|
||||
- private final Set<AttributeInstance> dirtyAttributes = Sets.newHashSet();
|
||||
+ // Gale start - Lithium - replace AI attributes with optimized collections
|
||||
+ private final Map<Attribute, AttributeInstance> attributes = new Reference2ReferenceOpenHashMap<>(0);
|
||||
+ private final Set<AttributeInstance> dirtyAttributes = new ReferenceOpenHashSet<>(0);
|
||||
+ // Gale end - Lithium - replace AI attributes with optimized collections
|
||||
private final AttributeSupplier supplier;
|
||||
private final java.util.function.Function<Attribute, AttributeInstance> createInstance; // Pufferfish
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sat, 6 Apr 2024 05:18:00 +0000
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 14:22:07 +0800
|
||||
Subject: [PATCH] Gale Replace throttle tracker map with optimized collection
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
index a53dd1ea02bd19826cd9fd337459b08e9533bce8..dec666713a1d3b5e3f2aa4bcbe8094ade8be1b05 100644
|
||||
index ddf42645402afefc0f5caebc684b191eef9d6ec2..a943f83e874d348251ddd3feb732e543641172d9 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
@@ -1,5 +1,7 @@
|
||||
@@ -15,8 +15,8 @@ index a53dd1ea02bd19826cd9fd337459b08e9533bce8..dec666713a1d3b5e3f2aa4bcbe8094ad
|
||||
+import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -13,7 +15,8 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.network.DisconnectionDetails;
|
||||
@@ -15,7 +17,8 @@ import net.minecraft.server.MinecraftServer;
|
||||
|
||||
// CraftBukkit start
|
||||
import java.net.InetAddress;
|
||||
@@ -26,7 +26,7 @@ index a53dd1ea02bd19826cd9fd337459b08e9533bce8..dec666713a1d3b5e3f2aa4bcbe8094ad
|
||||
// CraftBukkit end
|
||||
|
||||
public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketListener {
|
||||
@@ -24,7 +27,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
||||
@@ -26,7 +29,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
||||
static final java.util.regex.Pattern PROP_PATTERN = java.util.regex.Pattern.compile("\\w{0,16}");
|
||||
// Spigot end
|
||||
// CraftBukkit start - add fields
|
||||
@@ -35,27 +35,27 @@ index a53dd1ea02bd19826cd9fd337459b08e9533bce8..dec666713a1d3b5e3f2aa4bcbe8094ad
|
||||
private static int throttleCounter = 0;
|
||||
// CraftBukkit end
|
||||
private static final Component IGNORE_STATUS_REASON = Component.translatable("disconnect.ignoring_status_request");
|
||||
@@ -51,7 +54,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
||||
InetAddress address = ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getAddress();
|
||||
@@ -87,7 +90,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
||||
InetAddress address = ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getAddress();
|
||||
|
||||
synchronized (ServerHandshakePacketListenerImpl.throttleTracker) {
|
||||
- if (ServerHandshakePacketListenerImpl.throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - ServerHandshakePacketListenerImpl.throttleTracker.get(address) < connectionThrottle) {
|
||||
synchronized (ServerHandshakePacketListenerImpl.throttleTracker) {
|
||||
- if (ServerHandshakePacketListenerImpl.throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - ServerHandshakePacketListenerImpl.throttleTracker.get(address) < connectionThrottle) {
|
||||
+ if (ServerHandshakePacketListenerImpl.throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - ServerHandshakePacketListenerImpl.throttleTracker.getLong(address) < connectionThrottle) { // Gale - Dionysus - replace throttle tracker map with optimized collection
|
||||
ServerHandshakePacketListenerImpl.throttleTracker.put(address, currentTime);
|
||||
ServerHandshakePacketListenerImpl.throttleTracker.put(address, currentTime);
|
||||
Component chatmessage = io.papermc.paper.adventure.PaperAdventure.asVanilla(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.connectionThrottle); // Paper - Configurable connection throttle kick message
|
||||
this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage));
|
||||
@@ -65,13 +68,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
||||
ServerHandshakePacketListenerImpl.throttleCounter = 0;
|
||||
this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage));
|
||||
@@ -101,13 +104,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
||||
ServerHandshakePacketListenerImpl.throttleCounter = 0;
|
||||
|
||||
// Cleanup stale entries
|
||||
- java.util.Iterator iter = ServerHandshakePacketListenerImpl.throttleTracker.entrySet().iterator();
|
||||
- while (iter.hasNext()) {
|
||||
- java.util.Map.Entry<InetAddress, Long> entry = (java.util.Map.Entry) iter.next();
|
||||
- if (entry.getValue() > connectionThrottle) {
|
||||
- iter.remove();
|
||||
- }
|
||||
- }
|
||||
// Cleanup stale entries
|
||||
- java.util.Iterator iter = ServerHandshakePacketListenerImpl.throttleTracker.entrySet().iterator();
|
||||
- while (iter.hasNext()) {
|
||||
- java.util.Map.Entry<InetAddress, Long> entry = (java.util.Map.Entry) iter.next();
|
||||
- if (entry.getValue() > connectionThrottle) {
|
||||
- iter.remove();
|
||||
- }
|
||||
- }
|
||||
+ throttleTracker.object2LongEntrySet().removeIf(entry -> entry.getLongValue() > connectionThrottle); // Gale - Dionysus - replace throttle tracker map with optimized collection
|
||||
}
|
||||
}
|
||||
} // Paper - Unix domain socket support
|
||||
}
|
||||
}
|
||||
} // Paper - Unix domain socket support
|
||||
@@ -1,27 +1,27 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sun, 28 Jan 2024 09:11:58 +0000
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 14:25:46 +0800
|
||||
Subject: [PATCH] Sparkly Paper Optimize canSee checks
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index 76ad4d8bce1611ead6f1596b2ba78267e3718655..d1dc02b3e4f775c9bd79073a8e96243aa5ab6c24 100644
|
||||
index 74524dcd4539a31e9d0037cd607ffbfce02f414c..9d6d0c8c2a869c088b7ece7f3390f620d2c348b9 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -1408,7 +1408,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -1222,7 +1222,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
// Folia end - region threading
|
||||
|
||||
// CraftBukkit start - respect vanish API
|
||||
- if (flag && (!io.papermc.paper.util.TickThread.isTickThreadFor(player) || !player.getBukkitEntity().canSee(this.entity.getBukkitEntity()))) { // Paper - only consider hits // Folia - region threading
|
||||
+ if (flag && (!io.papermc.paper.util.TickThread.isTickThreadFor(player) || !player.getBukkitEntity().canSeeChunkMapUpdatePlayer(this.entity.getBukkitEntity()))) { // Paper - only consider hits // Folia - region threading // SparklyPaper - optimize canSee checks
|
||||
- if (flag && (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(player) || !player.getBukkitEntity().canSee(this.entity.getBukkitEntity()))) { // Paper - only consider hits // Folia - region threading
|
||||
+ if (flag && (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(player) || !player.getBukkitEntity().canSeeChunkMapUpdatePlayer(this.entity.getBukkitEntity()))) { // Paper - only consider hits // Folia - region threading // SparklyPaper - optimize canSee checks
|
||||
flag = false;
|
||||
}
|
||||
// CraftBukkit end
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 26f70965b45fa3c344781b569a651a4668d0621d..49f207b7e06a3f939dc6c9b4a078f6db7b779618 100644
|
||||
index 77576c06ffc0a677b1bfb63d48d39fba2aa2050d..4dfc7186b7ee0f77e681911fc93edc455e7bf19f 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -187,7 +187,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@@ -200,7 +200,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
private boolean hasPlayedBefore = false;
|
||||
private final ConversationTracker conversationTracker = new ConversationTracker();
|
||||
private final Set<String> channels = new HashSet<String>();
|
||||
@@ -30,7 +30,7 @@ index 26f70965b45fa3c344781b569a651a4668d0621d..49f207b7e06a3f939dc6c9b4a078f6db
|
||||
private final Set<UUID> unlistedEntities = new HashSet<>(); // Paper - Add Listing API for Player
|
||||
private static final WeakHashMap<Plugin, WeakReference<Plugin>> pluginWeakReferences = new WeakHashMap<>();
|
||||
private int hash = 0;
|
||||
@@ -2146,9 +2146,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@@ -2257,9 +2257,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
@Override
|
||||
public boolean canSee(org.bukkit.entity.Entity entity) {
|
||||
@@ -45,6 +45,6 @@ index 26f70965b45fa3c344781b569a651a4668d0621d..49f207b7e06a3f939dc6c9b4a078f6db
|
||||
+ }
|
||||
+ // SparklyPaper end
|
||||
+
|
||||
public boolean canSee(UUID uuid) {
|
||||
public boolean canSeePlayer(UUID uuid) {
|
||||
org.bukkit.entity.Entity entity = this.getServer().getPlayer(uuid);
|
||||
if (entity == null) {
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 06:30:38 +0000
|
||||
Subject: [PATCH] LinearPaper Remove all locks on region files
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java b/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java
|
||||
index b46acbc078f3d3bfb0f3ede3f1cc172f4b48c5df..812d8504c6abd16b34ee4abd976563f345f00d18 100644
|
||||
--- a/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java
|
||||
+++ b/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java
|
||||
@@ -835,7 +835,8 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
- return file.hasChunk(chunkPos) ? Boolean.TRUE : Boolean.FALSE;
|
||||
+ //return file.hasChunk(chunkPos) ? Boolean.TRUE : Boolean.FALSE;
|
||||
+ return Boolean.TRUE;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1146,7 +1147,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
return function.apply(regionFile);
|
||||
} finally {
|
||||
if (regionFile != null) {
|
||||
- regionFile.getFileLock().unlock(); // Kaiiju
|
||||
+// regionFile.getFileLock().unlock(); // Kaiiju
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1158,7 +1159,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
synchronized (cache) {
|
||||
regionFile = cache.getRegionFileIfLoaded(new ChunkPos(chunkX, chunkZ));
|
||||
if (regionFile != null) {
|
||||
- regionFile.getFileLock().lock(); // Kaiiju
|
||||
+// regionFile.getFileLock().lock(); // Kaiiju
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1166,7 +1167,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
return function.apply(regionFile);
|
||||
} finally {
|
||||
if (regionFile != null) {
|
||||
- regionFile.getFileLock().unlock(); // Kaiiju
|
||||
+// regionFile.getFileLock().unlock(); // Kaiiju
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
index db9e4386ca95bdaba0a4a4e13e3a90d2bcfbae91..73fc6d393cb338fee7d866b99a4e25684d47e79b 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
@@ -120,7 +120,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
// Paper start
|
||||
if (lock) {
|
||||
// must be in this synchronized block
|
||||
- regionfile.getFileLock().lock(); // Kaiiju
|
||||
+// regionfile.getFileLock().lock(); // Kaiiju
|
||||
}
|
||||
// Paper end
|
||||
return regionfile;
|
||||
@@ -169,7 +169,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
// Paper start
|
||||
if (lock) {
|
||||
// must be in this synchronized block
|
||||
- regionfile1.getFileLock().lock(); // Kaiiju
|
||||
+// regionfile1.getFileLock().lock(); // Kaiiju
|
||||
}
|
||||
// Paper end
|
||||
return regionfile1;
|
||||
@@ -249,7 +249,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
if (!chunkPos.equals(pos)) {
|
||||
net.minecraft.server.MinecraftServer.LOGGER.error("Attempting to read chunk data at " + pos + " but got chunk data for " + chunkPos + " instead! Attempting regionfile recalculation for regionfile " + regionfile.getRegionFile().toAbsolutePath()); // Kaiiju
|
||||
if (regionfile.recalculateHeader()) {
|
||||
- regionfile.getFileLock().lock(); // otherwise we will unlock twice and only lock once. // Kaiiju
|
||||
+// regionfile.getFileLock().lock(); // otherwise we will unlock twice and only lock once. // Kaiiju
|
||||
return this.read(pos, regionfile);
|
||||
}
|
||||
net.minecraft.server.MinecraftServer.LOGGER.error("Can't recalculate regionfile header, regenerating chunk " + pos + " for " + regionfile.getRegionFile().toAbsolutePath()); // Kaiiju
|
||||
@@ -286,7 +286,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
|
||||
return nbttagcompound;
|
||||
} finally { // Paper start
|
||||
- regionfile.getFileLock().unlock(); // Kaiiju
|
||||
+// regionfile.getFileLock().unlock(); // Kaiiju
|
||||
} // Paper end
|
||||
}
|
||||
|
||||
@@ -378,7 +378,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
// Paper end - Chunk save reattempt
|
||||
// Paper start - rewrite chunk system
|
||||
} finally {
|
||||
- regionfile.getFileLock().unlock(); // Kaiiju
|
||||
+ //regionfile.getFileLock().unlock(); // Kaiiju
|
||||
}
|
||||
// Paper end - rewrite chunk system
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 14:28:06 +0800
|
||||
Subject: [PATCH] SparklyPaper Skip "MapItem#update()" if the map does not have
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/MapItemUpdateSkipConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/MapItemUpdateSkipConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..6235ff18455a21695bdc2d65367558d3936a45c5
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/MapItemUpdateSkipConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.optimizations;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class MapItemUpdateSkipConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = true;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.OPTIMIZATIONS;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "skip_map_item_updates_if_no_bukkit_render";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/item/MapItem.java b/src/main/java/net/minecraft/world/item/MapItem.java
|
||||
index e96f15814986109e5e947c7b3b210be6e56ba0ed..31354cbf344c222a8e6e892091ea30d81b8b2706 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/MapItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/MapItem.java
|
||||
@@ -281,7 +281,7 @@ public class MapItem extends ComplexItem {
|
||||
mapItemSavedData.tickCarriedBy(player, stack);
|
||||
}
|
||||
|
||||
- if (!mapItemSavedData.locked && (selected || entity instanceof Player && ((Player)entity).getOffhandItem() == stack)) {
|
||||
+ if (!mapItemSavedData.locked && (!me.earthme.luminol.config.modules.optimizations.MapItemUpdateSkipConfig.enabled || mapItemSavedData.mapView.getRenderers().stream().anyMatch(mapRenderer -> mapRenderer.getClass() == org.bukkit.craftbukkit.map.CraftMapRenderer.class)) && (selected || 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(world, entity, mapItemSavedData);
|
||||
}
|
||||
} // Folia - region threading
|
||||
@@ -0,0 +1,28 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sun, 4 Aug 2024 22:29:01 +0800
|
||||
Subject: [PATCH] SparklyPaper Skip "distanceToSqr" call in
|
||||
"ServerEntity#sendChanges" if the delta movement hasn't changed
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
index 8ea2f24695f5dad55e21f238b69442513e7a90c6..08270040b4bfc6a4a65453d0d997b78425ec7a8f 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
@@ -216,6 +216,8 @@ public class ServerEntity {
|
||||
|
||||
if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) {
|
||||
Vec3 vec3d1 = this.entity.getDeltaMovement();
|
||||
+
|
||||
+ if (vec3d1 != this.lastSentMovement) { // SparklyPaper start - skip distanceToSqr call in ServerEntity#sendChanges if the delta movement hasn't changed
|
||||
double d0 = vec3d1.distanceToSqr(this.lastSentMovement);
|
||||
|
||||
if (d0 > 1.0E-7D || d0 > 0.0D && vec3d1.lengthSqr() == 0.0D) {
|
||||
@@ -230,6 +232,7 @@ public class ServerEntity {
|
||||
this.broadcast.accept(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement));
|
||||
}
|
||||
}
|
||||
+ } // SparklyPaper end
|
||||
}
|
||||
|
||||
if (packet1 != null) {
|
||||
@@ -0,0 +1,518 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Fri, 25 Oct 2024 00:09:17 +0800
|
||||
Subject: [PATCH] KioCG Chunk API and display of chunkhot in tpsbar
|
||||
|
||||
|
||||
diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/ChunkSystem.java b/src/main/java/ca/spottedleaf/moonrise/common/util/ChunkSystem.java
|
||||
index 83b052dbf6d21775664b286518f3cef1d86e87d1..c6c5292e96ef610b6edbb9341fda97d4cdec30e3 100644
|
||||
--- a/src/main/java/ca/spottedleaf/moonrise/common/util/ChunkSystem.java
|
||||
+++ b/src/main/java/ca/spottedleaf/moonrise/common/util/ChunkSystem.java
|
||||
@@ -113,6 +113,7 @@ public final class ChunkSystem {
|
||||
}
|
||||
|
||||
public static void onChunkNotTicking(final LevelChunk chunk, final ChunkHolder holder) {
|
||||
+ chunk.getChunkHot().clear(); // KioCG
|
||||
chunk.getLevel().getCurrentWorldData().removeTickingChunk(chunk.moonrise$getChunkAndHolder()); // Folia - region threading
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/com/kiocg/ChunkHot.java b/src/main/java/com/kiocg/ChunkHot.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..53b4397997bc9b9b9d88e48304b37a2590161906
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/kiocg/ChunkHot.java
|
||||
@@ -0,0 +1,90 @@
|
||||
+package com.kiocg;
|
||||
+
|
||||
+import java.util.Arrays;
|
||||
+
|
||||
+public class ChunkHot {
|
||||
+ // 热度统计总区间数量
|
||||
+ private static final int TIMES_LENGTH = 10;
|
||||
+ // 当前统计区间下标
|
||||
+ private int index = -1;
|
||||
+
|
||||
+ // 热度统计区间
|
||||
+ private final long[] times = new long[TIMES_LENGTH];
|
||||
+ // 存放临时的区间数值
|
||||
+ // 用于修正正在统计的当前区间热度没有计入总值的问题
|
||||
+ private long temp;
|
||||
+ // 所有区间的热度总值
|
||||
+ private long total;
|
||||
+
|
||||
+ // 用于每个具体统计的计算
|
||||
+ private long nanos;
|
||||
+ // 当前统计是否进行中
|
||||
+ private volatile boolean started = false;
|
||||
+
|
||||
+ /**
|
||||
+ * 更新区间下标
|
||||
+ */
|
||||
+ public void nextTick() {
|
||||
+ this.index = ++this.index % TIMES_LENGTH;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * 开始统计一个新区间
|
||||
+ */
|
||||
+ public void start() {
|
||||
+ started = true;
|
||||
+ temp = times[this.index];
|
||||
+ times[this.index] = 0L;
|
||||
+ }
|
||||
+
|
||||
+ public boolean isStarted(){
|
||||
+ return this.started;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * 结束当前区间的统计
|
||||
+ * 将统计值更新入热度总值
|
||||
+ */
|
||||
+ public void stop() {
|
||||
+ started = false;
|
||||
+ total -= temp;
|
||||
+ total += times[this.index];
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * 开始一个具体统计
|
||||
+ */
|
||||
+ public void startTicking() {
|
||||
+ if (!started) return;
|
||||
+ nanos = System.nanoTime();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * 结束一个具体统计
|
||||
+ * 将统计值计入当前热度区间
|
||||
+ */
|
||||
+ public void stopTickingAndCount() {
|
||||
+ if (!started) return;
|
||||
+ // 定义一个具体统计的最大值为 1,000,000
|
||||
+ // 有时候某个具体统计的计算值会在某1刻飙升,可能是由于保存数据到磁盘?
|
||||
+ times[this.index] += Math.min(System.nanoTime() - nanos, 1000000L);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * 清空统计 (当区块卸载时)
|
||||
+ */
|
||||
+ public void clear() {
|
||||
+ started = false;
|
||||
+ Arrays.fill(times, 0L);
|
||||
+ temp = 0L;
|
||||
+ total = 0L;
|
||||
+ nanos = 0L;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * @return 获取区块热度平均值
|
||||
+ */
|
||||
+ public long getAverage() {
|
||||
+ return total / ((long) TIMES_LENGTH * 20L);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/TpsBarConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/TpsBarConfig.java
|
||||
index aafb2f5052c7c8e5971a47308253badb3027093c..9fe7ac7ba83bbcc9a2a851a5cace47641323f4d2 100644
|
||||
--- a/src/main/java/me/earthme/luminol/config/modules/misc/TpsBarConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/TpsBarConfig.java
|
||||
@@ -12,11 +12,13 @@ public class TpsBarConfig implements IConfigModule {
|
||||
@ConfigInfo(baseName = "enabled")
|
||||
public static boolean tpsbarEnabled = false;
|
||||
@ConfigInfo(baseName = "format")
|
||||
- public static String tpsBarFormat = "<gray>TPS<yellow>:</yellow> <tps> MSPT<yellow>:</yellow> <mspt> Ping<yellow>:</yellow> <ping>ms";
|
||||
+ public static String tpsBarFormat = "<gray>TPS<yellow>:</yellow> <tps> MSPT<yellow>:</yellow> <mspt> Ping<yellow>:</yellow> <ping>ms ChunkHot<yellow>:</yellow> <chunkhot>";
|
||||
@ConfigInfo(baseName = "tps_color_list")
|
||||
public static List<String> tpsColors = List.of("GREEN","YELLOW","RED","PURPLE");
|
||||
@ConfigInfo(baseName = "ping_color_list")
|
||||
public static List<String> pingColors = List.of("GREEN","YELLOW","RED","PURPLE");
|
||||
+ @ConfigInfo(baseName = "chunkhot_color_list")
|
||||
+ public static List<String> chunkHotColors = List.of("GREEN","YELLOW","RED","PURPLE");
|
||||
@ConfigInfo(baseName = "update_interval_ticks")
|
||||
public static int updateInterval = 15;
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java b/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java
|
||||
index 026807e0851d67c6d57e81f573ac1bf8fedc6109..c45f6bd60d1cf7a915aa6ceea07c0929507b86e2 100644
|
||||
--- a/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java
|
||||
+++ b/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java
|
||||
@@ -138,7 +138,8 @@ public class GlobalServerTpsBar {
|
||||
TpsBarConfig.tpsBarFormat,
|
||||
Placeholder.component("tps",getTpsComponent(tps)),
|
||||
Placeholder.component("mspt",getMsptComponent(mspt)),
|
||||
- Placeholder.component("ping",getPingComponent(player.getPing()))
|
||||
+ Placeholder.component("ping",getPingComponent(player.getPing())),
|
||||
+ Placeholder.component("chunkhot",getChunkHotComponent(player.getNearbyChunkHot()))
|
||||
));
|
||||
bar.color(barColorFromTps(tps));
|
||||
bar.progress((float) Math.min((float)1,Math.max(mspt / 50,0)));
|
||||
@@ -180,6 +181,32 @@ public class GlobalServerTpsBar {
|
||||
return MiniMessage.miniMessage().deserialize(replaced,Placeholder.parsed("text", String.format("%.2f", mspt)));
|
||||
}
|
||||
|
||||
+ private static @NotNull Component getChunkHotComponent(long chunkHot){
|
||||
+ final BossBar.Color colorBukkit = barColorFromChunkHot(chunkHot);
|
||||
+ final String colorString = colorBukkit.name();
|
||||
+
|
||||
+ final String content = "<%s><text></%s>";
|
||||
+ final String replaced = String.format(content,colorString,colorString);
|
||||
+
|
||||
+ return MiniMessage.miniMessage().deserialize(replaced,Placeholder.parsed("text", String.valueOf(chunkHot)));
|
||||
+ }
|
||||
+
|
||||
+ private static BossBar.Color barColorFromChunkHot(long chunkHot){
|
||||
+ if (chunkHot == -1){
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.chunkHotColors.get(3));
|
||||
+ }
|
||||
+
|
||||
+ if (chunkHot <= 300000L){
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.chunkHotColors.get(0));
|
||||
+ }
|
||||
+
|
||||
+ if (chunkHot <= 500000L){
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.chunkHotColors.get(1));
|
||||
+ }
|
||||
+
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.chunkHotColors.get(2));
|
||||
+ }
|
||||
+
|
||||
private static BossBar.Color barColorFromMspt(double mspt){
|
||||
if (mspt == -1){
|
||||
return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(3));
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 29103346dd3e5e69de260c95051c9447fda0da41..93cc0a7562dce407b486007a9dd33652d2b75b90 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1715,6 +1715,29 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
// Folia end - region threading
|
||||
|
||||
+ // KioCG start - ChunkHot
|
||||
+ final ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<net.minecraft.world.level.chunk.LevelChunk> chunks = new ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<>();
|
||||
+ if (region != null){
|
||||
+ for (net.minecraft.server.level.ServerChunkCache.ChunkAndHolder chunkAndHolder : region.world.getCurrentWorldData().getTickingChunks()){
|
||||
+ final net.minecraft.world.level.chunk.LevelChunk chunk = chunkAndHolder.chunk();
|
||||
+
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(region.world, chunk.locX, chunk.locZ)){
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ chunks.add(chunk);
|
||||
+ }
|
||||
+ }
|
||||
+ if (region != null && io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick() % 20 == 0){
|
||||
+ final Iterator<net.minecraft.world.level.chunk.LevelChunk> chunkIterator = chunks.unsafeIterator();
|
||||
+ while (chunkIterator.hasNext()){
|
||||
+ final net.minecraft.world.level.chunk.LevelChunk targetChunk = chunkIterator.next();
|
||||
+
|
||||
+ targetChunk.getChunkHot().nextTick();
|
||||
+ targetChunk.getChunkHot().start();
|
||||
+ }
|
||||
+ }
|
||||
+ //KioCG end
|
||||
// Folia - region threading
|
||||
if (region == null) this.tickRateManager.tick(); // Folia - region threading
|
||||
this.tickChildren(shouldKeepTicking, region); // Folia - region threading
|
||||
@@ -1724,6 +1747,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
|
||||
// Folia - region threading
|
||||
+ // KioCG start - ChunkHot
|
||||
+ if (region != null && io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick() % 20 == 0){
|
||||
+ final Iterator<net.minecraft.world.level.chunk.LevelChunk> chunkIterator = chunks.unsafeIterator();
|
||||
+ while (chunkIterator.hasNext()){
|
||||
+ final net.minecraft.world.level.chunk.LevelChunk targetChunk = chunkIterator.next();
|
||||
+
|
||||
+ if (!targetChunk.getChunkHot().isStarted()){
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ targetChunk.getChunkHot().stop();
|
||||
+ }
|
||||
+ }
|
||||
+ //KioCG end
|
||||
// Paper start - Incremental chunk and player saving
|
||||
int playerSaveInterval = io.papermc.paper.configuration.GlobalConfiguration.get().playerAutoSave.rate;
|
||||
if (playerSaveInterval < 0) {
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 3ebea71bbc6ced0d0a325c519436a0199666fafb..2f9ba0b4298206f458d7cd7ca73c132477a0d7b7 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1377,6 +1377,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
|
||||
final int timerId = isActive ? entity.getType().tickTimerId : entity.getType().inactiveTickTimerId;
|
||||
final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler();
|
||||
profiler.startTimer(timerId);
|
||||
+ LevelChunk levelChunk = entity.shouldTickHot() ? this.getChunkIfLoaded(entity.moonrise$getSectionX(),entity.moonrise$getSectionZ()) : null; // KioCG
|
||||
+ if (levelChunk != null) levelChunk.getChunkHot().startTicking(); try { // KioCG
|
||||
// Folia end - timer
|
||||
try {
|
||||
// Paper end - timings
|
||||
@@ -1404,6 +1406,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
|
||||
} else { entity.inactiveTick(); } // Paper - EAR 2
|
||||
this.getProfiler().pop();
|
||||
} finally { timer.stopTiming(); profiler.stopTimer(timerId); } // Paper - timings // Folia - timer
|
||||
+ } finally { if (levelChunk != null) levelChunk.getChunkHot().stopTickingAndCount(); } // KioCG
|
||||
Iterator iterator = entity.getPassengers().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -1432,6 +1435,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
|
||||
final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler();
|
||||
profiler.startTimer(timerId);
|
||||
// Folia end - timer
|
||||
+ LevelChunk levelChunk = !(passenger instanceof Player) ? this.getChunkIfLoaded(passenger.blockPosition()) : null; // KioCG
|
||||
+ if (levelChunk != null) levelChunk.getChunkHot().startTicking(); try { // KioCG
|
||||
try {
|
||||
// Paper end
|
||||
passenger.setOldPosAndRot();
|
||||
@@ -1472,6 +1477,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
|
||||
}
|
||||
|
||||
} finally { timer.stopTiming(); profiler.stopTimer(timerId); }// Paper - EAR2 timings // Folia - timer
|
||||
+ } finally { if (levelChunk != null) levelChunk.getChunkHot().stopTickingAndCount(); } // KioCG
|
||||
}
|
||||
} else {
|
||||
passenger.stopRiding();
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 8cfaa94da67bcdd5c3d30479379d384c20b4a1ac..8559d14e4136c9e70c4190db3eb04500c9e530f0 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -339,6 +339,26 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
||||
public boolean handlingMoveEvent = false;
|
||||
//Luminol end
|
||||
|
||||
+ // KioCG start - ChunkHot
|
||||
+ private volatile long nearbyChunkHot = 0;
|
||||
+
|
||||
+ public long getNearbyChunkHot() { return this.nearbyChunkHot; }
|
||||
+
|
||||
+ private long refreshNearbyChunkHot() {
|
||||
+ long total = 0L;
|
||||
+ int searchRadius = ((ServerLevel) this.level()).moonrise$getViewDistanceHolder().getViewDistances().tickViewDistance();
|
||||
+ for (int i = this.moonrise$getSectionX() - searchRadius; i <= this.moonrise$getSectionX() + searchRadius; ++i) {
|
||||
+ for (int j = this.moonrise$getSectionZ() - searchRadius; j <= this.moonrise$getSectionZ() + searchRadius; ++j) {
|
||||
+ net.minecraft.world.level.chunk.LevelChunk targetChunk = this.level().getChunkIfLoaded(i, j);
|
||||
+ if (targetChunk != null) {
|
||||
+ total += targetChunk.getChunkHot().getAverage();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return total;
|
||||
+ }
|
||||
+ // KioCG end
|
||||
+
|
||||
public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, ClientInformation clientOptions) {
|
||||
super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile);
|
||||
this.chatVisibility = ChatVisiblity.FULL;
|
||||
@@ -970,6 +990,12 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
||||
this.trackEnteredOrExitedLavaOnVehicle();
|
||||
this.updatePlayerAttributes();
|
||||
this.advancements.flushDirty(this);
|
||||
+
|
||||
+ // KioCG start - ChunkHot
|
||||
+ if (this.tickCount % 20 == 0){
|
||||
+ this.nearbyChunkHot = this.refreshNearbyChunkHot();
|
||||
+ }
|
||||
+ // KioCG end
|
||||
}
|
||||
|
||||
private void updatePlayerAttributes() {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
||||
index 1859477e96709368683fe5707327e92f56fbfc8e..4c4814094552fa4382b1cbe649f24f473cdbf22e 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
||||
@@ -449,4 +449,11 @@ public class AreaEffectCloud extends Entity implements TraceableEntity {
|
||||
public EntityDimensions getDimensions(Pose pose) {
|
||||
return EntityDimensions.scalable(this.getRadius() * 2.0F, 0.5F);
|
||||
}
|
||||
+
|
||||
+ // KioCG start
|
||||
+ @Override
|
||||
+ public boolean shouldTickHot() {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // KioCG end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index e20533b2ab9f39fc942271b704d644fb382376f7..7c54abc8480b4184dc3712f02bd2ae2189ac0cc8 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -5860,4 +5860,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
return ((net.minecraft.server.level.ServerChunkCache) level.getChunkSource()).isPositionTicking(this);
|
||||
}
|
||||
// Paper end - Expose entity id counter
|
||||
+
|
||||
+ public boolean shouldTickHot() { return this.tickCount > 20 * 10 && this.isAlive(); } // KioCG
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LightningBolt.java b/src/main/java/net/minecraft/world/entity/LightningBolt.java
|
||||
index 4f701788bd21b61cad251a3a88f9bc416fb99051..86caa40a91ee0385bc32fd19d0fec6bd2f3634d2 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LightningBolt.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LightningBolt.java
|
||||
@@ -288,4 +288,11 @@ public class LightningBolt extends Entity {
|
||||
public Stream<Entity> getHitEntities() {
|
||||
return this.hitEntities.stream().filter(Entity::isAlive);
|
||||
}
|
||||
+
|
||||
+ // KioCG start
|
||||
+ @Override
|
||||
+ public boolean shouldTickHot() {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // KioCG end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index bc20ef314b20de38412522edcab99aaa4ba9ac32..33a895183ddb34626a4d2b40b97ff9a5c7bbfb82 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -1854,4 +1854,11 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
|
||||
return itemmonsteregg == null ? null : new ItemStack(itemmonsteregg);
|
||||
}
|
||||
+
|
||||
+ // KioCG start
|
||||
+ @Override
|
||||
+ public boolean shouldTickHot() {
|
||||
+ return super.shouldTickHot() && (!this.removeWhenFarAway(0.0) || this.isPersistenceRequired() || this.requiresCustomPersistence());
|
||||
+ }
|
||||
+ // KioCG end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/TraderLlama.java b/src/main/java/net/minecraft/world/entity/animal/horse/TraderLlama.java
|
||||
index bbfc94237bbd546361cc4a7bde773c810e8c5d49..d9f48fe2bcf1a2e317e97046618c056b05643268 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/horse/TraderLlama.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/horse/TraderLlama.java
|
||||
@@ -166,4 +166,11 @@ public class TraderLlama extends Llama {
|
||||
super.start();
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // KioCG start
|
||||
+ @Override
|
||||
+ public boolean shouldTickHot() {
|
||||
+ return super.shouldTickHot() && !this.canDespawn();
|
||||
+ }
|
||||
+ // KioCG end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
|
||||
index 0af34e0f9c9696fbcb11b12fb27472ef17ad532a..08c4ae0830cd523eb2cbf7e65b6a5b8a5366d45e 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
|
||||
@@ -326,4 +326,12 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill
|
||||
return !pos.closerToCenterThan(this.trader.position(), proximityDistance);
|
||||
}
|
||||
}
|
||||
+
|
||||
+
|
||||
+ // KioCG start
|
||||
+ @Override
|
||||
+ public boolean shouldTickHot() {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // KioCG end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
index b3377ed06d703f54e01ba174e5a06dc928cdff96..80af7979f9a2078a6c40c958ced1d487b92542d8 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
@@ -2516,4 +2516,12 @@ public abstract class Player extends LivingEntity {
|
||||
return this.message;
|
||||
}
|
||||
}
|
||||
+
|
||||
+
|
||||
+ // KioCG start
|
||||
+ @Override
|
||||
+ public boolean shouldTickHot() {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // KioCG end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
index 2f0a40134ef2fcccf407a5381994c3454040097e..4abfdad701a91b9c20b22064adb943c7e3d5a9a1 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
@@ -437,4 +437,11 @@ public abstract class Projectile extends Entity implements TraceableEntity {
|
||||
|
||||
return DoubleDoubleImmutablePair.of(d0, d1);
|
||||
}
|
||||
+
|
||||
+ // KioCG start
|
||||
+ @Override
|
||||
+ public boolean shouldTickHot() {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // KioCG end
|
||||
}
|
||||
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 ea95a382561dcf2bb958a08351d493087a49336a..054587c3a072b0480a3cff0ef9148d708e600baf 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
@@ -92,6 +92,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
private final Int2ObjectMap<GameEventListenerRegistry> gameEventListenerRegistrySections;
|
||||
private final LevelChunkTicks<Block> blockTicks;
|
||||
private final LevelChunkTicks<Fluid> fluidTicks;
|
||||
+ private final com.kiocg.ChunkHot chunkHot = new com.kiocg.ChunkHot(); public com.kiocg.ChunkHot getChunkHot() { return this.chunkHot; } // KioCG
|
||||
|
||||
public LevelChunk(Level world, ChunkPos pos) {
|
||||
this(world, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, (LevelChunkSection[]) null, (LevelChunk.PostLoadProcessor) null, (BlendingData) null);
|
||||
@@ -1051,6 +1052,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
|
||||
gameprofilerfiller.push(this::getType);
|
||||
this.blockEntity.tickTimer.startTiming(); // Spigot
|
||||
+ LevelChunk.this.chunkHot.startTicking(); // KioCG
|
||||
profiler.startTimer(timerId); try { // Folia - profiler
|
||||
BlockState iblockdata = LevelChunk.this.getBlockState(blockposition);
|
||||
|
||||
@@ -1081,6 +1083,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
} finally {
|
||||
this.blockEntity.tickTimer.stopTiming();
|
||||
// Spigot end
|
||||
+ LevelChunk.this.chunkHot.stopTickingAndCount(); // KioCG
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/redstone/NeighborUpdater.java b/src/main/java/net/minecraft/world/level/redstone/NeighborUpdater.java
|
||||
index e679b40b9628b0eb7152978ef641f9c918c4c8b2..bf9ae765242bb61d3e279893b0355d122cb1e985 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/redstone/NeighborUpdater.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/redstone/NeighborUpdater.java
|
||||
@@ -63,7 +63,10 @@ public interface NeighborUpdater {
|
||||
}
|
||||
}
|
||||
// CraftBukkit end
|
||||
+ net.minecraft.world.level.chunk.LevelChunk levelChunk = world.getChunkIfLoaded(pos); // KioCG
|
||||
+ if (levelChunk != null) levelChunk.getChunkHot().startTicking(); try { // KioCG
|
||||
state.handleNeighborChanged(world, pos, sourceBlock, sourcePos, notify);
|
||||
+ } finally { if (levelChunk != null) levelChunk.getChunkHot().stopTickingAndCount(); } // KioCG
|
||||
// Spigot Start
|
||||
} catch (StackOverflowError ex) {
|
||||
world.lastPhysicsProblem = new BlockPos(pos);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
|
||||
index 45e262308aebafa377a2353661acdd122933b99e..10b2261169d3cd10d736273fe7703f509fe2dffc 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
|
||||
@@ -436,4 +436,12 @@ public class CraftChunk implements Chunk {
|
||||
static {
|
||||
Arrays.fill(FULL_LIGHT, (byte) 0xFF);
|
||||
}
|
||||
+
|
||||
+ // KioCG start - ChunkHot
|
||||
+ @Override
|
||||
+ public long getChunkHotAvg() {
|
||||
+ final net.minecraft.world.level.chunk.LevelChunk target = this.worldServer.getChunkIfLoaded(this.x,this.z);
|
||||
+ return target == null ? -1 : target.getChunkHot().getAverage();
|
||||
+ }
|
||||
+ // KioCG end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 4dfc7186b7ee0f77e681911fc93edc455e7bf19f..4fb1abfa81b02198c823d6e175bde611a321edd3 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -3599,4 +3599,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundEntityEventPacket(((CraftEntity) target).getHandle(), effect.getData()));
|
||||
}
|
||||
// Paper end - entity effect API
|
||||
+
|
||||
+ // KioCG start - ChunkHot
|
||||
+ @Override
|
||||
+ public long getNearbyChunkHot() {
|
||||
+ return this.getHandle().getNearbyChunkHot();
|
||||
+ }
|
||||
+ // KioCG end
|
||||
}
|
||||
@@ -1,583 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 08:51:49 +0000
|
||||
Subject: [PATCH] Leaves Protocol Core
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/RegionizedServer.java b/src/main/java/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||
index 1ae61bc6603dd3ac290e3ead20416f9c5b63ff02..168ed2c21aed6a10f3aca259880b1b8bdbf98b78 100644
|
||||
--- a/src/main/java/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||
+++ b/src/main/java/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||
@@ -314,6 +314,8 @@ public final class RegionizedServer {
|
||||
|
||||
// player list
|
||||
MinecraftServer.getServer().getPlayerList().tick();
|
||||
+
|
||||
+ top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleTick(); //Leaves
|
||||
}
|
||||
|
||||
private void tickPlayerSample() {
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java b/src/main/java/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java
|
||||
index af86f752c33a2990405fea058b7c41c437ba9d46..bada9fae1e7178162429e1f5a1608b9c4a680a6c 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java
|
||||
@@ -20,7 +20,12 @@ public record ServerboundCustomPayloadPacket(CustomPacketPayload payload) implem
|
||||
|
||||
private static CustomPacketPayload readPayload(ResourceLocation id, FriendlyByteBuf buf) {
|
||||
FriendlyByteBuf.Reader<? extends CustomPacketPayload> packetdataserializer_a = (FriendlyByteBuf.Reader) ServerboundCustomPayloadPacket.KNOWN_TYPES.get(id);
|
||||
-
|
||||
+ // Leaves start - protocol
|
||||
+ CustomPacketPayload leavesPayload = top.leavesmc.leaves.protocol.core.LeavesProtocolManager.getPayload(id, buf);
|
||||
+ if (leavesPayload != null) {
|
||||
+ return leavesPayload;
|
||||
+ }
|
||||
+ // Leaves end - protocol
|
||||
return (CustomPacketPayload) (packetdataserializer_a != null ? (CustomPacketPayload) packetdataserializer_a.apply(buf) : readUnknownPayload(id, buf));
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
index c68910b2a2eb703406fb406a86783cf6ab48651e..f935214ed80fe54038a96a5cd668a072cdf406ec 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
@@ -139,6 +139,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
|
||||
@Override
|
||||
public void handleCustomPayload(ServerboundCustomPayloadPacket packet) {
|
||||
+ top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePayload(player, packet.payload()); // Leaves - protocol
|
||||
// Paper start - Brand support
|
||||
if (packet.payload() instanceof net.minecraft.network.protocol.common.custom.BrandPayload brandPayload) {
|
||||
this.player.clientBrandName = brandPayload.brand();
|
||||
@@ -156,6 +157,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);
|
||||
+ top.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/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 90be312057221a5a78066d89783c5e22008d797d..0f172512085e9dfc0850451d2c6bbffb18221f8f 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -441,6 +441,8 @@ public abstract class PlayerList {
|
||||
//return; // Folia - region threading - must still allow the player to connect, as we must add to chunk map before handling disconnect
|
||||
}
|
||||
|
||||
+ top.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
|
||||
@@ -696,6 +698,7 @@ public abstract class PlayerList {
|
||||
return this.remove(entityplayer, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? entityplayer.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(entityplayer.getDisplayName())));
|
||||
}
|
||||
public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer, net.kyori.adventure.text.Component leaveMessage) {
|
||||
+ top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerLeave(entityplayer); // Leaves - protocol
|
||||
// Paper end - Fix kick event leave message not being sent
|
||||
ServerLevel worldserver = entityplayer.serverLevel();
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index c70eb23d9745bdbfcc340bb554cf0bf2db71f5de..dc223b536eadd2da6cf3c758a62d0ed81b5a7b3b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -471,6 +471,7 @@ public final class CraftServer implements Server {
|
||||
MapPalette.setMapColorCache(new CraftMapColorCache(this.logger));
|
||||
}
|
||||
datapackManager = new io.papermc.paper.datapack.PaperDatapackManager(console.getPackRepository()); // Paper
|
||||
+ top.leavesmc.leaves.protocol.core.LeavesProtocolManager.init(); // Leaves - protocol
|
||||
}
|
||||
|
||||
public boolean getCommandBlockOverride(String command) {
|
||||
@@ -1129,6 +1130,7 @@ public final class CraftServer implements Server {
|
||||
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
|
||||
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
||||
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
|
||||
+ top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleServerReload(); // Leaves - protocol
|
||||
|
||||
int pollCount = 0;
|
||||
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocol.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..64a1d25973b032e8cab64bbffa6824a131676773
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocol.java
|
||||
@@ -0,0 +1,16 @@
|
||||
+package top.leavesmc.leaves.protocol.core;
|
||||
+
|
||||
+import java.lang.annotation.ElementType;
|
||||
+import java.lang.annotation.Retention;
|
||||
+import java.lang.annotation.RetentionPolicy;
|
||||
+import java.lang.annotation.Target;
|
||||
+
|
||||
+@Target(ElementType.TYPE)
|
||||
+@Retention(RetentionPolicy.RUNTIME)
|
||||
+public @interface LeavesProtocol {
|
||||
+
|
||||
+ String namespace() default "minecraft";
|
||||
+
|
||||
+ String[] namespaces() default {};
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocolManager.java b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..8b7813c442733f5d4d3b2a072902099cbe596b37
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
|
||||
@@ -0,0 +1,344 @@
|
||||
+package top.leavesmc.leaves.protocol.core;
|
||||
+
|
||||
+import net.minecraft.network.FriendlyByteBuf;
|
||||
+import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import org.apache.commons.lang.ArrayUtils;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.io.IOException;
|
||||
+import java.lang.reflect.Constructor;
|
||||
+import java.lang.reflect.InvocationTargetException;
|
||||
+import java.lang.reflect.Method;
|
||||
+import java.lang.reflect.Modifier;
|
||||
+import java.net.JarURLConnection;
|
||||
+import java.net.URL;
|
||||
+import java.net.URLDecoder;
|
||||
+import java.nio.charset.StandardCharsets;
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.Collections;
|
||||
+import java.util.Enumeration;
|
||||
+import java.util.HashMap;
|
||||
+import java.util.HashSet;
|
||||
+import java.util.LinkedHashSet;
|
||||
+import java.util.List;
|
||||
+import java.util.Map;
|
||||
+import java.util.Set;
|
||||
+import java.util.jar.JarEntry;
|
||||
+import java.util.jar.JarFile;
|
||||
+
|
||||
+public class LeavesProtocolManager {
|
||||
+
|
||||
+ private static final Map<LeavesProtocol, Map<ProtocolHandler.PayloadReceiver, Constructor<? extends CustomPacketPayload>>> KNOWN_TYPES = new HashMap<>();
|
||||
+ private static final Map<LeavesProtocol, Map<ProtocolHandler.PayloadReceiver, Method>> KNOW_RECEIVERS = new HashMap<>();
|
||||
+
|
||||
+ private static final List<Method> TICKERS = new ArrayList<>();
|
||||
+ private static final List<Method> PLAYER_JOIN = new ArrayList<>();
|
||||
+ private static final List<Method> PLAYER_LEAVE = new ArrayList<>();
|
||||
+ private static final List<Method> RELOAD_SERVER = new ArrayList<>();
|
||||
+ private static final Map<LeavesProtocol, Map<ProtocolHandler.MinecraftRegister, Method>> MINECRAFT_REGISTER = new HashMap<>();
|
||||
+
|
||||
+ public static void init() {
|
||||
+ //Luminol start - For the protocol supports of luminol
|
||||
+ final Set<Class<?>> allClazz = getClasses("org.leavesmc.leaves.protocol");
|
||||
+ allClazz.addAll(getClasses("me.earthme.luminol.protocols"));
|
||||
+ //Luminol end
|
||||
+ for (Class<?> clazz : allClazz) {
|
||||
+ final LeavesProtocol protocol = clazz.getAnnotation(LeavesProtocol.class);
|
||||
+ if (protocol != null) {
|
||||
+ Set<Method> methods;
|
||||
+ try {
|
||||
+ Method[] publicMethods = clazz.getMethods();
|
||||
+ Method[] privateMethods = clazz.getDeclaredMethods();
|
||||
+ methods = new HashSet<>(publicMethods.length + privateMethods.length, 1.0f);
|
||||
+ Collections.addAll(methods, publicMethods);
|
||||
+ Collections.addAll(methods, privateMethods);
|
||||
+ } catch (NoClassDefFoundError e) {
|
||||
+ e.printStackTrace();
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ Map<ProtocolHandler.PayloadReceiver, Constructor<? extends CustomPacketPayload>> map = new HashMap<>();
|
||||
+ for (final Method method : methods) {
|
||||
+ if (method.isBridge() || method.isSynthetic() || !Modifier.isStatic(method.getModifiers())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ method.setAccessible(true);
|
||||
+
|
||||
+ final ProtocolHandler.Init init = method.getAnnotation(ProtocolHandler.Init.class);
|
||||
+ if (init != null) {
|
||||
+ try {
|
||||
+ method.invoke(null);
|
||||
+ } catch (InvocationTargetException | IllegalAccessException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final ProtocolHandler.PayloadReceiver receiver = method.getAnnotation(ProtocolHandler.PayloadReceiver.class);
|
||||
+ if (receiver != null) {
|
||||
+ try {
|
||||
+ map.put(receiver, receiver.payload().getConstructor(ResourceLocation.class, FriendlyByteBuf.class));
|
||||
+ } catch (NoSuchMethodException e) {
|
||||
+ e.printStackTrace();
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if (!KNOW_RECEIVERS.containsKey(protocol)) {
|
||||
+ KNOW_RECEIVERS.put(protocol, new HashMap<>());
|
||||
+ }
|
||||
+
|
||||
+ KNOW_RECEIVERS.get(protocol).put(receiver, method);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final ProtocolHandler.Ticker ticker = method.getAnnotation(ProtocolHandler.Ticker.class);
|
||||
+ if (ticker != null) {
|
||||
+ TICKERS.add(method);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final ProtocolHandler.PlayerJoin playerJoin = method.getAnnotation(ProtocolHandler.PlayerJoin.class);
|
||||
+ if (playerJoin != null) {
|
||||
+ PLAYER_JOIN.add(method);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final ProtocolHandler.PlayerLeave playerLeave = method.getAnnotation(ProtocolHandler.PlayerLeave.class);
|
||||
+ if (playerLeave != null) {
|
||||
+ PLAYER_LEAVE.add(method);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final ProtocolHandler.ReloadServer reloadServer = method.getAnnotation(ProtocolHandler.ReloadServer.class);
|
||||
+ if (reloadServer != null) {
|
||||
+ RELOAD_SERVER.add(method);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final ProtocolHandler.MinecraftRegister minecraftRegister = method.getAnnotation(ProtocolHandler.MinecraftRegister.class);
|
||||
+ if (minecraftRegister != null) {
|
||||
+ if (!MINECRAFT_REGISTER.containsKey(protocol)) {
|
||||
+ MINECRAFT_REGISTER.put(protocol, new HashMap<>());
|
||||
+ }
|
||||
+
|
||||
+ MINECRAFT_REGISTER.get(protocol).put(minecraftRegister, method);
|
||||
+ }
|
||||
+ }
|
||||
+ KNOWN_TYPES.put(protocol, map);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static CustomPacketPayload getPayload(ResourceLocation id, FriendlyByteBuf buf) {
|
||||
+ for (LeavesProtocol protocol : KNOWN_TYPES.keySet()) {
|
||||
+ if (!protocol.namespace().equals(id.getNamespace()) && !ArrayUtils.contains(protocol.namespaces(), id.getNamespace())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ Map<ProtocolHandler.PayloadReceiver, Constructor<? extends CustomPacketPayload>> map = KNOWN_TYPES.get(protocol);
|
||||
+ for (ProtocolHandler.PayloadReceiver receiver : map.keySet()) {
|
||||
+ if (receiver.ignoreId() || receiver.payloadId().equals(id.getPath()) || ArrayUtils.contains(receiver.payloadIds(), id.getPath())) {
|
||||
+ try {
|
||||
+ return map.get(receiver).newInstance(id, buf);
|
||||
+ } catch (InvocationTargetException | InstantiationException | IllegalAccessException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ public static void handlePayload(ServerPlayer player, CustomPacketPayload payload) {
|
||||
+ for (LeavesProtocol protocol : KNOW_RECEIVERS.keySet()) {
|
||||
+ if (!protocol.namespace().equals(payload.id().getNamespace()) && !ArrayUtils.contains(protocol.namespaces(), payload.id().getNamespace())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ Map<ProtocolHandler.PayloadReceiver, Method> map = KNOW_RECEIVERS.get(protocol);
|
||||
+ for (ProtocolHandler.PayloadReceiver receiver : map.keySet()) {
|
||||
+ if (payload.getClass() == receiver.payload()) {
|
||||
+ if (receiver.ignoreId() || receiver.payloadId().equals(payload.id().getPath()) ||
|
||||
+ ArrayUtils.contains(receiver.payloadIds(), payload.id().getPath())) {
|
||||
+ try {
|
||||
+ map.get(receiver).invoke(null, player, payload);
|
||||
+ } catch (InvocationTargetException | IllegalAccessException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void handleTick() {
|
||||
+ if (!TICKERS.isEmpty()) {
|
||||
+ try {
|
||||
+ for (Method method : TICKERS) {
|
||||
+ method.invoke(null);
|
||||
+ }
|
||||
+ } catch (InvocationTargetException | IllegalAccessException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void handlePlayerJoin(ServerPlayer player) {
|
||||
+ if (!PLAYER_JOIN.isEmpty()) {
|
||||
+ try {
|
||||
+ for (Method method : PLAYER_JOIN) {
|
||||
+ method.invoke(null, player);
|
||||
+ }
|
||||
+ } catch (InvocationTargetException | IllegalAccessException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void handlePlayerLeave(ServerPlayer player) {
|
||||
+ if (!PLAYER_LEAVE.isEmpty()) {
|
||||
+ try {
|
||||
+ for (Method method : PLAYER_LEAVE) {
|
||||
+ method.invoke(null, player);
|
||||
+ }
|
||||
+ } catch (InvocationTargetException | IllegalAccessException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void handleServerReload() {
|
||||
+ if (!RELOAD_SERVER.isEmpty()) {
|
||||
+ try {
|
||||
+ for (Method method : RELOAD_SERVER) {
|
||||
+ method.invoke(null);
|
||||
+ }
|
||||
+ } catch (InvocationTargetException | IllegalAccessException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void handleMinecraftRegister(String channelId, ServerPlayer player) {
|
||||
+ for (LeavesProtocol protocol : MINECRAFT_REGISTER.keySet()) {
|
||||
+ String[] channel = channelId.split(":");
|
||||
+ if (!protocol.namespace().equals(channel[0]) && !ArrayUtils.contains(protocol.namespaces(), channel[0])) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ Map<ProtocolHandler.MinecraftRegister, Method> map = MINECRAFT_REGISTER.get(protocol);
|
||||
+ for (ProtocolHandler.MinecraftRegister register : map.keySet()) {
|
||||
+ if (register.ignoreId() || register.channelId().equals(channel[1]) ||
|
||||
+ ArrayUtils.contains(register.channelIds(), channel[1])) {
|
||||
+ try {
|
||||
+ map.get(register).invoke(null, player);
|
||||
+ } catch (InvocationTargetException | IllegalAccessException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static Set<Class<?>> getClasses(String pack) {
|
||||
+ Set<Class<?>> classes = new LinkedHashSet<Class<?>>();
|
||||
+ String packageDirName = pack.replace('.', '/');
|
||||
+ Enumeration<URL> dirs;
|
||||
+ try {
|
||||
+ dirs = Thread.currentThread().getContextClassLoader().getResources(packageDirName);
|
||||
+ while (dirs.hasMoreElements()) {
|
||||
+ URL url = dirs.nextElement();
|
||||
+ String protocol = url.getProtocol();
|
||||
+ if ("file".equals(protocol)) {
|
||||
+ String filePath = URLDecoder.decode(url.getFile(), StandardCharsets.UTF_8);
|
||||
+ findClassesInPackageByFile(pack, filePath, classes);
|
||||
+ } else if ("jar".equals(protocol)) {
|
||||
+ JarFile jar;
|
||||
+ try {
|
||||
+ jar = ((JarURLConnection) url.openConnection()).getJarFile();
|
||||
+ Enumeration<JarEntry> entries = jar.entries();
|
||||
+ findClassesInPackageByJar(pack, entries, packageDirName, classes);
|
||||
+ } catch (IOException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ } catch (IOException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ return classes;
|
||||
+ }
|
||||
+
|
||||
+ private static void findClassesInPackageByFile(String packageName, String packagePath, Set<Class<?>> classes) {
|
||||
+ File dir = new File(packagePath);
|
||||
+ if (!dir.exists() || !dir.isDirectory()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ File[] dirfiles = dir.listFiles((file) -> file.isDirectory() || file.getName().endsWith(".class"));
|
||||
+ if (dirfiles != null) {
|
||||
+ for (File file : dirfiles) {
|
||||
+ if (file.isDirectory()) {
|
||||
+ findClassesInPackageByFile(packageName + "." + file.getName(), file.getAbsolutePath(), classes);
|
||||
+ } else {
|
||||
+ String className = file.getName().substring(0, file.getName().length() - 6);
|
||||
+ try {
|
||||
+ classes.add(Class.forName(packageName + '.' + className));
|
||||
+ } catch (ClassNotFoundException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static void findClassesInPackageByJar(String packageName, Enumeration<JarEntry> entries, String packageDirName, Set<Class<?>> classes) {
|
||||
+ while (entries.hasMoreElements()) {
|
||||
+ JarEntry entry = entries.nextElement();
|
||||
+ String name = entry.getName();
|
||||
+ if (name.charAt(0) == '/') {
|
||||
+ name = name.substring(1);
|
||||
+ }
|
||||
+ if (name.startsWith(packageDirName)) {
|
||||
+ int idx = name.lastIndexOf('/');
|
||||
+ if (idx != -1) {
|
||||
+ packageName = name.substring(0, idx).replace('/', '.');
|
||||
+ }
|
||||
+ if (name.endsWith(".class") && !entry.isDirectory()) {
|
||||
+ String className = name.substring(packageName.length() + 1, name.length() - 6);
|
||||
+ try {
|
||||
+ classes.add(Class.forName(packageName + '.' + className));
|
||||
+ } catch (ClassNotFoundException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public record EmptyPayload(ResourceLocation id) implements CustomPacketPayload {
|
||||
+
|
||||
+ public EmptyPayload(ResourceLocation location, FriendlyByteBuf buf) {
|
||||
+ this(location);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void write(@NotNull FriendlyByteBuf buf) {
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public record LeavesPayload(FriendlyByteBuf data, ResourceLocation id) implements CustomPacketPayload {
|
||||
+
|
||||
+ public LeavesPayload(ResourceLocation location, FriendlyByteBuf buf) {
|
||||
+ this(new FriendlyByteBuf(buf.readBytes(buf.readableBytes())), location);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void write(FriendlyByteBuf buf) {
|
||||
+ buf.writeBytes(data);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolHandler.java b/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolHandler.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..d696f001d2576d1b61cc732c81f22eb52205072b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolHandler.java
|
||||
@@ -0,0 +1,65 @@
|
||||
+package top.leavesmc.leaves.protocol.core;
|
||||
+
|
||||
+import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
+
|
||||
+import java.lang.annotation.ElementType;
|
||||
+import java.lang.annotation.Retention;
|
||||
+import java.lang.annotation.RetentionPolicy;
|
||||
+import java.lang.annotation.Target;
|
||||
+
|
||||
+public class ProtocolHandler {
|
||||
+
|
||||
+ @Target(ElementType.METHOD)
|
||||
+ @Retention(RetentionPolicy.RUNTIME)
|
||||
+ public @interface Init {
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ @Target(ElementType.METHOD)
|
||||
+ @Retention(RetentionPolicy.RUNTIME)
|
||||
+ public @interface PayloadReceiver {
|
||||
+
|
||||
+ Class<? extends CustomPacketPayload> payload();
|
||||
+
|
||||
+ String[] payloadIds() default {};
|
||||
+
|
||||
+ String payloadId() default "";
|
||||
+
|
||||
+ boolean ignoreId() default false;
|
||||
+ }
|
||||
+
|
||||
+ @Target(ElementType.METHOD)
|
||||
+ @Retention(RetentionPolicy.RUNTIME)
|
||||
+ public @interface Ticker {
|
||||
+ int delay() default 0;
|
||||
+ }
|
||||
+
|
||||
+ @Target(ElementType.METHOD)
|
||||
+ @Retention(RetentionPolicy.RUNTIME)
|
||||
+ public @interface PlayerJoin {
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ @Target(ElementType.METHOD)
|
||||
+ @Retention(RetentionPolicy.RUNTIME)
|
||||
+ public @interface PlayerLeave {
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ @Target(ElementType.METHOD)
|
||||
+ @Retention(RetentionPolicy.RUNTIME)
|
||||
+ public @interface ReloadServer {
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ @Target(ElementType.METHOD)
|
||||
+ @Retention(RetentionPolicy.RUNTIME)
|
||||
+ public @interface MinecraftRegister {
|
||||
+
|
||||
+ String channelId() default "";
|
||||
+
|
||||
+ String[] channelIds() default {};
|
||||
+
|
||||
+ boolean ignoreId() default false;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolUtils.java b/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolUtils.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..5282c5ad3d26d06ab685ddaaf6fd9a4d49559717
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolUtils.java
|
||||
@@ -0,0 +1,36 @@
|
||||
+package top.leavesmc.leaves.protocol.core;
|
||||
+
|
||||
+import net.minecraft.network.FriendlyByteBuf;
|
||||
+import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
|
||||
+import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.util.function.Consumer;
|
||||
+
|
||||
+public class ProtocolUtils {
|
||||
+
|
||||
+ public static void sendEmptyPayloadPacket(ServerPlayer player, ResourceLocation id) {
|
||||
+ player.connection.send(new ClientboundCustomPayloadPacket(new LeavesProtocolManager.EmptyPayload(id)));
|
||||
+ }
|
||||
+
|
||||
+ public static void sendPayloadPacket(ServerPlayer player, ResourceLocation id, Consumer<FriendlyByteBuf> consumer) {
|
||||
+ player.connection.send(new ClientboundCustomPayloadPacket(new CustomPacketPayload() {
|
||||
+ @Override
|
||||
+ public void write(@NotNull FriendlyByteBuf buf) {
|
||||
+ consumer.accept(buf);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull
|
||||
+ public ResourceLocation id() {
|
||||
+ return id;
|
||||
+ }
|
||||
+ }));
|
||||
+ }
|
||||
+
|
||||
+ public static void sendPayloadPacket(ServerPlayer player, CustomPacketPayload payload) {
|
||||
+ player.connection.send(new ClientboundCustomPayloadPacket(payload));
|
||||
+ }
|
||||
+}
|
||||
@@ -1,6 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 08:35:11 +0000
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 14:30:23 +0800
|
||||
Subject: [PATCH] Purpur use alternative keep alive
|
||||
|
||||
|
||||
@@ -31,27 +31,27 @@ index 0000000000000000000000000000000000000000..43bbc2c30bdd3872a0179e0070403c3e
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
index 22f0d91df0a81040d72c499fbff32b3a9d41598f..c68910b2a2eb703406fb406a86783cf6ab48651e 100644
|
||||
index ea99a4e39cdfb4eeebc299030f7768b9c684df4e..c9a298808d287a2f82e075536d8a79d2281f1ce2 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
@@ -51,6 +51,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
private long keepAliveTime = Util.getMillis(); // Paper
|
||||
private boolean keepAlivePending;
|
||||
@@ -79,6 +79,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
private long keepAliveChallenge;
|
||||
private long closedListenerTime;
|
||||
private boolean closed = false;
|
||||
+ private it.unimi.dsi.fastutil.longs.LongList keepAlives = new it.unimi.dsi.fastutil.longs.LongArrayList(); // Purpur
|
||||
private int latency;
|
||||
private volatile boolean suspendFlushingOnServerThread = false;
|
||||
public final java.util.Map<java.util.UUID, net.kyori.adventure.resource.ResourcePackCallback> packCallbacks = new java.util.concurrent.ConcurrentHashMap<>(); // Paper - adventure resource pack callbacks
|
||||
@@ -103,6 +104,16 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
@@ -141,6 +142,16 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
|
||||
@Override
|
||||
public void handleKeepAlive(ServerboundKeepAlivePacket packet) {
|
||||
+ // Purpur start
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.PurpurAlternativeKeepaliveConfig.useAlternateKeepAlive) {
|
||||
+ long id = packet.getId();
|
||||
+ if (keepAlives.size() > 0 && keepAlives.contains(id)) {
|
||||
+ int ping = (int) (Util.getMillis() - id);
|
||||
+ if (this.keepAlivePending && !keepAlives.isEmpty() && keepAlives.contains(packet.getId())) {
|
||||
+ int ping = (int) (Util.getMillis() - packet.getId());
|
||||
+ this.latency = (this.latency * 3 + ping) / 4;
|
||||
+ this.keepAlivePending = false;
|
||||
+ keepAlives.clear(); // we got a valid response, lets roll with it and forget the rest
|
||||
+ }
|
||||
+ } else
|
||||
@@ -59,25 +59,33 @@ index 22f0d91df0a81040d72c499fbff32b3a9d41598f..c68910b2a2eb703406fb406a86783cf6
|
||||
//PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); // CraftBukkit // Paper - handle ServerboundKeepAlivePacket async
|
||||
if (this.keepAlivePending && packet.getId() == this.keepAliveChallenge) {
|
||||
int i = (int) (Util.getMillis() - this.keepAliveTime);
|
||||
@@ -221,6 +232,21 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
@@ -266,6 +277,21 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
long currentTime = Util.getMillis();
|
||||
long elapsedTime = currentTime - this.keepAliveTime;
|
||||
|
||||
+ // Purpur start
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.PurpurAlternativeKeepaliveConfig.useAlternateKeepAlive) {
|
||||
+ if (elapsedTime >= 1000L) { // 1 second
|
||||
+ if (!processedDisconnect && keepAlives.size() * 1000L >= KEEPALIVE_LIMIT) {
|
||||
+ if (this.keepAlivePending && !this.processedDisconnect && keepAlives.size() * 1000L >= KEEPALIVE_LIMIT) {
|
||||
+ LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName());
|
||||
+ disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE, org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT);
|
||||
+ } else {
|
||||
+ keepAliveTime = currentTime; // hijack this field for 1 second intervals
|
||||
+ keepAlives.add(currentTime); // currentTime is ID
|
||||
+ send(new ClientboundKeepAlivePacket(currentTime));
|
||||
+ this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE, org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT);
|
||||
+ } else if (this.checkIfClosed(currentTime)) {
|
||||
+ this.keepAlivePending = true;
|
||||
+ this.keepAliveTime = currentTime; // hijack this field for 1 second intervals
|
||||
+ this.keepAlives.add(currentTime); // currentTime is ID
|
||||
+ this.send(new ClientboundKeepAlivePacket(currentTime));
|
||||
+ }
|
||||
+ }
|
||||
+ } else
|
||||
+ // Purpur end
|
||||
+ } else {
|
||||
+
|
||||
if (this.keepAlivePending) {
|
||||
if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); // more info
|
||||
if (!this.isSingleplayerOwner() && elapsedTime >= 15000L) { // Paper - use vanilla's 15000L between keep alive packets
|
||||
if (this.keepAlivePending && !this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // Paper - check keepalive limit, don't fire if already disconnected
|
||||
this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE, PlayerKickEvent.Cause.TIMEOUT); // Paper - kick event cause
|
||||
@@ -277,6 +303,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
}
|
||||
}
|
||||
// Paper end - give clients a longer time to respond to pings as per pre 1.12.2 timings
|
||||
+ } // Purpur end
|
||||
|
||||
this.server.getProfiler().pop();
|
||||
}
|
||||
31
patches/server/0057-Leaf-Skip-event-if-no-listeners.patch
Normal file
31
patches/server/0057-Leaf-Skip-event-if-no-listeners.patch
Normal file
@@ -0,0 +1,31 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 14:48:44 +0800
|
||||
Subject: [PATCH] Leaf Skip event if no listeners
|
||||
|
||||
|
||||
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..9180f23529a31b6b0a5b38bb7cda3e32d487f691 100644
|
||||
--- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
@@ -36,15 +36,17 @@ class PaperEventManager {
|
||||
|
||||
// SimplePluginManager
|
||||
public void callEvent(@NotNull Event event) {
|
||||
+ // Leaf start - Skip event if no listeners
|
||||
+ RegisteredListener[] listeners = event.getHandlers().getRegisteredListeners();
|
||||
+ if (listeners.length == 0) return;
|
||||
+ // Leaf end - Skip event if no listeners
|
||||
+
|
||||
if (event.isAsynchronous() && this.server.isPrimaryThread()) {
|
||||
throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously.");
|
||||
} else if (!event.isAsynchronous() && !this.server.isPrimaryThread() && !this.server.isStopping()) {
|
||||
throw new IllegalStateException(event.getEventName() + " may only be triggered synchronously.");
|
||||
}
|
||||
|
||||
- HandlerList handlers = event.getHandlers();
|
||||
- RegisteredListener[] listeners = handlers.getRegisteredListeners();
|
||||
-
|
||||
for (RegisteredListener registration : listeners) {
|
||||
if (!registration.getPlugin().isEnabled()) {
|
||||
continue;
|
||||
@@ -1,292 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 08:59:41 +0000
|
||||
Subject: [PATCH] Leaves Bladeren Protocol
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/gameplay/LeavesBladerenProtocolConfig.java b/src/main/java/me/earthme/luminol/config/modules/gameplay/LeavesBladerenProtocolConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..4950d33288d6bc3c4ce90ae12bbf4797e3989500
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/gameplay/LeavesBladerenProtocolConfig.java
|
||||
@@ -0,0 +1,28 @@
|
||||
+package me.earthme.luminol.config.modules.gameplay;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.HotReloadUnsupported;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class LeavesBladerenProtocolConfig implements IConfigModule {
|
||||
+ @HotReloadUnsupported
|
||||
+ @ConfigInfo(baseName = "enable_base_protocol")
|
||||
+ public static boolean enableBaseProtocol = false;
|
||||
+ @HotReloadUnsupported
|
||||
+ @ConfigInfo(baseName = "enable_mspt_sync_protocol")
|
||||
+ public static boolean msptSyncProtocol = false;
|
||||
+ @HotReloadUnsupported
|
||||
+ @ConfigInfo(baseName = "mspt_sync_interval")
|
||||
+ public static int msptSyncTickInterval = 20;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.GAMEPLAY;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "leaves_bladeren_protocol";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/bladeren/BladerenProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/bladeren/BladerenProtocol.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..6415f17fa6c06199e59705a29605d2aef834fc17
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/bladeren/BladerenProtocol.java
|
||||
@@ -0,0 +1,150 @@
|
||||
+package top.leavesmc.leaves.protocol.bladeren;
|
||||
+
|
||||
+import com.google.common.collect.Maps;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+import net.minecraft.network.FriendlyByteBuf;
|
||||
+import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import org.jetbrains.annotations.Contract;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import top.leavesmc.leaves.protocol.core.LeavesProtocol;
|
||||
+import top.leavesmc.leaves.protocol.core.ProtocolHandler;
|
||||
+import top.leavesmc.leaves.protocol.core.ProtocolUtils;
|
||||
+
|
||||
+import java.util.HashMap;
|
||||
+import java.util.Map;
|
||||
+import java.util.function.BiConsumer;
|
||||
+
|
||||
+@LeavesProtocol(namespace = "bladeren")
|
||||
+public class BladerenProtocol {
|
||||
+
|
||||
+ public static final String PROTOCOL_ID = "bladeren";
|
||||
+ public static final String PROTOCOL_VERSION = "1.0.0";
|
||||
+
|
||||
+ private static final ResourceLocation HELLO_ID = id("hello");
|
||||
+ private static final ResourceLocation FEATURE_MODIFY_ID = id("feature_modify");
|
||||
+
|
||||
+ private static final Map<String, BiConsumer<ServerPlayer, CompoundTag>> registeredFeatures = Maps.newConcurrentMap();
|
||||
+
|
||||
+ @Contract("_ -> new")
|
||||
+ public static @NotNull ResourceLocation id(String path) {
|
||||
+ return new ResourceLocation(PROTOCOL_ID, path);
|
||||
+ }
|
||||
+
|
||||
+ @ProtocolHandler.PayloadReceiver(payload = BladerenHelloPayload.class, payloadId = "hello")
|
||||
+ private static void handleHello(@NotNull ServerPlayer player, @NotNull BladerenHelloPayload payload) {
|
||||
+ if (me.earthme.luminol.config.modules.gameplay.LeavesBladerenProtocolConfig.enableBaseProtocol) {
|
||||
+ String clientVersion = payload.version;
|
||||
+ CompoundTag tag = payload.nbt;
|
||||
+
|
||||
+ if (tag != null) {
|
||||
+ CompoundTag featureNbt = tag.getCompound("Features");
|
||||
+ for (String name : featureNbt.getAllKeys()) {
|
||||
+
|
||||
+ final BiConsumer<ServerPlayer,CompoundTag> target = registeredFeatures.get(name);
|
||||
+
|
||||
+ if (target != null){
|
||||
+ target.accept(player, featureNbt.getCompound(name));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @ProtocolHandler.PayloadReceiver(payload = BladerenFeatureModifyPayload.class, payloadId = "feature_modify")
|
||||
+ private static void handleModify(@NotNull ServerPlayer player, @NotNull BladerenFeatureModifyPayload payload) {
|
||||
+ if (me.earthme.luminol.config.modules.gameplay.LeavesBladerenProtocolConfig.enableBaseProtocol) {
|
||||
+ String name = payload.name;
|
||||
+ CompoundTag tag = payload.nbt;
|
||||
+
|
||||
+ final BiConsumer<ServerPlayer,CompoundTag> target = registeredFeatures.get(name);
|
||||
+
|
||||
+ if (target != null){
|
||||
+ target.accept(player, tag);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @ProtocolHandler.PlayerJoin
|
||||
+ public static void onPlayerJoin(@NotNull ServerPlayer player) {
|
||||
+ if (me.earthme.luminol.config.modules.gameplay.LeavesBladerenProtocolConfig.enableBaseProtocol) {
|
||||
+ CompoundTag tag = new CompoundTag();
|
||||
+ LeavesFeatureSet.writeNBT(tag);
|
||||
+ ProtocolUtils.sendPayloadPacket(player, new BladerenHelloPayload(PROTOCOL_VERSION, tag));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void registerFeature(String name, BiConsumer<ServerPlayer, CompoundTag> consumer) {
|
||||
+ registeredFeatures.put(name, consumer);
|
||||
+ }
|
||||
+
|
||||
+ public static class LeavesFeatureSet {
|
||||
+
|
||||
+ private static final Map<String, LeavesFeature> features = new HashMap<>();
|
||||
+
|
||||
+ public static void writeNBT(@NotNull CompoundTag tag) {
|
||||
+ CompoundTag featureNbt = new CompoundTag();
|
||||
+ features.values().forEach(feature -> feature.writeNBT(featureNbt));
|
||||
+ tag.put("Features", featureNbt);
|
||||
+ }
|
||||
+
|
||||
+ public static void register(LeavesFeature feature) {
|
||||
+ features.put(feature.name, feature);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public record LeavesFeature(String name, String value) {
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Contract("_, _ -> new")
|
||||
+ public static LeavesFeature of(String name, boolean value) {
|
||||
+ return new LeavesFeature(name, Boolean.toString(value));
|
||||
+ }
|
||||
+
|
||||
+ public void writeNBT(@NotNull CompoundTag rules) {
|
||||
+ CompoundTag rule = new CompoundTag();
|
||||
+ rule.putString("Feature", name);
|
||||
+ rule.putString("Value", value);
|
||||
+ rules.put(name, rule);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public record BladerenFeatureModifyPayload(String name, CompoundTag nbt) implements CustomPacketPayload {
|
||||
+
|
||||
+ public BladerenFeatureModifyPayload(ResourceLocation location, FriendlyByteBuf buf) {
|
||||
+ this(buf.readUtf(), buf.readNbt());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void write(@NotNull FriendlyByteBuf buf) {
|
||||
+ buf.writeUtf(name);
|
||||
+ buf.writeNbt(nbt);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull
|
||||
+ public ResourceLocation id() {
|
||||
+ return FEATURE_MODIFY_ID;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public record BladerenHelloPayload(String version, CompoundTag nbt) implements CustomPacketPayload {
|
||||
+
|
||||
+ public BladerenHelloPayload(ResourceLocation location, @NotNull FriendlyByteBuf buf) {
|
||||
+ this(buf.readUtf(64), buf.readNbt());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void write(@NotNull FriendlyByteBuf buf) {
|
||||
+ buf.writeUtf(version);
|
||||
+ buf.writeNbt(nbt);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull
|
||||
+ public ResourceLocation id() {
|
||||
+ return HELLO_ID;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..db63ea1cf65e6ca06bd1c6ce978193e068a9a951
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java
|
||||
@@ -0,0 +1,90 @@
|
||||
+package top.leavesmc.leaves.protocol.bladeren;
|
||||
+
|
||||
+import io.papermc.paper.threadedregions.ThreadedRegionizer;
|
||||
+import io.papermc.paper.threadedregions.TickData;
|
||||
+import io.papermc.paper.threadedregions.TickRegions;
|
||||
+import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
+import it.unimi.dsi.fastutil.objects.ObjectLists;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.level.ServerLevel;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import org.jetbrains.annotations.Contract;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import top.leavesmc.leaves.protocol.core.LeavesProtocol;
|
||||
+import top.leavesmc.leaves.protocol.core.ProtocolHandler;
|
||||
+import top.leavesmc.leaves.protocol.core.ProtocolUtils;
|
||||
+
|
||||
+import java.util.List;
|
||||
+
|
||||
+@LeavesProtocol(namespace = "bladeren")
|
||||
+public class MsptSyncProtocol {
|
||||
+
|
||||
+ public static final String PROTOCOL_ID = "bladeren";
|
||||
+
|
||||
+ private static final ResourceLocation MSPT_SYNC = id("mspt_sync");
|
||||
+
|
||||
+ private static final List<ServerPlayer> players = ObjectLists.synchronize(new ObjectArrayList<>());
|
||||
+
|
||||
+ private static int tickCounter = 0;
|
||||
+
|
||||
+ @Contract("_ -> new")
|
||||
+ public static @NotNull ResourceLocation id(String path) {
|
||||
+ return new ResourceLocation(PROTOCOL_ID, path);
|
||||
+ }
|
||||
+
|
||||
+ @ProtocolHandler.Init
|
||||
+ public static void init() {
|
||||
+ BladerenProtocol.registerFeature("mspt_sync", (player, compoundTag) -> {
|
||||
+ if (compoundTag.getString("Value").equals("true")) {
|
||||
+ onPlayerSubmit(player);
|
||||
+ } else {
|
||||
+ onPlayerLoggedOut(player);
|
||||
+ }
|
||||
+ });
|
||||
+ }
|
||||
+
|
||||
+ @ProtocolHandler.PlayerLeave
|
||||
+ public static void onPlayerLoggedOut(@NotNull ServerPlayer player) {
|
||||
+ if (me.earthme.luminol.config.modules.gameplay.LeavesBladerenProtocolConfig.msptSyncProtocol) {
|
||||
+ players.remove(player);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @ProtocolHandler.Ticker
|
||||
+ public static void tick() {
|
||||
+ if (me.earthme.luminol.config.modules.gameplay.LeavesBladerenProtocolConfig.msptSyncProtocol) {
|
||||
+ if (players.isEmpty()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (tickCounter++ % me.earthme.luminol.config.modules.gameplay.LeavesBladerenProtocolConfig.msptSyncTickInterval == 0) {
|
||||
+ for (ServerPlayer player : players){
|
||||
+ final ThreadedRegionizer.ThreadedRegion<TickRegions.TickRegionData, TickRegions.TickRegionSectionData> region = ((ServerLevel) player.level()).regioniser.getRegionAtUnsynchronised(player.sectionX,player.sectionZ);
|
||||
+
|
||||
+ if (region == null){
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final TickData.TickReportData reportData = region.getData().getRegionSchedulingHandle().getTickReport5s(System.nanoTime());
|
||||
+
|
||||
+ if (reportData != null){
|
||||
+ final TickData.SegmentData tpsData = reportData.tpsData().segmentAll();
|
||||
+ final double mspt = reportData.timePerTickData().segmentAll().average() / 1.0E6;
|
||||
+ final double tps = tpsData.average();
|
||||
+
|
||||
+ ProtocolUtils.sendPayloadPacket(player, MSPT_SYNC, buf -> {
|
||||
+ buf.writeDouble(mspt);
|
||||
+ buf.writeDouble(tps);
|
||||
+ });
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void onPlayerSubmit(@NotNull ServerPlayer player) {
|
||||
+ if (me.earthme.luminol.config.modules.gameplay.LeavesBladerenProtocolConfig.msptSyncProtocol) {
|
||||
+ players.add(player);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
@@ -1,93 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 09:00:10 +0000
|
||||
Subject: [PATCH] Leaves Fix Bladeren Protocol
|
||||
|
||||
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocol.java
|
||||
index 64a1d25973b032e8cab64bbffa6824a131676773..57a563b3f2d01719d490578907411d25ea07a658 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocol.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocol.java
|
||||
@@ -8,9 +8,7 @@ import java.lang.annotation.Target;
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface LeavesProtocol {
|
||||
-
|
||||
- String namespace() default "minecraft";
|
||||
-
|
||||
- String[] namespaces() default {};
|
||||
+
|
||||
+ String[] namespace();
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocolManager.java b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
|
||||
index 8b7813c442733f5d4d3b2a072902099cbe596b37..1f5b37daa5cbb709eeacf3dc7a4f9b4a0dc05274 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
|
||||
@@ -60,7 +60,7 @@ public class LeavesProtocolManager {
|
||||
return;
|
||||
}
|
||||
|
||||
- Map<ProtocolHandler.PayloadReceiver, Constructor<? extends CustomPacketPayload>> map = new HashMap<>();
|
||||
+ Map<ProtocolHandler.PayloadReceiver, Constructor<? extends CustomPacketPayload>> map = KNOWN_TYPES.getOrDefault(protocol, new HashMap<>());
|
||||
for (final Method method : methods) {
|
||||
if (method.isBridge() || method.isSynthetic() || !Modifier.isStatic(method.getModifiers())) {
|
||||
continue;
|
||||
@@ -135,13 +135,13 @@ public class LeavesProtocolManager {
|
||||
|
||||
public static CustomPacketPayload getPayload(ResourceLocation id, FriendlyByteBuf buf) {
|
||||
for (LeavesProtocol protocol : KNOWN_TYPES.keySet()) {
|
||||
- if (!protocol.namespace().equals(id.getNamespace()) && !ArrayUtils.contains(protocol.namespaces(), id.getNamespace())) {
|
||||
+ if (!ArrayUtils.contains(protocol.namespace(), id.getNamespace())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Map<ProtocolHandler.PayloadReceiver, Constructor<? extends CustomPacketPayload>> map = KNOWN_TYPES.get(protocol);
|
||||
for (ProtocolHandler.PayloadReceiver receiver : map.keySet()) {
|
||||
- if (receiver.ignoreId() || receiver.payloadId().equals(id.getPath()) || ArrayUtils.contains(receiver.payloadIds(), id.getPath())) {
|
||||
+ if (receiver.ignoreId() || ArrayUtils.contains(receiver.payloadId(), id.getPath())) {
|
||||
try {
|
||||
return map.get(receiver).newInstance(id, buf);
|
||||
} catch (InvocationTargetException | InstantiationException | IllegalAccessException e) {
|
||||
@@ -155,15 +155,14 @@ public class LeavesProtocolManager {
|
||||
|
||||
public static void handlePayload(ServerPlayer player, CustomPacketPayload payload) {
|
||||
for (LeavesProtocol protocol : KNOW_RECEIVERS.keySet()) {
|
||||
- if (!protocol.namespace().equals(payload.id().getNamespace()) && !ArrayUtils.contains(protocol.namespaces(), payload.id().getNamespace())) {
|
||||
+ if (!ArrayUtils.contains(protocol.namespace(), payload.id().getNamespace())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Map<ProtocolHandler.PayloadReceiver, Method> map = KNOW_RECEIVERS.get(protocol);
|
||||
for (ProtocolHandler.PayloadReceiver receiver : map.keySet()) {
|
||||
if (payload.getClass() == receiver.payload()) {
|
||||
- if (receiver.ignoreId() || receiver.payloadId().equals(payload.id().getPath()) ||
|
||||
- ArrayUtils.contains(receiver.payloadIds(), payload.id().getPath())) {
|
||||
+ if (receiver.ignoreId() || ArrayUtils.contains(receiver.payloadId(), payload.id().getPath())) {
|
||||
try {
|
||||
map.get(receiver).invoke(null, player, payload);
|
||||
} catch (InvocationTargetException | IllegalAccessException e) {
|
||||
@@ -226,7 +225,7 @@ public class LeavesProtocolManager {
|
||||
public static void handleMinecraftRegister(String channelId, ServerPlayer player) {
|
||||
for (LeavesProtocol protocol : MINECRAFT_REGISTER.keySet()) {
|
||||
String[] channel = channelId.split(":");
|
||||
- if (!protocol.namespace().equals(channel[0]) && !ArrayUtils.contains(protocol.namespaces(), channel[0])) {
|
||||
+ if (!ArrayUtils.contains(protocol.namespace(), channel[0])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolHandler.java b/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolHandler.java
|
||||
index d696f001d2576d1b61cc732c81f22eb52205072b..92ad6e9b1c0d9640b80c1ebe739c613d989eec21 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolHandler.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolHandler.java
|
||||
@@ -21,9 +21,7 @@ public class ProtocolHandler {
|
||||
|
||||
Class<? extends CustomPacketPayload> payload();
|
||||
|
||||
- String[] payloadIds() default {};
|
||||
-
|
||||
- String payloadId() default "";
|
||||
+ String[] payloadId();
|
||||
|
||||
boolean ignoreId() default false;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sat, 2 Nov 2024 21:48:13 +0800
|
||||
Subject: [PATCH] Leaves Fix Incorrect Collision Behavior for Block Shape
|
||||
|
||||
|
||||
diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
|
||||
index 8e2a3d85b7fb78d4e7198c09f356acb51f5be1e0..7ce7da8f6a4e4ffd6e319fc340289ae6bcc0d5fe 100644
|
||||
--- a/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
|
||||
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
|
||||
@@ -56,6 +56,14 @@ public final class CollisionUtil {
|
||||
(box1.minZ - box2.maxZ) < -COLLISION_EPSILON && (box1.maxZ - box2.minZ) > COLLISION_EPSILON;
|
||||
}
|
||||
|
||||
+ // Leaves start
|
||||
+ public static boolean voxelShapeIntersectVanilla(final net.minecraft.world.phys.AABB box1, final net.minecraft.world.phys.AABB box2) {
|
||||
+ return box1.minX < box2.maxX && box1.maxX > box2.minX &&
|
||||
+ box1.minY < box2.maxY && box1.maxY > box2.minY &&
|
||||
+ box1.minZ < box2.maxZ && box1.maxZ > box2.minZ;
|
||||
+ }
|
||||
+ // Leaves end
|
||||
+
|
||||
// assume !isEmpty(target) && abs(source_move) >= COLLISION_EPSILON
|
||||
public static double collideX(final net.minecraft.world.phys.AABB target, final net.minecraft.world.phys.AABB source, final double source_move) {
|
||||
if ((source.minY - target.maxY) < -COLLISION_EPSILON && (source.maxY - target.minY) > COLLISION_EPSILON &&
|
||||
@@ -1700,7 +1708,10 @@ public final class CollisionUtil {
|
||||
net.minecraft.world.phys.AABB singleAABB = ((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)blockCollision).moonrise$getSingleAABBRepresentation();
|
||||
if (singleAABB != null) {
|
||||
singleAABB = singleAABB.move((double)blockX, (double)blockY, (double)blockZ);
|
||||
- if (!voxelShapeIntersect(aabb, singleAABB)) {
|
||||
+ // Leaves start - Fix incorrect collision behavior for block shape
|
||||
+ boolean isBlockShape = blockCollision == net.minecraft.world.phys.shapes.Shapes.block();
|
||||
+ if (isBlockShape && !voxelShapeIntersectVanilla(aabb, singleAABB) || !isBlockShape && !voxelShapeIntersect(aabb, singleAABB)) {
|
||||
+ // Leaves end - Fix incorrect collision behavior for block shape
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1,153 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Thu, 8 Feb 2024 11:57:18 +0000
|
||||
Subject: [PATCH] Leaves carpet protocol support
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/gameplay/LeavesCarpetProtocolSupportConfig.java b/src/main/java/me/earthme/luminol/config/modules/gameplay/LeavesCarpetProtocolSupportConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0ef77515b213b74bdcf7dac70a02bfaa1c8804f5
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/gameplay/LeavesCarpetProtocolSupportConfig.java
|
||||
@@ -0,0 +1,22 @@
|
||||
+package me.earthme.luminol.config.modules.gameplay;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.HotReloadUnsupported;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class LeavesCarpetProtocolSupportConfig implements IConfigModule {
|
||||
+ @HotReloadUnsupported
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.GAMEPLAY;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "leaves_carpet_protocol";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/CarpetServerProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/CarpetServerProtocol.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0542d66a3dfae2aa3ccb6ca3dced6b34024017ad
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/CarpetServerProtocol.java
|
||||
@@ -0,0 +1,113 @@
|
||||
+package top.leavesmc.leaves.protocol;
|
||||
+
|
||||
+import me.earthme.luminol.config.modules.gameplay.LeavesCarpetProtocolSupportConfig;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+import net.minecraft.network.FriendlyByteBuf;
|
||||
+import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import org.jetbrains.annotations.Contract;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import top.leavesmc.leaves.protocol.core.LeavesProtocol;
|
||||
+import top.leavesmc.leaves.protocol.core.ProtocolHandler;
|
||||
+import top.leavesmc.leaves.protocol.core.ProtocolUtils;
|
||||
+
|
||||
+import java.util.HashMap;
|
||||
+import java.util.Locale;
|
||||
+import java.util.Map;
|
||||
+
|
||||
+@LeavesProtocol(namespace = "carpet")
|
||||
+public class CarpetServerProtocol {
|
||||
+
|
||||
+ public static final String PROTOCOL_ID = "carpet";
|
||||
+ public static final String VERSION = "leaves-carpet-1.0.0";
|
||||
+
|
||||
+ private static final ResourceLocation HELLO_ID = CarpetServerProtocol.id("hello");
|
||||
+
|
||||
+ private static final String HI = "69";
|
||||
+ private static final String HELLO = "420";
|
||||
+
|
||||
+ @Contract("_ -> new")
|
||||
+ public static @NotNull ResourceLocation id(String path) {
|
||||
+ return new ResourceLocation(PROTOCOL_ID, path);
|
||||
+ }
|
||||
+
|
||||
+ @ProtocolHandler.PlayerJoin
|
||||
+ public static void onPlayerJoin(ServerPlayer player) {
|
||||
+ if (LeavesCarpetProtocolSupportConfig.enabled) {
|
||||
+ CompoundTag data = new CompoundTag();
|
||||
+ data.putString(HI, VERSION);
|
||||
+ ProtocolUtils.sendPayloadPacket(player, new CarpetPayload(data));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @ProtocolHandler.PayloadReceiver(payload = CarpetPayload.class, payloadId = "hello")
|
||||
+ private static void handleHello(@NotNull ServerPlayer player, @NotNull CarpetServerProtocol.CarpetPayload payload) {
|
||||
+ if (LeavesCarpetProtocolSupportConfig.enabled) {
|
||||
+ if (payload.nbt.contains(HELLO)) {
|
||||
+ MinecraftServer.LOGGER.info("Player " + player.getScoreboardName() + " joined with carpet " + payload.nbt.getString(HELLO));
|
||||
+ CompoundTag data = new CompoundTag();
|
||||
+ CarpetRules.write(data);
|
||||
+ ProtocolUtils.sendPayloadPacket(player, new CarpetPayload(data));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static class CarpetRules {
|
||||
+
|
||||
+ private static final Map<String, CarpetRule> rules = new HashMap<>();
|
||||
+
|
||||
+ public static void write(@NotNull CompoundTag tag) {
|
||||
+ CompoundTag rulesNbt = new CompoundTag();
|
||||
+ rules.values().forEach(rule -> rule.writeNBT(rulesNbt));
|
||||
+
|
||||
+ tag.put("Rules", rulesNbt);
|
||||
+ }
|
||||
+
|
||||
+ public static void register(CarpetRule rule) {
|
||||
+ rules.put(rule.name, rule);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public record CarpetRule(String identifier, String name, String value) {
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Contract("_, _, _ -> new")
|
||||
+ public static CarpetRule of(String identifier, String name, Enum<?> value) {
|
||||
+ return new CarpetRule(identifier, name, value.name().toLowerCase(Locale.ROOT));
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Contract("_, _, _ -> new")
|
||||
+ public static CarpetRule of(String identifier, String name, boolean value) {
|
||||
+ return new CarpetRule(identifier, name, Boolean.toString(value));
|
||||
+ }
|
||||
+
|
||||
+ public void writeNBT(@NotNull CompoundTag rules) {
|
||||
+ CompoundTag rule = new CompoundTag();
|
||||
+ rule.putString("Value", value);
|
||||
+ rule.putString("Manager", identifier);
|
||||
+ rule.putString("Rule", name);
|
||||
+ rules.put(name, rule);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public record CarpetPayload(CompoundTag nbt) implements CustomPacketPayload {
|
||||
+
|
||||
+ public CarpetPayload(ResourceLocation location, FriendlyByteBuf buf) {
|
||||
+ this(buf.readNbt());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void write(FriendlyByteBuf buf) {
|
||||
+ buf.writeNbt(nbt);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull
|
||||
+ public ResourceLocation id() {
|
||||
+ return HELLO_ID;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
@@ -1,14 +1,14 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Fri, 9 Feb 2024 03:32:05 +0000
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 14:50:23 +0800
|
||||
Subject: [PATCH] Threaded region start tick and finished tick event
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/TickRegionScheduler.java b/src/main/java/io/papermc/paper/threadedregions/TickRegionScheduler.java
|
||||
index 865044d40a95d201765435cbc14b0384980eebf6..ab5f832aafc479eca1c5da012e180d6374e32325 100644
|
||||
index 4bfa83a6683970657eaaaaa265855f0d2e79a3a9..6bbc9a0fb94980cd201d7ddb7cb440fcee7786f4 100644
|
||||
--- a/src/main/java/io/papermc/paper/threadedregions/TickRegionScheduler.java
|
||||
+++ b/src/main/java/io/papermc/paper/threadedregions/TickRegionScheduler.java
|
||||
@@ -389,7 +389,7 @@ public final class TickRegionScheduler {
|
||||
@@ -442,7 +442,7 @@ public final class TickRegionScheduler {
|
||||
|
||||
final long scheduledStart = this.getScheduledStart();
|
||||
final long scheduledEnd = scheduledStart + TIME_BETWEEN_TICKS;
|
||||
@@ -17,7 +17,7 @@ index 865044d40a95d201765435cbc14b0384980eebf6..ab5f832aafc479eca1c5da012e180d63
|
||||
synchronized (this) {
|
||||
this.currentTickData = new TickTime(
|
||||
lastTickStart, scheduledStart, tickStart, cpuStart,
|
||||
@@ -424,6 +424,7 @@ public final class TickRegionScheduler {
|
||||
@@ -477,6 +477,7 @@ public final class TickRegionScheduler {
|
||||
);
|
||||
|
||||
this.addTickTime(time);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user