Compare commits

...

65 Commits

Author SHA1 Message Date
M2ke4U
6a7501f0eb [ck skip] Updated maven repo 2024-10-01 22:15:48 +08:00
M2ke4U
5fbb4cd58d [ck sip] Removed incorrect element 2024-10-01 22:14:08 +08:00
M2ke4U
a7b73c6321 [ci skip] Updated maven repo 2024-10-01 22:13:32 +08:00
M2ke4U
f960ffddc3 Updated maven repo link 2024-10-01 21:43:16 +08:00
M2ke4U
5a6f4bbf03 Merge pull request #28 from bridgelol/ver/1.20.4
fix: concurrency issue in ServerEntity#sendDirtyEntityData()
2024-08-24 12:08:14 +08:00
bridge
bbddf1cf4a fix: concurrency issue in ServerEntity#sendDirtyEntityData() 2024-08-23 23:22:58 +02:00
M2ke4U
8f9f29697b [ci skip]Update README_EN.md 2024-08-12 21:59:57 +08:00
M2ke4U
2fb281a364 [ci skip]Update README.md 2024-08-12 21:59:19 +08:00
M2ke4U
06bb9d05b1 Remove github packages, gpr registration and use snapshot repo 2024-08-12 19:28:30 +08:00
M2ke4U
e22eb0f63c Added maven publish back 2024-08-12 18:35:42 +08:00
M2ke4U
2c5d683242 [ci skip]Added molia maven repo 2024-08-12 18:31:41 +08:00
ShintoKosei
3299d03d66 Fix Afdian Link 2024-07-30 15:09:37 +08:00
MrHua269
5579f65eae Check null 2024-07-29 17:11:53 +08:00
MrHua269
592877ef28 Synced fixes from branch 1.20.6 2024-07-29 15:11:13 +08:00
MrHua269
bbd1c34a4f Synced POI fixes from branch 1.20.6 2024-07-23 11:43:47 +08:00
MrHua269
9885fe491b Synced POI fixes from branch 1.20.6 2024-07-19 17:55:54 +08:00
MrHua269
6918237be3 Fixed java compile 2024-07-12 21:53:21 +08:00
MrHua269
5c631a232b Synced watchdog fixes from dev/1.20.6 2024-07-01 12:34:36 +08:00
MrHua269
db740bdb3d Fix java compile and restore patches 2024-07-01 12:28:38 +08:00
MrHua269
25f8a7c455 Appended missing timestamp updates in LinearRegionFile 2024-07-01 12:12:18 +08:00
MrHua269
40a7b1a5ff Synced updates on ver/1.20.6 branch 2024-07-01 12:10:13 +08:00
MrHua269
5601fb53d1 Added a simple membar 2024-06-15 13:12:55 +00:00
MrHua269
d753f168ae Added comments for some config 2024-06-15 05:33:25 +00:00
MrHua269
b22fc1fd60 Try fixing folia off region POI accessing issue 2024-06-10 13:11:43 +00:00
ShintoKosei
4c6f3c3861 [ci skip]Update README 2024-05-24 22:20:12 +08:00
ShintoKosei
b42bf0819b [ci skip]Update README (Linear is not supported anymore) 2024-05-19 07:20:16 +08:00
M2ke4U
3ee5f928f0 Linear is not supported anymore 2024-05-11 22:10:03 +08:00
Dreeam
3b04cc4759 Updated Upstream (Folia) 2024-05-11 07:59:14 -04:00
M2ke4U
391ba7a9d6 MojangMap → Reobf 2024-05-10 23:55:44 +08:00
Dreeam
bedc48ca25 Updated Upstream (Folia) 2024-05-09 20:56:20 -04:00
Dreeam
b027e4cd03 Updated Upstream (Folia)
Latest 1.20.4 Paper/Folia
2024-05-09 16:58:15 -04:00
M2ke4U
1e5e540795 Corrected incorrect discord link
WTF??
2024-05-03 21:25:12 +08:00
M2ke4U
a020b181cc Corrected incorrect discord link
WTF?
2024-05-03 21:24:38 +08:00
M2ke4U
7ea76f4f74 Delete patches/server/0061-Added-chunkhot-to-tpsbar.patch 2024-05-03 21:21:19 +08:00
Luminol CI
787c3793c6 Merge remote-tracking branch 'origin/ver/1.20.4' into ver/1.20.4
# Conflicts:
#	patches/server/0052-Leaves-Replay-Mod-API.patch
2024-05-03 12:53:59 +00:00
Luminol CI
39c74a5409 Fix Java compile 2024-05-03 12:52:37 +00:00
M2ke4U
fca5e33fa4 Fix java compile in ReplayMod API 2024-05-03 18:26:07 +08:00
MrHua269
2d14daaa87 Merge remote-tracking branch 'origin/ver/1.20.4' into ver/1.20.4 2024-05-02 04:24:42 +00:00
MrHua269
0a63aeaca2 Removed useless patches 2024-05-02 04:24:28 +00:00
haha44444
729312415f fix goto chinese page bug 2024-04-30 23:19:13 +08:00
haha44444
96499c26ff fix goto english page bug 2024-04-30 23:19:13 +08:00
MrHua269
7645ef08e8 Added chunkhot to tpsbar 2024-04-30 23:19:13 +08:00
MrHua269
e7dde4f240 Merge remote-tracking branch 'origin/ver/1.20.4' into ver/1.20.4 2024-04-30 14:03:20 +00:00
MrHua269
dbb30dc4f3 Added chunkhot to tpsbar 2024-04-30 14:02:57 +00:00
M2ke4U
65de2ae23e Merge pull request #13 from haha44444/ver/1.20.4
fix a littleeeee issue
2024-04-30 20:24:36 +08:00
haha44444
ec74075cc5 fix goto chinese page bug 2024-04-30 02:26:59 +08:00
haha44444
e5379a2042 fix goto english page bug 2024-04-30 02:25:50 +08:00
MrHua269
67ba24ec92 Merge remote-tracking branch 'origin/ver/1.20.4' into ver/1.20.4 2024-04-27 13:24:15 +00:00
MrHua269
943c084de6 Fully APIs for ChunkHotAPI 2024-04-27 13:24:03 +00:00
ShintoKosei
8d3c7e7807 Change to Mojmap 2024-04-27 21:07:36 +08:00
MrHua269
fbd9d9f48f Fix some stuff about ChunkHot API 2024-04-27 13:03:44 +00:00
MrHua269
512da58f92 KioCG ChunkHot API test 2024-04-27 12:43:42 +00:00
MrHua269
b239c97db1 Removed linear format support 2024-04-27 10:39:01 +00:00
MrHua269
650ce2770d Added flush threshold for linear region file 2024-04-20 13:34:16 +00:00
MrHua269
ce500bf638 Added flush threshold for linear region file 2024-04-20 13:33:34 +00:00
MrHua269
48f34a6146 Refactor linear flushing again 2024-04-20 13:15:22 +00:00
ShintoKosei
40cae40b09 Fix CI 2024-04-14 13:56:38 +08:00
ShintoKosei
38a8161c1a Update CI 2024-04-14 13:50:09 +08:00
MrHua269
dced86a404 Fix java compile 2024-04-13 12:18:11 +00:00
MrHua269
a983ac00e5 Update(Leaves): Photographer GameMode locked 2024-04-13 12:16:03 +00:00
MrHua269
e2b21e0f69 Clean and optimize patches 2024-04-13 12:05:00 +00:00
MrHua269
07ef8e01c5 Remove io_uring support 2024-04-13 11:58:11 +00:00
MrHua269
77cb94ae5f Updated Upstream(Folia) 2024-04-13 11:55:55 +00:00
MrHua269
14e7cbe186 Clean patches 2024-04-13 11:41:31 +00:00
ShintoKosei
49be774d83 rebase 2024-04-13 19:03:09 +08:00
85 changed files with 2477 additions and 3951 deletions

2
.github/FUNDING.yml vendored
View File

@@ -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 lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
polar: # Replace with a single Polar username polar: # Replace with a single Polar username
buy_me_a_coffee: # Replace with a single Buy Me a Coffee 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

73
.github/workflows/build_1.20.4.yml vendored Normal file
View File

@@ -0,0 +1,73 @@
name: Luminol CI - 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
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.4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- 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 createReobfBundlerJar createReobfPaperclipJar
- name: Publish to repo
run: |
export GITHUB_USERNAME=LuminolCI
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
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 }} [![download](https://img.shields.io/github/downloads/LuminolMC/${{ env.project_id }}/${{ env.tag }}/total?color=0&style=flat-square)](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 }}
build/libs/${{ env.project_id }}-${{ env.mcversion }}-bundler.jar
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]')"
env:
secret_v2: ${{ secrets.API_KEY }}
tag: ${{ env.tag }}
project_id: ${{ env.project_id }}
run: sh scripts/PushToAPI.sh

View File

@@ -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

View File

@@ -9,12 +9,11 @@
![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/LuminolMC/Luminol?style=flat-square) ![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/LuminolMC/Luminol?style=flat-square)
![GitHub all releases](https://img.shields.io/github/downloads/LuminolMC/Luminol/total?style=flat-square) ![GitHub all releases](https://img.shields.io/github/downloads/LuminolMC/Luminol/total?style=flat-square)
[English](./README_EN) | **中文** [English](./README_EN.md) | **中文**
## 特性 ## 特性
- 可配置的原版特性 - 可配置的原版特性
- Tpsbar 支持 - Tpsbar 支持
- 线性区域文件格式 (from kaiiju)
- 对单线程区域性能的优化 - 对单线程区域性能的优化
- 更多的插件开发API支持进行中 - 更多的插件开发API支持进行中
@@ -25,35 +24,48 @@
要构建一个paperclip jar你需要运行以下命令。你可以在build/libs中找到jar注意需要`JDK17` 要构建一个paperclip jar你需要运行以下命令。你可以在build/libs中找到jar注意需要`JDK17`
```shell ```shell
./gradlew applyPatches && ./gradlew createReobfPaperclipJar ./gradlew applyPatches && ./gradlew createMojmapPaperclipJar
``` ```
## 使用API ## 使用API
使用 Gradle: 使用 Gradle:
```kotlin ```kotlin
repositories {
maven {
url = "http://maven.nostal.ink/repository/maven-snapshots/"
}
}
dependencies { dependencies {
compileOnly("me.earthme.luminol:luminol-api:1.20.4-R0.1-SNAPSHOT") compileOnly("me.earthme.luminol:luminol-api:1.20.4-R0.1-20241001.135101-1")
} }
``` ```
使用 Maven 使用 Maven
```xml ```xml
<dependency> <repositories>
<groupId>me.earthme.luminol</groupId> <repository>
<artifactId>luminol-api</artifactId> <id>nostal</id>
<version>1.20.4-R0.1-SNAPSHOT</version> <url>http://maven.nostal.ink/repository/maven-snapshots/</url>
</dependency> </repository>
</repositories>
<dependencies>
<dependency>
<groupId>me.earthme.luminol</groupId>
<artifactId>luminol-api</artifactId>
<version>1.20.4-R0.1-20241001.135101-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 ## 关于 Issue
当您遇到任何问题时,请向我们提问,我们将尽力解决,但请记得清楚地描述您的问题并提供足够的日志等信息。 当您遇到任何问题时,请向我们提问,我们将尽力解决,但请记得清楚地描述您的问题并提供足够的日志等信息。
@@ -74,3 +86,4 @@ QQ群: [368632360](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=MfosKhcDd8Fdxn1MREu
<img alt="Star历史表" src="https://api.star-history.com/svg?repos=LuminolMC/Luminol%2CLuminolMC/LightingLuminol&type=Date" /> <img alt="Star历史表" src="https://api.star-history.com/svg?repos=LuminolMC/Luminol%2CLuminolMC/LightingLuminol&type=Date" />
</picture> </picture>
</a> </a>

View File

@@ -1,5 +1,3 @@
<img src="./public/image/Luminol_5.png" alt="Logo" align="right" width="250">
# Luminol # Luminol
<h4>Luminol is a Folia fork with many useful optimizations, configurable vanilla features, and more API supports, and it was designed for survival and anarchy servers</h4> <h4>Luminol is a Folia fork with many useful optimizations, configurable vanilla features, and more API supports, and it was designed for survival and anarchy servers</h4>
@@ -9,12 +7,11 @@
![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/LuminolMC/Luminol?style=flat-square) ![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/LuminolMC/Luminol?style=flat-square)
![GitHub all releases](https://img.shields.io/github/downloads/LuminolMC/Luminol/total?style=flat-square) ![GitHub all releases](https://img.shields.io/github/downloads/LuminolMC/Luminol/total?style=flat-square)
**English** | [中文](./README) **English** | [中文](./README.md)
## Features ## Features
- Configurable vanilla features - Configurable vanilla features
- Tpsbar support - Tpsbar support
- Linear region file format(from kaiiju)
- Useful optimizations to improve the performance of single threaded region - Useful optimizations to improve the performance of single threaded region
- More API support for plugin development (W.I.P) - More API support for plugin development (W.I.P)
@@ -25,35 +22,47 @@ Any versions are available in the [release](https://github.com/LuminolMC/Luminol
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: JDK17 is needed)
```shell ```shell
./gradlew applyPatches && ./gradlew createReobfPaperclipJar ./gradlew applyPatches && ./gradlew createMojmapPaperclipJar
``` ```
## Using API ## Using API
For gradle: For gradle:
```kotlin ```kotlin
repositories {
maven {
url = "http://maven.nostal.ink/repository/maven-snapshots/"
}
}
dependencies { dependencies {
compileOnly("me.earthme.luminol:luminol-api:1.20.4-R0.1-SNAPSHOT") compileOnly("me.earthme.luminol:luminol-api:1.20.4-R0.1-20241001.135101-1")
} }
``` ```
For maven For maven
```xml ```xml
<dependency> <repositories>
<groupId>me.earthme.luminol</groupId> <repository>
<artifactId>luminol-api</artifactId> <id>nostal</id>
<version>1.20.4-R0.1-SNAPSHOT</version> <url>http://maven.nostal.ink/repository/maven-snapshots/</url>
</dependency> </repository>
</repositories>
<dependencies>
<dependency>
<groupId>me.earthme.luminol</groupId>
<artifactId>luminol-api</artifactId>
<version>1.20.4-R0.1-20241001.135101-1</version>
</dependency>
</dependencies>
``` ```
## Contact ## Contact
> If you are interested in this project or have any issue, feel free to ask us. > 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) **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)
> [!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.**
## About Issue ## 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> 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>

View File

@@ -2,7 +2,7 @@ plugins {
java java
`maven-publish` `maven-publish`
id("com.github.johnrengelman.shadow") version "8.1.1" apply false id("com.github.johnrengelman.shadow") version "8.1.1" apply false
id("io.papermc.paperweight.patcher") version "1.5.11" id("io.papermc.paperweight.patcher") version "1.5.15"
} }
val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
@@ -15,9 +15,9 @@ repositories {
} }
dependencies { dependencies {
remapper("net.fabricmc:tiny-remapper:0.8.6:fat") remapper("net.fabricmc:tiny-remapper:0.10.1:fat")
decompiler("org.quiltmc:quiltflower:1.9.0") decompiler("org.vineflower:vineflower:1.10.1")
paperclip("io.papermc:paperclip:3.0.3-SNAPSHOT") paperclip("io.papermc:paperclip:3.0.3")
} }
subprojects { subprojects {
@@ -112,21 +112,15 @@ allprojects {
publishing { publishing {
repositories { repositories {
maven { maven {
name = "githubPackage" name = "moliaMavenRepo"
url = uri("https://maven.pkg.github.com/LuminolMC/Luminol") url = uri("https://maven.nostal.ink/repository/maven-snapshots/")
credentials.username = System.getenv("GITHUB_USERNAME") credentials.username = System.getenv("MAVEN_REPO_USER")
credentials.password = System.getenv("GITHUB_TOKEN") credentials.password = System.getenv("MAVEN_REPO_PASSWORD")
}
publications {
register<MavenPublication>("gpr") {
from(components["java"])
}
} }
} }
} }
} }
publishing { publishing {
if (project.hasProperty("publishDevBundle")) { if (project.hasProperty("publishDevBundle")) {

View File

@@ -1,9 +1,13 @@
group = me.earthme.luminol group = me.earthme.luminol
version = 1.20.4-R0.1-SNAPSHOT version = 1.20.4-R0.1-SNAPSHOT
foliaCommit = ef2c6971891b7571261591cd22d27ff555c5d3f2 foliaCommit = ec6b1729ec9c3449cb65918d7af1ccf464ab3692
org.gradle.caching = true org.gradle.caching = true
org.gradle.parallel = true org.gradle.parallel = true
org.gradle.vfs.watch = false org.gradle.vfs.watch = false
org.gradle.jvmargs = -Xmx3G org.gradle.jvmargs = -Xmx3G
mcVersion = 1.20.4
GroupMCV = 1.20
preVersion = false

Binary file not shown.

View File

@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists 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 networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

29
gradlew vendored
View File

@@ -83,10 +83,8 @@ done
# This is normally unused # This is normally unused
# shellcheck disable=SC2034 # shellcheck disable=SC2034
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # 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
# 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"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@@ -133,10 +131,13 @@ location of your Java installation."
fi fi
else else
JAVACMD=java 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 Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
@@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #( case $MAX_FD in #(
max*) max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. # 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 ) || MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit" warn "Could not query maximum file descriptor limit"
esac esac
@@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #( '' | soft) :;; #(
*) *)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. # 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" || ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD" warn "Could not set maximum file descriptor limit to $MAX_FD"
esac esac
@@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done done
fi fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
# shell script including quotes and variable substitutions, so put them in DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded. # 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 -- \ set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \ "-Dorg.gradle.appname=$APP_BASE_NAME" \

20
gradlew.bat vendored
View File

@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute if %ERRORLEVEL% equ 0 goto execute
echo. echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. echo location of your Java installation. 1>&2
goto fail goto fail
@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute if exist "%JAVA_EXE%" goto execute
echo. echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. echo location of your Java installation. 1>&2
goto fail goto fail

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Leaves Replay Mod API
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 4d6de4f2c67b1f122768806443766bd20c5ae617..b5155ffe86c490252fd0fcd1a00581e09808eeee 100644 index c37904d1aae749030620e1bbdb955e25c91ab1f8..84df970635f25239ba1e67fd3dcb4401d14be862 100644
--- a/src/main/java/org/bukkit/Bukkit.java --- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2886,4 +2886,10 @@ public final class Bukkit { @@ -2892,4 +2892,10 @@ public final class Bukkit {
public static Server.Spigot spigot() { public static Server.Spigot spigot() {
return server.spigot(); return server.spigot();
} }
@@ -20,10 +20,10 @@ index 4d6de4f2c67b1f122768806443766bd20c5ae617..b5155ffe86c490252fd0fcd1a00581e0
+ // Leaves end - Photographer API + // Leaves end - Photographer API
} }
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index d46f932b595495816ea038cf161bc7f2d85f177e..7d8a9bab880656e34d8c4dceb4dea3b0c1ced4c8 100644 index 15395ef52505087e7eef3b1a5981e787dcc16508..7c7b350f1bbcd1585d175cf9c6b0a938ae5ad759 100644
--- a/src/main/java/org/bukkit/Server.java --- a/src/main/java/org/bukkit/Server.java
+++ b/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 @@ -2524,4 +2524,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*/ */
public boolean isGlobalTickThread(); public boolean isGlobalTickThread();
// Folia end - region threading API // Folia end - region threading API

View File

@@ -0,0 +1,28 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <novau233@163.com>
Date: Sat, 27 Apr 2024 13:22:59 +0000
Subject: [PATCH] KioCG Chunk API
diff --git a/src/main/java/org/bukkit/Chunk.java b/src/main/java/org/bukkit/Chunk.java
index d547ae2b20c58bc703de4532b3b591dd34ddb1c6..8721954514f813d0a1200935e27a3ac00ceca135 100644
--- a/src/main/java/org/bukkit/Chunk.java
+++ b/src/main/java/org/bukkit/Chunk.java
@@ -377,4 +377,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 d048ae07cc33fd77d128cc1ebf88b0804969fa3c..7e633b448327ee01533a00bc278367c47951d3e2 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -3752,4 +3752,6 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
@Override
Spigot spigot();
// Spigot end
+
+ long getNearbyChunkHot(); // KioCG
}

View File

@@ -27,7 +27,7 @@ index cb60d58d4a7556dd896f31d0cd249f860bb3ef84..b52a805150e95d7d27403d3c18088b33
metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> { metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> {
Map<String, Map<String, Integer>> map = new HashMap<>(); 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 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 e2f704c115fd6e00960bb56bb0779f1100c89c17..7707908064a75ecf02677a0110207e194c3eefd1 100644
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java --- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
+++ b/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; @@ -20,7 +20,7 @@ import java.util.stream.StreamSupport;
@@ -51,7 +51,7 @@ index e2f704c115fd6e00960bb56bb0779f1100c89c17..72b9343979de5aa8bb399cbe7cb8a795
return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage; 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 diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index d6a7188227cee9072976db98613324ee2d3dcdc8..8c9a80197247a384dd80747bf23fdd809d08b341 100644 index bcc8a0171f981e2b2e24dd57834701c1899ab4c9..489e0faaf1847bf849719a58323d8eb575bdaf50 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/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 @@ -1963,7 +1963,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Empty config file base
diff --git a/build.gradle.kts b/build.gradle.kts diff --git a/build.gradle.kts b/build.gradle.kts
index 48e9f6ff317bfc7077563e9c651d2a90da6bb37a..d4baa7a193eba22be23921029ca4808a73de063d 100644 index c0608731dd7a352628a1e31997d0658dfa9f2ea8..66c34f883a93dd86fcac8029cce63ffe7340c89b 100644
--- a/build.gradle.kts --- a/build.gradle.kts
+++ b/build.gradle.kts +++ b/build.gradle.kts
@@ -19,6 +19,7 @@ dependencies { @@ -19,6 +19,7 @@ dependencies {
@@ -414,24 +414,15 @@ index 0000000000000000000000000000000000000000..2b4e64796bf01b0a5fcb306850cd6083
+ } + }
+} +}
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java 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 6b3242117d62175de462d04e4d178b49ae2521e9..68355b9a0a88c871e18031d04581c9ef53313f48 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/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; @@ -209,6 +209,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
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
this.paperConfigurations.initializeGlobalConfiguration(this.registryAccess()); this.paperConfigurations.initializeGlobalConfiguration(this.registryAccess());
this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess());
// Paper end - initialize global and world-defaults configuration // Paper end - initialize global and world-defaults configuration
+ LuminolConfig.loadConfig(); //Luminol - load config file + me.earthme.luminol.config.LuminolConfig.loadConfig(); //Luminol - load config file
+ LuminolConfig.setupLatch(); //Luminol - load config file + me.earthme.luminol.config.LuminolConfig.setupLatch(); //Luminol - load config file
// Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save // Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save
if (this.convertOldUsers()) { if (this.convertOldUsers()) {
this.getProfileCache().save(false); // Paper this.getProfileCache().save(false); // Paper

View File

@@ -6,7 +6,7 @@ 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 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 new file mode 100644
index 0000000000000000000000000000000000000000..1b0de6f0ccab72c409a63dc1904829008e30328e index 0000000000000000000000000000000000000000..ea374875f529b30db17e8b8cb07b99a600b722dc
--- /dev/null --- /dev/null
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/UnsafeTeleportationConfig.java +++ b/src/main/java/me/earthme/luminol/config/modules/fixes/UnsafeTeleportationConfig.java
@@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
@@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..1b0de6f0ccab72c409a63dc190482900
+import me.earthme.luminol.config.IConfigModule; +import me.earthme.luminol.config.IConfigModule;
+ +
+public class UnsafeTeleportationConfig implements IConfigModule { +public class UnsafeTeleportationConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enabled", comments = "If you want to use sand duping,please turn on this") + @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; + public static boolean enabled = false;
+ +
+ @Override + @Override
@@ -31,7 +31,7 @@ index 0000000000000000000000000000000000000000..1b0de6f0ccab72c409a63dc190482900
+ } + }
+} +}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java 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 index 0e71fa29ebfa649bc23899046396a6b01c4bd131..6463a55477b61f8cb3d17159792e5d3f1a87f7b7 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/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 @@ -4065,6 +4065,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S

View File

@@ -31,10 +31,10 @@ 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 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 36f1af9ef5fca7c45f250470d21a4dfbf573ceac..43b8f64d7c14e6dd0975b24a3205806c4433f26f 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/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 { @@ -3058,7 +3058,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
// Spigot Start // Spigot Start
if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message 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 // Paper start - Fix merchant inventory not closing on entity removal

View File

@@ -6,7 +6,7 @@ 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 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 new file mode 100644
index 0000000000000000000000000000000000000000..ee247014c9a2ec1bbb7f25ef41da110a270154d6 index 0000000000000000000000000000000000000000..0e6bfc03be660415c333024b56ac6565e3b61ab1
--- /dev/null --- /dev/null
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/VanillaRandomSourceConfig.java +++ b/src/main/java/me/earthme/luminol/config/modules/fixes/VanillaRandomSourceConfig.java
@@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
@@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..ee247014c9a2ec1bbb7f25ef41da110a
+import me.earthme.luminol.config.IConfigModule; +import me.earthme.luminol.config.IConfigModule;
+ +
+public class VanillaRandomSourceConfig implements 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; + public static boolean useLegacyRandomSourceForPlayers = false;
+ +
+ @Override + @Override
@@ -31,7 +31,7 @@ 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 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 6463a55477b61f8cb3d17159792e5d3f1a87f7b7..8ad21bf69fe2ebbda7295c16971c31a55cd23108 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/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 @@ -567,7 +567,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S

View File

@@ -31,7 +31,7 @@ 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 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 4abd7babc3aa7268975386e7c2319f7961b0c3aa..d209466866c30b3f15b8c40934ea6470292b8a77 100644
--- a/src/main/java/net/minecraft/commands/arguments/ArgumentSignatures.java --- a/src/main/java/net/minecraft/commands/arguments/ArgumentSignatures.java
+++ b/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,17 @@ public record ArgumentSignatures(List<ArgumentSignatures.Entry> entries) {
@@ -52,7 +52,7 @@ index 72a8aa676836fcb3b4578689d16af65e18f55bbe..9408747cb254a99d5cb3fc26fde16ddb
+ +
@Nullable @Nullable
public MessageSignature get(String argumentName) { public MessageSignature get(String argumentName) {
for(ArgumentSignatures.Entry entry : this.entries) { for (ArgumentSignatures.Entry entry : this.entries) {
diff --git a/src/main/java/net/minecraft/network/FriendlyByteBuf.java b/src/main/java/net/minecraft/network/FriendlyByteBuf.java 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 b863249ff7e13cf4939c8961601f0564c62fd661..6ab73b0568c3f9df8090be992736a14d49e0286c 100644
--- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java --- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java

View File

@@ -347,10 +347,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 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 68355b9a0a88c871e18031d04581c9ef53313f48..c626018d786fe231cd74a28c83515715d896f214 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/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 @@ -830,6 +830,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
@Override @Override
public void stopServer() { public void stopServer() {
@@ -359,7 +359,7 @@ index 4744ace98d1741db80ac2aea198f332d95c0ba33..550fb11c64e3adb35bb7f78c53f0b5ae
//Util.shutdownExecutors(); // Paper - moved into super //Util.shutdownExecutors(); // Paper - moved into super
SkullBlockEntity.clear(); SkullBlockEntity.clear();
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java 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 9d7837f90340a96edbd544826ae2241c61ae72c4..c8701a2a0a3cbd60e263fe5c069b5993b36842a6 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/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 { @@ -285,6 +285,7 @@ public class ServerPlayer extends Player {
@@ -371,7 +371,7 @@ index cbc89b8898f9243776af88c2b04ad3c2e4e23fb6..318cb1e98a3d73b7893f07c9f0db3ada
public io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances getViewDistances() { public io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances getViewDistances() {
return this.viewDistances.get(); return this.viewDistances.get();
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java 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 0ece776a1e281a328e28dc07fb4dc882b19d029c..b57980d4fa445f2aa71e4477459da833eade50e8 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/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 { @@ -2287,6 +2287,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {

View File

@@ -0,0 +1,331 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <novau233@163.com>
Date: Sun, 2 Jun 2024 12:18:05 +0000
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..a33a45194273cc1b4e4157a5449c7994968a3480
--- /dev/null
+++ b/src/main/java/me/earthme/luminol/functions/GlobalServerMemoryBar.java
@@ -0,0 +1,186 @@
+package me.earthme.luminol.functions;
+
+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 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 java.lang.management.ManagementFactory;
+import java.lang.management.MemoryUsage;
+import java.util.*;
+
+public class GlobalServerMemoryBar {
+ protected static final MinecraftInternalPlugin NULL_PLUGIN = new MinecraftInternalPlugin();
+ protected static final Map<UUID, BossBar> uuid2Bossbars = new HashMap<>();
+ protected static volatile ScheduledTask membarTask = null;
+ private static final Logger logger = LogManager.getLogger();
+
+ public static void init(){
+ cancelBarUpdateTask();
+
+ Bukkit.getGlobalRegionScheduler().runAtFixedRate(NULL_PLUGIN, c -> {
+ membarTask = c;
+ try {
+ update();
+ }catch (Exception e){
+ logger.error(e);
+ }
+ },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.sectionX,nmsPlayer.sectionZ);
+
+ 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 c626018d786fe231cd74a28c83515715d896f214..49647526d81e269aaf7a375992e3b42765ef5f8a 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -831,6 +831,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 c8701a2a0a3cbd60e263fe5c069b5993b36842a6..4e500aea07278535467ab6a9eba5b4269e1bd6ac 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -286,6 +286,7 @@ public class ServerPlayer extends Player {
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;
public volatile boolean isTpsBarVisible = false; //Luminol - Tps bar
+ public volatile boolean isMemBarVisible = false; //Luminol - Memory bar
public io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances getViewDistances() {
return this.viewDistances.get();

View File

@@ -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 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 49647526d81e269aaf7a375992e3b42765ef5f8a..04cf704af4def0b6fb4fbdedb4c9cdaa4216bc46 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/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 @@ -282,7 +282,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
String proxyFlavor = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "Velocity" : "BungeeCord"; 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/"; 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 // Paper end - Add Velocity IP Forwarding Support
- if (!this.usesAuthentication()) { - 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("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
// Spigot start // Spigot start

View File

@@ -31,10 +31,10 @@ 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 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 0af9ed92824ccf30814eceb6a2c2e5c12661c991..7c42f0ca1f3abe38dcd97b0985c72332b45761f7 100644
--- a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java --- a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
+++ b/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 { @@ -37,7 +37,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) 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()) { } 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 throw new SignedMessageChain.DecodeException(Component.translatable("chat.disabled.expiredProfileKey"), false, org.bukkit.event.player.PlayerKickEvent.Cause.EXPIRED_PROFILE_PUBLIC_KEY); // Paper - kick event causes

View File

@@ -16,24 +16,11 @@ index fc3d332aa1c1d469cedfe2aaa7102dcd78e25642..1ae61bc6603dd3ac290e3ead20416f9c
/* /*
if (false) { if (false) {
io.papermc.paper.threadedregions.ThreadedTicketLevelPropagator.main(null); 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 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 index 2ad25dd345ab42125d456f2b9cf67d8c4515c8b7..183fede965c3d227bbcc7e54781869e09796081f 100644
--- a/src/main/java/io/papermc/paper/threadedregions/TickRegions.java --- a/src/main/java/io/papermc/paper/threadedregions/TickRegions.java
+++ b/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 @@ -402,10 +402,11 @@ public final class TickRegions implements ThreadedRegionizer.RegionCallbacks<Tic
@Override @Override
protected void tickRegion(final int tickCount, final long startTime, final long scheduledEnd) { protected void tickRegion(final int tickCount, final long startTime, final long scheduledEnd) {
@@ -41,6 +28,11 @@ index 2ad25dd345ab42125d456f2b9cf67d8c4515c8b7..78c50292fb25e8703e9c91db892f0545
final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); // Folia - profiler final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); // Folia - profiler
profiler.startTick(); try { // Folia - profiler profiler.startTick(); try { // Folia - profiler
MinecraftServer.getServer().tickServer(startTime, scheduledEnd, TimeUnit.MILLISECONDS.toMillis(10L), this.region); MinecraftServer.getServer().tickServer(startTime, scheduledEnd, TimeUnit.MILLISECONDS.toMillis(10L), this.region);
- } finally { profiler.stopTick(); } // Folia - profiler
+ } finally { profiler.stopTick(); me.earthme.luminol.utils.LuminolWatchDog.releaseTickRegion(); } // Folia - profiler //Luminol - Simple watchdog
}
@Override
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 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 new file mode 100644
index 0000000000000000000000000000000000000000..71d80b401470db777a86274d32f178bb2aa023d5 index 0000000000000000000000000000000000000000..71d80b401470db777a86274d32f178bb2aa023d5
@@ -76,10 +68,10 @@ index 0000000000000000000000000000000000000000..71d80b401470db777a86274d32f178bb
+} +}
diff --git a/src/main/java/me/earthme/luminol/utils/LuminolWatchDog.java b/src/main/java/me/earthme/luminol/utils/LuminolWatchDog.java 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 new file mode 100644
index 0000000000000000000000000000000000000000..6b4368cdf9762ad981345fef0f26cd008a4236ee index 0000000000000000000000000000000000000000..e19c6330a48cee402b1a999ca71cb2329d530356
--- /dev/null --- /dev/null
+++ b/src/main/java/me/earthme/luminol/utils/LuminolWatchDog.java +++ b/src/main/java/me/earthme/luminol/utils/LuminolWatchDog.java
@@ -0,0 +1,161 @@ @@ -0,0 +1,178 @@
+package me.earthme.luminol.utils; +package me.earthme.luminol.utils;
+ +
+import com.google.common.collect.Maps; +import com.google.common.collect.Maps;
@@ -100,18 +92,23 @@ index 0000000000000000000000000000000000000000..6b4368cdf9762ad981345fef0f26cd00
+import java.util.Map; +import java.util.Map;
+import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Executor; +import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeUnit;
+ +
+public class LuminolWatchDog { +public class LuminolWatchDog {
+ private static final Object keepaliveDataLock = new Object(); + private static final Object keepaliveDataLock = new Object();
+ private static Pair<Thread,Long> globalRegionLastKeepalive = null; + private static Pair<Thread,Long> globalRegionLastKeepalive = null;
+ private static final Map<Thread,Pair<ThreadedRegionizer.ThreadedRegion<?,?>,Long>> otherTickRegionKeepalive = Maps.newHashMap(); + 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 Executor checkTimer = CompletableFuture.delayedExecutor(50, TimeUnit.MILLISECONDS,Executors.newSingleThreadExecutor());
+ private static final Logger logger = MinecraftServer.LOGGER; + private static final Logger logger = MinecraftServer.LOGGER;
+ private static int tickCount = 0; + private static int tickCount = 0;
+ private static boolean runScheduleNext = true; + private static volatile boolean runScheduleNext = true;
+ +
+ public static void boot(){ + public static void boot(){
+ if (!WatchdogConfig.enabled){
+ return;
+ }
+
+ runCheck(); + runCheck();
+ } + }
+ +
@@ -119,6 +116,10 @@ index 0000000000000000000000000000000000000000..6b4368cdf9762ad981345fef0f26cd00
+ checkTimer.execute(LuminolWatchDog::runCheck); + checkTimer.execute(LuminolWatchDog::runCheck);
+ } + }
+ +
+ public static void stopTicking(){
+ runScheduleNext = false;
+ }
+
+ private static void runCheck(){ + private static void runCheck(){
+ try { + try {
+ if (MinecraftServer.getServer().isStopped() || !runScheduleNext){ + if (MinecraftServer.getServer().isStopped() || !runScheduleNext){
@@ -143,15 +144,23 @@ index 0000000000000000000000000000000000000000..6b4368cdf9762ad981345fef0f26cd00
+ } + }
+ } + }
+ +
+ for (Map.Entry<Thread,Pair<ThreadedRegionizer.ThreadedRegion<?,?>,Long>> tickData : otherTickRegionKeepalive.entrySet()){
+ final Thread targetThread = tickData.getKey();
+ final Pair<ThreadedRegionizer.ThreadedRegion<?, ?>, Long> keepaliveData = tickData.getValue();
+ final long lastKeepalive = keepaliveData.getRight();
+
+ final long timeEscaped = currentTimeNano - lastKeepalive;
+
+ if (timeEscaped >= WatchdogConfig.warnPeriodTicks * 50 * 1000 * 1000){
+ threadsToWarn.add(Pair.of(targetThread,timeEscaped));
+ }
+ }
+
+ for(Pair<Thread,Long> warnInfo : threadsToWarn){ + for(Pair<Thread,Long> warnInfo : threadsToWarn){
+ final Thread targetThread = warnInfo.getLeft(); + final Thread targetThread = warnInfo.getLeft();
+ final long timeEscaped = warnInfo.getRight(); + final long timeEscaped = warnInfo.getRight();
+ +
+ final ThreadedRegionizer.ThreadedRegion<?,?> targetRegion; + final ThreadedRegionizer.ThreadedRegion<?,?> targetRegion = targetThread == globalRegionLastKeepalive.getKey() ? null : otherTickRegionKeepalive.get(targetThread).getLeft();
+
+ synchronized (keepaliveDataLock){
+ targetRegion = otherTickRegionKeepalive.get(targetThread).getLeft();
+ }
+ +
+ if (tickCount % WatchdogConfig.warnPeriodTicks == 0){ + if (tickCount % WatchdogConfig.warnPeriodTicks == 0){
+ dumpSingleRegion(targetThread,targetRegion,timeEscaped); + dumpSingleRegion(targetThread,targetRegion,timeEscaped);
@@ -231,7 +240,7 @@ index 0000000000000000000000000000000000000000..6b4368cdf9762ad981345fef0f26cd00
+ } + }
+ } + }
+ +
+ public static void onRegionDeath(ThreadedRegionizer.ThreadedRegion<?,?> currentRegion){ + public static void releaseTickRegion(){
+ if (!WatchdogConfig.enabled){ + if (!WatchdogConfig.enabled){
+ return; + return;
+ } + }
@@ -243,10 +252,18 @@ index 0000000000000000000000000000000000000000..6b4368cdf9762ad981345fef0f26cd00
+} +}
\ No newline at end of file \ 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 diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 0d756dd5181a2444175184227bef648d07c17236..59b1da130e519cbe06ed5eedf9e4dc881e45ba36 100644 index cb3ae17634dfc753dec75c7e2385a4ccdcba40d3..90fa6634dd1e426ba2469d366b3226a077c10f0e 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/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 @@ -1003,6 +1003,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
// Folia end - region threading
public void stopServer() {
+ me.earthme.luminol.utils.LuminolWatchDog.stopTicking(); // Luminol - Watchdog
// Folia start - region threading
// halt scheduler
// don't wait, we may be on a scheduler thread
@@ -1222,6 +1223,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.statusIcon = (ServerStatus.Favicon) this.loadStatusIcon().orElse(null); // CraftBukkit - decompile error this.statusIcon = (ServerStatus.Favicon) this.loadStatusIcon().orElse(null); // CraftBukkit - decompile error
this.status = this.buildServerStatus(); this.status = this.buildServerStatus();

View File

@@ -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
}
}
}

View File

@@ -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;

View File

@@ -6,10 +6,10 @@ 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 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 new file mode 100644
index 0000000000000000000000000000000000000000..8487799cdfb776eaca33b57f7c99ae3aeadb890d index 0000000000000000000000000000000000000000..01f8c6ff3662569be5a4ff998bcd4fbbcb555105
--- /dev/null --- /dev/null
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaSpectorTeleportationFixConfig.java +++ b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaSpectorTeleportationFixConfig.java
@@ -0,0 +1,20 @@ @@ -0,0 +1,25 @@
+package me.earthme.luminol.config.modules.fixes; +package me.earthme.luminol.config.modules.fixes;
+ +
+import me.earthme.luminol.config.ConfigInfo; +import me.earthme.luminol.config.ConfigInfo;
@@ -17,7 +17,12 @@ index 0000000000000000000000000000000000000000..8487799cdfb776eaca33b57f7c99ae3a
+import me.earthme.luminol.config.IConfigModule; +import me.earthme.luminol.config.IConfigModule;
+ +
+public class FoliaSpectorTeleportationFixConfig implements IConfigModule { +public class FoliaSpectorTeleportationFixConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enabled") + @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; + public static boolean fixSpectorTeleportFolia = false;
+ +
+ @Override + @Override
@@ -31,24 +36,15 @@ index 0000000000000000000000000000000000000000..8487799cdfb776eaca33b57f7c99ae3a
+ } + }
+} +}
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java 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 index 4e500aea07278535467ab6a9eba5b4269e1bd6ac..25978b9c25096f252acd60a0924bac400d6026e7 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/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; @@ -843,6 +843,11 @@ public class ServerPlayer extends Player {
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(); Entity entity = this.getCamera();
+ //Luminol start - Fix folia spector teleportation + //Luminol start - Fix folia spector teleportation
+ if (!io.papermc.paper.util.TickThread.isTickThreadFor(entity) && FoliaSpectorTeleportationFixConfig.fixSpectorTeleportFolia){ + if (!io.papermc.paper.util.TickThread.isTickThreadFor(entity) && me.earthme.luminol.config.modules.fixes.FoliaSpectorTeleportationFixConfig.fixSpectorTeleportFolia){
+ this.setCamera(this); + this.setCamera(this);
+ } + }
+ //Luminol end + //Luminol end

View File

@@ -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 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 new file mode 100644
index 0000000000000000000000000000000000000000..73d99a105a18231901e691922b0c283adae0cc79 index 0000000000000000000000000000000000000000..0e51d465db3554ac80d00c6b85cc1f013f3949ba
--- /dev/null --- /dev/null
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaEntityMovingFixConfig.java +++ 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; +package me.earthme.luminol.config.modules.fixes;
+ +
+import me.earthme.luminol.config.ConfigInfo; +import me.earthme.luminol.config.ConfigInfo;
@@ -17,7 +17,13 @@ index 0000000000000000000000000000000000000000..73d99a105a18231901e691922b0c283a
+import me.earthme.luminol.config.IConfigModule; +import me.earthme.luminol.config.IConfigModule;
+ +
+public class FoliaEntityMovingFixConfig implements 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; + public static boolean enabled = false;
+ @ConfigInfo(baseName = "warn_on_detected") + @ConfigInfo(baseName = "warn_on_detected")
+ public static boolean warnOnDetected = true; + 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 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 8ad21bf69fe2ebbda7295c16971c31a55cd23108..cbf5bda50b87b8520ee6fa6d0b41c94b5c9f3583 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/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; @@ -1086,10 +1086,40 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
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
} }
// Paper end - detailed watchdog information // Paper end - detailed watchdog information
@@ -66,13 +55,13 @@ index 9bbfac91f97331b1b558264c867b7e00185291f2..dfb1b8c3af93bfcddb976c003c6ac2d5
// Paper start - detailed watchdog information // Paper start - detailed watchdog information
io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main"); io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main");
+ //Luminol start - Fix high position moving + //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 (me.earthme.luminol.config.modules.fixes.FoliaEntityMovingFixConfig.enabled && io.papermc.paper.util.TickThread.isTickThread()){ //Except the threads because it may be called by the chunk system worker thread
+ if (this.preventMoving){ + if (this.preventMoving){
+ return; + return;
+ } + }
+ +
+ var finalPosition = movement.add(this.position); + var finalPosition = movement.add(this.position);
+ if (!TickThread.isTickThreadFor(((ServerLevel) this.level),finalPosition)){ + if (!io.papermc.paper.util.TickThread.isTickThreadFor(((ServerLevel) this.level),finalPosition)){
+ this.preventMoving = true; + this.preventMoving = true;
+ this.teleportAsync( + this.teleportAsync(
+ (ServerLevel) this.level(), + (ServerLevel) this.level(),
@@ -84,7 +73,7 @@ index 9bbfac91f97331b1b558264c867b7e00185291f2..dfb1b8c3af93bfcddb976c003c6ac2d5
+ this.preventMoving = false; + 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()); + MinecraftServer.LOGGER.warn("Entity {} with entityId {} has tried moving to another region!",this.type.getCategory().getName(),this.getId());
+ } + }
+ return; + return;

View File

@@ -0,0 +1,97 @@
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..4dcf71e9f861596bd02902d0851ffa57ff9e4170 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 (!io.papermc.paper.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..dd1baee4bc36b28b7e10d98525d55cbcfb562649 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
@@ -6,6 +6,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.GlobalPos;
import net.minecraft.core.Holder;
import net.minecraft.network.protocol.game.DebugPackets;
+import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.ai.behavior.declarative.BehaviorBuilder;
@@ -33,7 +34,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 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 (!io.papermc.paper.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 a26cc9b81d93f04cd741a2558f0787bb2037351e..c7860dca86e4a9251d81d98129347e1a59c09f04 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
@@ -82,7 +82,7 @@ public class PoiManager extends SectionStorage<PoiSection> {
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 ? io.papermc.paper.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;
});

View File

@@ -6,10 +6,10 @@ 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 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 new file mode 100644
index 0000000000000000000000000000000000000000..b8aceab54bb60000e7c56810140271022f5147a2 index 0000000000000000000000000000000000000000..8f1449545d6d217b46a9ffae705123daefe55b25
--- /dev/null --- /dev/null
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaTeleportAsyncFixConfig.java +++ 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; +package me.earthme.luminol.config.modules.fixes;
+ +
+import me.earthme.luminol.config.ConfigInfo; +import me.earthme.luminol.config.ConfigInfo;
@@ -17,7 +17,9 @@ index 0000000000000000000000000000000000000000..b8aceab54bb60000e7c5681014027102
+import me.earthme.luminol.config.IConfigModule; +import me.earthme.luminol.config.IConfigModule;
+ +
+public class FoliaTeleportAsyncFixConfig implements 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; + public static boolean enabled = false;
+ @ConfigInfo(baseName = "throw_on_detected") + @ConfigInfo(baseName = "throw_on_detected")
+ public static boolean throwOnDetected = true; + public static boolean throwOnDetected = true;
@@ -33,10 +35,10 @@ 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 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 25978b9c25096f252acd60a0924bac400d6026e7..922ce7627bd0d546802ec6b013056f7aa6acbf33 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/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 { @@ -331,6 +331,10 @@ public class ServerPlayer extends Player {
public double lastEntitySpawnRadiusSquared = -1.0; public double lastEntitySpawnRadiusSquared = -1.0;
// Paper end - optimise chunk tick iteration // Paper end - optimise chunk tick iteration
@@ -48,7 +50,7 @@ index 9cbf17436b4cf52aae374767aafe79ea4f60c3ce..f2068e7608ed765e35759eb981db6c95
super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile); super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile);
this.chatVisibility = ChatVisiblity.FULL; 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 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 e7b510dee355a9865bd67f5aea52c62957226eb3..e0f12426f18b343b27089440cd01127d79600ef0 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/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 @@ -675,7 +675,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -72,41 +74,17 @@ index 3b2508dc6cd4f70b09dce3b7e745e6efabaaa74e..b3ff8ed6d0f0414c15b9d2e6a51a0e34
// If the event is cancelled we move the player back to their old location. // If the event is cancelled we move the player back to their old location.
if (event.isCancelled()) { 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 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 cbf5bda50b87b8520ee6fa6d0b41c94b5c9f3583..ac4533f69e9bb22c7375ad8bc83ddc23399a56d7 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/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; @@ -3986,6 +3986,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
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
java.util.function.Consumer<Entity> teleportComplete) { java.util.function.Consumer<Entity> teleportComplete) {
io.papermc.paper.util.TickThread.ensureTickThread(this, "Cannot teleport entity async"); io.papermc.paper.util.TickThread.ensureTickThread(this, "Cannot teleport entity async");
+ //Luminol start - Prevent teleportAsync calling during moving event being handled + //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 (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!"); + 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); + MinecraftServer.LOGGER.warn("Player {} is trying to teleport to {} during move event handling!",player.getScoreboardName(),pos);
@@ -119,33 +97,16 @@ index dfb1b8c3af93bfcddb976c003c6ac2d52afc41c6..09cdd28dcb2357ba3d7be316b7ca94dc
return false; 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 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 d514ec1e4cbdc579c3a61533998437903afdc8b6..ed4cbc459bf5f4b7615c6e2ab0d99728d18f2598 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java --- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
+++ b/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; @@ -378,7 +378,21 @@ public abstract class AbstractMinecart extends VehicleEntity {
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 {
this.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle)); this.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
if (!from.equals(to)) { if (!from.equals(to)) {
+ //Luminol start - Prevent teleportAsync calling during moving event being handled + //Luminol start - Prevent teleportAsync calling during moving event being handled
+ for (Entity passenger : this.getPassengers()) { + for (Entity passenger : this.getPassengers()) {
+ if (passenger instanceof ServerPlayer player){ + if (passenger instanceof net.minecraft.server.level.ServerPlayer player){
+ player.handlingMoveEvent = true; + player.handlingMoveEvent = true;
+ } + }
+ } + }
@@ -153,7 +114,7 @@ index d514ec1e4cbdc579c3a61533998437903afdc8b6..c547376967360402d22657d25e110036
this.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to)); this.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to));
+ //Luminol start - Prevent teleportAsync calling during moving event being handled + //Luminol start - Prevent teleportAsync calling during moving event being handled
+ for (Entity passenger : this.getPassengers()) { + for (Entity passenger : this.getPassengers()) {
+ if (passenger instanceof ServerPlayer player){ + if (passenger instanceof net.minecraft.server.level.ServerPlayer player){
+ player.handlingMoveEvent = false; + player.handlingMoveEvent = false;
+ } + }
+ } + }
@@ -162,33 +123,16 @@ index d514ec1e4cbdc579c3a61533998437903afdc8b6..c547376967360402d22657d25e110036
// CraftBukkit end // CraftBukkit end
if (this.getMinecartType() == AbstractMinecart.Type.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) { 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 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 db6aa75d642f4a7258f197933671907faf79c8f2..065d4c06e3fd93fb46595b9864b150ea2480f5fc 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java --- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
+++ b/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; @@ -377,8 +377,22 @@ public class Boat extends VehicleEntity implements VariantHolder<Boat.Type> {
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> {
server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle)); server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
if (this.lastLocation != null && !this.lastLocation.equals(to)) { if (this.lastLocation != null && !this.lastLocation.equals(to)) {
+ //Luminol start - Prevent teleportAsync calling during moving event being handled + //Luminol start - Prevent teleportAsync calling during moving event being handled
+ for (Entity passenger : this.getPassengers()) { + for (Entity passenger : this.getPassengers()) {
+ if (passenger instanceof ServerPlayer player){ + if (passenger instanceof net.minecraft.server.level.ServerPlayer player){
+ player.handlingMoveEvent = true; + player.handlingMoveEvent = true;
+ } + }
+ } + }
@@ -197,7 +141,7 @@ index db6aa75d642f4a7258f197933671907faf79c8f2..b7c792f75dda1c62ee3730b8204c3478
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
+ //Luminol start - Prevent teleportAsync calling during moving event being handled + //Luminol start - Prevent teleportAsync calling during moving event being handled
+ for (Entity passenger : this.getPassengers()) { + for (Entity passenger : this.getPassengers()) {
+ if (passenger instanceof ServerPlayer player){ + if (passenger instanceof net.minecraft.server.level.ServerPlayer player){
+ player.handlingMoveEvent = false; + player.handlingMoveEvent = false;
+ } + }
+ } + }

View File

@@ -5,10 +5,10 @@ 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 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..28602455d659dfac4653ab5b7bf4139f65c190ad 100644
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java --- a/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
+++ b/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) { private boolean tryComputePath(Mob entity, WalkTarget walkTarget, long time) {
BlockPos blockPos = walkTarget.getTarget().currentBlockPosition(); BlockPos blockPos = walkTarget.getTarget().currentBlockPosition();

View File

@@ -5,10 +5,10 @@ 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 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 index ac4533f69e9bb22c7375ad8bc83ddc23399a56d7..2ff3216c3789fc4779bb18502cb288f57e370ea0 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/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 @@ -4193,12 +4193,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
targetPos, 16, // load 16 blocks to be safe from block physics targetPos, 16, // load 16 blocks to be safe from block physics
ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.HIGH, ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.HIGH,
(chunks) -> { (chunks) -> {
@@ -28,7 +28,7 @@ index 09cdd28dcb2357ba3d7be316b7ca94dc93ac5dd0..d955a555d260d39812b84eb5319db619
); );
} }
); );
@@ -4387,6 +4392,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @@ -4385,6 +4390,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
if (!this.canPortalAsync(takePassengers)) { if (!this.canPortalAsync(takePassengers)) {
return false; return false;
} }
@@ -39,7 +39,7 @@ index 09cdd28dcb2357ba3d7be316b7ca94dc93ac5dd0..d955a555d260d39812b84eb5319db619
Vec3 initialPosition = this.position(); Vec3 initialPosition = this.position();
ChunkPos initialPositionChunk = new ChunkPos( ChunkPos initialPositionChunk = new ChunkPos(
@@ -4445,7 +4454,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @@ -4443,7 +4452,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
// place // place
passengerTree.root.placeInAsync( passengerTree.root.placeInAsync(
originWorld, destination, Entity.TELEPORT_FLAG_LOAD_CHUNK | (takePassengers ? Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS : 0L), originWorld, destination, Entity.TELEPORT_FLAG_LOAD_CHUNK | (takePassengers ? Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS : 0L),

File diff suppressed because it is too large Load Diff

View File

@@ -33,10 +33,10 @@ 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 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 3228d15fc21fec08e8683f96c829935a1de6cf45..7433a29577ecb36e847bd610059c0c83702d01f6 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java --- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/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 { @@ -926,10 +926,11 @@ public abstract class Mob extends LivingEntity implements Targeting {
return; return;
} }
// Paper end - Allow nerfed mobs to jump and float // Paper end - Allow nerfed mobs to jump and float

View File

@@ -5,10 +5,10 @@ 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 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 index 2ff3216c3789fc4779bb18502cb288f57e370ea0..a19773b8721fb4011a48738977a162358b4dbcb5 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/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 @@ -309,7 +309,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
public double yo; public double yo;
public double zo; public double zo;
private Vec3 position; private Vec3 position;
@@ -18,7 +18,7 @@ index d955a555d260d39812b84eb5319db619ec0f8d28..7834646fd6a894ff85973566d9aeda98
private Vec3 deltaMovement; private Vec3 deltaMovement;
private float yRot; 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 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 b9f6e599afd4bdfb97e7f1b1881730cbed781bba..ff7b0d6a22a0858d4e4348d4f3c0c55bcb3f0084 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/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; @@ -143,7 +143,6 @@ import org.bukkit.event.entity.EntityTeleportEvent;
@@ -51,10 +51,10 @@ index fdb5ef574c14fafa1af50f4f656763119695f00e..bbfbeddcba884ae1964f7421fcdf1799
if (this.isSpectator()) { if (this.isSpectator()) {
return false; return false;
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
index f8718d91f4c15c74d6e6dd5f60f7f05f45f63655..50fafff765b2494c075784cc5342d086c8dc97b2 100644 index 4fc4690d03fd5f39e019f16845954052210c7361..c77beef9651aa2f7333d536e8ff4af3281834619 100644
--- a/src/main/java/org/spigotmc/ActivationRange.java --- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/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 ) if ( entity instanceof LivingEntity )
{ {
LivingEntity living = (LivingEntity) entity; LivingEntity living = (LivingEntity) entity;

View File

@@ -31,7 +31,7 @@ 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 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 ff7b0d6a22a0858d4e4348d4f3c0c55bcb3f0084..96039cd1c01cf6ea384f63bf5623de75e5def41f 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/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 { @@ -428,7 +428,7 @@ public abstract class LivingEntity extends Entity implements Attackable {

View File

@@ -5,15 +5,15 @@ 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 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 d2f0c3b26d4beedb49d86e0242d843590d469d02..c55fe31f3fc1c9ccb949c6bfb64e1bd6f37b8356 100644
--- a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java --- a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
+++ b/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) { if (this.range > 0.0) {
- double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0D; - double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0;
- double e = Math.max((this.useFollowRange ? this.getFollowRange(baseEntity) : this.range) * d, 2.0D); // Paper - Fix MC-145656 - 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 + // Pufferfish start - check range before getting visibility
+ // d = invisibility percent, e = follow range adjusted for invisibility, f = distance + // d = invisibility percent, e = follow range adjusted for invisibility, f = distance
double f = baseEntity.distanceToSqr(targetEntity.getX(), targetEntity.getY(), targetEntity.getZ()); double f = baseEntity.distanceToSqr(targetEntity.getX(), targetEntity.getY(), targetEntity.getZ());
@@ -23,8 +23,8 @@ index c8a80c1b2fedff22e8a877d466062375ffb2f0d7..3c4f4af85a3f2d4f9f52827164e63727
+ return false; + return false;
+ } + }
+ +
+ double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0D; + double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0;
+ double e = Math.max((followRangeRaw) * d, 2.0D); // Paper + double e = Math.max((followRangeRaw) * d, 2.0D); // Paper - Fix MC-145656
+ // Pufferfish end + // Pufferfish end
if (f > e * e) { if (f > e * e) {
return false; return false;

View File

@@ -5,12 +5,12 @@ 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 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 --- a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
+++ b/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 { @@ -121,6 +121,7 @@ public abstract class MoveToBlockGoal extends Goal {
for(int m = 0; m <= l; m = m > 0 ? -m : 1 - m) { 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) { for (int n = m < l && m > -l ? l : 0; n <= l; n = n > 0 ? -n : 1 - n) {
mutableBlockPos.setWithOffset(blockPos, m, k - 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.level().hasChunkAt(mutableBlockPos)) continue; // Pufferfish - if this block isn't loaded, continue
if (this.mob.isWithinRestriction(mutableBlockPos) && this.isValidTarget(this.mob.level(), mutableBlockPos)) { if (this.mob.isWithinRestriction(mutableBlockPos) && this.isValidTarget(this.mob.level(), mutableBlockPos)) {

View File

@@ -5,10 +5,10 @@ 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 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 index a19773b8721fb4011a48738977a162358b4dbcb5..ada744f8e594dbec516e2a66beaf6140e98d7510 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/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 @@ -5260,16 +5260,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
} }
public boolean updateFluidHeightAndDoFluidPushing(TagKey<Fluid> tag, double speed) { public boolean updateFluidHeightAndDoFluidPushing(TagKey<Fluid> tag, double speed) {
@@ -34,7 +34,7 @@ index 7834646fd6a894ff85973566d9aeda98e5b0c284..21284dba89c8adbb46086afd9a900fb2
double d1 = 0.0D; double d1 = 0.0D;
boolean flag = this.isPushedByFluid(); boolean flag = this.isPushedByFluid();
boolean flag1 = false; boolean flag1 = false;
@@ -5279,14 +5281,61 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @@ -5277,14 +5279,61 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
int k1 = 0; int k1 = 0;
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
@@ -102,7 +102,7 @@ index 7834646fd6a894ff85973566d9aeda98e5b0c284..21284dba89c8adbb46086afd9a900fb2
if (d2 >= axisalignedbb.minY) { if (d2 >= axisalignedbb.minY) {
flag1 = true; flag1 = true;
@@ -5308,9 +5357,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @@ -5306,9 +5355,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
// CraftBukkit end // CraftBukkit end
} }
} }

View File

@@ -5,21 +5,10 @@ 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 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 44fa2d4f90389f5526746bd94a2450c03340bd0b..3bbeb33eb51b6aea96e926af6715980e207b815e 100644
--- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java --- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java
+++ b/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; @@ -241,13 +241,25 @@ public class Bat extends AmbientCreature {
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 {
} }
} }
@@ -28,8 +17,8 @@ index 44fa2d4f90389f5526746bd94a2450c03340bd0b..864c3c72b6881a2a8223a9aa5a593f1a
+ private static final int ONE_HOUR = 20 * 60 * 60; + private static final int ONE_HOUR = 20 * 60 * 60;
+ private static int lastSpookyCheck = -ONE_HOUR; + private static int lastSpookyCheck = -ONE_HOUR;
private static boolean isHalloween() { private static boolean isHalloween() {
+ final ThreadedRegionizer.ThreadedRegion<TickRegions.TickRegionData, TickRegions.TickRegionSectionData> region = + final io.papermc.paper.threadedregions.ThreadedRegionizer.ThreadedRegion<io.papermc.paper.threadedregions.TickRegions.TickRegionData, io.papermc.paper.threadedregions.TickRegions.TickRegionSectionData> region =
+ TickRegionScheduler.getCurrentRegion(); + io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegion();
+ final long tickCount = region.getData().getCurrentTick(); + final long tickCount = region.getData().getCurrentTick();
+ if (tickCount - lastSpookyCheck > ONE_HOUR) { + if (tickCount - lastSpookyCheck > ONE_HOUR) {
LocalDate localdate = LocalDate.now(); LocalDate localdate = LocalDate.now();

View File

@@ -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 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 ada744f8e594dbec516e2a66beaf6140e98d7510..5c36b3c6bf38acfa3f38dcca4b666aca9665e7d4 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/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 @@ -812,6 +812,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
} }
public void tick() { public void tick() {

View File

@@ -33,19 +33,10 @@ 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 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 10d7c64fb3a9bafdcdae99f8dc87017722341337..079c0b34f28d57ce967715f809e737a67fa56d07 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
+++ b/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; @@ -45,6 +45,38 @@ public abstract class Projectile extends Entity implements TraceableEntity {
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 {
super(type, world); super(type, world);
} }
@@ -56,23 +47,25 @@ index 10d7c64fb3a9bafdcdae99f8dc87017722341337..c366da764e2e11018460430595c14b17
+ private int loadedLifetime = 0; + private int loadedLifetime = 0;
+ @Override + @Override
+ public void setPos(double x, double y, double z) { + public void setPos(double x, double y, double z) {
+ long currentTick = TickRegionScheduler.getCurrentRegion().getData().getCurrentTick(); + if (io.papermc.paper.util.TickThread.isTickThreadFor(this) && io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegion() != null){
+ if (loadedTick != currentTick) { + long currentTick = io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegion().getData().getCurrentTick();
+ loadedTick = currentTick; + if (loadedTick != currentTick) {
+ loadedThisTick = 0; + 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; + int previousX = Mth.floor(this.getX()) >> 4, previousZ = Mth.floor(this.getZ()) >> 4;
+ if (previousX != newX || previousZ != newZ) { + int newX = Mth.floor(x) >> 4, newZ = Mth.floor(z) >> 4;
+ boolean isLoaded = ((net.minecraft.server.level.ServerChunkCache) this.level().getChunkSource()).getChunkAtIfLoadedMainThread(newX, newZ) != null; + if ((previousX != newX || previousZ != newZ) && io.papermc.paper.util.TickThread.isTickThreadFor(((ServerLevel) this.level()), newX, newZ)) {
+ if (!isLoaded) { + boolean isLoaded = ((net.minecraft.server.level.ServerChunkCache) this.level().getChunkSource()).getChunkAtIfLoadedMainThread(newX, newZ) != null;
+ if (Projectile.loadedThisTick > me.earthme.luminol.config.modules.optimizations.ProjectileChunkReduceConfig.maxProjectileLoadsPerTick) { + if (!isLoaded) {
+ if (++this.loadedLifetime > me.earthme.luminol.config.modules.optimizations.ProjectileChunkReduceConfig.maxProjectileLoadsPerProjectile) { + if (Projectile.loadedThisTick > me.earthme.luminol.config.modules.optimizations.ProjectileChunkReduceConfig.maxProjectileLoadsPerTick) {
+ this.discard(); + if (++this.loadedLifetime > me.earthme.luminol.config.modules.optimizations.ProjectileChunkReduceConfig.maxProjectileLoadsPerProjectile) {
+ this.discard();
+ }
+ return;
+ } + }
+ return; + Projectile.loadedThisTick++;
+ } + }
+ Projectile.loadedThisTick++;
+ } + }
+ } + }
+ super.setPos(x, y, z); + super.setPos(x, y, z);

View File

@@ -71,7 +71,7 @@ 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 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 6439c6974f0292d105581456fcb5e27fdfbae6d6..2847d5c82f8f266ab552410e23168a7115c1e3ab 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/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 { @@ -987,6 +987,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -83,10 +83,10 @@ index da6269249a95d78f91e90416a96bf1b776fd9c97..25a2f23618cd02366f71e704638adfba
if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed
entity.discard(); entity.discard();
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java 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 5c36b3c6bf38acfa3f38dcca4b666aca9665e7d4..5b76c645214852f172c2a498751438090cc970ec 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/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 @@ -481,6 +481,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
// Folia - region ticking // Folia - region ticking
// Paper end - optimise entity tracking // Paper end - optimise entity tracking
@@ -111,7 +111,7 @@ index 8deae3e95a26f4b42b2c2134e22f9649bd7a5391..c09357c1ef84a29d972119cb496b0ae9
private String descriptionId; private String descriptionId;
@Nullable @Nullable
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java 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 7433a29577ecb36e847bd610059c0c83702d01f6..397c8ef1c83f0bf3c03d31ee19dbf1533dba9e48 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java --- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/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 { @@ -234,10 +234,10 @@ public abstract class Mob extends LivingEntity implements Targeting {
@@ -127,7 +127,7 @@ index b90865dbfb3a4bd83e4cd3ba3b5b965036039f98..66c581585e6ca58eba0e8b7af0fa1f0c
this.targetSelector.tick(); this.targetSelector.tick();
} }
} }
@@ -935,16 +935,20 @@ public abstract class Mob extends LivingEntity implements Targeting { @@ -934,16 +934,20 @@ public abstract class Mob extends LivingEntity implements Targeting {
if (i % 2 != 0 && this.tickCount > 1) { if (i % 2 != 0 && this.tickCount > 1) {
this.level().getProfiler().push("targetSelector"); this.level().getProfiler().push("targetSelector");
@@ -149,10 +149,10 @@ index b90865dbfb3a4bd83e4cd3ba3b5b965036039f98..66c581585e6ca58eba0e8b7af0fa1f0c
this.level().getProfiler().pop(); this.level().getProfiler().pop();
} }
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 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 38af5c7280366fd6ec077f3d914ea5f3ee77451a..f97b41422949bc6521b289daa6ca2861f25885a0 100644
--- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java --- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
+++ b/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 { @@ -52,9 +52,12 @@ public class GoalSelector {
} }
// Paper start // Paper start
@@ -200,11 +200,11 @@ index b21e180641d17438997a80e5bcb0ec7998d24a2e..33c160994f70f71446d665e748791343
this.level().getProfiler().pop(); this.level().getProfiler().pop();
this.level().getProfiler().push("axolotlActivityUpdate"); 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 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 a03fb7aa9f4528f4885db88eaf480202d5f54750..1767fd2df8cb37e9c36fa3008b5131ff4bdad12c 100644
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java --- a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
+++ b/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> { @@ -183,9 +183,11 @@ public class Frog extends Animal implements VariantHolder<FrogVariant> {
}
} }
+ private int behaviorTick = 0; // Pufferfish + private int behaviorTick = 0; // Pufferfish
@@ -248,11 +248,11 @@ index 5d247ac38fe8a61603b3d934f3000bcda773142b..2e4177cfb02616ef6fa689f6d378976e
this.level().getProfiler().pop(); this.level().getProfiler().pop();
this.level().getProfiler().push("goatActivityUpdate"); 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 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 050ffa4a23feba29fdf4c6a175cdff4e5009027d..1299f93d4f983e6715e447add65df91ef9e9090a 100644
--- a/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java --- a/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java
+++ b/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 { @@ -155,9 +155,11 @@ public class Hoglin extends Animal implements Enemy, HoglinBase {
return (Brain<Hoglin>) super.getBrain(); // Paper - decompile fix return (Brain<Hoglin>)super.getBrain();
} }
+ private int behaviorTick; // Pufferfish + private int behaviorTick; // Pufferfish
@@ -280,7 +280,7 @@ index a9813da7f2b248f98f22e0ad2e7842915025ec12..83d83e3f84bb6bd58761671c6cd4c868
this.level().getProfiler().pop(); this.level().getProfiler().pop();
PiglinAi.updateActivity(this); 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 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 937f81a859953498abe73bea560c86e6560e1c33..0a151c679b0dc943598180942d6d4b3886211688 100644
--- a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java --- a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
+++ b/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 { @@ -273,11 +273,13 @@ public class Warden extends Monster implements VibrationSystem {
@@ -332,7 +332,7 @@ index 3eeff0cd8563939c656b5ded8470cab016903f25..90d8cd94d987416a3e9f6e6d47a5b366
if (this.assignProfessionWhenSpawned) { if (this.assignProfessionWhenSpawned) {
this.assignProfessionWhenSpawned = false; this.assignProfessionWhenSpawned = false;
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
index 50fafff765b2494c075784cc5342d086c8dc97b2..78b495ffbb1ca753714304e2a18035bcfd84b918 100644 index c77beef9651aa2f7333d536e8ff4af3281834619..9628cc2b7f200e0bab4fed48997dde3e266200ee 100644
--- a/src/main/java/org/spigotmc/ActivationRange.java --- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java +++ b/src/main/java/org/spigotmc/ActivationRange.java
@@ -38,6 +38,10 @@ import co.aikar.timings.MinecraftTimings; @@ -38,6 +38,10 @@ import co.aikar.timings.MinecraftTimings;
@@ -346,7 +346,7 @@ index 50fafff765b2494c075784cc5342d086c8dc97b2..78b495ffbb1ca753714304e2a18035bc
public class ActivationRange public class ActivationRange
{ {
@@ -230,6 +234,25 @@ public class ActivationRange @@ -232,6 +236,25 @@ public class ActivationRange
} }
// Paper end - Configurable marker ticking // Paper end - Configurable marker ticking
ActivationRange.activateEntity(entity, bbByType); // Folia - threaded regions ActivationRange.activateEntity(entity, bbByType); // Folia - threaded regions
@@ -372,7 +372,7 @@ index 50fafff765b2494c075784cc5342d086c8dc97b2..78b495ffbb1ca753714304e2a18035bc
} }
// Paper end // Paper end
} }
@@ -246,12 +269,12 @@ public class ActivationRange @@ -248,12 +271,12 @@ public class ActivationRange
if ( io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick() > entity.activatedTick ) // Folia - threaded regions if ( io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick() > entity.activatedTick ) // Folia - threaded regions
{ {
if ( entity.defaultActivationState ) if ( entity.defaultActivationState )

View File

@@ -31,7 +31,7 @@ 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 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 397c8ef1c83f0bf3c03d31ee19dbf1533dba9e48..abbbd6b56af8a177cd8ebfc5aa34c3f7282bdc59 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java --- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/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 { @@ -230,11 +230,13 @@ public abstract class Mob extends LivingEntity implements Targeting {

View File

@@ -5,7 +5,7 @@ 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 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 index b99a080ab27e24d8131fda931ca70d6d271bb01c..8d6954d05d2bf6d6c1c4953db3127b011a858cec 100644
--- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java --- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
+++ b/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 { @@ -23,9 +23,11 @@ public class AttributeMap {
@@ -16,20 +16,18 @@ index 897d7632ecfea40890433474870dd7a5e534d8ab..683c9693754d1a87b7e8fccc757a0d09
public AttributeMap(AttributeSupplier defaultAttributes) { public AttributeMap(AttributeSupplier defaultAttributes) {
this.supplier = defaultAttributes; this.supplier = defaultAttributes;
+ this.createInstance = attribute -> this.supplier.createInstance(this::onAttributeModified, attribute); // Pufferfish + this.createInstance = attributex -> this.supplier.createInstance(this::onAttributeModified, attributex); // Pufferfish
} }
private void onAttributeModified(AttributeInstance instance) { private void onAttributeModified(AttributeInstance instance) {
@@ -45,11 +47,10 @@ public class AttributeMap { @@ -42,9 +44,10 @@ public class AttributeMap {
}).collect(Collectors.toList()); return this.attributes.values().stream().filter(attribute -> attribute.getAttribute().isClientSyncable()).collect(Collectors.toList());
} }
+ +
@Nullable @Nullable
public AttributeInstance getInstance(Attribute attribute) { public AttributeInstance getInstance(Attribute attribute) {
- return this.attributes.computeIfAbsent(attribute, (attributex) -> { - return this.attributes.computeIfAbsent(attribute, attributex -> this.supplier.createInstance(this::onAttributeModified, 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 + return this.attributes.computeIfAbsent(attribute, this.createInstance); // Pufferfish - cache lambda, as for some reason java allocates it anyways
} }

View File

@@ -459,12 +459,12 @@ index 82e7e76fecceb55522b5828a56f036e42ef55201..882e27de852c89c837d7943c5a9ae6fb
public static void entityInside(Level world, BlockPos pos, BlockState state, Entity entity, HopperBlockEntity blockEntity) { 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 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 index dfd1246b735fe64c5beae83567a013861eb00822..fa64bf5ad13c278438039b663ea3134e72108411 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java --- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
+++ b/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 @@ -94,12 +94,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
public boolean isEmpty() { public boolean isEmpty() {
this.unpackLootTable((Player)null); this.unpackLootTable(null);
// Paper start - Perf: Optimize Hoppers // Paper start - Perf: Optimize Hoppers
- for (final ItemStack itemStack : this.getItems()) { - for (final ItemStack itemStack : this.getItems()) {
- if (!itemStack.isEmpty()) { - if (!itemStack.isEmpty()) {

View File

@@ -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 diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
index 78b495ffbb1ca753714304e2a18035bcfd84b918..e9331fe4d524215bbab9a410d16e4f1811f5ad31 100644 index 9628cc2b7f200e0bab4fed48997dde3e266200ee..3a6ae320891f1e3202c59b63a5f2c96c18727314 100644
--- a/src/main/java/org/spigotmc/ActivationRange.java --- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java +++ b/src/main/java/org/spigotmc/ActivationRange.java
@@ -75,28 +75,41 @@ public class ActivationRange @@ -75,28 +75,41 @@ public class ActivationRange

View File

@@ -31,10 +31,10 @@ index 0000000000000000000000000000000000000000..ed62d25d6cd6dfcf8c5db20ced36eb3d
+ } + }
+} +}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java 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 index 5b76c645214852f172c2a498751438090cc970ec..62f997aae20fe392bc271b23b632441ce989c69c 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/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 @@ -5458,6 +5458,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
return this.feetBlockState; return this.feetBlockState;
} }
@@ -52,7 +52,7 @@ index 4b3acc0de20b246e20e2cc91ba0eca493a675729..2d78d28120af075bebee4d97428ed48c
return this.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 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 index 96039cd1c01cf6ea384f63bf5623de75e5def41f..e618ce4e71e4aef0620ac1b178f4df6a35deb87e 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/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 { @@ -2062,19 +2062,43 @@ public abstract class LivingEntity extends Entity implements Attackable {

View File

@@ -5,10 +5,10 @@ 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 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 62f997aae20fe392bc271b23b632441ce989c69c..485ca9a13a04ee47b27f1d23c6323583139865a1 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/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 @@ -308,7 +308,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
public double xo; public double xo;
public double yo; public double yo;
public double zo; public double zo;
@@ -17,7 +17,7 @@ index 2d78d28120af075bebee4d97428ed48cf27c9d78..a4682b8bd269f52af26a03347e8d3869
public BlockPos blockPosition; // Pufferfish - private->public public BlockPos blockPosition; // Pufferfish - private->public
private ChunkPos chunkPosition; private ChunkPos chunkPosition;
private Vec3 deltaMovement; private Vec3 deltaMovement;
@@ -2068,9 +2068,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @@ -2066,9 +2066,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
/** @deprecated */ /** @deprecated */
@Deprecated @Deprecated
public float getLightLevelDependentMagicValue() { public float getLightLevelDependentMagicValue() {
@@ -37,7 +37,7 @@ index 2d78d28120af075bebee4d97428ed48cf27c9d78..a4682b8bd269f52af26a03347e8d3869
this.absMoveTo(x, y, z); this.absMoveTo(x, y, z);
this.setYRot(yaw % 360.0F); this.setYRot(yaw % 360.0F);
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java 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 abbbd6b56af8a177cd8ebfc5aa34c3f7282bdc59..b3ab33fb1e77cd1f95e4669fc7c7c2a188e813ca 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java --- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/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 { @@ -1750,13 +1750,29 @@ public abstract class Mob extends LivingEntity implements Targeting {

View File

@@ -5,7 +5,7 @@ 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 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 index e618ce4e71e4aef0620ac1b178f4df6a35deb87e..2164413ca25dc6c1ae52e687f0786418ee4dda10 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/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 { @@ -597,11 +597,10 @@ public abstract class LivingEntity extends Entity implements Attackable {

View File

@@ -6,7 +6,7 @@ Subject: [PATCH] Gale Don't trigger lootable refresh for non-player
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 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 index fa64bf5ad13c278438039b663ea3134e72108411..cb3318c124337868f763b0e060f90e7eb3ba466d 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java --- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
+++ b/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 @@ -68,6 +68,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc

View File

@@ -133,10 +133,10 @@ index 49ccb27a17bec1d4ff31bc8d72e4724d65adc20c..34ccd489268c51c0aeecf5918878122b
public static long getBlockKey(final int x, final int y, final int z) { 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 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 28653d149bcbfa7bc37b8a09ae58229b908374f7..66192e92f18062f6bec377a43d6cfc5b277705a1 100644
--- a/src/main/java/net/minecraft/util/Mth.java --- a/src/main/java/net/minecraft/util/Mth.java
+++ b/src/main/java/net/minecraft/util/Mth.java +++ b/src/main/java/net/minecraft/util/Mth.java
@@ -56,13 +56,11 @@ public class Mth { @@ -57,13 +57,11 @@ public class Mth {
} }
public static int floor(float value) { public static int floor(float value) {
@@ -152,7 +152,7 @@ index 03854a2d26a3cfc1817acfdc28cbf151ba59e05b..d9e0224dc108a99c194d4947d18f2d85
} }
public static long lfloor(double value) { public static long lfloor(double value) {
@@ -79,13 +77,11 @@ public class Mth { @@ -80,13 +78,11 @@ public class Mth {
} }
public static int ceil(float value) { public static int ceil(float value) {
@@ -168,15 +168,15 @@ index 03854a2d26a3cfc1817acfdc28cbf151ba59e05b..d9e0224dc108a99c194d4947d18f2d85
} }
public static int clamp(int value, int min, int max) { public static int clamp(int value, int min, int max) {
@@ -121,15 +117,7 @@ public class Mth { @@ -122,15 +118,7 @@ public class Mth {
} }
public static double absMax(double a, double b) { public static double absMax(double a, double b) {
- if (a < 0.0D) { - if (a < 0.0) {
- a = -a; - a = -a;
- } - }
- -
- if (b < 0.0D) { - if (b < 0.0) {
- b = -b; - b = -b;
- } - }
- -

View File

@@ -5,10 +5,10 @@ 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 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 485ca9a13a04ee47b27f1d23c6323583139865a1..2072664329f68552f43db55dee283ba96951ac09 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/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 @@ -317,6 +317,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
public float yRotO; public float yRotO;
public float xRotO; public float xRotO;
private AABB bb; private AABB bb;
@@ -16,7 +16,7 @@ index a4682b8bd269f52af26a03347e8d3869d2b1ba41..d78ad18ac3b69c893a23b6bb9a6837b6
public boolean onGround; public boolean onGround;
public boolean horizontalCollision; public boolean horizontalCollision;
public boolean verticalCollision; public boolean verticalCollision;
@@ -1104,6 +1105,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @@ -1102,6 +1103,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
//Luminol end //Luminol end
public void move(MoverType movementType, Vec3 movement) { public void move(MoverType movementType, Vec3 movement) {
@@ -28,7 +28,7 @@ index a4682b8bd269f52af26a03347e8d3869d2b1ba41..d78ad18ac3b69c893a23b6bb9a6837b6
final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity
// Paper start - detailed watchdog information // Paper start - detailed watchdog information
io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main"); 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 @@ -4955,6 +4961,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
} }
public final void setBoundingBox(AABB boundingBox) { public final void setBoundingBox(AABB boundingBox) {

View File

@@ -106,7 +106,7 @@ index 0000000000000000000000000000000000000000..f2f10b651e4fbecdd1ea1bc28ebf40d6
+ +
+} +}
diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java 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 index 8c455cda45ca2d724fbc140d53ffc7ecba3ca44c..dd63a219caf36acc58b73190e67faf9a504aef20 100644
--- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java --- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java
+++ b/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; @@ -8,6 +8,7 @@ import java.util.concurrent.atomic.AtomicLong;

View File

@@ -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 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 --- a/src/main/java/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java
+++ b/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 { @@ -11,6 +11,27 @@ public final class ImprovedNoise {
@@ -34,9 +34,9 @@ index fb84d703b4461343d50510d7c9be32fc1f09ed22..93a11c95f96f975fafe03e77a2caace5
+ // Gale end - C2ME - optimize noise generation + // Gale end - C2ME - optimize noise generation
+ +
public ImprovedNoise(RandomSource random) { public ImprovedNoise(RandomSource random) {
this.xo = random.nextDouble() * 256.0D; this.xo = random.nextDouble() * 256.0;
this.yo = random.nextDouble() * 256.0D; this.yo = random.nextDouble() * 256.0;
@@ -40,12 +61,14 @@ public final class ImprovedNoise { @@ -38,12 +59,14 @@ public final class ImprovedNoise {
double d = x + this.xo; double d = x + this.xo;
double e = y + this.yo; double e = y + this.yo;
double f = z + this.zo; double f = z + this.zo;
@@ -55,16 +55,16 @@ index fb84d703b4461343d50510d7c9be32fc1f09ed22..93a11c95f96f975fafe03e77a2caace5
+ double l = f - k; + double l = f - k;
+ // Gale end - C2ME - optimize noise generation - optimize: remove frequent type conversions + // Gale end - C2ME - optimize noise generation - optimize: remove frequent type conversions
double o; double o;
if (yScale != 0.0D) { if (yScale != 0.0) {
double m; double m;
@@ -55,25 +78,27 @@ public final class ImprovedNoise { @@ -53,25 +76,27 @@ public final class ImprovedNoise {
m = h; 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 + o = Math.floor(m / yScale + (double)1.0E-7F) * yScale; // Gale - C2ME - optimize noise generation - optimize: remove frequent type conversions
} else { } else {
o = 0.0D; o = 0.0;
} }
- return this.sampleAndLerp(i, j, k, g, h - o, l, h); - 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) { 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) { 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 m = this.p(j + sectionY);
- int n = this.p(j + sectionY + 1); - int n = this.p(j + sectionY + 1);
- double d = gradDot(this.p(k + sectionZ), localX, localY, localZ); - double d = gradDot(this.p(k + sectionZ), localX, localY, localZ);
- double e = gradDot(this.p(m + sectionZ), localX - 1.0D, localY, localZ); - double e = gradDot(this.p(m + sectionZ), localX - 1.0, localY, localZ);
- double f = gradDot(this.p(l + sectionZ), localX, localY - 1.0D, localZ); - double f = gradDot(this.p(l + sectionZ), localX, localY - 1.0, localZ);
- double g = gradDot(this.p(n + sectionZ), localX - 1.0D, localY - 1.0D, 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.0D); - double h = gradDot(this.p(k + sectionZ + 1), localX, localY, localZ - 1.0);
- double o = gradDot(this.p(m + sectionZ + 1), localX - 1.0D, localY, localZ - 1.0D); - 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.0D, localZ - 1.0D); - 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.0D, localY - 1.0D, localZ - 1.0D); - double q = gradDot(this.p(n + sectionZ + 1), localX - 1.0, localY - 1.0, localZ - 1.0);
- double r = Mth.smoothstep(localX); - double r = Mth.smoothstep(localX);
- double s = Mth.smoothstep(fadeLocalY); - double s = Mth.smoothstep(fadeLocalY);
- double t = Mth.smoothstep(localZ); - 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) { 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 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 --- a/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinNoise.java
+++ b/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 { @@ -26,6 +26,10 @@ public class PerlinNoise {
@@ -195,12 +195,12 @@ index 97ef7288ea935f3d17c5b7a9eba642143c786c2b..6d084145f8529fa8b0439123f9a98129
+ private final double [] amplitudesArray; + private final double [] amplitudesArray;
+ // Gale end - C2ME - optimize noise generation + // Gale end - C2ME - optimize noise generation
/** @deprecated */
@Deprecated @Deprecated
@@ -131,6 +135,10 @@ public class PerlinNoise { public static PerlinNoise createLegacyForBlendedNoise(RandomSource random, IntStream octaves) {
this.lowestFreqInputFactor = Math.pow(2.0D, (double)(-j)); @@ -127,6 +131,10 @@ public class PerlinNoise {
this.lowestFreqValueFactor = Math.pow(2.0D, (double)(i - 1)) / (Math.pow(2.0D, (double)i) - 1.0D); this.lowestFreqInputFactor = Math.pow(2.0, (double)(-j));
this.maxValue = this.edgeValue(2.0D); 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 + // Gale start - C2ME - optimize noise generation
+ this.octaveSamplersCount = this.noiseLevels.length; + this.octaveSamplersCount = this.noiseLevels.length;
+ this.amplitudesArray = this.amplitudes.toDoubleArray(); + this.amplitudesArray = this.amplitudes.toDoubleArray();
@@ -208,11 +208,11 @@ index 97ef7288ea935f3d17c5b7a9eba642143c786c2b..6d084145f8529fa8b0439123f9a98129
} }
protected double maxValue() { 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) { 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 + // Gale start - C2ME - optimize noise generation - optimize for common cases
+ double d = 0.0; + double d = 0.0;
+ double e = this.lowestFreqInputFactor; + double e = this.lowestFreqInputFactor;
@@ -236,4 +236,4 @@ index 97ef7288ea935f3d17c5b7a9eba642143c786c2b..6d084145f8529fa8b0439123f9a98129
+ // Gale end - C2ME - optimize noise generation - optimize for common cases + // Gale end - C2ME - optimize noise generation - optimize for common cases
} }
/** @deprecated */ @Deprecated

View File

@@ -214,10 +214,10 @@ index 8bafd5fd7499ba4a04bf706cfd1e156073716e21..f62aab492f231e688b448389b1910e6f
+ <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 + <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
} }
diff --git a/src/main/java/net/minecraft/util/SimpleBitStorage.java b/src/main/java/net/minecraft/util/SimpleBitStorage.java 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 8d7d763bf51cac556057645e6169c9447993189b..c1e5f04df9529e9236a5c8a047b02ad560085025 100644
--- a/src/main/java/net/minecraft/util/SimpleBitStorage.java --- a/src/main/java/net/minecraft/util/SimpleBitStorage.java
+++ b/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 { @@ -389,4 +389,45 @@ public class SimpleBitStorage implements BitStorage {
super(message); super(message);
} }
} }
@@ -264,10 +264,10 @@ index 453c1d7e01970fd817d27f59c3b00ffc70e8ca0c..844539798213360831541f49d97f8401
+ +
} }
diff --git a/src/main/java/net/minecraft/util/ZeroBitStorage.java b/src/main/java/net/minecraft/util/ZeroBitStorage.java 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 01f5b946fabbe34f31110e75973dab9f39897346..1cd79ab7635d4a5e55538c1130f487245f45b4b6 100644
--- a/src/main/java/net/minecraft/util/ZeroBitStorage.java --- a/src/main/java/net/minecraft/util/ZeroBitStorage.java
+++ b/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 { @@ -71,4 +71,6 @@ public class ZeroBitStorage implements BitStorage {
public BitStorage copy() { public BitStorage copy() {
return this; return this;
} }
@@ -286,7 +286,7 @@ index acae3eb30e0689048937f479dc3070f0688abdad..4b79f0474a9013dd4fdb68c6363ca194
int onResize(int newBits, T object); 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 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 adfbdca12fbdee2602feb0158674166d5256e49e..9990e60f61d678e20cfffe22848eb5cc7c554b8a 100644
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java --- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
+++ b/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; @@ -25,6 +25,22 @@ import net.minecraft.util.ThreadingDetector;
@@ -310,9 +310,9 @@ index 983799520ce052d98c9231f4f7925492d4f7d5c9..6e7b3ea1819780aef6db3ff0b43998de
+ // Gale end - Lithium - faster chunk serialization + // Gale end - Lithium - faster chunk serialization
+ +
private static final int MIN_PALETTE_BITS = 0; private static final int MIN_PALETTE_BITS = 0;
private final PaletteResize<T> dummyPaletteResize = (newSize, added) -> { private final PaletteResize<T> dummyPaletteResize = (newSize, added) -> 0;
return 0; public final IdMap<T> registry;
@@ -302,30 +318,54 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer @@ -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 public synchronized PalettedContainerRO.PackedData<T> pack(IdMap<T> idList, PalettedContainer.Strategy paletteProvider) { // Paper - synchronize
this.acquire(); this.acquire();
@@ -325,9 +325,7 @@ index 983799520ce052d98c9231f4f7925492d4f7d5c9..6e7b3ea1819780aef6db3ff0b43998de
- int i = paletteProvider.size(); - int i = paletteProvider.size();
- int[] is = new int[i]; - int[] is = new int[i];
- this.data.storage.unpack(is); - this.data.storage.unpack(is);
- swapPalette(is, (id) -> { - swapPalette(is, id -> hashMapPalette.idFor(this.data.palette.valueFor(id)));
- return hashMapPalette.idFor(this.data.palette.valueFor(id));
- });
- int j = paletteProvider.calculateBitsForSerialization(idList, hashMapPalette.getSize()); - int j = paletteProvider.calculateBitsForSerialization(idList, hashMapPalette.getSize());
- Optional<LongStream> optional; - Optional<LongStream> optional;
- if (j != 0) { - if (j != 0) {
@@ -384,7 +382,7 @@ index 983799520ce052d98c9231f4f7925492d4f7d5c9..6e7b3ea1819780aef6db3ff0b43998de
} }
private static <T> void swapPalette(int[] is, IntUnaryOperator applier) { 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 @Override
public void count(PalettedContainer.CountConsumer<T> counter) { public void count(PalettedContainer.CountConsumer<T> counter) {
@@ -392,12 +390,8 @@ index 983799520ce052d98c9231f4f7925492d4f7d5c9..6e7b3ea1819780aef6db3ff0b43998de
- counter.accept(this.data.palette.valueFor(0), this.data.storage.getSize()); - counter.accept(this.data.palette.valueFor(0), this.data.storage.getSize());
- } else { - } else {
- Int2IntOpenHashMap int2IntOpenHashMap = new Int2IntOpenHashMap(); - Int2IntOpenHashMap int2IntOpenHashMap = new Int2IntOpenHashMap();
- this.data.storage.getAll((key) -> { - this.data.storage.getAll(key -> int2IntOpenHashMap.addTo(key, 1));
- int2IntOpenHashMap.addTo(key, 1); - int2IntOpenHashMap.int2IntEntrySet().forEach(entry -> counter.accept(this.data.palette.valueFor(entry.getIntKey()), entry.getIntValue()));
- });
- int2IntOpenHashMap.int2IntEntrySet().forEach((entry) -> {
- counter.accept(this.data.palette.valueFor(entry.getIntKey()), entry.getIntValue());
- });
+ // Gale start - Lithium - faster chunk serialization + // Gale start - Lithium - faster chunk serialization
+ int len = this.data.palette().getSize(); + int len = this.data.palette().getSize();
+ +
@@ -408,12 +402,8 @@ index 983799520ce052d98c9231f4f7925492d4f7d5c9..6e7b3ea1819780aef6db3ff0b43998de
+ counter.accept(this.data.palette.valueFor(0), this.data.storage.getSize()); + counter.accept(this.data.palette.valueFor(0), this.data.storage.getSize());
+ } else { + } else {
+ Int2IntOpenHashMap int2IntOpenHashMap = new Int2IntOpenHashMap(); + Int2IntOpenHashMap int2IntOpenHashMap = new Int2IntOpenHashMap();
+ this.data.storage.getAll((key) -> { + this.data.storage.getAll(key -> int2IntOpenHashMap.addTo(key, 1));
+ int2IntOpenHashMap.addTo(key, 1); + int2IntOpenHashMap.int2IntEntrySet().forEach(entry -> counter.accept(this.data.palette.valueFor(entry.getIntKey()), entry.getIntValue()));
+ });
+ int2IntOpenHashMap.int2IntEntrySet().forEach((entry) -> {
+ counter.accept(this.data.palette.valueFor(entry.getIntKey()), entry.getIntValue());
+ });
+ } + }
+ } + }
+ +

View File

@@ -1,21 +1,20 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <novau233@163.com> From: MrHua269 <novau233@163.com>
Date: Sat, 6 Apr 2024 05:14:57 +0000 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 EntityBasedExplosionDamageCalculator
diff --git a/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java b/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java 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 --- a/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java
+++ b/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 @Override
public Optional<Float> getBlockExplosionResistance(Explosion explosion, BlockGetter world, BlockPos pos, BlockState blockState, FluidState fluidState) { 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 super.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState)
- return this.source.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState, max); - .map(max -> this.source.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState, max));
- });
+ // Gale start - Lithium - reduce lambda and Optional allocation in EntityBasedExplosionDamageCalculator + // Gale start - Lithium - reduce lambda and Optional allocation in EntityBasedExplosionDamageCalculator
+ Optional<Float> optionalBlastResistance = super.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState); + Optional<Float> optionalBlastResistance = super.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState);
+ if (optionalBlastResistance.isPresent()) { + if (optionalBlastResistance.isPresent()) {

View File

@@ -5,10 +5,10 @@ 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 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 index f97b41422949bc6521b289daa6ca2861f25885a0..bcda232bb1c2490f14dd26aaca52afbc597ea9b7 100644
--- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java --- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
+++ b/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; @@ -14,6 +14,7 @@ import java.util.function.Supplier;
import java.util.stream.Stream; import java.util.stream.Stream;
import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.util.profiling.ProfilerFiller;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -16,7 +16,7 @@ index 0f53c206b4c0607e2cda5cfa4edeae5209e897bf..6313020a80cab0b8df8d775431d4aa06
public class GoalSelector { public class GoalSelector {
private static final Logger LOGGER = LogUtils.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
@@ -28,7 +29,7 @@ public class GoalSelector { @@ -29,7 +30,7 @@ public class GoalSelector {
} }
}; };
private final Map<Goal.Flag, WrappedGoal> lockedFlags = new EnumMap<>(Goal.Flag.class); private final Map<Goal.Flag, WrappedGoal> lockedFlags = new EnumMap<>(Goal.Flag.class);

View File

@@ -5,7 +5,7 @@ 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 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 index 8d6954d05d2bf6d6c1c4953db3127b011a858cec..0ddb031bfe8df351f1cf97d258f81558e4719dbf 100644
--- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java --- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
+++ b/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 @@ @@ -1,8 +1,6 @@

View File

@@ -5,7 +5,7 @@ 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 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 0e8023d7105ea9781482e26e75d35565c52bfcb7..e192ae7eb424613fbb5b54d226ece9121545d468 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/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 @@ -1408,7 +1408,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -18,7 +18,7 @@ index 76ad4d8bce1611ead6f1596b2ba78267e3718655..d1dc02b3e4f775c9bd79073a8e96243a
} }
// CraftBukkit end // CraftBukkit end
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java 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 b57980d4fa445f2aa71e4477459da833eade50e8..a68485e29466f26d1cb94cd827f5a5d9645b1e5c 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/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 { @@ -187,7 +187,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -30,7 +30,7 @@ index 26f70965b45fa3c344781b569a651a4668d0621d..49f207b7e06a3f939dc6c9b4a078f6db
private final Set<UUID> unlistedEntities = new HashSet<>(); // Paper - Add Listing API for Player private final Set<UUID> unlistedEntities = new HashSet<>(); // Paper - Add Listing API for Player
private static final WeakHashMap<Plugin, WeakReference<Plugin>> pluginWeakReferences = new WeakHashMap<>(); private static final WeakHashMap<Plugin, WeakReference<Plugin>> pluginWeakReferences = new WeakHashMap<>();
private int hash = 0; private int hash = 0;
@@ -2146,9 +2146,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -2148,9 +2148,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override @Override
public boolean canSee(org.bukkit.entity.Entity entity) { public boolean canSee(org.bukkit.entity.Entity entity) {

View File

@@ -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
}

View File

@@ -149,7 +149,7 @@ index 676a1499747b071515479130875157263d3a8352..e5ef298dc1df9cc42b3d349939a966b7
if (((List) object).size() >= i) { if (((List) object).size() >= i) {
return (List) object; return (List) object;
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 18b8651147dedcf80d9baf04e87fb25cfbf9b89f..e9a49eb00c64d864ebf4b24d6fe84aba7b2dbed8 100644 index 936f8663b23908ac5de2076401a5d508f88a0376..0e8e57c291539e50f61e8178fc355fa698248967 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -179,6 +179,14 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -179,6 +179,14 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@@ -168,10 +168,10 @@ index 18b8651147dedcf80d9baf04e87fb25cfbf9b89f..e9a49eb00c64d864ebf4b24d6fe84aba
super.channelActive(channelhandlercontext); super.channelActive(channelhandlercontext);
this.channel = channelhandlercontext.channel(); this.channel = channelhandlercontext.channel();
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index c924951c3dd7652ee446b40689ff9004546e972a..776f5ce5fac57bc7ccdfc4dbab87811bc33de87d 100644 index 90fa6634dd1e426ba2469d366b3226a077c10f0e..2ed097054d18919ad570a0fa990876285279f921 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1727,7 +1727,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1728,7 +1728,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
} }
private ServerStatus.Players buildPlayerStatus() { private ServerStatus.Players buildPlayerStatus() {
@@ -197,20 +197,33 @@ index 24e5993b281448734eb67c7a8439a349bbf9fd72..da840e40dbb0f0c8dab5fbb27e2cfe6a
AdvancementProgress advancementprogress = this.getOrStartProgress(advancement); AdvancementProgress advancementprogress = this.getOrStartProgress(advancement);
boolean flag1 = advancementprogress.isDone(); boolean flag1 = advancementprogress.isDone();
diff --git a/src/main/java/net/minecraft/server/commands/OpCommand.java b/src/main/java/net/minecraft/server/commands/OpCommand.java diff --git a/src/main/java/net/minecraft/server/commands/OpCommand.java b/src/main/java/net/minecraft/server/commands/OpCommand.java
index 2e2a7c2cf3081187da817479a9da3eb10f662a6d..ee616fe98c98a345872c1eadf41c78524d131b61 100644 index e7b444a10b244828827b3c66c53465206ea8e0ec..030601fdfde2232a933b2ad7022e9909db3a3783 100644
--- a/src/main/java/net/minecraft/server/commands/OpCommand.java --- a/src/main/java/net/minecraft/server/commands/OpCommand.java
+++ b/src/main/java/net/minecraft/server/commands/OpCommand.java +++ b/src/main/java/net/minecraft/server/commands/OpCommand.java
@@ -20,7 +20,7 @@ public class OpCommand { @@ -25,7 +25,7 @@ public class OpCommand {
return source.hasPermission(3); (context, builder) -> {
}).then(Commands.argument("targets", GameProfileArgument.gameProfile()).suggests((context, builder) -> { PlayerList playerList = context.getSource().getServer().getPlayerList();
PlayerList playerList = context.getSource().getServer().getPlayerList(); return SharedSuggestionProvider.suggest(
- return SharedSuggestionProvider.suggest(playerList.getPlayers().stream().filter((player) -> { - playerList.getPlayers()
+ return SharedSuggestionProvider.suggest(playerList.realPlayers.stream().filter((player) -> { // Leaves - only real player + playerList.realPlayers // Leaves - only real player
return !playerList.isOp(player.getGameProfile()); .stream()
}).map((player) -> { .filter(player -> !playerList.isOp(player.getGameProfile()))
return player.getGameProfile().getName(); .map(player -> player.getGameProfile().getName()),
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 922ce7627bd0d546802ec6b013056f7aa6acbf33..6357440e89ffddfc61de767e4a1bfdbbb9d854b3 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -197,7 +197,7 @@ public class ServerPlayer extends Player {
private static final int FLY_STAT_RECORDING_SPEED = 25;
public ServerGamePacketListenerImpl connection;
public final MinecraftServer server;
- public final ServerPlayerGameMode gameMode;
+ public ServerPlayerGameMode gameMode;
private final PlayerAdvancements advancements;
private final ServerStatsCounter stats;
private float lastRecordedHealthAndAbsorption = Float.MIN_VALUE;
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index b3ff8ed6d0f0414c15b9d2e6a51a0e34c361f92a..b6e078a10adbbf5c2061b4bf448836231818b768 100644 index e0f12426f18b343b27089440cd01127d79600ef0..fbe2372d871f8f2b53b04f7bddf3a5652f2eb394 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -297,7 +297,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @@ -297,7 +297,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -229,7 +242,7 @@ index b3ff8ed6d0f0414c15b9d2e6a51a0e34c361f92a..b6e078a10adbbf5c2061b4bf44883623
player.connection = this; player.connection = this;
player.getTextFilter().join(); player.getTextFilter().join();
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 0f172512085e9dfc0850451d2c6bbffb18221f8f..291f646febc3b40e91056f268433f09b584f2b29 100644 index 90be312057221a5a78066d89783c5e22008d797d..24f52fde099bac6f7c6a61cfc28a2b23437a116d 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java --- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -13,15 +13,7 @@ import java.net.SocketAddress; @@ -13,15 +13,7 @@ import java.net.SocketAddress;
@@ -329,7 +342,7 @@ index 0f172512085e9dfc0850451d2c6bbffb18221f8f..291f646febc3b40e91056f268433f09b
+ return; + return;
+ } + }
+ +
+ top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); // Leaves - protocol + // top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); // Leaves - protocol
+ +
+ final List<ServerPlayer> playersCopy = new ArrayList<>(this.players); + final List<ServerPlayer> playersCopy = new ArrayList<>(this.players);
+ final List<ServerPlayer> onlinePlayers = Lists.newArrayListWithExpectedSize(playersCopy.size() - 1); + final List<ServerPlayer> onlinePlayers = Lists.newArrayListWithExpectedSize(playersCopy.size() - 1);
@@ -399,7 +412,7 @@ index 0f172512085e9dfc0850451d2c6bbffb18221f8f..291f646febc3b40e91056f268433f09b
this.playersByName.put(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT), player); // Spigot this.playersByName.put(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT), player); // Spigot
this.playersByUUID.put(player.getUUID(), player); this.playersByUUID.put(player.getUUID(), player);
// this.broadcastAll(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(entityplayer))); // CraftBukkit - replaced with loop below // this.broadcastAll(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(entityplayer))); // CraftBukkit - replaced with loop below
@@ -473,6 +587,12 @@ public abstract class PlayerList { @@ -471,6 +585,12 @@ public abstract class PlayerList {
continue; continue;
} }
@@ -412,7 +425,7 @@ index 0f172512085e9dfc0850451d2c6bbffb18221f8f..291f646febc3b40e91056f268433f09b
onlinePlayers.add(entityplayer1); // Paper - Use single player info update packet on join onlinePlayers.add(entityplayer1); // Paper - Use single player info update packet on join
} }
// Paper start - Use single player info update packet on join // Paper start - Use single player info update packet on join
@@ -693,6 +813,54 @@ public abstract class PlayerList { @@ -691,6 +811,54 @@ public abstract class PlayerList {
} }
@@ -467,7 +480,7 @@ index 0f172512085e9dfc0850451d2c6bbffb18221f8f..291f646febc3b40e91056f268433f09b
public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer) { // CraftBukkit - return string // Paper - return Component public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer) { // CraftBukkit - return string // Paper - return Component
// Paper start - Fix kick event leave message not being sent // Paper start - Fix kick event leave message not being sent
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()))); 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())));
@@ -761,6 +929,7 @@ public abstract class PlayerList { @@ -758,6 +926,7 @@ public abstract class PlayerList {
// Folia - region threading - move to onDisconnect of common packet listener // Folia - region threading - move to onDisconnect of common packet listener
entityplayer.getAdvancements().stopListening(); entityplayer.getAdvancements().stopListening();
this.players.remove(entityplayer); this.players.remove(entityplayer);
@@ -476,7 +489,7 @@ index 0f172512085e9dfc0850451d2c6bbffb18221f8f..291f646febc3b40e91056f268433f09b
this.server.getCustomBossEvents().onPlayerDisconnect(entityplayer); this.server.getCustomBossEvents().onPlayerDisconnect(entityplayer);
UUID uuid = entityplayer.getUUID(); UUID uuid = entityplayer.getUUID();
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index dc223b536eadd2da6cf3c758a62d0ed81b5a7b3b..e0f49c7e941830236b92f6705cd2c4b96e943a96 100644 index c70eb23d9745bdbfcc340bb554cf0bf2db71f5de..469e175dc87e66ce73efcc04a68b19140cb7194f 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -308,6 +308,7 @@ public final class CraftServer implements Server { @@ -308,6 +308,7 @@ public final class CraftServer implements Server {
@@ -496,7 +509,7 @@ index dc223b536eadd2da6cf3c758a62d0ed81b5a7b3b..e0f49c7e941830236b92f6705cd2c4b9
@Override @Override
public CraftPlayer apply(ServerPlayer player) { public CraftPlayer apply(ServerPlayer player) {
return player.getBukkitEntity(); return player.getBukkitEntity();
@@ -3306,4 +3307,11 @@ public final class CraftServer implements Server { @@ -3304,4 +3305,11 @@ public final class CraftServer implements Server {
} }
// Paper end // Paper end
@@ -509,7 +522,7 @@ index dc223b536eadd2da6cf3c758a62d0ed81b5a7b3b..e0f49c7e941830236b92f6705cd2c4b9
+ // Leaves end - replay mod api + // Leaves end - replay mod api
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 73316307666674f9f6e7ddb964e2ec2583743c79..d15f24d91255664af4295fca8d5e237dce520201 100644 index 8c7e01972888df4ccbaccc4eebceeeb5ab357f4c..99956f506d543c2917746d5eb095598135251320 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -57,6 +57,8 @@ import org.bukkit.util.NumberConversions; @@ -57,6 +57,8 @@ import org.bukkit.util.NumberConversions;
@@ -531,10 +544,10 @@ index 73316307666674f9f6e7ddb964e2ec2583743c79..d15f24d91255664af4295fca8d5e237d
if (entity instanceof EnderDragonPart complexPart) { if (entity instanceof EnderDragonPart complexPart) {
if (complexPart.parentMob instanceof EnderDragon) { if (complexPart.parentMob instanceof EnderDragon) {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 49f207b7e06a3f939dc6c9b4a078f6db7b779618..aedf5ec139613a4ddf6cdb87cc52ae29eda323b2 100644 index a68485e29466f26d1cb94cd827f5a5d9645b1e5c..2a5e76b1cee25b05189bb75daad4ced939bbb343 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -2141,7 +2141,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -2143,7 +2143,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override @Override
public boolean canSee(Player player) { public boolean canSee(Player player) {
@@ -1358,7 +1371,7 @@ index 0000000000000000000000000000000000000000..852f2098d93d4437fe79af06e454d849
+} +}
diff --git a/src/main/java/top/leavesmc/leaves/replay/ServerPhotographer.java b/src/main/java/top/leavesmc/leaves/replay/ServerPhotographer.java diff --git a/src/main/java/top/leavesmc/leaves/replay/ServerPhotographer.java b/src/main/java/top/leavesmc/leaves/replay/ServerPhotographer.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..3941d297587e971c5bbd8f3303dbac755ab77d2c index 0000000000000000000000000000000000000000..438651c02b371f9f85cd97fe0fefb14d1858aaa0
--- /dev/null --- /dev/null
+++ b/src/main/java/top/leavesmc/leaves/replay/ServerPhotographer.java +++ b/src/main/java/top/leavesmc/leaves/replay/ServerPhotographer.java
@@ -0,0 +1,246 @@ @@ -0,0 +1,246 @@
@@ -1405,6 +1418,7 @@ index 0000000000000000000000000000000000000000..3941d297587e971c5bbd8f3303dbac75
+ +
+ private ServerPhotographer(MinecraftServer server, ServerLevel world, GameProfile profile) { + private ServerPhotographer(MinecraftServer server, ServerLevel world, GameProfile profile) {
+ super(server, world, profile, ClientInformation.createDefault()); + super(server, world, profile, ClientInformation.createDefault());
+ this.gameMode = new ServerPhotographerGameMode(this);
+ this.followPlayer = null; + this.followPlayer = null;
+ this.stats = new NullStatsCounter(server); + this.stats = new NullStatsCounter(server);
+ this.lastPos = this.position(); + this.lastPos = this.position();
@@ -1439,7 +1453,6 @@ index 0000000000000000000000000000000000000000..3941d297587e971c5bbd8f3303dbac75
+ +
+ photographer.recorder.start(); + photographer.recorder.start();
+ MinecraftServer.getServer().getPlayerList().placeNewPhotographer(photographer.recorder, photographer, world, state.loc); + MinecraftServer.getServer().getPlayerList().placeNewPhotographer(photographer.recorder, photographer, world, state.loc);
+ photographer.setGameMode(GameType.SPECTATOR);
+ photographer.serverLevel().chunkSource.move(photographer); + photographer.serverLevel().chunkSource.move(photographer);
+ photographer.setInvisible(true); + photographer.setInvisible(true);
+ photographers.add(photographer); + photographers.add(photographer);
@@ -1608,6 +1621,47 @@ index 0000000000000000000000000000000000000000..3941d297587e971c5bbd8f3303dbac75
+ } + }
+ } + }
+} +}
diff --git a/src/main/java/top/leavesmc/leaves/replay/ServerPhotographerGameMode.java b/src/main/java/top/leavesmc/leaves/replay/ServerPhotographerGameMode.java
new file mode 100644
index 0000000000000000000000000000000000000000..f8c4d248c7f9e0b42cd04e252a1281ceb3e3c4ce
--- /dev/null
+++ b/src/main/java/top/leavesmc/leaves/replay/ServerPhotographerGameMode.java
@@ -0,0 +1,34 @@
+package top.leavesmc.leaves.replay;
+
+ import net.kyori.adventure.text.Component;
+import net.minecraft.server.level.ServerPlayerGameMode;
+import net.minecraft.world.level.GameType;
+import org.bukkit.event.player.PlayerGameModeChangeEvent;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public class ServerPhotographerGameMode extends ServerPlayerGameMode {
+ public ServerPhotographerGameMode(ServerPhotographer photographer) {
+ super(photographer);
+ super.setGameModeForPlayer(GameType.SPECTATOR, null);
+ }
+
+ @Override
+ public boolean changeGameModeForPlayer(@NotNull GameType gameMode) {
+ return false;
+ }
+
+ @Nullable
+ @Override
+ public PlayerGameModeChangeEvent changeGameModeForPlayer(@NotNull GameType gameMode, PlayerGameModeChangeEvent.@NotNull Cause cause, @Nullable Component cancelMessage) {
+ return null;
+ }
+
+ @Override
+ protected void setGameModeForPlayer(@NotNull GameType gameMode, @Nullable GameType previousGameMode) {
+ }
+
+ @Override
+ public void tick() {
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/top/leavesmc/leaves/util/UUIDSerializer.java b/src/main/java/top/leavesmc/leaves/util/UUIDSerializer.java diff --git a/src/main/java/top/leavesmc/leaves/util/UUIDSerializer.java b/src/main/java/top/leavesmc/leaves/util/UUIDSerializer.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..1329a725a2bd03d3ef6d7131d8bc77f20bf2e566 index 0000000000000000000000000000000000000000..1329a725a2bd03d3ef6d7131d8bc77f20bf2e566

View File

@@ -5,23 +5,15 @@ Subject: [PATCH] Fix-MC-172047
diff --git a/src/main/java/net/minecraft/world/entity/animal/Wolf.java b/src/main/java/net/minecraft/world/entity/animal/Wolf.java diff --git a/src/main/java/net/minecraft/world/entity/animal/Wolf.java b/src/main/java/net/minecraft/world/entity/animal/Wolf.java
index 2d20b2c1f58beb1ad8c9012d8124e476899e6be6..4e06908ed9759abb61a5ef5abf774874d231a83e 100644 index 2d20b2c1f58beb1ad8c9012d8124e476899e6be6..8f7f53a355a5db5f32cae511484c1cf4b15e37e3 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Wolf.java --- a/src/main/java/net/minecraft/world/entity/animal/Wolf.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Wolf.java +++ b/src/main/java/net/minecraft/world/entity/animal/Wolf.java
@@ -52,6 +52,7 @@ import net.minecraft.world.entity.ai.goal.target.OwnerHurtTargetGoal; @@ -529,13 +529,34 @@ public class Wolf extends TamableAnimal implements NeutralMob {
import net.minecraft.world.entity.ai.goal.target.ResetUniversalAngerTargetGoal;
import net.minecraft.world.entity.animal.horse.AbstractHorse;
import net.minecraft.world.entity.animal.horse.Llama;
+import net.minecraft.world.entity.decoration.ArmorStand;
import net.minecraft.world.entity.monster.AbstractSkeleton;
import net.minecraft.world.entity.monster.Creeper;
import net.minecraft.world.entity.monster.Ghast;
@@ -529,13 +530,34 @@ public class Wolf extends TamableAnimal implements NeutralMob {
@Override @Override
public boolean wantsToAttack(LivingEntity target, LivingEntity owner) { public boolean wantsToAttack(LivingEntity target, LivingEntity owner) {
- if (!(target instanceof Creeper) && !(target instanceof Ghast)) { - if (!(target instanceof Creeper) && !(target instanceof Ghast)) {
+ if (!(target instanceof Creeper) && !(target instanceof Ghast) && !(target instanceof ArmorStand)) { // Luminol - Fix MC-172047 + if (!(target instanceof Creeper) && !(target instanceof Ghast) && !(target instanceof net.minecraft.world.entity.decoration.ArmorStand)) { // Luminol - Fix MC-172047
if (target instanceof Wolf) { if (target instanceof Wolf) {
Wolf entitywolf = (Wolf) target; Wolf entitywolf = (Wolf) target;

View File

@@ -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));
+ }
+}

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Fix-MC-2025
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index d78ad18ac3b69c893a23b6bb9a6837b6a82ebdc2..8f40db062159dea7761a5663edef997a113e828b 100644 index 2072664329f68552f43db55dee283ba96951ac09..82ffe6571b06a482296fb28e37aa148daf6a0ce6 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2551,6 +2551,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @@ -2549,6 +2549,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
nbttagcompound.putBoolean("Paper.FreezeLock", true); nbttagcompound.putBoolean("Paper.FreezeLock", true);
} }
// Paper end // Paper end
@@ -25,7 +25,7 @@ index d78ad18ac3b69c893a23b6bb9a6837b6a82ebdc2..8f40db062159dea7761a5663edef997a
return nbttagcompound; return nbttagcompound;
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
@@ -2628,6 +2638,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @@ -2626,6 +2636,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
this.reapplyPosition(); this.reapplyPosition();
} }

View File

@@ -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);
+ }
+ }
+}

View File

@@ -0,0 +1,466 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <novau233@163.com>
Date: Sat, 27 Apr 2024 12:36:55 +0000
Subject: [PATCH] KioCG Chunk API
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/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 2ed097054d18919ad570a0fa990876285279f921..37e7e88fa75dda6c2b59ed610ec3ae2136c653a5 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1655,6 +1655,17 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
// Folia end - 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 = region.world.getCurrentWorldData().getChunks().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
@@ -1664,6 +1675,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 = region.world.getCurrentWorldData().getChunks().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 2847d5c82f8f266ab552410e23168a7115c1e3ab..3ab3e61879e5b2ab93fae9ace79deec9305b0df9 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1542,6 +1542,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
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.sectionX,entity.sectionZ) : null; // KioCG
+ if (levelChunk != null) levelChunk.getChunkHot().startTicking(); try { // KioCG
// Folia end - timer
try {
// Paper end - timings
@@ -1569,6 +1571,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
} 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()) {
@@ -1597,6 +1600,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
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();
@@ -1637,6 +1642,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
}
} 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 6357440e89ffddfc61de767e4a1bfdbbb9d854b3..c25261e2c5313aedeae813b5f439a5b29a0ffcbb 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -335,6 +335,25 @@ public class ServerPlayer extends Player {
public boolean handlingMoveEvent = false;
//Luminol end
+ // KioCG start - ChunkHot
+ private long nearbyChunkHot = 0;
+
+ public long getNearbyChunkHot() { return this.nearbyChunkHot; }
+
+ private long refreshNearbyChunkHot() {
+ long total = 0L;
+ for (int i = this.sectionX - 4; i <= this.sectionX + 4; ++i) {
+ for (int j = this.sectionZ - 4; j <= this.sectionZ + 4; ++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;
@@ -873,6 +892,12 @@ public class ServerPlayer extends Player {
this.trackStartFallingPosition();
this.trackEnteredOrExitedLavaOnVehicle();
this.advancements.flushDirty(this);
+
+ // KioCG start - ChunkHot
+ if (this.tickCount % 20 == 0){
+ this.nearbyChunkHot = this.refreshNearbyChunkHot();
+ }
+ // KioCG end
}
public void doTick() {
diff --git a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
index 094ab43e5a209ea848bf0994db9018281c64e08d..e2084013770e78d006ddd9547f6c9040aceb22c9 100644
--- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
+++ b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
@@ -498,4 +498,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 82ffe6571b06a482296fb28e37aa148daf6a0ce6..9293fb2dec97e6c6bf5abe5eb7d1878bb7f200d1 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -5898,4 +5898,6 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
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 0a8a53710c693a220e9475f6f3112b91d8209c00..5053852c72b68db41a2f51a72fffa1f8fe09b8da 100644
--- a/src/main/java/net/minecraft/world/entity/LightningBolt.java
+++ b/src/main/java/net/minecraft/world/entity/LightningBolt.java
@@ -287,4 +287,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 b3ab33fb1e77cd1f95e4669fc7c7c2a188e813ca..4c26749515f7d4508f749caf4ae90607131bed4e 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -1831,4 +1831,11 @@ public abstract class Mob extends LivingEntity implements Targeting {
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 038de19633002e8f7c4b1ead7438cef0163456ce..c33da6894f81cc9c6641885969532633fb845594 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 8d1cc1a644415be251f469ab1cb2ebc09fe5c3eb..32b128e4ea8fdeb55ba568f8af09abf9e80f7c42 100644
--- a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
+++ b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
@@ -327,4 +327,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 579eb5a81281ca36c145153d8c24a517242ffe18..a758081a3058bee62721a0b73adbce511dcebe51 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -2426,4 +2426,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 d44510a3b70b97b13b87a8e0868fdc699b70b75b..2430e5c15be02c75d0e7de3af4118846da122554 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
@@ -353,4 +353,11 @@ public abstract class Projectile extends Entity implements TraceableEntity {
public boolean mayBreak(Level world) {
return this.getType().is(EntityTypeTags.IMPACT_PROJECTILES) && world.getGameRules().getBoolean(GameRules.RULE_PROJECTILESCANBREAKBLOCKS);
}
+
+ // 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 8c6ade7cf14e367d6390849ef1b2a1bfef0d52ac..a484970c122fb190155e15109781b17155f9a499 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 {
private final LevelChunkTicks<Block> blockTicks;
private final LevelChunkTicks<Fluid> fluidTicks;
public volatile FullChunkStatus chunkStatus = FullChunkStatus.INACCESSIBLE; // Paper - rewrite chunk system
+ 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);
@@ -762,6 +763,7 @@ public class LevelChunk extends ChunkAccess {
}
public void onChunkNotTicking(io.papermc.paper.chunk.system.scheduling.NewChunkHolder chunkHolder) {
+ this.chunkHot.clear(); // KioCG
io.papermc.paper.chunk.system.ChunkSystem.onChunkNotTicking(this, chunkHolder.vanillaChunkHolder);
}
@@ -1188,6 +1190,7 @@ public class LevelChunk extends ChunkAccess {
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);
@@ -1218,6 +1221,7 @@ public class LevelChunk extends ChunkAccess {
} 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 19faa8f5f891c1ffbed0af8391dee8202433c447..a3503375133e5ed14dc7092bd403f2266fffa628 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.neighborChanged(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 dca5f25cf331b5550e9be491b4e8a3466531e021..0dee50f136b81f788f84beeb1ad8720007736517 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
@@ -22,13 +22,7 @@ import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.LightLayer;
import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.level.block.Blocks;
-import net.minecraft.world.level.chunk.ChunkAccess;
-import net.minecraft.world.level.chunk.ChunkStatus;
-import net.minecraft.world.level.chunk.DataLayer;
-import net.minecraft.world.level.chunk.ImposterProtoChunk;
-import net.minecraft.world.level.chunk.LevelChunkSection;
-import net.minecraft.world.level.chunk.PalettedContainer;
-import net.minecraft.world.level.chunk.PalettedContainerRO;
+import net.minecraft.world.level.chunk.*;
import net.minecraft.world.level.chunk.storage.ChunkSerializer;
import net.minecraft.world.level.chunk.storage.EntityStorage;
import net.minecraft.world.level.entity.PersistentEntitySectionManager;
@@ -428,4 +422,12 @@ public class CraftChunk implements Chunk {
static {
Arrays.fill(FULL_LIGHT, (byte) 0xFF);
}
+
+ // KioCG start - ChunkHot
+ @Override
+ public long getChunkHotAvg() {
+ final 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 2a5e76b1cee25b05189bb75daad4ced939bbb343..51caaac770b063a4be432b06030e325047651e91 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -3481,4 +3481,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void setSendViewDistance(final int viewDistance) {
this.getHandle().setSendViewDistance(viewDistance);
}
+
+ // KioCG start - ChunkHot
+ @Override
+ public long getNearbyChunkHot() {
+ return this.getHandle().getNearbyChunkHot();
+ }
+ // KioCG end
}
diff --git a/src/main/java/top/leavesmc/leaves/entity/CraftPhotographer.java b/src/main/java/top/leavesmc/leaves/entity/CraftPhotographer.java
index 4f58b6623a6b5c726d718ced6ab106af3e665e35..3941f2d37bca6482e5db2d2fbe248f0faa8133ce 100644
--- a/src/main/java/top/leavesmc/leaves/entity/CraftPhotographer.java
+++ b/src/main/java/top/leavesmc/leaves/entity/CraftPhotographer.java
@@ -70,4 +70,11 @@ public class CraftPhotographer extends CraftPlayer implements Photographer {
public String toString() {
return "CraftPhotographer{" + "name=" + getName() + '}';
}
+
+ // KioCG start - ChunkHot
+ @Override
+ public long getNearbyChunkHot() {
+ return this.getHandle().getNearbyChunkHot();
+ }
+ // KioCG end
}

View File

@@ -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;
}

View File

@@ -0,0 +1,72 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <novau233@163.com>
Date: Tue, 30 Apr 2024 14:02:39 +0000
Subject: [PATCH] Added chunkhot to tpsbar
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 3f1478dde900d671c4bfa43df80f629519cd602e..7abde30d420ff66026d1dee017c41bc23df22b26 100644
--- a/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java
+++ b/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java
@@ -139,7 +139,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)));
@@ -181,6 +182,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));

View File

@@ -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;
+ }
+ }
+}

View File

@@ -0,0 +1,46 @@
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] 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..5adefc33c501baf967adeaa4741373507eb0946d 100644
--- a/src/main/java/net/minecraft/world/entity/player/ProfilePublicKey.java
+++ b/src/main/java/net/minecraft/world/entity/player/ProfilePublicKey.java
@@ -23,7 +23,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 ((!me.earthme.luminol.config.modules.misc.PublickeyVerifyConfig.enabled || org.bukkit.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);

View File

@@ -0,0 +1,32 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <wangxyper@163.com>
Date: Fri, 12 Jul 2024 21:52:54 +0800
Subject: [PATCH] Fix linear java compile
diff --git a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
index 4938d86f62071f578822684f576b838296d4070f..654eaae20ccddd6d6ffa6f431472e28ffb44ae0c 100644
--- a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
+++ b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
@@ -118,9 +118,9 @@ public class WorldUpgrader {
// LinearPurpur start
String worldName = this.levelStorage.getLevelId();
- org.purpurmc.purpur.region.RegionFileFormat formatName = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().purpurConfig.regionFormatName;
- int linearCompression = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().purpurConfig.regionFormatLinearCompressionLevel;
- boolean linearCrashOnBrokenSymlink = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().purpurConfig.linearCrashOnBrokenSymlink;
+ org.purpurmc.purpur.region.RegionFileFormat formatName = me.earthme.luminol.config.modules.misc.RegionFormatConfig.regionFormatType;
+ int linearCompression = me.earthme.luminol.config.modules.misc.RegionFormatConfig.linearCompressionLevel;
+ boolean linearCrashOnBrokenSymlink = me.earthme.luminol.config.modules.misc.RegionFormatConfig.linearCrashOnBrokenSymlink;
builder1.put(resourcekey1, new ChunkStorage(formatName, linearCompression, linearCrashOnBrokenSymlink, path.resolve("region"), this.dataFixer, true));
// LinearPurpur end
}
@@ -268,7 +268,7 @@ public class WorldUpgrader {
try {
// LinearPurpur start
String worldName = this.levelStorage.getLevelId();
- int linearCompression = ((org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(worldName)).getHandle().purpurConfig.regionFormatLinearCompressionLevel;
+ int linearCompression = me.earthme.luminol.config.modules.misc.RegionFormatConfig.linearCompressionLevel;
org.purpurmc.purpur.region.AbstractRegionFile regionfile = org.purpurmc.purpur.region.AbstractRegionFileFactory.getAbstractRegionFile(linearCompression, file2.toPath(), file1.toPath(), true);
// LinearPurpur end

View File

@@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <wangxyper@163.com>
Date: Fri, 12 Jul 2024 21:53:03 +0800
Subject: [PATCH] Fix membar java compile
diff --git a/src/main/java/me/earthme/luminol/functions/GlobalServerMemoryBar.java b/src/main/java/me/earthme/luminol/functions/GlobalServerMemoryBar.java
index a33a45194273cc1b4e4157a5449c7994968a3480..e7b37460587ec5b0b1b24e164713a7e19da9e40e 100644
--- a/src/main/java/me/earthme/luminol/functions/GlobalServerMemoryBar.java
+++ b/src/main/java/me/earthme/luminol/functions/GlobalServerMemoryBar.java
@@ -174,7 +174,7 @@ public class GlobalServerMemoryBar {
}
if (memPercent <= 50){
- return BossBar.Color.valueOf(MembarConfig.memColors.getFirst());
+ return BossBar.Color.valueOf(MembarConfig.memColors.get(0));
}
if (memPercent <= 70){

View File

@@ -0,0 +1,44 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: bridge <ctibeheerder@gmail.com>
Date: Fri, 23 Aug 2024 22:44:57 +0200
Subject: [PATCH] Fix Concurrency issue in ServerEntity#sendDirtyEntityData()
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
index 16373e0c5ea38199fab3eb289bf2a5fcf0dd7439..da03bd8fc88a4bbc756e6335ef0adc15ee6eb97e 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -3,13 +3,8 @@ package net.minecraft.server.level;
import com.google.common.collect.Lists;
import com.mojang.datafixers.util.Pair;
import com.mojang.logging.LogUtils;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
+
+import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Stream;
import javax.annotation.Nullable;
@@ -392,7 +387,7 @@ public class ServerEntity {
}
if (this.entity instanceof LivingEntity) {
- Set<AttributeInstance> set = ((LivingEntity) this.entity).getAttributes().getDirtyAttributes();
+ Set<AttributeInstance> set = new HashSet<>(((LivingEntity) this.entity).getAttributes().getDirtyAttributes());
if (!set.isEmpty()) {
// CraftBukkit start - Send scaled max health
@@ -403,7 +398,7 @@ public class ServerEntity {
this.broadcastAndSend(new ClientboundUpdateAttributesPacket(this.entity.getId(), set));
}
- set.clear();
+ ((LivingEntity) this.entity).getAttributes().getDirtyAttributes().clear();
}
}

View File

@@ -0,0 +1,46 @@
sha256() {
sha256sum $1 | awk '{print $1}'
}
prop() {
grep "^[[:space:]]*${1}" gradle.properties | cut -d'=' -f2 | sed 's/^[[:space:]]*//; s/\r//'
}
mcversion_group=$(prop GroupMCV)
mcversion=$(prop mcVersion)
pre=$(prop preVersion)
pro_id_mcv=$project_id-$mcversion
if [ $pre = "true" ]; then
channel="experimental"
else
channel="default"
fi
changes=$(git log -1 --pretty="[{\"commit\": \"%H\", \"message\": \"%s\", \"summary\": \"%s\"}]")
jar_sha256=`sha256 build/libs/$pro_id_mcv-paperclip.jar`
jar_name="$pro_id_mcv-paperclip.jar"
ctime=$(date -u +"%s")"000"
# v2
json=$(printf "{\\\"channel\\\":\\\"%s\\\", \\\"jar_name\\\":\\\"%s\\\", \\\"sha256\\\":\\\"%s\\\", \\\"tag\\\":\\\"%s\\\", \\\"time\\\":\\\"%s\\\", \\\"changes\\\":\\\"%s\\\"}" \
"$channel" "$jar_name" "$jar_sha256" "$tag" "$ctime" "$changes")
echo "[DEBUG] $json"
echo "[DEBUG] $changes"
echo "[DEBUG] curl --location --request POST \"https://api.luminolmc.com/v2/projects/$project_id/$mcversion/build/commit\" \
-H \"Content-Type: application/x-www-form-urlencoded\" \
-H \"Authorization: $secret_v2\" \
--data-urlencode \"channel=$channel\" \
--data-urlencode \"jar_name=$jar_name\" \
--data-urlencode \"sha256=$jar_sha256\" \
--data-urlencode \"release_tag=$tag\" \
--data-urlencode \"time=$ctime\" \
--data-urlencode \"changes=$changes\""
curl -L --request POST "https://api.luminolmc.com/v2/projects/$project_id/$mcversion/build/commit" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Authorization: $secret_v2" \
--data-urlencode "channel=$channel" \
--data-urlencode "jar_name=$jar_name" \
--data-urlencode "sha256=$jar_sha256" \
--data-urlencode "release_tag=$tag" \
--data-urlencode "time=$ctime" \
--data-urlencode "changes=$changes"

29
scripts/SetENV.sh Normal file
View File

@@ -0,0 +1,29 @@
prop() {
grep "^[[:space:]]*${1}" gradle.properties | cut -d'=' -f2 | sed 's/^[[:space:]]*//; s/\r//'
}
project_id="luminol"
project_id_b="Luminol"
commitid=$(git log --pretty='%h' -1)
mcversion=$(prop mcVersion)
grdversion=$(prop version)
preVersion=$(prop preVersion)
release_tag="$mcversion-$commitid"
jarName="$project_id-$mcversion-paperclip.jar"
jarName_dir="build/libs/$jarName"
make_latest=$([ $preVersion = "true" ] && echo "false" || echo "true")
mv build/libs/$project_id-paperclip-$grdversion-reobf.jar build/libs/$jarName
mv build/libs/$project_id-bundler-$grdversion-reobf.jar build/libs/$project_id-$mcversion-bundler.jar
echo "project_id=$project_id" >> $GITHUB_ENV
echo "project_id_b=$project_id_b" >> $GITHUB_ENV
echo "commit_id=$commitid" >> $GITHUB_ENV
echo "commit_msg=$(git log --pretty='> [%h] %s' -1)" >> $GITHUB_ENV
echo "mcversion=$mcversion" >> $GITHUB_ENV
echo "pre=$preVersion" >> $GITHUB_ENV
echo "tag=$release_tag" >> $GITHUB_ENV
echo "jar=$jarName" >> $GITHUB_ENV
echo "jar_dir=$jarName_dir" >> $GITHUB_ENV
echo "make_latest=$make_latest" >> $GITHUB_ENV

View File

@@ -9,7 +9,7 @@ pluginManagement {
rootProject.name = "luminol" rootProject.name = "luminol"
for (name in listOf("Luminol-API", "Luminol-Server")) { for (name in listOf("Luminol-API", "Luminol-Server")) {
val projName = name.toLowerCase(Locale.ENGLISH) val projName = name.lowercase(Locale.ENGLISH)
include(projName) include(projName)
findProject(":$projName")!!.projectDir = file(name) findProject(":$projName")!!.projectDir = file(name)
} }