Compare commits
41 Commits
1.20.4-798
...
ver/1.20.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
365639d7db | ||
|
|
5257a5ccc9 | ||
|
|
a1fffec02a | ||
|
|
79a21ab81a | ||
|
|
d577729ca2 | ||
|
|
b41225df65 | ||
|
|
3a473302d0 | ||
|
|
a1df619285 | ||
|
|
a4ba907b33 | ||
|
|
aa5acdd1b5 | ||
|
|
f9b62e717e | ||
|
|
7d04bb5038 | ||
|
|
0e70acaa9c | ||
|
|
0872f03352 | ||
|
|
f5550b8cc1 | ||
|
|
909b208b67 | ||
|
|
b159640ebe | ||
|
|
76aa79aa3c | ||
|
|
f2d8696e94 | ||
|
|
31e86623e1 | ||
|
|
a290a8d6a0 | ||
|
|
31a559f1d9 | ||
|
|
be9ff6c4ce | ||
|
|
51ad682270 | ||
|
|
b396452d5f | ||
|
|
7d5174c23d | ||
|
|
09d5da9bbb | ||
|
|
a3ed860ba1 | ||
|
|
cee866c80f | ||
|
|
ad71c13e4b | ||
|
|
a03519f434 | ||
|
|
6470c6124d | ||
|
|
df20d94756 | ||
|
|
65378b9e26 | ||
|
|
c252b863d5 | ||
|
|
54fd31cb6c | ||
|
|
7465ab1daf | ||
|
|
4f43e7845c | ||
|
|
5e62e78720 | ||
|
|
1d4276694e | ||
|
|
3bca6a9846 |
@@ -5,13 +5,13 @@
|
||||
# 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
|
||||
name: LuminolCI - Ver/1.20.2
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "ver/1.20.4" ]
|
||||
branches: [ "ver/1.20.2" ]
|
||||
pull_request:
|
||||
branches: [ "ver/1.20.4" ]
|
||||
branches: [ "ver/1.20.2" ]
|
||||
|
||||
permissions: write-all
|
||||
|
||||
@@ -51,13 +51,13 @@ jobs:
|
||||
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
|
||||
./gradlew publish
|
||||
- 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
|
||||
run: mv build/libs/Luminol-paperclip-1.20.2-R0.1-SNAPSHOT-reobf.jar build/libs/luminol-1.20.2-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 }}"
|
||||
release_name: "Luminol MC1.20.2 - ${{ github.event.repository.updated_at}}"
|
||||
tag: "1.20.2-${{ github.run_id }}"
|
||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
file: "build/libs/luminol-1.20.4-paperclip.jar"
|
||||
file: "build/libs/luminol-1.20.2-paperclip.jar"
|
||||
file_glob: true
|
||||
prerelease: true
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -55,4 +55,4 @@ build-data/
|
||||
Hearse-API
|
||||
Hearse-Server
|
||||
*.jar
|
||||
/patches2/todo/
|
||||
/patches/todo/
|
||||
51
README.md
51
README.md
@@ -1,7 +1,10 @@
|
||||
<img src="./public/image/Luminol_5.png" alt="Logo" align="right" width="250">
|
||||
|
||||
# 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>
|
||||
|
||||
**English** | [中文](./README_CN.md)
|
||||
|
||||
[](LICENSE)
|
||||
[](https://github.com/LuminolMC/Luminol/issues)
|
||||
@@ -9,66 +12,36 @@
|
||||

|
||||

|
||||
|
||||
**English** | [中文](./README_CN.md)
|
||||
|
||||
## Features
|
||||
- Configurable vanilla features
|
||||
- Tpsbar support
|
||||
- Linear region file format(from kaiiju)
|
||||
- Useful optimizations to improve the performance of single threaded region
|
||||
- More API support for plugin development (W.I.P)
|
||||
- Configurable vanilla features
|
||||
- Tpsbar support
|
||||
- Linear region file format(from kaiiju)
|
||||
- Useful optimizations to improve the performance of single threaded region
|
||||
- More API support for plugin development (W.I.P)
|
||||
|
||||
## Download
|
||||
Any versions are available in the [release](https://github.com/LuminolMC/Luminol/releases), also you can build it by yourself through [the following steps](https://github.com/LuminolMC/Luminol#build).
|
||||
Any versions are available in the [release](https://github.com/LuminolMC/Luminol/releases), also you can build it by yourself through the following steps.
|
||||
|
||||
## Build
|
||||
To build a paperclip jar, you need to run the following command. You can find the jar in build/libs(Note: JDK17 is needed)
|
||||
|
||||
```shell
|
||||
./gradlew applyPatches && ./gradlew createReobfPaperclipJar
|
||||
```
|
||||
|
||||
## Using API
|
||||
For gradle:
|
||||
|
||||
```kotlin
|
||||
dependencies {
|
||||
compileOnly("me.earthme.luminol:luminol-api:1.20.4-R0.1-SNAPSHOT")
|
||||
compileOnly("me.earthme.luminol:luminol-api:1.20.2-R0.1-SNAPSHOT")
|
||||
}
|
||||
```
|
||||
|
||||
For maven
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>me.earthme.luminol</groupId>
|
||||
<artifactId>luminol-api</artifactId>
|
||||
<version>1.20.4-R0.1-SNAPSHOT</version>
|
||||
<version>1.20.2-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
## Contact
|
||||
> If you are interested in this project or have any issue, feel free to ask us.
|
||||
|
||||
QQ Group: `368632360` | QQ Channel: [Click To Join](https://pd.qq.com/s/eq9krf9j)
|
||||
|
||||
## Notice
|
||||
**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
|
||||
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>
|
||||
|
||||
## Pull Requests
|
||||
See [Contributing](./docs/CONTRIBUTING.md)
|
||||
|
||||
## BStats
|
||||

|
||||
|
||||
## Please ⭐star us!
|
||||
<a href="https://star-history.com/#LuminolMC/Luminol&LuminolMC/LightingLuminol&Date">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=LuminolMC/Luminol%2CLuminolMC/LightingLuminol&type=Date&theme=dark" />
|
||||
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=LuminolMC/Luminol%2CLuminolMC/LightingLuminol&type=Date" />
|
||||
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=LuminolMC/Luminol%2CLuminolMC/LightingLuminol&type=Date" />
|
||||
</picture>
|
||||
</a>
|
||||
|
||||
121
README_CN.md
121
README_CN.md
@@ -1,73 +1,48 @@
|
||||
<img src="./public/image/Luminol_5.png" alt="Logo" align="right" width="250">
|
||||
|
||||
# Luminol
|
||||
<h4>Luminol 是一个基于Folia的分支,具有许多有用的优化、可配置的原版特性和更多的API支持,它专为生存和无政府服务器设计</h4>
|
||||
|
||||
[](LICENSE)
|
||||
[](https://github.com/LuminolMC/Luminol/issues)
|
||||

|
||||

|
||||

|
||||
|
||||
[English](./README.md) | **中文**
|
||||
|
||||
## 特性
|
||||
- 可配置的原版特性
|
||||
- Tpsbar 支持
|
||||
- 线性区域文件格式 (from kaiiju)
|
||||
- 对单线程区域性能的优化
|
||||
- 更多的插件开发API支持(进行中)
|
||||
|
||||
## 下载
|
||||
任何版本都可以在 [Release](https://github.com/LuminolMC/Luminol/releases) 中找到,你也可以通过[以下步骤](./README_CN.md#构建)自己构建。
|
||||
|
||||
## 构建
|
||||
要构建一个paperclip jar,你需要运行以下命令。你可以在build/libs中找到jar(注意:需要`JDK17`)
|
||||
|
||||
```shell
|
||||
./gradlew applyPatches && ./gradlew createReobfPaperclipJar
|
||||
```
|
||||
|
||||
## 使用API
|
||||
使用 Gradle:
|
||||
|
||||
```kotlin
|
||||
dependencies {
|
||||
compileOnly("me.earthme.luminol:luminol-api:1.20.4-R0.1-SNAPSHOT")
|
||||
}
|
||||
```
|
||||
|
||||
使用 Maven
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>me.earthme.luminol</groupId>
|
||||
<artifactId>luminol-api</artifactId>
|
||||
<version>1.20.4-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
## 联系方式
|
||||
> 如果您对这个项目感兴趣或有任何问题,请随时向我们提问。
|
||||
|
||||
QQ群:`368632360` | QQ频道:[点击加入](https://pd.qq.com/s/eq9krf9j)
|
||||
|
||||
## 关于 Issue
|
||||
当您遇到任何问题时,请向我们提问,我们将尽力解决,但请记得清楚地描述您的问题并提供足够的日志等信息。
|
||||
|
||||
## 贡献代码
|
||||
可[查看 Contributing](./docs/CONTRIBUTING_cn.md)
|
||||
|
||||
## BStats
|
||||

|
||||
|
||||
## 请给我们一个 ⭐Star!
|
||||
> 你的每一个免费的 ⭐Star 就是我们每一个前进的动力。
|
||||
|
||||
<a href="https://star-history.com/#LuminolMC/Luminol&LuminolMC/LightingLuminol&Date">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=LuminolMC/Luminol%2CLuminolMC/LightingLuminol&type=Date&theme=dark" />
|
||||
<source media="(prefers-color-scheme: light)" srcset="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>
|
||||
</a>
|
||||
<img src="./public/image/Luminol_5.png" alt="Logo" align="right" width="250">
|
||||
|
||||
# Luminol
|
||||
|
||||
<h4>Luminol 是一个基于folia的分支,具有许多有用的优化、可配置的原版特性和更多的API支持,它专为生存和无政府服务器设计</h4>
|
||||
|
||||
[English](./README.md) | **中文**
|
||||
|
||||
[](LICENSE)
|
||||
[](https://github.com/LuminolMC/Luminol/issues)
|
||||

|
||||

|
||||

|
||||
|
||||
## 特性
|
||||
- 可配置的原版特性
|
||||
- Tpsbar 支持
|
||||
- 线性区域文件格式 (from kaiiju)
|
||||
- 对单线程区域性能的优化
|
||||
- 更多的插件开发API支持(进行中)
|
||||
|
||||
## 下载
|
||||
任何版本都可以在 [release](https://github.com/LuminolMC/Luminol/releases), 中找到,您也可以通过以下步骤自己构建。
|
||||
|
||||
## 构建
|
||||
要构建一个paperclip jar,你需要运行以下命令。你可以在build/libs中找到jar(注意:需要JDK17)
|
||||
```shell
|
||||
./gradlew applyPatches && ./gradlew createReobfPaperclipJar
|
||||
```
|
||||
## 使用API
|
||||
使用 Gradle:
|
||||
```kotlin
|
||||
dependencies {
|
||||
compileOnly("me.earthme.luminol:luminol-api:1.20.2-R0.1-SNAPSHOT")
|
||||
}
|
||||
```
|
||||
使用 Maven
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>me.earthme.luminol</groupId>
|
||||
<artifactId>luminol-api</artifactId>
|
||||
<version>1.20.2-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
## BStats
|
||||

|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import io.papermc.paperweight.util.constants.*
|
||||
|
||||
plugins {
|
||||
java
|
||||
`maven-publish`
|
||||
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.9"
|
||||
}
|
||||
|
||||
val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
|
||||
@@ -89,12 +91,43 @@ paperweight {
|
||||
serverPatchDir.set(layout.projectDirectory.dir("patches/server"))
|
||||
serverOutputDir.set(layout.projectDirectory.dir("Luminol-Server"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
patchTasks.register("generatedApi") {
|
||||
isBareDirectory = true
|
||||
upstreamDirPath = "paper-api-generator/generated"
|
||||
patchDir = layout.projectDirectory.dir("patches/generatedApi")
|
||||
outputDir = layout.projectDirectory.dir("paper-api-generator/generated")
|
||||
allprojects {
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
name = "githubPackage"
|
||||
url = uri("https://maven.pkg.github.com/LuminolMC/Luminol")
|
||||
|
||||
credentials.username = System.getenv("GITHUB_USERNAME")
|
||||
credentials.password = System.getenv("GITHUB_TOKEN")
|
||||
}
|
||||
|
||||
maven {
|
||||
name = "moliaMavenRepo"
|
||||
url = uri("https://maven.nostal.ink/repository/maven-snapshots/")
|
||||
|
||||
credentials.username = System.getenv("MAVEN_REPO_USER")
|
||||
credentials.password = System.getenv("MAVEN_REPO_PASSWORD")
|
||||
}
|
||||
|
||||
publications {
|
||||
register<MavenPublication>("gpr") {
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
if (project.hasProperty("publishDevBundle")) {
|
||||
publications.create<MavenPublication>("devBundle") {
|
||||
artifact(tasks.generateDevelopmentBundle) {
|
||||
artifactId = "dev-bundle"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
Contributing to Luminol
|
||||
===========
|
||||
|
||||
**English** | [中文](./CONTRIBUTING_cn.md)
|
||||
|
||||
We're glad that you want to contribute to our project!
|
||||
In general, our review of pull requests is very lenient.
|
||||
And if you can follow the rules below, we can complete the review faster.
|
||||
|
||||
## Please fork using your personal account
|
||||
|
||||
We regularly merge existing PRs.
|
||||
If there're some small problems, we'll help you solve them by editing your PR.
|
||||
|
||||
But, if your PR is from a organization, we can NOT edit your PR, so we must merge your PR manually.
|
||||
|
||||
So, don't use orgnization accounts for fork!
|
||||
|
||||
See also [This issue](https://github.com/isaacs/github/issues/1681), and then you'll know why we can't edit PRs from organizations.
|
||||
|
||||
## Development Environment
|
||||
|
||||
Before coding, you need these softwares / tools as Dev Environment.
|
||||
|
||||
- `git`
|
||||
- `JDK 17 or higher`
|
||||
|
||||
## Understanding "Patches"
|
||||
|
||||
Luminol uses as the same patching system as Paper,
|
||||
and has been divided into two directories for the purpose of modifying different parts of it:
|
||||
|
||||
- `luminol-api` - Modifications to `Folia-API` / `Paper-API` / `Spigot-API` / `Bukkit`.
|
||||
|
||||
The patching system is based on git, and you can learn about it at here: <https://git-scm.com/docs/gittutorial>
|
||||
|
||||
If you have forked the main repository, then you should follow the steps below:
|
||||
|
||||
1. Clone your repository to local
|
||||
2. Run Gradle's `applyPatches` task in your IDE or terminal (You can run `./gradlew applyPatches` directly in terminal.)
|
||||
3. Enter `luminol-api` directory to carry out modifications.
|
||||
|
||||
BTW, `luminol-api` and are not normal git repositories.
|
||||
|
||||
- Before applying patches, the base will point to unmodified source code.
|
||||
- Every commit after the base is a patch.
|
||||
- Only commits after the last commit of Paper will be considered Luminol' patches.
|
||||
|
||||
## Adding new patches
|
||||
|
||||
It's very easy to to add patches by following the steps below:
|
||||
|
||||
1. Modify the code of `luminol-api`
|
||||
2. Add these changes to the local git repository (For example, `git add .`)
|
||||
3. Commit these changes using `git commit -m <Commit Message>`
|
||||
4. Run Gradle's task `rebuildPatches` to convert your commits to a new patch
|
||||
5. Push your patches to your repository
|
||||
|
||||
After pushing, you can open a PR to submit your patches.
|
||||
|
||||
## Modifying patches
|
||||
|
||||
You can modify a existing patch by following the steps below:
|
||||
|
||||
1. Modify code at HEAD
|
||||
2. Run `git commit -a --fixup <hash>` in your terminal to make a fix-up commit
|
||||
- If you want to edit the commit message, replace `--fixup` with `--squash`.
|
||||
3. Run `git rebase -i --autosquash base` to rebase automatically, then just type `:q` to close the confirm page
|
||||
4. Run Gradle's task `rebuildPatches` to modify existing patches
|
||||
5. Push and PR again
|
||||
@@ -1,67 +0,0 @@
|
||||
为Luminol贡献代码
|
||||
===========
|
||||
|
||||
[English](./CONTRIBUTING.md) | **中文**
|
||||
|
||||
我们很开心您想为我们的项目做出贡献!一般来说,我们对PR的审核是十分宽松的;
|
||||
但是如果您可以遵守下列的规则,我们可以更快地完成审核。
|
||||
|
||||
## 使用个人账户进行 Fork
|
||||
|
||||
我们会定期尝试合并已有的 PR,如果有一些小问题,会尝试帮您解决这些问题。
|
||||
|
||||
但是如果您使用了组织账号进行 PR,我们就不能对您的 PR 进行修改了。因此我们只能关闭你的PR然后进行手动合并。
|
||||
|
||||
所以,请不要使用组织账号进行 Fork!
|
||||
|
||||
您可以看看 [这个 Issue](https://github.com/isaacs/github/issues/1681) 来了解一下我们为什么无法修改组织账号的 PR。
|
||||
|
||||
## 开发环境
|
||||
|
||||
在开始开发之前,您首先需要拥有以下软件作为开发环境:
|
||||
|
||||
- `git`
|
||||
- `JDK 17 或更高版本`
|
||||
|
||||
## 了解补丁(Patches)
|
||||
|
||||
Luminol 使用和 Folia 一样的补丁系统,并为了针对不同部分的修改分成了两个目录:
|
||||
|
||||
- `luminol-api` - 对 `Folia-API` / `Paper-API` / `Spigot-API` / `Bukkit` 进行的修改。
|
||||
|
||||
补丁系统是基于 git 的,你可以在这里了解 git 的基本内容: <https://git-scm.com/docs/gittutorial>
|
||||
|
||||
如果你已经 Fork 了主储存库,那么下面你应该这么做:
|
||||
|
||||
1. 将你的仓库 clone 到本地;
|
||||
2. 在你的 IDE 或 终端 内执行 Gradle 的 `applyPatches` 任务,如果是在终端内,你可以执行 `./gradlew applyPatches`;
|
||||
3. 进入 `luminol-api` 文件夹进行修改。
|
||||
|
||||
顺便一提,`luminol-api` 并不是正常的 git 仓库:
|
||||
|
||||
- 在应用补丁前,基点将会指向未被更改的源码
|
||||
- 在基点后的每一个提交都是一个补丁
|
||||
- 只有在 Folia 最后一个提交后的提交才会被视为 luminol 补丁
|
||||
|
||||
## 增加补丁
|
||||
|
||||
按照以下步骤增加一个补丁是非常简单的:
|
||||
|
||||
1. 对 `luminol-api` 进行修改;
|
||||
2. 使用 git 添加你的修改,比如 `git add .`;
|
||||
3. 使用 `git commit -m <提交信息>` 进行提交;
|
||||
4. 运行 Gradle 任务 `rebuildPatches` 将你的提交转化为一个补丁;
|
||||
5. 将你生成的补丁文件进行推送。
|
||||
|
||||
这样做以后,你就可以将你的补丁文件进行 PR 提交。
|
||||
|
||||
## 修改补丁
|
||||
|
||||
你可以使用以下方法来修改一个补丁的内容:
|
||||
|
||||
1. 在 HEAD 上直接进行修改;
|
||||
2. 使用 `git commit -a --fixup <hash>` 来进行一个更正提交;
|
||||
- 如果你想要更改提交信息,你也可以用 `--squash` 来代替 `--fixup`。
|
||||
3. 使用 `git rebase -i --autosquash base` 来进行自动变基,你只需要输入 `:q` 来关闭确认页面即可;
|
||||
4. 运行 Gradle 任务 `rebuildPatches` 来修改已被修改的补丁;
|
||||
5. 将修改后的补丁 PR 发回储存库。
|
||||
@@ -1,7 +1,7 @@
|
||||
group = me.earthme.luminol
|
||||
version = 1.20.4-R0.1-SNAPSHOT
|
||||
version = 1.20.2-R0.1-SNAPSHOT
|
||||
|
||||
foliaCommit = e22501a8e39b8f234bfbedbe0560b6f8f425a818
|
||||
foliaCommit = 1e5e2154c9f88d788cecf0b9fcc77ece7d1f8663
|
||||
|
||||
org.gradle.caching = true
|
||||
org.gradle.parallel = true
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 24 Dec 2023 12:11:45 +0800
|
||||
Date: Sun, 26 Nov 2023 18:04:47 +0800
|
||||
Subject: [PATCH] Added maven publish
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 3e3ea0e4e4ceb3283ad2b99957e3795d66a9a716..0f1846c506cbe25cdd37b8f4b7fd9f7aef2bf0b9 100644
|
||||
index 639651972fddce4dff63a0f0a7e566a15b9e2dd6..890820cb36e4cadeadb4c2d7cd961a73b065a217 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -199,3 +199,23 @@ tasks.check {
|
||||
dependsOn(scanJarForOldGeneratedCode)
|
||||
@@ -168,3 +168,23 @@ tasks.check {
|
||||
dependsOn(scanJar)
|
||||
}
|
||||
// Paper end
|
||||
+
|
||||
|
||||
506
patches/api/0002-Leaves-fakeplayer-API.patch
Normal file
506
patches/api/0002-Leaves-fakeplayer-API.patch
Normal file
@@ -0,0 +1,506 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Tue, 30 Jan 2024 09:03:08 +0000
|
||||
Subject: [PATCH] Leaves fakeplayer API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||
index b7e1c8bd8dd38e1a9e74925740b22dad61a75f49..5ee1ba3847599ac67b5cd8ca26e61b1231c45dcd 100644
|
||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||
@@ -58,6 +58,7 @@ import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import io.papermc.paper.util.JarManifests; // Paper
|
||||
+import top.leavesmc.leaves.entity.BotManager;
|
||||
|
||||
/**
|
||||
* Represents the Bukkit core, for version and Server singleton handling
|
||||
@@ -2836,6 +2837,17 @@ public final class Bukkit {
|
||||
}
|
||||
// Folia end - region threading API
|
||||
|
||||
+ // Leaves start - Bot API
|
||||
+ /**
|
||||
+ * Returns a bot manager.
|
||||
+ *
|
||||
+ * @return Bot Manager
|
||||
+ */
|
||||
+ public static @NotNull BotManager getBotManager() {
|
||||
+ return server.getBotManager();
|
||||
+ }
|
||||
+ // Leaves end - Bot API
|
||||
+
|
||||
@NotNull
|
||||
public static Server.Spigot spigot() {
|
||||
return server.spigot();
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index 85b169c04f44431363d4e14d4857140f160ceace..9e12552aca127892d122a2616d303d3cdfc67416 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -58,6 +58,7 @@ import org.bukkit.util.CachedServerIcon;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
+import top.leavesmc.leaves.entity.BotManager;
|
||||
|
||||
/**
|
||||
* Represents a server implementation.
|
||||
@@ -2479,4 +2480,14 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
*/
|
||||
public boolean isGlobalTickThread();
|
||||
// Folia end - region threading API
|
||||
+
|
||||
+
|
||||
+ // Leaves start - Bot API
|
||||
+ /**
|
||||
+ * Returns a bot manager.
|
||||
+ *
|
||||
+ * @return Bot Manager
|
||||
+ */
|
||||
+ @NotNull BotManager getBotManager();
|
||||
+ // Leaves end - Bot API
|
||||
}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/entity/Bot.java b/src/main/java/top/leavesmc/leaves/entity/Bot.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..8816683c795f9be6a4f112203cfac3f59d8faba5
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/entity/Bot.java
|
||||
@@ -0,0 +1,46 @@
|
||||
+package top.leavesmc.leaves.entity;
|
||||
+
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+import top.leavesmc.leaves.entity.botaction.LeavesBotAction;
|
||||
+
|
||||
+/**
|
||||
+ * Represents a fakeplayer
|
||||
+ */
|
||||
+public interface Bot extends Player {
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the fakeplayer skin
|
||||
+ *
|
||||
+ * @return fakeplayer skin name
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public String getSkinName();
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the fakeplayer name without prefix and suffix
|
||||
+ *
|
||||
+ * @return fakeplayer real name
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public String getRealName();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the fakeplayer action with args.
|
||||
+ *
|
||||
+ * @param action action name
|
||||
+ * @param player player who create this action
|
||||
+ * @param args passed action arguments
|
||||
+ */
|
||||
+ public boolean setBotAction(@NotNull String action, @NotNull Player player, @NotNull String[] args);
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the fakeplayer action with args.
|
||||
+ *
|
||||
+ * @param action leaves bot action
|
||||
+ * @param player player who create this action
|
||||
+ * @param args passed action arguments
|
||||
+ */
|
||||
+ public boolean setBotAction(@NotNull LeavesBotAction action, @NotNull Player player, @NotNull String[] args);
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/entity/BotManager.java b/src/main/java/top/leavesmc/leaves/entity/BotManager.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..f2258027b2ed4bfcf7feda2e9075b1a1a05a85b6
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/entity/BotManager.java
|
||||
@@ -0,0 +1,107 @@
|
||||
+package top.leavesmc.leaves.entity;
|
||||
+
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.util.Consumer;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+import top.leavesmc.leaves.entity.botaction.CustomBotAction;
|
||||
+
|
||||
+import java.util.Collection;
|
||||
+import java.util.UUID;
|
||||
+
|
||||
+/**
|
||||
+ * Simple fakeplayer manager
|
||||
+ */
|
||||
+public interface BotManager {
|
||||
+
|
||||
+ /**
|
||||
+ * Gets a fakeplayer object by the given uuid.
|
||||
+ *
|
||||
+ * @param uuid the uuid to look up
|
||||
+ * @return a fakeplayer if one was found, null otherwise
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public Bot getBot(@NotNull UUID uuid);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets a fakeplayer object by the given name.
|
||||
+ *
|
||||
+ * @param name the name to look up
|
||||
+ * @return a fakeplayer if one was found, null otherwise
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public Bot getBot(@NotNull String name);
|
||||
+
|
||||
+ /**
|
||||
+ * Creates a fakeplayer with given param.
|
||||
+ * <p>
|
||||
+ * prefix and suffix will not be added.
|
||||
+ *
|
||||
+ * @param name fakeplayer name
|
||||
+ * @param realName fakeplayer real name
|
||||
+ * @param skin fakeplayer skin arr
|
||||
+ * @param skinName fakeplayer skin name
|
||||
+ * @param location a location will create fakeplayer
|
||||
+ * @return a fakeplayer if success, null otherwise
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public Bot createBot(@NotNull String name, @NotNull String realName, @Nullable String[] skin, @Nullable String skinName, @NotNull Location location);
|
||||
+
|
||||
+ /**
|
||||
+ * Creates a fakeplayer with given param.
|
||||
+ *
|
||||
+ * @param name fakeplayer name
|
||||
+ * @param skinName fakeplayer skin name
|
||||
+ * @param location a location will create fakeplayer
|
||||
+ * @param consumer a consumer after create fakeplayer success
|
||||
+ */
|
||||
+ public void createBot(@NotNull String name, @Nullable String skinName, @NotNull Location location, @Nullable Consumer<Bot> consumer);
|
||||
+
|
||||
+ /**
|
||||
+ * Removes a fakeplayer object by the given name.
|
||||
+ *
|
||||
+ * @param name the name to look up
|
||||
+ */
|
||||
+ public void removeBot(@NotNull String name);
|
||||
+
|
||||
+ /**
|
||||
+ * Removes a fakeplayer object by the given uuid.
|
||||
+ *
|
||||
+ * @param uuid the uuid to look up
|
||||
+ */
|
||||
+ public void removeBot(@NotNull UUID uuid);
|
||||
+
|
||||
+ /**
|
||||
+ * Removes all fakeplayers.
|
||||
+ */
|
||||
+ public void removeAllBots();
|
||||
+
|
||||
+ /**
|
||||
+ * Save fakeplayers data if resident-fakeplayer is true, or remove all fakeplayer.
|
||||
+ */
|
||||
+ public void saveOrRemoveAllBots();
|
||||
+
|
||||
+ /**
|
||||
+ * Gets a view of all currently logged in fakeplayers. This view is a reused object, making some operations like Collection.size() zero-allocation.
|
||||
+ *
|
||||
+ * @return a view of fakeplayers.
|
||||
+ */
|
||||
+ public Collection<Bot> getBots();
|
||||
+
|
||||
+ /**
|
||||
+ * Register a custom bot action.
|
||||
+ *
|
||||
+ * @param name action name
|
||||
+ * @param action action executor
|
||||
+ * @return true if success, or false
|
||||
+ */
|
||||
+ public boolean registerCustomBotAction(String name, CustomBotAction action);
|
||||
+
|
||||
+ /**
|
||||
+ * Unregister a custom bot action.
|
||||
+ *
|
||||
+ * @param name action name
|
||||
+ * @return true if success, or false
|
||||
+ */
|
||||
+ public boolean unregisterCustomBotAction(String name);
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/entity/botaction/CustomBotAction.java b/src/main/java/top/leavesmc/leaves/entity/botaction/CustomBotAction.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7abf4eef22e40468929e724ebc07a97b0b2a05f3
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/entity/botaction/CustomBotAction.java
|
||||
@@ -0,0 +1,52 @@
|
||||
+package top.leavesmc.leaves.entity.botaction;
|
||||
+
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+import top.leavesmc.leaves.entity.Bot;
|
||||
+
|
||||
+import java.util.List;
|
||||
+
|
||||
+/**
|
||||
+ * Represents a class which contains methods for a custom bot action
|
||||
+ */
|
||||
+public interface CustomBotAction {
|
||||
+
|
||||
+ /**
|
||||
+ * Executes the action, returning its success.
|
||||
+ *
|
||||
+ * @param bot bot of the action
|
||||
+ * @return true if once action finish, otherwise false
|
||||
+ */
|
||||
+ public boolean doTick(Bot bot);
|
||||
+
|
||||
+ /**
|
||||
+ * Created a new action instance.
|
||||
+ *
|
||||
+ * @param player player who create this action
|
||||
+ * @param args passed action arguments
|
||||
+ * @return a new action instance with given args
|
||||
+ */
|
||||
+ public @Nullable CustomBotAction getNew(Player player, String[] args);
|
||||
+
|
||||
+ /**
|
||||
+ * Requests a list of possible completions for a action argument.
|
||||
+ *
|
||||
+ * @return A List of a List of possible completions for the argument.
|
||||
+ */
|
||||
+ public @NotNull List<List<String>> getTabComplete();
|
||||
+
|
||||
+ /**
|
||||
+ * Return a ticks to wait between {@link CustomBotAction#doTick(Bot)}
|
||||
+ *
|
||||
+ * @return the ticks to wait between runs
|
||||
+ */
|
||||
+ public int getTickDelay();
|
||||
+
|
||||
+ /**
|
||||
+ * Return a number of times {@link CustomBotAction#doTick(Bot)} can return true
|
||||
+ *
|
||||
+ * @return the number of times an action can be executed
|
||||
+ */
|
||||
+ public int getNumber();
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/entity/botaction/LeavesBotAction.java b/src/main/java/top/leavesmc/leaves/entity/botaction/LeavesBotAction.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e298722319ff0cfd52e531693ea3767e5f9a3d52
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/entity/botaction/LeavesBotAction.java
|
||||
@@ -0,0 +1,32 @@
|
||||
+package top.leavesmc.leaves.entity.botaction;
|
||||
+
|
||||
+/**
|
||||
+ * A Leaves bot action enum
|
||||
+ */
|
||||
+public enum LeavesBotAction {
|
||||
+ ATTACK("attack"),
|
||||
+ ATTACK_SELF("attack_self"),
|
||||
+ BREAK("break"),
|
||||
+ DROP("drop"),
|
||||
+ FISH("fish"),
|
||||
+ JUMP("jump"),
|
||||
+ LAY("lay"),
|
||||
+ LOOK("look"),
|
||||
+ ROTATE("rotate"),
|
||||
+ SNEAK("sneak"),
|
||||
+ STOP("stop"),
|
||||
+ SWIM("swim"),
|
||||
+ USE("use"),
|
||||
+ USE_ON("use_on"),
|
||||
+ USE_TO("use_to");
|
||||
+
|
||||
+ private final String name;
|
||||
+
|
||||
+ private LeavesBotAction(String name) {
|
||||
+ this.name = name;
|
||||
+ }
|
||||
+
|
||||
+ public String getName() {
|
||||
+ return name;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/event/bot/BotCreateEvent.java b/src/main/java/top/leavesmc/leaves/event/bot/BotCreateEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7cf1eb4eb3d2fe9310f9272ec53208632b87b49b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/event/bot/BotCreateEvent.java
|
||||
@@ -0,0 +1,106 @@
|
||||
+package top.leavesmc.leaves.event.bot;
|
||||
+
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+/**
|
||||
+ * Call when a fakeplayer creates a server
|
||||
+ */
|
||||
+public class BotCreateEvent extends Event implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+
|
||||
+ private final String bot;
|
||||
+ private final String skin;
|
||||
+ private String joinMessage;
|
||||
+ private Location createLocation;
|
||||
+ private boolean cancel = false;
|
||||
+
|
||||
+ public BotCreateEvent(@NotNull final String who, @NotNull final String skin, @NotNull final Location createLocation, @Nullable final String joinMessage) {
|
||||
+ this.bot = who;
|
||||
+ this.skin = skin;
|
||||
+ this.joinMessage = joinMessage;
|
||||
+ this.createLocation = createLocation;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the fakeplayer name
|
||||
+ *
|
||||
+ * @return fakeplayer name
|
||||
+ */
|
||||
+ public String getBot() {
|
||||
+ return bot;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the join message to send to all online players
|
||||
+ *
|
||||
+ * @return string join message. Can be null
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public String getJoinMessage() {
|
||||
+ return joinMessage;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the join message to send to all online players
|
||||
+ *
|
||||
+ * @param joinMessage join message. If null, no message will be sent
|
||||
+ */
|
||||
+ public void setJoinMessage(@Nullable String joinMessage) {
|
||||
+ this.joinMessage = joinMessage;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the location to create the fakeplayer
|
||||
+ *
|
||||
+ * @return Location to create the fakeplayer
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Location getCreateLocation() {
|
||||
+ return createLocation;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the location to create the fakeplayer
|
||||
+ *
|
||||
+ * @param createLocation location to create the fakeplayer
|
||||
+ */
|
||||
+ public void setCreateLocation(@NotNull Location createLocation) {
|
||||
+ this.createLocation = createLocation;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the fakeplayer skin
|
||||
+ *
|
||||
+ * @return fakeplayer skin name
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public String getSkin() {
|
||||
+ return skin;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancel = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/event/bot/BotEvent.java b/src/main/java/top/leavesmc/leaves/event/bot/BotEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..4a4fe07ce965d4a97e0d8105a91310dac7d1343c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/event/bot/BotEvent.java
|
||||
@@ -0,0 +1,31 @@
|
||||
+package top.leavesmc.leaves.event.bot;
|
||||
+
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import top.leavesmc.leaves.entity.Bot;
|
||||
+
|
||||
+/**
|
||||
+ * Represents a fakeplayer related event
|
||||
+ */
|
||||
+public abstract class BotEvent extends Event {
|
||||
+ protected Bot bot;
|
||||
+
|
||||
+ public BotEvent(@NotNull final Bot who) {
|
||||
+ bot = who;
|
||||
+ }
|
||||
+
|
||||
+ public BotEvent(@NotNull final Bot who, boolean async) { // Paper - public
|
||||
+ super(async);
|
||||
+ bot = who;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the fakeplayer involved in this event
|
||||
+ *
|
||||
+ * @return Fakeplayer who is involved in this event
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public final Bot getBot() {
|
||||
+ return bot;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/event/bot/BotJoinEvent.java b/src/main/java/top/leavesmc/leaves/event/bot/BotJoinEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..10afa5c7fd4ee8a4e72d64f8ca9bf8731ec2ad61
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/event/bot/BotJoinEvent.java
|
||||
@@ -0,0 +1,27 @@
|
||||
+package top.leavesmc.leaves.event.bot;
|
||||
+
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import top.leavesmc.leaves.entity.Bot;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a fakeplayer joins a server
|
||||
+ */
|
||||
+public class BotJoinEvent extends BotEvent {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+
|
||||
+ public BotJoinEvent(@NotNull Bot who) {
|
||||
+ super(who);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
@@ -1,101 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Fri, 9 Feb 2024 03:32:05 +0000
|
||||
Subject: [PATCH] Threaded region start tick and finished tick event
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/api/events/TickRegionFinishedTickEvent.java b/src/main/java/me/earthme/luminol/api/events/TickRegionFinishedTickEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..29b98728d3ca4a439c6b3333cd123c0e0b8a2846
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/api/events/TickRegionFinishedTickEvent.java
|
||||
@@ -0,0 +1,42 @@
|
||||
+package me.earthme.luminol.api.events;
|
||||
+
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a region finished its tick task.
|
||||
+ */
|
||||
+public class TickRegionFinishedTickEvent extends Event {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+
|
||||
+ private final long currTime;
|
||||
+ private final long regionId;
|
||||
+
|
||||
+ public TickRegionFinishedTickEvent(long currTime, long regionId) {
|
||||
+ this.currTime = currTime;
|
||||
+ this.regionId = regionId;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the time of tick end
|
||||
+ * @return The time of tick end in nanoseconds
|
||||
+ */
|
||||
+ public long getFinishedTime() {
|
||||
+ return this.currTime;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the id of current region
|
||||
+ * Notice: The id of global region is -1 in this event
|
||||
+ * @return The id of current region
|
||||
+ */
|
||||
+ public long getRegionId() {
|
||||
+ return this.regionId;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/api/events/TickRegionStartTickEvent.java b/src/main/java/me/earthme/luminol/api/events/TickRegionStartTickEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..1f3cba43ebd873965c24b96ca116abfb149ab4e6
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/api/events/TickRegionStartTickEvent.java
|
||||
@@ -0,0 +1,41 @@
|
||||
+package me.earthme.luminol.api.events;
|
||||
+
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a tick was started.
|
||||
+ */
|
||||
+public class TickRegionStartTickEvent extends Event {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private final long currTime;
|
||||
+ private final long regionId;
|
||||
+
|
||||
+ public TickRegionStartTickEvent(long currTime, long regionId) {
|
||||
+ this.currTime = currTime;
|
||||
+ this.regionId = regionId;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the id of current region
|
||||
+ * Notice: The id of global region is -1 in this event
|
||||
+ * @return The id of current region
|
||||
+ */
|
||||
+ public long getRegionId() {
|
||||
+ return this.regionId;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the time of tick start
|
||||
+ * @return The time of tick start in nanoseconds
|
||||
+ */
|
||||
+ public long getStartTime(){
|
||||
+ return this.currTime;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
@@ -1,11 +1,11 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Mon, 1 Jan 2024 07:59:27 +0000
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 08:20:14 +0800
|
||||
Subject: [PATCH] Fix build
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 959e62d800de05b2dd77a252f442c3daf8438490..b9c5ef4d15aa97a380419912e3ee09d094ae752e 100644
|
||||
index 0cd12a854e544e867abfd94c18a9f138ba57e587..d295ee01481b088a376691de7c0927e95d7a68a8 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -14,7 +14,7 @@ val alsoShade: Configuration by configurations.creating
|
||||
@@ -13,11 +13,11 @@ index 959e62d800de05b2dd77a252f442c3daf8438490..b9c5ef4d15aa97a380419912e3ee09d0
|
||||
dependencies {
|
||||
// Folia start
|
||||
- implementation(project(":folia-api"))
|
||||
+ implementation(project(":luminol-api"))//Luminol
|
||||
+ implementation(project(":luminol-api")) //Luminol
|
||||
implementation("io.papermc.paper:paper-mojangapi:${project.version}") {
|
||||
exclude("io.papermc.paper", "paper-api")
|
||||
}
|
||||
@@ -73,7 +73,7 @@ tasks.jar {
|
||||
@@ -74,7 +74,7 @@ tasks.jar {
|
||||
attributes(
|
||||
"Main-Class" to "org.bukkit.craftbukkit.Main",
|
||||
"Implementation-Title" to "CraftBukkit",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
179
patches/server/0003-Added-empty-luminol-config.patch
Normal file
179
patches/server/0003-Added-empty-luminol-config.patch
Normal file
@@ -0,0 +1,179 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 10:40:56 +0800
|
||||
Subject: [PATCH] Added empty luminol config
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index d295ee01481b088a376691de7c0927e95d7a68a8..54d761d7e4733c12fbb4957acd509d278ae11316 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -19,6 +19,7 @@ dependencies {
|
||||
exclude("io.papermc.paper", "paper-api")
|
||||
}
|
||||
// Folia end
|
||||
+ implementation("com.electronwill.night-config:toml:3.6.0") //Luminol - Night config
|
||||
// Paper start
|
||||
implementation("org.jline:jline-terminal-jansi:3.21.0")
|
||||
implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..1f9ff0fc33fa36c90fc4cbbd21b7b790de581632
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -0,0 +1,99 @@
|
||||
+package me.earthme.luminol;
|
||||
+
|
||||
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import net.minecraft.server.level.ServerLevel;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.io.IOException;
|
||||
+
|
||||
+public class LuminolConfig {
|
||||
+ private static final File PARENT_FOLDER = new File("luminol_config");
|
||||
+ private static final File MAIN_CONFIG_FILE = new File(PARENT_FOLDER,"luminol_global.toml");
|
||||
+ private static CommentedFileConfig MAIN_CONFIG;
|
||||
+
|
||||
+ public static String serverModName = "Luminol";
|
||||
+ public static boolean fakeVanillaModeEnabled = false;
|
||||
+
|
||||
+ public static void init() throws IOException {
|
||||
+ PARENT_FOLDER.mkdir();
|
||||
+
|
||||
+ if (!MAIN_CONFIG_FILE.exists()){
|
||||
+ MAIN_CONFIG_FILE.createNewFile();
|
||||
+ }
|
||||
+
|
||||
+ MAIN_CONFIG = CommentedFileConfig.ofConcurrent(MAIN_CONFIG_FILE);
|
||||
+
|
||||
+ MAIN_CONFIG.load();
|
||||
+ initValues();
|
||||
+ MAIN_CONFIG.save();
|
||||
+ }
|
||||
+
|
||||
+ public static void initValues(){
|
||||
+ serverModName = get("misc.server_mod_name",serverModName,"The servermod name will be sent to players,and you can see it in F3 or motd responses");
|
||||
+ fakeVanillaModeEnabled = get("misc.enable_fake_vanilla_mode",fakeVanillaModeEnabled,"Enable this to make the ping response of your server like a vanilla server");
|
||||
+ }
|
||||
+
|
||||
+ public static <T> T get(String key,T def){
|
||||
+ if (MAIN_CONFIG.contains(key)){
|
||||
+ return MAIN_CONFIG.get(key);
|
||||
+ }
|
||||
+
|
||||
+ MAIN_CONFIG.set(key,def);
|
||||
+ return def;
|
||||
+ }
|
||||
+
|
||||
+ public static <T> T get(String key,T def,String comment){
|
||||
+ MAIN_CONFIG.setComment(key,comment);
|
||||
+
|
||||
+ if (MAIN_CONFIG.contains(key)){
|
||||
+ return MAIN_CONFIG.get(key);
|
||||
+ }
|
||||
+
|
||||
+ MAIN_CONFIG.set(key,def);
|
||||
+ return def;
|
||||
+ }
|
||||
+
|
||||
+ public static class LumionalWorldConfig{
|
||||
+ private final File configFile;
|
||||
+ private CommentedFileConfig commentedFileConfig;
|
||||
+
|
||||
+ public LumionalWorldConfig(ServerLevel level) {
|
||||
+ this.configFile = new File(PARENT_FOLDER,"luminol_world_"+level.getWorld().getName()+".toml");
|
||||
+ }
|
||||
+
|
||||
+ public void init() throws IOException {
|
||||
+ if (!this.configFile.exists()){
|
||||
+ this.configFile.createNewFile();
|
||||
+ }
|
||||
+
|
||||
+ this.commentedFileConfig = CommentedFileConfig.ofConcurrent(this.configFile);
|
||||
+ this.commentedFileConfig.load();
|
||||
+ this.initValues();
|
||||
+ this.commentedFileConfig.save();
|
||||
+ }
|
||||
+
|
||||
+ public void initValues(){
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ public <T> T get(String key,T def,String comment){
|
||||
+ this.commentedFileConfig.setComment(key,comment);
|
||||
+
|
||||
+ if (this.commentedFileConfig.contains(key)){
|
||||
+ return this.commentedFileConfig.get(key);
|
||||
+ }
|
||||
+
|
||||
+ this.commentedFileConfig.set(key,def);
|
||||
+ return def;
|
||||
+ }
|
||||
+
|
||||
+ public <T> T get(String key,T def){
|
||||
+ if (this.commentedFileConfig.contains(key)){
|
||||
+ return this.commentedFileConfig.get(key);
|
||||
+ }
|
||||
+
|
||||
+ this.commentedFileConfig.set(key,def);
|
||||
+ return def;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 05d8cabd2294456e3c8df60265f8b035990dd896..f0bf57a7acd77eeffbeeb6743ba58166823022fd 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -19,6 +19,8 @@ import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.DefaultUncaughtExceptionHandler;
|
||||
import net.minecraft.DefaultUncaughtExceptionHandlerWithName;
|
||||
import net.minecraft.SharedConstants;
|
||||
@@ -206,6 +208,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
// Spigot end
|
||||
// Paper start
|
||||
io.papermc.paper.util.ObfHelper.INSTANCE.getClass(); // Paper - load mappings for stacktrace deobf and etc.
|
||||
+ LuminolConfig.init(); //Luminol
|
||||
paperConfigurations.initializeGlobalConfiguration();
|
||||
paperConfigurations.initializeWorldDefaultsConfiguration();
|
||||
// Paper start - moved up to right after PlayerList creation but before file load/save
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 724aa1d8147ea2fb5e46d291adacfb7e1f5b5f62..e274c501e2455845f6f9a4614802336205362b69 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -38,6 +38,8 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -766,6 +768,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
}
|
||||
// Folia end - region threading
|
||||
|
||||
+ public final LuminolConfig.LumionalWorldConfig lumionalWorldConfig; //Luminol
|
||||
+
|
||||
// Add env and gen to constructor, IWorldDataServer -> WorldDataServer
|
||||
public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey<Level> resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List<CustomSpawner> list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
|
||||
// IRegistryCustom.Dimension iregistrycustom_dimension = minecraftserver.registryAccess(); // CraftBukkit - decompile error
|
||||
@@ -850,6 +854,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
this.chunkTaskScheduler = new io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler(this, io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.workerThreads); // Paper - rewrite chunk system
|
||||
this.entityLookup = new io.papermc.paper.chunk.system.entity.EntityLookup(this, new EntityCallbacks()); // Paper - rewrite chunk system
|
||||
this.updateTickData(); // Folia - region threading - make sure it is initialised before ticked
|
||||
+ this.lumionalWorldConfig = new LuminolConfig.LumionalWorldConfig(this);
|
||||
+ try {
|
||||
+ this.lumionalWorldConfig.init();
|
||||
+ } catch (IOException e) {
|
||||
+ throw new RuntimeException("Failed to create luminol config for level "+ this.getWorld().getName()+"!",e);
|
||||
+ }
|
||||
}
|
||||
|
||||
// Folia start - region threading
|
||||
@@ -1,313 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 00:45:19 +0000
|
||||
Subject: [PATCH] Empty config file base
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index b9c5ef4d15aa97a380419912e3ee09d094ae752e..e837f1f9b444318cbee8719b9dd0eb669478742e 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -19,6 +19,7 @@ dependencies {
|
||||
exclude("io.papermc.paper", "paper-api")
|
||||
}
|
||||
// Folia end
|
||||
+ implementation("com.electronwill.night-config:toml:3.6.6") //Luminol - Night config
|
||||
// Paper start
|
||||
implementation("org.jline:jline-terminal-jansi:3.21.0")
|
||||
implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/ConfigInfo.java b/src/main/java/me/earthme/luminol/config/ConfigInfo.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..01b64c2cf6b437114337626c242e1da3fbdb8ead
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/ConfigInfo.java
|
||||
@@ -0,0 +1,11 @@
|
||||
+package me.earthme.luminol.config;
|
||||
+
|
||||
+import java.lang.annotation.Retention;
|
||||
+import java.lang.annotation.RetentionPolicy;
|
||||
+
|
||||
+@Retention(RetentionPolicy.RUNTIME)
|
||||
+public @interface ConfigInfo {
|
||||
+ String baseName();
|
||||
+
|
||||
+ String comments() default "";
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/DoNotLoad.java b/src/main/java/me/earthme/luminol/config/DoNotLoad.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..fffc5eb4be4b78a886f3c340bd60f3a2b0108a7d
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/DoNotLoad.java
|
||||
@@ -0,0 +1,8 @@
|
||||
+package me.earthme.luminol.config;
|
||||
+
|
||||
+import java.lang.annotation.Retention;
|
||||
+import java.lang.annotation.RetentionPolicy;
|
||||
+
|
||||
+@Retention(RetentionPolicy.RUNTIME)
|
||||
+public @interface DoNotLoad {
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/EnumConfigCategory.java b/src/main/java/me/earthme/luminol/config/EnumConfigCategory.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ac2a92fe0ddbebb71ea4dd8c96f461d06ec29a4c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/EnumConfigCategory.java
|
||||
@@ -0,0 +1,18 @@
|
||||
+package me.earthme.luminol.config;
|
||||
+
|
||||
+public enum EnumConfigCategory {
|
||||
+ OPTIMIZATIONS("optimizations"),
|
||||
+ FIXES("fixes"),
|
||||
+ MISC("misc"),
|
||||
+ GAMEPLAY("gameplay");
|
||||
+
|
||||
+ private final String baseKeyName;
|
||||
+
|
||||
+ EnumConfigCategory(String baseKeyName) {
|
||||
+ this.baseKeyName = baseKeyName;
|
||||
+ }
|
||||
+
|
||||
+ public String getBaseKeyName() {
|
||||
+ return this.baseKeyName;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/IConfigModule.java b/src/main/java/me/earthme/luminol/config/IConfigModule.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..9f6896711907ac30fe0c00130207b970007e4bb4
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/IConfigModule.java
|
||||
@@ -0,0 +1,22 @@
|
||||
+package me.earthme.luminol.config;
|
||||
+
|
||||
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+public interface IConfigModule {
|
||||
+
|
||||
+ EnumConfigCategory getCategory();
|
||||
+
|
||||
+ String getBaseName();
|
||||
+
|
||||
+ default void onLoaded(CommentedFileConfig configInstance) {}
|
||||
+
|
||||
+ default <T> T get(String keyName, T defaultValue, @NotNull CommentedFileConfig config){
|
||||
+ if (!config.contains(keyName)){
|
||||
+ config.set(keyName,defaultValue);
|
||||
+ return defaultValue;
|
||||
+ }
|
||||
+
|
||||
+ return config.get(keyName);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/LuminolConfig.java b/src/main/java/me/earthme/luminol/config/LuminolConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..63d1de1cebe2700010191560ea8b80dfdac2f9bc
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/LuminolConfig.java
|
||||
@@ -0,0 +1,185 @@
|
||||
+package me.earthme.luminol.config;
|
||||
+
|
||||
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.io.IOException;
|
||||
+import java.lang.reflect.Field;
|
||||
+import java.lang.reflect.InvocationTargetException;
|
||||
+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.*;
|
||||
+import java.util.jar.JarEntry;
|
||||
+import java.util.jar.JarFile;
|
||||
+
|
||||
+import org.apache.logging.log4j.LogManager;
|
||||
+import org.apache.logging.log4j.Logger;
|
||||
+
|
||||
+public class LuminolConfig {
|
||||
+ public static final Logger logger = LogManager.getLogger();
|
||||
+ private static final File baseConfigFolder = new File("luminol_config");
|
||||
+ private static final File baseConfigFile = new File(baseConfigFolder,"luminol_global_config.toml");
|
||||
+ private static final Set<IConfigModule> allInstanced = new HashSet<>();
|
||||
+ private static CommentedFileConfig configFileInstance;
|
||||
+
|
||||
+ public static void loadConfig() throws IOException {
|
||||
+ baseConfigFolder.mkdirs();
|
||||
+
|
||||
+ if (!baseConfigFile.exists()){
|
||||
+ baseConfigFile.createNewFile();
|
||||
+ }
|
||||
+
|
||||
+ configFileInstance = CommentedFileConfig.ofConcurrent(baseConfigFile);
|
||||
+
|
||||
+ configFileInstance.load();
|
||||
+
|
||||
+ try {
|
||||
+ instanceAllModule();
|
||||
+ loadAllModules();
|
||||
+ }catch (Exception e){
|
||||
+ logger.error("Failed to load config modules!",e);
|
||||
+ }
|
||||
+
|
||||
+ configFileInstance.save();
|
||||
+ }
|
||||
+
|
||||
+ private static void loadAllModules() throws IllegalAccessException {
|
||||
+ for (IConfigModule instanced : allInstanced){
|
||||
+ loadForSingle(instanced);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static void instanceAllModule() throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
|
||||
+ for (Class<?> clazz : getClasses("me.earthme.luminol.config.modules")){
|
||||
+ if (IConfigModule.class.isAssignableFrom(clazz)){
|
||||
+ allInstanced.add((IConfigModule) clazz.getConstructor().newInstance());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static void loadForSingle(@NotNull IConfigModule singleConfigModule) throws IllegalAccessException {
|
||||
+ final EnumConfigCategory category = singleConfigModule.getCategory();
|
||||
+
|
||||
+ Field[] fields = singleConfigModule.getClass().getDeclaredFields();
|
||||
+
|
||||
+ for (Field field : fields) {
|
||||
+ int modifiers = field.getModifiers();
|
||||
+ if (Modifier.isStatic(modifiers) && !Modifier.isFinal(modifiers)) {
|
||||
+ boolean skipLoad = field.getAnnotation(DoNotLoad.class) != null;
|
||||
+ ConfigInfo configInfo = field.getAnnotation(ConfigInfo.class);
|
||||
+
|
||||
+ if (skipLoad || configInfo == null){
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final String fullConfigKeyName = category.getBaseKeyName() + "." + singleConfigModule.getBaseName() + "." + configInfo.baseName();
|
||||
+
|
||||
+ field.setAccessible(true);
|
||||
+ final Object currentValue = field.get(null);
|
||||
+
|
||||
+ if (!configFileInstance.contains(fullConfigKeyName)){
|
||||
+ if (currentValue == null){
|
||||
+ throw new UnsupportedOperationException("Config " + singleConfigModule.getBaseName() + "tried to add an null default value!");
|
||||
+ }
|
||||
+
|
||||
+ final String comments = configInfo.comments();
|
||||
+
|
||||
+ if (!comments.isBlank()){
|
||||
+ configFileInstance.setComment(fullConfigKeyName,comments);
|
||||
+ }
|
||||
+
|
||||
+ configFileInstance.add(fullConfigKeyName,currentValue);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final Object actuallyValue = configFileInstance.get(fullConfigKeyName);
|
||||
+ field.set(null,actuallyValue);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ singleConfigModule.onLoaded(configFileInstance);
|
||||
+ }
|
||||
+
|
||||
+ public static @NotNull Set<Class<?>> getClasses(String pack) {
|
||||
+ Set<Class<?>> classes = new LinkedHashSet<>();
|
||||
+ 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) {
|
||||
+ throw new RuntimeException(e);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ } catch (IOException e) {
|
||||
+ throw new RuntimeException(e);
|
||||
+ }
|
||||
+
|
||||
+ 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) {
|
||||
+ throw new RuntimeException(e);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ 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) {
|
||||
+ throw new RuntimeException(e);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 6b3242117d62175de462d04e4d178b49ae2521e9..d6b480565340f5edbf81d7b57c3199292b020615 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -19,6 +19,8 @@ import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.earthme.luminol.config.LuminolConfig;
|
||||
import net.minecraft.DefaultUncaughtExceptionHandler;
|
||||
import net.minecraft.DefaultUncaughtExceptionHandlerWithName;
|
||||
import net.minecraft.SharedConstants;
|
||||
@@ -209,6 +211,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
this.paperConfigurations.initializeGlobalConfiguration(this.registryAccess());
|
||||
this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess());
|
||||
// Paper end - initialize global and world-defaults configuration
|
||||
+ LuminolConfig.loadConfig(); //Luminol - load config file
|
||||
// Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save
|
||||
if (this.convertOldUsers()) {
|
||||
this.getProfileCache().save(false); // Paper
|
||||
49
patches/server/0004-Add-config-for-server-brand-name.patch
Normal file
49
patches/server/0004-Add-config-for-server-brand-name.patch
Normal file
@@ -0,0 +1,49 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 11:17:37 +0800
|
||||
Subject: [PATCH] Add config for server brand name
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/network/PaperServerListPingEventImpl.java b/src/main/java/com/destroystokyo/paper/network/PaperServerListPingEventImpl.java
|
||||
index 5d7110a33957a597592cacb864c947eb053e8563..25cda48a6ab9a703d64c391007f5c32c368fdbe2 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/network/PaperServerListPingEventImpl.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/network/PaperServerListPingEventImpl.java
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.destroystokyo.paper.network;
|
||||
|
||||
import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -14,7 +15,7 @@ class PaperServerListPingEventImpl extends PaperServerListPingEvent {
|
||||
|
||||
PaperServerListPingEventImpl(MinecraftServer server, StatusClient client, int protocolVersion, @Nullable CachedServerIcon icon) {
|
||||
super(client, server.server.motd(), server.getPlayerCount(), server.getMaxPlayers(),
|
||||
- server.getServerModName() + ' ' + server.getServerVersion(), protocolVersion, icon);
|
||||
+ LuminolConfig.fakeVanillaModeEnabled ? server.getServerVersion() : server.getServerModName() + ' ' + server.getServerVersion(), protocolVersion, icon);//Luminol - Fake vanilla mode
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 781612b6fc3d020e832164ebce231961dd68e24e..03165a7791aeac54e44391bbb0f432b613369bfa 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -53,6 +53,8 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.imageio.ImageIO;
|
||||
+
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.ReportedException;
|
||||
import net.minecraft.SharedConstants;
|
||||
@@ -1833,7 +1835,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
- return "Luminol"; //Luminol - Luminol > // Folia - Folia > // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla!
|
||||
+ return LuminolConfig.fakeVanillaModeEnabled ? "vanilla" : LuminolConfig.serverModName; //Luminol //Luminol - Luminol > // Folia - Folia > // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla!
|
||||
}
|
||||
|
||||
public SystemReport fillSystemReport(SystemReport details) {
|
||||
@@ -1,61 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 00:49:38 +0000
|
||||
Subject: [PATCH] Add config for server mod name
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/network/PaperServerListPingEventImpl.java b/src/main/java/com/destroystokyo/paper/network/PaperServerListPingEventImpl.java
|
||||
index 6ed2114f577ce12d2d493985e798609c7d83f15e..7a5dcf3b7108794b9a224004730eb396a96cce8f 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/network/PaperServerListPingEventImpl.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/network/PaperServerListPingEventImpl.java
|
||||
@@ -14,7 +14,7 @@ class PaperServerListPingEventImpl extends PaperServerListPingEvent {
|
||||
|
||||
PaperServerListPingEventImpl(MinecraftServer server, StatusClient client, int protocolVersion, @Nullable CachedServerIcon icon) {
|
||||
super(client, server.motd(), server.getPlayerCount(), server.getMaxPlayers(),
|
||||
- server.getServerModName() + ' ' + server.getServerVersion(), protocolVersion, icon);
|
||||
+ me.earthme.luminol.config.modules.misc.ServerModNameConfig.fakeVanilla ? server.getServerVersion() : server.getServerModName() + ' ' + server.getServerVersion(), protocolVersion, icon);//Luminol - Fake vanilla mode
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/ServerModNameConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/ServerModNameConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..94e7c8910e3623163528a844fd7a08b3ffe5826b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/ServerModNameConfig.java
|
||||
@@ -0,0 +1,23 @@
|
||||
+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 ServerModNameConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "name")
|
||||
+ public static String serverModName = "Luminol";
|
||||
+
|
||||
+ @ConfigInfo(baseName = "vanilla_spoof")
|
||||
+ public static boolean fakeVanilla = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "server_mod_name";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 22aff010859dded150b6e3dd0644fe3c38dbaea9..4468e6fdbbe527111f4410188f2f2df7f592f81e 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1954,7 +1954,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
- return "Luminol"; // Paper // Folia - Folia //Luminol - Luminol
|
||||
+ return me.earthme.luminol.config.modules.misc.ServerModNameConfig.fakeVanilla ? "vanilla" : me.earthme.luminol.config.modules.misc.ServerModNameConfig.serverModName; // Paper // Folia - Folia //Luminol - Luminol //Luminol - Add config for this
|
||||
}
|
||||
|
||||
public SystemReport fillSystemReport(SystemReport details) {
|
||||
@@ -1,57 +1,77 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 00:53:03 +0000
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 11:18:04 +0800
|
||||
Subject: [PATCH] Add config for unsafe teleportation
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/UnsafeTeleportationConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/UnsafeTeleportationConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..cb2fef0d808e2fc2950eded5b39651c66fff9103
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/UnsafeTeleportationConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.fixes;
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index 1f9ff0fc33fa36c90fc4cbbd21b7b790de581632..36ca0b94d29d81e5f1f2aff4a38ead0b363dd1c7 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -14,6 +14,8 @@ public class LuminolConfig {
|
||||
public static String serverModName = "Luminol";
|
||||
public static boolean fakeVanillaModeEnabled = false;
|
||||
|
||||
+ public static boolean safeTeleportation = true;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
public static void init() throws IOException {
|
||||
PARENT_FOLDER.mkdir();
|
||||
|
||||
@@ -31,6 +33,8 @@ public class LuminolConfig {
|
||||
public static void initValues(){
|
||||
serverModName = get("misc.server_mod_name",serverModName,"The servermod name will be sent to players,and you can see it in F3 or motd responses");
|
||||
fakeVanillaModeEnabled = get("misc.enable_fake_vanilla_mode",fakeVanillaModeEnabled,"Enable this to make the ping response of your server like a vanilla server");
|
||||
+
|
||||
+public class UnsafeTeleportationConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.FIXES;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "allow_unsafe_teleportation";
|
||||
+ }
|
||||
+}
|
||||
+ safeTeleportation = get("fixes.enable_safe_teleportation",safeTeleportation,"If this enabled,the end portals will not teleport removed entities.");
|
||||
}
|
||||
|
||||
public static <T> T get(String key,T def){
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 0725386d7ef47171012671725ceddfe92b43b203..78ad77dd1368d3743ea5091a81f63339f7921efe 100644
|
||||
index 385d5bc08928dd990b690b926e174af86f178c64..e357ed9607889536ecd0e6ea8b59c97d3dab631f 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -4046,6 +4046,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -24,6 +24,8 @@ import java.util.function.BiConsumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.BlockUtil;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.CrashReportCategory;
|
||||
@@ -4001,6 +4003,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
|
||||
protected boolean tryEndPortal() {
|
||||
io.papermc.paper.util.TickThread.ensureTickThread(this, "Cannot portal entity async");
|
||||
+ if (me.earthme.luminol.config.modules.fixes.UnsafeTeleportationConfig.enabled && !(this instanceof Player)) return false; //Luminol - Unsafe teleportation
|
||||
+ if (!LuminolConfig.safeTeleportation && !(this instanceof Player)) return false; //Luminol - Unsafe teleportation
|
||||
BlockPos pos = this.portalBlock;
|
||||
ServerLevel world = this.portalWorld;
|
||||
this.portalBlock = null;
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
index a0c1db8cfebaa0344012cc0af18d6231cdcdcbb8..cb174f06f9701cc4f0ff479649f39ee9aa63a97a 100644
|
||||
index 41d7cff39fc37955877668337689b4b26cd8c7cf..ca5799c618bec3d0abc4566d82a29bcc767c6f1f 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
@@ -61,6 +61,13 @@ public class EndPortalBlock extends BaseEntityBlock {
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.world.level.block;
|
||||
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
@@ -7,6 +8,7 @@ import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
+import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -53,6 +55,13 @@ public class EndPortalBlock extends BaseEntityBlock {
|
||||
// return; // CraftBukkit - always fire event in case plugins wish to change it
|
||||
}
|
||||
|
||||
+ //Luminol start - Unsafe teleportation
|
||||
+ if (me.earthme.luminol.config.modules.fixes.UnsafeTeleportationConfig.enabled && !(entity instanceof net.minecraft.world.entity.player.Player)){
|
||||
+ if (!LuminolConfig.safeTeleportation && !(entity instanceof Player)){
|
||||
+ entity.endPortalLogicAsync();
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
@@ -1,54 +1,57 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 00:56:34 +0000
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sat, 25 Nov 2023 18:17:52 +0800
|
||||
Subject: [PATCH] Add config for sand duping
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/SandDupingFixConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/SandDupingFixConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7561dfd23724fc3f2cc580b2b53fa1469e3d098e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/SandDupingFixConfig.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 SandDupingFixConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.FIXES;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "allow_sand_duping";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index 36ca0b94d29d81e5f1f2aff4a38ead0b363dd1c7..9db3bdd7a7d0b2a110e927ee4781eee489d0da9b 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -15,6 +15,7 @@ public class LuminolConfig {
|
||||
public static boolean fakeVanillaModeEnabled = false;
|
||||
|
||||
public static boolean safeTeleportation = true;
|
||||
+ public static boolean enableSandDuping = false;
|
||||
|
||||
public static void init() throws IOException {
|
||||
PARENT_FOLDER.mkdir();
|
||||
@@ -35,6 +36,7 @@ public class LuminolConfig {
|
||||
fakeVanillaModeEnabled = get("misc.enable_fake_vanilla_mode",fakeVanillaModeEnabled,"Enable this to make the ping response of your server like a vanilla server");
|
||||
|
||||
safeTeleportation = get("fixes.enable_safe_teleportation",safeTeleportation,"If this enabled,the end portals will not teleport removed entities.");
|
||||
+ enableSandDuping = get("fixes.enable_sand_duping",enableSandDuping,"If this enabled,The value of safe teleportation will always be false and sand duping will be enabled");
|
||||
}
|
||||
|
||||
public static <T> T get(String key,T def){
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
index 25b7b85cbd1130c5320e55b3c6b6f81ec228da81..c43f710a558cfe887a373a94ee48c4804986186d 100644
|
||||
index 8e348099d6b3eb4510405d76453d70e7cadeebf6..cf72aa13fce00bf21c036c14a605ea7c6090d5f0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
@@ -133,7 +133,7 @@ public class FallingBlockEntity extends Entity {
|
||||
@@ -4,6 +4,8 @@ import com.mojang.logging.LogUtils;
|
||||
import java.util.Iterator;
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.CrashReportCategory;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -133,7 +135,7 @@ public class FallingBlockEntity extends Entity {
|
||||
@Override
|
||||
public void tick() {
|
||||
// Paper start - fix sand duping
|
||||
- if (this.isRemoved()) {
|
||||
+ if (!me.earthme.luminol.config.modules.fixes.SandDupingFixConfig.enabled && this.isRemoved()) { //Luminol - Add config for sand duping
|
||||
+ if (!LuminolConfig.enableSandDuping && this.isRemoved()) { //Luminol - Add config for sand duping
|
||||
return;
|
||||
}
|
||||
// Paper end - fix sand duping
|
||||
@@ -149,7 +149,7 @@ public class FallingBlockEntity extends Entity {
|
||||
|
||||
@@ -150,7 +152,7 @@ public class FallingBlockEntity extends Entity {
|
||||
this.move(MoverType.SELF, this.getDeltaMovement());
|
||||
|
||||
// Paper start - fix sand duping
|
||||
- if (this.isRemoved()) {
|
||||
+ if (!me.earthme.luminol.config.modules.fixes.SandDupingFixConfig.enabled && this.isRemoved()) { //Luminol - Add config for sand duping
|
||||
+ if (!LuminolConfig.enableSandDuping && this.isRemoved()) { //Luminol - Add config for sand duping
|
||||
return;
|
||||
}
|
||||
// Paper end - fix sand duping
|
||||
|
||||
@@ -1,45 +1,39 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 00:59:18 +0000
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sat, 25 Nov 2023 18:22:09 +0800
|
||||
Subject: [PATCH] Add config for void trading
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/VoidTradingFixConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/VoidTradingFixConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..22f3c6c70e4287f1bdd0b18f87f57efeb20140a2
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/VoidTradingFixConfig.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 VoidTradingFixConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.FIXES;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "allow_void_trading";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index 9db3bdd7a7d0b2a110e927ee4781eee489d0da9b..dffa9db569fcef2feec75072fe86c9a6ded80aa4 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -16,6 +16,7 @@ public class LuminolConfig {
|
||||
|
||||
public static boolean safeTeleportation = true;
|
||||
public static boolean enableSandDuping = false;
|
||||
+ public static boolean enableVoidTrading = false;
|
||||
|
||||
public static void init() throws IOException {
|
||||
PARENT_FOLDER.mkdir();
|
||||
@@ -37,6 +38,7 @@ public class LuminolConfig {
|
||||
|
||||
safeTeleportation = get("fixes.enable_safe_teleportation",safeTeleportation,"If this enabled,the end portals will not teleport removed entities.");
|
||||
enableSandDuping = get("fixes.enable_sand_duping",enableSandDuping,"If this enabled,The value of safe teleportation will always be false and sand duping will be enabled");
|
||||
+ enableVoidTrading = get("fixes.enable_void_trading",enableVoidTrading);
|
||||
}
|
||||
|
||||
public static <T> T get(String key,T def){
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index ec25610cbffe30fecaeaadf9098e187bc15b5405..682ca5ec0aee427463d1a9f97292c6ea65ca2da0 100644
|
||||
index e274c501e2455845f6f9a4614802336205362b69..722a5ec7f8e4995ac7025ca0785145d46bd66fcd 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -3045,7 +3045,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
@@ -3026,7 +3026,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
// Spigot Start
|
||||
if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message
|
||||
// Paper start - Fix merchant inventory not closing on entity removal
|
||||
// Paper start
|
||||
- if (entity.getBukkitEntity() instanceof org.bukkit.inventory.Merchant merchant && merchant.getTrader() != null) {
|
||||
+ if (!me.earthme.luminol.config.modules.fixes.VoidTradingFixConfig.enabled && (entity.getBukkitEntity() instanceof org.bukkit.inventory.Merchant merchant && merchant.getTrader() != null)) { //Luminol - Add config for void trading
|
||||
+ if (!LuminolConfig.enableVoidTrading && (entity.getBukkitEntity() instanceof org.bukkit.inventory.Merchant merchant && merchant.getTrader() != null)) { //Luminol - Add config for void trading
|
||||
merchant.getTrader().closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED);
|
||||
}
|
||||
// Paper end - Fix merchant inventory not closing on entity removal
|
||||
// Paper end
|
||||
|
||||
@@ -1,45 +1,48 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 01:05:57 +0000
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sat, 25 Nov 2023 18:25:37 +0800
|
||||
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/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index dffa9db569fcef2feec75072fe86c9a6ded80aa4..a49da370c91211d4e2274f72d62c911a1912296a 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -17,6 +17,7 @@ public class LuminolConfig {
|
||||
public static boolean safeTeleportation = true;
|
||||
public static boolean enableSandDuping = false;
|
||||
public static boolean enableVoidTrading = false;
|
||||
+ public static boolean allowIncorrectTripwireUpdating = false;
|
||||
|
||||
public static void init() throws IOException {
|
||||
PARENT_FOLDER.mkdir();
|
||||
@@ -39,6 +40,7 @@ public class LuminolConfig {
|
||||
safeTeleportation = get("fixes.enable_safe_teleportation",safeTeleportation,"If this enabled,the end portals will not teleport removed entities.");
|
||||
enableSandDuping = get("fixes.enable_sand_duping",enableSandDuping,"If this enabled,The value of safe teleportation will always be false and sand duping will be enabled");
|
||||
enableVoidTrading = get("fixes.enable_void_trading",enableVoidTrading);
|
||||
+ allowIncorrectTripwireUpdating = get("fixes.allow_incorrect_trip_wire_updaing",allowIncorrectTripwireUpdating);
|
||||
}
|
||||
|
||||
public static <T> T get(String key,T def){
|
||||
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 7f2dcf6a9e69779e6f898284b58fb1e32902000c..e1a7208b76e4dc7f388923d72edeceb6daefa774 100644
|
||||
index 004dce26ff073f1de52a84cd425c4f60fdab5e50..ef150d50ff076c80ee62c3c413745fa312c9d289 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
|
||||
@@ -162,7 +162,7 @@ public class TripWireHookBlock extends Block {
|
||||
boolean flag7 = (Boolean) iblockdata2.getValue(TripWireBlock.POWERED);
|
||||
@@ -2,6 +2,8 @@ package net.minecraft.world.level.block;
|
||||
|
||||
flag5 |= flag6 && flag7;
|
||||
- if (k != i || !tripWireBeingRemoved || !flag6) // Paper - fix tripwire state inconsistency; don't update the tripwire again if being removed and not disarmed
|
||||
+ if (k != i || !tripWireBeingRemoved || !flag6 || me.earthme.luminol.config.modules.fixes.IncorrectTripwireFixConfig.enabled) // Paper - don't update the tripwire again if being removed and not disarmed //Luminol - Add config for incorrect tripwire updating fixing
|
||||
aiblockdata[k] = iblockdata2;
|
||||
if (k == i) {
|
||||
world.scheduleTick(pos, block, 10);
|
||||
import com.google.common.base.MoreObjects;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
@@ -147,7 +149,7 @@ public class TripWireHookBlock extends Block {
|
||||
boolean flag7 = (Boolean) iblockdata2.getValue(TripWireBlock.POWERED);
|
||||
|
||||
flag5 |= flag6 && flag7;
|
||||
- if (k != i || !tripWireBeingRemoved || !flag6) // Paper - don't update the tripwire again if being removed and not disarmed
|
||||
+ if (k != i || !tripWireBeingRemoved || !flag6 || LuminolConfig.allowIncorrectTripwireUpdating) // Paper - don't update the tripwire again if being removed and not disarmed //Luminol - Add config for incorrect tripwire updating fixing
|
||||
aiblockdata[k] = iblockdata2;
|
||||
if (k == i) {
|
||||
world.scheduleTick(pos, (Block) this, 10);
|
||||
|
||||
118
patches/server/0009-Add-config-for-chat-sign.patch
Normal file
118
patches/server/0009-Add-config-for-chat-sign.patch
Normal file
@@ -0,0 +1,118 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sat, 25 Nov 2023 18:31:24 +0800
|
||||
Subject: [PATCH] Add config for chat sign
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
|
||||
index 772e3a864e0e70288a1c010d8bbb809d34d16a41..68bd66aad880c81d1f8eaf88525597c878350961 100644
|
||||
--- a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
|
||||
+++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
|
||||
@@ -15,6 +15,8 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.Function;
|
||||
+
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.ForwardingAudience;
|
||||
import net.kyori.adventure.key.Key;
|
||||
@@ -355,7 +357,7 @@ public final class ChatProcessor {
|
||||
|
||||
private void sendToServer(final ChatType.Bound chatType, final @Nullable Function<Audience, net.minecraft.network.chat.Component> msgFunction) {
|
||||
final PlayerChatMessage toConsoleMessage = msgFunction == null ? ChatProcessor.this.message : ChatProcessor.this.message.withUnsignedContent(msgFunction.apply(ChatProcessor.this.server.console));
|
||||
- ChatProcessor.this.server.logChatMessage(toConsoleMessage.decoratedContent(), chatType, ChatProcessor.this.server.getPlayerList().verifyChatTrusted(toConsoleMessage) ? null : "Not Secure");
|
||||
+ ChatProcessor.this.server.logChatMessage(toConsoleMessage.decoratedContent(), chatType, ChatProcessor.this.server.getPlayerList().verifyChatTrusted(toConsoleMessage) || LuminolConfig.disableChatSign ? null : "Not Secure"); //Luminol - Add config for chat sign
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index a49da370c91211d4e2274f72d62c911a1912296a..8d1ce8eae252fcf05b6a62d2dc467d6d503d3df4 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -13,6 +13,7 @@ public class LuminolConfig {
|
||||
|
||||
public static String serverModName = "Luminol";
|
||||
public static boolean fakeVanillaModeEnabled = false;
|
||||
+ public static boolean disableChatSign = false;
|
||||
|
||||
public static boolean safeTeleportation = true;
|
||||
public static boolean enableSandDuping = false;
|
||||
@@ -36,6 +37,7 @@ public class LuminolConfig {
|
||||
public static void initValues(){
|
||||
serverModName = get("misc.server_mod_name",serverModName,"The servermod name will be sent to players,and you can see it in F3 or motd responses");
|
||||
fakeVanillaModeEnabled = get("misc.enable_fake_vanilla_mode",fakeVanillaModeEnabled,"Enable this to make the ping response of your server like a vanilla server");
|
||||
+ disableChatSign = get("misc.disable_chat_sign",disableChatSign,"Set this to true to disable mojang's chat sign");
|
||||
|
||||
safeTeleportation = get("fixes.enable_safe_teleportation",safeTeleportation,"If this enabled,the end portals will not teleport removed entities.");
|
||||
enableSandDuping = get("fixes.enable_sand_duping",enableSandDuping,"If this enabled,The value of safe teleportation will always be false and sand duping will be enabled");
|
||||
diff --git a/src/main/java/net/minecraft/commands/arguments/ArgumentSignatures.java b/src/main/java/net/minecraft/commands/arguments/ArgumentSignatures.java
|
||||
index 72a8aa676836fcb3b4578689d16af65e18f55bbe..04653d58f2493d796e61bc97f0481cb628539c37 100644
|
||||
--- a/src/main/java/net/minecraft/commands/arguments/ArgumentSignatures.java
|
||||
+++ b/src/main/java/net/minecraft/commands/arguments/ArgumentSignatures.java
|
||||
@@ -4,6 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.MessageSignature;
|
||||
import net.minecraft.network.chat.SignableCommand;
|
||||
@@ -14,8 +16,16 @@ public record ArgumentSignatures(List<ArgumentSignatures.Entry> entries) {
|
||||
private static final int MAX_ARGUMENT_NAME_LENGTH = 16;
|
||||
|
||||
public ArgumentSignatures(FriendlyByteBuf buf) {
|
||||
- this(buf.readCollection(FriendlyByteBuf.limitValue(ArrayList::new, 8), ArgumentSignatures.Entry::new));
|
||||
+ this(readSign(buf));
|
||||
+ }
|
||||
+
|
||||
+ //Luminol start - Add config for chat sign
|
||||
+ private static List<ArgumentSignatures.Entry> readSign(FriendlyByteBuf buf) {
|
||||
+ var entries = buf.readCollection(FriendlyByteBuf.limitValue(ArrayList::new, 8), Entry::new);
|
||||
+ return LuminolConfig.disableChatSign ? List.of() : entries;
|
||||
}
|
||||
+ //Luminol end
|
||||
+
|
||||
|
||||
@Nullable
|
||||
public MessageSignature get(String argumentName) {
|
||||
diff --git a/src/main/java/net/minecraft/network/FriendlyByteBuf.java b/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
||||
index 2e395962b555bef0ce1a98e1d768e7738f011535..11a9bc78c34b9f6bfff1ebf979be55b9bbbbed55 100644
|
||||
--- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
||||
+++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
||||
@@ -48,6 +48,8 @@ import java.util.function.Function;
|
||||
import java.util.function.IntFunction;
|
||||
import java.util.function.ToIntFunction;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -65,6 +67,7 @@ import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
+import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Crypt;
|
||||
@@ -137,6 +140,17 @@ public class FriendlyByteBuf extends ByteBuf {
|
||||
public <T> void writeJsonWithCodec(Codec<T> codec, T value) {
|
||||
DataResult<JsonElement> dataresult = codec.encodeStart(JsonOps.INSTANCE, value);
|
||||
|
||||
+
|
||||
+ //Luminol start - Add config for chat sign
|
||||
+ if (codec == ServerStatus.CODEC) {
|
||||
+ JsonElement element = Util.getOrThrow(dataresult, string -> new EncoderException("Failed to encode: " + string + " " + value));
|
||||
+ element.getAsJsonObject().addProperty("preventsChatReports", LuminolConfig.disableChatSign);
|
||||
+
|
||||
+ this.writeUtf(GSON.toJson(element));
|
||||
+ return;
|
||||
+ }
|
||||
+ //Luminol end
|
||||
+
|
||||
this.writeUtf(FriendlyByteBuf.GSON.toJson((JsonElement) Util.getOrThrow(dataresult, (s) -> {
|
||||
return new EncoderException("Failed to encode: " + s + " " + value);
|
||||
})));
|
||||
@@ -1,45 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 02:33:00 +0000
|
||||
Subject: [PATCH] Add config for vanilla random
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/VanillaRandomSourceConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/VanillaRandomSourceConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ee247014c9a2ec1bbb7f25ef41da110a270154d6
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/VanillaRandomSourceConfig.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 VanillaRandomSourceConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enable_for_player_entity")
|
||||
+ public static boolean useLegacyRandomSourceForPlayers = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.FIXES;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "use_vanilla_random_source";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 6b560754382936d4889e5729613077a3401d8740..865804a16fce714497b2c025a869f972787442e3 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -563,7 +563,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
this.bb = Entity.INITIAL_AABB;
|
||||
this.stuckSpeedMultiplier = Vec3.ZERO;
|
||||
this.nextStep = 1.0F;
|
||||
- this.random = SHARED_RANDOM; // Paper - Share random for entities to make them more random
|
||||
+ this.random = me.earthme.luminol.config.modules.fixes.VanillaRandomSourceConfig.useLegacyRandomSourceForPlayers ? RandomSource.create() : SHARED_RANDOM;//Luminol - Add config for vanilla random SHARED_RANDOM // Paper - Share random for entities to make them more random
|
||||
this.remainingFireTicks = -this.getFireImmuneTicks();
|
||||
this.fluidHeight = new Object2DoubleArrayMap(2);
|
||||
this.fluidOnEyes = new HashSet();
|
||||
@@ -1,76 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 02:00:50 +0000
|
||||
Subject: [PATCH] Add config for chat sign
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/ChatSignConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/ChatSignConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..1e03e51e51f56c38abaad100274e25c9f854f727
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/ChatSignConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.misc;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class ChatSignConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = true;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "mojang_chat_sign";
|
||||
+ }
|
||||
+}
|
||||
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
|
||||
--- a/src/main/java/net/minecraft/commands/arguments/ArgumentSignatures.java
|
||||
+++ b/src/main/java/net/minecraft/commands/arguments/ArgumentSignatures.java
|
||||
@@ -14,9 +14,17 @@ public record ArgumentSignatures(List<ArgumentSignatures.Entry> entries) {
|
||||
private static final int MAX_ARGUMENT_NAME_LENGTH = 16;
|
||||
|
||||
public ArgumentSignatures(FriendlyByteBuf buf) {
|
||||
- this(buf.readCollection(FriendlyByteBuf.limitValue(ArrayList::new, 8), ArgumentSignatures.Entry::new));
|
||||
+ this(readSign(buf)); //Luminol - Fix java compile
|
||||
}
|
||||
|
||||
+ //Luminol start - Add config for chat sign
|
||||
+ private static List<ArgumentSignatures.Entry> readSign(FriendlyByteBuf buf) {
|
||||
+ var entries = buf.readCollection(FriendlyByteBuf.limitValue(ArrayList::new, 8), Entry::new);
|
||||
+ return me.earthme.luminol.config.modules.misc.ChatSignConfig.enabled ? List.of() : entries;
|
||||
+ }
|
||||
+ //Luminol end
|
||||
+
|
||||
+
|
||||
@Nullable
|
||||
public MessageSignature get(String argumentName) {
|
||||
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
|
||||
index b863249ff7e13cf4939c8961601f0564c62fd661..6ab73b0568c3f9df8090be992736a14d49e0286c 100644
|
||||
--- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
||||
+++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
||||
@@ -143,6 +143,16 @@ public class FriendlyByteBuf extends ByteBuf {
|
||||
// Paper end - Adventure; add max length parameter
|
||||
DataResult<JsonElement> dataresult = codec.encodeStart(JsonOps.INSTANCE, value);
|
||||
|
||||
+ //Luminol start - Add config for chat sign
|
||||
+ if (codec == net.minecraft.network.protocol.status.ServerStatus.CODEC) {
|
||||
+ JsonElement element = Util.getOrThrow(dataresult, string -> new EncoderException("Failed to encode: " + string + " " + value));
|
||||
+ element.getAsJsonObject().addProperty("preventsChatReports", !me.earthme.luminol.config.modules.misc.ChatSignConfig.enabled);
|
||||
+
|
||||
+ this.writeUtf(GSON.toJson(element));
|
||||
+ return;
|
||||
+ }
|
||||
+ //Luminol end
|
||||
+
|
||||
this.writeUtf(FriendlyByteBuf.GSON.toJson((JsonElement) Util.getOrThrow(dataresult, (s) -> {
|
||||
return new EncoderException("Failed to encode: " + s + " " + value);
|
||||
})), maxLength); // Paper - Adventure; add max length parameter
|
||||
39
patches/server/0010-Add-config-for-vanilla-random.patch
Normal file
39
patches/server/0010-Add-config-for-vanilla-random.patch
Normal file
@@ -0,0 +1,39 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sat, 25 Nov 2023 19:03:34 +0800
|
||||
Subject: [PATCH] Add config for vanilla random
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index 8d1ce8eae252fcf05b6a62d2dc467d6d503d3df4..89d8ffc947d265e0e81943ad851e868b622de168 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -19,6 +19,7 @@ public class LuminolConfig {
|
||||
public static boolean enableSandDuping = false;
|
||||
public static boolean enableVoidTrading = false;
|
||||
public static boolean allowIncorrectTripwireUpdating = false;
|
||||
+ public static boolean useVanillaRandomSource = false;
|
||||
|
||||
public static void init() throws IOException {
|
||||
PARENT_FOLDER.mkdir();
|
||||
@@ -43,6 +44,7 @@ public class LuminolConfig {
|
||||
enableSandDuping = get("fixes.enable_sand_duping",enableSandDuping,"If this enabled,The value of safe teleportation will always be false and sand duping will be enabled");
|
||||
enableVoidTrading = get("fixes.enable_void_trading",enableVoidTrading);
|
||||
allowIncorrectTripwireUpdating = get("fixes.allow_incorrect_trip_wire_updaing",allowIncorrectTripwireUpdating);
|
||||
+ useVanillaRandomSource = get("fixes.use_vanilla_random_source",useVanillaRandomSource,"RNG feature related");
|
||||
}
|
||||
|
||||
public static <T> T get(String key,T def){
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index e357ed9607889536ecd0e6ea8b59c97d3dab631f..cb32a3851a315f1f1b4fb6d26fdffbcb471bfc06 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -569,7 +569,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
this.bb = Entity.INITIAL_AABB;
|
||||
this.stuckSpeedMultiplier = Vec3.ZERO;
|
||||
this.nextStep = 1.0F;
|
||||
- this.random = SHARED_RANDOM; // Paper
|
||||
+ this.random = LuminolConfig.useVanillaRandomSource ? RandomSource.create() : SHARED_RANDOM;//Luminol - Add config for vanilla random SHARED_RANDOM; // Paper
|
||||
this.remainingFireTicks = -this.getFireImmuneTicks();
|
||||
this.fluidHeight = new Object2DoubleArrayMap(2);
|
||||
this.fluidOnEyes = new HashSet();
|
||||
@@ -1,45 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 04:50:10 +0000
|
||||
Subject: [PATCH] Add config for username check
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/UsernameCheckConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/UsernameCheckConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..c7e4724cc4ab8d911bcaf0106c098b266c843bb1
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/UsernameCheckConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.misc;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class UsernameCheckConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = true;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "username_checks";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
index aa4b461bbb2c8c4753f7c9057bab1740de2c0284..1ff6c82925417932df856bf1e5866519327f018e 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
@@ -143,7 +143,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||
@Override
|
||||
public void handleHello(ServerboundHelloPacket packet) {
|
||||
Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet", new Object[0]);
|
||||
- if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation && !this.iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation) Validate.validState(Player.isValidUsername(packet.name()), "Invalid characters in username", new Object[0]); // Paper - config username validation
|
||||
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation && !this.iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation && me.earthme.luminol.config.modules.misc.UsernameCheckConfig.enabled) Validate.validState(Player.isValidUsername(packet.name()), "Invalid characters in username", new Object[0]); // Paper - config username validation //Luminol - Add config for username check
|
||||
this.requestedUsername = packet.name();
|
||||
GameProfile gameprofile = this.server.getSingleplayerProfile();
|
||||
|
||||
25
patches/server/0012-Add-logger-field-to-LuminolConfig.patch
Normal file
25
patches/server/0012-Add-logger-field-to-LuminolConfig.patch
Normal file
@@ -0,0 +1,25 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sat, 25 Nov 2023 19:26:01 +0800
|
||||
Subject: [PATCH] Add logger field to LuminolConfig
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index 89d8ffc947d265e0e81943ad851e868b622de168..74573c50c903cfbe5f9617be5b75c21647f05a91 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -2,11 +2,14 @@ package me.earthme.luminol;
|
||||
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
+import org.apache.logging.log4j.LogManager;
|
||||
+import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class LuminolConfig {
|
||||
+ private static final Logger logger = LogManager.getLogger();
|
||||
private static final File PARENT_FOLDER = new File("luminol_config");
|
||||
private static final File MAIN_CONFIG_FILE = new File(PARENT_FOLDER,"luminol_global.toml");
|
||||
private static CommentedFileConfig MAIN_CONFIG;
|
||||
@@ -1,45 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 06:40:44 +0000
|
||||
Subject: [PATCH] Add config for offline mode warning
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/OfflineModeWarningConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/OfflineModeWarningConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..502b93c7bda9e8577a1901a8777b7cf9b9bdc36b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/OfflineModeWarningConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.misc;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class OfflineModeWarningConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = true;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "warn_on_offline_mode";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index ea3b3f8b2318b8a1e8975e89c90cab05c6ab2835..dd0d8ba5087532770358416be72bb0215b265180 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -283,7 +283,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
String proxyFlavor = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "Velocity" : "BungeeCord";
|
||||
String proxyLink = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "https://docs.papermc.io/velocity/security" : "http://www.spigotmc.org/wiki/firewall-guide/";
|
||||
// Paper end - Add Velocity IP Forwarding Support
|
||||
- if (!this.usesAuthentication()) {
|
||||
+ if (!this.usesAuthentication() && !me.earthme.luminol.config.modules.misc.OfflineModeWarningConfig.enabled) { //Luminol - Add config for offline mod warning
|
||||
DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
|
||||
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
|
||||
// Spigot start
|
||||
98
patches/server/0013-Kaiiju-region-format-settings.patch
Normal file
98
patches/server/0013-Kaiiju-region-format-settings.patch
Normal file
@@ -0,0 +1,98 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sat, 25 Nov 2023 21:28:45 +0800
|
||||
Subject: [PATCH] Kaiiju region format settings
|
||||
|
||||
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/RegionFileFormat.java b/src/main/java/dev/kaiijumc/kaiiju/region/RegionFileFormat.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7164d9cd03186f0657783f83de3d6435cda2b17e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/RegionFileFormat.java
|
||||
@@ -0,0 +1,16 @@
|
||||
+package dev.kaiijumc.kaiiju.region;
|
||||
+
|
||||
+public enum RegionFileFormat {
|
||||
+ ANVIL,
|
||||
+ LINEAR,
|
||||
+ INVALID;
|
||||
+
|
||||
+ public static RegionFileFormat fromString(String format) {
|
||||
+ for (RegionFileFormat rff : values()) {
|
||||
+ if (rff.name().equalsIgnoreCase(format)) {
|
||||
+ return rff;
|
||||
+ }
|
||||
+ }
|
||||
+ return RegionFileFormat.INVALID;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index 74573c50c903cfbe5f9617be5b75c21647f05a91..3d526d7cfb313e419de89be1b275651982be42c7 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -1,10 +1,13 @@
|
||||
package me.earthme.luminol;
|
||||
|
||||
+import dev.kaiijumc.kaiiju.region.RegionFileFormat;
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+import java.util.Arrays;
|
||||
+import java.util.logging.Level;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -24,6 +27,9 @@ public class LuminolConfig {
|
||||
public static boolean allowIncorrectTripwireUpdating = false;
|
||||
public static boolean useVanillaRandomSource = false;
|
||||
|
||||
+ public static RegionFileFormat regionFormatName = RegionFileFormat.ANVIL;
|
||||
+ public static int regionFormatLinearCompressionLevel = 1;
|
||||
+
|
||||
public static void init() throws IOException {
|
||||
PARENT_FOLDER.mkdir();
|
||||
|
||||
@@ -48,6 +54,19 @@ public class LuminolConfig {
|
||||
enableVoidTrading = get("fixes.enable_void_trading",enableVoidTrading);
|
||||
allowIncorrectTripwireUpdating = get("fixes.allow_incorrect_trip_wire_updaing",allowIncorrectTripwireUpdating);
|
||||
useVanillaRandomSource = get("fixes.use_vanilla_random_source",useVanillaRandomSource,"RNG feature related");
|
||||
+
|
||||
+ regionFormatName = RegionFileFormat.fromString(get("save.region-format.format", regionFormatName.name()));
|
||||
+ if (regionFormatName.equals(RegionFileFormat.INVALID)) {
|
||||
+ logger.error("Unknown region format in luminol global config: " + regionFormatName);
|
||||
+ logger.error("Falling back to ANVIL region file format.");
|
||||
+ regionFormatName = RegionFileFormat.ANVIL;
|
||||
+ }
|
||||
+ regionFormatLinearCompressionLevel = get("save.region-format.linear.compression-level", regionFormatLinearCompressionLevel);
|
||||
+ if (regionFormatLinearCompressionLevel > 23 || regionFormatLinearCompressionLevel < 1) {
|
||||
+ logger.error("Linear region compression level should be between 1 and 22 in luminol global config: " + regionFormatLinearCompressionLevel);
|
||||
+ logger.error("Falling back to compression level 1.");
|
||||
+ regionFormatLinearCompressionLevel = 1;
|
||||
+ }
|
||||
}
|
||||
|
||||
public static <T> T get(String key,T def){
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 03165a7791aeac54e44391bbb0f432b613369bfa..675bbf1f69011f7f95fabc050c9877d6e70070b2 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -882,7 +882,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
// Paper start - rewrite chunk system
|
||||
worldserver.save((ProgressListener) null, flush, worldserver.noSave && !force, close);
|
||||
if (flush) {
|
||||
- MinecraftServer.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", worldserver.getChunkSource().chunkMap.getStorageName());
|
||||
+ MinecraftServer.LOGGER.info("ThreadedChunkStorage ({}): All chunks are saved", worldserver.getChunkSource().chunkMap.getStorageName()); // Kaiiju
|
||||
}
|
||||
// Paper end - rewrite chunk system
|
||||
}
|
||||
@@ -906,7 +906,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
//MinecraftServer.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", worldserver2.getChunkSource().chunkMap.getStorageName()); // Paper - move up
|
||||
}
|
||||
|
||||
- MinecraftServer.LOGGER.info("ThreadedAnvilChunkStorage: All dimensions are saved");
|
||||
+ MinecraftServer.LOGGER.info("ThreadedChunkStorage: All dimensions are saved"); // Kaiiju
|
||||
}
|
||||
|
||||
return flag3;
|
||||
@@ -1,45 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Tue, 20 Feb 2024 13:10:07 +0000
|
||||
Subject: [PATCH] Add config for out-of-order chat checks
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/InorderChatConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/InorderChatConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..83176a8a7e993b51a0663b0f76161884abbf4951
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/InorderChatConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.misc;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class InorderChatConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = true;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "mojang_out_of_order_chat_check";
|
||||
+ }
|
||||
+}
|
||||
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
|
||||
--- a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||||
@@ -38,7 +38,7 @@ public class SignedMessageChain {
|
||||
throw new SignedMessageChain.DecodeException(Component.translatable("chat.disabled.chain_broken"), false); // Paper - diff on change (if disconnects, need a new kick event cause)
|
||||
} else if (playerPublicKey.data().hasExpired()) {
|
||||
throw new SignedMessageChain.DecodeException(Component.translatable("chat.disabled.expiredProfileKey"), false, org.bukkit.event.player.PlayerKickEvent.Cause.EXPIRED_PROFILE_PUBLIC_KEY); // Paper - kick event causes
|
||||
- } else if (body.timeStamp().isBefore(this.lastTimeStamp)) {
|
||||
+ } else if (me.earthme.luminol.config.modules.misc.InorderChatConfig.enabled && body.timeStamp().isBefore(this.lastTimeStamp)) { // Luminol - Add config for out-of-order chat checks
|
||||
throw new SignedMessageChain.DecodeException(Component.translatable("multiplayer.disconnect.out_of_order_chat"), true, org.bukkit.event.player.PlayerKickEvent.Cause.OUT_OF_ORDER_CHAT); // Paper - kick event causes
|
||||
} else {
|
||||
this.lastTimeStamp = body.timeStamp();
|
||||
@@ -1,24 +1,39 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 03:11:28 +0000
|
||||
Subject: [PATCH] Kaiiju linear region format and settings
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 11:30:57 +0800
|
||||
Subject: [PATCH] Kaiiju Add linear region format
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 3a787b0afa3a34f23f1c18fb5250a5ff4bcd2f96..18326989bfccea2c6d292b0020aab711438031c8 100644
|
||||
index 54d761d7e4733c12fbb4957acd509d278ae11316..8a926993088d33983f75071b3320dd67c3e857c3 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -20,6 +20,10 @@ dependencies {
|
||||
@@ -19,6 +19,10 @@ dependencies {
|
||||
exclude("io.papermc.paper", "paper-api")
|
||||
}
|
||||
// Folia end
|
||||
implementation("com.electronwill.night-config:toml:3.6.6") //Luminol - Night config
|
||||
+ // Kaiiju start - Linear format
|
||||
+ implementation("com.github.luben:zstd-jni:1.5.4-1")
|
||||
+ implementation("org.lz4:lz4-java:1.8.0")
|
||||
+ // Kaiiju end
|
||||
implementation("com.electronwill.night-config:toml:3.6.0") //Luminol - Night config
|
||||
// Paper start
|
||||
implementation("org.jline:jline-terminal-jansi:3.21.0")
|
||||
implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/io/PaperFileIOThread.java b/src/main/java/com/destroystokyo/paper/io/PaperFileIOThread.java
|
||||
index f2c27e0ac65be4b75c1d86ef6fd45fdb538d96ac..00724993d0448454d14a47652b039b88052b8a4f 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/io/PaperFileIOThread.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/io/PaperFileIOThread.java
|
||||
@@ -314,8 +314,8 @@ public final class PaperFileIOThread extends QueueExecutorThread {
|
||||
public abstract void writeData(final int x, final int z, final CompoundTag compound) throws IOException;
|
||||
public abstract CompoundTag readData(final int x, final int z) throws IOException;
|
||||
|
||||
- public abstract <T> T computeForRegionFile(final int chunkX, final int chunkZ, final Function<RegionFile, T> function);
|
||||
- public abstract <T> T computeForRegionFileIfLoaded(final int chunkX, final int chunkZ, final Function<RegionFile, T> function);
|
||||
+ public abstract <T> T computeForRegionFile(final int chunkX, final int chunkZ, final Function<dev.kaiijumc.kaiiju.region.AbstractRegionFile, T> function); // Kaiiju
|
||||
+ public abstract <T> T computeForRegionFileIfLoaded(final int chunkX, final int chunkZ, final Function<dev.kaiijumc.kaiiju.region.AbstractRegionFile, T> function); // Kaiiju
|
||||
|
||||
public static final class InProgressWrite {
|
||||
public long writeCounter;
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFile.java b/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFile.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..249303116d3cfadd078ebf0ae6e44bf99eed6a47
|
||||
@@ -415,15 +430,16 @@ index 0000000000000000000000000000000000000000..e40989889f3821bb7484fc0bae5d94b0
|
||||
+}
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFileFlusher.java b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFileFlusher.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..f06d7767c79e465f999b2032086cc224de95152a
|
||||
index 0000000000000000000000000000000000000000..e800c6103396530efe5acd0b4081a3cd05b62b68
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFileFlusher.java
|
||||
@@ -0,0 +1,44 @@
|
||||
@@ -0,0 +1,45 @@
|
||||
+package dev.kaiijumc.kaiiju.region;
|
||||
+
|
||||
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
+import java.util.Queue;
|
||||
+import java.util.concurrent.*;
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
+import org.bukkit.Bukkit;
|
||||
+
|
||||
+public class LinearRegionFileFlusher {
|
||||
@@ -434,15 +450,15 @@ index 0000000000000000000000000000000000000000..f06d7767c79e465f999b2032086cc224
|
||||
+ .build()
|
||||
+ );
|
||||
+ private final ExecutorService executor = Executors.newFixedThreadPool(
|
||||
+ me.earthme.luminol.config.modules.misc.RegionFormatConfig.linearFlushThreads,
|
||||
+ LuminolConfig.linearFlushThreads,
|
||||
+ new ThreadFactoryBuilder()
|
||||
+ .setNameFormat("linear-flusher-%d")
|
||||
+ .build()
|
||||
+ );
|
||||
+
|
||||
+ public LinearRegionFileFlusher() {
|
||||
+ Bukkit.getLogger().info("Using " + me.earthme.luminol.config.modules.misc.RegionFormatConfig.linearFlushThreads + " threads for linear region flushing.");
|
||||
+ scheduler.scheduleAtFixedRate(this::pollAndFlush, 0L, me.earthme.luminol.config.modules.misc.RegionFormatConfig.linearFlushFrequency, TimeUnit.SECONDS);
|
||||
+ Bukkit.getLogger().info("Using " + LuminolConfig.linearFlushThreads + " threads for linear region flushing.");
|
||||
+ scheduler.scheduleAtFixedRate(this::pollAndFlush, 0L, LuminolConfig.linearFlushFrequency, TimeUnit.SECONDS);
|
||||
+ }
|
||||
+
|
||||
+ public void scheduleSave(LinearRegionFile regionFile) {
|
||||
@@ -463,33 +479,11 @@ index 0000000000000000000000000000000000000000..f06d7767c79e465f999b2032086cc224
|
||||
+ scheduler.shutdown();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/RegionFileFormat.java b/src/main/java/dev/kaiijumc/kaiiju/region/RegionFileFormat.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7164d9cd03186f0657783f83de3d6435cda2b17e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/RegionFileFormat.java
|
||||
@@ -0,0 +1,16 @@
|
||||
+package dev.kaiijumc.kaiiju.region;
|
||||
+
|
||||
+public enum RegionFileFormat {
|
||||
+ ANVIL,
|
||||
+ LINEAR,
|
||||
+ INVALID;
|
||||
+
|
||||
+ public static RegionFileFormat fromString(String format) {
|
||||
+ for (RegionFileFormat rff : values()) {
|
||||
+ if (rff.name().equalsIgnoreCase(format)) {
|
||||
+ return rff;
|
||||
+ }
|
||||
+ }
|
||||
+ return RegionFileFormat.INVALID;
|
||||
+ }
|
||||
+}
|
||||
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 2934f0cf0ef09c84739312b00186c2ef0019a165..b46acbc078f3d3bfb0f3ede3f1cc172f4b48c5df 100644
|
||||
index 8a11e10b01fa012b2f98b1c193c53251e848f909..61001e76b38f8647b33e73b5cc15b4b6785cf49a 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
|
||||
@@ -816,7 +816,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
@@ -811,7 +811,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
final ChunkDataController taskController) {
|
||||
final ChunkPos chunkPos = new ChunkPos(chunkX, chunkZ);
|
||||
if (intendingToBlock) {
|
||||
@@ -498,7 +492,7 @@ index 2934f0cf0ef09c84739312b00186c2ef0019a165..b46acbc078f3d3bfb0f3ede3f1cc172f
|
||||
if (file == null) { // null if no regionfile exists
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
@@ -829,7 +829,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
@@ -824,7 +824,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
return Boolean.FALSE;
|
||||
} // else: it either exists or is not known, fall back to checking the loaded region file
|
||||
|
||||
@@ -507,7 +501,7 @@ index 2934f0cf0ef09c84739312b00186c2ef0019a165..b46acbc078f3d3bfb0f3ede3f1cc172f
|
||||
if (file == null) { // null if not loaded
|
||||
// not sure at this point, let the I/O thread figure it out
|
||||
return Boolean.TRUE;
|
||||
@@ -1131,9 +1131,9 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
@@ -1126,9 +1126,9 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
return this.getCache().doesRegionFileNotExistNoIO(new ChunkPos(chunkX, chunkZ));
|
||||
}
|
||||
|
||||
@@ -519,7 +513,7 @@ index 2934f0cf0ef09c84739312b00186c2ef0019a165..b46acbc078f3d3bfb0f3ede3f1cc172f
|
||||
synchronized (cache) {
|
||||
try {
|
||||
regionFile = cache.getRegionFile(new ChunkPos(chunkX, chunkZ), existingOnly, true);
|
||||
@@ -1146,19 +1146,19 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
@@ -1141,19 +1141,19 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
return function.apply(regionFile);
|
||||
} finally {
|
||||
if (regionFile != null) {
|
||||
@@ -543,7 +537,7 @@ index 2934f0cf0ef09c84739312b00186c2ef0019a165..b46acbc078f3d3bfb0f3ede3f1cc172f
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1166,7 +1166,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
@@ -1161,7 +1161,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
|
||||
return function.apply(regionFile);
|
||||
} finally {
|
||||
if (regionFile != null) {
|
||||
@@ -553,7 +547,7 @@ index 2934f0cf0ef09c84739312b00186c2ef0019a165..b46acbc078f3d3bfb0f3ede3f1cc172f
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java b/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
||||
index 9017907c0ec67a37a506f09b7e4499cef7885279..8b9ffcaab5d71660291d1c0454d2abd969d8c6ae 100644
|
||||
index 513833c2ea23df5b079d157bc5cb89d5c9754c0b..bd377033987bf7ded03016d1d8f05fd039bffbb5 100644
|
||||
--- a/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
||||
+++ b/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
||||
@@ -84,8 +84,13 @@ public class ThreadedWorldUpgrader {
|
||||
@@ -561,8 +555,8 @@ index 9017907c0ec67a37a506f09b7e4499cef7885279..8b9ffcaab5d71660291d1c0454d2abd9
|
||||
LOGGER.info("Starting conversion now for world " + this.worldName);
|
||||
|
||||
+ // Kaiiju start
|
||||
+ dev.kaiijumc.kaiiju.region.RegionFileFormat formatName = me.earthme.luminol.config.modules.misc.RegionFormatConfig.regionFormatName;
|
||||
+ int linearCompression = me.earthme.luminol.config.modules.misc.RegionFormatConfig.regionFormatLinearCompressionLevel;
|
||||
+ dev.kaiijumc.kaiiju.region.RegionFileFormat formatName = me.earthme.luminol.LuminolConfig.regionFormatName;
|
||||
+ int linearCompression = me.earthme.luminol.LuminolConfig.regionFormatLinearCompressionLevel;
|
||||
+ LOGGER.info("Using format " + formatName + " (" + linearCompression + ")");
|
||||
+ // Kaiiju end
|
||||
final WorldInfo info = new WorldInfo(() -> worldPersistentData,
|
||||
@@ -571,109 +565,57 @@ index 9017907c0ec67a37a506f09b7e4499cef7885279..8b9ffcaab5d71660291d1c0454d2abd9
|
||||
|
||||
long expectedChunks = (long)regionFiles.length * (32L * 32L);
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/RegionFormatConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/RegionFormatConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..5219ef799585db502a19e79145b971365a736277
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/RegionFormatConfig.java
|
||||
@@ -0,0 +1,50 @@
|
||||
+package me.earthme.luminol.config.modules.misc;
|
||||
+
|
||||
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import dev.kaiijumc.kaiiju.region.RegionFileFormat;
|
||||
+import me.earthme.luminol.config.*;
|
||||
+
|
||||
+public class RegionFormatConfig implements IConfigModule {
|
||||
+ @DoNotLoad
|
||||
+ public static RegionFileFormat regionFormatName = RegionFileFormat.ANVIL;
|
||||
+
|
||||
+ @ConfigInfo(baseName = "formatName")
|
||||
+ private static String formatName = "ANVIL";
|
||||
+ @ConfigInfo(baseName = "linear_compression_level")
|
||||
+ public static int regionFormatLinearCompressionLevel = 1;
|
||||
+ @ConfigInfo(baseName = "linear_flusher_thread_count")
|
||||
+ public static int linearFlushThreads = 1;
|
||||
+ @ConfigInfo(baseName = "linear_flush_frequency")
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index 3d526d7cfb313e419de89be1b275651982be42c7..90a6cfd011aaefe66fda79f887380ab2d62a07b1 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -29,6 +29,8 @@ public class LuminolConfig {
|
||||
|
||||
public static RegionFileFormat regionFormatName = RegionFileFormat.ANVIL;
|
||||
public static int regionFormatLinearCompressionLevel = 1;
|
||||
+ public static int linearFlushFrequency = 10;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "region_format";
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onLoaded(CommentedFileConfig configInstance){
|
||||
+ regionFormatName = RegionFileFormat.fromString(formatName);
|
||||
+ if (regionFormatName.equals(RegionFileFormat.INVALID)) {
|
||||
+ LuminolConfig.logger.error("Unknown region format in luminol global config: {}", formatName);
|
||||
+ LuminolConfig.logger.error("Falling back to ANVIL region file format.");
|
||||
+ regionFormatName = RegionFileFormat.ANVIL;
|
||||
+ }
|
||||
+
|
||||
+ if (regionFormatLinearCompressionLevel > 23 || regionFormatLinearCompressionLevel < 1) {
|
||||
+ LuminolConfig.logger.error("Linear region compression level should be between 1 and 22 in luminol global config: {}", regionFormatLinearCompressionLevel);
|
||||
+ LuminolConfig.logger.error("Falling back to compression level 1.");
|
||||
+ regionFormatLinearCompressionLevel = 1;
|
||||
+ }
|
||||
+
|
||||
+ public static int linearFlushThreads = 1;
|
||||
|
||||
public static void init() throws IOException {
|
||||
PARENT_FOLDER.mkdir();
|
||||
@@ -67,6 +69,12 @@ public class LuminolConfig {
|
||||
logger.error("Falling back to compression level 1.");
|
||||
regionFormatLinearCompressionLevel = 1;
|
||||
}
|
||||
+ linearFlushFrequency = get("save.region-format.linear.flush-frequency", linearFlushFrequency);
|
||||
+ linearFlushThreads = get("save.region-format.linear.flush-max-threads", linearFlushThreads);
|
||||
+ if (linearFlushThreads < 0)
|
||||
+ linearFlushThreads = Math.max(Runtime.getRuntime().availableProcessors() + linearFlushThreads, 1);
|
||||
+ else
|
||||
+ linearFlushThreads = Math.max(linearFlushThreads, 1);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 4468e6fdbbe527111f4410188f2f2df7f592f81e..13ad20b3d43cc22ad1046220b24272dd274de997 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -923,7 +923,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
// Paper start - rewrite chunk system
|
||||
worldserver.save((ProgressListener) null, flush, worldserver.noSave && !force, close);
|
||||
if (flush) {
|
||||
- MinecraftServer.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", worldserver.getChunkSource().chunkMap.getStorageName());
|
||||
+ MinecraftServer.LOGGER.info("ThreadedChunkStorage ({}): All chunks are saved", worldserver.getChunkSource().chunkMap.getStorageName()); // Kaiiju
|
||||
}
|
||||
// Paper end - rewrite chunk system
|
||||
}
|
||||
@@ -947,7 +947,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
//MinecraftServer.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", worldserver2.getChunkSource().chunkMap.getStorageName()); // Paper - move up
|
||||
}
|
||||
}
|
||||
|
||||
- MinecraftServer.LOGGER.info("ThreadedAnvilChunkStorage: All dimensions are saved");
|
||||
+ MinecraftServer.LOGGER.info("ThreadedChunkStorage: All dimensions are saved"); // Kaiiju
|
||||
}
|
||||
|
||||
return flag3;
|
||||
public static <T> T get(String key,T def){
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index 21ec49acb3c1241d9286959c42a7f8363f637e4f..c212030a24174115a975604b91d03cf8ad4043de 100644
|
||||
index 50597a8b45bbd7dcc40b361da78358d9d01f5484..4709782f3e858edfa6ce25696462eb45909885ee 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -211,7 +211,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -212,7 +212,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
// Paper end - optimise chunk tick iteration
|
||||
|
||||
public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor executor, BlockableEventLoop<Runnable> mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier<DimensionDataStorage> persistentStateManagerFactory, int viewDistance, boolean dsync) {
|
||||
- super(session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync);
|
||||
+ super(me.earthme.luminol.config.modules.misc.RegionFormatConfig.regionFormatName, me.earthme.luminol.config.modules.misc.RegionFormatConfig.regionFormatLinearCompressionLevel, session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync); // Kaiiju
|
||||
+ super(me.earthme.luminol.LuminolConfig.regionFormatName, me.earthme.luminol.LuminolConfig.regionFormatLinearCompressionLevel, session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync); // Kaiiju
|
||||
// Paper - rewrite chunk system
|
||||
this.tickingGenerated = new AtomicInteger();
|
||||
//this.playerMap = new PlayerMap(); // Folia - region threading
|
||||
@@ -256,7 +256,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -257,7 +257,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
this.lightEngine = new ThreadedLevelLightEngine(chunkProvider, this, this.level.dimensionType().hasSkyLight(), null, null); // Paper - rewrite chunk system
|
||||
this.distanceManager = new ChunkMap.ChunkDistanceManager(executor, mainThreadExecutor);
|
||||
this.overworldDataStorage = persistentStateManagerFactory;
|
||||
- this.poiManager = new PoiManager(path.resolve("poi"), dataFixer, dsync, iregistrycustom, world);
|
||||
+ this.poiManager = new PoiManager(me.earthme.luminol.config.modules.misc.RegionFormatConfig.regionFormatName, me.earthme.luminol.config.modules.misc.RegionFormatConfig.regionFormatLinearCompressionLevel, path.resolve("poi"), dataFixer, dsync, iregistrycustom, world); // Kaiiju
|
||||
+ this.poiManager = new PoiManager(me.earthme.luminol.LuminolConfig.regionFormatName, me.earthme.luminol.LuminolConfig.regionFormatLinearCompressionLevel, path.resolve("poi"), dataFixer, dsync, iregistrycustom, world); // Kaiiju
|
||||
this.setServerViewDistance(viewDistance);
|
||||
// Paper start
|
||||
this.dataRegionManager = new io.papermc.paper.chunk.SingleThreadChunkRegionManager(this.level, 2, (1.0 / 3.0), 1, 6, "Data", DataRegionData::new, DataRegionSectionData::new);
|
||||
@@ -808,13 +808,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
}
|
||||
@@ -823,13 +823,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
|
||||
// Paper start - chunk status cache "api"
|
||||
public ChunkStatus getChunkStatusOnDiskIfCached(ChunkPos chunkPos) {
|
||||
- net.minecraft.world.level.chunk.storage.RegionFile regionFile = regionFileCache.getRegionFileIfLoaded(chunkPos);
|
||||
+ dev.kaiijumc.kaiiju.region.AbstractRegionFile regionFile = regionFileCache.getRegionFileIfLoaded(chunkPos); // Kaiiju
|
||||
@@ -687,7 +629,7 @@ index 21ec49acb3c1241d9286959c42a7f8363f637e4f..c212030a24174115a975604b91d03cf8
|
||||
|
||||
if (regionFile == null || !regionFileCache.chunkExists(chunkPos)) {
|
||||
return null;
|
||||
@@ -832,7 +832,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -847,7 +847,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
}
|
||||
|
||||
public void updateChunkStatusOnDisk(ChunkPos chunkPos, @Nullable CompoundTag compound) throws IOException {
|
||||
@@ -697,10 +639,10 @@ index 21ec49acb3c1241d9286959c42a7f8363f637e4f..c212030a24174115a975604b91d03cf8
|
||||
regionFile.setStatus(chunkPos.x, chunkPos.z, ChunkSerializer.getStatus(compound));
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 682ca5ec0aee427463d1a9f97292c6ea65ca2da0..c06ddc99a0971be46746c767ad8ce590a8e2ee30 100644
|
||||
index 722a5ec7f8e4995ac7025ca0785145d46bd66fcd..561681deaf647277ecde64eed4cfbd9f38b5fed1 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -446,8 +446,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
@@ -453,8 +453,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
|
||||
private static final class EntityRegionFileStorage extends net.minecraft.world.level.chunk.storage.RegionFileStorage {
|
||||
|
||||
@@ -711,22 +653,22 @@ index 682ca5ec0aee427463d1a9f97292c6ea65ca2da0..c06ddc99a0971be46746c767ad8ce590
|
||||
}
|
||||
|
||||
protected void write(ChunkPos pos, net.minecraft.nbt.CompoundTag nbt) throws IOException {
|
||||
@@ -808,7 +808,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
@@ -812,7 +812,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
// CraftBukkit end
|
||||
boolean flag2 = minecraftserver.forceSynchronousWrites();
|
||||
DataFixer datafixer = minecraftserver.getFixerUpper();
|
||||
- this.entityStorage = new EntityRegionFileStorage(convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), flag2); // Paper - rewrite chunk system //EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver);
|
||||
+ this.entityStorage = new EntityRegionFileStorage(me.earthme.luminol.config.modules.misc.RegionFormatConfig.regionFormatName, me.earthme.luminol.config.modules.misc.RegionFormatConfig.regionFormatLinearCompressionLevel, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), flag2); // Paper - rewrite chunk system //EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver); // Kaiiju
|
||||
+ this.entityStorage = new EntityRegionFileStorage(me.earthme.luminol.LuminolConfig.regionFormatName, me.earthme.luminol.LuminolConfig.regionFormatLinearCompressionLevel, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), flag2); // Paper - rewrite chunk system //EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver); // Kaiiju
|
||||
|
||||
// this.entityManager = new PersistentEntitySectionManager<>(Entity.class, new ServerLevel.EntityCallbacks(), entitypersistentstorage, this.entitySliceManager); // Paper // Paper - rewrite chunk system
|
||||
StructureTemplateManager structuretemplatemanager = minecraftserver.getStructureManager();
|
||||
diff --git a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||
index 77dd632a266f4abed30b87b7909d77857c01e316..97007462c7f3d7231fff18ecf295f2574684bf9f 100644
|
||||
index e16ef1b7c0bfe6d6194c09f6787a50fd9b28f55e..cc70b729663bececec45a03ec21a94792e5f2052 100644
|
||||
--- a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||
+++ b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||
@@ -61,7 +61,7 @@ public class WorldUpgrader {
|
||||
private volatile int skipped;
|
||||
private final Reference2FloatMap<ResourceKey<Level>> progressMap = Reference2FloatMaps.synchronize(new Reference2FloatOpenHashMap());
|
||||
private final Object2FloatMap<ResourceKey<Level>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(Util.identityStrategy()));
|
||||
private volatile Component status = Component.translatable("optimizeWorld.stage.counting");
|
||||
- public static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
|
||||
+ public static Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.(linear | mca)$"); // Kaiiju
|
||||
@@ -740,14 +682,14 @@ index 77dd632a266f4abed30b87b7909d77857c01e316..97007462c7f3d7231fff18ecf295f257
|
||||
- builder1.put(resourcekey1, new ChunkStorage(path.resolve("region"), this.dataFixer, true));
|
||||
+ // Kaiiju start
|
||||
+ String worldName = this.levelStorage.getLevelId();
|
||||
+ dev.kaiijumc.kaiiju.region.RegionFileFormat formatName = me.earthme.luminol.config.modules.misc.RegionFormatConfig.regionFormatName;
|
||||
+ int linearCompression = me.earthme.luminol.config.modules.misc.RegionFormatConfig.regionFormatLinearCompressionLevel;
|
||||
+ dev.kaiijumc.kaiiju.region.RegionFileFormat formatName = me.earthme.luminol.LuminolConfig.regionFormatName;
|
||||
+ int linearCompression = me.earthme.luminol.LuminolConfig.regionFormatLinearCompressionLevel;
|
||||
+ builder1.put(resourcekey1, new ChunkStorage(formatName, linearCompression, path.resolve("region"), this.dataFixer, true));
|
||||
+ // Kaiiju end
|
||||
}
|
||||
|
||||
ImmutableMap<ResourceKey<Level>, ChunkStorage> immutablemap1 = builder1.build();
|
||||
@@ -241,7 +246,7 @@ public class WorldUpgrader {
|
||||
@@ -235,7 +240,7 @@ public class WorldUpgrader {
|
||||
File file = this.levelStorage.getDimensionPath(world).toFile();
|
||||
File file1 = new File(file, "region");
|
||||
File[] afile = file1.listFiles((file2, s) -> {
|
||||
@@ -756,14 +698,14 @@ index 77dd632a266f4abed30b87b7909d77857c01e316..97007462c7f3d7231fff18ecf295f257
|
||||
});
|
||||
|
||||
if (afile == null) {
|
||||
@@ -260,7 +265,11 @@ public class WorldUpgrader {
|
||||
@@ -254,7 +259,11 @@ public class WorldUpgrader {
|
||||
int l = Integer.parseInt(matcher.group(2)) << 5;
|
||||
|
||||
try {
|
||||
- RegionFile regionfile = new RegionFile(file2.toPath(), file1.toPath(), true);
|
||||
+ // Kaiiju start
|
||||
+ String worldName = this.levelStorage.getLevelId();
|
||||
+ int linearCompression = me.earthme.luminol.config.modules.misc.RegionFormatConfig.regionFormatLinearCompressionLevel;
|
||||
+ int linearCompression = me.earthme.luminol.LuminolConfig.regionFormatLinearCompressionLevel;
|
||||
+ dev.kaiijumc.kaiiju.region.AbstractRegionFile regionfile = dev.kaiijumc.kaiiju.region.AbstractRegionFileFactory.getAbstractRegionFile(linearCompression, file2.toPath(), file1.toPath(), true);
|
||||
+ // Kaiiju end
|
||||
|
||||
@@ -785,23 +727,25 @@ index 5150d447c9dc2f539446749c8bee102050bab4ed..187ff795192c7eb56dffafa1ff6fa306
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||
index d16d7c2fed89fb1347df7ddd95856e7f08c22e8a..e4200692f6a33a12d00120f7a661de3e57a671dd 100644
|
||||
index 8ebecb588058da174b0e0e19e54fcddfeeca1422..1d880f27dd147da683fc30ed6f1bfa43ecdb7d93 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||
@@ -36,9 +36,9 @@ public class ChunkStorage implements AutoCloseable {
|
||||
@Nullable
|
||||
private volatile LegacyStructureDataHandler legacyStructureHandler;
|
||||
@@ -37,11 +37,11 @@ public class ChunkStorage implements AutoCloseable {
|
||||
public final RegionFileStorage regionFileCache;
|
||||
// Paper end - async chunk loading
|
||||
|
||||
- public ChunkStorage(Path directory, DataFixer dataFixer, boolean dsync) {
|
||||
+ public ChunkStorage(dev.kaiijumc.kaiiju.region.RegionFileFormat format, int linearCompression, Path directory, DataFixer dataFixer, boolean dsync) { // Kaiiju
|
||||
this.fixerUpper = dataFixer;
|
||||
- this.regionFileCache = new RegionFileStorage(directory, dsync, true); // Paper - rewrite chunk system; async chunk IO & Attempt to recalculate regionfile header if it is corrupt
|
||||
+ this.regionFileCache = new RegionFileStorage(format,linearCompression,directory, dsync, true); // Paper - rewrite chunk system; async chunk IO & Attempt to recalculate regionfile header if it is corrupt //Kaiiju
|
||||
// Paper start - async chunk io
|
||||
// remove IO worker
|
||||
- this.regionFileCache = new RegionFileStorage(directory, dsync, true); // Paper - nuke IOWorker // Paper
|
||||
+ this.regionFileCache = new RegionFileStorage(format, linearCompression, directory, dsync, true); // Paper - nuke IOWorker // Paper
|
||||
// Paper end - async chunk io
|
||||
}
|
||||
|
||||
public boolean isOldChunkAround(ChunkPos chunkPos, int checkRadius) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
index 6cf83502a954cce9c562ec036bfeddb477d38b73..a450533cd01dab4ae165dc93f6c57553fee831c8 100644
|
||||
index 9248769e6d357f6eec68945fd7700e79b2942c41..024870a31469c40cd680be0399ce0e0e73839a0f 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
@@ -26,7 +26,7 @@ import net.minecraft.nbt.NbtIo; // Paper
|
||||
@@ -813,7 +757,7 @@ index 6cf83502a954cce9c562ec036bfeddb477d38b73..a450533cd01dab4ae165dc93f6c57553
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static final int SECTOR_BYTES = 4096;
|
||||
@@ -50,6 +50,17 @@ public class RegionFile implements AutoCloseable {
|
||||
@@ -50,6 +50,16 @@ public class RegionFile implements AutoCloseable {
|
||||
public final java.util.concurrent.locks.ReentrantLock fileLock = new java.util.concurrent.locks.ReentrantLock(); // Paper
|
||||
public final Path regionFile; // Paper
|
||||
|
||||
@@ -827,11 +771,10 @@ index 6cf83502a954cce9c562ec036bfeddb477d38b73..a450533cd01dab4ae165dc93f6c57553
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
+
|
||||
+
|
||||
// Paper start - Attempt to recalculate regionfile header if it is corrupt
|
||||
// Paper start - try to recover from RegionFile header corruption
|
||||
private static long roundToSectors(long bytes) {
|
||||
long sectors = bytes >>> 12; // 4096 = 2^12
|
||||
@@ -128,7 +139,7 @@ public class RegionFile implements AutoCloseable {
|
||||
@@ -128,7 +138,7 @@ public class RegionFile implements AutoCloseable {
|
||||
}
|
||||
|
||||
// note: only call for CHUNK regionfiles
|
||||
@@ -840,7 +783,7 @@ index 6cf83502a954cce9c562ec036bfeddb477d38b73..a450533cd01dab4ae165dc93f6c57553
|
||||
if (!this.canRecalcHeader) {
|
||||
return false;
|
||||
}
|
||||
@@ -955,10 +966,10 @@ public class RegionFile implements AutoCloseable {
|
||||
@@ -954,10 +964,10 @@ public class RegionFile implements AutoCloseable {
|
||||
private static int getChunkIndex(int x, int z) {
|
||||
return (x & 31) + (z & 31) * 32;
|
||||
}
|
||||
@@ -853,7 +796,7 @@ index 6cf83502a954cce9c562ec036bfeddb477d38b73..a450533cd01dab4ae165dc93f6c57553
|
||||
final int offset = getChunkIndex(x, z);
|
||||
boolean previous = this.oversized[offset] == 1;
|
||||
this.oversized[offset] = (byte) (oversized ? 1 : 0);
|
||||
@@ -997,7 +1008,7 @@ public class RegionFile implements AutoCloseable {
|
||||
@@ -996,7 +1006,7 @@ public class RegionFile implements AutoCloseable {
|
||||
return this.regionFile.getParent().resolve(this.regionFile.getFileName().toString().replaceAll("\\.mca$", "") + "_oversized_" + x + "_" + z + ".nbt");
|
||||
}
|
||||
|
||||
@@ -863,7 +806,7 @@ index 6cf83502a954cce9c562ec036bfeddb477d38b73..a450533cd01dab4ae165dc93f6c57553
|
||||
try (DataInputStream out = new DataInputStream(new java.io.BufferedInputStream(new InflaterInputStream(Files.newInputStream(file))))) {
|
||||
return NbtIo.read((java.io.DataInput) out);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
index fe312b1aef579cb4bf81bdd967cf72ff880d7505..db9e4386ca95bdaba0a4a4e13e3a90d2bcfbae91 100644
|
||||
index db571f658f636cdda1dcdbaffa0c4da67fae11ad..21537b14c6c6789da3db04577f1c93998397678d 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
|
||||
@@ -21,9 +21,13 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -948,7 +891,7 @@ index fe312b1aef579cb4bf81bdd967cf72ff880d7505..db9e4386ca95bdaba0a4a4e13e3a90d2
|
||||
@@ -123,28 +131,45 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
}
|
||||
// Paper end - cache regionfile does not exist state
|
||||
if (this.regionCache.size() >= io.papermc.paper.configuration.GlobalConfiguration.get().misc.regionFileCacheSize) { // Paper - Sanitise RegionFileCache and make configurable
|
||||
if (this.regionCache.size() >= io.papermc.paper.configuration.GlobalConfiguration.get().misc.regionFileCacheSize) { // Paper - configurable
|
||||
- ((RegionFile) this.regionCache.removeLast()).close();
|
||||
+ this.regionCache.removeLast().close(); // Kaiiju
|
||||
}
|
||||
@@ -998,16 +941,16 @@ index fe312b1aef579cb4bf81bdd967cf72ff880d7505..db9e4386ca95bdaba0a4a4e13e3a90d2
|
||||
}
|
||||
// Paper end
|
||||
return regionfile1;
|
||||
@@ -156,7 +181,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
org.apache.logging.log4j.LogManager.getLogger().fatal(msg + " (" + file.toString().replaceAll(".+[\\\\/]", "") + " - " + x + "," + z + ") Go clean it up to remove this message. /minecraft:tp " + (x<<4)+" 128 "+(z<<4) + " - DO NOT REPORT THIS TO PAPER - You may ask for help on Discord, but do not file an issue. These error messages can not be removed.");
|
||||
@@ -172,7 +197,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
}
|
||||
|
||||
|
||||
- private static CompoundTag readOversizedChunk(RegionFile regionfile, ChunkPos chunkCoordinate) throws IOException {
|
||||
+ private static CompoundTag readOversizedChunk(dev.kaiijumc.kaiiju.region.AbstractRegionFile regionfile, ChunkPos chunkCoordinate) throws IOException { // Kaiiju
|
||||
synchronized (regionfile) {
|
||||
try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) {
|
||||
CompoundTag oversizedData = regionfile.getOversizedData(chunkCoordinate.x, chunkCoordinate.z);
|
||||
@@ -191,14 +216,14 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -219,14 +244,14 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@Nullable
|
||||
public CompoundTag read(ChunkPos pos) throws IOException {
|
||||
// CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
|
||||
@@ -1024,7 +967,7 @@ index fe312b1aef579cb4bf81bdd967cf72ff880d7505..db9e4386ca95bdaba0a4a4e13e3a90d2
|
||||
// We add the regionfile parameter to avoid the potential deadlock (on fileLock) if we went back to obtain a regionfile
|
||||
// if we decide to re-read
|
||||
// Paper end
|
||||
@@ -208,7 +233,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -236,7 +261,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
|
||||
// Paper start
|
||||
if (regionfile.isOversized(pos.x, pos.z)) {
|
||||
@@ -1033,7 +976,7 @@ index fe312b1aef579cb4bf81bdd967cf72ff880d7505..db9e4386ca95bdaba0a4a4e13e3a90d2
|
||||
return readOversizedChunk(regionfile, pos);
|
||||
}
|
||||
// Paper end
|
||||
@@ -222,12 +247,12 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -250,12 +275,12 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
if (this.isChunkData) {
|
||||
ChunkPos chunkPos = ChunkSerializer.getChunkCoordinate(nbttagcompound);
|
||||
if (!chunkPos.equals(pos)) {
|
||||
@@ -1049,7 +992,7 @@ index fe312b1aef579cb4bf81bdd967cf72ff880d7505..db9e4386ca95bdaba0a4a4e13e3a90d2
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -261,13 +286,13 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -289,13 +314,13 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
|
||||
return nbttagcompound;
|
||||
} finally { // Paper start
|
||||
@@ -1065,25 +1008,25 @@ index fe312b1aef579cb4bf81bdd967cf72ff880d7505..db9e4386ca95bdaba0a4a4e13e3a90d2
|
||||
if (regionfile == null) {
|
||||
return;
|
||||
}
|
||||
@@ -298,7 +323,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -325,7 +350,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
}
|
||||
|
||||
protected void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException {
|
||||
// Paper start - rewrite chunk system
|
||||
- RegionFile regionfile = this.getRegionFile(pos, nbt == null, true); // CraftBukkit
|
||||
+ dev.kaiijumc.kaiiju.region.AbstractRegionFile regionfile = this.getRegionFile(pos, nbt == null, true); // CraftBukkit // Kaiiju
|
||||
- RegionFile regionfile = this.getRegionFile(pos, nbt == null, true); // CraftBukkit // Paper // Paper start - rewrite chunk system
|
||||
+ dev.kaiijumc.kaiiju.region.AbstractRegionFile regionfile = this.getRegionFile(pos, nbt == null, true); // CraftBukkit // Paper // Paper start - rewrite chunk system // Kaiiju
|
||||
if (nbt == null && regionfile == null) {
|
||||
return;
|
||||
}
|
||||
@@ -353,7 +378,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
// Paper end - Chunk save reattempt
|
||||
// Paper start - rewrite chunk system
|
||||
} finally {
|
||||
@@ -375,7 +400,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
}
|
||||
// Paper end
|
||||
} finally { // Paper start
|
||||
- regionfile.fileLock.unlock();
|
||||
+ regionfile.getFileLock().unlock(); // Kaiiju
|
||||
}
|
||||
// Paper end - rewrite chunk system
|
||||
} // Paper end
|
||||
}
|
||||
@@ -363,7 +388,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
|
||||
@@ -384,7 +409,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
ObjectIterator objectiterator = this.regionCache.values().iterator();
|
||||
|
||||
while (objectiterator.hasNext()) {
|
||||
@@ -1092,7 +1035,7 @@ index fe312b1aef579cb4bf81bdd967cf72ff880d7505..db9e4386ca95bdaba0a4a4e13e3a90d2
|
||||
|
||||
try {
|
||||
regionfile.close();
|
||||
@@ -379,7 +404,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
@@ -400,7 +425,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
ObjectIterator objectiterator = this.regionCache.values().iterator();
|
||||
|
||||
while (objectiterator.hasNext()) {
|
||||
@@ -1117,13 +1060,13 @@ index 4aac1979cf57300825a999c876fcf24d3170e68e..3b96582f15d0985b670b5b5a1548800d
|
||||
this.factory = factory;
|
||||
this.fixerUpper = dataFixer;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 379c10e791a961d25d7de571f81ace1ac7d84381..e268ef6a373fa0e144104eb7fcfaf7bc9005c987 100644
|
||||
index bcbf7ba7c687ecaa530d4de3af45ebeb80dd15c5..f19db38e64854d051d4d8dbbb3ff4236b5d4537b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -575,7 +575,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
world.getChunk(x, z); // make sure we're at ticket level 32 or lower
|
||||
@@ -561,7 +561,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
return true;
|
||||
}
|
||||
|
||||
- net.minecraft.world.level.chunk.storage.RegionFile file;
|
||||
+ dev.kaiijumc.kaiiju.region.AbstractRegionFile file; // Kaiiju
|
||||
try {
|
||||
@@ -1,9 +1,66 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 04:39:56 +0000
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 15:19:16 +0800
|
||||
Subject: [PATCH] Add a simple tpsbar
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index 90a6cfd011aaefe66fda79f887380ab2d62a07b1..0657fce8aabb956a400b3cead53c28ef52e67fe9 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -2,11 +2,15 @@ package me.earthme.luminol;
|
||||
|
||||
import dev.kaiijumc.kaiiju.region.RegionFileFormat;
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import me.earthme.luminol.commands.TpsBarCommand;
|
||||
+import me.earthme.luminol.functions.GlobalServerTpsBar;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
+import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.Arrays;
|
||||
+import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -20,6 +24,10 @@ public class LuminolConfig {
|
||||
public static String serverModName = "Luminol";
|
||||
public static boolean fakeVanillaModeEnabled = false;
|
||||
public static boolean disableChatSign = false;
|
||||
+ public static boolean tpsbarEnabled = false;
|
||||
+ public static String tpsBarFormat = "<gray>TPS<yellow>:</yellow> <tps> MSPT<yellow>:</yellow> <mspt> Ping<yellow>:</yellow> <ping>ms";
|
||||
+ public static String[] tpsColors = new String[]{"GREEN","YELLOW","RED","PURPLE"};
|
||||
+ public static String[] pingColors = new String[]{"GREEN","YELLOW","RED","PURPLE"};
|
||||
|
||||
public static boolean safeTeleportation = true;
|
||||
public static boolean enableSandDuping = false;
|
||||
@@ -46,10 +54,25 @@ public class LuminolConfig {
|
||||
MAIN_CONFIG.save();
|
||||
}
|
||||
|
||||
+ public static void initTpsbar(){
|
||||
+ if (tpsbarEnabled){
|
||||
+ GlobalServerTpsBar.init();
|
||||
+ Bukkit.getCommandMap().register("tpsbar","luminol",new TpsBarCommand("tpsbar"));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
public static void initValues(){
|
||||
serverModName = get("misc.server_mod_name",serverModName,"The servermod name will be sent to players,and you can see it in F3 or motd responses");
|
||||
fakeVanillaModeEnabled = get("misc.enable_fake_vanilla_mode",fakeVanillaModeEnabled,"Enable this to make the ping response of your server like a vanilla server");
|
||||
disableChatSign = get("misc.disable_chat_sign",disableChatSign,"Set this to true to disable mojang's chat sign");
|
||||
+ tpsbarEnabled = get("misc.enable_tpsbar",tpsbarEnabled,"When this enabled,You or your players can see the tps,mspt and ping through a simple bossbar");
|
||||
+ tpsBarFormat = get("misc.tpsbar_title_format",tpsBarFormat,"The format of tpsbar.");
|
||||
+ tpsColors = get("misc.tpsbar_range_colors", List.of(tpsColors),"The bar and text color of each tps ranges.The last is the color of initial bar's color").toArray(String[]::new);
|
||||
+ pingColors = get("misc.tpsbar_ping_range_colors",List.of(pingColors),"As same as the tpsColors").toArray(String[]::new);
|
||||
+
|
||||
+ if (tpsbarEnabled){
|
||||
+ initTpsbar();
|
||||
+ }
|
||||
|
||||
safeTeleportation = get("fixes.enable_safe_teleportation",safeTeleportation,"If this enabled,the end portals will not teleport removed entities.");
|
||||
enableSandDuping = get("fixes.enable_sand_duping",enableSandDuping,"If this enabled,The value of safe teleportation will always be false and sand duping will be enabled");
|
||||
diff --git a/src/main/java/me/earthme/luminol/commands/TpsBarCommand.java b/src/main/java/me/earthme/luminol/commands/TpsBarCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ac8f0e3bf130ba6dfd7202e2f480352218154cdc
|
||||
@@ -50,73 +107,26 @@ index 0000000000000000000000000000000000000000..ac8f0e3bf130ba6dfd7202e2f4803522
|
||||
+ return true;
|
||||
+ }
|
||||
+}
|
||||
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
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..b370787c3f525b9b978ad14b3e7056d7c92fcae5
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/TpsBarConfig.java
|
||||
@@ -0,0 +1,40 @@
|
||||
+package me.earthme.luminol.config.modules.misc;
|
||||
+
|
||||
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import me.earthme.luminol.commands.TpsBarCommand;
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+import me.earthme.luminol.functions.GlobalServerTpsBar;
|
||||
+import org.bukkit.Bukkit;
|
||||
+
|
||||
+import java.util.List;
|
||||
+
|
||||
+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";
|
||||
+ @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");
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "tpsbar";
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onLoaded(CommentedFileConfig configInstance){
|
||||
+ if (tpsbarEnabled){
|
||||
+ GlobalServerTpsBar.init();
|
||||
+ Bukkit.getCommandMap().register("tpsbar","luminol",new TpsBarCommand("tpsbar"));
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java b/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7511bc3f6828ab712f644cf4292a5f831e8c8653
|
||||
index 0000000000000000000000000000000000000000..baec715e0c20e920ccb99f2f07d84fcb6f2b434e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java
|
||||
@@ -0,0 +1,206 @@
|
||||
@@ -0,0 +1,204 @@
|
||||
+package me.earthme.luminol.functions;
|
||||
+
|
||||
+import com.google.common.collect.Lists;
|
||||
+import io.papermc.paper.threadedregions.ThreadedRegionizer;
|
||||
+import io.papermc.paper.threadedregions.TickData;
|
||||
+import io.papermc.paper.threadedregions.TickRegions;
|
||||
+import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
||||
+import me.earthme.luminol.config.modules.misc.TpsBarConfig;
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
+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;
|
||||
@@ -130,7 +140,6 @@ index 0000000000000000000000000000000000000000..7511bc3f6828ab712f644cf4292a5f83
|
||||
+ protected static final MinecraftInternalPlugin NULL_PLUGIN = new MinecraftInternalPlugin();
|
||||
+ protected static final Map<UUID,BossBar> uuid2Bossbars = new HashMap<>();
|
||||
+ protected static volatile ScheduledTask tpsbarTask = null;
|
||||
+ private static final Logger logger = LogManager.getLogger();
|
||||
+
|
||||
+ public static void init(){
|
||||
+ Bukkit.getAsyncScheduler().runAtFixedRate(NULL_PLUGIN,c -> {
|
||||
@@ -138,7 +147,7 @@ index 0000000000000000000000000000000000000000..7511bc3f6828ab712f644cf4292a5f83
|
||||
+ try {
|
||||
+ update();
|
||||
+ }catch (Exception e){
|
||||
+ logger.error(e);
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ },1,1, TimeUnit.SECONDS);
|
||||
+ }
|
||||
@@ -206,7 +215,7 @@ index 0000000000000000000000000000000000000000..7511bc3f6828ab712f644cf4292a5f83
|
||||
+ BossBar targetBossbar = uuid2Bossbars.get(nmsPlayer.getUUID());
|
||||
+
|
||||
+ if (targetBossbar == null && isPlayerVisible(apiPlayer)){
|
||||
+ targetBossbar = BossBar.bossBar(Component.text(""),0.0F, BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(3)), BossBar.Overlay.NOTCHED_20);
|
||||
+ targetBossbar = BossBar.bossBar(Component.text(""),0.0F, BossBar.Color.valueOf(LuminolConfig.tpsColors[3]), BossBar.Overlay.NOTCHED_20);
|
||||
+ uuid2Bossbars.put(nmsPlayer.getUUID(),targetBossbar);
|
||||
+ apiPlayer.showBossBar(targetBossbar);
|
||||
+ }
|
||||
@@ -221,7 +230,7 @@ index 0000000000000000000000000000000000000000..7511bc3f6828ab712f644cf4292a5f83
|
||||
+
|
||||
+ private static void updateTpsBar(double tps, double mspt, @NotNull BossBar bar, @NotNull Player player){
|
||||
+ bar.name(MiniMessage.miniMessage().deserialize(
|
||||
+ TpsBarConfig.tpsBarFormat,
|
||||
+ LuminolConfig.tpsBarFormat,
|
||||
+ Placeholder.component("tps",getTpsComponent(tps)),
|
||||
+ Placeholder.component("mspt",getMsptComponent(mspt)),
|
||||
+ Placeholder.component("ping",getPingComponent(player.getPing()))
|
||||
@@ -242,18 +251,18 @@ index 0000000000000000000000000000000000000000..7511bc3f6828ab712f644cf4292a5f83
|
||||
+
|
||||
+ private static BossBar.Color barColorFromPing(int ping){
|
||||
+ if (ping == -1){
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.pingColors.get(3));
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[3]);
|
||||
+ }
|
||||
+
|
||||
+ if (ping <= 80){
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.pingColors.get(0));
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[0]);
|
||||
+ }
|
||||
+
|
||||
+ if (ping <= 160){
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.pingColors.get(1));
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[1]);
|
||||
+ }
|
||||
+
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.pingColors.get(2));
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[2]);
|
||||
+ }
|
||||
+
|
||||
+ private static @NotNull Component getMsptComponent(double mspt){
|
||||
@@ -268,18 +277,18 @@ index 0000000000000000000000000000000000000000..7511bc3f6828ab712f644cf4292a5f83
|
||||
+
|
||||
+ private static BossBar.Color barColorFromMspt(double mspt){
|
||||
+ if (mspt == -1){
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(3));
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[3]);
|
||||
+ }
|
||||
+
|
||||
+ if (mspt <= 25){
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(0));
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[0]);
|
||||
+ }
|
||||
+
|
||||
+ if (mspt <= 50){
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(1));
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[1]);
|
||||
+ }
|
||||
+
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(2));
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[2]);
|
||||
+ }
|
||||
+
|
||||
+ private static @NotNull Component getTpsComponent(double tps){
|
||||
@@ -294,65 +303,90 @@ index 0000000000000000000000000000000000000000..7511bc3f6828ab712f644cf4292a5f83
|
||||
+
|
||||
+ private static BossBar.Color barColorFromTps(double tps){
|
||||
+ if (tps == -1){
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(3));
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[3]);
|
||||
+ }
|
||||
+
|
||||
+ if (tps >= 18){
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(0));
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[0]);
|
||||
+ }
|
||||
+
|
||||
+ if (tps >= 15){
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(1));
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[1]);
|
||||
+ }
|
||||
+
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(2));
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[2]);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index d6b480565340f5edbf81d7b57c3199292b020615..ea3b3f8b2318b8a1e8975e89c90cab05c6ab2835 100644
|
||||
index f0bf57a7acd77eeffbeeb6743ba58166823022fd..4a1e068c27853a38db0641806626e7ac740bd8de 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
|
||||
@@ -1,20 +1,16 @@
|
||||
package net.minecraft.server.dedicated;
|
||||
|
||||
-import com.google.common.collect.Lists;
|
||||
+import me.earthme.luminol.functions.GlobalServerTpsBar;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import com.mojang.logging.LogUtils;
|
||||
-import java.io.BufferedReader;
|
||||
+
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
-import java.io.InputStreamReader;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Proxy;
|
||||
-import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
-import java.util.Collections;
|
||||
-import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BooleanSupplier;
|
||||
@@ -829,6 +825,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
|
||||
@Override
|
||||
public void stopServer() {
|
||||
+ me.earthme.luminol.functions.GlobalServerTpsBar.cancelBarUpdateTask(); //Luminol - Tpsbar
|
||||
+ GlobalServerTpsBar.cancelBarUpdateTask(); //Luminol - Tpsbar
|
||||
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 cbc89b8898f9243776af88c2b04ad3c2e4e23fb6..318cb1e98a3d73b7893f07c9f0db3adab801b67e 100644
|
||||
index 97bfb92e52c3c5ef1cd22afe2b97c204eb45025a..d7a280427442bac8cc8ccb542d24d4e0901df70a 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -285,6 +285,7 @@ public class ServerPlayer extends Player {
|
||||
@@ -278,6 +278,7 @@ public class ServerPlayer extends Player {
|
||||
// Paper start - replace player chunk loader
|
||||
private final java.util.concurrent.atomic.AtomicReference<io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances> viewDistances = new java.util.concurrent.atomic.AtomicReference<>(new io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances(-1, -1, -1));
|
||||
public io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader;
|
||||
+ public volatile boolean isTpsBarVisible = false; //Luminol - Tps bar
|
||||
+ public volatile boolean isTpsBarVisible = false;
|
||||
|
||||
public io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances getViewDistances() {
|
||||
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
|
||||
index 8fc071a6249193af5e1795cc19f50996ea22d96f..830616f7a3d1c3e25133229a74e08cbb9d412179 100644
|
||||
index 6c8f6e26687b557fcdcd65c657d8b35d3fde805e..06c92a2d3ecb3b747c2303819f72c1c41967af8c 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -2287,6 +2287,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@@ -2216,6 +2216,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
handle.expToDrop = data.getInt("expToDrop");
|
||||
handle.keepLevel = data.getBoolean("keepLevel");
|
||||
}
|
||||
+
|
||||
+ //Luminol start - Tpsbar
|
||||
+ getHandle().isTpsBarVisible = data.getBoolean("tpsbarVisible");
|
||||
+ //Luminol end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2308,6 +2311,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@@ -2237,6 +2241,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
data.putLong("lastPlayed", System.currentTimeMillis());
|
||||
data.putString("lastKnownName", handle.getScoreboardName());
|
||||
|
||||
+ //Luminol start - Tpsbar
|
||||
+ data.putBoolean("tpsbarVisible",handle.isTpsBarVisible);
|
||||
+ //Luminol end
|
||||
+
|
||||
// Paper start - persist for use in offline save data
|
||||
if (!nbttagcompound.contains("Paper")) {
|
||||
nbttagcompound.put("Paper", new CompoundTag());
|
||||
@@ -1,75 +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 e837f1f9b444318cbee8719b9dd0eb669478742e..3a787b0afa3a34f23f1c18fb5250a5ff4bcd2f96 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..313c3908ea406119da4f49db2e4fac6572727c80
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/IOUringSupportConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.misc;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class IOUringSupportConfig implements IConfigModule {
|
||||
+ @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;
|
||||
55
patches/server/0016-Petal-Reduce-sensor-work.patch
Normal file
55
patches/server/0016-Petal-Reduce-sensor-work.patch
Normal file
@@ -0,0 +1,55 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 15:36:59 +0800
|
||||
Subject: [PATCH] Petal Reduce sensor work
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index 0657fce8aabb956a400b3cead53c28ef52e67fe9..c3a481cb7bea0619b1af0e3203e9d88514e84c62 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -40,6 +40,8 @@ public class LuminolConfig {
|
||||
public static int linearFlushFrequency = 10;
|
||||
public static int linearFlushThreads = 1;
|
||||
|
||||
+ public static boolean reduceSensorWork = true;
|
||||
+
|
||||
public static void init() throws IOException {
|
||||
PARENT_FOLDER.mkdir();
|
||||
|
||||
@@ -98,6 +100,8 @@ public class LuminolConfig {
|
||||
linearFlushThreads = Math.max(Runtime.getRuntime().availableProcessors() + linearFlushThreads, 1);
|
||||
else
|
||||
linearFlushThreads = Math.max(linearFlushThreads, 1);
|
||||
+
|
||||
+ reduceSensorWork = get("optimizations.reduce_sensor_work",reduceSensorWork,"This optimization is from petal.You can find out more about it on petal's repository");
|
||||
}
|
||||
|
||||
public static <T> T get(String key,T def){
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index 4e9d510646abbc2d2b6f2d935f7416b6872eb234..d3f8aa29b05a3813c0ec6e2ea5a253868abd6b07 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -9,6 +9,8 @@ import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.core.Vec3i;
|
||||
@@ -924,10 +926,11 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||
return;
|
||||
}
|
||||
// Paper end
|
||||
+ int i = this.tickCount + this.getId(); // Folia - region threading //Luminol - Petal - Move up
|
||||
+
|
||||
this.level().getProfiler().push("sensing");
|
||||
- this.sensing.tick();
|
||||
+ if (i % 10 == 0 || !LuminolConfig.reduceSensorWork)this.sensing.tick(); //Luminol - Petal - Reduce sensor work
|
||||
this.level().getProfiler().pop();
|
||||
- int i = this.tickCount + this.getId(); // Folia - region threading
|
||||
|
||||
if (i % 2 != 0 && this.tickCount > 1) {
|
||||
this.level().getProfiler().push("targetSelector");
|
||||
@@ -1,57 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 06:30:03 +0000
|
||||
Subject: [PATCH] Try fixing folia spector teleportation
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaSpectorTeleportationFixConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaSpectorTeleportationFixConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..8487799cdfb776eaca33b57f7c99ae3aeadb890d
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaSpectorTeleportationFixConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.fixes;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class FoliaSpectorTeleportationFixConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean fixSpectorTeleportFolia = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.FIXES;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "folia.fix_spector_teleportation";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 318cb1e98a3d73b7893f07c9f0db3adab801b67e..9cbf17436b4cf52aae374767aafe79ea4f60c3ce 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -17,6 +17,8 @@ import java.util.OptionalInt;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.earthme.luminol.config.modules.fixes.FoliaSpectorTeleportationFixConfig;
|
||||
import net.minecraft.BlockUtil;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.CrashReport;
|
||||
@@ -842,6 +844,11 @@ public class ServerPlayer extends Player {
|
||||
}
|
||||
|
||||
Entity entity = this.getCamera();
|
||||
+ //Luminol start - Fix folia spector teleportation
|
||||
+ if (!io.papermc.paper.util.TickThread.isTickThreadFor(entity) && FoliaSpectorTeleportationFixConfig.fixSpectorTeleportFolia){
|
||||
+ this.setCamera(this);
|
||||
+ }
|
||||
+ //Luminol end
|
||||
|
||||
if (entity != this) {
|
||||
if (entity.isAlive()) {
|
||||
52
patches/server/0017-Add-config-for-username-check.patch
Normal file
52
patches/server/0017-Add-config-for-username-check.patch
Normal file
@@ -0,0 +1,52 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 15:56:26 +0800
|
||||
Subject: [PATCH] Add config for username check
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index c3a481cb7bea0619b1af0e3203e9d88514e84c62..0929a5a167691bde7dedaa1e2812b34ad69913d6 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -28,6 +28,7 @@ public class LuminolConfig {
|
||||
public static String tpsBarFormat = "<gray>TPS<yellow>:</yellow> <tps> MSPT<yellow>:</yellow> <mspt> Ping<yellow>:</yellow> <ping>ms";
|
||||
public static String[] tpsColors = new String[]{"GREEN","YELLOW","RED","PURPLE"};
|
||||
public static String[] pingColors = new String[]{"GREEN","YELLOW","RED","PURPLE"};
|
||||
+ public static boolean disableUsernameCheck = false;
|
||||
|
||||
public static boolean safeTeleportation = true;
|
||||
public static boolean enableSandDuping = false;
|
||||
@@ -71,6 +72,7 @@ public class LuminolConfig {
|
||||
tpsBarFormat = get("misc.tpsbar_title_format",tpsBarFormat,"The format of tpsbar.");
|
||||
tpsColors = get("misc.tpsbar_range_colors", List.of(tpsColors),"The bar and text color of each tps ranges.The last is the color of initial bar's color").toArray(String[]::new);
|
||||
pingColors = get("misc.tpsbar_ping_range_colors",List.of(pingColors),"As same as the tpsColors").toArray(String[]::new);
|
||||
+ disableUsernameCheck = get("misc.disable_username_check",disableUsernameCheck,"Disable username check that can accept usernames with other characters(such as Chinese).Not recommended to use");
|
||||
|
||||
if (tpsbarEnabled){
|
||||
initTpsbar();
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
index f7c2d6d82ee1b5975cd114934b7beaec3d5d490d..f26c44bb8c4e3d8556c8c5ac7389e02381239594 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
@@ -16,6 +16,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.SecretKey;
|
||||
+
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.DefaultUncaughtExceptionHandler;
|
||||
import net.minecraft.core.UUIDUtil;
|
||||
import net.minecraft.network.Connection;
|
||||
@@ -162,10 +164,10 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||
@Override
|
||||
public void handleHello(ServerboundHelloPacket packet) {
|
||||
Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet", new Object[0]);
|
||||
- Validate.validState(ServerLoginPacketListenerImpl.isValidUsername(packet.name()), "Invalid characters in username", new Object[0]);
|
||||
+ if (!LuminolConfig.disableUsernameCheck) Validate.validState(ServerLoginPacketListenerImpl.isValidUsername(packet.name()), "Invalid characters in username", new Object[0]); //Luminol - Add config for usename check
|
||||
// Paper start - validate usernames
|
||||
if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation) {
|
||||
- if (!this.iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation && !validateUsername(packet.name())) {
|
||||
+ if (!this.iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation && !validateUsername(packet.name()) && !LuminolConfig.disableUsernameCheck) { //Luminol - Add config for username check
|
||||
ServerLoginPacketListenerImpl.this.disconnect("Failed to verify username!");
|
||||
return;
|
||||
}
|
||||
@@ -5,10 +5,10 @@ Subject: [PATCH] Pufferfish Optimize entity coordinate key
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
index 878306271d4af280c7a086d1839c446a01da1ad6..cb22cac2b8c4eaf705b76fd4a9d8b82fb8eb0140 100644
|
||||
index 8f91b7f44baaf62b829a81afc0633311e6c13f19..a149d98be7b4744f18d4ed4940881e13a76e4a7c 100644
|
||||
--- a/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
+++ b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
@@ -212,7 +212,7 @@ public final class MCUtil {
|
||||
@@ -213,7 +213,7 @@ public final class MCUtil {
|
||||
}
|
||||
|
||||
public static long getCoordinateKey(final Entity entity) {
|
||||
@@ -1,14 +1,14 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sun, 14 Jan 2024 00:40:35 +0000
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16:00:17 +0800
|
||||
Subject: [PATCH] Pufferfish Cache climbing check for activation
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 24c05e40c9eeeb4a181d2f9994b0e786393046b9..a899f33c8c6033ad99d8187f29d6e9ebd99ded09 100644
|
||||
index cb32a3851a315f1f1b4fb6d26fdffbcb471bfc06..3c9ec0f5fef49b0abc42382551de11ab942b3b20 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -310,7 +310,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -308,7 +308,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
public double yo;
|
||||
public double zo;
|
||||
private Vec3 position;
|
||||
@@ -18,7 +18,7 @@ index 24c05e40c9eeeb4a181d2f9994b0e786393046b9..a899f33c8c6033ad99d8187f29d6e9eb
|
||||
private Vec3 deltaMovement;
|
||||
private float yRot;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index b640d877f924094bcabbf9618bbd9aa0a70bf94a..d38918b973f76e4b3eec5e16ea4f2473e92ae858 100644
|
||||
index 82996d0c2891871bd6ef9ff81aef123add08ebda..51dee7adc0dc534fac66bf3e8709865157dd763b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -142,7 +142,6 @@ import org.bukkit.event.entity.EntityTeleportEvent;
|
||||
@@ -29,7 +29,7 @@ index b640d877f924094bcabbf9618bbd9aa0a70bf94a..d38918b973f76e4b3eec5e16ea4f2473
|
||||
|
||||
public abstract class LivingEntity extends Entity implements Attackable {
|
||||
|
||||
@@ -2027,6 +2026,20 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -2006,6 +2005,20 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
return this.lastClimbablePos;
|
||||
}
|
||||
|
||||
@@ -51,15 +51,15 @@ index b640d877f924094bcabbf9618bbd9aa0a70bf94a..d38918b973f76e4b3eec5e16ea4f2473
|
||||
if (this.isSpectator()) {
|
||||
return false;
|
||||
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
index f8718d91f4c15c74d6e6dd5f60f7f05f45f63655..50fafff765b2494c075784cc5342d086c8dc97b2 100644
|
||||
index d88988200016c1a3cc76c017dfb7deabf6fc17af..22daed525b023998a05884db603e2c7385ce0873 100644
|
||||
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
||||
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
@@ -305,7 +305,7 @@ public class ActivationRange
|
||||
if ( entity instanceof LivingEntity )
|
||||
{
|
||||
LivingEntity living = (LivingEntity) entity;
|
||||
- if ( living.onClimbable() || living.jumping || living.hurtTime > 0 || living.activeEffects.size() > 0 || living.isFreezing()) // Paper
|
||||
+ if ( living.onClimableCached() || living.jumping || living.hurtTime > 0 || living.activeEffects.size() > 0 || living.isFreezing()) // Paper // Pufferfish - use cached
|
||||
- if ( living.onClimbable() || living.jumping || living.hurtTime > 0 || living.activeEffects.size() > 0 ) // Paper
|
||||
+ if ( living.onClimableCached() || living.jumping || living.hurtTime > 0 || living.activeEffects.size() > 0 ) // Paper // Pufferfish - use cached
|
||||
{
|
||||
return 1; // Paper
|
||||
}
|
||||
@@ -147,7 +147,7 @@ index 0000000000000000000000000000000000000000..aa8467b9dda1f7707e41f50ac7b3e9d7
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||
index 6d8ff6c06af5545634f255ed17dc1e489ece2548..6411aa4ff6bd4cabb25c426fa8f4a7eedb969c03 100644
|
||||
index e21f4c5aff3a8e97101f6efc1349fbecf326b5ea..c55f51e6db55f9fa66f53eef0e7a56af5f81d742 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||
@@ -45,6 +45,8 @@ public abstract class FlowingFluid extends Fluid {
|
||||
@@ -174,7 +174,7 @@ index 6d8ff6c06af5545634f255ed17dc1e489ece2548..6411aa4ff6bd4cabb25c426fa8f4a7ee
|
||||
private final Map<FluidState, VoxelShape> shapes = Maps.newIdentityHashMap();
|
||||
|
||||
public FlowingFluid() {}
|
||||
@@ -251,6 +261,8 @@ public abstract class FlowingFluid extends Fluid {
|
||||
@@ -252,6 +262,8 @@ public abstract class FlowingFluid extends Fluid {
|
||||
return false;
|
||||
}
|
||||
// Paper end - optimise collisions
|
||||
@@ -183,7 +183,7 @@ index 6d8ff6c06af5545634f255ed17dc1e489ece2548..6411aa4ff6bd4cabb25c426fa8f4a7ee
|
||||
Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap;
|
||||
|
||||
if (!state.getBlock().hasDynamicShape() && !fromState.getBlock().hasDynamicShape()) {
|
||||
@@ -258,9 +270,16 @@ public abstract class FlowingFluid extends Fluid {
|
||||
@@ -259,9 +271,16 @@ public abstract class FlowingFluid extends Fluid {
|
||||
} else {
|
||||
object2bytelinkedopenhashmap = null;
|
||||
}
|
||||
@@ -200,7 +200,7 @@ index 6d8ff6c06af5545634f255ed17dc1e489ece2548..6411aa4ff6bd4cabb25c426fa8f4a7ee
|
||||
if (object2bytelinkedopenhashmap != null) {
|
||||
block_a = new Block.BlockStatePairKey(state, fromState, face);
|
||||
byte b0 = object2bytelinkedopenhashmap.getAndMoveToFirst(block_a);
|
||||
@@ -271,11 +290,22 @@ public abstract class FlowingFluid extends Fluid {
|
||||
@@ -272,11 +291,22 @@ public abstract class FlowingFluid extends Fluid {
|
||||
} else {
|
||||
block_a = null;
|
||||
}
|
||||
@@ -223,7 +223,7 @@ index 6d8ff6c06af5545634f255ed17dc1e489ece2548..6411aa4ff6bd4cabb25c426fa8f4a7ee
|
||||
if (object2bytelinkedopenhashmap != null) {
|
||||
if (object2bytelinkedopenhashmap.size() == 200) {
|
||||
object2bytelinkedopenhashmap.removeLastByte();
|
||||
@@ -283,6 +313,11 @@ public abstract class FlowingFluid extends Fluid {
|
||||
@@ -284,6 +314,11 @@ public abstract class FlowingFluid extends Fluid {
|
||||
|
||||
object2bytelinkedopenhashmap.putAndMoveToFirst(block_a, (byte) (flag ? 1 : 0));
|
||||
}
|
||||
@@ -1,40 +1,43 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 04:55:43 +0000
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16:05:32 +0800
|
||||
Subject: [PATCH] Pufferfish Optimize suffocation
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/SuffocationOptimizationConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/SuffocationOptimizationConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..3e48cd297b4869e5c89b6abc43c726d3a7511e7f
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/SuffocationOptimizationConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.optimizations;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class SuffocationOptimizationConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.OPTIMIZATIONS;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "suffocation_optimization";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index 0929a5a167691bde7dedaa1e2812b34ad69913d6..de0855656ad3882b182aa5674fd0117288268e71 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -42,6 +42,7 @@ public class LuminolConfig {
|
||||
public static int linearFlushThreads = 1;
|
||||
|
||||
public static boolean reduceSensorWork = true;
|
||||
+ public static boolean enableSuffocationOptimization = true;
|
||||
|
||||
public static void init() throws IOException {
|
||||
PARENT_FOLDER.mkdir();
|
||||
@@ -104,6 +105,7 @@ public class LuminolConfig {
|
||||
linearFlushThreads = Math.max(linearFlushThreads, 1);
|
||||
|
||||
reduceSensorWork = get("optimizations.reduce_sensor_work",reduceSensorWork,"This optimization is from petal.You can find out more about it on petal's repository");
|
||||
+ enableSuffocationOptimization = get("optimizations.optimize_suffocation_check",enableSuffocationOptimization);
|
||||
}
|
||||
|
||||
public static <T> T get(String key,T def){
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index d38918b973f76e4b3eec5e16ea4f2473e92ae858..3731013a4369dac2130045bdc2bbde170075a3df 100644
|
||||
index 51dee7adc0dc534fac66bf3e8709865157dd763b..f13d26b280f095d006ffccb36af66bb7487cb8da 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -419,7 +419,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -19,6 +19,8 @@ import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.BlockUtil;
|
||||
import net.minecraft.advancements.CriteriaTriggers;
|
||||
import net.minecraft.commands.arguments.EntityAnchorArgument;
|
||||
@@ -420,7 +422,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
boolean flag = this instanceof net.minecraft.world.entity.player.Player;
|
||||
|
||||
if (!this.level().isClientSide) {
|
||||
@@ -43,7 +46,7 @@ index d38918b973f76e4b3eec5e16ea4f2473e92ae858..3731013a4369dac2130045bdc2bbde17
|
||||
this.hurt(this.damageSources().inWall(), 1.0F);
|
||||
} else if (flag && !this.level().getWorldBorder().isWithinBounds(this.getBoundingBox())) {
|
||||
double d0 = this.level().getWorldBorder().getDistanceToBorder(this) + this.level().getWorldBorder().getDamageSafeZone();
|
||||
@@ -1420,6 +1420,19 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -1410,6 +1412,19 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
return this.getHealth() <= 0.0F;
|
||||
}
|
||||
|
||||
@@ -56,7 +59,7 @@ index d38918b973f76e4b3eec5e16ea4f2473e92ae858..3731013a4369dac2130045bdc2bbde17
|
||||
+ }
|
||||
+
|
||||
+ public boolean shouldCheckForSuffocation() {
|
||||
+ return !me.earthme.luminol.config.modules.optimizations.SuffocationOptimizationConfig.enabled || (tickCount % 10 == 0 && couldPossiblyBeHurt(1.0F));
|
||||
+ return !LuminolConfig.enableSuffocationOptimization || (tickCount % 10 == 0 && couldPossiblyBeHurt(1.0F));
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
+
|
||||
@@ -64,7 +67,7 @@ index d38918b973f76e4b3eec5e16ea4f2473e92ae858..3731013a4369dac2130045bdc2bbde17
|
||||
public boolean hurt(DamageSource source, float amount) {
|
||||
if (this.isInvulnerableTo(source)) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
index ac9eaeaf7df1e84ee588f371628c0a10784d50bc..ea8883b0661e894a466eca24bfc247ac37f40a81 100644
|
||||
index 1e07febcf7a3dfb281728cc5e3e4f15dd776d7e0..c65ab566c6241dd6a44bd11a449ef0c4b2f6dc65 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
@@ -150,6 +150,13 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob
|
||||
@@ -1,11 +1,11 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Tue, 6 Feb 2024 03:17:39 +0000
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16:07:30 +0800
|
||||
Subject: [PATCH] Pufferfish Early return optimization for target finding
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
|
||||
index c8a80c1b2fedff22e8a877d466062375ffb2f0d7..3c4f4af85a3f2d4f9f52827164e63727b916c33a 100644
|
||||
index c157309ac78e7af084d3acb6e8b2bcd469a39d5e..ac5e5676b194a2a99e5cf53eb89c1152cac963b8 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
|
||||
@@ -75,9 +75,18 @@ public class TargetingConditions {
|
||||
@@ -13,7 +13,7 @@ index c8a80c1b2fedff22e8a877d466062375ffb2f0d7..3c4f4af85a3f2d4f9f52827164e63727
|
||||
|
||||
if (this.range > 0.0D) {
|
||||
- double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0D;
|
||||
- double e = Math.max((this.useFollowRange ? this.getFollowRange(baseEntity) : this.range) * d, 2.0D); // Paper - Fix MC-145656
|
||||
- double e = Math.max((this.useFollowRange ? this.getFollowRange(baseEntity) : this.range) * d, 2.0D); // Paper
|
||||
+ // Pufferfish start - check range before getting visibility
|
||||
+ // d = invisibility percent, e = follow range adjusted for invisibility, f = distance
|
||||
double f = baseEntity.distanceToSqr(targetEntity.getX(), targetEntity.getY(), targetEntity.getZ());
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Pufferfish Reduce chunk loading & lookups
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
||||
index f33c03e81b7ff643741f56eea055e6af260de618..6563e625ebae47fc68e5010d36bd4b4d327c07b7 100644
|
||||
index bd5996eef2d946e9d7765b6b315bc5951158810e..0d51f435f18f3f9d59a3241a0b7fa1c4af841b72 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
||||
@@ -333,11 +333,17 @@ public class EnderMan extends Monster implements NeutralMob {
|
||||
@@ -1,52 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 04:46:30 +0000
|
||||
Subject: [PATCH] Petal Reduce sensor work
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/PetalReduceSensorWorkConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/PetalReduceSensorWorkConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..dd45cf1fde5ee4cf8347064f106c64b861b77ead
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/PetalReduceSensorWorkConfig.java
|
||||
@@ -0,0 +1,22 @@
|
||||
+package me.earthme.luminol.config.modules.optimizations;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class PetalReduceSensorWorkConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = true;
|
||||
+ @ConfigInfo(baseName = "delay_ticks")
|
||||
+ public static int delayTicks = 10;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.OPTIMIZATIONS;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "reduce_sensor_work";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index dc94c66404e9f2015119e249a560571355c92c96..9636f69fab9f34f3b3f4590f151248cd5b2da089 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -926,10 +926,11 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||
return;
|
||||
}
|
||||
// Paper end - Allow nerfed mobs to jump and float
|
||||
+ int i = this.tickCount + this.getId(); // Folia - region threading //Luminol - Petal - Move up
|
||||
+
|
||||
this.level().getProfiler().push("sensing");
|
||||
- this.sensing.tick();
|
||||
+ if (i % me.earthme.luminol.config.modules.optimizations.PetalReduceSensorWorkConfig.delayTicks == 0 || !me.earthme.luminol.config.modules.optimizations.PetalReduceSensorWorkConfig.enabled)this.sensing.tick(); //Luminol - Petal - Reduce sensor work
|
||||
this.level().getProfiler().pop();
|
||||
- int i = this.tickCount + this.getId(); // Folia - region threading
|
||||
|
||||
if (i % 2 != 0 && this.tickCount > 1) {
|
||||
this.level().getProfiler().push("targetSelector");
|
||||
@@ -1,6 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sat, 27 Jan 2024 11:55:08 +0000
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16:08:46 +0800
|
||||
Subject: [PATCH] Pufferfish Improve container checking with a bitset
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ index d6cbe98e67fdbf8db46338a88ab1356dd63b50a3..20dd3a63b2f955b05a75eb240e33ae4c
|
||||
int LARGE_MAX_STACK_SIZE = 64;
|
||||
int DEFAULT_DISTANCE_LIMIT = 8;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
index 6d23c39e4eadf23616080d6d08672e13b5d3c37d..e7115f1635821e0aab32e8aeea6914388dc24639 100644
|
||||
index 00187fbbeddfc17e1b6887f8bf0f50da23938470..f64edfdb03f99624daf1e05b5dc86d845c3018b6 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
@@ -27,7 +27,10 @@ import org.bukkit.inventory.InventoryHolder;
|
||||
@@ -284,7 +284,7 @@ index 6d23c39e4eadf23616080d6d08672e13b5d3c37d..e7115f1635821e0aab32e8aeea691438
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
index 9b1243d96e0694c62fc9e82e9be540bce0d2b3ad..3514022d898a24052c917ebf55dcef3e757d6836 100644
|
||||
index a71414397bd45ee7bcacfeef0041d80dfa25f114..d66806565770cb03a21794f99e5c4b0f3040b26a 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
@@ -31,7 +31,10 @@ import org.bukkit.entity.HumanEntity;
|
||||
@@ -362,7 +362,7 @@ index 9b1243d96e0694c62fc9e82e9be540bce0d2b3ad..3514022d898a24052c917ebf55dcef3e
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
index 26ff1a3d07c92f7035020d08d35116f7feede600..009263f6aab41608d7e17bebbed6f962fcb55634 100644
|
||||
index 72779080969fe9f058c19533ffc9dad5f9c47086..c90d578643490709936545ee9cbd41c8671eeb7a 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
@@ -47,7 +47,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
@@ -421,14 +421,14 @@ index 26ff1a3d07c92f7035020d08d35116f7feede600..009263f6aab41608d7e17bebbed6f962
|
||||
|
||||
private static boolean isFullContainer(Container inventory, Direction direction) {
|
||||
+ if (true) return inventory.isCompletelyFull(direction); // Pufferfish - use bitsets
|
||||
// Paper start - Perf: Optimize Hoppers
|
||||
// Paper start - optimize hoppers
|
||||
if (inventory instanceof WorldlyContainer worldlyContainer) {
|
||||
for (final int slot : worldlyContainer.getSlotsForFace(direction)) {
|
||||
@@ -515,7 +542,11 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
}
|
||||
|
||||
private static boolean isEmptyContainer(Container inv, Direction facing) {
|
||||
- return allMatch(inv, facing, IS_EMPTY_TEST); // Paper - Perf: Optimize Hoppers
|
||||
- return allMatch(inv, facing, IS_EMPTY_TEST);
|
||||
+ // Paper start
|
||||
+ // Pufferfish start - use bitsets
|
||||
+ //return allMatch(inv, facing, IS_EMPTY_TEST);
|
||||
@@ -459,13 +459,13 @@ index 26ff1a3d07c92f7035020d08d35116f7feede600..009263f6aab41608d7e17bebbed6f962
|
||||
|
||||
public static void entityInside(Level world, BlockPos pos, BlockState state, Entity entity, HopperBlockEntity blockEntity) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
index a94300a457b25f0e33a8eeabba6dd5720ca9ab1e..b41635dd0569ff7df909df492d3e850aef7214be 100644
|
||||
index 3e638f12956e57548f76c7e2403ba370f7baa249..02364a148b347e3669275553004391e31d77c0b5 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
@@ -94,12 +94,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
|
||||
@@ -96,12 +96,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
|
||||
public boolean isEmpty() {
|
||||
this.unpackLootTable((Player)null);
|
||||
// Paper start - Perf: Optimize Hoppers
|
||||
// Paper start
|
||||
- for (final ItemStack itemStack : this.getItems()) {
|
||||
- if (!itemStack.isEmpty()) {
|
||||
- return false;
|
||||
@@ -473,6 +473,6 @@ index a94300a457b25f0e33a8eeabba6dd5720ca9ab1e..b41635dd0569ff7df909df492d3e850a
|
||||
- }
|
||||
- return true;
|
||||
+ return this.isCompletelyEmpty(null); // Pufferfish - use super
|
||||
// Paper end - Perf: Optimize Hoppers
|
||||
// Paper end
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Tue, 6 Feb 2024 03:21:56 +0000
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16:09:27 +0800
|
||||
Subject: [PATCH] Pufferfish Fix Paper#6045, block goal shouldn't load chunks
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
|
||||
index 07519c817cc6de04a98198c43a0c2b02ba3141eb..ee66be6e5aa45ec8448b6d30785a6e71200b09e3 100644
|
||||
index 34f319ad09276c6f68dde449c79351de0d7d86f5..a719af0b512d9ef243d0d54f3b744b1b1a5f2772 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
|
||||
@@ -120,6 +120,7 @@ public abstract class MoveToBlockGoal extends Goal {
|
||||
@@ -119,6 +119,7 @@ public abstract class MoveToBlockGoal extends Goal {
|
||||
for(int m = 0; m <= l; m = m > 0 ? -m : 1 - m) {
|
||||
for(int n = m < l && m > -l ? l : 0; n <= l; n = n > 0 ? -n : 1 - n) {
|
||||
mutableBlockPos.setWithOffset(blockPos, m, k - 1, n);
|
||||
+ if (!this.mob.level().hasChunkAt(mutableBlockPos)) continue; // Pufferfish - if this block isn't loaded, continue
|
||||
if (this.mob.isWithinRestriction(mutableBlockPos) && this.isValidTarget(this.mob.level(), mutableBlockPos)) {
|
||||
this.blockPos = mutableBlockPos;
|
||||
this.mob.movingTarget = mutableBlockPos == BlockPos.ZERO ? null : mutableBlockPos.immutable(); // Paper
|
||||
setTargetPosition(mutableBlockPos.immutable()); // Paper
|
||||
@@ -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
|
||||
index a899f33c8c6033ad99d8187f29d6e9ebd99ded09..0b201fd79233ed0a5c2d298b283a15497dffd8e5 100644
|
||||
index 3c9ec0f5fef49b0abc42382551de11ab942b3b20..967c7a953084dc68a0ecd4b1a0f13ead7e72cb3d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -5243,16 +5243,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -5132,16 +5132,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
|
||||
public boolean updateFluidHeightAndDoFluidPushing(TagKey<Fluid> tag, double speed) {
|
||||
@@ -34,7 +34,7 @@ index a899f33c8c6033ad99d8187f29d6e9ebd99ded09..0b201fd79233ed0a5c2d298b283a1549
|
||||
double d1 = 0.0D;
|
||||
boolean flag = this.isPushedByFluid();
|
||||
boolean flag1 = false;
|
||||
@@ -5260,14 +5262,61 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -5149,14 +5151,61 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
int k1 = 0;
|
||||
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
|
||||
|
||||
@@ -102,7 +102,7 @@ index a899f33c8c6033ad99d8187f29d6e9ebd99ded09..0b201fd79233ed0a5c2d298b283a1549
|
||||
|
||||
if (d2 >= axisalignedbb.minY) {
|
||||
flag1 = true;
|
||||
@@ -5289,9 +5338,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -5178,9 +5227,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
// CraftBukkit end
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,7 @@ index a899f33c8c6033ad99d8187f29d6e9ebd99ded09..0b201fd79233ed0a5c2d298b283a1549
|
||||
if (vec3d.length() > 0.0D) {
|
||||
if (k1 > 0) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
index 796bbef3544e06b8e7aac7e8ac5f740a2613f4bd..2422ca3ffc6ab7178cacf933b8013f85e7de4bd9 100644
|
||||
index f0de72afad4bb571153436399386a6a8a70582a6..45b7527341fcb6d24f35318cedb522646b5ee1c2 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
@@ -25,6 +25,7 @@ public class LevelChunkSection {
|
||||
@@ -143,11 +143,11 @@ index 796bbef3544e06b8e7aac7e8ac5f740a2613f4bd..2422ca3ffc6ab7178cacf933b8013f85
|
||||
}
|
||||
|
||||
this.updateBlockCallback(x, y, z, iblockdata1, state); // Paper - optimise collisions
|
||||
@@ -162,6 +165,7 @@ public class LevelChunkSection {
|
||||
if (fluid.isRandomlyTicking()) {
|
||||
this.tickingFluidCount = (short) (this.tickingFluidCount + 1);
|
||||
}
|
||||
+ this.fluidStateCount++; // Pufferfish
|
||||
@@ -161,6 +164,7 @@ public class LevelChunkSection {
|
||||
if (fluid.isRandomlyTicking()) {
|
||||
this.tickingFluidCount = (short) (this.tickingFluidCount + 1);
|
||||
}
|
||||
+ this.fluidStateCount++; // Pufferfish
|
||||
}
|
||||
|
||||
// Paper start - optimise collisions
|
||||
// Paper start - optimise collisions
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Pufferfish Only check for spooky season once an hour
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ambient/Bat.java b/src/main/java/net/minecraft/world/entity/ambient/Bat.java
|
||||
index 44fa2d4f90389f5526746bd94a2450c03340bd0b..864c3c72b6881a2a8223a9aa5a593f1a65bcc857 100644
|
||||
index 5beaa849a250ea005733250ad3edfa8382224667..2028ae6cc50d86c579ec062536e8c6339196ce09 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ambient/Bat.java
|
||||
@@ -3,6 +3,10 @@ package net.minecraft.world.entity.ambient;
|
||||
@@ -19,7 +19,7 @@ index 44fa2d4f90389f5526746bd94a2450c03340bd0b..864c3c72b6881a2a8223a9aa5a593f1a
|
||||
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 {
|
||||
@@ -237,13 +241,25 @@ public class Bat extends AmbientCreature {
|
||||
}
|
||||
}
|
||||
|
||||
87
patches/server/0028-Pufferfish-Entity-TTL.patch
Normal file
87
patches/server/0028-Pufferfish-Entity-TTL.patch
Normal file
@@ -0,0 +1,87 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16:30:24 +0800
|
||||
Subject: [PATCH] Pufferfish Entity TTL
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index de0855656ad3882b182aa5674fd0117288268e71..d0c0b4daec59f23a989a8b8f66ea3c704b0e309c 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -4,13 +4,16 @@ import dev.kaiijumc.kaiiju.region.RegionFileFormat;
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
import me.earthme.luminol.commands.TpsBarCommand;
|
||||
import me.earthme.luminol.functions.GlobalServerTpsBar;
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
+import net.minecraft.world.entity.EntityType;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
+import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -65,6 +68,22 @@ public class LuminolConfig {
|
||||
}
|
||||
}
|
||||
|
||||
+ private static void initEntityTTL() {
|
||||
+ // Set some defaults
|
||||
+ get("optimizations.entity_timeouts.SNOWBALL", -1);
|
||||
+ get("optimizations.entity_timeouts.LLAMA_SPIT", -1);
|
||||
+ MAIN_CONFIG.setComment("optimizations.entity_timeouts",
|
||||
+ """
|
||||
+ These values define a entity's maximum lifespan. If an
|
||||
+ entity is in this list and it has survived for longer than
|
||||
+ that number of ticks, then it will be removed. Setting a value to
|
||||
+ -1 disables this feature.""");
|
||||
+ for (EntityType<?> entityType : BuiltInRegistries.ENTITY_TYPE) {
|
||||
+ String type = EntityType.getKey(entityType).getPath().toUpperCase(Locale.ROOT);
|
||||
+ entityType.ttl = get("optimizations.entity_timeouts." + type, -1);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
public static void initValues(){
|
||||
serverModName = get("misc.server_mod_name",serverModName,"The servermod name will be sent to players,and you can see it in F3 or motd responses");
|
||||
fakeVanillaModeEnabled = get("misc.enable_fake_vanilla_mode",fakeVanillaModeEnabled,"Enable this to make the ping response of your server like a vanilla server");
|
||||
@@ -106,6 +125,7 @@ public class LuminolConfig {
|
||||
|
||||
reduceSensorWork = get("optimizations.reduce_sensor_work",reduceSensorWork,"This optimization is from petal.You can find out more about it on petal's repository");
|
||||
enableSuffocationOptimization = get("optimizations.optimize_suffocation_check",enableSuffocationOptimization);
|
||||
+ initEntityTTL();
|
||||
}
|
||||
|
||||
public static <T> T get(String key,T def){
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 967c7a953084dc68a0ecd4b1a0f13ead7e72cb3d..8bdaab46c2e128aa58d13101170ce358146377a8 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -798,6 +798,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
+ // Pufferfish start - entity TTL
|
||||
+ if (type != EntityType.PLAYER && type.ttl >= 0 && this.tickCount >= type.ttl) {
|
||||
+ discard();
|
||||
+ return;
|
||||
+ }
|
||||
+ // Pufferfish end - entity TTL
|
||||
this.baseTick();
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
index 3f3494c20cd15a721090f1b36293562a6b834b14..4d60ac50a1d3860f2a2e9265aef9507d790220a3 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
@@ -309,6 +309,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
|
||||
private ResourceLocation lootTable;
|
||||
private final EntityDimensions dimensions;
|
||||
private final FeatureFlagSet requiredFeatures;
|
||||
+ public int ttl = -1; // Pufferfish
|
||||
|
||||
private static <T extends Entity> EntityType<T> register(String id, EntityType.Builder type) { // CraftBukkit - decompile error
|
||||
return (EntityType) Registry.register(BuiltInRegistries.ENTITY_TYPE, id, (EntityType<T>) type.build(id)); // CraftBukkit - decompile error
|
||||
@@ -1,39 +1,33 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 05:45:24 +0000
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16:35:37 +0800
|
||||
Subject: [PATCH] Pufferfish Reduce projectile chunk loading
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/ProjectileChunkReduceConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/ProjectileChunkReduceConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..12683ec5a5102e45b6171fea0b833ba57e5e188c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/ProjectileChunkReduceConfig.java
|
||||
@@ -0,0 +1,22 @@
|
||||
+package me.earthme.luminol.config.modules.optimizations;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class ProjectileChunkReduceConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "max-loads-per-tick")
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index d0c0b4daec59f23a989a8b8f66ea3c704b0e309c..11c1a367fbc25cb63738a00ad93fb0b0b3500e7d 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -46,6 +46,8 @@ public class LuminolConfig {
|
||||
|
||||
public static boolean reduceSensorWork = true;
|
||||
public static boolean enableSuffocationOptimization = true;
|
||||
+ public static int maxProjectileLoadsPerTick;
|
||||
+ @ConfigInfo(baseName = "max-loads-per-projectile")
|
||||
+ public static int maxProjectileLoadsPerProjectile;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.OPTIMIZATIONS;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "projectile";
|
||||
+ }
|
||||
+}
|
||||
|
||||
public static void init() throws IOException {
|
||||
PARENT_FOLDER.mkdir();
|
||||
@@ -126,6 +128,8 @@ public class LuminolConfig {
|
||||
reduceSensorWork = get("optimizations.reduce_sensor_work",reduceSensorWork,"This optimization is from petal.You can find out more about it on petal's repository");
|
||||
enableSuffocationOptimization = get("optimizations.optimize_suffocation_check",enableSuffocationOptimization);
|
||||
initEntityTTL();
|
||||
+ maxProjectileLoadsPerTick = get("optimizations.projectile.max-loads-per-tick", maxProjectileLoadsPerTick, "Controls how many chunks are allowed \nto be sync loaded by projectiles in a tick.");
|
||||
+ maxProjectileLoadsPerProjectile = get("optimizations.projectile.max-loads-per-projectile", maxProjectileLoadsPerProjectile, "Controls how many chunks a projectile \n can load in its lifetime before it gets \nautomatically removed.");
|
||||
}
|
||||
|
||||
public static <T> T get(String key,T def){
|
||||
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 0c8f90a904c01105ba5fa6a8037150697bc2621e..527168199605c8c606c6dde563e4fe096b6f17ac 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
@@ -4,6 +4,8 @@ import com.google.common.base.MoreObjects;
|
||||
@@ -45,7 +39,7 @@ index 10d7c64fb3a9bafdcdae99f8dc87017722341337..c366da764e2e11018460430595c14b17
|
||||
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 {
|
||||
@@ -44,6 +46,36 @@ public abstract class Projectile extends Entity implements TraceableEntity {
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
@@ -66,8 +60,8 @@ index 10d7c64fb3a9bafdcdae99f8dc87017722341337..c366da764e2e11018460430595c14b17
|
||||
+ if (previousX != newX || previousZ != newZ) {
|
||||
+ boolean isLoaded = ((net.minecraft.server.level.ServerChunkCache) this.level().getChunkSource()).getChunkAtIfLoadedMainThread(newX, newZ) != null;
|
||||
+ if (!isLoaded) {
|
||||
+ if (Projectile.loadedThisTick > me.earthme.luminol.config.modules.optimizations.ProjectileChunkReduceConfig.maxProjectileLoadsPerTick) {
|
||||
+ if (++this.loadedLifetime > me.earthme.luminol.config.modules.optimizations.ProjectileChunkReduceConfig.maxProjectileLoadsPerProjectile) {
|
||||
+ if (Projectile.loadedThisTick > me.earthme.luminol.LuminolConfig.maxProjectileLoadsPerTick) {
|
||||
+ if (++this.loadedLifetime > me.earthme.luminol.LuminolConfig.maxProjectileLoadsPerProjectile) {
|
||||
+ this.discard();
|
||||
+ }
|
||||
+ return;
|
||||
@@ -1,80 +1,93 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 05:56:56 +0000
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16:44:23 +0800
|
||||
Subject: [PATCH] Pufferfish Dynamic Activation of Brain
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/EntityDABConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/EntityDABConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..af5893ba1f738ec9827d7b714682c314229292d9
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/EntityDABConfig.java
|
||||
@@ -0,0 +1,60 @@
|
||||
+package me.earthme.luminol.config.modules.optimizations;
|
||||
+
|
||||
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.DoNotLoad;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index 11c1a367fbc25cb63738a00ad93fb0b0b3500e7d..4f6af1fa55047e7be9e57c1dd1c60e9d96d12187 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -11,13 +11,16 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
-import java.util.Arrays;
|
||||
-import java.util.List;
|
||||
-import java.util.Locale;
|
||||
+import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import org.bukkit.configuration.ConfigurationSection;
|
||||
+import net.minecraft.world.entity.EntityType;
|
||||
+import java.util.Collections;
|
||||
+import java.util.List;
|
||||
+
|
||||
+public class EntityDABConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean dearEnabled = false;
|
||||
+ @ConfigInfo(baseName = "start_distance",comments =
|
||||
+ "This value determines how far away an entity has to be\n" +
|
||||
+ " from the player to start being effected by DEAR."
|
||||
+ )
|
||||
+ public static int startDistance = 12;
|
||||
+ @DoNotLoad
|
||||
public class LuminolConfig {
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private static final File PARENT_FOLDER = new File("luminol_config");
|
||||
@@ -48,6 +51,12 @@ public class LuminolConfig {
|
||||
public static boolean enableSuffocationOptimization = true;
|
||||
public static int maxProjectileLoadsPerTick;
|
||||
public static int maxProjectileLoadsPerProjectile;
|
||||
+ public static boolean dearEnabled;
|
||||
+ public static int startDistance;
|
||||
+ public static int startDistanceSquared;
|
||||
+ @ConfigInfo(baseName = "max-tick-freq",comments =
|
||||
+ "This value defines how often in ticks, the furthest entity\n"+
|
||||
+ "will get their pathfinders and behaviors ticked. 20 = 1s")
|
||||
+ public static int maximumActivationPrio = 20;
|
||||
+ @ConfigInfo(baseName = "activation-dist-mod",comments =
|
||||
+ """
|
||||
+ This value defines how much distance modifies an entity's
|
||||
+ tick frequency. freq = (distanceToPlayer^2) / (2^value)
|
||||
+ If you want further away entities to tick less often, use 7.
|
||||
+ If you want further away entities to tick more often, try 9.""")
|
||||
+ public static int maximumActivationPrio;
|
||||
+ public static int activationDistanceMod;
|
||||
+ @ConfigInfo(baseName = "blacklisted-entities")
|
||||
+ public static List<String> blackedEntities = Collections.emptyList();
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.OPTIMIZATIONS;
|
||||
+ }
|
||||
|
||||
public static void init() throws IOException {
|
||||
PARENT_FOLDER.mkdir();
|
||||
@@ -86,6 +95,33 @@ public class LuminolConfig {
|
||||
}
|
||||
}
|
||||
|
||||
+ private static void initDAB(){
|
||||
+ dearEnabled = get("optimizations.dab.enabled", true);
|
||||
+ startDistance = get("optimizations.dab.start-distance", 12,
|
||||
+ "This value determines how far away an entity has to be\n"+
|
||||
+ "from the player to start being effected by DEAR.");
|
||||
+ startDistanceSquared = startDistance * startDistance;
|
||||
+ maximumActivationPrio = get("optimizations.dab.max-tick-freq",20,
|
||||
+ "This value defines how often in ticks, the furthest entity\n"+
|
||||
+ "will get their pathfinders and behaviors ticked. 20 = 1s");
|
||||
+ activationDistanceMod = get("optimizations.dab.activation-dist-mod",8,
|
||||
+ """
|
||||
+ This value defines how much distance modifies an entity's
|
||||
+ tick frequency. freq = (distanceToPlayer^2) / (2^value)
|
||||
+ If you want further away entities to tick less often, use 7.
|
||||
+ If you want further away entities to tick more often, try 9.""");
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "dab";
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onLoaded(CommentedFileConfig config) {
|
||||
+ for (EntityType<?> entityType : BuiltInRegistries.ENTITY_TYPE) {
|
||||
+ entityType.dabEnabled = true; // reset all, before setting the ones to true
|
||||
+ }
|
||||
+
|
||||
+ blackedEntities.forEach(name -> EntityType.byString(name).ifPresentOrElse(entityType -> {
|
||||
+ get("optimizations.dab.blacklisted-entities",Collections.<String>emptyList(), "A list of entities to ignore for activation")
|
||||
+ .forEach(name -> EntityType.byString(name).ifPresentOrElse(entityType -> {
|
||||
+ entityType.dabEnabled = false;
|
||||
+ }, () -> MinecraftServer.LOGGER.warn("Unknown entity \"" + name + "\"")));
|
||||
+ }, () -> MinecraftServer.LOGGER.warn("Unknown entity \"" + name + "\"")));
|
||||
+
|
||||
+ config.setComment("optimizations.dab", "Optimizes entity brains when\n" + "they're far away from the player");
|
||||
+ MAIN_CONFIG.setComment("optimizations.dab", "Optimizes entity brains when\n"+"they're far away from the player");
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
public static void initValues(){
|
||||
serverModName = get("misc.server_mod_name",serverModName,"The servermod name will be sent to players,and you can see it in F3 or motd responses");
|
||||
fakeVanillaModeEnabled = get("misc.enable_fake_vanilla_mode",fakeVanillaModeEnabled,"Enable this to make the ping response of your server like a vanilla server");
|
||||
@@ -130,6 +166,7 @@ public class LuminolConfig {
|
||||
initEntityTTL();
|
||||
maxProjectileLoadsPerTick = get("optimizations.projectile.max-loads-per-tick", maxProjectileLoadsPerTick, "Controls how many chunks are allowed \nto be sync loaded by projectiles in a tick.");
|
||||
maxProjectileLoadsPerProjectile = get("optimizations.projectile.max-loads-per-projectile", maxProjectileLoadsPerProjectile, "Controls how many chunks a projectile \n can load in its lifetime before it gets \nautomatically removed.");
|
||||
+ initDAB();
|
||||
}
|
||||
|
||||
public static <T> T get(String key,T def){
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index c06ddc99a0971be46746c767ad8ce590a8e2ee30..f3f095e6acbe50154503524b160255394f4d9ec6 100644
|
||||
index 561681deaf647277ecde64eed4cfbd9f38b5fed1..2ba86122ccb444908c35ea5cc1e245f5068a054a 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -987,6 +987,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
@@ -982,6 +982,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
this.timings.entityTick.startTiming(); // Spigot
|
||||
profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_TICK); try { // Folia - profiler
|
||||
regionizedWorldData.forEachTickingEntity((entity) -> { // Folia - regionised ticking
|
||||
@@ -83,26 +96,26 @@ index c06ddc99a0971be46746c767ad8ce590a8e2ee30..f3f095e6acbe50154503524b16025539
|
||||
if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed
|
||||
entity.discard();
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index f120f977e3535847a1e3a009a25eb0137fce6ab0..d62734c0365af706c136274faf3e135f6ea099ee 100644
|
||||
index 8bdaab46c2e128aa58d13101170ce358146377a8..56efbcc29adca0239ef09a269f0899a3a6e2801b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -482,6 +482,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
|
||||
// Folia - region ticking
|
||||
// Paper end - optimise entity tracking
|
||||
+ //Pufferfish start
|
||||
@@ -436,6 +436,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
return this.originWorld;
|
||||
}
|
||||
// Paper end
|
||||
+ // Pufferfish start
|
||||
+ public boolean activatedPriorityReset = false; // DAB
|
||||
+ public int activatedPriority = me.earthme.luminol.config.modules.optimizations.EntityDABConfig.maximumActivationPrio; // golf score
|
||||
+ public int activatedPriority = LuminolConfig.maximumActivationPrio; // golf score
|
||||
+ // Pufferfish end
|
||||
+
|
||||
+
|
||||
public float getBukkitYaw() {
|
||||
return this.yRot;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
index 8deae3e95a26f4b42b2c2134e22f9649bd7a5391..c09357c1ef84a29d972119cb496b0ae97f98e4f4 100644
|
||||
index 4d60ac50a1d3860f2a2e9265aef9507d790220a3..0867c85964952ec118ea7517cd5ef570be1ee982 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
@@ -305,6 +305,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
|
||||
@@ -301,6 +301,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
|
||||
private final boolean canSpawnFarFromPlayer;
|
||||
private final int clientTrackingRange;
|
||||
private final int updateInterval;
|
||||
@@ -111,10 +124,10 @@ index 8deae3e95a26f4b42b2c2134e22f9649bd7a5391..c09357c1ef84a29d972119cb496b0ae9
|
||||
private String descriptionId;
|
||||
@Nullable
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index 9636f69fab9f34f3b3f4590f151248cd5b2da089..50a144b0122c970856ef3faa3f899ee72e2a6300 100644
|
||||
index d3f8aa29b05a3813c0ec6e2ea5a253868abd6b07..54e821351e46d25e8b0ead52d2c8dfecd1957544 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -233,10 +233,10 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||
@@ -234,10 +234,10 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
super.inactiveTick();
|
||||
@@ -149,16 +162,25 @@ index 9636f69fab9f34f3b3f4590f151248cd5b2da089..50a144b0122c970856ef3faa3f899ee7
|
||||
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
|
||||
index 676f5485a4ca9252e911213dcda8d51776b637b6..0f53c206b4c0607e2cda5cfa4edeae5209e897bf 100644
|
||||
index b738ee2d3801fadfd09313f05ae24593e56b0ec6..9306ab8d2b6eeb73f86d4d94c0065d461905d702 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
||||
@@ -53,9 +53,12 @@ public class GoalSelector {
|
||||
@@ -11,6 +11,8 @@ import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
+
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -53,9 +55,12 @@ public class GoalSelector {
|
||||
}
|
||||
|
||||
// Paper start
|
||||
- public boolean inactiveTick() {
|
||||
+ public boolean inactiveTick(int tickRate, boolean inactive) { // Pufferfish start
|
||||
+ if (inactive && !me.earthme.luminol.config.modules.optimizations.EntityDABConfig.dearEnabled) tickRate = 4; // reset to Paper's
|
||||
+ if (inactive && !LuminolConfig.dearEnabled) tickRate = 4; // reset to Paper's
|
||||
+ tickRate = Math.min(tickRate, this.newGoalRate);
|
||||
this.curRate++;
|
||||
- return this.curRate % this.newGoalRate == 0;
|
||||
@@ -184,10 +206,10 @@ index 5ad5f22e5aa26445e5eb229958e7bf356bdd460e..d241ca4d0295f9fce39c11197bd435cf
|
||||
this.level().getProfiler().pop();
|
||||
this.level().getProfiler().push("allayActivityUpdate");
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
index b21e180641d17438997a80e5bcb0ec7998d24a2e..33c160994f70f71446d665e7487913437c9f9db4 100644
|
||||
index d5b97d4316390028f54aa9bb9fa52b0b003e32a0..b4793b88688bd568a428aa520e880f0038de45a7 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
@@ -275,9 +275,11 @@ public class Axolotl extends Animal implements LerpingModel, VariantHolder<Axolo
|
||||
@@ -280,9 +280,11 @@ public class Axolotl extends Animal implements LerpingModel, VariantHolder<Axolo
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -200,11 +222,11 @@ index b21e180641d17438997a80e5bcb0ec7998d24a2e..33c160994f70f71446d665e748791343
|
||||
this.level().getProfiler().pop();
|
||||
this.level().getProfiler().push("axolotlActivityUpdate");
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
index 580da502c62ec5d669cb09932d99d1c7d711c965..b94d775e366f5cb251e9199ff5022ad53129da76 100644
|
||||
index 5000ebc5f19dee72a86360062b822aecd60beb47..c8e3d47b3f2dc919cca8ad397095437f1da6c762 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
@@ -159,9 +159,11 @@ public class Frog extends Animal implements VariantHolder<FrogVariant> {
|
||||
|
||||
@@ -164,9 +164,11 @@ public class Frog extends Animal implements VariantHolder<FrogVariant> {
|
||||
return true;
|
||||
}
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@@ -232,7 +254,7 @@ index 4aeab90e778629c355189dfe79c39c4b21f5f5ac..6ed4ac06c76b8d0d6e8db778cade15db
|
||||
this.level().getProfiler().pop();
|
||||
this.level().getProfiler().push("tadpoleActivityUpdate");
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
index 5d247ac38fe8a61603b3d934f3000bcda773142b..2e4177cfb02616ef6fa689f6d378976e39484cfb 100644
|
||||
index 111a244087e24f25ba8524a46a228da10cd9498a..ff12ba2b79cb2e7e0bfd0e3b58ff6cb9e770092b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
@@ -191,9 +191,11 @@ public class Goat extends Animal {
|
||||
@@ -248,7 +270,7 @@ index 5d247ac38fe8a61603b3d934f3000bcda773142b..2e4177cfb02616ef6fa689f6d378976e
|
||||
this.level().getProfiler().pop();
|
||||
this.level().getProfiler().push("goatActivityUpdate");
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java b/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
||||
index 01a2016ac82807d28ffe407b7dbb74bdbcde503e..9921b160fb21f72fbd28fe81ea66fbc3dc05f83f 100644
|
||||
index 4257f2282152aee09533c9a2e53018d3e49effa4..e703320717ff620a19ff76d1c10066117c9895d5 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
||||
@@ -128,9 +128,11 @@ public class Hoglin extends Animal implements Enemy, HoglinBase {
|
||||
@@ -264,7 +286,7 @@ index 01a2016ac82807d28ffe407b7dbb74bdbcde503e..9921b160fb21f72fbd28fe81ea66fbc3
|
||||
this.level().getProfiler().pop();
|
||||
HoglinAi.updateActivity(this);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java b/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||
index a9813da7f2b248f98f22e0ad2e7842915025ec12..83d83e3f84bb6bd58761671c6cd4c8683545ff4c 100644
|
||||
index 6407ddef8442fce4f310ac4babf3e3de0dd5fc9a..cfdc1650783d6855e0d4f33ec68aab48dbee09f0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||
@@ -300,9 +300,11 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento
|
||||
@@ -280,10 +302,10 @@ index a9813da7f2b248f98f22e0ad2e7842915025ec12..83d83e3f84bb6bd58761671c6cd4c868
|
||||
this.level().getProfiler().pop();
|
||||
PiglinAi.updateActivity(this);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
||||
index 7aadd36f0fe986635b495ab8c1426644620400cf..0c947d7509d66647327bce885ad2c6051f41c56f 100644
|
||||
index b2bc3a832c310448046ccde37a04918aa6d63197..5e43912708f9074dee1bb351efa737a7e6796fc3 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
||||
@@ -273,11 +273,13 @@ public class Warden extends Monster implements VibrationSystem {
|
||||
@@ -272,11 +272,13 @@ public class Warden extends Monster implements VibrationSystem {
|
||||
|
||||
}
|
||||
|
||||
@@ -298,7 +320,7 @@ index 7aadd36f0fe986635b495ab8c1426644620400cf..0c947d7509d66647327bce885ad2c605
|
||||
this.level().getProfiler().pop();
|
||||
super.customServerAiStep();
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
index 853c777bad19656cd48e9de9015c12e2c078d940..fba0f3725ff3001decdb9efeeab50dd7ce3e4ddc 100644
|
||||
index 4e9ccc518f37755e86687653f7724240db754682..a94661deaa6e1288bb957dc5d7711c5d03b9e460 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
@@ -142,6 +142,8 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -332,10 +354,17 @@ index 853c777bad19656cd48e9de9015c12e2c078d940..fba0f3725ff3001decdb9efeeab50dd7
|
||||
if (this.assignProfessionWhenSpawned) {
|
||||
this.assignProfessionWhenSpawned = false;
|
||||
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
index 50fafff765b2494c075784cc5342d086c8dc97b2..78b495ffbb1ca753714304e2a18035bcfd84b918 100644
|
||||
index 22daed525b023998a05884db603e2c7385ce0873..e77e1c60a611c49489c65d66e54236a86c3093e3 100644
|
||||
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
||||
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
@@ -38,6 +38,10 @@ import co.aikar.timings.MinecraftTimings;
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.spigotmc;
|
||||
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerChunkCache;
|
||||
@@ -38,6 +39,10 @@ import co.aikar.timings.MinecraftTimings;
|
||||
import net.minecraft.world.entity.schedule.Activity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
@@ -346,24 +375,24 @@ index 50fafff765b2494c075784cc5342d086c8dc97b2..78b495ffbb1ca753714304e2a18035bc
|
||||
|
||||
public class ActivationRange
|
||||
{
|
||||
@@ -230,6 +234,25 @@ public class ActivationRange
|
||||
@@ -230,6 +235,25 @@ public class ActivationRange
|
||||
}
|
||||
// Paper end - Configurable marker ticking
|
||||
ActivationRange.activateEntity(entity, bbByType); // Folia - threaded regions
|
||||
// Paper end - configurable marker ticking
|
||||
ActivationRange.activateEntity(entity);
|
||||
+
|
||||
+ // Pufferfish start
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.EntityDABConfig.dearEnabled && entity.getType().dabEnabled) {
|
||||
+ if (LuminolConfig.dearEnabled && entity.getType().dabEnabled) {
|
||||
+ if (!entity.activatedPriorityReset) {
|
||||
+ entity.activatedPriorityReset = true;
|
||||
+ entity.activatedPriority = me.earthme.luminol.config.modules.optimizations.EntityDABConfig.maximumActivationPrio;
|
||||
+ entity.activatedPriority = LuminolConfig.maximumActivationPrio;
|
||||
+ }
|
||||
+ Vec3 playerVec = player.position();
|
||||
+ Vec3 entityVec = entity.position();
|
||||
+ double diffX = playerVec.x - entityVec.x, diffY = playerVec.y - entityVec.y, diffZ = playerVec.z - entityVec.z;
|
||||
+ int squaredDistance = (int) (diffX * diffX + diffY * diffY + diffZ * diffZ);
|
||||
+ entity.activatedPriority = squaredDistance > me.earthme.luminol.config.modules.optimizations.EntityDABConfig.startDistanceSquared ?
|
||||
+ Math.max(1, Math.min(squaredDistance >> me.earthme.luminol.config.modules.optimizations.EntityDABConfig.activationDistanceMod, entity.activatedPriority)) :
|
||||
+ 1;
|
||||
+ entity.activatedPriority = squaredDistance > LuminolConfig.startDistanceSquared ?
|
||||
+ Math.max(1, Math.min(squaredDistance >> LuminolConfig.activationDistanceMod, entity.activatedPriority)) :
|
||||
+ 1;
|
||||
+ } else {
|
||||
+ entity.activatedPriority = 1;
|
||||
+ }
|
||||
@@ -372,7 +401,7 @@ index 50fafff765b2494c075784cc5342d086c8dc97b2..78b495ffbb1ca753714304e2a18035bc
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
@@ -246,12 +269,12 @@ public class ActivationRange
|
||||
@@ -246,12 +270,12 @@ public class ActivationRange
|
||||
if ( io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick() > entity.activatedTick ) // Folia - threaded regions
|
||||
{
|
||||
if ( entity.defaultActivationState )
|
||||
@@ -381,7 +410,7 @@ index 50fafff765b2494c075784cc5342d086c8dc97b2..78b495ffbb1ca753714304e2a18035bc
|
||||
entity.activatedTick = io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick(); // Folia - threaded regions
|
||||
return;
|
||||
}
|
||||
if ( bbByType[entity.activationType.ordinal()].intersects( entity.getBoundingBox() ) ) // Folia - threaded regions
|
||||
if ( entity.activationType.boundingBox.intersects( entity.getBoundingBox() ) )
|
||||
- {
|
||||
+ { // Pufferfish - diff on change
|
||||
entity.activatedTick = io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick(); // Folia - threaded regions
|
||||
@@ -1,40 +1,34 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 06:00:22 +0000
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 17:08:22 +0800
|
||||
Subject: [PATCH] Gale Variable entity wake-up duration
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/GaleVariableEntityWakeupConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/GaleVariableEntityWakeupConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..fa30e8dc39a2d4bd1399e41230b307b19eeb716a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/GaleVariableEntityWakeupConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.optimizations;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class GaleVariableEntityWakeupConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "entity_wakeup_duration_ratio_standard_deviation")
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index 4f6af1fa55047e7be9e57c1dd1c60e9d96d12187..793dc5b35e9a0665d486a74ce5b776b43b941ee2 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -56,6 +56,7 @@ public class LuminolConfig {
|
||||
public static int startDistanceSquared;
|
||||
public static int maximumActivationPrio;
|
||||
public static int activationDistanceMod;
|
||||
+ public static double entityWakeUpDurationRatioStandardDeviation = 0.2;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.OPTIMIZATIONS;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "variable_entity_waking_up";
|
||||
+ }
|
||||
+}
|
||||
|
||||
|
||||
public static void init() throws IOException {
|
||||
@@ -167,6 +168,7 @@ public class LuminolConfig {
|
||||
maxProjectileLoadsPerTick = get("optimizations.projectile.max-loads-per-tick", maxProjectileLoadsPerTick, "Controls how many chunks are allowed \nto be sync loaded by projectiles in a tick.");
|
||||
maxProjectileLoadsPerProjectile = get("optimizations.projectile.max-loads-per-projectile", maxProjectileLoadsPerProjectile, "Controls how many chunks a projectile \n can load in its lifetime before it gets \nautomatically removed.");
|
||||
initDAB();
|
||||
+ entityWakeUpDurationRatioStandardDeviation = get("optimizations.entity_wakeup_duration_ratio_standard_deviation",entityWakeUpDurationRatioStandardDeviation);
|
||||
}
|
||||
|
||||
public static <T> T get(String key,T def){
|
||||
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
index 78b495ffbb1ca753714304e2a18035bcfd84b918..e9331fe4d524215bbab9a410d16e4f1811f5ad31 100644
|
||||
index e77e1c60a611c49489c65d66e54236a86c3093e3..51adf24b9274b6bc78ef94e77a0b2d73b1f2bbbb 100644
|
||||
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
||||
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
@@ -75,28 +75,41 @@ public class ActivationRange
|
||||
@@ -76,28 +76,40 @@ public class ActivationRange
|
||||
if (entity.activationType == ActivationType.VILLAGER) {
|
||||
if (inactiveFor > config.wakeUpInactiveVillagersEvery && worldData.wakeupInactiveRemainingVillagers > 0) { // Folia - threaded regions
|
||||
worldData.wakeupInactiveRemainingVillagers--; // Folia - threaded regions
|
||||
@@ -65,10 +59,10 @@ index 78b495ffbb1ca753714304e2a18035bcfd84b918..e9331fe4d524215bbab9a410d16e4f18
|
||||
// Paper end
|
||||
|
||||
+ // Gale start - variable entity wake-up duration
|
||||
+ private static final java.util.concurrent.ThreadLocalRandom wakeUpDurationRandom = java.util.concurrent.ThreadLocalRandom.current();
|
||||
+ private static final java.util.Random wakeUpDurationRandom = new java.util.Random();
|
||||
+
|
||||
+ private static int getWakeUpDurationWithVariance(Entity entity, int wakeUpDuration) {
|
||||
+ double deviation = me.earthme.luminol.config.modules.optimizations.GaleVariableEntityWakeupConfig.entityWakeUpDurationRatioStandardDeviation;
|
||||
+ double deviation = LuminolConfig.entityWakeUpDurationRatioStandardDeviation;
|
||||
+ if (deviation <= 0) {
|
||||
+ return wakeUpDuration;
|
||||
+ }
|
||||
@@ -76,7 +70,6 @@ index 78b495ffbb1ca753714304e2a18035bcfd84b918..e9331fe4d524215bbab9a410d16e4f18
|
||||
+ }
|
||||
+ // Gale end - variable entity wake-up duration
|
||||
+
|
||||
+
|
||||
// Folia - threaded regions - replaced by local variable
|
||||
static AABB maxBB = new AABB( 0, 0, 0, 0, 0, 0 );
|
||||
|
||||
/**
|
||||
@@ -1,40 +1,34 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 06:03:02 +0000
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 17:21:11 +0800
|
||||
Subject: [PATCH] Gale Don't load chunks to activate climbing entities
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/LoadChunksToActiveClimbingEntitiesConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/LoadChunksToActiveClimbingEntitiesConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ed62d25d6cd6dfcf8c5db20ced36eb3d3c79dafd
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/LoadChunksToActiveClimbingEntitiesConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.optimizations;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class LoadChunksToActiveClimbingEntitiesConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "allow")
|
||||
+ public static boolean allow = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.OPTIMIZATIONS;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "load_chunks_to_active_climbing_entities";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index 793dc5b35e9a0665d486a74ce5b776b43b941ee2..fcd532898e099a809969603941b90fdd415b03c3 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -57,6 +57,7 @@ public class LuminolConfig {
|
||||
public static int maximumActivationPrio;
|
||||
public static int activationDistanceMod;
|
||||
public static double entityWakeUpDurationRatioStandardDeviation = 0.2;
|
||||
+ public static boolean loadChunksToActiveClimbingEntities = false;
|
||||
|
||||
|
||||
public static void init() throws IOException {
|
||||
@@ -169,6 +170,7 @@ public class LuminolConfig {
|
||||
maxProjectileLoadsPerProjectile = get("optimizations.projectile.max-loads-per-projectile", maxProjectileLoadsPerProjectile, "Controls how many chunks a projectile \n can load in its lifetime before it gets \nautomatically removed.");
|
||||
initDAB();
|
||||
entityWakeUpDurationRatioStandardDeviation = get("optimizations.entity_wakeup_duration_ratio_standard_deviation",entityWakeUpDurationRatioStandardDeviation);
|
||||
+ loadChunksToActiveClimbingEntities = get("optimizations.load_chunks_to_active_climbing_entities",loadChunksToActiveClimbingEntities);
|
||||
}
|
||||
|
||||
public static <T> T get(String key,T def){
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index d62734c0365af706c136274faf3e135f6ea099ee..bc655e3db34630a419be883b0dcc1ba4d5bbeb90 100644
|
||||
index 56efbcc29adca0239ef09a269f0899a3a6e2801b..54daa1744c89e98136d0f594a35119d5fd3d6bc8 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -5441,6 +5441,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -5330,6 +5330,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
return this.feetBlockState;
|
||||
}
|
||||
|
||||
@@ -52,17 +46,17 @@ index d62734c0365af706c136274faf3e135f6ea099ee..bc655e3db34630a419be883b0dcc1ba4
|
||||
return this.chunkPosition;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 3731013a4369dac2130045bdc2bbde170075a3df..39f054b9352376336b543c1ca4e9be9a6dee79b3 100644
|
||||
index f13d26b280f095d006ffccb36af66bb7487cb8da..ecbacbed29af51d949122b21c3ae9fc95885c6d8 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -2046,19 +2046,43 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -2027,19 +2027,43 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
|
||||
public boolean onClimableCached() {
|
||||
if (!this.blockPosition().equals(this.lastClimbingPosition)) {
|
||||
- this.cachedOnClimable = this.onClimbable();
|
||||
- this.lastClimbingPosition = this.blockPosition();
|
||||
+ // Gale start - don't load chunks to activate climbing entities
|
||||
+ Boolean onClimbableIfLoaded = this.onClimbable(me.earthme.luminol.config.modules.optimizations.LoadChunksToActiveClimbingEntitiesConfig.allow);
|
||||
+ Boolean onClimbableIfLoaded = this.onClimbable(LuminolConfig.loadChunksToActiveClimbingEntities);
|
||||
+ if (onClimbableIfLoaded != null) {
|
||||
+ this.cachedOnClimable = onClimbableIfLoaded;
|
||||
+ this.lastClimbingPosition = this.blockPosition();
|
||||
@@ -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
|
||||
index bc655e3db34630a419be883b0dcc1ba4d5bbeb90..bf530eb5e039f37b9bea37d2a61ee31fdab8c8a9 100644
|
||||
index 54daa1744c89e98136d0f594a35119d5fd3d6bc8..6f3e87661c3181b6537e4d6d96e50d8d5680c040 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -309,7 +309,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -307,7 +307,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
public double xo;
|
||||
public double yo;
|
||||
public double zo;
|
||||
@@ -17,7 +17,7 @@ index bc655e3db34630a419be883b0dcc1ba4d5bbeb90..bf530eb5e039f37b9bea37d2a61ee31f
|
||||
public BlockPos blockPosition; // Pufferfish - private->public
|
||||
private ChunkPos chunkPosition;
|
||||
private Vec3 deltaMovement;
|
||||
@@ -2052,9 +2052,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -2026,9 +2026,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
/** @deprecated */
|
||||
@Deprecated
|
||||
public float getLightLevelDependentMagicValue() {
|
||||
@@ -37,10 +37,10 @@ index bc655e3db34630a419be883b0dcc1ba4d5bbeb90..bf530eb5e039f37b9bea37d2a61ee31f
|
||||
this.absMoveTo(x, y, z);
|
||||
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
|
||||
index 7378c9cb5eeddc7cefc409638179dfb8602ed0d0..d83a6adc34c64652f1070651f5c96579a5c45e67 100644
|
||||
index 54e821351e46d25e8b0ead52d2c8dfecd1957544..394913950ac8fbcfcdbce817bac95f3b6604beb7 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -1749,13 +1749,29 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||
@@ -1736,13 +1736,29 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 17:30:32 +0800
|
||||
Subject: [PATCH] Gale Reduce acquire POI for stuck entities
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index fcd532898e099a809969603941b90fdd415b03c3..d032786938db9725e1be72dae63a1387bcb69d79 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -12,14 +12,10 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.*;
|
||||
-import java.util.logging.Level;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
-import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
-import org.bukkit.configuration.ConfigurationSection;
|
||||
-import net.minecraft.world.entity.EntityType;
|
||||
|
||||
public class LuminolConfig {
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
@@ -58,6 +54,7 @@ public class LuminolConfig {
|
||||
public static int activationDistanceMod;
|
||||
public static double entityWakeUpDurationRatioStandardDeviation = 0.2;
|
||||
public static boolean loadChunksToActiveClimbingEntities = false;
|
||||
+ public static int acquirePoiForStuckEntityInterval = 60;
|
||||
|
||||
|
||||
public static void init() throws IOException {
|
||||
@@ -171,6 +168,7 @@ public class LuminolConfig {
|
||||
initDAB();
|
||||
entityWakeUpDurationRatioStandardDeviation = get("optimizations.entity_wakeup_duration_ratio_standard_deviation",entityWakeUpDurationRatioStandardDeviation);
|
||||
loadChunksToActiveClimbingEntities = get("optimizations.load_chunks_to_active_climbing_entities",loadChunksToActiveClimbingEntities);
|
||||
+ acquirePoiForStuckEntityInterval = get("optimizations.acquire_poi_for_stuck_entity_interval", acquirePoiForStuckEntityInterval);
|
||||
}
|
||||
|
||||
public static <T> T get(String key,T def){
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
||||
index 8f8b29f80d1573981ccffd207dd6e0941e71a352..ba4cdaf499c7ffef0c7fbdd575bdba841bcb7282 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
||||
@@ -7,12 +7,14 @@ import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
-import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
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.util.RandomSource;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.PathfinderMob;
|
||||
@@ -26,6 +28,13 @@ import org.apache.commons.lang3.mutable.MutableLong;
|
||||
public class AcquirePoi {
|
||||
public static final int SCAN_RANGE = 48;
|
||||
|
||||
+ // Gale start - Airplane - reduce acquire POI for stuck entities
|
||||
+ public static void addAdditionalTimeToMutableLongIfEntityIsStuck(MutableLong mutableLong, ServerLevel world, PathfinderMob entity) {
|
||||
+ long stuckEntityAdditionalWaitTime = LuminolConfig.acquirePoiForStuckEntityInterval;
|
||||
+ mutableLong.add(stuckEntityAdditionalWaitTime <= 0L ? 0L : entity.getNavigation().isStuck() ? stuckEntityAdditionalWaitTime : 0L);
|
||||
+ }
|
||||
+ // Gale end - Airplane - reduce acquire POI for stuck entities
|
||||
+
|
||||
public static BehaviorControl<PathfinderMob> create(Predicate<Holder<PoiType>> poiPredicate, MemoryModuleType<GlobalPos> poiPosModule, boolean onlyRunIfChild, Optional<Byte> entityStatus) {
|
||||
return create(poiPredicate, poiPosModule, poiPosModule, onlyRunIfChild, entityStatus);
|
||||
}
|
||||
@@ -42,12 +51,13 @@ public class AcquirePoi {
|
||||
return false;
|
||||
} else if (mutableLong.getValue() == 0L) {
|
||||
mutableLong.setValue(world.getGameTime() + (long)world.random.nextInt(20));
|
||||
+ addAdditionalTimeToMutableLongIfEntityIsStuck(mutableLong, world, entity); // Gale - Airplane - reduce acquire POI for stuck entities
|
||||
return false;
|
||||
} else if (world.getGameTime() < mutableLong.getValue()) {
|
||||
return false;
|
||||
} else {
|
||||
mutableLong.setValue(time + 20L + (long)world.getRandom().nextInt(20));
|
||||
- if (entity.getNavigation().isStuck()) mutableLong.add(200); // Paper - Wait an additional 10s to check again if they're stuck
|
||||
+ addAdditionalTimeToMutableLongIfEntityIsStuck(mutableLong, world, entity); // Gale - Airplane - reduce acquire POI for stuck entities
|
||||
PoiManager poiManager = world.getPoiManager();
|
||||
long2ObjectMap.long2ObjectEntrySet().removeIf((entry) -> {
|
||||
return !entry.getValue().isStillValid(time);
|
||||
@@ -0,0 +1,24 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 17:30:32 +0800
|
||||
Subject: [PATCH] Gale Skip secondary POI sensor if absent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
|
||||
index cb1d91f9fe98f21c2afbe3894dfd9bca3bdd3ba6..75dc06a3041bfdfb08c914eb50cfa282ae9eb2fe 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
|
||||
@@ -22,6 +22,13 @@ public class SecondaryPoiSensor extends Sensor<Villager> {
|
||||
|
||||
@Override
|
||||
protected void doTick(ServerLevel world, Villager entity) {
|
||||
+ // Gale start - Lithium - skip secondary POI sensor if absent
|
||||
+ var secondaryPoi = entity.getVillagerData().getProfession().secondaryPoi();
|
||||
+ if (secondaryPoi.isEmpty()) {
|
||||
+ entity.getBrain().eraseMemory(MemoryModuleType.SECONDARY_JOB_SITE);
|
||||
+ return;
|
||||
+ }
|
||||
+ // Gale end - Lithium - skip secondary POI sensor if absent
|
||||
ResourceKey<Level> resourceKey = world.dimension();
|
||||
BlockPos blockPos = entity.blockPosition();
|
||||
List<GlobalPos> list = Lists.newArrayList();
|
||||
@@ -1,79 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 05:19:37 +0000
|
||||
Subject: [PATCH] Pufferfish Entity TTL
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/EntityTTLOptimizationConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/EntityTTLOptimizationConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..15697d69659b6e1e776acf5094684b5f0c079b57
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/EntityTTLOptimizationConfig.java
|
||||
@@ -0,0 +1,38 @@
|
||||
+package me.earthme.luminol.config.modules.optimizations;
|
||||
+
|
||||
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
+import net.minecraft.world.entity.EntityType;
|
||||
+
|
||||
+import java.util.Locale;
|
||||
+
|
||||
+public class EntityTTLOptimizationConfig implements IConfigModule {
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.OPTIMIZATIONS;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "entity_time_outs";
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onLoaded(CommentedFileConfig config) {
|
||||
+ // Set some defaults
|
||||
+ this.get("optimizations.entity_timeouts.SNOWBALL", -1,config);
|
||||
+ this.get("optimizations.entity_timeouts.LLAMA_SPIT", -1,config);
|
||||
+ config.setComment("optimizations.entity_timeouts",
|
||||
+ """
|
||||
+ These values define a entity's maximum lifespan. If an
|
||||
+ entity is in this list and it has survived for longer than
|
||||
+ that number of ticks, then it will be removed. Setting a value to
|
||||
+ -1 disables this feature.""");
|
||||
+ for (EntityType<?> entityType : BuiltInRegistries.ENTITY_TYPE) {
|
||||
+ String type = EntityType.getKey(entityType).getPath().toUpperCase(Locale.ROOT);
|
||||
+ entityType.ttl = this.get("optimizations.entity_timeouts." + type, -1,config);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 0b201fd79233ed0a5c2d298b283a15497dffd8e5..f120f977e3535847a1e3a009a25eb0137fce6ab0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -798,6 +798,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
+ // Pufferfish start - entity TTL
|
||||
+ if (type != EntityType.PLAYER && type.ttl >= 0 && this.tickCount >= type.ttl) {
|
||||
+ discard();
|
||||
+ return;
|
||||
+ }
|
||||
+ // Pufferfish end - entity TTL
|
||||
this.baseTick();
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
index f921c159c4f7556daf3c8405241de3607ba251ad..8deae3e95a26f4b42b2c2134e22f9649bd7a5391 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
@@ -313,6 +313,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
|
||||
private ResourceLocation lootTable;
|
||||
private final EntityDimensions dimensions;
|
||||
private final FeatureFlagSet requiredFeatures;
|
||||
+ public int ttl = -1; // Pufferfish
|
||||
|
||||
private static <T extends Entity> EntityType<T> register(String id, EntityType.Builder type) { // CraftBukkit - decompile error
|
||||
return (EntityType) Registry.register(BuiltInRegistries.ENTITY_TYPE, id, (EntityType<T>) type.build(id)); // CraftBukkit - decompile error
|
||||
@@ -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
|
||||
index 13b1bf1d3dea42d0d0d45ebd2c9ccbf6928c395b..24c05e40c9eeeb4a181d2f9994b0e786393046b9 100644
|
||||
index 6f3e87661c3181b6537e4d6d96e50d8d5680c040..3a5c8f1f9a8173777b00d43c15e8e313526d3e28 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -4176,12 +4176,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -4108,12 +4108,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
targetPos, 16, // load 16 blocks to be safe from block physics
|
||||
ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.HIGH,
|
||||
(chunks) -> {
|
||||
@@ -28,7 +28,7 @@ index 13b1bf1d3dea42d0d0d45ebd2c9ccbf6928c395b..24c05e40c9eeeb4a181d2f9994b0e786
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -4368,6 +4373,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -4300,6 +4305,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
if (!this.canPortalAsync(takePassengers)) {
|
||||
return false;
|
||||
}
|
||||
@@ -39,7 +39,7 @@ index 13b1bf1d3dea42d0d0d45ebd2c9ccbf6928c395b..24c05e40c9eeeb4a181d2f9994b0e786
|
||||
|
||||
Vec3 initialPosition = this.position();
|
||||
ChunkPos initialPositionChunk = new ChunkPos(
|
||||
@@ -4426,7 +4435,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -4358,7 +4367,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
// place
|
||||
passengerTree.root.placeInAsync(
|
||||
originWorld, destination, Entity.TELEPORT_FLAG_LOAD_CHUNK | (takePassengers ? Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS : 0L),
|
||||
@@ -0,0 +1,99 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 21:23:06 +0800
|
||||
Subject: [PATCH] Try fixing folia spector teleportation
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index d032786938db9725e1be72dae63a1387bcb69d79..dcc52141b34b87a67c3d6070b68b58af4a7c4f26 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -31,6 +31,7 @@ public class LuminolConfig {
|
||||
public static String[] tpsColors = new String[]{"GREEN","YELLOW","RED","PURPLE"};
|
||||
public static String[] pingColors = new String[]{"GREEN","YELLOW","RED","PURPLE"};
|
||||
public static boolean disableUsernameCheck = false;
|
||||
+ public static boolean fixSpectorTeleportFolia = false;
|
||||
|
||||
public static boolean safeTeleportation = true;
|
||||
public static boolean enableSandDuping = false;
|
||||
@@ -130,6 +131,7 @@ public class LuminolConfig {
|
||||
tpsColors = get("misc.tpsbar_range_colors", List.of(tpsColors),"The bar and text color of each tps ranges.The last is the color of initial bar's color").toArray(String[]::new);
|
||||
pingColors = get("misc.tpsbar_ping_range_colors",List.of(pingColors),"As same as the tpsColors").toArray(String[]::new);
|
||||
disableUsernameCheck = get("misc.disable_username_check",disableUsernameCheck,"Disable username check that can accept usernames with other characters(such as Chinese).Not recommended to use");
|
||||
+ fixSpectorTeleportFolia = get("misc.fix_folia_spector_teleport",fixSpectorTeleportFolia);
|
||||
|
||||
if (tpsbarEnabled){
|
||||
initTpsbar();
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index d7a280427442bac8cc8ccb542d24d4e0901df70a..755294e3f5b3fbcfbdc0cc85627b2487663ce591 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -18,6 +18,9 @@ import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import io.papermc.paper.util.TickThread;
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.BlockUtil;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.CrashReport;
|
||||
@@ -836,18 +839,7 @@ public class ServerPlayer extends Player {
|
||||
|
||||
Entity entity = this.getCamera();
|
||||
|
||||
- if (entity != this) {
|
||||
- if (entity.isAlive()) {
|
||||
- this.absMoveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot());
|
||||
- this.serverLevel().getChunkSource().move(this);
|
||||
- if (this.wantsToStopRiding()) {
|
||||
- this.setCamera(this);
|
||||
- }
|
||||
- } else {
|
||||
- this.setCamera(this);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
+ //Luminol - move up
|
||||
CriteriaTriggers.TICK.trigger(this);
|
||||
if (this.levitationStartPos != null) {
|
||||
CriteriaTriggers.LEVITATION.trigger(this, this.levitationStartPos, this.tickCount - this.levitationStartTime);
|
||||
@@ -856,6 +848,38 @@ public class ServerPlayer extends Player {
|
||||
this.trackStartFallingPosition();
|
||||
this.trackEnteredOrExitedLavaOnVehicle();
|
||||
this.advancements.flushDirty(this);
|
||||
+
|
||||
+ if (entity != this) {
|
||||
+ if (entity.isAlive()) {
|
||||
+ //Luminol start - Fix spector camera
|
||||
+ if (TickThread.isTickThreadFor(entity) || !LuminolConfig.fixSpectorTeleportFolia){
|
||||
+ this.absMoveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot());
|
||||
+ this.serverLevel().getChunkSource().move(this);
|
||||
+ if (this.wantsToStopRiding()) {
|
||||
+ this.setCamera(this);
|
||||
+ }
|
||||
+ }else{
|
||||
+ this.teleportAsync(
|
||||
+ ((ServerLevel) entity.level()),
|
||||
+ entity.position,
|
||||
+ entity.getYRot(),
|
||||
+ entity.getXRot(),
|
||||
+ null,
|
||||
+ TeleportCause.SPECTATE,
|
||||
+ Entity.TELEPORT_FLAG_LOAD_CHUNK | Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS,
|
||||
+ r -> {
|
||||
+ this.serverLevel().getChunkSource().move(this);
|
||||
+ if (this.wantsToStopRiding()) {
|
||||
+ this.setCamera(this);
|
||||
+ }
|
||||
+ }
|
||||
+ );
|
||||
+ }
|
||||
+ //Luminol end
|
||||
+ } else {
|
||||
+ this.setCamera(this);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
public void doTick() {
|
||||
@@ -0,0 +1,39 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Wed, 29 Nov 2023 21:15:32 +0800
|
||||
Subject: [PATCH] Add config for offline mode warning
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index dcc52141b34b87a67c3d6070b68b58af4a7c4f26..8bf7a0235ed292d6cb3beca9b786a69148e0b4d9 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -31,6 +31,7 @@ public class LuminolConfig {
|
||||
public static String[] tpsColors = new String[]{"GREEN","YELLOW","RED","PURPLE"};
|
||||
public static String[] pingColors = new String[]{"GREEN","YELLOW","RED","PURPLE"};
|
||||
public static boolean disableUsernameCheck = false;
|
||||
+ public static boolean disableOfflineModeWarning = false;
|
||||
public static boolean fixSpectorTeleportFolia = false;
|
||||
|
||||
public static boolean safeTeleportation = true;
|
||||
@@ -132,6 +133,7 @@ public class LuminolConfig {
|
||||
pingColors = get("misc.tpsbar_ping_range_colors",List.of(pingColors),"As same as the tpsColors").toArray(String[]::new);
|
||||
disableUsernameCheck = get("misc.disable_username_check",disableUsernameCheck,"Disable username check that can accept usernames with other characters(such as Chinese).Not recommended to use");
|
||||
fixSpectorTeleportFolia = get("misc.fix_folia_spector_teleport",fixSpectorTeleportFolia);
|
||||
+ disableOfflineModeWarning = get("misc.disable_offline_mode_warning",disableOfflineModeWarning);
|
||||
|
||||
if (tpsbarEnabled){
|
||||
initTpsbar();
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 4a1e068c27853a38db0641806626e7ac740bd8de..4cc62104942e58ededd5c838f4bd5c4db0d574d4 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -278,7 +278,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
String proxyFlavor = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "Velocity" : "BungeeCord";
|
||||
String proxyLink = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "https://docs.papermc.io/velocity/security" : "http://www.spigotmc.org/wiki/firewall-guide/";
|
||||
// Paper end
|
||||
- if (!this.usesAuthentication()) {
|
||||
+ if (!this.usesAuthentication() && !LuminolConfig.disableOfflineModeWarning) { //Luminol - Add config for offline mod warning
|
||||
DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
|
||||
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
|
||||
// Spigot start
|
||||
@@ -1,51 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Tue, 20 Feb 2024 13:03:42 +0000
|
||||
Subject: [PATCH] Pufferfish Throttle goal selector during inactive ticking
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/EntityGoalSelectorInactiveTickConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/EntityGoalSelectorInactiveTickConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..acc032f727e605e79b688efb4873ff474fe7e132
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/EntityGoalSelectorInactiveTickConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.optimizations;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class EntityGoalSelectorInactiveTickConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.OPTIMIZATIONS;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "skip_goal_selector_tick_in_inactive_tick";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index 50a144b0122c970856ef3faa3f899ee72e2a6300..7378c9cb5eeddc7cefc409638179dfb8602ed0d0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -229,11 +229,13 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||
return this.lookControl;
|
||||
}
|
||||
|
||||
+ int _pufferfish_inactiveTickDisableCounter = 0; // Pufferfish - throttle inactive goal selector ticking
|
||||
// Paper start
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
super.inactiveTick();
|
||||
- if (this.goalSelector.inactiveTick(this.activatedPriority, true)) { // Pufferfish - pass activated priroity
|
||||
+ boolean isThrottled = me.earthme.luminol.config.modules.optimizations.EntityGoalSelectorInactiveTickConfig.enabled && _pufferfish_inactiveTickDisableCounter++ % 20 != 0; // Pufferfish - throttle inactive goal selector ticking
|
||||
+ if (this.goalSelector.inactiveTick(this.activatedPriority, true) && !isThrottled) { // Pufferfish - pass activated priroity // Pufferfish - throttle inactive goal selector ticking
|
||||
this.goalSelector.tick();
|
||||
}
|
||||
if (this.targetSelector.inactiveTick(this.activatedPriority, true)) { // Pufferfish - pass activated priority
|
||||
39
patches/server/0039-Add-config-for-root-user-warning.patch
Normal file
39
patches/server/0039-Add-config-for-root-user-warning.patch
Normal file
@@ -0,0 +1,39 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Thu, 30 Nov 2023 22:41:04 +0800
|
||||
Subject: [PATCH] Add config for root user warning
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index 8bf7a0235ed292d6cb3beca9b786a69148e0b4d9..7ada58f2fa83a47908723bdf1e5c5fbbc2f5ffa9 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -33,6 +33,7 @@ public class LuminolConfig {
|
||||
public static boolean disableUsernameCheck = false;
|
||||
public static boolean disableOfflineModeWarning = false;
|
||||
public static boolean fixSpectorTeleportFolia = false;
|
||||
+ public static boolean disableRootUserWarning = false;
|
||||
|
||||
public static boolean safeTeleportation = true;
|
||||
public static boolean enableSandDuping = false;
|
||||
@@ -134,6 +135,7 @@ public class LuminolConfig {
|
||||
disableUsernameCheck = get("misc.disable_username_check",disableUsernameCheck,"Disable username check that can accept usernames with other characters(such as Chinese).Not recommended to use");
|
||||
fixSpectorTeleportFolia = get("misc.fix_folia_spector_teleport",fixSpectorTeleportFolia);
|
||||
disableOfflineModeWarning = get("misc.disable_offline_mode_warning",disableOfflineModeWarning);
|
||||
+ disableRootUserWarning = get("misc.disable_root_user_warning",disableRootUserWarning);
|
||||
|
||||
if (tpsbarEnabled){
|
||||
initTpsbar();
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 4cc62104942e58ededd5c838f4bd5c4db0d574d4..964777e992974dc02ee106ec47efd2e04f3b76c3 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -178,7 +178,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
}
|
||||
|
||||
// Paper start - detect running as root
|
||||
- if (io.papermc.paper.util.ServerEnvironment.userIsRootOrAdmin()) {
|
||||
+ if (io.papermc.paper.util.ServerEnvironment.userIsRootOrAdmin() && !LuminolConfig.disableRootUserWarning) { //Luminol - Add config for root user warning
|
||||
DedicatedServer.LOGGER.warn("****************************");
|
||||
DedicatedServer.LOGGER.warn("YOU ARE RUNNING THIS SERVER AS AN ADMINISTRATIVE OR ROOT USER. THIS IS NOT ADVISED.");
|
||||
DedicatedServer.LOGGER.warn("YOU ARE OPENING YOURSELF UP TO POTENTIAL RISKS WHEN DOING THIS.");
|
||||
@@ -1,36 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Tue, 20 Feb 2024 13:11:11 +0000
|
||||
Subject: [PATCH] Pufferfish Reduce entity allocations
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||
index 897d7632ecfea40890433474870dd7a5e534d8ab..683c9693754d1a87b7e8fccc757a0d0963351f60 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||
@@ -23,9 +23,11 @@ public class AttributeMap {
|
||||
private final Map<Attribute, AttributeInstance> attributes = Maps.newHashMap();
|
||||
private final Set<AttributeInstance> dirtyAttributes = Sets.newHashSet();
|
||||
private final AttributeSupplier supplier;
|
||||
+ private final java.util.function.Function<Attribute, AttributeInstance> createInstance; // Pufferfish
|
||||
|
||||
public AttributeMap(AttributeSupplier defaultAttributes) {
|
||||
this.supplier = defaultAttributes;
|
||||
+ this.createInstance = attribute -> this.supplier.createInstance(this::onAttributeModified, attribute); // Pufferfish
|
||||
}
|
||||
|
||||
private void onAttributeModified(AttributeInstance instance) {
|
||||
@@ -45,11 +47,10 @@ public class AttributeMap {
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
+
|
||||
@Nullable
|
||||
public AttributeInstance getInstance(Attribute attribute) {
|
||||
- return this.attributes.computeIfAbsent(attribute, (attributex) -> {
|
||||
- return this.supplier.createInstance(this::onAttributeModified, attributex);
|
||||
- });
|
||||
+ return this.attributes.computeIfAbsent(attribute, this.createInstance); // Pufferfish - cache lambda, as for some reason java allocates it anyways
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1,6 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 07:33:03 +0000
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Wed, 6 Dec 2023 23:43:00 +0800
|
||||
Subject: [PATCH] Kaiiju Async path processing
|
||||
|
||||
|
||||
@@ -299,14 +299,15 @@ index 0000000000000000000000000000000000000000..6b91852238f80d236fc44f766b115267
|
||||
+}
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/path/AsyncPathProcessor.java b/src/main/java/dev/kaiijumc/kaiiju/path/AsyncPathProcessor.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..31f3ae25069f516255263ab50aca8ee6f1268f8f
|
||||
index 0000000000000000000000000000000000000000..b4c27b33dffa8dce19c9db25d15bc57f48e05d4a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/path/AsyncPathProcessor.java
|
||||
@@ -0,0 +1,52 @@
|
||||
@@ -0,0 +1,53 @@
|
||||
+package dev.kaiijumc.kaiiju.path;
|
||||
+
|
||||
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
+
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
+import net.minecraft.world.level.pathfinder.Path;
|
||||
+import net.minecraft.world.entity.Entity;
|
||||
+
|
||||
@@ -323,8 +324,8 @@ index 0000000000000000000000000000000000000000..31f3ae25069f516255263ab50aca8ee6
|
||||
+
|
||||
+ private static final Executor pathProcessingExecutor = new ThreadPoolExecutor(
|
||||
+ 1,
|
||||
+ me.earthme.luminol.config.modules.optimizations.AsyncPathProcessingConfig.asyncPathProcessingMaxThreads,
|
||||
+ me.earthme.luminol.config.modules.optimizations.AsyncPathProcessingConfig.asyncPathProcessingKeepalive, TimeUnit.SECONDS,
|
||||
+ LuminolConfig.asyncPathProcessingMaxThreads,
|
||||
+ LuminolConfig.asyncPathProcessingKeepalive, TimeUnit.SECONDS,
|
||||
+ new LinkedBlockingQueue<>(),
|
||||
+ new ThreadFactoryBuilder()
|
||||
+ .setNameFormat("petal-path-processor-%d")
|
||||
@@ -473,52 +474,51 @@ index 0000000000000000000000000000000000000000..130d61324679c8600faa52255f3ad99f
|
||||
+ return WALK;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/AsyncPathProcessingConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/AsyncPathProcessingConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..a5472bb9d453bbeee92738c8d1a57ef4fd9bf07e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/AsyncPathProcessingConfig.java
|
||||
@@ -0,0 +1,35 @@
|
||||
+package me.earthme.luminol.config.modules.optimizations;
|
||||
+
|
||||
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class AsyncPathProcessingConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index 7ada58f2fa83a47908723bdf1e5c5fbbc2f5ffa9..dee892ef5f999b693507e7de909d639ce7875780 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -11,6 +11,7 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
+import java.lang.Math;
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -58,7 +59,9 @@ public class LuminolConfig {
|
||||
public static double entityWakeUpDurationRatioStandardDeviation = 0.2;
|
||||
public static boolean loadChunksToActiveClimbingEntities = false;
|
||||
public static int acquirePoiForStuckEntityInterval = 60;
|
||||
-
|
||||
+ public static boolean asyncPathProcessing = false;
|
||||
+ @ConfigInfo(baseName = "max_threads")
|
||||
+ public static int asyncPathProcessingMaxThreads = 0;
|
||||
+ @ConfigInfo(baseName = "keep_alive_time")
|
||||
+ public static int asyncPathProcessingKeepalive = 60;
|
||||
|
||||
public static void init() throws IOException {
|
||||
PARENT_FOLDER.mkdir();
|
||||
@@ -175,6 +178,16 @@ public class LuminolConfig {
|
||||
entityWakeUpDurationRatioStandardDeviation = get("optimizations.entity_wakeup_duration_ratio_standard_deviation",entityWakeUpDurationRatioStandardDeviation);
|
||||
loadChunksToActiveClimbingEntities = get("optimizations.load_chunks_to_active_climbing_entities",loadChunksToActiveClimbingEntities);
|
||||
acquirePoiForStuckEntityInterval = get("optimizations.acquire_poi_for_stuck_entity_interval", acquirePoiForStuckEntityInterval);
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.OPTIMIZATIONS;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "async_path_processing";
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onLoaded(CommentedFileConfig config){
|
||||
+ asyncPathProcessing = get("optimizations.async_pathfinding.enabled",asyncPathProcessing,"Config to enable the async pathfinder.");
|
||||
+ asyncPathProcessingMaxThreads = get("optimizations.async_pathfinding.max-threads", asyncPathProcessingMaxThreads,"If it was set to 0(default),the thread count will be auto set(a quarter of the CPU thread count)");
|
||||
+ asyncPathProcessingKeepalive = get("optimizations.async_pathfinding.keepalive", asyncPathProcessingKeepalive);
|
||||
+ if (asyncPathProcessingMaxThreads < 0)
|
||||
+ asyncPathProcessingMaxThreads = Math.max(Runtime.getRuntime().availableProcessors() + asyncPathProcessingMaxThreads, 1);
|
||||
+ else if (asyncPathProcessingMaxThreads == 0)
|
||||
+ asyncPathProcessingMaxThreads = Math.max(Runtime.getRuntime().availableProcessors() / 4, 1);
|
||||
+ if (!asyncPathProcessing)
|
||||
+ asyncPathProcessingMaxThreads = 0;
|
||||
+ }
|
||||
+}
|
||||
}
|
||||
|
||||
public static <T> T get(String key,T def){
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index a3992e21e7d4112b9903e8d16a5e898d448eaea8..dc94c66404e9f2015119e249a560571355c92c96 100644
|
||||
index 394913950ac8fbcfcdbce817bac95f3b6604beb7..fcf22d62b2bb61807ab54a3e4dca8500d9a1f8a7 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -296,6 +296,7 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||
@@ -297,6 +297,7 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||
@Nullable
|
||||
@Override
|
||||
public LivingEntity getTarget() {
|
||||
@@ -527,15 +527,15 @@ index a3992e21e7d4112b9903e8d16a5e898d448eaea8..dc94c66404e9f2015119e249a5605713
|
||||
if (this.target != null && (!io.papermc.paper.util.TickThread.isTickThreadFor(this.target) || this.target.isRemoved())) {
|
||||
this.target = null;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
||||
index abcc3ef59475ac170fd10b4dd4a4f3371faf17e0..e1dc31deeb87d695ddf2308c27e2cf949e48e538 100644
|
||||
index ba4cdaf499c7ffef0c7fbdd575bdba841bcb7282..6e8e0afb5ec86358f4e3eb929b590fdea1564d21 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
||||
@@ -68,6 +68,40 @@ public class AcquirePoi {
|
||||
@@ -78,6 +78,40 @@ public class AcquirePoi {
|
||||
io.papermc.paper.util.PoiAccess.findNearestPoiPositions(poiManager, poiPredicate, predicate2, entity.blockPosition(), 48, 48*48, PoiManager.Occupancy.HAS_SPACE, false, 5, poiposes);
|
||||
Set<Pair<Holder<PoiType>, BlockPos>> set = new java.util.HashSet<>(poiposes);
|
||||
// Paper end - optimise POI access
|
||||
+ // Kaiiju start - petal - Async path processing
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.AsyncPathProcessingConfig.asyncPathProcessing) {
|
||||
+ if (me.earthme.luminol.LuminolConfig.asyncPathProcessing) {
|
||||
+ // await on path async
|
||||
+ Path possiblePath = findPathToPois(entity, set);
|
||||
+
|
||||
@@ -571,7 +571,7 @@ index abcc3ef59475ac170fd10b4dd4a4f3371faf17e0..e1dc31deeb87d695ddf2308c27e2cf94
|
||||
Path path = findPathToPois(entity, set);
|
||||
if (path != null && path.canReach()) {
|
||||
BlockPos blockPos = path.getTarget();
|
||||
@@ -89,6 +123,7 @@ public class AcquirePoi {
|
||||
@@ -99,6 +133,7 @@ public class AcquirePoi {
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -580,7 +580,7 @@ index abcc3ef59475ac170fd10b4dd4a4f3371faf17e0..e1dc31deeb87d695ddf2308c27e2cf94
|
||||
return true;
|
||||
}
|
||||
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 98bf17441da3169d49de55fe89d79ebe250a2b7e..74162661e5757bb2c732361042b5dd2c3ded43ee 100644
|
||||
index 98bf17441da3169d49de55fe89d79ebe250a2b7e..a93457a4c0f4ec8be3a105c6feeb5a189056d8cf 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
||||
@@ -21,6 +21,7 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
||||
@@ -596,10 +596,10 @@ index 98bf17441da3169d49de55fe89d79ebe250a2b7e..74162661e5757bb2c732361042b5dd2c
|
||||
WalkTarget walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET).get();
|
||||
boolean bl = this.reachedTarget(entity, walkTarget);
|
||||
- if (!bl && this.tryComputePath(entity, walkTarget, world.getGameTime())) {
|
||||
+ if (!me.earthme.luminol.config.modules.optimizations.AsyncPathProcessingConfig.asyncPathProcessing && !bl && this.tryComputePath(entity, walkTarget, world.getGameTime())) { // Kaiiju - petal - async path processing means we can't know if the path is reachable here
|
||||
+ if (!me.earthme.luminol.LuminolConfig.asyncPathProcessing && !bl && this.tryComputePath(entity, walkTarget, world.getGameTime())) { // Kaiiju - petal - async path processing means we can't know if the path is reachable here
|
||||
this.lastTargetPos = walkTarget.getTarget().currentBlockPosition();
|
||||
return true;
|
||||
+ } else if (me.earthme.luminol.config.modules.optimizations.AsyncPathProcessingConfig.asyncPathProcessing && !bl) { return true; // Kaiiju - async pathfinding
|
||||
+ } else if (me.earthme.luminol.LuminolConfig.asyncPathProcessing && !bl) { return true; // Kaiiju - async pathfinding
|
||||
} else {
|
||||
brain.eraseMemory(MemoryModuleType.WALK_TARGET);
|
||||
if (bl) {
|
||||
@@ -607,7 +607,7 @@ index 98bf17441da3169d49de55fe89d79ebe250a2b7e..74162661e5757bb2c732361042b5dd2c
|
||||
|
||||
@Override
|
||||
protected boolean canStillUse(ServerLevel world, Mob entity, long time) {
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.AsyncPathProcessingConfig.asyncPathProcessing && !this.finishedProcessing) return true; // Kaiiju - petal - wait for processing
|
||||
+ if (me.earthme.luminol.LuminolConfig.asyncPathProcessing && !this.finishedProcessing) return true; // Kaiiju - petal - wait for processing
|
||||
if (this.path != null && this.lastTargetPos != null) {
|
||||
Optional<WalkTarget> optional = entity.getBrain().getMemory(MemoryModuleType.WALK_TARGET);
|
||||
boolean bl = optional.map(MoveToTargetSink::isWalkTargetSpectator).orElse(false);
|
||||
@@ -616,7 +616,7 @@ index 98bf17441da3169d49de55fe89d79ebe250a2b7e..74162661e5757bb2c732361042b5dd2c
|
||||
@Override
|
||||
protected void start(ServerLevel serverLevel, Mob mob, long l) {
|
||||
+ // Kaiiju start - petal - start processing
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.AsyncPathProcessingConfig.asyncPathProcessing) {
|
||||
+ if (me.earthme.luminol.LuminolConfig.asyncPathProcessing) {
|
||||
+ Brain<?> brain = mob.getBrain();
|
||||
+ WalkTarget walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET).get();
|
||||
+
|
||||
@@ -633,7 +633,7 @@ index 98bf17441da3169d49de55fe89d79ebe250a2b7e..74162661e5757bb2c732361042b5dd2c
|
||||
@Override
|
||||
protected void tick(ServerLevel serverLevel, Mob mob, long l) {
|
||||
+ // Kaiiju start - petal - Async path processing
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.AsyncPathProcessingConfig.asyncPathProcessing) {
|
||||
+ if (me.earthme.luminol.LuminolConfig.asyncPathProcessing) {
|
||||
+ if (this.path != null && !this.path.isProcessed()) return; // wait for processing
|
||||
+
|
||||
+ if (!this.finishedProcessing) {
|
||||
@@ -705,7 +705,7 @@ index 98bf17441da3169d49de55fe89d79ebe250a2b7e..74162661e5757bb2c732361042b5dd2c
|
||||
private boolean tryComputePath(Mob entity, WalkTarget walkTarget, long time) {
|
||||
BlockPos blockPos = walkTarget.getTarget().currentBlockPosition();
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/SetClosestHomeAsWalkTarget.java b/src/main/java/net/minecraft/world/entity/ai/behavior/SetClosestHomeAsWalkTarget.java
|
||||
index 271efbb027f6f5d69ac5bc5dc51102a1eb00ab31..cd2a3edc03301286114834e721f5441e7b70474a 100644
|
||||
index 271efbb027f6f5d69ac5bc5dc51102a1eb00ab31..a64be68194fb0fa205b3f3cb87406056832d1fe3 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/SetClosestHomeAsWalkTarget.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/SetClosestHomeAsWalkTarget.java
|
||||
@@ -57,6 +57,26 @@ public class SetClosestHomeAsWalkTarget {
|
||||
@@ -713,7 +713,7 @@ index 271efbb027f6f5d69ac5bc5dc51102a1eb00ab31..cd2a3edc03301286114834e721f5441e
|
||||
return poiType.is(PoiTypes.HOME);
|
||||
}, predicate, entity.blockPosition(), 48, PoiManager.Occupancy.ANY).collect(Collectors.toSet());
|
||||
+ // Kaiiju start - petal - Async path processing
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.AsyncPathProcessingConfig.asyncPathProcessing) {
|
||||
+ if (me.earthme.luminol.LuminolConfig.asyncPathProcessing) {
|
||||
+ // await on path async
|
||||
+ Path possiblePath = AcquirePoi.findPathToPois(entity, set);
|
||||
+
|
||||
@@ -757,7 +757,7 @@ index 6771f2dc974317b6b152288bf41d1a95bc78a8e4..7a641747b17164b09bb8483cda7f69d1
|
||||
Node node = path.getNode(i);
|
||||
this.doorPos = new BlockPos(node.x, node.y + 1, node.z);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java
|
||||
index 9d3b32c852d660356e0f16d4cc10072b1c603e64..2e64fe17fb3ee1925db1fdb34dedba356aea070b 100644
|
||||
index 9d3b32c852d660356e0f16d4cc10072b1c603e64..545f578d77398a00fbc626e048eac56626308792 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java
|
||||
@@ -12,10 +12,26 @@ public class AmphibiousPathNavigation extends PathNavigation {
|
||||
@@ -780,7 +780,7 @@ index 9d3b32c852d660356e0f16d4cc10072b1c603e64..2e64fe17fb3ee1925db1fdb34dedba35
|
||||
this.nodeEvaluator = new AmphibiousNodeEvaluator(false);
|
||||
this.nodeEvaluator.setCanPassDoors(true);
|
||||
+ // Kaiiju start - petal - async path processing
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.AsyncPathProcessingConfig.asyncPathProcessing)
|
||||
+ if (me.earthme.luminol.LuminolConfig.asyncPathProcessing)
|
||||
+ return new PathFinder(this.nodeEvaluator, range, nodeEvaluatorGenerator);
|
||||
+ else
|
||||
+ // Kaiiju end
|
||||
@@ -788,7 +788,7 @@ index 9d3b32c852d660356e0f16d4cc10072b1c603e64..2e64fe17fb3ee1925db1fdb34dedba35
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java
|
||||
index e35c38feb62c3345d82636081decc09db9f061ab..70f4104f8e49fd6b7df531673f3e1da123783409 100644
|
||||
index 027eef4ace908147285c8d72b612d16e4f925672..6ba693159dcc0827563b5141d12a15ede43b6eda 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java
|
||||
@@ -16,10 +16,26 @@ public class FlyingPathNavigation extends PathNavigation {
|
||||
@@ -811,7 +811,7 @@ index e35c38feb62c3345d82636081decc09db9f061ab..70f4104f8e49fd6b7df531673f3e1da1
|
||||
this.nodeEvaluator = new FlyNodeEvaluator();
|
||||
this.nodeEvaluator.setCanPassDoors(true);
|
||||
+ // Kaiiju start - petal - async path processing
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.AsyncPathProcessingConfig.asyncPathProcessing)
|
||||
+ if (me.earthme.luminol.LuminolConfig.asyncPathProcessing)
|
||||
+ return new PathFinder(this.nodeEvaluator, range, nodeEvaluatorGenerator);
|
||||
+ else
|
||||
+ // Kaiiju end
|
||||
@@ -827,7 +827,7 @@ index e35c38feb62c3345d82636081decc09db9f061ab..70f4104f8e49fd6b7df531673f3e1da1
|
||||
if (!this.isDone()) {
|
||||
if (this.canUpdatePath()) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java
|
||||
index b31ba4e2286eaee5028cb4dc236829d1a302a25a..aaa04a4b01575495e6e01f0d83b2bb03acc93822 100644
|
||||
index c065d372ac5f1663db3c521e996ee03669d0bc31..c560435f92d770f1ad7869abaaf7d680b9a866eb 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java
|
||||
@@ -23,10 +23,26 @@ public class GroundPathNavigation extends PathNavigation {
|
||||
@@ -850,7 +850,7 @@ index b31ba4e2286eaee5028cb4dc236829d1a302a25a..aaa04a4b01575495e6e01f0d83b2bb03
|
||||
this.nodeEvaluator = new WalkNodeEvaluator();
|
||||
this.nodeEvaluator.setCanPassDoors(true);
|
||||
+ // Kaiiju start - petal - async path processing
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.AsyncPathProcessingConfig.asyncPathProcessing)
|
||||
+ if (me.earthme.luminol.LuminolConfig.asyncPathProcessing)
|
||||
+ return new PathFinder(this.nodeEvaluator, range, nodeEvaluatorGenerator);
|
||||
+ else
|
||||
+ // Kaiiju end
|
||||
@@ -858,10 +858,10 @@ index b31ba4e2286eaee5028cb4dc236829d1a302a25a..aaa04a4b01575495e6e01f0d83b2bb03
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
index 089baec30e0c16149b147a501d68958663519b96..f6484fefd28a028fbcd1a54d93c8607b65575d00 100644
|
||||
index 147057bfd67d56857b5d3ab1ebd0f0a0c1793a9c..4e104f7ab240ffb53823b14ad6c2506c5e169f98 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
@@ -153,6 +153,10 @@ public abstract class PathNavigation {
|
||||
@@ -152,6 +152,10 @@ public abstract class PathNavigation {
|
||||
return null;
|
||||
} else if (!this.canUpdatePath()) {
|
||||
return null;
|
||||
@@ -872,12 +872,12 @@ index 089baec30e0c16149b147a501d68958663519b96..f6484fefd28a028fbcd1a54d93c8607b
|
||||
} else if (this.path != null && !this.path.isDone() && positions.contains(this.targetPos)) {
|
||||
return this.path;
|
||||
} else {
|
||||
@@ -179,11 +183,29 @@ public abstract class PathNavigation {
|
||||
@@ -178,11 +182,29 @@ public abstract class PathNavigation {
|
||||
PathNavigationRegion pathNavigationRegion = new PathNavigationRegion(this.level, blockPos.offset(-i, -i, -i), blockPos.offset(i, i, i));
|
||||
Path path = this.pathFinder.findPath(pathNavigationRegion, this.mob, positions, followRange, distance, this.maxVisitedNodesMultiplier);
|
||||
this.level.getProfiler().pop();
|
||||
+ // Kaiiju start - petal - async path processing
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.AsyncPathProcessingConfig.asyncPathProcessing) {
|
||||
+ if (me.earthme.luminol.LuminolConfig.asyncPathProcessing) {
|
||||
+ // assign early a target position. most calls will only have 1 position
|
||||
+ if (!positions.isEmpty()) this.targetPos = positions.iterator().next();
|
||||
+
|
||||
@@ -902,7 +902,7 @@ index 089baec30e0c16149b147a501d68958663519b96..f6484fefd28a028fbcd1a54d93c8607b
|
||||
|
||||
return path;
|
||||
}
|
||||
@@ -230,8 +252,8 @@ public abstract class PathNavigation {
|
||||
@@ -229,8 +251,8 @@ public abstract class PathNavigation {
|
||||
if (this.isDone()) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -913,7 +913,7 @@ index 089baec30e0c16149b147a501d68958663519b96..f6484fefd28a028fbcd1a54d93c8607b
|
||||
return false;
|
||||
} else {
|
||||
this.speedModifier = speed;
|
||||
@@ -254,6 +276,7 @@ public abstract class PathNavigation {
|
||||
@@ -253,6 +275,7 @@ public abstract class PathNavigation {
|
||||
if (this.hasDelayedRecomputation) {
|
||||
this.recomputePath();
|
||||
}
|
||||
@@ -921,7 +921,7 @@ index 089baec30e0c16149b147a501d68958663519b96..f6484fefd28a028fbcd1a54d93c8607b
|
||||
|
||||
if (!this.isDone()) {
|
||||
if (this.canUpdatePath()) {
|
||||
@@ -280,6 +303,7 @@ public abstract class PathNavigation {
|
||||
@@ -279,6 +302,7 @@ public abstract class PathNavigation {
|
||||
}
|
||||
|
||||
protected void followThePath() {
|
||||
@@ -929,7 +929,7 @@ index 089baec30e0c16149b147a501d68958663519b96..f6484fefd28a028fbcd1a54d93c8607b
|
||||
Vec3 vec3 = this.getTempMobPos();
|
||||
this.maxDistanceToWaypoint = this.mob.getBbWidth() > 0.75F ? this.mob.getBbWidth() / 2.0F : 0.75F - this.mob.getBbWidth() / 2.0F;
|
||||
Vec3i vec3i = this.path.getNextNodePos();
|
||||
@@ -435,7 +459,7 @@ public abstract class PathNavigation {
|
||||
@@ -434,7 +458,7 @@ public abstract class PathNavigation {
|
||||
public boolean shouldRecomputePath(BlockPos pos) {
|
||||
if (this.hasDelayedRecomputation) {
|
||||
return false;
|
||||
@@ -939,7 +939,7 @@ index 089baec30e0c16149b147a501d68958663519b96..f6484fefd28a028fbcd1a54d93c8607b
|
||||
Vec3 vec3 = new Vec3(((double)node.x + this.mob.getX()) / 2.0D, ((double)node.y + this.mob.getY()) / 2.0D, ((double)node.z + this.mob.getZ()) / 2.0D);
|
||||
return pos.closerToCenterThan(vec3, (double)(this.path.getNodeCount() - this.path.getNextNodeIndex()));
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java
|
||||
index ee8543afbbd681bf327a353530a7a635aa5ef592..238b5f2dc5487dcf675152b8c19a40a6e16958dc 100644
|
||||
index ee8543afbbd681bf327a353530a7a635aa5ef592..0e6fd5c6d31e6b39e693866165f3dab3d483c920 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java
|
||||
@@ -15,10 +15,26 @@ public class WaterBoundPathNavigation extends PathNavigation {
|
||||
@@ -962,7 +962,7 @@ index ee8543afbbd681bf327a353530a7a635aa5ef592..238b5f2dc5487dcf675152b8c19a40a6
|
||||
this.allowBreaching = this.mob.getType() == EntityType.DOLPHIN;
|
||||
this.nodeEvaluator = new SwimNodeEvaluator(this.allowBreaching);
|
||||
+ // Kaiiju start - async path processing
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.AsyncPathProcessingConfig.asyncPathProcessing)
|
||||
+ if (me.earthme.luminol.LuminolConfig.asyncPathProcessing)
|
||||
+ return new PathFinder(this.nodeEvaluator, range, nodeEvaluatorGenerator);
|
||||
+ else
|
||||
+ // Kaiiju end
|
||||
@@ -970,7 +970,7 @@ index ee8543afbbd681bf327a353530a7a635aa5ef592..238b5f2dc5487dcf675152b8c19a40a6
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java
|
||||
index 8db20db72cd51046213625fac46c35854c59ec5d..afa5d36f5f9e6f3a44a1e92f98a1d83c3af4d277 100644
|
||||
index 8db20db72cd51046213625fac46c35854c59ec5d..d40e00a0a8726c920ea43aaa1ed680054cbfd9a3 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java
|
||||
@@ -57,6 +57,25 @@ public class NearestBedSensor extends Sensor<Mob> {
|
||||
@@ -978,7 +978,7 @@ index 8db20db72cd51046213625fac46c35854c59ec5d..afa5d36f5f9e6f3a44a1e92f98a1d83c
|
||||
// don't ask me why it's unbounded. ask mojang.
|
||||
io.papermc.paper.util.PoiAccess.findAnyPoiPositions(poiManager, type -> type.is(PoiTypes.HOME), predicate, entity.blockPosition(), 48, PoiManager.Occupancy.ANY, false, Integer.MAX_VALUE, poiposes);
|
||||
+ // Kaiiju start - await on async path processing
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.AsyncPathProcessingConfig.asyncPathProcessing) {
|
||||
+ if (me.earthme.luminol.LuminolConfig.asyncPathProcessing) {
|
||||
+ Path possiblePath = AcquirePoi.findPathToPois(entity, new java.util.HashSet<>(poiposes));
|
||||
+ dev.kaiijumc.kaiiju.path.AsyncPathProcessor.awaitProcessing(entity, possiblePath, path -> {
|
||||
+ // read canReach check
|
||||
@@ -1008,10 +1008,10 @@ index 8db20db72cd51046213625fac46c35854c59ec5d..afa5d36f5f9e6f3a44a1e92f98a1d83c
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
index 9f1791e60061934fc89a13258f3fab9f67f3a45c..489fab4847118b8ecb92e435d57d224104e7a3b6 100644
|
||||
index 25fd3aea2d66503018637781ccb8b5690c02e57b..3eb38f2ad12ee459dfaf0e9f917633c8db6d58e3 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
@@ -1084,7 +1084,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
@@ -1077,7 +1077,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
} else {
|
||||
Bee.this.pathfindRandomlyTowards(Bee.this.hivePos);
|
||||
}
|
||||
@@ -1020,7 +1020,7 @@ index 9f1791e60061934fc89a13258f3fab9f67f3a45c..489fab4847118b8ecb92e435d57d2241
|
||||
boolean flag = this.pathfindDirectlyTowards(Bee.this.hivePos);
|
||||
|
||||
if (!flag) {
|
||||
@@ -1146,7 +1146,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
@@ -1139,7 +1139,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
} else {
|
||||
Path pathentity = Bee.this.navigation.getPath();
|
||||
|
||||
@@ -1030,10 +1030,10 @@ index 9f1791e60061934fc89a13258f3fab9f67f3a45c..489fab4847118b8ecb92e435d57d2241
|
||||
}
|
||||
}
|
||||
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 295769d039f2a1e4f48912a60f9dbe267d8992c1..580da502c62ec5d669cb09932d99d1c7d711c965 100644
|
||||
index c8e3d47b3f2dc919cca8ad397095437f1da6c762..dc7c35492c9481a45891ad32b45d7d46bc492461 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
@@ -383,6 +383,17 @@ public class Frog extends Animal implements VariantHolder<FrogVariant> {
|
||||
@@ -390,6 +390,17 @@ public class Frog extends Animal implements VariantHolder<FrogVariant> {
|
||||
super(frog, world);
|
||||
}
|
||||
|
||||
@@ -1051,12 +1051,12 @@ index 295769d039f2a1e4f48912a60f9dbe267d8992c1..580da502c62ec5d669cb09932d99d1c7
|
||||
@Override
|
||||
public boolean canCutCorner(BlockPathTypes nodeType) {
|
||||
return nodeType != BlockPathTypes.WATER_BORDER && super.canCutCorner(nodeType);
|
||||
@@ -392,6 +403,11 @@ public class Frog extends Animal implements VariantHolder<FrogVariant> {
|
||||
@@ -399,6 +410,11 @@ public class Frog extends Animal implements VariantHolder<FrogVariant> {
|
||||
protected PathFinder createPathFinder(int range) {
|
||||
this.nodeEvaluator = new Frog.FrogNodeEvaluator(true);
|
||||
this.nodeEvaluator.setCanPassDoors(true);
|
||||
+ // Kaiiju start - petal - async path processing
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.AsyncPathProcessingConfig.asyncPathProcessing)
|
||||
+ if (me.earthme.luminol.LuminolConfig.asyncPathProcessing)
|
||||
+ return new PathFinder(this.nodeEvaluator, range, nodeEvaluatorGenerator);
|
||||
+ else
|
||||
+ // Kaiiju end
|
||||
@@ -1064,7 +1064,7 @@ index 295769d039f2a1e4f48912a60f9dbe267d8992c1..580da502c62ec5d669cb09932d99d1c7
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Drowned.java b/src/main/java/net/minecraft/world/entity/monster/Drowned.java
|
||||
index 01897af1e6253b987734a24c052daf2ce1314092..b2f3f65caa92cfd9a8c65e617fde558506ca5a95 100644
|
||||
index 991d728db2a3b64316fc2102cf3aee470327a62e..c99de04d082f7f9b08d25730460385c400b1b975 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Drowned.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Drowned.java
|
||||
@@ -216,7 +216,6 @@ public class Drowned extends Zombie implements RangedAttackMob {
|
||||
@@ -1085,7 +1085,7 @@ index 01897af1e6253b987734a24c052daf2ce1314092..b2f3f65caa92cfd9a8c65e617fde5585
|
||||
|
||||
if (blockposition != null) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Strider.java b/src/main/java/net/minecraft/world/entity/monster/Strider.java
|
||||
index 61162ecd43dc5e6f7898daecdec49f444e6d869b..864215e909224d180b47798e90a3c5846fa03dbd 100644
|
||||
index 61162ecd43dc5e6f7898daecdec49f444e6d869b..26cdfe0dcf16c252648561f83e4d6a6757c0bd38 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Strider.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Strider.java
|
||||
@@ -563,10 +563,26 @@ public class Strider extends Animal implements ItemSteerable, Saddleable {
|
||||
@@ -1108,7 +1108,7 @@ index 61162ecd43dc5e6f7898daecdec49f444e6d869b..864215e909224d180b47798e90a3c584
|
||||
this.nodeEvaluator = new WalkNodeEvaluator();
|
||||
this.nodeEvaluator.setCanPassDoors(true);
|
||||
+ // Kaiiju start - async path processing
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.AsyncPathProcessingConfig.asyncPathProcessing)
|
||||
+ if (me.earthme.luminol.LuminolConfig.asyncPathProcessing)
|
||||
+ return new PathFinder(this.nodeEvaluator, range, nodeEvaluatorGenerator);
|
||||
+ else
|
||||
+ // Kaiiju end
|
||||
@@ -1116,15 +1116,15 @@ index 61162ecd43dc5e6f7898daecdec49f444e6d869b..864215e909224d180b47798e90a3c584
|
||||
}
|
||||
|
||||
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 937f81a859953498abe73bea560c86e6560e1c33..7aadd36f0fe986635b495ab8c1426644620400cf 100644
|
||||
index 5e43912708f9074dee1bb351efa737a7e6796fc3..6b3279c74148e3e93364fe0859b543fba4e6933c 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
||||
@@ -602,6 +602,16 @@ public class Warden extends Monster implements VibrationSystem {
|
||||
@@ -603,6 +603,16 @@ public class Warden extends Monster implements VibrationSystem {
|
||||
protected PathFinder createPathFinder(int range) {
|
||||
this.nodeEvaluator = new WalkNodeEvaluator();
|
||||
this.nodeEvaluator.setCanPassDoors(true);
|
||||
+ // Kaiiju start - petal - async path processing
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.AsyncPathProcessingConfig.asyncPathProcessing)
|
||||
+ if (me.earthme.luminol.LuminolConfig.asyncPathProcessing)
|
||||
+ return new PathFinder(this.nodeEvaluator, range, GroundPathNavigation.nodeEvaluatorGenerator) {
|
||||
+ @Override
|
||||
+ protected float distance(Node a, Node b) {
|
||||
@@ -1137,10 +1137,10 @@ index 937f81a859953498abe73bea560c86e6560e1c33..7aadd36f0fe986635b495ab8c1426644
|
||||
@Override
|
||||
protected float distance(Node a, Node b) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java b/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
||||
index 42407c5c0c09cd9d19bc7af92af8868bb038c686..39ed19562210f1329b22c630e667578473cda7cb 100644
|
||||
index d5fe3b8e2f5a8899f6afeb0600764284a617f261..4f15b9e4b1aba5375a2572ff28cea4e3d96eb82d 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
||||
@@ -254,6 +254,7 @@ public class ShulkerBoxBlock extends BaseEntityBlock {
|
||||
@@ -238,6 +238,7 @@ public class ShulkerBoxBlock extends BaseEntityBlock {
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
|
||||
@@ -1149,10 +1149,10 @@ index 42407c5c0c09cd9d19bc7af92af8868bb038c686..39ed19562210f1329b22c630e6675784
|
||||
return blockEntity instanceof ShulkerBoxBlockEntity ? Shapes.create(((ShulkerBoxBlockEntity)blockEntity).getBoundingBox(state)) : Shapes.block();
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java b/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java
|
||||
index d3d1ad7901411574b85b0febd1c7ddaa8ad7c9f4..850065df2b95b0967660f246cd007bf9f53e26df 100644
|
||||
index e941a4ce35c1bcc84836d04fb97cb1e7f292ae42..26f3c25f2dfda5f7c6213746efa8b883b655d2e1 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java
|
||||
@@ -110,6 +110,7 @@ public class MovingPistonBlock extends BaseEntityBlock {
|
||||
@@ -102,6 +102,7 @@ public class MovingPistonBlock extends BaseEntityBlock {
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
|
||||
@@ -1161,7 +1161,7 @@ index d3d1ad7901411574b85b0febd1c7ddaa8ad7c9f4..850065df2b95b0967660f246cd007bf9
|
||||
return pistonMovingBlockEntity != null ? pistonMovingBlockEntity.getCollisionShape(world, pos) : Shapes.empty();
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/Path.java b/src/main/java/net/minecraft/world/level/pathfinder/Path.java
|
||||
index 3049edb5a8b5967e5242a3896b23665888eb3472..0da9acd785cf785d82be7aab0a1e2bfd70c62998 100644
|
||||
index eea4c932d909145e7af848cf76e3f49dbb2deff2..7160459ec8ba81f66a85082a1fe7b06377180afa 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/pathfinder/Path.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/pathfinder/Path.java
|
||||
@@ -27,6 +27,17 @@ public class Path {
|
||||
@@ -1191,7 +1191,7 @@ index 3049edb5a8b5967e5242a3896b23665888eb3472..0da9acd785cf785d82be7aab0a1e2bfd
|
||||
return false;
|
||||
} else if (o.nodes.size() != this.nodes.size()) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
||||
index eb18494bd7257fa5eb00dea16cf4d5667b796f2b..3cbc29fa169350879254a90e198e6247b6ab3037 100644
|
||||
index d23481453717f715124156b5d83f6448f720d049..d806d941fe0610d84a50cf4c2051fb26b612efa8 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
||||
@@ -24,37 +24,80 @@ public class PathFinder {
|
||||
@@ -1218,7 +1218,7 @@ index eb18494bd7257fa5eb00dea16cf4d5667b796f2b..3cbc29fa169350879254a90e198e6247
|
||||
- this.openSet.clear();
|
||||
- this.nodeEvaluator.prepare(world, mob);
|
||||
- Node node = this.nodeEvaluator.getStart();
|
||||
+ if(!me.earthme.luminol.config.modules.optimizations.AsyncPathProcessingConfig.asyncPathProcessing) this.openSet.clear(); // Kaiiju - petal - it's always cleared in processPath
|
||||
+ if(!me.earthme.luminol.LuminolConfig.asyncPathProcessing) this.openSet.clear(); // Kaiiju - petal - it's always cleared in processPath
|
||||
+ // Kaiiju start - petal - use a generated evaluator if we have one otherwise run sync
|
||||
+ NodeEvaluator nodeEvaluator = this.nodeEvaluatorGenerator == null
|
||||
+ ? this.nodeEvaluator
|
||||
@@ -1230,13 +1230,13 @@ index eb18494bd7257fa5eb00dea16cf4d5667b796f2b..3cbc29fa169350879254a90e198e6247
|
||||
+ dev.kaiijumc.kaiiju.path.NodeEvaluatorCache.removeNodeEvaluator(nodeEvaluator); // Kaiiju - petal - handle nodeEvaluatorGenerator
|
||||
return null;
|
||||
} else {
|
||||
// Paper start - Perf: remove streams and optimize collection
|
||||
// Paper start - remove streams - and optimize collection
|
||||
List<Map.Entry<Target, BlockPos>> map = Lists.newArrayList();
|
||||
for (BlockPos pos : positions) {
|
||||
- map.add(new java.util.AbstractMap.SimpleEntry<>(this.nodeEvaluator.getGoal(pos.getX(), pos.getY(), pos.getZ()), pos));
|
||||
+ map.add(new java.util.AbstractMap.SimpleEntry<>(nodeEvaluator.getGoal(pos.getX(), pos.getY(), pos.getZ()), pos)); // Kaiiju - petal - handle nodeEvaluatorGenerator
|
||||
}
|
||||
// Paper end - Perf: remove streams and optimize collection
|
||||
// Paper end
|
||||
- Path path = this.findPath(world.getProfiler(), node, map, followRange, distance, rangeMultiplier);
|
||||
- this.nodeEvaluator.done();
|
||||
- return path;
|
||||
@@ -1264,7 +1264,7 @@ index eb18494bd7257fa5eb00dea16cf4d5667b796f2b..3cbc29fa169350879254a90e198e6247
|
||||
|
||||
- @Nullable
|
||||
+ //@Nullable // Kaiiju - Always not null
|
||||
// Paper start - Perf: remove streams and optimize collection
|
||||
// Paper start - optimize collection
|
||||
private Path findPath(ProfilerFiller profiler, Node startNode, List<Map.Entry<Target, BlockPos>> positions, float followRange, int distance, float rangeMultiplier) {
|
||||
profiler.push("find_path");
|
||||
profiler.markForCharting(MetricCategory.PATH_FINDING);
|
||||
@@ -1299,7 +1299,7 @@ index eb18494bd7257fa5eb00dea16cf4d5667b796f2b..3cbc29fa169350879254a90e198e6247
|
||||
}
|
||||
+ //noinspection ConstantConditions // Kaiiju - petal - ignore this warning, we know that the above loop always runs at least once since positions is not empty
|
||||
return best;
|
||||
// Paper end - Perf: remove streams and optimize collection
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java b/src/main/java/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java
|
||||
index 0e2b14e7dfedf209d63279c81723fd7955122d78..079b278e2e262af433bb5bd0c12b3d8db4fa12fc 100644
|
||||
@@ -0,0 +1,483 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sat, 9 Dec 2023 22:19:49 +0800
|
||||
Subject: [PATCH] Optimize mob spawning(Async mob spawn state calc)
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/util/misc/AreaMap.java b/src/main/java/com/destroystokyo/paper/util/misc/AreaMap.java
|
||||
index 41b9405d6759d865e0d14dd4f95163e9690e967d..091b1ae822e1c0517e59572e7a9bda11e998c0ee 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/util/misc/AreaMap.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/util/misc/AreaMap.java
|
||||
@@ -26,7 +26,7 @@ public abstract class AreaMap<E> {
|
||||
|
||||
// we use linked for better iteration.
|
||||
// map of: coordinate to set of objects in coordinate
|
||||
- protected final Long2ObjectOpenHashMap<PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<E>> areaMap = new Long2ObjectOpenHashMap<>(1024, 0.7f);
|
||||
+ protected Long2ObjectOpenHashMap<PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<E>> areaMap = new Long2ObjectOpenHashMap<>(1024, 0.7f); // Pufferfish - not actually final
|
||||
protected final PooledLinkedHashSets<E> pooledHashSets;
|
||||
|
||||
protected final ChangeCallback<E> addCallback;
|
||||
@@ -160,7 +160,8 @@ public abstract class AreaMap<E> {
|
||||
protected abstract PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<E> getEmptySetFor(final E object);
|
||||
|
||||
// expensive op, only for debug
|
||||
- protected void validate(final E object, final int viewDistance) {
|
||||
+ protected void validate0(final E object, final int viewDistance) { // Pufferfish - rename this thing just in case it gets used I'd rather a compile time error.
|
||||
+ if (true) throw new UnsupportedOperationException(); // Pufferfish - not going to put in the effort to fix this if it doesn't ever get used.
|
||||
int entiesGot = 0;
|
||||
int expectedEntries = (2 * viewDistance + 1);
|
||||
expectedEntries *= expectedEntries;
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/util/misc/PlayerAreaMap.java b/src/main/java/com/destroystokyo/paper/util/misc/PlayerAreaMap.java
|
||||
index 46954db7ecd35ac4018fdf476df7c8020d7ce6c8..1ad890a244bdf6df48a8db68cb43450e08c788a6 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/util/misc/PlayerAreaMap.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/util/misc/PlayerAreaMap.java
|
||||
@@ -5,7 +5,7 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
/**
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
-public final class PlayerAreaMap extends AreaMap<ServerPlayer> {
|
||||
+public class PlayerAreaMap extends AreaMap<ServerPlayer> { // Pufferfish - not actually final
|
||||
|
||||
public PlayerAreaMap() {
|
||||
super();
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/util/AsyncPlayerAreaMap.java b/src/main/java/gg/pufferfish/pufferfish/util/AsyncPlayerAreaMap.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..fdcb62d12164024a5f354d60cc863821a18d1b2a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/util/AsyncPlayerAreaMap.java
|
||||
@@ -0,0 +1,31 @@
|
||||
+package gg.pufferfish.pufferfish.util;
|
||||
+
|
||||
+import com.destroystokyo.paper.util.misc.PlayerAreaMap;
|
||||
+import com.destroystokyo.paper.util.misc.PooledLinkedHashSets;
|
||||
+import java.util.concurrent.ConcurrentHashMap;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+
|
||||
+public final class AsyncPlayerAreaMap extends PlayerAreaMap {
|
||||
+
|
||||
+ public AsyncPlayerAreaMap() {
|
||||
+ super();
|
||||
+ this.areaMap = new Long2ObjectOpenHashMapWrapper<>(new ConcurrentHashMap<>(1024, 0.7f));
|
||||
+ }
|
||||
+
|
||||
+ public AsyncPlayerAreaMap(final PooledLinkedHashSets<ServerPlayer> pooledHashSets) {
|
||||
+ super(pooledHashSets);
|
||||
+ this.areaMap = new Long2ObjectOpenHashMapWrapper<>(new ConcurrentHashMap<>(1024, 0.7f));
|
||||
+ }
|
||||
+
|
||||
+ public AsyncPlayerAreaMap(final PooledLinkedHashSets<ServerPlayer> pooledHashSets, final ChangeCallback<ServerPlayer> addCallback,
|
||||
+ final ChangeCallback<ServerPlayer> removeCallback) {
|
||||
+ this(pooledHashSets, addCallback, removeCallback, null);
|
||||
+ }
|
||||
+
|
||||
+ public AsyncPlayerAreaMap(final PooledLinkedHashSets<ServerPlayer> pooledHashSets, final ChangeCallback<ServerPlayer> addCallback,
|
||||
+ final ChangeCallback<ServerPlayer> removeCallback, final ChangeSourceCallback<ServerPlayer> changeSourceCallback) {
|
||||
+ super(pooledHashSets, addCallback, removeCallback, changeSourceCallback);
|
||||
+ this.areaMap = new Long2ObjectOpenHashMapWrapper<>(new ConcurrentHashMap<>(1024, 0.7f));
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/util/Long2ObjectOpenHashMapWrapper.java b/src/main/java/gg/pufferfish/pufferfish/util/Long2ObjectOpenHashMapWrapper.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..facd55463d44cb7e3d2ca6892982f5497b8dded1
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/util/Long2ObjectOpenHashMapWrapper.java
|
||||
@@ -0,0 +1,40 @@
|
||||
+package gg.pufferfish.pufferfish.util;
|
||||
+
|
||||
+import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||
+import java.util.Map;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+public class Long2ObjectOpenHashMapWrapper<V> extends Long2ObjectOpenHashMap<V> {
|
||||
+
|
||||
+ private final Map<Long, V> backingMap;
|
||||
+
|
||||
+ public Long2ObjectOpenHashMapWrapper(Map<Long, V> map) {
|
||||
+ backingMap = map;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public V put(Long key, V value) {
|
||||
+ return backingMap.put(key, value);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public V get(Object key) {
|
||||
+ return backingMap.get(key);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public V remove(Object key) {
|
||||
+ return backingMap.remove(key);
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ @Override
|
||||
+ public V putIfAbsent(Long key, V value) {
|
||||
+ return backingMap.putIfAbsent(key, value);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int size() {
|
||||
+ return backingMap.size();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/RegionizedWorldData.java b/src/main/java/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
index 7ca275826609bcf96f103a8c50beaa47c3b4068b..dc5399bd5dba9dd33a7cfd644327c2568a6ad051 100644
|
||||
--- a/src/main/java/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
+++ b/src/main/java/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
@@ -4,6 +4,7 @@ import com.destroystokyo.paper.util.maplist.ReferenceList;
|
||||
import com.destroystokyo.paper.util.misc.PlayerAreaMap;
|
||||
import com.destroystokyo.paper.util.misc.PooledLinkedHashSets;
|
||||
import com.mojang.logging.LogUtils;
|
||||
+import gg.pufferfish.pufferfish.util.AsyncPlayerAreaMap;
|
||||
import io.papermc.paper.chunk.system.scheduling.ChunkHolderManager;
|
||||
import io.papermc.paper.util.CoordinateUtils;
|
||||
import io.papermc.paper.util.TickThread;
|
||||
@@ -14,6 +15,7 @@ import it.unimi.dsi.fastutil.longs.Long2ReferenceMap;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ReferenceOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.ReportedException;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -58,6 +60,10 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
+import java.util.concurrent.CompletableFuture;
|
||||
+import java.util.concurrent.LinkedBlockingQueue;
|
||||
+import java.util.concurrent.ThreadPoolExecutor;
|
||||
+import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@@ -145,6 +151,10 @@ public final class RegionizedWorldData {
|
||||
into.wanderingTraderSpawnDelay = Math.max(from.wanderingTraderSpawnDelay, into.wanderingTraderSpawnDelay);
|
||||
into.wanderingTraderSpawnChance = Math.max(from.wanderingTraderSpawnChance, into.wanderingTraderSpawnChance);
|
||||
}
|
||||
+
|
||||
+ //Luminol start - Async mob spawning
|
||||
+ from.lastAsyncSpawnStateTask = null; //Discard the task currently processing
|
||||
+ //Luminol end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -302,6 +312,10 @@ public final class RegionizedWorldData {
|
||||
regionizedWorldData.wanderingTraderSpawnDelay = from.wanderingTraderSpawnDelay;
|
||||
regionizedWorldData.villageSiegeState = new VillageSiegeState(); // just re set it, as the spawn pos will be invalid
|
||||
}
|
||||
+
|
||||
+ //Luminol start - Async mob spawning
|
||||
+ from.lastAsyncSpawnStateTask = null; //Reset the task
|
||||
+ //Luminol end
|
||||
}
|
||||
};
|
||||
|
||||
@@ -398,6 +412,22 @@ public final class RegionizedWorldData {
|
||||
public java.util.ArrayDeque<net.minecraft.world.level.block.RedstoneTorchBlock.Toggle> redstoneUpdateInfos;
|
||||
public final Long2IntOpenHashMap chunksBeingWorkedOn = new Long2IntOpenHashMap();
|
||||
|
||||
+ //Luminol start - Asnc mob spawning
|
||||
+ public volatile CompletableFuture<NaturalSpawner.SpawnState> lastAsyncSpawnStateTask = null;
|
||||
+ public static ThreadPoolExecutor ASYNC_MOB_SPAWNING_EXECUTOR;
|
||||
+ public static void initMobSpawningExecutor(){
|
||||
+ if (LuminolConfig.enableAsyncMobSpawning){
|
||||
+ ASYNC_MOB_SPAWNING_EXECUTOR = new ThreadPoolExecutor(
|
||||
+ 1,
|
||||
+ Integer.MAX_VALUE,
|
||||
+ 1,
|
||||
+ TimeUnit.MINUTES,
|
||||
+ new LinkedBlockingQueue<>()
|
||||
+ );
|
||||
+ }
|
||||
+ }
|
||||
+ //Luminol end
|
||||
+
|
||||
public static final class TempCollisionList<T> {
|
||||
final UnsafeList<T> list = new UnsafeList<>(64);
|
||||
boolean inUse;
|
||||
@@ -430,7 +460,7 @@ public final class RegionizedWorldData {
|
||||
|
||||
// Mob spawning
|
||||
private final PooledLinkedHashSets<ServerPlayer> pooledHashSets = new PooledLinkedHashSets<>();
|
||||
- public final PlayerAreaMap mobSpawnMap = new PlayerAreaMap(this.pooledHashSets);
|
||||
+ public final PlayerAreaMap mobSpawnMap = new AsyncPlayerAreaMap(this.pooledHashSets); //Luminol - Async mob spawning
|
||||
public int catSpawnerNextTick = 0;
|
||||
public int patrolSpawnerNextTick = 0;
|
||||
public int phantomSpawnerNextTick = 0;
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index e8cd180bab5c196db09ded74aea676b4412fc6e9..534f54be1495b1a8f754bec0eb1aba8306c1d902 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -2,6 +2,7 @@ package me.earthme.luminol;
|
||||
|
||||
import dev.kaiijumc.kaiiju.region.RegionFileFormat;
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import io.papermc.paper.threadedregions.RegionizedWorldData;
|
||||
import me.earthme.luminol.commands.TpsBarCommand;
|
||||
import me.earthme.luminol.functions.GlobalServerTpsBar;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
@@ -62,6 +63,7 @@ public class LuminolConfig {
|
||||
public static boolean asyncPathProcessing = false;
|
||||
public static int asyncPathProcessingMaxThreads = 0;
|
||||
public static int asyncPathProcessingKeepalive = 60;
|
||||
+ public static boolean enableAsyncMobSpawning = false;
|
||||
|
||||
public static void init() throws IOException {
|
||||
PARENT_FOLDER.mkdir();
|
||||
@@ -188,6 +190,8 @@ public class LuminolConfig {
|
||||
asyncPathProcessingMaxThreads = Math.max(Runtime.getRuntime().availableProcessors() / 4, 1);
|
||||
if (!asyncPathProcessing)
|
||||
asyncPathProcessingMaxThreads = 0;
|
||||
+ enableAsyncMobSpawning = get("optimizations.enable_async_mob_spawning",enableAsyncMobSpawning);
|
||||
+ RegionizedWorldData.initMobSpawningExecutor();
|
||||
}
|
||||
|
||||
public static <T> T get(String key,T def){
|
||||
diff --git a/src/main/java/me/earthme/luminol/utils/AsyncMobSpawnExecutor.java b/src/main/java/me/earthme/luminol/utils/AsyncMobSpawnExecutor.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..88d5b188ccfb17fe1ae4b08f32565f27569cad5c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/utils/AsyncMobSpawnExecutor.java
|
||||
@@ -0,0 +1,71 @@
|
||||
+package me.earthme.luminol.utils;
|
||||
+
|
||||
+import ca.spottedleaf.concurrentutil.collection.MultiThreadedQueue;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.util.concurrent.Executor;
|
||||
+import java.util.concurrent.atomic.AtomicBoolean;
|
||||
+import java.util.concurrent.locks.LockSupport;
|
||||
+
|
||||
+public class AsyncMobSpawnExecutor implements Runnable, Executor {
|
||||
+ private final MultiThreadedQueue<Runnable> allTasks = new MultiThreadedQueue<>();
|
||||
+ private final Thread worker = new Thread(this);
|
||||
+ private AtomicBoolean shouldRunNext = new AtomicBoolean(true);
|
||||
+ private AtomicBoolean isRunning = new AtomicBoolean(false);
|
||||
+ private AtomicBoolean isIdle = new AtomicBoolean(false);
|
||||
+
|
||||
+ public boolean isRunning(){
|
||||
+ return this.isRunning.get();
|
||||
+ }
|
||||
+
|
||||
+ public void startExecutor(){
|
||||
+ this.worker.setDaemon(true);
|
||||
+ this.worker.setContextClassLoader(MinecraftServer.class.getClassLoader());
|
||||
+ this.worker.start();
|
||||
+ }
|
||||
+
|
||||
+ public void forceTerminate(){
|
||||
+ this.shouldRunNext.set(false);
|
||||
+ if (this.isRunning.get()){
|
||||
+ this.allTasks.clear();
|
||||
+ LockSupport.unpark(this.worker);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void dropAllTasks(){
|
||||
+ this.allTasks.clear();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void run() {
|
||||
+ this.isRunning.set(true);
|
||||
+ try {
|
||||
+ while (this.shouldRunNext.get()){
|
||||
+ final Runnable task = this.allTasks.poll();
|
||||
+ if (task != null){
|
||||
+ this.isIdle.set(false);
|
||||
+
|
||||
+ try {
|
||||
+ task.run();
|
||||
+ }catch (Exception e){
|
||||
+ e.printStackTrace(); //TODO - Exception processing?
|
||||
+ }
|
||||
+
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ this.isIdle.set(true);
|
||||
+ LockSupport.park();
|
||||
+ }
|
||||
+ }finally {
|
||||
+ this.isRunning.set(false);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void execute(@NotNull Runnable command) {
|
||||
+ this.allTasks.offer(command);
|
||||
+ LockSupport.unpark(this.worker); //Notify
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
index b9b1dfe04eda8498f0ceff0aee66489d2a02b814..c470eafef884075b6e4d170adc2ced96a4beb517 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -11,13 +11,15 @@ import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
-import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import io.papermc.paper.threadedregions.RegionizedWorldData;
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.SectionPos;
|
||||
@@ -487,32 +489,38 @@ public class ServerChunkCache extends ChunkSource {
|
||||
this.level.timings.countNaturalMobs.startTiming(); // Paper - timings
|
||||
int l = this.distanceManager.getNaturalSpawnChunkCount();
|
||||
// Paper start - per player mob spawning
|
||||
- NaturalSpawner.SpawnState spawnercreature_d; // moved down
|
||||
+ NaturalSpawner.SpawnState spawnercreature_d = null; // moved down
|
||||
profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.MOB_SPAWN_ENTITY_COUNT); try { // Folia - profiler
|
||||
- if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled
|
||||
- // re-set mob counts
|
||||
- for (ServerPlayer player : regionizedWorldData.getLocalPlayers()) { // Folia - region threading
|
||||
- // Paper start - per player mob spawning backoff
|
||||
- for (int ii = 0; ii < ServerPlayer.MOBCATEGORY_TOTAL_ENUMS; ii++) {
|
||||
- player.mobCounts[ii] = 0;
|
||||
-
|
||||
- int newBackoff = player.mobBackoffCounts[ii] - 1; // TODO make configurable bleed // TODO use nonlinear algorithm?
|
||||
- if (newBackoff < 0) {
|
||||
- newBackoff = 0;
|
||||
+ if (!LuminolConfig.enableAsyncMobSpawning){ //Luminol
|
||||
+ if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled
|
||||
+ // re-set mob counts
|
||||
+ for (ServerPlayer player : regionizedWorldData.getLocalPlayers()) { // Folia - region threading
|
||||
+ // Paper start - per player mob spawning backoff
|
||||
+ for (int ii = 0; ii < ServerPlayer.MOBCATEGORY_TOTAL_ENUMS; ii++) {
|
||||
+ player.mobCounts[ii] = 0;
|
||||
+
|
||||
+ int newBackoff = player.mobBackoffCounts[ii] - 1; // TODO make configurable bleed // TODO use nonlinear algorithm?
|
||||
+ if (newBackoff < 0) {
|
||||
+ newBackoff = 0;
|
||||
+ }
|
||||
+ player.mobBackoffCounts[ii] = newBackoff;
|
||||
}
|
||||
- player.mobBackoffCounts[ii] = newBackoff;
|
||||
+ // Paper end - per player mob spawning backoff
|
||||
}
|
||||
- // Paper end - per player mob spawning backoff
|
||||
+ spawnercreature_d = NaturalSpawner.createState(l, regionizedWorldData.getLoadedEntities(), this::getFullChunk, null, true); // Folia - region threading
|
||||
+ } else {
|
||||
+ spawnercreature_d = NaturalSpawner.createState(l, regionizedWorldData.getLoadedEntities(), this::getFullChunk, !this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new LocalMobCapCalculator(this.chunkMap) : null, false); // Folia - region threading
|
||||
}
|
||||
- spawnercreature_d = NaturalSpawner.createState(l, regionizedWorldData.getLoadedEntities(), this::getFullChunk, null, true); // Folia - region threading
|
||||
- } else {
|
||||
- spawnercreature_d = NaturalSpawner.createState(l, regionizedWorldData.getLoadedEntities(), this::getFullChunk, !this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new LocalMobCapCalculator(this.chunkMap) : null, false); // Folia - region threading
|
||||
+ }//Luminol
|
||||
+ //Luminol start - Async mob spawning
|
||||
+ if (!LuminolConfig.enableAsyncMobSpawning){
|
||||
+ regionizedWorldData.lastAsyncSpawnStateTask = CompletableFuture.completedFuture(spawnercreature_d);
|
||||
}
|
||||
} finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.MOB_SPAWN_ENTITY_COUNT); } // Folia - profiler
|
||||
// Paper end
|
||||
this.level.timings.countNaturalMobs.stopTiming(); // Paper - timings
|
||||
|
||||
- regionizedWorldData.lastSpawnState = spawnercreature_d; // Folia - region threading
|
||||
+ //regionizedWorldData.lastSpawnState = spawnercreature_d; // Folia - region threading //Luminol - Async mob spawning
|
||||
gameprofilerfiller.popPush("filteringLoadedChunks");
|
||||
// Paper - optimise chunk tick iteration
|
||||
// Paper - optimise chunk tick iteration
|
||||
@@ -610,7 +618,12 @@ public class ServerChunkCache extends ChunkSource {
|
||||
chunk1.incrementInhabitedTime(j);
|
||||
if (spawn && flag2 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair)) { // Spigot // Paper - optimise chunk tick iteration
|
||||
++spawnChunkCount; // Folia - profiler
|
||||
- NaturalSpawner.spawnForChunk(this.level, chunk1, spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1);
|
||||
+
|
||||
+ //Luminol start - Async mob spawning
|
||||
+ if (regionizedWorldData.lastAsyncSpawnStateTask != null && regionizedWorldData.lastAsyncSpawnStateTask.isDone()){
|
||||
+ NaturalSpawner.spawnForChunk(this.level, chunk1, regionizedWorldData.lastAsyncSpawnStateTask.join(), this.spawnFriendlies, this.spawnEnemies, flag1);
|
||||
+ }
|
||||
+ //Luminol end
|
||||
}
|
||||
|
||||
if (true || this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) { // Paper - optimise chunk tick iteration
|
||||
@@ -667,6 +680,36 @@ public class ServerChunkCache extends ChunkSource {
|
||||
gameprofilerfiller.pop();
|
||||
gameprofilerfiller.pop();
|
||||
this.chunkMap.tick();
|
||||
+
|
||||
+ //Luminol start - Async mob spawning
|
||||
+ if (LuminolConfig.enableAsyncMobSpawning){
|
||||
+ //Luminol - Copied down
|
||||
+ if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled
|
||||
+ // re-set mob counts
|
||||
+ for (ServerPlayer player : regionizedWorldData.getLocalPlayers()) { // Folia - region threading
|
||||
+ // Paper start - per player mob spawning backoff
|
||||
+ for (int ii = 0; ii < ServerPlayer.MOBCATEGORY_TOTAL_ENUMS; ii++) {
|
||||
+ player.mobCounts[ii] = 0;
|
||||
+
|
||||
+ int newBackoff = player.mobBackoffCounts[ii] - 1; // TODO make configurable bleed // TODO use nonlinear algorithm?
|
||||
+ if (newBackoff < 0) {
|
||||
+ newBackoff = 0;
|
||||
+ }
|
||||
+ player.mobBackoffCounts[ii] = newBackoff;
|
||||
+ }
|
||||
+ // Paper end - per player mob spawning backoff
|
||||
+ }
|
||||
+
|
||||
+ if (regionizedWorldData.lastAsyncSpawnStateTask == null || regionizedWorldData.lastAsyncSpawnStateTask.isDone()){
|
||||
+ regionizedWorldData.lastAsyncSpawnStateTask = CompletableFuture.supplyAsync(() -> NaturalSpawner.createState(l, regionizedWorldData.getLoadedEntities(), this::getFullChunk, null, true),RegionizedWorldData.ASYNC_MOB_SPAWNING_EXECUTOR);
|
||||
+ }
|
||||
+ } else {
|
||||
+ if (regionizedWorldData.lastAsyncSpawnStateTask == null || regionizedWorldData.lastAsyncSpawnStateTask.isDone()){
|
||||
+ regionizedWorldData.lastAsyncSpawnStateTask = CompletableFuture.supplyAsync(() -> NaturalSpawner.createState(l, regionizedWorldData.getLoadedEntities(), this::getFullChunk, !this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new LocalMobCapCalculator(this.chunkMap) : null, false), RegionizedWorldData.ASYNC_MOB_SPAWNING_EXECUTOR);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ //Luminol end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -809,7 +852,7 @@ public class ServerChunkCache extends ChunkSource {
|
||||
@VisibleForDebug
|
||||
public NaturalSpawner.SpawnState getLastSpawnState() {
|
||||
io.papermc.paper.threadedregions.RegionizedWorldData worldData = this.level.getCurrentWorldData(); // Folia - region threading
|
||||
- return worldData == null ? null : worldData.lastSpawnState; // Folia - region threading
|
||||
+ return worldData.lastAsyncSpawnStateTask != null && worldData.lastAsyncSpawnStateTask.isDone() ? worldData.lastAsyncSpawnStateTask.join() : null; // Folia - region threading //Luminol - Async mob spawning
|
||||
}
|
||||
|
||||
public void removeTicketsOnClosing() {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||
index 5caca2a34849189ea42d2699f6d8672e0d7251cb..b21243d494fd1989e7d6c2b98b08e090dc2f38b7 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||
@@ -1,6 +1,9 @@
|
||||
package net.minecraft.world.level;
|
||||
|
||||
+import ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor;
|
||||
import com.mojang.logging.LogUtils;
|
||||
+import io.papermc.paper.threadedregions.RegionizedServer;
|
||||
+import io.papermc.paper.util.TickThread;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMaps;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
@@ -117,6 +120,15 @@ public final class NaturalSpawner {
|
||||
object2intopenhashmap.addTo(enumcreaturetype, 1);
|
||||
// Paper start
|
||||
if (countMobs) {
|
||||
+ //Luminol start - Async mob spawning
|
||||
+ if (!TickThread.isTickThread()){
|
||||
+ RegionizedServer.getInstance().taskQueue.queueTickTaskQueue(chunk.level,chunk.locX,chunk.locZ,()->{
|
||||
+ chunk.level.getChunkSource().chunkMap.updatePlayerMobTypeMap(entity);
|
||||
+ });
|
||||
+ return;
|
||||
+ }
|
||||
+ //Luminol end
|
||||
+
|
||||
chunk.level.getChunkSource().chunkMap.updatePlayerMobTypeMap(entity);
|
||||
}
|
||||
// Paper end
|
||||
19
patches/server/0042-Added-back-worldborder-command.patch
Normal file
19
patches/server/0042-Added-back-worldborder-command.patch
Normal file
@@ -0,0 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Mon, 11 Dec 2023 20:00:10 +0800
|
||||
Subject: [PATCH] Added back worldborder command
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
|
||||
index 3435bdeaf723c64103f7c924ea42a4ec78f2ba01..a7732effbb2885b398d18df2e581f7a0f279a85a 100644
|
||||
--- a/src/main/java/net/minecraft/commands/Commands.java
|
||||
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
||||
@@ -202,7 +202,7 @@ public class Commands {
|
||||
TitleCommand.register(this.dispatcher);
|
||||
//TriggerCommand.register(this.dispatcher); // Folia - region threading - TODO later
|
||||
WeatherCommand.register(this.dispatcher);
|
||||
- //WorldBorderCommand.register(this.dispatcher); // Folia - region threading - TODO later
|
||||
+ WorldBorderCommand.register(this.dispatcher); // Folia - region threading - TODO later //Lumino - Add back world border
|
||||
if (JvmProfiler.INSTANCE.isAvailable()) {
|
||||
JfrCommand.register(this.dispatcher);
|
||||
}
|
||||
@@ -1,37 +1,31 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 08:35:11 +0000
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 17 Dec 2023 20:32:49 +0800
|
||||
Subject: [PATCH] Purpur use alternative keep alive
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/PurpurAlternativeKeepaliveConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/PurpurAlternativeKeepaliveConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..43bbc2c30bdd3872a0179e0070403c3e257c320e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/PurpurAlternativeKeepaliveConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.optimizations;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class PurpurAlternativeKeepaliveConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index 6edafcdbc188cd6c78e4c4237363e41d927a665e..a62680768068b611fe723fedeb617d42c643e59e 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -64,6 +64,7 @@ public class LuminolConfig {
|
||||
public static int asyncPathProcessingMaxThreads = 0;
|
||||
public static int asyncPathProcessingKeepalive = 60;
|
||||
public static boolean enableAsyncMobSpawning = false;
|
||||
+ public static boolean useAlternateKeepAlive = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.OPTIMIZATIONS;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "alternative_keepalive_handling";
|
||||
+ }
|
||||
+}
|
||||
|
||||
public static void init() throws IOException {
|
||||
PARENT_FOLDER.mkdir();
|
||||
@@ -192,6 +193,7 @@ public class LuminolConfig {
|
||||
asyncPathProcessingMaxThreads = 0;
|
||||
enableAsyncMobSpawning = get("optimizations.enable_async_mob_spawning",enableAsyncMobSpawning);
|
||||
RegionizedWorldData.initMobSpawningExecutor();
|
||||
+ useAlternateKeepAlive = get("optimizations.enable_alternative_keep_alive_handling",useAlternateKeepAlive,"Enabling this sends a keepalive packet once per second to a player, and only kicks for timeout if none of them were responded to in 30 seconds. Responding to any of them in any order will keep the player connected. AKA, it won't kick your players because one packet gets dropped somewhere along the lines(From purpur)");
|
||||
}
|
||||
|
||||
public static <T> T get(String key,T def){
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
index 22f0d91df0a81040d72c499fbff32b3a9d41598f..c68910b2a2eb703406fb406a86783cf6ab48651e 100644
|
||||
index 2bb944cef9bc8c5e56023ef20921ef13509d4823..9d23285f97ac5d90eb177ddc325281fa197d7f76 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
@@ -51,6 +51,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
@@ -41,13 +35,13 @@ index 22f0d91df0a81040d72c499fbff32b3a9d41598f..c68910b2a2eb703406fb406a86783cf6
|
||||
+ private it.unimi.dsi.fastutil.longs.LongList keepAlives = new it.unimi.dsi.fastutil.longs.LongArrayList(); // Purpur
|
||||
private int latency;
|
||||
private volatile boolean suspendFlushingOnServerThread = false;
|
||||
public final java.util.Map<java.util.UUID, net.kyori.adventure.resource.ResourcePackCallback> packCallbacks = new java.util.concurrent.ConcurrentHashMap<>(); // Paper - adventure resource pack callbacks
|
||||
@@ -103,6 +104,16 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit
|
||||
@@ -91,6 +92,16 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
|
||||
@Override
|
||||
public void handleKeepAlive(ServerboundKeepAlivePacket packet) {
|
||||
+ // Purpur start
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.PurpurAlternativeKeepaliveConfig.useAlternateKeepAlive) {
|
||||
+ if (me.earthme.luminol.LuminolConfig.useAlternateKeepAlive) {
|
||||
+ long id = packet.getId();
|
||||
+ if (keepAlives.size() > 0 && keepAlives.contains(id)) {
|
||||
+ int ping = (int) (Util.getMillis() - id);
|
||||
@@ -55,16 +49,16 @@ index 22f0d91df0a81040d72c499fbff32b3a9d41598f..c68910b2a2eb703406fb406a86783cf6
|
||||
+ keepAlives.clear(); // we got a valid response, lets roll with it and forget the rest
|
||||
+ }
|
||||
+ } else
|
||||
+ // Purpur end
|
||||
//PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); // CraftBukkit // Paper - handle ServerboundKeepAlivePacket async
|
||||
+ // Purpur end
|
||||
//PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); // CraftBukkit // Paper - This shouldn't be on the main thread
|
||||
if (this.keepAlivePending && packet.getId() == this.keepAliveChallenge) {
|
||||
int i = (int) (Util.getMillis() - this.keepAliveTime);
|
||||
@@ -221,6 +232,21 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
@@ -197,6 +208,21 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
long currentTime = Util.getMillis();
|
||||
long elapsedTime = currentTime - this.keepAliveTime;
|
||||
|
||||
+ // Purpur start
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.PurpurAlternativeKeepaliveConfig.useAlternateKeepAlive) {
|
||||
+ if (me.earthme.luminol.LuminolConfig.useAlternateKeepAlive) {
|
||||
+ if (elapsedTime >= 1000L) { // 1 second
|
||||
+ if (!processedDisconnect && keepAlives.size() * 1000L >= KEEPALIVE_LIMIT) {
|
||||
+ LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName());
|
||||
@@ -1,11 +1,11 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 08:51:49 +0000
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 17 Dec 2023 20:39:21 +0800
|
||||
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 fc3d332aa1c1d469cedfe2aaa7102dcd78e25642..bebaa4e7abcbd01dc57fddf2a473b846e887cc7f 100644
|
||||
index 1e3117ccd51be58d988089207a3efdbff02fc374..a28cdeed2a0a2d5194edcfc13cac38f2f2d80489 100644
|
||||
--- a/src/main/java/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||
+++ b/src/main/java/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||
@@ -313,6 +313,8 @@ public final class RegionizedServer {
|
||||
@@ -36,18 +36,18 @@ index af86f752c33a2990405fea058b7c41c437ba9d46..bada9fae1e7178162429e1f5a1608b9c
|
||||
}
|
||||
|
||||
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
|
||||
index 9d23285f97ac5d90eb177ddc325281fa197d7f76..e1ace2ad411b8d54c56660b41e774a1c998b3ac3 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
|
||||
@@ -127,6 +127,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
|
||||
// Paper start - handle brand payload packet
|
||||
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
|
||||
@@ -144,6 +145,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);
|
||||
@@ -56,10 +56,10 @@ index c68910b2a2eb703406fb406a86783cf6ab48651e..f935214ed80fe54038a96a5cd668a072
|
||||
} 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 d13edeff0de64cb77d7668e5b964cabcf9729388..c8c72cefba44ce8587a9ae22f5a87d3199f8ca5f 100644
|
||||
index 7edaa7558e40942f94c459e9b480ef640146ec6b..3f366ad035ada0ac8170d2925bbfe86b80bd84cb 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -433,6 +433,8 @@ public abstract class PlayerList {
|
||||
@@ -435,6 +435,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
|
||||
}
|
||||
|
||||
@@ -68,19 +68,19 @@ index d13edeff0de64cb77d7668e5b964cabcf9729388..c8c72cefba44ce8587a9ae22f5a87d31
|
||||
final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage();
|
||||
|
||||
if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure
|
||||
@@ -688,6 +690,7 @@ public abstract class PlayerList {
|
||||
@@ -691,6 +693,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
|
||||
// Paper end
|
||||
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 b9b1bcd165fb8864dda924a29d128d810b2ee7ab..e5e0f469b0fe98c18d87f3fc4fdecf6f26e33149 100644
|
||||
index 5fe36cbb14f0f0e9692cfa40381cebdb4e142bbe..ee66241a422acb8920395fd5e41578a966746f5c 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 {
|
||||
@@ -478,6 +478,7 @@ public final class CraftServer implements Server {
|
||||
MapPalette.setMapColorCache(new CraftMapColorCache(this.logger));
|
||||
}
|
||||
datapackManager = new io.papermc.paper.datapack.PaperDatapackManager(console.getPackRepository()); // Paper
|
||||
@@ -88,7 +88,7 @@ index b9b1bcd165fb8864dda924a29d128d810b2ee7ab..e5e0f469b0fe98c18d87f3fc4fdecf6f
|
||||
}
|
||||
|
||||
public boolean getCommandBlockOverride(String command) {
|
||||
@@ -1129,6 +1130,7 @@ public final class CraftServer implements Server {
|
||||
@@ -1114,6 +1115,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");
|
||||
709
patches/server/0045-Leaves-PCA-sync-protocol.patch
Normal file
709
patches/server/0045-Leaves-PCA-sync-protocol.patch
Normal file
@@ -0,0 +1,709 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 17 Dec 2023 21:01:59 +0800
|
||||
Subject: [PATCH] Leaves PCA sync protocol
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index a62680768068b611fe723fedeb617d42c643e59e..cfe9a8eb705039ee7e2dc9262e1355c4b0f664bb 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -66,6 +66,10 @@ public class LuminolConfig {
|
||||
public static boolean enableAsyncMobSpawning = false;
|
||||
public static boolean useAlternateKeepAlive = false;
|
||||
|
||||
+ public static boolean pcaSyncProtocol = false;
|
||||
+ public static String pcaSyncPlayerEntity = "NOBODY";
|
||||
+
|
||||
+
|
||||
public static void init() throws IOException {
|
||||
PARENT_FOLDER.mkdir();
|
||||
|
||||
@@ -194,6 +198,9 @@ public class LuminolConfig {
|
||||
enableAsyncMobSpawning = get("optimizations.enable_async_mob_spawning",enableAsyncMobSpawning);
|
||||
RegionizedWorldData.initMobSpawningExecutor();
|
||||
useAlternateKeepAlive = get("optimizations.enable_alternative_keep_alive_handling",useAlternateKeepAlive,"Enabling this sends a keepalive packet once per second to a player, and only kicks for timeout if none of them were responded to in 30 seconds. Responding to any of them in any order will keep the player connected. AKA, it won't kick your players because one packet gets dropped somewhere along the lines(From purpur)");
|
||||
+
|
||||
+ pcaSyncProtocol = get("gameplay.enable_pca_sync_protocol",pcaSyncProtocol);
|
||||
+ pcaSyncPlayerEntity = get("gameplay.pca_sync_player_entity",pcaSyncPlayerEntity,"Available values: NOBODY,EVERYBODY,OPS,OPS_AND_SELF");
|
||||
}
|
||||
|
||||
public static <T> T get(String key,T def){
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
|
||||
index a0628b9d74c29d02bfba583edf7ee6f2cde2cff6..698c7bfddb0d45d088c30fd26eccb86b924fd60a 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
|
||||
@@ -373,6 +373,11 @@ public abstract class AbstractHorse extends Animal implements ContainerListener,
|
||||
|
||||
@Override
|
||||
public void containerChanged(Container sender) {
|
||||
+ // Leaves start - pca
|
||||
+ if (me.earthme.luminol.LuminolConfig.pcaSyncProtocol) {
|
||||
+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncEntityToClient(this);
|
||||
+ }
|
||||
+ // Leaves end - pca
|
||||
boolean flag = this.isSaddled();
|
||||
|
||||
this.updateContainerEquipment();
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
|
||||
index ce728f062794e239d1dfdf842d7d0c725f77fba7..a3200593788525c7f18420036044bfdccfaf40fc 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
|
||||
@@ -64,6 +64,15 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa
|
||||
super(type, world);
|
||||
this.setPathfindingMalus(BlockPathTypes.DANGER_FIRE, 16.0F);
|
||||
this.setPathfindingMalus(BlockPathTypes.DAMAGE_FIRE, -1.0F);
|
||||
+ // Leaves start - pca
|
||||
+ if (!this.level().isClientSide()) {
|
||||
+ this.inventory.addListener(inventory -> {
|
||||
+ if (me.earthme.luminol.LuminolConfig.pcaSyncProtocol) {
|
||||
+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncEntityToClient(this);
|
||||
+ }
|
||||
+ });
|
||||
+ }
|
||||
+ // Leaves end - pca
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
index f64edfdb03f99624daf1e05b5dc86d845c3018b6..e98ea5f93a829e232a61eee4564209d1831f8b8d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
@@ -138,7 +138,13 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void setChanged() {}
|
||||
+ public void setChanged() {
|
||||
+ // Leaves start - pca
|
||||
+ if (me.earthme.luminol.LuminolConfig.pcaSyncProtocol) {
|
||||
+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncEntityToClient(this);
|
||||
+ }
|
||||
+ // Leaves end - pca
|
||||
+ }
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||
index a18aadbf7ae83713e1f2b21553185d8000bc7699..4b174bed02fb98f798f9444e03fc866baf1e1a07 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||
@@ -569,6 +569,16 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
|
||||
|
||||
}
|
||||
|
||||
+ // Leaves start - pca
|
||||
+ @Override
|
||||
+ public void setChanged() {
|
||||
+ super.setChanged();
|
||||
+ if (me.earthme.luminol.LuminolConfig.pcaSyncProtocol) {
|
||||
+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this);
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaves end - pca
|
||||
+
|
||||
@Override
|
||||
public boolean stillValid(net.minecraft.world.entity.player.Player player) {
|
||||
return Container.stillValidBlockEntity(this, player);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
||||
index 416aa989ebb18a8741cc9d605a1180ab830f6643..b73c3dc28a95279285e911bfed3bc3d3f038e6db 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
||||
@@ -131,6 +131,16 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
|
||||
this.items = list;
|
||||
}
|
||||
|
||||
+ // Leaves start - pca
|
||||
+ @Override
|
||||
+ public void setChanged() {
|
||||
+ super.setChanged();
|
||||
+ if (me.earthme.luminol.LuminolConfig.pcaSyncProtocol) {
|
||||
+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this);
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaves end - pca
|
||||
+
|
||||
@Override
|
||||
protected Component getDefaultName() {
|
||||
return Component.translatable("container.barrel");
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
||||
index cf09525efd2d53bf884cd6ec3b0b9229715895eb..9c7b5fbec4ec1eb6b39f139a9b16483208249b6f 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
||||
@@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
+import java.util.Objects;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -127,6 +128,11 @@ public class BeehiveBlockEntity extends BlockEntity {
|
||||
super.setChanged();
|
||||
}
|
||||
|
||||
+ // Leaves start - pca
|
||||
+ if (me.earthme.luminol.LuminolConfig.pcaSyncProtocol) {
|
||||
+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this);
|
||||
+ }
|
||||
+ // Leaves end - pca
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -188,6 +194,12 @@ public class BeehiveBlockEntity extends BlockEntity {
|
||||
this.level.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of(entity, this.getBlockState()));
|
||||
}
|
||||
|
||||
+ // Leaves start - pca
|
||||
+ if (me.earthme.luminol.LuminolConfig.pcaSyncProtocol) {
|
||||
+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this);
|
||||
+ }
|
||||
+ // Leaves end - pca
|
||||
+
|
||||
entity.discard();
|
||||
super.setChanged();
|
||||
}
|
||||
@@ -334,6 +346,11 @@ public class BeehiveBlockEntity extends BlockEntity {
|
||||
if (BeehiveBlockEntity.releaseOccupant(world, pos, state, tileentitybeehive_hivebee, (List) null, tileentitybeehive_releasestatus, flowerPos)) {
|
||||
flag = true;
|
||||
iterator.remove();
|
||||
+ // Leaves start - pca
|
||||
+ if (me.earthme.luminol.LuminolConfig.pcaSyncProtocol) {
|
||||
+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(Objects.requireNonNull(world.getBlockEntity(pos)));
|
||||
+ }
|
||||
+ // Leaves end - pca
|
||||
// CraftBukkit start
|
||||
} else {
|
||||
tileentitybeehive_hivebee.exitTickCounter = tileentitybeehive_hivebee.minOccupationTicks / 2; // Not strictly Vanilla behaviour in cases where bees cannot spawn but still reasonable // Paper - use exitTickCounter to keep actual bee life
|
||||
@@ -385,6 +402,11 @@ public class BeehiveBlockEntity extends BlockEntity {
|
||||
this.maxBees = nbt.getInt("Bukkit.MaxEntities");
|
||||
}
|
||||
// CraftBukkit end
|
||||
+ // Leaves start - pca
|
||||
+ if (me.earthme.luminol.LuminolConfig.pcaSyncProtocol) {
|
||||
+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this);
|
||||
+ }
|
||||
+ // Leaves end - pca
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
|
||||
index 526d1bfd5ad0de7bcfd0c2da902515f3dec94c54..66758af67aca2c726b2f5b451f3f7197102af22f 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
|
||||
@@ -333,6 +333,16 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
|
||||
|
||||
}
|
||||
|
||||
+ // Leaves start - pca
|
||||
+ @Override
|
||||
+ public void setChanged() {
|
||||
+ super.setChanged();
|
||||
+ if (me.earthme.luminol.LuminolConfig.pcaSyncProtocol) {
|
||||
+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this);
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaves end - pca
|
||||
+
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
return Container.stillValidBlockEntity(this, player);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
index d66806565770cb03a21794f99e5c4b0f3040b26a..034bc37a8b50a3c9904f4f53c8758b1b02b458b1 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
@@ -220,6 +220,16 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
// Pufferfish end
|
||||
}
|
||||
|
||||
+ // Leaves start - pca
|
||||
+ @Override
|
||||
+ public void setChanged() {
|
||||
+ super.setChanged();
|
||||
+ if (me.earthme.luminol.LuminolConfig.pcaSyncProtocol) {
|
||||
+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this);
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaves end - pca
|
||||
+
|
||||
@Override
|
||||
public float getOpenNess(float tickDelta) {
|
||||
return this.chestLidController.getOpenness(tickDelta);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
|
||||
index 881379681c39230a00b3a1f11cd87498984396c7..51fae4d72eed9e4224a8abe1a0b6520835857ba5 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
|
||||
@@ -92,6 +92,16 @@ public class DispenserBlockEntity extends RandomizableContainerBlockEntity {
|
||||
return -1;
|
||||
}
|
||||
|
||||
+ // Leaves start - pca
|
||||
+ @Override
|
||||
+ public void setChanged() {
|
||||
+ super.setChanged();
|
||||
+ if (me.earthme.luminol.LuminolConfig.pcaSyncProtocol) {
|
||||
+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this);
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaves end - pca
|
||||
+
|
||||
@Override
|
||||
protected Component getDefaultName() {
|
||||
return Component.translatable("container.dispenser");
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
index c90d578643490709936545ee9cbd41c8671eeb7a..3527a3cc76d3b1ad1319f1eebe31fd4d9e8aa039 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
@@ -155,6 +155,16 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
|
||||
}
|
||||
|
||||
+ // Leaves start - pca
|
||||
+ @Override
|
||||
+ public void setChanged() {
|
||||
+ super.setChanged();
|
||||
+ if (me.earthme.luminol.LuminolConfig.pcaSyncProtocol) {
|
||||
+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this);
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaves end - pca
|
||||
+
|
||||
@Override
|
||||
protected Component getDefaultName() {
|
||||
return Component.translatable("container.hopper");
|
||||
@@ -234,6 +244,11 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
if (flag) {
|
||||
blockEntity.setCooldown(world.spigotConfig.hopperTransfer); // Spigot
|
||||
setChanged(world, pos, state);
|
||||
+ // Leaves start - pca
|
||||
+ if (me.earthme.luminol.LuminolConfig.pcaSyncProtocol) {
|
||||
+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(blockEntity);
|
||||
+ }
|
||||
+ // Leaves end - pca
|
||||
return true;
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
|
||||
index 1fa22445a4ecc8c08dbcf0cc6bd39dc5003604c4..c1492fce06cdc00a8e82977f0c474a541efa39e8 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
|
||||
@@ -269,6 +269,16 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl
|
||||
this.itemStacks = list;
|
||||
}
|
||||
|
||||
+ // Leaves start - pca
|
||||
+ @Override
|
||||
+ public void setChanged() {
|
||||
+ super.setChanged();
|
||||
+ if (me.earthme.luminol.LuminolConfig.pcaSyncProtocol) {
|
||||
+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this);
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaves end - pca
|
||||
+
|
||||
@Override
|
||||
public int[] getSlotsForFace(Direction side) {
|
||||
return ShulkerBoxBlockEntity.SLOTS;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
index b23e43f7ac22bc106a0bcde4a8bca9ecba1a9ae4..08bf4f13e0ee6698b18a6946cb78adb4ae65c852 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
@@ -45,7 +45,7 @@ import org.bukkit.scheduler.BukkitWorker;
|
||||
*/
|
||||
public class CraftScheduler implements BukkitScheduler {
|
||||
|
||||
- static Plugin MINECRAFT = new MinecraftInternalPlugin();
|
||||
+ public static Plugin MINECRAFT = new MinecraftInternalPlugin();
|
||||
/**
|
||||
* The start ID for the counter.
|
||||
*/
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/PcaSyncProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/PcaSyncProtocol.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ebd28033ddf0fe6a354585dc2818a9b481d90ed4
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/PcaSyncProtocol.java
|
||||
@@ -0,0 +1,384 @@
|
||||
+package top.leavesmc.leaves.protocol;
|
||||
+
|
||||
+import net.minecraft.core.BlockPos;
|
||||
+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.ServerLevel;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import net.minecraft.world.entity.Entity;
|
||||
+import net.minecraft.world.entity.player.Player;
|
||||
+import net.minecraft.world.level.Level;
|
||||
+import net.minecraft.world.level.block.ChestBlock;
|
||||
+import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
+import net.minecraft.world.level.block.state.BlockState;
|
||||
+import net.minecraft.world.level.block.state.properties.ChestType;
|
||||
+import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
+import org.apache.commons.lang3.tuple.MutablePair;
|
||||
+import org.apache.commons.lang3.tuple.Pair;
|
||||
+import org.apache.logging.log4j.LogManager;
|
||||
+import org.bukkit.craftbukkit.scheduler.CraftScheduler;
|
||||
+import org.jetbrains.annotations.Contract;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+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.HashSet;
|
||||
+import java.util.Map;
|
||||
+import java.util.Set;
|
||||
+import java.util.concurrent.locks.ReentrantLock;
|
||||
+
|
||||
+import static org.bukkit.craftbukkit.scheduler.CraftScheduler.MINECRAFT;
|
||||
+import static top.leavesmc.leaves.protocol.core.LeavesProtocolManager.EmptyPayload;
|
||||
+
|
||||
+@LeavesProtocol(namespace = "pca")
|
||||
+public class PcaSyncProtocol {
|
||||
+
|
||||
+ public static final String PROTOCOL_ID = "pca";
|
||||
+
|
||||
+ public static final ReentrantLock lock = new ReentrantLock(true);
|
||||
+ public static final ReentrantLock pairLock = new ReentrantLock(true);
|
||||
+
|
||||
+ // send
|
||||
+ private static final ResourceLocation ENABLE_PCA_SYNC_PROTOCOL = id("enable_pca_sync_protocol");
|
||||
+ private static final ResourceLocation DISABLE_PCA_SYNC_PROTOCOL = id("disable_pca_sync_protocol");
|
||||
+ private static final ResourceLocation UPDATE_ENTITY = id("update_entity");
|
||||
+ private static final ResourceLocation UPDATE_BLOCK_ENTITY = id("update_block_entity");
|
||||
+
|
||||
+ private static final Map<ServerPlayer, Pair<ResourceLocation, BlockPos>> playerWatchBlockPos = new HashMap<>();
|
||||
+ private static final Map<ServerPlayer, Pair<ResourceLocation, Entity>> playerWatchEntity = new HashMap<>();
|
||||
+ private static final Map<Pair<ResourceLocation, BlockPos>, Set<ServerPlayer>> blockPosWatchPlayerSet = new HashMap<>();
|
||||
+ private static final Map<Pair<ResourceLocation, Entity>, Set<ServerPlayer>> entityWatchPlayerSet = new HashMap<>();
|
||||
+ private static final MutablePair<ResourceLocation, Entity> ResourceLocationEntityPair = new MutablePair<>();
|
||||
+ private static final MutablePair<ResourceLocation, BlockPos> ResourceLocationBlockPosPair = new MutablePair<>();
|
||||
+
|
||||
+ @Contract("_ -> new")
|
||||
+ public static @NotNull ResourceLocation id(String path) {
|
||||
+ return new ResourceLocation(PROTOCOL_ID, path);
|
||||
+ }
|
||||
+
|
||||
+ @ProtocolHandler.PlayerJoin
|
||||
+ private static void onJoin(ServerPlayer player) {
|
||||
+ if (me.earthme.luminol.LuminolConfig.pcaSyncProtocol) {
|
||||
+ enablePcaSyncProtocol(player);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @ProtocolHandler.ReloadServer
|
||||
+ private static void onServerReload() {
|
||||
+ if (me.earthme.luminol.LuminolConfig.pcaSyncProtocol) {
|
||||
+ enablePcaSyncProtocolGlobal();
|
||||
+ } else {
|
||||
+ disablePcaSyncProtocolGlobal();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @ProtocolHandler.PayloadReceiver(payload = EmptyPayload.class, payloadId = "cancel_sync_block_entity")
|
||||
+ private static void cancelSyncBlockEntityHandler(ServerPlayer player, EmptyPayload payload) {
|
||||
+ if (!me.earthme.luminol.LuminolConfig.pcaSyncProtocol) {
|
||||
+ return;
|
||||
+ }
|
||||
+ PcaSyncProtocol.clearPlayerWatchBlock(player);
|
||||
+ }
|
||||
+
|
||||
+ @ProtocolHandler.PayloadReceiver(payload = EmptyPayload.class, payloadId = "cancel_sync_entity")
|
||||
+ private static void cancelSyncEntityHandler(ServerPlayer player, EmptyPayload payload) {
|
||||
+ if (!me.earthme.luminol.LuminolConfig.pcaSyncProtocol) {
|
||||
+ return;
|
||||
+ }
|
||||
+ PcaSyncProtocol.clearPlayerWatchEntity(player);
|
||||
+ }
|
||||
+
|
||||
+ @ProtocolHandler.PayloadReceiver(payload = SyncBlockEntityPayload.class, payloadId = "sync_block_entity")
|
||||
+ private static void syncBlockEntityHandler(ServerPlayer player, SyncBlockEntityPayload payload) {
|
||||
+ if (!me.earthme.luminol.LuminolConfig.pcaSyncProtocol) {
|
||||
+ return;
|
||||
+ }
|
||||
+ MinecraftServer server = MinecraftServer.getServer();
|
||||
+ BlockPos pos = payload.pos;
|
||||
+ ServerLevel world = player.serverLevel();
|
||||
+
|
||||
+ player.getBukkitEntity().getScheduler().execute(MINECRAFT,() -> {
|
||||
+ BlockState blockState = world.getBlockState(pos);
|
||||
+ clearPlayerWatchData(player);
|
||||
+
|
||||
+ BlockEntity blockEntityAdj = null;
|
||||
+ if (blockState.getBlock() instanceof ChestBlock) {
|
||||
+ if (blockState.getValue(ChestBlock.TYPE) != ChestType.SINGLE) {
|
||||
+ BlockPos posAdj = pos.offset(ChestBlock.getConnectedDirection(blockState).getNormal());
|
||||
+ // The method in World now checks that the caller is from the same thread...
|
||||
+ blockEntityAdj = world.getChunk(posAdj).getBlockEntity(posAdj);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (blockEntityAdj != null) {
|
||||
+ updateBlockEntity(player, blockEntityAdj);
|
||||
+ }
|
||||
+
|
||||
+ // The method in World now checks that the caller is from the same thread...
|
||||
+ BlockEntity blockEntity = world.getChunk(pos).getBlockEntity(pos);
|
||||
+ if (blockEntity != null) {
|
||||
+ updateBlockEntity(player, blockEntity);
|
||||
+ }
|
||||
+
|
||||
+ Pair<ResourceLocation, BlockPos> pair = new ImmutablePair<>(player.level().dimension().location(), pos);
|
||||
+ lock.lock();
|
||||
+ playerWatchBlockPos.put(player, pair);
|
||||
+ if (!blockPosWatchPlayerSet.containsKey(pair)) {
|
||||
+ blockPosWatchPlayerSet.put(pair, new HashSet<>());
|
||||
+ }
|
||||
+ blockPosWatchPlayerSet.get(pair).add(player);
|
||||
+ lock.unlock();
|
||||
+ },null,1);
|
||||
+ }
|
||||
+
|
||||
+ @ProtocolHandler.PayloadReceiver(payload = SyncEntityPayload.class, payloadId = "sync_entity")
|
||||
+ private static void syncEntityHandler(ServerPlayer player, SyncEntityPayload payload) {
|
||||
+ if (!me.earthme.luminol.LuminolConfig.pcaSyncProtocol) {
|
||||
+ return;
|
||||
+ }
|
||||
+ MinecraftServer server = MinecraftServer.getServer();
|
||||
+ int entityId = payload.entityId;
|
||||
+ ServerLevel world = player.serverLevel();
|
||||
+ player.getBukkitEntity().getScheduler().execute(MINECRAFT,() -> {
|
||||
+ Entity entity = world.getEntity(entityId);
|
||||
+ if (entity != null) {
|
||||
+ clearPlayerWatchData(player);
|
||||
+ if (entity instanceof Player) {
|
||||
+ if (me.earthme.luminol.LuminolConfig.pcaSyncPlayerEntity.equals("NOBODY")) {
|
||||
+ return;
|
||||
+ }else if (me.earthme.luminol.LuminolConfig.pcaSyncPlayerEntity.equals("OPS")) {
|
||||
+ if (server.getProfilePermissions(player.getGameProfile()) < 2) {
|
||||
+ return;
|
||||
+ }
|
||||
+ } else if (me.earthme.luminol.LuminolConfig.pcaSyncPlayerEntity.equals("OPS_AND_SELF")) {
|
||||
+ if (server.getProfilePermissions(player.getGameProfile()) < 2 &&
|
||||
+ entity != player) {
|
||||
+ return;
|
||||
+ }
|
||||
+ } else if (!me.earthme.luminol.LuminolConfig.pcaSyncPlayerEntity.equals("EVERYONE")) {
|
||||
+ // wtf????
|
||||
+ LogManager.getLogger().warn("pcaSyncPlayerEntity wtf???");
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ updateEntity(player, entity);
|
||||
+
|
||||
+ Pair<ResourceLocation, Entity> pair = new ImmutablePair<>(entity.level().dimension().location(), entity);
|
||||
+ lock.lock();
|
||||
+ playerWatchEntity.put(player, pair);
|
||||
+ if (!entityWatchPlayerSet.containsKey(pair)) {
|
||||
+ entityWatchPlayerSet.put(pair, new HashSet<>());
|
||||
+ }
|
||||
+ entityWatchPlayerSet.get(pair).add(player);
|
||||
+ lock.unlock();
|
||||
+ }
|
||||
+ },null,1);
|
||||
+ }
|
||||
+
|
||||
+ public static void enablePcaSyncProtocol(@NotNull ServerPlayer player) {
|
||||
+ ProtocolUtils.sendEmptyPayloadPacket(player, ENABLE_PCA_SYNC_PROTOCOL);
|
||||
+ }
|
||||
+
|
||||
+ public static void disablePcaSyncProtocol(@NotNull ServerPlayer player) {
|
||||
+ ProtocolUtils.sendEmptyPayloadPacket(player, DISABLE_PCA_SYNC_PROTOCOL);
|
||||
+ }
|
||||
+
|
||||
+ public static void updateEntity(@NotNull ServerPlayer player, @NotNull Entity entity) {
|
||||
+ CompoundTag nbt = entity.saveWithoutId(new CompoundTag());
|
||||
+ ProtocolUtils.sendPayloadPacket(player, UPDATE_ENTITY, buf -> {
|
||||
+ buf.writeResourceLocation(entity.level().dimension().location());
|
||||
+ buf.writeInt(entity.getId());
|
||||
+ buf.writeNbt(nbt);
|
||||
+ });
|
||||
+ }
|
||||
+
|
||||
+ public static void updateBlockEntity(@NotNull ServerPlayer player, @NotNull BlockEntity blockEntity) {
|
||||
+ Level world = blockEntity.getLevel();
|
||||
+
|
||||
+ if (world == null) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ ProtocolUtils.sendPayloadPacket(player, UPDATE_BLOCK_ENTITY, buf -> {
|
||||
+ buf.writeResourceLocation(world.dimension().location());
|
||||
+ buf.writeBlockPos(blockEntity.getBlockPos());
|
||||
+ buf.writeNbt(blockEntity.saveWithId());
|
||||
+ });
|
||||
+ }
|
||||
+
|
||||
+ private static MutablePair<ResourceLocation, Entity> getResourceLocationEntityPair(ResourceLocation ResourceLocation, Entity entity) {
|
||||
+ pairLock.lock();
|
||||
+ ResourceLocationEntityPair.setLeft(ResourceLocation);
|
||||
+ ResourceLocationEntityPair.setRight(entity);
|
||||
+ pairLock.unlock();
|
||||
+ return ResourceLocationEntityPair;
|
||||
+ }
|
||||
+
|
||||
+ private static MutablePair<ResourceLocation, BlockPos> getResourceLocationBlockPosPair(ResourceLocation ResourceLocation, BlockPos pos) {
|
||||
+ pairLock.lock();
|
||||
+ ResourceLocationBlockPosPair.setLeft(ResourceLocation);
|
||||
+ ResourceLocationBlockPosPair.setRight(pos);
|
||||
+ pairLock.unlock();
|
||||
+ return ResourceLocationBlockPosPair;
|
||||
+ }
|
||||
+
|
||||
+ private static @Nullable Set<ServerPlayer> getWatchPlayerList(@NotNull Entity entity) {
|
||||
+ return entityWatchPlayerSet.get(getResourceLocationEntityPair(entity.level().dimension().location(), entity));
|
||||
+ }
|
||||
+
|
||||
+ private static @Nullable Set<ServerPlayer> getWatchPlayerList(@NotNull Level world, @NotNull BlockPos blockPos) {
|
||||
+ return blockPosWatchPlayerSet.get(getResourceLocationBlockPosPair(world.dimension().location(), blockPos));
|
||||
+ }
|
||||
+
|
||||
+ public static boolean syncEntityToClient(@NotNull Entity entity) {
|
||||
+ if (entity.level().isClientSide()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ lock.lock();
|
||||
+ Set<ServerPlayer> playerList = getWatchPlayerList(entity);
|
||||
+ boolean ret = false;
|
||||
+ if (playerList != null) {
|
||||
+ for (ServerPlayer player : playerList) {
|
||||
+ updateEntity(player, entity);
|
||||
+ ret = true;
|
||||
+ }
|
||||
+ }
|
||||
+ lock.unlock();
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ public static boolean syncBlockEntityToClient(@NotNull BlockEntity blockEntity) {
|
||||
+ boolean ret = false;
|
||||
+ Level world = blockEntity.getLevel();
|
||||
+ BlockPos pos = blockEntity.getBlockPos();
|
||||
+ if (world != null) {
|
||||
+ if (world.isClientSide()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ BlockState blockState = world.getBlockState(pos);
|
||||
+ lock.lock();
|
||||
+ Set<ServerPlayer> playerList = getWatchPlayerList(world, blockEntity.getBlockPos());
|
||||
+
|
||||
+ Set<ServerPlayer> playerListAdj = null;
|
||||
+
|
||||
+ if (blockState.getBlock() instanceof ChestBlock) {
|
||||
+ if (blockState.getValue(ChestBlock.TYPE) != ChestType.SINGLE) {
|
||||
+ BlockPos posAdj = pos.offset(ChestBlock.getConnectedDirection(blockState).getNormal());
|
||||
+ playerListAdj = getWatchPlayerList(world, posAdj);
|
||||
+ }
|
||||
+ }
|
||||
+ if (playerListAdj != null) {
|
||||
+ if (playerList == null) {
|
||||
+ playerList = playerListAdj;
|
||||
+ } else {
|
||||
+ playerList.addAll(playerListAdj);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (playerList != null) {
|
||||
+ for (ServerPlayer player : playerList) {
|
||||
+ updateBlockEntity(player, blockEntity);
|
||||
+ ret = true;
|
||||
+ }
|
||||
+ }
|
||||
+ lock.unlock();
|
||||
+ }
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ private static void clearPlayerWatchEntity(ServerPlayer player) {
|
||||
+ lock.lock();
|
||||
+ Pair<ResourceLocation, Entity> pair = playerWatchEntity.get(player);
|
||||
+ if (pair != null) {
|
||||
+ Set<ServerPlayer> playerSet = entityWatchPlayerSet.get(pair);
|
||||
+ playerSet.remove(player);
|
||||
+ if (playerSet.isEmpty()) {
|
||||
+ entityWatchPlayerSet.remove(pair);
|
||||
+ }
|
||||
+ playerWatchEntity.remove(player);
|
||||
+ }
|
||||
+ lock.unlock();
|
||||
+ }
|
||||
+
|
||||
+ private static void clearPlayerWatchBlock(ServerPlayer player) {
|
||||
+ lock.lock();
|
||||
+ Pair<ResourceLocation, BlockPos> pair = playerWatchBlockPos.get(player);
|
||||
+ if (pair != null) {
|
||||
+ Set<ServerPlayer> playerSet = blockPosWatchPlayerSet.get(pair);
|
||||
+ playerSet.remove(player);
|
||||
+ if (playerSet.isEmpty()) {
|
||||
+ blockPosWatchPlayerSet.remove(pair);
|
||||
+ }
|
||||
+ playerWatchBlockPos.remove(player);
|
||||
+ }
|
||||
+ lock.unlock();
|
||||
+ }
|
||||
+
|
||||
+ public static void disablePcaSyncProtocolGlobal() {
|
||||
+ lock.lock();
|
||||
+ playerWatchBlockPos.clear();
|
||||
+ playerWatchEntity.clear();
|
||||
+ blockPosWatchPlayerSet.clear();
|
||||
+ entityWatchPlayerSet.clear();
|
||||
+ lock.unlock();
|
||||
+ for (ServerPlayer player : MinecraftServer.getServer().getPlayerList().getPlayers()) {
|
||||
+ disablePcaSyncProtocol(player);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void enablePcaSyncProtocolGlobal() {
|
||||
+ for (ServerPlayer player : MinecraftServer.getServer().getPlayerList().getPlayers()) {
|
||||
+ enablePcaSyncProtocol(player);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static void clearPlayerWatchData(ServerPlayer player) {
|
||||
+ PcaSyncProtocol.clearPlayerWatchBlock(player);
|
||||
+ PcaSyncProtocol.clearPlayerWatchEntity(player);
|
||||
+ }
|
||||
+
|
||||
+ public record SyncBlockEntityPayload(BlockPos pos) implements CustomPacketPayload {
|
||||
+
|
||||
+ public static final ResourceLocation SYNC_BLOCK_ENTITY = PcaSyncProtocol.id("sync_block_entity");
|
||||
+
|
||||
+ public SyncBlockEntityPayload(ResourceLocation id, FriendlyByteBuf buf) {
|
||||
+ this(buf.readBlockPos());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void write(FriendlyByteBuf buf) {
|
||||
+ buf.writeBlockPos(pos);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull ResourceLocation id() {
|
||||
+ return SYNC_BLOCK_ENTITY;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public record SyncEntityPayload(int entityId) implements CustomPacketPayload {
|
||||
+
|
||||
+ public static final ResourceLocation SYNC_ENTITY = PcaSyncProtocol.id("sync_entity");
|
||||
+
|
||||
+ public SyncEntityPayload(ResourceLocation id, FriendlyByteBuf buf) {
|
||||
+ this(buf.readInt());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void write(FriendlyByteBuf buf) {
|
||||
+ buf.writeInt(entityId);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull ResourceLocation id() {
|
||||
+ return SYNC_ENTITY;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
183
patches/server/0046-Leaves-Bladeren-protocol.patch
Normal file
183
patches/server/0046-Leaves-Bladeren-protocol.patch
Normal file
@@ -0,0 +1,183 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Thu, 21 Dec 2023 19:50:41 +0800
|
||||
Subject: [PATCH] Leaves Bladeren protocol
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index cfe9a8eb705039ee7e2dc9262e1355c4b0f664bb..a0fd4fec133617893487586fd52e3a3a864871b4 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -68,6 +68,7 @@ public class LuminolConfig {
|
||||
|
||||
public static boolean pcaSyncProtocol = false;
|
||||
public static String pcaSyncPlayerEntity = "NOBODY";
|
||||
+ public static boolean bladerenLeavesProtocol = false;
|
||||
|
||||
|
||||
public static void init() throws IOException {
|
||||
@@ -201,6 +202,7 @@ public class LuminolConfig {
|
||||
|
||||
pcaSyncProtocol = get("gameplay.enable_pca_sync_protocol",pcaSyncProtocol);
|
||||
pcaSyncPlayerEntity = get("gameplay.pca_sync_player_entity",pcaSyncPlayerEntity,"Available values: NOBODY,EVERYBODY,OPS,OPS_AND_SELF");
|
||||
+ bladerenLeavesProtocol = get("gameplay.bladeren_leaves_protocol",bladerenLeavesProtocol);
|
||||
}
|
||||
|
||||
public static <T> T get(String key,T def){
|
||||
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..cf344ad5e928f1bf23953d7b25c4636734da69e6
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/bladeren/BladerenProtocol.java
|
||||
@@ -0,0 +1,151 @@
|
||||
+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 me.earthme.luminol.LuminolConfig;
|
||||
+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 (LuminolConfig.bladerenLeavesProtocol) {
|
||||
+ 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 (LuminolConfig.bladerenLeavesProtocol) {
|
||||
+ 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 (LuminolConfig.bladerenLeavesProtocol) {
|
||||
+ 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;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
@@ -1,192 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Fri, 9 Feb 2024 23:43:16 +0000
|
||||
Subject: [PATCH] Gale Optimize world generation chunk and block access
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/util/Pos.java b/src/main/java/me/jellysquid/mods/lithium/common/util/Pos.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..f2f10b651e4fbecdd1ea1bc28ebf40d685a67cee
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/jellysquid/mods/lithium/common/util/Pos.java
|
||||
@@ -0,0 +1,95 @@
|
||||
+// Gale - Lithium - position utility
|
||||
+
|
||||
+package me.jellysquid.mods.lithium.common.util;
|
||||
+
|
||||
+import net.minecraft.core.SectionPos;
|
||||
+import net.minecraft.world.level.LevelHeightAccessor;
|
||||
+
|
||||
+public class Pos {
|
||||
+
|
||||
+ public static class BlockCoord {
|
||||
+ public static int getYSize(LevelHeightAccessor view) {
|
||||
+ return view.getHeight();
|
||||
+ }
|
||||
+ public static int getMinY(LevelHeightAccessor view) {
|
||||
+ return view.getMinBuildHeight();
|
||||
+ }
|
||||
+ public static int getMaxYInclusive(LevelHeightAccessor view) {
|
||||
+ return view.getMaxBuildHeight() - 1;
|
||||
+ }
|
||||
+ public static int getMaxYExclusive(LevelHeightAccessor view) {
|
||||
+ return view.getMaxBuildHeight();
|
||||
+ }
|
||||
+
|
||||
+ public static int getMaxInSectionCoord(int sectionCoord) {
|
||||
+ return 15 + getMinInSectionCoord(sectionCoord);
|
||||
+ }
|
||||
+
|
||||
+ public static int getMaxYInSectionIndex(LevelHeightAccessor view, int sectionIndex){
|
||||
+ return getMaxInSectionCoord(SectionYCoord.fromSectionIndex(view, sectionIndex));
|
||||
+ }
|
||||
+
|
||||
+ public static int getMinInSectionCoord(int sectionCoord) {
|
||||
+ return SectionPos.sectionToBlockCoord(sectionCoord);
|
||||
+ }
|
||||
+
|
||||
+ public static int getMinYInSectionIndex(LevelHeightAccessor view, int sectionIndex) {
|
||||
+ return getMinInSectionCoord(SectionYCoord.fromSectionIndex(view, sectionIndex));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static class ChunkCoord {
|
||||
+ public static int fromBlockCoord(int blockCoord) {
|
||||
+ return SectionPos.blockToSectionCoord(blockCoord);
|
||||
+ }
|
||||
+
|
||||
+ public static int fromBlockSize(int i) {
|
||||
+ return i >> 4; //same method as fromBlockCoord, just be clear about coord/size semantic difference
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static class SectionYCoord {
|
||||
+ public static int getNumYSections(LevelHeightAccessor view) {
|
||||
+ return view.getSectionsCount();
|
||||
+ }
|
||||
+ public static int getMinYSection(LevelHeightAccessor view) {
|
||||
+ return view.getMinSection();
|
||||
+ }
|
||||
+ public static int getMaxYSectionInclusive(LevelHeightAccessor view) {
|
||||
+ return view.getMaxSection() - 1;
|
||||
+ }
|
||||
+ public static int getMaxYSectionExclusive(LevelHeightAccessor view) {
|
||||
+ return view.getMaxSection();
|
||||
+ }
|
||||
+
|
||||
+ public static int fromSectionIndex(LevelHeightAccessor view, int sectionCoord) {
|
||||
+ return sectionCoord + SectionYCoord.getMinYSection(view);
|
||||
+ }
|
||||
+ public static int fromBlockCoord(int blockCoord) {
|
||||
+ return SectionPos.blockToSectionCoord(blockCoord);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static class SectionYIndex {
|
||||
+ public static int getNumYSections(LevelHeightAccessor view) {
|
||||
+ return view.getSectionsCount();
|
||||
+ }
|
||||
+ public static int getMinYSectionIndex(LevelHeightAccessor view) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+ public static int getMaxYSectionIndexInclusive(LevelHeightAccessor view) {
|
||||
+ return view.getSectionsCount() - 1;
|
||||
+ }
|
||||
+ public static int getMaxYSectionIndexExclusive(LevelHeightAccessor view) {
|
||||
+ return view.getSectionsCount();
|
||||
+ }
|
||||
+
|
||||
+ public static int fromSectionCoord(LevelHeightAccessor view, int sectionCoord) {
|
||||
+ return sectionCoord - SectionYCoord.getMinYSection(view);
|
||||
+ }
|
||||
+ public static int fromBlockCoord(LevelHeightAccessor view, int blockCoord) {
|
||||
+ return fromSectionCoord(view, SectionPos.blockToSectionCoord(blockCoord));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
|
||||
index 33c1ef45ed620f8424c2c83dd30b674892ddffe3..60db67956d8455d02c7b315cbdcb952206d776db 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
|
||||
@@ -8,6 +8,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -83,6 +84,10 @@ public class WorldGenRegion implements WorldGenLevel {
|
||||
private Supplier<String> currentlyGenerating;
|
||||
private final AtomicLong subTickCount = new AtomicLong();
|
||||
private static final ResourceLocation WORLDGEN_REGION_RANDOM = new ResourceLocation("worldgen_region_random");
|
||||
+ // Gale start - Lithium - optimize world generation chunk and block access
|
||||
+ private ChunkAccess[] chunksArr;
|
||||
+ private int minChunkX, minChunkZ;
|
||||
+ // Gale end - Lithium - optimize world generation chunk and block access
|
||||
|
||||
// Folia start - region threading
|
||||
@Override
|
||||
@@ -112,6 +117,11 @@ public class WorldGenRegion implements WorldGenLevel {
|
||||
this.lastPos = ((ChunkAccess) chunks.get(chunks.size() - 1)).getPos();
|
||||
this.structureManager = world.structureManager().forWorldGenRegion(this);
|
||||
}
|
||||
+ // Gale start - Lithium - optimize world generation chunk and block access
|
||||
+ this.minChunkX = this.firstPos.x;
|
||||
+ this.minChunkZ = this.firstPos.z;
|
||||
+ this.chunksArr = chunks.toArray(new ChunkAccess[0]);
|
||||
+ // Gale end - Lithium - optimize world generation chunk and block access
|
||||
}
|
||||
|
||||
// Paper start - starlight
|
||||
@@ -150,9 +160,29 @@ public class WorldGenRegion implements WorldGenLevel {
|
||||
|
||||
@Override
|
||||
public ChunkAccess getChunk(int chunkX, int chunkZ) {
|
||||
- return this.getChunk(chunkX, chunkZ, ChunkStatus.EMPTY);
|
||||
+ // Gale start - Lithium - optimize world generation chunk and block access - use the chunk array for faster access
|
||||
+ int x = chunkX - this.minChunkX;
|
||||
+ int z = chunkZ - this.minChunkZ;
|
||||
+ int w = this.size;
|
||||
+
|
||||
+ if (x >= 0 && z >= 0 && x < w && z < w) {
|
||||
+ return this.chunksArr[x + z * w];
|
||||
+ } else {
|
||||
+ throw new NullPointerException("No chunk exists at " + new ChunkPos(chunkX, chunkZ));
|
||||
+ }
|
||||
+ // Gale end - Lithium - optimize world generation chunk and block access - use the chunk array for faster access
|
||||
}
|
||||
|
||||
+ // Gale start - Lithium - optimize world generation chunk and block access
|
||||
+ /**
|
||||
+ * Use our chunk fetch function
|
||||
+ */
|
||||
+ public ChunkAccess getChunk(BlockPos pos) {
|
||||
+ // Skip checking chunk.getStatus().isAtLeast(ChunkStatus.EMPTY) here, because it is always true
|
||||
+ return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ()));
|
||||
+ }
|
||||
+ // Gale end - Lithium - optimize world generation chunk and block access
|
||||
+
|
||||
@Nullable
|
||||
@Override
|
||||
public ChunkAccess getChunk(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) {
|
||||
@@ -210,7 +240,17 @@ public class WorldGenRegion implements WorldGenLevel {
|
||||
|
||||
@Override
|
||||
public BlockState getBlockState(BlockPos pos) {
|
||||
- return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())).getBlockState(pos);
|
||||
+ // Gale start - Lithium - optimize world generation chunk and block access - avoid pointer de-referencing, make method easier to inline
|
||||
+ int x = SectionPos.blockToSectionCoord(pos.getX()) - this.minChunkX;
|
||||
+ int z = SectionPos.blockToSectionCoord(pos.getZ()) - this.minChunkZ;
|
||||
+ int w = this.size;
|
||||
+
|
||||
+ if (x >= 0 && z >= 0 && x < w && z < w) {
|
||||
+ return this.chunksArr[x + z * w].getBlockState(pos);
|
||||
+ } else {
|
||||
+ throw new NullPointerException("No chunk exists at " + new ChunkPos(pos));
|
||||
+ }
|
||||
+ // Gale end - Lithium - optimize world generation chunk and block access - avoid pointer de-referencing, make method easier to inline
|
||||
}
|
||||
|
||||
@Override
|
||||
126
patches/server/0047-Leaves-Bladeren-mspt-sync-protocol.patch
Normal file
126
patches/server/0047-Leaves-Bladeren-mspt-sync-protocol.patch
Normal file
@@ -0,0 +1,126 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Thu, 21 Dec 2023 20:06:50 +0800
|
||||
Subject: [PATCH] Leaves Bladeren mspt sync protocol
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index a0fd4fec133617893487586fd52e3a3a864871b4..d19f423debbeaedf955977c02aaf5f8e0016bea3 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -69,6 +69,9 @@ public class LuminolConfig {
|
||||
public static boolean pcaSyncProtocol = false;
|
||||
public static String pcaSyncPlayerEntity = "NOBODY";
|
||||
public static boolean bladerenLeavesProtocol = false;
|
||||
+ public static boolean msptSyncProtocol = false;
|
||||
+ public static int msptSyncTickInterval = 20;
|
||||
+
|
||||
|
||||
|
||||
public static void init() throws IOException {
|
||||
@@ -203,6 +206,8 @@ public class LuminolConfig {
|
||||
pcaSyncProtocol = get("gameplay.enable_pca_sync_protocol",pcaSyncProtocol);
|
||||
pcaSyncPlayerEntity = get("gameplay.pca_sync_player_entity",pcaSyncPlayerEntity,"Available values: NOBODY,EVERYBODY,OPS,OPS_AND_SELF");
|
||||
bladerenLeavesProtocol = get("gameplay.bladeren_leaves_protocol",bladerenLeavesProtocol);
|
||||
+ msptSyncProtocol = get("gameplay.bladeren_mspt_sync_protocol",bladerenLeavesProtocol);
|
||||
+ msptSyncTickInterval = get("gameplay.bladeren_mspt_sync_interval",msptSyncTickInterval);
|
||||
}
|
||||
|
||||
public static <T> T get(String key,T def){
|
||||
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..de92ebdf9d51a4f9a58a7650b09f070e51710ef0
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java
|
||||
@@ -0,0 +1,91 @@
|
||||
+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 me.earthme.luminol.LuminolConfig;
|
||||
+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 (LuminolConfig.msptSyncProtocol) {
|
||||
+ players.remove(player);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @ProtocolHandler.Ticker
|
||||
+ public static void tick() {
|
||||
+ if (LuminolConfig.msptSyncProtocol) {
|
||||
+ if (players.isEmpty()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (tickCounter++ % LuminolConfig.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 (LuminolConfig.msptSyncProtocol) {
|
||||
+ players.add(player);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
@@ -1,239 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Fri, 9 Feb 2024 23:44:23 +0000
|
||||
Subject: [PATCH] Gale Optimize noise generation
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java b/src/main/java/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java
|
||||
index fb84d703b4461343d50510d7c9be32fc1f09ed22..93a11c95f96f975fafe03e77a2caace57675d130 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java
|
||||
@@ -11,6 +11,27 @@ public final class ImprovedNoise {
|
||||
public final double yo;
|
||||
public final double zo;
|
||||
|
||||
+ // Gale start - C2ME - optimize noise generation
|
||||
+ private static final double[] FLAT_SIMPLEX_GRAD = new double[]{
|
||||
+ 1, 1, 0, 0,
|
||||
+ -1, 1, 0, 0,
|
||||
+ 1, -1, 0, 0,
|
||||
+ -1, -1, 0, 0,
|
||||
+ 1, 0, 1, 0,
|
||||
+ -1, 0, 1, 0,
|
||||
+ 1, 0, -1, 0,
|
||||
+ -1, 0, -1, 0,
|
||||
+ 0, 1, 1, 0,
|
||||
+ 0, -1, 1, 0,
|
||||
+ 0, 1, -1, 0,
|
||||
+ 0, -1, -1, 0,
|
||||
+ 1, 1, 0, 0,
|
||||
+ 0, -1, 1, 0,
|
||||
+ -1, 1, 0, 0,
|
||||
+ 0, -1, -1, 0,
|
||||
+ };
|
||||
+ // Gale end - C2ME - optimize noise generation
|
||||
+
|
||||
public ImprovedNoise(RandomSource random) {
|
||||
this.xo = random.nextDouble() * 256.0D;
|
||||
this.yo = random.nextDouble() * 256.0D;
|
||||
@@ -40,12 +61,14 @@ public final class ImprovedNoise {
|
||||
double d = x + this.xo;
|
||||
double e = y + this.yo;
|
||||
double f = z + this.zo;
|
||||
- int i = Mth.floor(d);
|
||||
- int j = Mth.floor(e);
|
||||
- int k = Mth.floor(f);
|
||||
- double g = d - (double)i;
|
||||
- double h = e - (double)j;
|
||||
- double l = f - (double)k;
|
||||
+ // Gale start - C2ME - optimize noise generation - optimize: remove frequent type conversions
|
||||
+ double i = Math.floor(d);
|
||||
+ double j = Math.floor(e);
|
||||
+ double k = Math.floor(f);
|
||||
+ double g = d - i;
|
||||
+ double h = e - j;
|
||||
+ double l = f - k;
|
||||
+ // Gale end - C2ME - optimize noise generation - optimize: remove frequent type conversions
|
||||
double o;
|
||||
if (yScale != 0.0D) {
|
||||
double m;
|
||||
@@ -55,25 +78,27 @@ public final class ImprovedNoise {
|
||||
m = h;
|
||||
}
|
||||
|
||||
- o = (double)Mth.floor(m / yScale + (double)1.0E-7F) * yScale;
|
||||
+ o = Math.floor(m / yScale + (double)1.0E-7F) * yScale; // Gale - C2ME - optimize noise generation - optimize: remove frequent type conversions
|
||||
} else {
|
||||
o = 0.0D;
|
||||
}
|
||||
|
||||
- return this.sampleAndLerp(i, j, k, g, h - o, l, h);
|
||||
+ return this.sampleAndLerp((int) i, (int) j, (int) k, g, h - o, l, h); // Gale - C2ME - optimize noise generation - optimize: remove frequent type conversions
|
||||
}
|
||||
|
||||
public double noiseWithDerivative(double x, double y, double z, double[] ds) {
|
||||
double d = x + this.xo;
|
||||
double e = y + this.yo;
|
||||
double f = z + this.zo;
|
||||
- int i = Mth.floor(d);
|
||||
- int j = Mth.floor(e);
|
||||
- int k = Mth.floor(f);
|
||||
- double g = d - (double)i;
|
||||
- double h = e - (double)j;
|
||||
- double l = f - (double)k;
|
||||
- return this.sampleWithDerivative(i, j, k, g, h, l, ds);
|
||||
+ // Gale start - C2ME - optimize noise generation - optimize: remove frequent type conversions
|
||||
+ double i = Math.floor(d);
|
||||
+ double j = Math.floor(e);
|
||||
+ double k = Math.floor(f);
|
||||
+ double g = d - i;
|
||||
+ double h = e - j;
|
||||
+ double l = f - k;
|
||||
+ return this.sampleWithDerivative((int) i, (int) j, (int) k, g, h, l, ds);
|
||||
+ // Gale end - C2ME - optimize noise generation - optimize: remove frequent type conversions
|
||||
}
|
||||
|
||||
private static double gradDot(int hash, double x, double y, double z) {
|
||||
@@ -85,24 +110,69 @@ public final class ImprovedNoise {
|
||||
}
|
||||
|
||||
private double sampleAndLerp(int sectionX, int sectionY, int sectionZ, double localX, double localY, double localZ, double fadeLocalY) {
|
||||
- int i = this.p(sectionX);
|
||||
- int j = this.p(sectionX + 1);
|
||||
- int k = this.p(i + sectionY);
|
||||
- int l = this.p(i + sectionY + 1);
|
||||
- int m = this.p(j + sectionY);
|
||||
- int n = this.p(j + sectionY + 1);
|
||||
- double d = gradDot(this.p(k + sectionZ), localX, localY, localZ);
|
||||
- double e = gradDot(this.p(m + sectionZ), localX - 1.0D, localY, localZ);
|
||||
- double f = gradDot(this.p(l + sectionZ), localX, localY - 1.0D, localZ);
|
||||
- double g = gradDot(this.p(n + sectionZ), localX - 1.0D, localY - 1.0D, localZ);
|
||||
- double h = gradDot(this.p(k + sectionZ + 1), localX, localY, localZ - 1.0D);
|
||||
- double o = gradDot(this.p(m + sectionZ + 1), localX - 1.0D, localY, localZ - 1.0D);
|
||||
- double p = gradDot(this.p(l + sectionZ + 1), localX, localY - 1.0D, localZ - 1.0D);
|
||||
- double q = gradDot(this.p(n + sectionZ + 1), localX - 1.0D, localY - 1.0D, localZ - 1.0D);
|
||||
- double r = Mth.smoothstep(localX);
|
||||
- double s = Mth.smoothstep(fadeLocalY);
|
||||
- double t = Mth.smoothstep(localZ);
|
||||
- return Mth.lerp3(r, s, t, d, e, f, g, h, o, p, q);
|
||||
+ // Gale start - C2ME - optimize noise generation - inline math & small optimization: remove frequent type conversions and redundant ops
|
||||
+ final int var0 = sectionX & 0xFF;
|
||||
+ final int var1 = (sectionX + 1) & 0xFF;
|
||||
+ final int var2 = this.p[var0] & 0xFF;
|
||||
+ final int var3 = this.p[var1] & 0xFF;
|
||||
+ final int var4 = (var2 + sectionY) & 0xFF;
|
||||
+ final int var5 = (var3 + sectionY) & 0xFF;
|
||||
+ final int var6 = (var2 + sectionY + 1) & 0xFF;
|
||||
+ final int var7 = (var3 + sectionY + 1) & 0xFF;
|
||||
+ final int var8 = this.p[var4] & 0xFF;
|
||||
+ final int var9 = this.p[var5] & 0xFF;
|
||||
+ final int var10 = this.p[var6] & 0xFF;
|
||||
+ final int var11 = this.p[var7] & 0xFF;
|
||||
+
|
||||
+ final int var12 = (var8 + sectionZ) & 0xFF;
|
||||
+ final int var13 = (var9 + sectionZ) & 0xFF;
|
||||
+ final int var14 = (var10 + sectionZ) & 0xFF;
|
||||
+ final int var15 = (var11 + sectionZ) & 0xFF;
|
||||
+ final int var16 = (var8 + sectionZ + 1) & 0xFF;
|
||||
+ final int var17 = (var9 + sectionZ + 1) & 0xFF;
|
||||
+ final int var18 = (var10 + sectionZ + 1) & 0xFF;
|
||||
+ final int var19 = (var11 + sectionZ + 1) & 0xFF;
|
||||
+ final int var20 = (this.p[var12] & 15) << 2;
|
||||
+ final int var21 = (this.p[var13] & 15) << 2;
|
||||
+ final int var22 = (this.p[var14] & 15) << 2;
|
||||
+ final int var23 = (this.p[var15] & 15) << 2;
|
||||
+ final int var24 = (this.p[var16] & 15) << 2;
|
||||
+ final int var25 = (this.p[var17] & 15) << 2;
|
||||
+ final int var26 = (this.p[var18] & 15) << 2;
|
||||
+ final int var27 = (this.p[var19] & 15) << 2;
|
||||
+ final double var60 = localX - 1.0;
|
||||
+ final double var61 = localY - 1.0;
|
||||
+ final double var62 = localZ - 1.0;
|
||||
+ final double var87 = FLAT_SIMPLEX_GRAD[(var20) | 0] * localX + FLAT_SIMPLEX_GRAD[(var20) | 1] * localY + FLAT_SIMPLEX_GRAD[(var20) | 2] * localZ;
|
||||
+ final double var88 = FLAT_SIMPLEX_GRAD[(var21) | 0] * var60 + FLAT_SIMPLEX_GRAD[(var21) | 1] * localY + FLAT_SIMPLEX_GRAD[(var21) | 2] * localZ;
|
||||
+ final double var89 = FLAT_SIMPLEX_GRAD[(var22) | 0] * localX + FLAT_SIMPLEX_GRAD[(var22) | 1] * var61 + FLAT_SIMPLEX_GRAD[(var22) | 2] * localZ;
|
||||
+ final double var90 = FLAT_SIMPLEX_GRAD[(var23) | 0] * var60 + FLAT_SIMPLEX_GRAD[(var23) | 1] * var61 + FLAT_SIMPLEX_GRAD[(var23) | 2] * localZ;
|
||||
+ final double var91 = FLAT_SIMPLEX_GRAD[(var24) | 0] * localX + FLAT_SIMPLEX_GRAD[(var24) | 1] * localY + FLAT_SIMPLEX_GRAD[(var24) | 2] * var62;
|
||||
+ final double var92 = FLAT_SIMPLEX_GRAD[(var25) | 0] * var60 + FLAT_SIMPLEX_GRAD[(var25) | 1] * localY + FLAT_SIMPLEX_GRAD[(var25) | 2] * var62;
|
||||
+ final double var93 = FLAT_SIMPLEX_GRAD[(var26) | 0] * localX + FLAT_SIMPLEX_GRAD[(var26) | 1] * var61 + FLAT_SIMPLEX_GRAD[(var26) | 2] * var62;
|
||||
+ final double var94 = FLAT_SIMPLEX_GRAD[(var27) | 0] * var60 + FLAT_SIMPLEX_GRAD[(var27) | 1] * var61 + FLAT_SIMPLEX_GRAD[(var27) | 2] * var62;
|
||||
+
|
||||
+ final double var95 = localX * 6.0 - 15.0;
|
||||
+ final double var96 = fadeLocalY * 6.0 - 15.0;
|
||||
+ final double var97 = localZ * 6.0 - 15.0;
|
||||
+ final double var98 = localX * var95 + 10.0;
|
||||
+ final double var99 = fadeLocalY * var96 + 10.0;
|
||||
+ final double var100 = localZ * var97 + 10.0;
|
||||
+ final double var101 = localX * localX * localX * var98;
|
||||
+ final double var102 = fadeLocalY * fadeLocalY * fadeLocalY * var99;
|
||||
+ final double var103 = localZ * localZ * localZ * var100;
|
||||
+
|
||||
+ final double var113 = var87 + var101 * (var88 - var87);
|
||||
+ final double var114 = var93 + var101 * (var94 - var93);
|
||||
+ final double var115 = var91 + var101 * (var92 - var91);
|
||||
+ final double var116 = var89 + var101 * (var90 - var89);
|
||||
+ final double var117 = var114 - var115;
|
||||
+ final double var118 = var102 * (var116 - var113);
|
||||
+ final double var119 = var102 * var117;
|
||||
+ final double var120 = var113 + var118;
|
||||
+ final double var121 = var115 + var119;
|
||||
+ return var120 + (var103 * (var121 - var120));
|
||||
+ // Gale end - C2ME - optimize noise generation - inline math & small optimization: remove frequent type conversions and redundant ops
|
||||
}
|
||||
|
||||
private double sampleWithDerivative(int sectionX, int sectionY, int sectionZ, double localX, double localY, double localZ, double[] ds) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinNoise.java b/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinNoise.java
|
||||
index 97ef7288ea935f3d17c5b7a9eba642143c786c2b..6d084145f8529fa8b0439123f9a9812940cc62da 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinNoise.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinNoise.java
|
||||
@@ -26,6 +26,10 @@ public class PerlinNoise {
|
||||
private final double lowestFreqValueFactor;
|
||||
private final double lowestFreqInputFactor;
|
||||
private final double maxValue;
|
||||
+ // Gale start - C2ME - optimize noise generation
|
||||
+ private final int octaveSamplersCount;
|
||||
+ private final double [] amplitudesArray;
|
||||
+ // Gale end - C2ME - optimize noise generation
|
||||
|
||||
/** @deprecated */
|
||||
@Deprecated
|
||||
@@ -131,6 +135,10 @@ public class PerlinNoise {
|
||||
this.lowestFreqInputFactor = Math.pow(2.0D, (double)(-j));
|
||||
this.lowestFreqValueFactor = Math.pow(2.0D, (double)(i - 1)) / (Math.pow(2.0D, (double)i) - 1.0D);
|
||||
this.maxValue = this.edgeValue(2.0D);
|
||||
+ // Gale start - C2ME - optimize noise generation
|
||||
+ this.octaveSamplersCount = this.noiseLevels.length;
|
||||
+ this.amplitudesArray = this.amplitudes.toDoubleArray();
|
||||
+ // Gale end - C2ME - optimize noise generation
|
||||
}
|
||||
|
||||
protected double maxValue() {
|
||||
@@ -142,7 +150,27 @@ public class PerlinNoise {
|
||||
}
|
||||
|
||||
public double getValue(double x, double y, double z) {
|
||||
- return this.getValue(x, y, z, 0.0D, 0.0D, false);
|
||||
+ // Gale start - C2ME - optimize noise generation - optimize for common cases
|
||||
+ double d = 0.0;
|
||||
+ double e = this.lowestFreqInputFactor;
|
||||
+ double f = this.lowestFreqValueFactor;
|
||||
+
|
||||
+ for(int i = 0; i < this.octaveSamplersCount; ++i) {
|
||||
+ ImprovedNoise perlinNoiseSampler = this.noiseLevels[i];
|
||||
+ if (perlinNoiseSampler != null) {
|
||||
+ @SuppressWarnings("deprecation")
|
||||
+ double g = perlinNoiseSampler.noise(
|
||||
+ wrap(x * e), wrap(y * e), wrap(z * e), 0.0, 0.0
|
||||
+ );
|
||||
+ d += this.amplitudesArray[i] * g * f;
|
||||
+ }
|
||||
+
|
||||
+ e *= 2.0;
|
||||
+ f /= 2.0;
|
||||
+ }
|
||||
+
|
||||
+ return d;
|
||||
+ // Gale end - C2ME - optimize noise generation - optimize for common cases
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
2044
patches/server/0048-Leaves-Syncmatica-Protocol.patch
Normal file
2044
patches/server/0048-Leaves-Syncmatica-Protocol.patch
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,74 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Mon, 8 Jan 2024 12:19:29 +0000
|
||||
Subject: [PATCH] Do not process any packet if the leaves protocol supports are
|
||||
disabled
|
||||
|
||||
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/PcaSyncProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/PcaSyncProtocol.java
|
||||
index ebd28033ddf0fe6a354585dc2818a9b481d90ed4..33c7221a1f33cdb81dfac92fc3332f92cf3cd2d9 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/protocol/PcaSyncProtocol.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/PcaSyncProtocol.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package top.leavesmc.leaves.protocol;
|
||||
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java
|
||||
index de92ebdf9d51a4f9a58a7650b09f070e51710ef0..b309963dcf41f16a7b53e4cc2816975523ccba55 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java
|
||||
@@ -35,6 +35,9 @@ public class MsptSyncProtocol {
|
||||
|
||||
@ProtocolHandler.Init
|
||||
public static void init() {
|
||||
+ if (!LuminolConfig.msptSyncProtocol){
|
||||
+ return;
|
||||
+ }
|
||||
BladerenProtocol.registerFeature("mspt_sync", (player, compoundTag) -> {
|
||||
if (compoundTag.getString("Value").equals("true")) {
|
||||
onPlayerSubmit(player);
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java
|
||||
index fc229f23076147304754a267bcc345cc836b648b..6325f6441e28d915514e6b0ee9b450610e99b2c2 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java
|
||||
@@ -2,6 +2,7 @@ package top.leavesmc.leaves.protocol.syncmatica;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import io.netty.buffer.Unpooled;
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -68,6 +69,9 @@ public class CommunicationManager {
|
||||
|
||||
@ProtocolHandler.PlayerJoin
|
||||
public static void onPlayerJoin(ServerPlayer player) {
|
||||
+ if (!LuminolConfig.syncmaticaProtocol){
|
||||
+ return;
|
||||
+ }
|
||||
final ExchangeTarget newPlayer = player.connection.exchangeTarget;
|
||||
final VersionHandshakeServer hi = new VersionHandshakeServer(newPlayer);
|
||||
playerMap.put(newPlayer, player);
|
||||
@@ -78,6 +82,9 @@ public class CommunicationManager {
|
||||
|
||||
@ProtocolHandler.PlayerLeave
|
||||
public static void onPlayerLeave(ServerPlayer player) {
|
||||
+ if (!LuminolConfig.syncmaticaProtocol){
|
||||
+ return;
|
||||
+ }
|
||||
final ExchangeTarget oldPlayer = player.connection.exchangeTarget;
|
||||
final Collection<Exchange> potentialMessageTarget = oldPlayer.getExchanges();
|
||||
if (potentialMessageTarget != null) {
|
||||
@@ -92,6 +99,9 @@ public class CommunicationManager {
|
||||
|
||||
@ProtocolHandler.PayloadReceiver(payload = LeavesProtocolManager.LeavesPayload.class, ignoreId = true)
|
||||
public static void onPacketGet(ServerPlayer player, LeavesProtocolManager.LeavesPayload payload) {
|
||||
+ if (!LuminolConfig.syncmaticaProtocol){
|
||||
+ return;
|
||||
+ }
|
||||
onPacket(player.connection.exchangeTarget, payload.id(), payload.data());
|
||||
}
|
||||
|
||||
@@ -1,434 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Tue, 20 Feb 2024 13:21:53 +0000
|
||||
Subject: [PATCH] Gale Faster chunk serialization
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/world/chunk/LithiumHashPalette.java b/src/main/java/me/jellysquid/mods/lithium/common/world/chunk/LithiumHashPalette.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..349618b7f544bf9a30e0796d4d9a26407a2b8329
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/jellysquid/mods/lithium/common/world/chunk/LithiumHashPalette.java
|
||||
@@ -0,0 +1,192 @@
|
||||
+// Gale - Lithium - faster chunk serialization
|
||||
+
|
||||
+package me.jellysquid.mods.lithium.common.world.chunk;
|
||||
+
|
||||
+import com.google.common.collect.ImmutableList;
|
||||
+import it.unimi.dsi.fastutil.HashCommon;
|
||||
+import it.unimi.dsi.fastutil.objects.Reference2IntMap;
|
||||
+import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.List;
|
||||
+import java.util.function.Predicate;
|
||||
+import net.minecraft.core.IdMap;
|
||||
+import net.minecraft.network.FriendlyByteBuf;
|
||||
+import net.minecraft.network.VarInt;
|
||||
+import net.minecraft.world.level.chunk.Palette;
|
||||
+import net.minecraft.world.level.chunk.PaletteResize;
|
||||
+
|
||||
+import static it.unimi.dsi.fastutil.Hash.FAST_LOAD_FACTOR;
|
||||
+
|
||||
+/**
|
||||
+ * Generally provides better performance over the vanilla {@link net.minecraft.world.level.chunk.HashMapPalette} when calling
|
||||
+ * {@link LithiumHashPalette#idFor(Object)} through using a faster backing map and reducing pointer chasing.
|
||||
+ */
|
||||
+public class LithiumHashPalette<T> implements Palette<T> {
|
||||
+ private static final int ABSENT_VALUE = -1;
|
||||
+
|
||||
+ private final IdMap<T> idList;
|
||||
+ private final PaletteResize<T> resizeHandler;
|
||||
+ private final int indexBits;
|
||||
+
|
||||
+ private final Reference2IntMap<T> table;
|
||||
+ private T[] entries;
|
||||
+ private int size = 0;
|
||||
+
|
||||
+ public LithiumHashPalette(IdMap<T> idList, PaletteResize<T> resizeHandler, int indexBits, T[] entries, Reference2IntMap<T> table, int size) {
|
||||
+ this.idList = idList;
|
||||
+ this.resizeHandler = resizeHandler;
|
||||
+ this.indexBits = indexBits;
|
||||
+ this.entries = entries;
|
||||
+ this.table = table;
|
||||
+ this.size = size;
|
||||
+ }
|
||||
+
|
||||
+ public LithiumHashPalette(IdMap<T> idList, int bits, PaletteResize<T> resizeHandler, List<T> list) {
|
||||
+ this(idList, bits, resizeHandler);
|
||||
+
|
||||
+ for (T t : list) {
|
||||
+ this.addEntry(t);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @SuppressWarnings("unchecked")
|
||||
+ public LithiumHashPalette(IdMap<T> idList, int bits, PaletteResize<T> resizeHandler) {
|
||||
+ this.idList = idList;
|
||||
+ this.indexBits = bits;
|
||||
+ this.resizeHandler = resizeHandler;
|
||||
+
|
||||
+ int capacity = 1 << bits;
|
||||
+
|
||||
+ this.entries = (T[]) new Object[capacity];
|
||||
+ this.table = new Reference2IntOpenHashMap<>(capacity, FAST_LOAD_FACTOR);
|
||||
+ this.table.defaultReturnValue(ABSENT_VALUE);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int idFor(T obj) {
|
||||
+ int id = this.table.getInt(obj);
|
||||
+
|
||||
+ if (id == ABSENT_VALUE) {
|
||||
+ id = this.computeEntry(obj);
|
||||
+ }
|
||||
+
|
||||
+ return id;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean maybeHas(Predicate<T> predicate) {
|
||||
+ for (int i = 0; i < this.size; ++i) {
|
||||
+ if (predicate.test(this.entries[i])) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ private int computeEntry(T obj) {
|
||||
+ int id = this.addEntry(obj);
|
||||
+
|
||||
+ if (id >= 1 << this.indexBits) {
|
||||
+ if (this.resizeHandler == null) {
|
||||
+ throw new IllegalStateException("Cannot grow");
|
||||
+ } else {
|
||||
+ id = this.resizeHandler.onResize(this.indexBits + 1, obj);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return id;
|
||||
+ }
|
||||
+
|
||||
+ private int addEntry(T obj) {
|
||||
+ int nextId = this.size;
|
||||
+
|
||||
+ if (nextId >= this.entries.length) {
|
||||
+ this.resize(this.size);
|
||||
+ }
|
||||
+
|
||||
+ this.table.put(obj, nextId);
|
||||
+ this.entries[nextId] = obj;
|
||||
+
|
||||
+ this.size++;
|
||||
+
|
||||
+ return nextId;
|
||||
+ }
|
||||
+
|
||||
+ private void resize(int neededCapacity) {
|
||||
+ this.entries = Arrays.copyOf(this.entries, HashCommon.nextPowerOfTwo(neededCapacity + 1));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public T valueFor(int id) {
|
||||
+ T[] entries = this.entries;
|
||||
+
|
||||
+ if (id >= 0 && id < entries.length) {
|
||||
+ return entries[id];
|
||||
+ }
|
||||
+
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void read(FriendlyByteBuf buf) {
|
||||
+ this.clear();
|
||||
+
|
||||
+ int entryCount = buf.readVarInt();
|
||||
+
|
||||
+ for (int i = 0; i < entryCount; ++i) {
|
||||
+ this.addEntry(this.idList.byId(buf.readVarInt()));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void write(FriendlyByteBuf buf) {
|
||||
+ int size = this.size;
|
||||
+ buf.writeVarInt(size);
|
||||
+
|
||||
+ for (int i = 0; i < size; ++i) {
|
||||
+ buf.writeVarInt(this.idList.getId(this.valueFor(i)));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getSerializedSize() {
|
||||
+ int size = VarInt.getByteSize(this.size);
|
||||
+
|
||||
+ for (int i = 0; i < this.size; ++i) {
|
||||
+ size += VarInt.getByteSize(this.idList.getId(this.valueFor(i)));
|
||||
+ }
|
||||
+
|
||||
+ return size;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getSize() {
|
||||
+ return this.size;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Palette<T> copy() {
|
||||
+ return new LithiumHashPalette<>(this.idList, this.resizeHandler, this.indexBits, this.entries.clone(), new Reference2IntOpenHashMap<>(this.table), this.size);
|
||||
+ }
|
||||
+
|
||||
+ private void clear() {
|
||||
+ Arrays.fill(this.entries, null);
|
||||
+ this.table.clear();
|
||||
+ this.size = 0;
|
||||
+ }
|
||||
+
|
||||
+ public List<T> getElements() {
|
||||
+ ImmutableList.Builder<T> builder = new ImmutableList.Builder<>();
|
||||
+ for (T entry : this.entries) {
|
||||
+ if (entry != null) {
|
||||
+ builder.add(entry);
|
||||
+ }
|
||||
+ }
|
||||
+ return builder.build();
|
||||
+ }
|
||||
+
|
||||
+ public static <A> Palette<A> create(int bits, IdMap<A> idList, PaletteResize<A> listener, List<A> list) {
|
||||
+ return new LithiumHashPalette<>(idList, bits, listener, list);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/util/BitStorage.java b/src/main/java/net/minecraft/util/BitStorage.java
|
||||
index 8bafd5fd7499ba4a04bf706cfd1e156073716e21..f62aab492f231e688b448389b1910e6fc2f5d8e6 100644
|
||||
--- a/src/main/java/net/minecraft/util/BitStorage.java
|
||||
+++ b/src/main/java/net/minecraft/util/BitStorage.java
|
||||
@@ -31,4 +31,6 @@ public interface BitStorage {
|
||||
|
||||
}
|
||||
// Paper end
|
||||
+
|
||||
+ <T> void compact(net.minecraft.world.level.chunk.Palette<T> srcPalette, net.minecraft.world.level.chunk.Palette<T> dstPalette, short[] out); // Gale - Lithium - faster chunk serialization
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/util/SimpleBitStorage.java b/src/main/java/net/minecraft/util/SimpleBitStorage.java
|
||||
index 453c1d7e01970fd817d27f59c3b00ffc70e8ca0c..844539798213360831541f49d97f8401d80d030e 100644
|
||||
--- a/src/main/java/net/minecraft/util/SimpleBitStorage.java
|
||||
+++ b/src/main/java/net/minecraft/util/SimpleBitStorage.java
|
||||
@@ -201,4 +201,45 @@ public class SimpleBitStorage implements BitStorage {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // Gale start - Lithium - faster chunk serialization
|
||||
+ @Override
|
||||
+ public <T> void compact(net.minecraft.world.level.chunk.Palette<T> srcPalette, net.minecraft.world.level.chunk.Palette<T> dstPalette, short[] out) {
|
||||
+ if (this.size >= Short.MAX_VALUE) {
|
||||
+ throw new IllegalStateException("Array too large");
|
||||
+ }
|
||||
+
|
||||
+ if (this.size != out.length) {
|
||||
+ throw new IllegalStateException("Array size mismatch");
|
||||
+ }
|
||||
+
|
||||
+ short[] mappings = new short[(int) (this.mask + 1)];
|
||||
+
|
||||
+ int idx = 0;
|
||||
+
|
||||
+ for (long word : this.data) {
|
||||
+ long bits = word;
|
||||
+
|
||||
+ for (int elementIdx = 0; elementIdx < this.valuesPerLong; ++elementIdx) {
|
||||
+ int value = (int) (bits & this.mask);
|
||||
+ int remappedId = mappings[value];
|
||||
+
|
||||
+ if (remappedId == 0) {
|
||||
+ remappedId = dstPalette.idFor(srcPalette.valueFor(value)) + 1;
|
||||
+ mappings[value] = (short) remappedId;
|
||||
+ }
|
||||
+
|
||||
+ out[idx] = (short) (remappedId - 1);
|
||||
+ bits >>= this.bits;
|
||||
+
|
||||
+ ++idx;
|
||||
+
|
||||
+ if (idx >= this.size) {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Gale end - Lithium - faster chunk serialization
|
||||
+
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/util/ZeroBitStorage.java b/src/main/java/net/minecraft/util/ZeroBitStorage.java
|
||||
index f8de91393564b3691c17339ac9196cc0fc1cf748..ecfe47110697378d7f7369640cd06b77f6fa0a87 100644
|
||||
--- a/src/main/java/net/minecraft/util/ZeroBitStorage.java
|
||||
+++ b/src/main/java/net/minecraft/util/ZeroBitStorage.java
|
||||
@@ -72,4 +72,6 @@ public class ZeroBitStorage implements BitStorage {
|
||||
public BitStorage copy() {
|
||||
return this;
|
||||
}
|
||||
+
|
||||
+ @Override public <T> void compact(net.minecraft.world.level.chunk.Palette<T> srcPalette, net.minecraft.world.level.chunk.Palette<T> dstPalette, short[] out) {} // Gale - Lithium - faster chunk serialization
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/PaletteResize.java b/src/main/java/net/minecraft/world/level/chunk/PaletteResize.java
|
||||
index acae3eb30e0689048937f479dc3070f0688abdad..4b79f0474a9013dd4fdb68c6363ca1942ba8b007 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/PaletteResize.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/PaletteResize.java
|
||||
@@ -1,5 +1,5 @@
|
||||
package net.minecraft.world.level.chunk;
|
||||
|
||||
-interface PaletteResize<T> {
|
||||
+public interface PaletteResize<T> { // Gale - Lithium - faster chunk serialization - package -> public
|
||||
int onResize(int newBits, T object);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||
index 983799520ce052d98c9231f4f7925492d4f7d5c9..6e7b3ea1819780aef6db3ff0b43998de8f1066bf 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||
@@ -25,6 +25,22 @@ import net.minecraft.util.ThreadingDetector;
|
||||
import net.minecraft.util.ZeroBitStorage;
|
||||
|
||||
public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainerRO<T> {
|
||||
+
|
||||
+ // Gale start - Lithium - faster chunk serialization
|
||||
+ private static final ThreadLocal<short[]> CACHED_ARRAY_4096 = ThreadLocal.withInitial(() -> new short[4096]);
|
||||
+ private static final ThreadLocal<short[]> CACHED_ARRAY_64 = ThreadLocal.withInitial(() -> new short[64]);
|
||||
+ private Optional<LongStream> asOptional(long[] data) {
|
||||
+ return Optional.of(Arrays.stream(data));
|
||||
+ }
|
||||
+ private short[] getOrCreate(int size) {
|
||||
+ return switch (size) {
|
||||
+ case 64 -> CACHED_ARRAY_64.get();
|
||||
+ case 4096 -> CACHED_ARRAY_4096.get();
|
||||
+ default -> new short[size];
|
||||
+ };
|
||||
+ }
|
||||
+ // Gale end - Lithium - faster chunk serialization
|
||||
+
|
||||
private static final int MIN_PALETTE_BITS = 0;
|
||||
private final PaletteResize<T> dummyPaletteResize = (newSize, added) -> {
|
||||
return 0;
|
||||
@@ -302,30 +318,54 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
||||
public synchronized PalettedContainerRO.PackedData<T> pack(IdMap<T> idList, PalettedContainer.Strategy paletteProvider) { // Paper - synchronize
|
||||
this.acquire();
|
||||
|
||||
- PalettedContainerRO.PackedData var12;
|
||||
+ // Gale start - Lithium - faster chunk serialization
|
||||
+ Optional<LongStream> data = Optional.empty();
|
||||
+ List<T> elements = null;
|
||||
try {
|
||||
- HashMapPalette<T> hashMapPalette = new HashMapPalette<>(idList, this.data.storage.getBits(), this.dummyPaletteResize);
|
||||
- int i = paletteProvider.size();
|
||||
- int[] is = new int[i];
|
||||
- this.data.storage.unpack(is);
|
||||
- swapPalette(is, (id) -> {
|
||||
- return hashMapPalette.idFor(this.data.palette.valueFor(id));
|
||||
- });
|
||||
- int j = paletteProvider.calculateBitsForSerialization(idList, hashMapPalette.getSize());
|
||||
- Optional<LongStream> optional;
|
||||
- if (j != 0) {
|
||||
- SimpleBitStorage simpleBitStorage = new SimpleBitStorage(j, i, is);
|
||||
- optional = Optional.of(Arrays.stream(simpleBitStorage.getRaw()));
|
||||
- } else {
|
||||
- optional = Optional.empty();
|
||||
+ // The palette that will be serialized
|
||||
+ me.jellysquid.mods.lithium.common.world.chunk.LithiumHashPalette<T> hashPalette = null;
|
||||
+
|
||||
+ final Palette<T> palette = this.data.palette();
|
||||
+ final BitStorage storage = this.data.storage();
|
||||
+ if (storage instanceof ZeroBitStorage || palette.getSize() == 1) {
|
||||
+ // If the palette only contains one entry, don't attempt to repack it.
|
||||
+ elements = List.of(palette.valueFor(0));
|
||||
+ } else if (palette instanceof me.jellysquid.mods.lithium.common.world.chunk.LithiumHashPalette<T> lithiumHashPalette) {
|
||||
+ hashPalette = lithiumHashPalette;
|
||||
}
|
||||
|
||||
- var12 = new PalettedContainerRO.PackedData<>(hashMapPalette.getEntries(), optional);
|
||||
+ if (elements == null) {
|
||||
+ me.jellysquid.mods.lithium.common.world.chunk.LithiumHashPalette<T> compactedPalette = new me.jellysquid.mods.lithium.common.world.chunk.LithiumHashPalette<>(idList, storage.getBits(), this.dummyPaletteResize);
|
||||
+ short[] array = this.getOrCreate(paletteProvider.size());
|
||||
+
|
||||
+ storage.compact(this.data.palette(), compactedPalette, array);
|
||||
+
|
||||
+ // If the palette didn't change during compaction, do a simple copy of the data array
|
||||
+ if (hashPalette != null && hashPalette.getSize() == compactedPalette.getSize() && storage.getBits() == paletteProvider.calculateBitsForSerialization(idList, hashPalette.getSize())) { // paletteSize can de-sync from palette - see https://github.com/CaffeineMC/lithium-fabric/issues/279
|
||||
+ data = this.asOptional(storage.getRaw().clone());
|
||||
+ elements = hashPalette.getElements();
|
||||
+ } else {
|
||||
+ int bits = paletteProvider.calculateBitsForSerialization(idList, compactedPalette.getSize());
|
||||
+ if (bits != 0) {
|
||||
+ // Re-pack the integer array as the palette has changed size
|
||||
+ SimpleBitStorage copy = new SimpleBitStorage(bits, array.length);
|
||||
+ for (int i = 0; i < array.length; ++i) {
|
||||
+ copy.set(i, array[i]);
|
||||
+ }
|
||||
+
|
||||
+ // We don't need to clone the data array as we are the sole owner of it
|
||||
+ data = this.asOptional(copy.getRaw());
|
||||
+ }
|
||||
+
|
||||
+ elements = compactedPalette.getElements();
|
||||
+ }
|
||||
+ }
|
||||
} finally {
|
||||
this.release();
|
||||
}
|
||||
|
||||
- return var12;
|
||||
+ return new PalettedContainerRO.PackedData<>(elements, data);
|
||||
+ // Gale end - Lithium - faster chunk serialization
|
||||
}
|
||||
|
||||
private static <T> void swapPalette(int[] is, IntUnaryOperator applier) {
|
||||
@@ -365,17 +405,37 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
||||
|
||||
@Override
|
||||
public void count(PalettedContainer.CountConsumer<T> counter) {
|
||||
- if (this.data.palette.getSize() == 1) {
|
||||
- counter.accept(this.data.palette.valueFor(0), this.data.storage.getSize());
|
||||
- } else {
|
||||
- Int2IntOpenHashMap int2IntOpenHashMap = new Int2IntOpenHashMap();
|
||||
- this.data.storage.getAll((key) -> {
|
||||
- int2IntOpenHashMap.addTo(key, 1);
|
||||
- });
|
||||
- int2IntOpenHashMap.int2IntEntrySet().forEach((entry) -> {
|
||||
- counter.accept(this.data.palette.valueFor(entry.getIntKey()), entry.getIntValue());
|
||||
- });
|
||||
+ // Gale start - Lithium - faster chunk serialization
|
||||
+ int len = this.data.palette().getSize();
|
||||
+
|
||||
+ // Do not allocate huge arrays if we're using a large palette
|
||||
+ if (len > 4096) {
|
||||
+ // VanillaCopy
|
||||
+ if (this.data.palette.getSize() == 1) {
|
||||
+ counter.accept(this.data.palette.valueFor(0), this.data.storage.getSize());
|
||||
+ } else {
|
||||
+ Int2IntOpenHashMap int2IntOpenHashMap = new Int2IntOpenHashMap();
|
||||
+ this.data.storage.getAll((key) -> {
|
||||
+ int2IntOpenHashMap.addTo(key, 1);
|
||||
+ });
|
||||
+ int2IntOpenHashMap.int2IntEntrySet().forEach((entry) -> {
|
||||
+ counter.accept(this.data.palette.valueFor(entry.getIntKey()), entry.getIntValue());
|
||||
+ });
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ short[] counts = new short[len];
|
||||
+
|
||||
+ this.data.storage().getAll(i -> counts[i]++);
|
||||
+
|
||||
+ for (int i = 0; i < counts.length; i++) {
|
||||
+ T obj = this.data.palette().valueFor(i);
|
||||
+
|
||||
+ if (obj != null) {
|
||||
+ counter.accept(obj, counts[i]);
|
||||
+ }
|
||||
}
|
||||
+ // Gale end - Lithium - faster chunk serialization
|
||||
}
|
||||
|
||||
static record Configuration<T>(Palette.Factory factory, int bits) {
|
||||
@@ -1,6 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 09:00:10 +0000
|
||||
Date: Wed, 17 Jan 2024 14:10:33 +0000
|
||||
Subject: [PATCH] Leaves Fix Bladeren Protocol
|
||||
|
||||
|
||||
@@ -91,3 +91,16 @@ index d696f001d2576d1b61cc732c81f22eb52205072b..92ad6e9b1c0d9640b80c1ebe739c613d
|
||||
|
||||
boolean ignoreId() default false;
|
||||
}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java
|
||||
index 6325f6441e28d915514e6b0ee9b450610e99b2c2..19277aa7b9bd16b3e70d581d38a4c28e60165f65 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java
|
||||
@@ -97,7 +97,7 @@ public class CommunicationManager {
|
||||
playerMap.remove(oldPlayer);
|
||||
}
|
||||
|
||||
- @ProtocolHandler.PayloadReceiver(payload = LeavesProtocolManager.LeavesPayload.class, ignoreId = true)
|
||||
+ @ProtocolHandler.PayloadReceiver(payload = LeavesProtocolManager.LeavesPayload.class, ignoreId = true, payloadId = "")
|
||||
public static void onPacketGet(ServerPlayer player, LeavesProtocolManager.LeavesPayload payload) {
|
||||
if (!LuminolConfig.syncmaticaProtocol){
|
||||
return;
|
||||
@@ -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
|
||||
}
|
||||
85
patches/server/0051-Fix-folia-181-on-1.20.2.patch
Normal file
85
patches/server/0051-Fix-folia-181-on-1.20.2.patch
Normal file
@@ -0,0 +1,85 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sun, 21 Jan 2024 00:27:17 +0000
|
||||
Subject: [PATCH] Fix folia #181 on 1.20.2
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index 875afb57c7f0c4e3d0bc752d86a8308147eee31a..e91061b96701bc46f5a6ed8315eb6c8da8a74f3a 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -36,6 +36,7 @@ public class LuminolConfig {
|
||||
public static boolean disableOfflineModeWarning = false;
|
||||
public static boolean fixSpectorTeleportFolia = false;
|
||||
public static boolean disableRootUserWarning = false;
|
||||
+ public static boolean fixDoubleEntitySchedulerRetring = false;
|
||||
|
||||
public static boolean safeTeleportation = true;
|
||||
public static boolean enableSandDuping = false;
|
||||
@@ -153,6 +154,7 @@ public class LuminolConfig {
|
||||
fixSpectorTeleportFolia = get("misc.fix_folia_spector_teleport",fixSpectorTeleportFolia);
|
||||
disableOfflineModeWarning = get("misc.disable_offline_mode_warning",disableOfflineModeWarning);
|
||||
disableRootUserWarning = get("misc.disable_root_user_warning",disableRootUserWarning);
|
||||
+ fixDoubleEntitySchedulerRetring = get("misc.fix_folia_double_entity_scheduler_retring",fixDoubleEntitySchedulerRetring,"Fix https://github.com/PaperMC/Folia/pull/181 on Folia");
|
||||
|
||||
if (tpsbarEnabled){
|
||||
initTpsbar();
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
index e1ace2ad411b8d54c56660b41e774a1c998b3ac3..5303d92484b4afdc697c79eecb71d5f24d670aa4 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
@@ -4,6 +4,8 @@ import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import java.util.Objects;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.CrashReportCategory;
|
||||
@@ -69,6 +71,9 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
protected final ServerPlayer player;
|
||||
protected final org.bukkit.craftbukkit.CraftServer cserver;
|
||||
public boolean processedDisconnect;
|
||||
+ //Luminol start - Fix folia #181
|
||||
+ private boolean handledDisconnect = false;
|
||||
+ //Luminol end
|
||||
|
||||
public CraftPlayer getCraftPlayer() {
|
||||
return (this.player == null) ? null : (CraftPlayer) this.player.getBukkitEntity();
|
||||
@@ -86,6 +91,13 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
ServerCommonPacketListenerImpl.LOGGER.info("Stopping singleplayer server as player logged out");
|
||||
this.server.halt(false);
|
||||
}
|
||||
+ //Luminol start - Fix folia #181
|
||||
+ if (this.handledDisconnect && LuminolConfig.fixDoubleEntitySchedulerRetring){
|
||||
+ return;
|
||||
+ }
|
||||
+ this.handledDisconnect = true;
|
||||
+ //Luminol end
|
||||
+
|
||||
this.player.getBukkitEntity().taskScheduler.retire(); // Folia - region threading
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 59cd97446b9dace1a887e35761bc94c88348256a..c4652f250e22f33e8505183b4050e08aedf9245c 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -29,6 +29,8 @@ import java.util.function.UnaryOperator;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.Util;
|
||||
@@ -337,7 +339,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
public void tick() {
|
||||
// Folia start - region threading
|
||||
this.keepConnectionAlive();
|
||||
- if (this.player.wonGame) {
|
||||
+ if ((LuminolConfig.fixDoubleEntitySchedulerRetring && this.processedDisconnect) || this.player.wonGame) { //Luminol - Fix folia #181
|
||||
return;
|
||||
}
|
||||
// Folia end - region threading
|
||||
@@ -1,14 +1,14 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 07:18:27 +0000
|
||||
Date: Sun, 21 Jan 2024 11:49:38 +0000
|
||||
Subject: [PATCH] Piston fixes from molean server
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index a0915438503e385153ec7bc7584860466f65b461..13b1bf1d3dea42d0d0d45ebd2c9ccbf6928c395b 100644
|
||||
index 3a5c8f1f9a8173777b00d43c15e8e313526d3e28..9bd6d4881280196a437161a9375ac8ee5e0f9231 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -1447,7 +1447,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -1428,7 +1428,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
if (movement.lengthSqr() <= 1.0E-7D) {
|
||||
return movement;
|
||||
} else {
|
||||
@@ -18,10 +18,10 @@ index a0915438503e385153ec7bc7584860466f65b461..13b1bf1d3dea42d0d0d45ebd2c9ccbf6
|
||||
if (i != this.pistonDeltasGameTime) {
|
||||
Arrays.fill(this.pistonDeltas, 0.0D);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
||||
index be74adc86f0ca467f3b59e7b57fd47a8f381d86e..3482ed0449478b258d85751ffc90ce677acbc60f 100644
|
||||
index cdcf11fb9e4690d74b30fe0ade842d6574464624..141b806493f25854fc49f90816cd22e7d5d74e6f 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
||||
@@ -152,7 +152,7 @@ public class PistonBaseBlock extends DirectionalBlock {
|
||||
@@ -139,7 +139,7 @@ public class PistonBaseBlock extends DirectionalBlock {
|
||||
if (tileentity instanceof PistonMovingBlockEntity) {
|
||||
PistonMovingBlockEntity tileentitypiston = (PistonMovingBlockEntity) tileentity;
|
||||
|
||||
@@ -31,7 +31,7 @@ index be74adc86f0ca467f3b59e7b57fd47a8f381d86e..3482ed0449478b258d85751ffc90ce67
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
|
||||
index 1c23597f172f46eec714b510acfedb415bb01bff..3262398db1b053115b83ed6aab15f9fef511d5d3 100644
|
||||
index a595abb43853cd4c3f5886a83527c6cbe4a3e8f7..2284dfcb09d9a7c6f670e5266a3f2856c2d40e8d 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
|
||||
@@ -277,7 +277,7 @@ public class PistonMovingBlockEntity extends BlockEntity {
|
||||
@@ -1,39 +1,33 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 06:34:15 +0000
|
||||
Subject: [PATCH] Teleport async if entity was moving to another region at once
|
||||
Date: Fri, 26 Jan 2024 10:58:48 +0000
|
||||
Subject: [PATCH] Teleport async if the entity was moving to another region
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaEntityMovingFixConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaEntityMovingFixConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..73d99a105a18231901e691922b0c283adae0cc79
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaEntityMovingFixConfig.java
|
||||
@@ -0,0 +1,22 @@
|
||||
+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 FoliaEntityMovingFixConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+ @ConfigInfo(baseName = "warn_on_detected")
|
||||
+ public static boolean warnOnDetected = true;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.FIXES;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "folia.fix_high_velocity_issue";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index e91061b96701bc46f5a6ed8315eb6c8da8a74f3a..55d0ae641f1de570a293d1d6fe03da3ab2bba1c4 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -43,6 +43,8 @@ public class LuminolConfig {
|
||||
public static boolean enableVoidTrading = false;
|
||||
public static boolean allowIncorrectTripwireUpdating = false;
|
||||
public static boolean useVanillaRandomSource = false;
|
||||
+ public static boolean fixLargePosMoving = false;
|
||||
+ public static boolean warnOnLargeMovingDetected = true;
|
||||
|
||||
public static RegionFileFormat regionFormatName = RegionFileFormat.ANVIL;
|
||||
public static int regionFormatLinearCompressionLevel = 1;
|
||||
@@ -165,6 +167,8 @@ public class LuminolConfig {
|
||||
enableVoidTrading = get("fixes.enable_void_trading",enableVoidTrading);
|
||||
allowIncorrectTripwireUpdating = get("fixes.allow_incorrect_trip_wire_updaing",allowIncorrectTripwireUpdating);
|
||||
useVanillaRandomSource = get("fixes.use_vanilla_random_source",useVanillaRandomSource,"RNG feature related");
|
||||
+ fixLargePosMoving = get("fixes.fix_large_pos_moving", fixLargePosMoving,"Fix an entity moving issue on folia which is not fixed yet");
|
||||
+ warnOnLargeMovingDetected = get("fixes.warn_on_large_pos_moving",warnOnLargeMovingDetected);
|
||||
|
||||
regionFormatName = RegionFileFormat.fromString(get("save.region-format.format", regionFormatName.name()));
|
||||
if (regionFormatName.equals(RegionFileFormat.INVALID)) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index e6252c2cb76d96929c69c651b6570b586ee7e7e3..53c4ac14ce95f21ef87a148dddb349f18d6320b1 100644
|
||||
index 9bd6d4881280196a437161a9375ac8ee5e0f9231..18fdb265714584d4ee759d86cc8a10b13742e153 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -7,6 +7,7 @@ import com.google.common.collect.Lists;
|
||||
@@ -44,16 +38,7 @@ index e6252c2cb76d96929c69c651b6570b586ee7e7e3..53c4ac14ce95f21ef87a148dddb349f1
|
||||
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;
|
||||
@@ -1070,10 +1073,40 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -1084,9 +1085,39 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
// Paper end - detailed watchdog information
|
||||
|
||||
@@ -62,11 +47,10 @@ index e6252c2cb76d96929c69c651b6570b586ee7e7e3..53c4ac14ce95f21ef87a148dddb349f1
|
||||
+ //Luminol end
|
||||
+
|
||||
public void move(MoverType movementType, Vec3 movement) {
|
||||
final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity
|
||||
// Paper start - detailed watchdog information
|
||||
io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main");
|
||||
+ //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 (LuminolConfig.fixLargePosMoving && TickThread.isTickThread()){ //Except the threads because it may be called by the chunk system worker thread
|
||||
+ if (this.preventMoving){
|
||||
+ return;
|
||||
+ }
|
||||
@@ -84,7 +68,7 @@ index e6252c2cb76d96929c69c651b6570b586ee7e7e3..53c4ac14ce95f21ef87a148dddb349f1
|
||||
+ this.preventMoving = false;
|
||||
+ }
|
||||
+ );
|
||||
+ if (FoliaEntityMovingFixConfig.warnOnDetected){
|
||||
+ if (LuminolConfig.warnOnLargeMovingDetected){
|
||||
+ MinecraftServer.LOGGER.warn("Entity {} with entityId {} has tried moving to another region!",this.type.getCategory().getName(),this.getId());
|
||||
+ }
|
||||
+ return;
|
||||
@@ -1,288 +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..b882549a3c3bc8c192014fd6e1ac7b4f0feddafc
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/gameplay/LeavesBladerenProtocolConfig.java
|
||||
@@ -0,0 +1,24 @@
|
||||
+package me.earthme.luminol.config.modules.gameplay;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class LeavesBladerenProtocolConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enable_base_protocol")
|
||||
+ public static boolean enableBaseProtocol = false;
|
||||
+ @ConfigInfo(baseName = "enable_mspt_sync_protocol")
|
||||
+ public static boolean msptSyncProtocol = false;
|
||||
+ @ConfigInfo(baseName = "mspt_sync_interval")
|
||||
+ public static int msptSyncTickInterval = 20;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.GAMEPLAY;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "leaves_bladeren_protocol";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/bladeren/BladerenProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/bladeren/BladerenProtocol.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..6415f17fa6c06199e59705a29605d2aef834fc17
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/bladeren/BladerenProtocol.java
|
||||
@@ -0,0 +1,150 @@
|
||||
+package top.leavesmc.leaves.protocol.bladeren;
|
||||
+
|
||||
+import com.google.common.collect.Maps;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+import net.minecraft.network.FriendlyByteBuf;
|
||||
+import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import org.jetbrains.annotations.Contract;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import top.leavesmc.leaves.protocol.core.LeavesProtocol;
|
||||
+import top.leavesmc.leaves.protocol.core.ProtocolHandler;
|
||||
+import top.leavesmc.leaves.protocol.core.ProtocolUtils;
|
||||
+
|
||||
+import java.util.HashMap;
|
||||
+import java.util.Map;
|
||||
+import java.util.function.BiConsumer;
|
||||
+
|
||||
+@LeavesProtocol(namespace = "bladeren")
|
||||
+public class BladerenProtocol {
|
||||
+
|
||||
+ public static final String PROTOCOL_ID = "bladeren";
|
||||
+ public static final String PROTOCOL_VERSION = "1.0.0";
|
||||
+
|
||||
+ private static final ResourceLocation HELLO_ID = id("hello");
|
||||
+ private static final ResourceLocation FEATURE_MODIFY_ID = id("feature_modify");
|
||||
+
|
||||
+ private static final Map<String, BiConsumer<ServerPlayer, CompoundTag>> registeredFeatures = Maps.newConcurrentMap();
|
||||
+
|
||||
+ @Contract("_ -> new")
|
||||
+ public static @NotNull ResourceLocation id(String path) {
|
||||
+ return new ResourceLocation(PROTOCOL_ID, path);
|
||||
+ }
|
||||
+
|
||||
+ @ProtocolHandler.PayloadReceiver(payload = BladerenHelloPayload.class, payloadId = "hello")
|
||||
+ private static void handleHello(@NotNull ServerPlayer player, @NotNull BladerenHelloPayload payload) {
|
||||
+ if (me.earthme.luminol.config.modules.gameplay.LeavesBladerenProtocolConfig.enableBaseProtocol) {
|
||||
+ String clientVersion = payload.version;
|
||||
+ CompoundTag tag = payload.nbt;
|
||||
+
|
||||
+ if (tag != null) {
|
||||
+ CompoundTag featureNbt = tag.getCompound("Features");
|
||||
+ for (String name : featureNbt.getAllKeys()) {
|
||||
+
|
||||
+ final BiConsumer<ServerPlayer,CompoundTag> target = registeredFeatures.get(name);
|
||||
+
|
||||
+ if (target != null){
|
||||
+ target.accept(player, featureNbt.getCompound(name));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @ProtocolHandler.PayloadReceiver(payload = BladerenFeatureModifyPayload.class, payloadId = "feature_modify")
|
||||
+ private static void handleModify(@NotNull ServerPlayer player, @NotNull BladerenFeatureModifyPayload payload) {
|
||||
+ if (me.earthme.luminol.config.modules.gameplay.LeavesBladerenProtocolConfig.enableBaseProtocol) {
|
||||
+ String name = payload.name;
|
||||
+ CompoundTag tag = payload.nbt;
|
||||
+
|
||||
+ final BiConsumer<ServerPlayer,CompoundTag> target = registeredFeatures.get(name);
|
||||
+
|
||||
+ if (target != null){
|
||||
+ target.accept(player, tag);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @ProtocolHandler.PlayerJoin
|
||||
+ public static void onPlayerJoin(@NotNull ServerPlayer player) {
|
||||
+ if (me.earthme.luminol.config.modules.gameplay.LeavesBladerenProtocolConfig.enableBaseProtocol) {
|
||||
+ CompoundTag tag = new CompoundTag();
|
||||
+ LeavesFeatureSet.writeNBT(tag);
|
||||
+ ProtocolUtils.sendPayloadPacket(player, new BladerenHelloPayload(PROTOCOL_VERSION, tag));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void registerFeature(String name, BiConsumer<ServerPlayer, CompoundTag> consumer) {
|
||||
+ registeredFeatures.put(name, consumer);
|
||||
+ }
|
||||
+
|
||||
+ public static class LeavesFeatureSet {
|
||||
+
|
||||
+ private static final Map<String, LeavesFeature> features = new HashMap<>();
|
||||
+
|
||||
+ public static void writeNBT(@NotNull CompoundTag tag) {
|
||||
+ CompoundTag featureNbt = new CompoundTag();
|
||||
+ features.values().forEach(feature -> feature.writeNBT(featureNbt));
|
||||
+ tag.put("Features", featureNbt);
|
||||
+ }
|
||||
+
|
||||
+ public static void register(LeavesFeature feature) {
|
||||
+ features.put(feature.name, feature);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public record LeavesFeature(String name, String value) {
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Contract("_, _ -> new")
|
||||
+ public static LeavesFeature of(String name, boolean value) {
|
||||
+ return new LeavesFeature(name, Boolean.toString(value));
|
||||
+ }
|
||||
+
|
||||
+ public void writeNBT(@NotNull CompoundTag rules) {
|
||||
+ CompoundTag rule = new CompoundTag();
|
||||
+ rule.putString("Feature", name);
|
||||
+ rule.putString("Value", value);
|
||||
+ rules.put(name, rule);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public record BladerenFeatureModifyPayload(String name, CompoundTag nbt) implements CustomPacketPayload {
|
||||
+
|
||||
+ public BladerenFeatureModifyPayload(ResourceLocation location, FriendlyByteBuf buf) {
|
||||
+ this(buf.readUtf(), buf.readNbt());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void write(@NotNull FriendlyByteBuf buf) {
|
||||
+ buf.writeUtf(name);
|
||||
+ buf.writeNbt(nbt);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull
|
||||
+ public ResourceLocation id() {
|
||||
+ return FEATURE_MODIFY_ID;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public record BladerenHelloPayload(String version, CompoundTag nbt) implements CustomPacketPayload {
|
||||
+
|
||||
+ public BladerenHelloPayload(ResourceLocation location, @NotNull FriendlyByteBuf buf) {
|
||||
+ this(buf.readUtf(64), buf.readNbt());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void write(@NotNull FriendlyByteBuf buf) {
|
||||
+ buf.writeUtf(version);
|
||||
+ buf.writeNbt(nbt);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull
|
||||
+ public ResourceLocation id() {
|
||||
+ return HELLO_ID;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..db63ea1cf65e6ca06bd1c6ce978193e068a9a951
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java
|
||||
@@ -0,0 +1,90 @@
|
||||
+package top.leavesmc.leaves.protocol.bladeren;
|
||||
+
|
||||
+import io.papermc.paper.threadedregions.ThreadedRegionizer;
|
||||
+import io.papermc.paper.threadedregions.TickData;
|
||||
+import io.papermc.paper.threadedregions.TickRegions;
|
||||
+import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
+import it.unimi.dsi.fastutil.objects.ObjectLists;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.level.ServerLevel;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import org.jetbrains.annotations.Contract;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import top.leavesmc.leaves.protocol.core.LeavesProtocol;
|
||||
+import top.leavesmc.leaves.protocol.core.ProtocolHandler;
|
||||
+import top.leavesmc.leaves.protocol.core.ProtocolUtils;
|
||||
+
|
||||
+import java.util.List;
|
||||
+
|
||||
+@LeavesProtocol(namespace = "bladeren")
|
||||
+public class MsptSyncProtocol {
|
||||
+
|
||||
+ public static final String PROTOCOL_ID = "bladeren";
|
||||
+
|
||||
+ private static final ResourceLocation MSPT_SYNC = id("mspt_sync");
|
||||
+
|
||||
+ private static final List<ServerPlayer> players = ObjectLists.synchronize(new ObjectArrayList<>());
|
||||
+
|
||||
+ private static int tickCounter = 0;
|
||||
+
|
||||
+ @Contract("_ -> new")
|
||||
+ public static @NotNull ResourceLocation id(String path) {
|
||||
+ return new ResourceLocation(PROTOCOL_ID, path);
|
||||
+ }
|
||||
+
|
||||
+ @ProtocolHandler.Init
|
||||
+ public static void init() {
|
||||
+ BladerenProtocol.registerFeature("mspt_sync", (player, compoundTag) -> {
|
||||
+ if (compoundTag.getString("Value").equals("true")) {
|
||||
+ onPlayerSubmit(player);
|
||||
+ } else {
|
||||
+ onPlayerLoggedOut(player);
|
||||
+ }
|
||||
+ });
|
||||
+ }
|
||||
+
|
||||
+ @ProtocolHandler.PlayerLeave
|
||||
+ public static void onPlayerLoggedOut(@NotNull ServerPlayer player) {
|
||||
+ if (me.earthme.luminol.config.modules.gameplay.LeavesBladerenProtocolConfig.msptSyncProtocol) {
|
||||
+ players.remove(player);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @ProtocolHandler.Ticker
|
||||
+ public static void tick() {
|
||||
+ if (me.earthme.luminol.config.modules.gameplay.LeavesBladerenProtocolConfig.msptSyncProtocol) {
|
||||
+ if (players.isEmpty()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (tickCounter++ % me.earthme.luminol.config.modules.gameplay.LeavesBladerenProtocolConfig.msptSyncTickInterval == 0) {
|
||||
+ for (ServerPlayer player : players){
|
||||
+ final ThreadedRegionizer.ThreadedRegion<TickRegions.TickRegionData, TickRegions.TickRegionSectionData> region = ((ServerLevel) player.level()).regioniser.getRegionAtUnsynchronised(player.sectionX,player.sectionZ);
|
||||
+
|
||||
+ if (region == null){
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final TickData.TickReportData reportData = region.getData().getRegionSchedulingHandle().getTickReport5s(System.nanoTime());
|
||||
+
|
||||
+ if (reportData != null){
|
||||
+ final TickData.SegmentData tpsData = reportData.tpsData().segmentAll();
|
||||
+ final double mspt = reportData.timePerTickData().segmentAll().average() / 1.0E6;
|
||||
+ final double tps = tpsData.average();
|
||||
+
|
||||
+ ProtocolUtils.sendPayloadPacket(player, MSPT_SYNC, buf -> {
|
||||
+ buf.writeDouble(mspt);
|
||||
+ buf.writeDouble(tps);
|
||||
+ });
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void onPlayerSubmit(@NotNull ServerPlayer player) {
|
||||
+ if (me.earthme.luminol.config.modules.gameplay.LeavesBladerenProtocolConfig.msptSyncProtocol) {
|
||||
+ players.add(player);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
@@ -1,14 +1,14 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sun, 28 Jan 2024 09:11:58 +0000
|
||||
Date: Sun, 28 Jan 2024 09:51:56 +0000
|
||||
Subject: [PATCH] Sparkly Paper Optimize canSee checks
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index c212030a24174115a975604b91d03cf8ad4043de..2fc86eb396ed600154840dd6cd43b9294a34595c 100644
|
||||
index 4709782f3e858edfa6ce25696462eb45909885ee..3cba356b74362c2fc010d0c1bfb6eeecb449908e 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -1408,7 +1408,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -1419,7 +1419,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
// Folia end - region threading
|
||||
|
||||
// CraftBukkit start - respect vanish API
|
||||
@@ -18,19 +18,19 @@ index c212030a24174115a975604b91d03cf8ad4043de..2fc86eb396ed600154840dd6cd43b929
|
||||
}
|
||||
// CraftBukkit end
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 830616f7a3d1c3e25133229a74e08cbb9d412179..80e0bb615ee8283b5618566c8011f06b1c84a0a8 100644
|
||||
index 06c92a2d3ecb3b747c2303819f72c1c41967af8c..7ae6925732c347ec97c94c5fdfd0012fbe6820fc 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -187,7 +187,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@@ -183,7 +183,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
private boolean hasPlayedBefore = false;
|
||||
private final ConversationTracker conversationTracker = new ConversationTracker();
|
||||
private final Set<String> channels = new HashSet<String>();
|
||||
- private final Map<UUID, Set<WeakReference<Plugin>>> invertedVisibilityEntities = new HashMap<>();
|
||||
+ private final Map<UUID, Set<WeakReference<Plugin>>> invertedVisibilityEntities = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(); // SparklyPaper - optimize canSee checks
|
||||
private final Set<UUID> unlistedEntities = new HashSet<>(); // Paper - Add Listing API for Player
|
||||
private final Set<UUID> unlistedEntities = new HashSet<>(); // Paper
|
||||
private static final WeakHashMap<Plugin, WeakReference<Plugin>> pluginWeakReferences = new WeakHashMap<>();
|
||||
private int hash = 0;
|
||||
@@ -2146,9 +2146,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@@ -2075,9 +2075,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
@Override
|
||||
public boolean canSee(org.bukkit.entity.Entity entity) {
|
||||
@@ -1,14 +1,14 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Tue, 6 Feb 2024 04:21:05 +0000
|
||||
Date: Sun, 28 Jan 2024 09:52:09 +0000
|
||||
Subject: [PATCH] Gale Skip entity move if movement is zero
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index bf530eb5e039f37b9bea37d2a61ee31fdab8c8a9..d175f13ada111bcee977957c6fd9580e032183e9 100644
|
||||
index 18fdb265714584d4ee759d86cc8a10b13742e153..ec255db477e6308cc0fbe336b7bebeac75b97b2a 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -318,6 +318,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -317,6 +317,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
public float yRotO;
|
||||
public float xRotO;
|
||||
private AABB bb;
|
||||
@@ -16,7 +16,7 @@ index bf530eb5e039f37b9bea37d2a61ee31fdab8c8a9..d175f13ada111bcee977957c6fd9580e
|
||||
public boolean onGround;
|
||||
public boolean horizontalCollision;
|
||||
public boolean verticalCollision;
|
||||
@@ -1088,6 +1089,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -1090,6 +1091,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
//Luminol end
|
||||
|
||||
public void move(MoverType movementType, Vec3 movement) {
|
||||
@@ -25,10 +25,10 @@ index bf530eb5e039f37b9bea37d2a61ee31fdab8c8a9..d175f13ada111bcee977957c6fd9580e
|
||||
+ return;
|
||||
+ }
|
||||
+ // Gale end - VMP - skip entity move if movement is zero
|
||||
final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity
|
||||
// Paper start - detailed watchdog information
|
||||
io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main");
|
||||
@@ -4938,6 +4944,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
//Luminol start - Fix high position moving
|
||||
@@ -4875,6 +4881,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
|
||||
public final void setBoundingBox(AABB boundingBox) {
|
||||
@@ -1,14 +1,14 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sun, 28 Jan 2024 09:30:22 +0000
|
||||
Date: Sun, 28 Jan 2024 09:52:24 +0000
|
||||
Subject: [PATCH] Gale Check frozen ticks before landing block
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 39f054b9352376336b543c1ca4e9be9a6dee79b3..7ae3d5a9e44092501271b36e593fe6d7270c472b 100644
|
||||
index ecbacbed29af51d949122b21c3ae9fc95885c6d8..3c83ff19c40eb44eae3ed9f7db4f5291d080b32c 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -588,11 +588,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -591,11 +591,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
|
||||
protected void tryAddFrost() {
|
||||
@@ -21,7 +21,7 @@ index 39f054b9352376336b543c1ca4e9be9a6dee79b3..7ae3d5a9e44092501271b36e593fe6d7
|
||||
|
||||
if (attributemodifiable == null) {
|
||||
return;
|
||||
@@ -602,7 +601,6 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -605,7 +604,6 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
|
||||
attributemodifiable.addTransientModifier(new AttributeModifier(LivingEntity.SPEED_MODIFIER_POWDER_SNOW_UUID, "Powder snow slow", (double) f, AttributeModifier.Operation.ADDITION));
|
||||
}
|
||||
@@ -1,150 +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/LeavesProtocolSupportConfig.java b/src/main/java/me/earthme/luminol/config/modules/gameplay/LeavesProtocolSupportConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..80d57d6262510cf7c6446e46cdd16d05461e9484
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/gameplay/LeavesProtocolSupportConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.gameplay;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class LeavesProtocolSupportConfig implements IConfigModule {
|
||||
+ @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..2af49a86bf2a8bb65073c8ce088e875224916fd8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/CarpetServerProtocol.java
|
||||
@@ -0,0 +1,112 @@
|
||||
+package top.leavesmc.leaves.protocol;
|
||||
+
|
||||
+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 (me.earthme.luminol.config.modules.gameplay.LeavesProtocolSupportConfig.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 (me.earthme.luminol.config.modules.gameplay.LeavesProtocolSupportConfig.enabled) {
|
||||
+ if (payload.nbt.contains(HELLO)) {
|
||||
+ MinecraftServer.LOGGER.info("Player " + player.getScoreboardName() + " joined with carpet " + payload.nbt.getString(HELLO));
|
||||
+ CompoundTag data = new CompoundTag();
|
||||
+ CarpetRules.write(data);
|
||||
+ ProtocolUtils.sendPayloadPacket(player, new CarpetPayload(data));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static class CarpetRules {
|
||||
+
|
||||
+ private static final Map<String, CarpetRule> rules = new HashMap<>();
|
||||
+
|
||||
+ public static void write(@NotNull CompoundTag tag) {
|
||||
+ CompoundTag rulesNbt = new CompoundTag();
|
||||
+ rules.values().forEach(rule -> rule.writeNBT(rulesNbt));
|
||||
+
|
||||
+ tag.put("Rules", rulesNbt);
|
||||
+ }
|
||||
+
|
||||
+ public static void register(CarpetRule rule) {
|
||||
+ rules.put(rule.name, rule);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public record CarpetRule(String identifier, String name, String value) {
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Contract("_, _, _ -> new")
|
||||
+ public static CarpetRule of(String identifier, String name, Enum<?> value) {
|
||||
+ return new CarpetRule(identifier, name, value.name().toLowerCase(Locale.ROOT));
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Contract("_, _, _ -> new")
|
||||
+ public static CarpetRule of(String identifier, String name, boolean value) {
|
||||
+ return new CarpetRule(identifier, name, Boolean.toString(value));
|
||||
+ }
|
||||
+
|
||||
+ public void writeNBT(@NotNull CompoundTag rules) {
|
||||
+ CompoundTag rule = new CompoundTag();
|
||||
+ rule.putString("Value", value);
|
||||
+ rule.putString("Manager", identifier);
|
||||
+ rule.putString("Rule", name);
|
||||
+ rules.put(name, rule);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public record CarpetPayload(CompoundTag nbt) implements CustomPacketPayload {
|
||||
+
|
||||
+ public CarpetPayload(ResourceLocation location, FriendlyByteBuf buf) {
|
||||
+ this(buf.readNbt());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void write(FriendlyByteBuf buf) {
|
||||
+ buf.writeNbt(nbt);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull
|
||||
+ public ResourceLocation id() {
|
||||
+ return HELLO_ID;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
@@ -1,19 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sun, 28 Jan 2024 09:31:27 +0000
|
||||
Date: Sun, 28 Jan 2024 09:52:48 +0000
|
||||
Subject: [PATCH] Gale Don't trigger lootable refresh for non-player
|
||||
interaction
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
index b41635dd0569ff7df909df492d3e850aef7214be..7ff40b74827a52eb5daaff72e1563b044d41c6c1 100644
|
||||
index 02364a148b347e3669275553004391e31d77c0b5..6c6ed0e9877c7e0c9804f3c2c786a61c301e318f 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
@@ -68,6 +68,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
|
||||
@@ -70,6 +70,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unpackLootTable(@org.jetbrains.annotations.Nullable final Player player) {
|
||||
public void unpackLootTable(@Nullable Player player) {
|
||||
+ if (player == null) return; // Gale - EMC - don't trigger lootable refresh for non-player interaction
|
||||
// Copied from super with changes, always check the original method
|
||||
net.minecraft.world.level.Level level = this.getLevel();
|
||||
BlockPos blockPos = this.getBlockPos();
|
||||
if (this.level != null && this.lootableData.shouldReplenish(player) && this.level.getServer() != null) { // Paper - don't unpack loot table if not in world
|
||||
LootTable lootTable = this.level.getServer().getLootData().getLootTable(this.lootTable);
|
||||
if (player instanceof ServerPlayer) {
|
||||
@@ -1,27 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Fri, 9 Feb 2024 03:32:05 +0000
|
||||
Subject: [PATCH] Threaded region start tick and finished tick event
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/TickRegionScheduler.java b/src/main/java/io/papermc/paper/threadedregions/TickRegionScheduler.java
|
||||
index 865044d40a95d201765435cbc14b0384980eebf6..ab5f832aafc479eca1c5da012e180d6374e32325 100644
|
||||
--- a/src/main/java/io/papermc/paper/threadedregions/TickRegionScheduler.java
|
||||
+++ b/src/main/java/io/papermc/paper/threadedregions/TickRegionScheduler.java
|
||||
@@ -389,7 +389,7 @@ public final class TickRegionScheduler {
|
||||
|
||||
final long scheduledStart = this.getScheduledStart();
|
||||
final long scheduledEnd = scheduledStart + TIME_BETWEEN_TICKS;
|
||||
-
|
||||
+ new me.earthme.luminol.api.events.TickRegionStartTickEvent(this.region == null ? -1 : this.region.region.id,System.nanoTime()); //Luminol - Threaded regions API
|
||||
synchronized (this) {
|
||||
this.currentTickData = new TickTime(
|
||||
lastTickStart, scheduledStart, tickStart, cpuStart,
|
||||
@@ -424,6 +424,7 @@ public final class TickRegionScheduler {
|
||||
);
|
||||
|
||||
this.addTickTime(time);
|
||||
+ new me.earthme.luminol.api.events.TickRegionFinishedTickEvent(this.region == null ? -1 : this.region.region.id,System.nanoTime()); //Luminol - Threaded regions API
|
||||
TickRegionScheduler.setTickTask(null);
|
||||
if (this.region != null) {
|
||||
TickRegionScheduler.setTickingRegion(null);
|
||||
@@ -99,10 +99,10 @@ public class Main {
|
||||
```
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
index cb22cac2b8c4eaf705b76fd4a9d8b82fb8eb0140..f24132f5ab6362829e88559304173bd9a259caa3 100644
|
||||
index a149d98be7b4744f18d4ed4940881e13a76e4a7c..ad61afcfe1d0b01b17bc02977e8ff2b8d0420088 100644
|
||||
--- a/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
+++ b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
@@ -165,13 +165,11 @@ public final class MCUtil {
|
||||
@@ -166,13 +166,11 @@ public final class MCUtil {
|
||||
}
|
||||
|
||||
public static int fastFloor(double x) {
|
||||
@@ -118,7 +118,7 @@ index cb22cac2b8c4eaf705b76fd4a9d8b82fb8eb0140..f24132f5ab6362829e88559304173bd9
|
||||
}
|
||||
|
||||
public static float normalizeYaw(float f) {
|
||||
@@ -232,11 +230,11 @@ public final class MCUtil {
|
||||
@@ -233,11 +231,11 @@ public final class MCUtil {
|
||||
}
|
||||
|
||||
public static int getChunkCoordinate(final double coordinate) {
|
||||
@@ -133,10 +133,10 @@ index cb22cac2b8c4eaf705b76fd4a9d8b82fb8eb0140..f24132f5ab6362829e88559304173bd9
|
||||
|
||||
public static long getBlockKey(final int x, final int y, final int z) {
|
||||
diff --git a/src/main/java/net/minecraft/util/Mth.java b/src/main/java/net/minecraft/util/Mth.java
|
||||
index 03854a2d26a3cfc1817acfdc28cbf151ba59e05b..d9e0224dc108a99c194d4947d18f2d855a341534 100644
|
||||
index 33ace08d15bbcad66c09c7bd65dd03e784246e8f..d04586223a9b2a30efb17da01fb7f3e8f2a6af7b 100644
|
||||
--- a/src/main/java/net/minecraft/util/Mth.java
|
||||
+++ b/src/main/java/net/minecraft/util/Mth.java
|
||||
@@ -56,13 +56,11 @@ public class Mth {
|
||||
@@ -51,13 +51,11 @@ public class Mth {
|
||||
}
|
||||
|
||||
public static int floor(float value) {
|
||||
@@ -152,7 +152,7 @@ index 03854a2d26a3cfc1817acfdc28cbf151ba59e05b..d9e0224dc108a99c194d4947d18f2d85
|
||||
}
|
||||
|
||||
public static long lfloor(double value) {
|
||||
@@ -79,13 +77,11 @@ public class Mth {
|
||||
@@ -74,13 +72,11 @@ public class Mth {
|
||||
}
|
||||
|
||||
public static int ceil(float value) {
|
||||
@@ -168,7 +168,7 @@ index 03854a2d26a3cfc1817acfdc28cbf151ba59e05b..d9e0224dc108a99c194d4947d18f2d85
|
||||
}
|
||||
|
||||
public static int clamp(int value, int min, int max) {
|
||||
@@ -121,15 +117,7 @@ public class Mth {
|
||||
@@ -116,15 +112,7 @@ public class Mth {
|
||||
}
|
||||
|
||||
public static double absMax(double a, double b) {
|
||||
@@ -0,0 +1,56 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sun, 28 Jan 2024 10:48:45 +0000
|
||||
Subject: [PATCH] Added config for secondary POI optimizations
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index 55d0ae641f1de570a293d1d6fe03da3ab2bba1c4..e531453e3d25700e38ff41548c7e32e278a6304d 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -68,6 +68,7 @@ public class LuminolConfig {
|
||||
public static int asyncPathProcessingKeepalive = 60;
|
||||
public static boolean enableAsyncMobSpawning = false;
|
||||
public static boolean useAlternateKeepAlive = false;
|
||||
+ public static boolean skipSecondaryPOIIfIsEmpty = true;
|
||||
|
||||
public static boolean pcaSyncProtocol = false;
|
||||
public static String pcaSyncPlayerEntity = "NOBODY";
|
||||
@@ -211,6 +212,7 @@ public class LuminolConfig {
|
||||
enableAsyncMobSpawning = get("optimizations.enable_async_mob_spawning",enableAsyncMobSpawning);
|
||||
RegionizedWorldData.initMobSpawningExecutor();
|
||||
useAlternateKeepAlive = get("optimizations.enable_alternative_keep_alive_handling",useAlternateKeepAlive,"Enabling this sends a keepalive packet once per second to a player, and only kicks for timeout if none of them were responded to in 30 seconds. Responding to any of them in any order will keep the player connected. AKA, it won't kick your players because one packet gets dropped somewhere along the lines(From purpur)");
|
||||
+ skipSecondaryPOIIfIsEmpty = get("optimizations.skip_secondary_poi_if_is_empty",skipSecondaryPOIIfIsEmpty);
|
||||
|
||||
pcaSyncProtocol = get("gameplay.enable_pca_sync_protocol",pcaSyncProtocol);
|
||||
pcaSyncPlayerEntity = get("gameplay.pca_sync_player_entity",pcaSyncPlayerEntity,"Available values: NOBODY,EVERYBODY,OPS,OPS_AND_SELF");
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
|
||||
index 75dc06a3041bfdfb08c914eb50cfa282ae9eb2fe..6a95fe3f648a54b3cbb2b38a294028043c8012c9 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
|
||||
@@ -4,6 +4,8 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
+
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.GlobalPos;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
@@ -23,10 +25,12 @@ public class SecondaryPoiSensor extends Sensor<Villager> {
|
||||
@Override
|
||||
protected void doTick(ServerLevel world, Villager entity) {
|
||||
// Gale start - Lithium - skip secondary POI sensor if absent
|
||||
- var secondaryPoi = entity.getVillagerData().getProfession().secondaryPoi();
|
||||
- if (secondaryPoi.isEmpty()) {
|
||||
- entity.getBrain().eraseMemory(MemoryModuleType.SECONDARY_JOB_SITE);
|
||||
- return;
|
||||
+ if (LuminolConfig.skipSecondaryPOIIfIsEmpty){
|
||||
+ var secondaryPoi = entity.getVillagerData().getProfession().secondaryPoi();
|
||||
+ if (secondaryPoi.isEmpty()) {
|
||||
+ entity.getBrain().eraseMemory(MemoryModuleType.SECONDARY_JOB_SITE);
|
||||
+ return;
|
||||
+ }
|
||||
}
|
||||
// Gale end - Lithium - skip secondary POI sensor if absent
|
||||
ResourceKey<Level> resourceKey = world.dimension();
|
||||
166
patches/server/0060-Leaves-Command-Utilities.patch
Normal file
166
patches/server/0060-Leaves-Command-Utilities.patch
Normal file
@@ -0,0 +1,166 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Mon, 29 Jan 2024 12:47:41 +0000
|
||||
Subject: [PATCH] Leaves Command Utilities
|
||||
|
||||
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/command/CommandArgument.java b/src/main/java/top/leavesmc/leaves/command/CommandArgument.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..eadc6d168fb13299348b0c275ae352ee2f1e1ea2
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/command/CommandArgument.java
|
||||
@@ -0,0 +1,43 @@
|
||||
+package top.leavesmc.leaves.command;
|
||||
+
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.List;
|
||||
+
|
||||
+public class CommandArgument {
|
||||
+
|
||||
+ private final List<CommandArgumentType<?>> argumentTypes;
|
||||
+ private final List<List<String>> tabComplete;
|
||||
+
|
||||
+ public CommandArgument(CommandArgumentType<?>... argumentTypes) {
|
||||
+ this.argumentTypes = List.of(argumentTypes);
|
||||
+ this.tabComplete = new ArrayList<>();
|
||||
+ for (int i = 0; i < argumentTypes.length; i++) {
|
||||
+ tabComplete.add(new ArrayList<>());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public List<String> tabComplete(int n) {
|
||||
+ if (tabComplete.size() > n) {
|
||||
+ return tabComplete.get(n);
|
||||
+ } else {
|
||||
+ return List.of();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public CommandArgument setTabComplete(int index, List<String> list) {
|
||||
+ tabComplete.set(index, list);
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ public CommandArgumentResult parse(int index, String @NotNull [] args) {
|
||||
+ Object[] result = new Object[argumentTypes.size()];
|
||||
+ Arrays.fill(result, null);
|
||||
+ for (int i = index, j = 0; i < args.length && j < result.length; i++, j++) {
|
||||
+ result[j] = argumentTypes.get(j).pasre(args[i]);
|
||||
+ }
|
||||
+ return new CommandArgumentResult(new ArrayList<>(Arrays.asList(result)));
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/command/CommandArgumentResult.java b/src/main/java/top/leavesmc/leaves/command/CommandArgumentResult.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..340eaca64c96180b895a075ce9e44402cd104eed
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/command/CommandArgumentResult.java
|
||||
@@ -0,0 +1,62 @@
|
||||
+package top.leavesmc.leaves.command;
|
||||
+
|
||||
+import net.minecraft.core.BlockPos;
|
||||
+import org.bukkit.util.Vector;
|
||||
+
|
||||
+import java.util.List;
|
||||
+import java.util.Objects;
|
||||
+
|
||||
+public class CommandArgumentResult {
|
||||
+
|
||||
+ private final List<Object> result;
|
||||
+
|
||||
+ public CommandArgumentResult(List<Object> result) {
|
||||
+ this.result = result;
|
||||
+ }
|
||||
+
|
||||
+ public Integer readInt(int def) {
|
||||
+ return Objects.requireNonNullElse(read(Integer.class), def);
|
||||
+ }
|
||||
+
|
||||
+ public Double readDouble(double def) {
|
||||
+ return Objects.requireNonNullElse(read(Double.class), def);
|
||||
+ }
|
||||
+
|
||||
+ public String readString(String def) {
|
||||
+ return Objects.requireNonNullElse(read(String.class), def);
|
||||
+ }
|
||||
+
|
||||
+ public BlockPos readPos() {
|
||||
+ Integer[] pos = {read(Integer.class), read(Integer.class), read(Integer.class)};
|
||||
+ for (Integer po : pos) {
|
||||
+ if (po == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ }
|
||||
+ return new BlockPos(pos[0], pos[1], pos[2]);
|
||||
+ }
|
||||
+
|
||||
+ public Vector readVector() {
|
||||
+ Double[] pos = {read(Double.class), read(Double.class), read(Double.class)};
|
||||
+ for (Double po : pos) {
|
||||
+ if (po == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ }
|
||||
+ return new Vector(pos[0], pos[1], pos[2]);
|
||||
+ }
|
||||
+
|
||||
+ public <T> T read(Class<T> tClass) {
|
||||
+ if (result.isEmpty()) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ Object obj = result.remove(0);
|
||||
+ if (tClass.isInstance(obj)) {
|
||||
+ return tClass.cast(obj);
|
||||
+ } else {
|
||||
+ return null;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/command/CommandArgumentType.java b/src/main/java/top/leavesmc/leaves/command/CommandArgumentType.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..edf12195c7224ca2fb5d3c2ac3fcf485d3049d07
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/command/CommandArgumentType.java
|
||||
@@ -0,0 +1,37 @@
|
||||
+package top.leavesmc.leaves.command;
|
||||
+
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+public abstract class CommandArgumentType<E> {
|
||||
+
|
||||
+ public static final CommandArgumentType<Integer> INTEGER = new CommandArgumentType<>() {
|
||||
+ @Override
|
||||
+ public Integer pasre(@NotNull String arg) {
|
||||
+ try {
|
||||
+ return Integer.parseInt(arg);
|
||||
+ } catch (NumberFormatException e) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ }
|
||||
+ };
|
||||
+
|
||||
+ public static final CommandArgumentType<Double> DOUBLE = new CommandArgumentType<>() {
|
||||
+ @Override
|
||||
+ public Double pasre(@NotNull String arg) {
|
||||
+ try {
|
||||
+ return Double.parseDouble(arg);
|
||||
+ } catch (NumberFormatException e) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ }
|
||||
+ };
|
||||
+
|
||||
+ public static final CommandArgumentType<String> STRING = new CommandArgumentType<>() {
|
||||
+ @Override
|
||||
+ public String pasre(@NotNull String arg) {
|
||||
+ return arg;
|
||||
+ }
|
||||
+ };
|
||||
+
|
||||
+ public abstract E pasre(@NotNull String arg);
|
||||
+}
|
||||
3259
patches/server/0061-Leaves-fakeplayer-support.patch
Normal file
3259
patches/server/0061-Leaves-fakeplayer-support.patch
Normal file
File diff suppressed because it is too large
Load Diff
102
patches/server/0062-Io_uring-channel-type-support.patch
Normal file
102
patches/server/0062-Io_uring-channel-type-support.patch
Normal file
@@ -0,0 +1,102 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Tue, 30 Jan 2024 13:08:25 +0000
|
||||
Subject: [PATCH] Io_uring channel type support
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 8a926993088d33983f75071b3320dd67c3e857c3..aa1033e0de7d59c32acd2afa58c0b916588b97ed 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -39,6 +39,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/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index 610642b0a0c3f17c66ec27ed812b97c68cee1be6..87f5c0fc3f92feecb167c3e28d86a67ba848cb61 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -37,6 +37,7 @@ public class LuminolConfig {
|
||||
public static boolean fixSpectorTeleportFolia = false;
|
||||
public static boolean disableRootUserWarning = false;
|
||||
public static boolean fixDoubleEntitySchedulerRetring = false;
|
||||
+ public static boolean enableIoUring = false;
|
||||
|
||||
public static boolean safeTeleportation = true;
|
||||
public static boolean enableSandDuping = false;
|
||||
@@ -185,6 +186,7 @@ public class LuminolConfig {
|
||||
disableOfflineModeWarning = get("misc.disable_offline_mode_warning",disableOfflineModeWarning);
|
||||
disableRootUserWarning = get("misc.disable_root_user_warning",disableRootUserWarning);
|
||||
fixDoubleEntitySchedulerRetring = get("misc.fix_folia_double_entity_scheduler_retring",fixDoubleEntitySchedulerRetring,"Fix https://github.com/PaperMC/Folia/pull/181 on Folia");
|
||||
+ enableIoUring = get("misc.enable_io_uring_support",enableIoUring);
|
||||
|
||||
if (tpsbarEnabled){
|
||||
initTpsbar();
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
|
||||
index 81090d1b5d67506268a41c6387a1d45302e88a5c..637d321b75dc7b5653ff9aa6134f900c634a19d8 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
|
||||
@@ -20,9 +20,11 @@ import io.netty.channel.epoll.EpollServerSocketChannel;
|
||||
import io.netty.channel.local.LocalAddress;
|
||||
import io.netty.channel.local.LocalServerChannel;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
-import io.netty.channel.socket.ServerSocketChannel;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
import io.netty.handler.timeout.ReadTimeoutHandler;
|
||||
+import io.netty.incubator.channel.uring.IOUring;
|
||||
+import io.netty.incubator.channel.uring.IOUringEventLoopGroup;
|
||||
+import io.netty.incubator.channel.uring.IOUringServerSocketChannel;
|
||||
import io.netty.util.HashedWheelTimer;
|
||||
import io.netty.util.Timeout;
|
||||
import io.netty.util.Timer;
|
||||
@@ -35,6 +37,8 @@ import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Supplier;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.ReportedException;
|
||||
import net.minecraft.network.BandwidthDebugMonitor;
|
||||
@@ -73,6 +77,10 @@ public class ServerConnectionListener {
|
||||
}
|
||||
// Paper end
|
||||
|
||||
+ //Luminol start - io_uring support
|
||||
+ public static final Supplier<IOUringEventLoopGroup> SERVER_IO_URING_WORKER_GROUP = Suppliers.memoize(() -> new 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;
|
||||
@@ -89,8 +97,14 @@ public class ServerConnectionListener {
|
||||
synchronized (this.channels) {
|
||||
Class oclass;
|
||||
EventLoopGroup eventloopgroup;
|
||||
-
|
||||
- if (Epoll.isAvailable() && this.server.isEpollEnabled()) {
|
||||
+ //Luminol start - io_uring support
|
||||
+ if (IOUring.isAvailable() && LuminolConfig.enableIoUring){
|
||||
+ eventloopgroup = SERVER_IO_URING_WORKER_GROUP.get();
|
||||
+ oclass = IOUringServerSocketChannel.class;
|
||||
+ ServerConnectionListener.LOGGER.info("Using io_uring channel type");
|
||||
+ }
|
||||
+ else if (Epoll.isAvailable() && this.server.isEpollEnabled()) {
|
||||
+ //Luminol end
|
||||
// Paper start
|
||||
if (address instanceof io.netty.channel.unix.DomainSocketAddress) {
|
||||
oclass = io.netty.channel.epoll.EpollServerDomainSocketChannel.class;
|
||||
@@ -100,7 +114,8 @@ public class ServerConnectionListener {
|
||||
// Paper end
|
||||
eventloopgroup = (EventLoopGroup) ServerConnectionListener.SERVER_EPOLL_EVENT_GROUP.get();
|
||||
ServerConnectionListener.LOGGER.info("Using epoll channel type");
|
||||
- } else {
|
||||
+ }
|
||||
+ else {
|
||||
oclass = NioServerSocketChannel.class;
|
||||
eventloopgroup = (EventLoopGroup) ServerConnectionListener.SERVER_EVENT_GROUP.get();
|
||||
ServerConnectionListener.LOGGER.info("Using default channel type");
|
||||
@@ -1,42 +1,37 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 06:58:52 +0000
|
||||
Subject: [PATCH] Prevent teleportAsync calling during moving event being
|
||||
Date: Thu, 1 Feb 2024 09:51:45 +0000
|
||||
Subject: [PATCH] Prevent teleportAsync calling during moving event being
|
||||
handled
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaTeleportAsyncFixConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaTeleportAsyncFixConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..b8aceab54bb60000e7c56810140271022f5147a2
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaTeleportAsyncFixConfig.java
|
||||
@@ -0,0 +1,22 @@
|
||||
+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 FoliaTeleportAsyncFixConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+ @ConfigInfo(baseName = "throw_on_detected")
|
||||
+ public static boolean throwOnDetected = true;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.FIXES;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "folia.prevent_teleportasync_call_during_moving";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index 87f5c0fc3f92feecb167c3e28d86a67ba848cb61..0a1a8016f5e51163c2c375a9444d68d3d68544d1 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -46,6 +46,8 @@ public class LuminolConfig {
|
||||
public static boolean useVanillaRandomSource = false;
|
||||
public static boolean fixLargePosMoving = false;
|
||||
public static boolean warnOnLargeMovingDetected = true;
|
||||
+ public static boolean preventTeleportAsyncDuringMovingEvent = false;
|
||||
+ public static boolean throwOnPreventingTeleportAsync = true;
|
||||
|
||||
public static RegionFileFormat regionFormatName = RegionFileFormat.ANVIL;
|
||||
public static int regionFormatLinearCompressionLevel = 1;
|
||||
@@ -199,6 +201,8 @@ public class LuminolConfig {
|
||||
useVanillaRandomSource = get("fixes.use_vanilla_random_source",useVanillaRandomSource,"RNG feature related");
|
||||
fixLargePosMoving = get("fixes.fix_large_pos_moving", fixLargePosMoving,"Fix an entity moving issue on folia which is not fixed yet");
|
||||
warnOnLargeMovingDetected = get("fixes.warn_on_large_pos_moving",warnOnLargeMovingDetected);
|
||||
+ preventTeleportAsyncDuringMovingEvent = get("fixes.prevent_teleportasync_during_moving_event",preventTeleportAsyncDuringMovingEvent);
|
||||
+ throwOnPreventingTeleportAsync = get("fixes.throw_on_preventing_async_teleport",throwOnPreventingTeleportAsync);
|
||||
|
||||
regionFormatName = RegionFileFormat.fromString(get("save.region-format.format", regionFormatName.name()));
|
||||
if (regionFormatName.equals(RegionFileFormat.INVALID)) {
|
||||
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 ea409d2a03c35990c6857c24305346a6ec7f4bf8..33d2205ba32dd1e11bba92e40d6a4125379b715f 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -332,6 +332,10 @@ public class ServerPlayer extends Player {
|
||||
@@ -326,6 +326,10 @@ public class ServerPlayer extends Player {
|
||||
public double lastEntitySpawnRadiusSquared = -1.0;
|
||||
// Paper end - optimise chunk tick iteration
|
||||
|
||||
@@ -48,65 +43,41 @@ index 9cbf17436b4cf52aae374767aafe79ea4f60c3ce..f2068e7608ed765e35759eb981db6c95
|
||||
super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile);
|
||||
this.chatVisibility = ChatVisiblity.FULL;
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index bcd5d0a274960ccd02a18f754c7ccfdaea698ecc..3ab8e0b0744eaa94cab1f81bc561e420cb151adf 100644
|
||||
index 18745ee33843d668613fd9e7f15d6a79f118280f..9f7eedbac2cbccba4e4cf5e0059cf3a4248438f1 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -675,7 +675,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
@@ -688,7 +688,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
if (true) { // Spigot - don't skip any move events
|
||||
Location oldTo = to.clone();
|
||||
PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
|
||||
+ this.player.handlingMoveEvent = true; //Luminol - Prevent teleportAsync calling during moving event being handled
|
||||
this.cserver.getPluginManager().callEvent(event);
|
||||
+ this.player.handlingMoveEvent = false; //Luminol - Prevent teleportAsync calling during moving event being handled
|
||||
|
||||
Location oldTo = to.clone();
|
||||
PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
|
||||
+ this.player.handlingMoveEvent = true; //Luminol - Prevent teleportAsync calling during moving event being handled
|
||||
this.cserver.getPluginManager().callEvent(event);
|
||||
+ this.player.handlingMoveEvent = false; //Luminol - Prevent teleportAsync calling during moving event being handled
|
||||
// If the event is cancelled we move the player back to their old location.
|
||||
if (event.isCancelled()) {
|
||||
@@ -1592,7 +1594,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
if (from.getX() != Double.MAX_VALUE) {
|
||||
Location oldTo = to.clone();
|
||||
PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
|
||||
+ this.player.handlingMoveEvent = true; //Luminol - Prevent teleportAsync calling during moving event being handled
|
||||
this.cserver.getPluginManager().callEvent(event);
|
||||
+ this.player.handlingMoveEvent = false; //Luminol - Prevent teleportAsync calling during moving event being handled
|
||||
|
||||
// If the event is cancelled we move the player back to their old location.
|
||||
if (event.isCancelled()) {
|
||||
@@ -1625,7 +1627,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
|
||||
Location oldTo = to.clone();
|
||||
PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
|
||||
+ this.player.handlingMoveEvent = true; //Luminol - Prevent teleportAsync calling during moving event being handled
|
||||
this.cserver.getPluginManager().callEvent(event);
|
||||
+ this.player.handlingMoveEvent = false; //Luminol - Prevent teleportAsync calling during moving event being handled
|
||||
|
||||
// If the event is cancelled we move the player back to their old location.
|
||||
if (event.isCancelled()) {
|
||||
// If the event is cancelled we move the player back to their old location.
|
||||
if (event.isCancelled()) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 53c4ac14ce95f21ef87a148dddb349f18d6320b1..a0915438503e385153ec7bc7584860466f65b461 100644
|
||||
index e24b55dc96c2e3904e3c03d6bfa769aedf767b3b..1e5eb1277e1b4f2ba51fadbe2d882198ae940ae0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -27,6 +27,7 @@ import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import me.earthme.luminol.config.modules.fixes.FoliaEntityMovingFixConfig;
|
||||
+import me.earthme.luminol.config.modules.fixes.FoliaTeleportAsyncFixConfig;
|
||||
import net.minecraft.BlockUtil;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.CrashReportCategory;
|
||||
@@ -59,7 +60,6 @@ import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
-import io.papermc.paper.util.MCUtil;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -132,7 +132,6 @@ import org.joml.Vector3f;
|
||||
import org.slf4j.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
-import org.bukkit.Server;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.event.CraftPortalEvent;
|
||||
@@ -3970,6 +3969,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -3950,6 +3950,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
java.util.function.Consumer<Entity> teleportComplete) {
|
||||
io.papermc.paper.util.TickThread.ensureTickThread(this, "Cannot teleport entity async");
|
||||
|
||||
+ //Luminol start - Prevent teleportAsync calling during moving event being handled
|
||||
+ if (this instanceof ServerPlayer player && FoliaTeleportAsyncFixConfig.enabled){
|
||||
+ if (this instanceof ServerPlayer player && LuminolConfig.preventTeleportAsyncDuringMovingEvent){
|
||||
+ if (player.handlingMoveEvent){
|
||||
+ if (FoliaTeleportAsyncFixConfig.throwOnDetected){
|
||||
+ if (LuminolConfig.throwOnPreventingTeleportAsync){
|
||||
+ 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);
|
||||
@@ -119,7 +90,7 @@ index 53c4ac14ce95f21ef87a148dddb349f18d6320b1..a0915438503e385153ec7bc758486046
|
||||
return false;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
index d514ec1e4cbdc579c3a61533998437903afdc8b6..c547376967360402d22657d25e1100366dd50c59 100644
|
||||
index 44a6118d3bd67a95180f750c17967561946e2e87..d642f4d42ae7e73642929708a198294e4c5a24d4 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
@@ -5,6 +5,8 @@ import com.google.common.collect.ImmutableMap;
|
||||
@@ -131,15 +102,15 @@ index d514ec1e4cbdc579c3a61533998437903afdc8b6..c547376967360402d22657d25e110036
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -21,6 +23,7 @@ import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
@@ -20,6 +22,7 @@ import net.minecraft.nbt.NbtUtils;
|
||||
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 {
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
@@ -426,7 +429,21 @@ public abstract class AbstractMinecart extends Entity {
|
||||
this.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
|
||||
|
||||
if (!from.equals(to)) {
|
||||
@@ -162,7 +133,7 @@ index d514ec1e4cbdc579c3a61533998437903afdc8b6..c547376967360402d22657d25e110036
|
||||
// CraftBukkit end
|
||||
if (this.getMinecartType() == AbstractMinecart.Type.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
index db6aa75d642f4a7258f197933671907faf79c8f2..b7c792f75dda1c62ee3730b8204c347848710a9c 100644
|
||||
index 5c07da62c82bc70138f6cb5007629d6974be69ac..c68c84af56053cbf7f0c7809a16b60749a4fdd05 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
@@ -2,6 +2,8 @@ package net.minecraft.world.entity.vehicle;
|
||||
@@ -181,8 +152,8 @@ index db6aa75d642f4a7258f197933671907faf79c8f2..b7c792f75dda1c62ee3730b8204c3478
|
||||
+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> {
|
||||
import net.minecraft.tags.FluidTags;
|
||||
@@ -434,8 +437,22 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
|
||||
server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
|
||||
|
||||
if (this.lastLocation != null && !this.lastLocation.equals(to)) {
|
||||
@@ -1,78 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Fri, 9 Feb 2024 03:28:48 +0000
|
||||
Subject: [PATCH] Threaded region remove and create event
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/api/events/TickRegionCreateEvent.java b/src/main/java/me/earthme/luminol/api/events/TickRegionCreateEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..9f842aeb33e658f3db540b6195f848d2a56ce14f
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/api/events/TickRegionCreateEvent.java
|
||||
@@ -0,0 +1,32 @@
|
||||
+package me.earthme.luminol.api.events;
|
||||
+
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * This event was called when a new threaded region was created.When the event called,it means this region was already added to the region list
|
||||
+ * Notice: It may be called when splitting or merging regions
|
||||
+ */
|
||||
+public class TickRegionCreateEvent extends Event {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+
|
||||
+ private final long id;
|
||||
+
|
||||
+ public TickRegionCreateEvent(long id) {
|
||||
+ this.id = id;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the id of the threaded region which was created
|
||||
+ * @return The id of the threaded region
|
||||
+ */
|
||||
+ public long getId() {
|
||||
+ return this.id;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/api/events/TickRegionRemoveEvent.java b/src/main/java/me/earthme/luminol/api/events/TickRegionRemoveEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..aa3d3868f9d0c3353380960db36ee60a6b4aeb03
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/api/events/TickRegionRemoveEvent.java
|
||||
@@ -0,0 +1,28 @@
|
||||
+package me.earthme.luminol.api.events;
|
||||
+
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * This event was called when a new threaded region was removed.When the event called,it means this region was already removed from the region list
|
||||
+ * Notice: It may be called when splitting or merging regions
|
||||
+ */
|
||||
+public class TickRegionRemoveEvent extends Event {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+
|
||||
+ private final long id;
|
||||
+
|
||||
+ public TickRegionRemoveEvent(long id) {
|
||||
+ this.id = id;
|
||||
+ }
|
||||
+
|
||||
+ public long getId() {
|
||||
+ return this.id;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
@@ -1,26 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Fri, 9 Feb 2024 03:28:48 +0000
|
||||
Subject: [PATCH] Threaded region remove and create event
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/ThreadedRegionizer.java b/src/main/java/io/papermc/paper/threadedregions/ThreadedRegionizer.java
|
||||
index 531aa50f2c84e13358e8918bb0c15ea3cd036cb5..26183f979e24de369fd8f5e72a26a6a9ba44f601 100644
|
||||
--- a/src/main/java/io/papermc/paper/threadedregions/ThreadedRegionizer.java
|
||||
+++ b/src/main/java/io/papermc/paper/threadedregions/ThreadedRegionizer.java
|
||||
@@ -805,6 +805,7 @@ public final class ThreadedRegionizer<R extends ThreadedRegionizer.ThreadedRegio
|
||||
private void onCreate() {
|
||||
this.regioniser.onRegionCreate(this);
|
||||
this.regioniser.callbacks.onRegionCreate(this);
|
||||
+ new me.earthme.luminol.api.events.TickRegionCreateEvent(this.id).callEvent(); //Luminol - Threaded regions API
|
||||
}
|
||||
|
||||
private void onRemove(final boolean wasActive) {
|
||||
@@ -813,6 +814,7 @@ public final class ThreadedRegionizer<R extends ThreadedRegionizer.ThreadedRegio
|
||||
}
|
||||
this.regioniser.callbacks.onRegionDestroy(this);
|
||||
this.regioniser.onRegionDestroy(this);
|
||||
+ new me.earthme.luminol.api.events.TickRegionRemoveEvent(this.id).callEvent(); //Luminol - Threaded regions API
|
||||
}
|
||||
|
||||
private final boolean hasNoAliveSections() {
|
||||
Reference in New Issue
Block a user