Compare commits
186 Commits
ver/1.20.2
...
1.20.6-b20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b208bcc81f | ||
|
|
43eda55b88 | ||
|
|
e6ee20986b | ||
|
|
46aec00348 | ||
|
|
3deaf5f7fb | ||
|
|
81dd04e018 | ||
|
|
bd26f9aeab | ||
|
|
6b2a9d25c8 | ||
|
|
15bb0f42d0 | ||
|
|
841c0b9cd3 | ||
|
|
63ef3ce0b9 | ||
|
|
92b9d91fdf | ||
|
|
a02d29c6a7 | ||
|
|
7b971faccc | ||
|
|
b952734d6b | ||
|
|
5e86abed12 | ||
|
|
266ea43135 | ||
|
|
a33f5c92bb | ||
|
|
1238ec3bf9 | ||
|
|
dec6cf5fd3 | ||
|
|
bb679c51fc | ||
|
|
0f1fee37ef | ||
|
|
5a852d792e | ||
|
|
4333f80871 | ||
|
|
45e119a5ad | ||
|
|
b027e4cd03 | ||
|
|
1e5e540795 | ||
|
|
a020b181cc | ||
|
|
7ea76f4f74 | ||
|
|
787c3793c6 | ||
|
|
39c74a5409 | ||
|
|
fca5e33fa4 | ||
|
|
2d14daaa87 | ||
|
|
0a63aeaca2 | ||
|
|
729312415f | ||
|
|
96499c26ff | ||
|
|
7645ef08e8 | ||
|
|
e7dde4f240 | ||
|
|
dbb30dc4f3 | ||
|
|
65de2ae23e | ||
|
|
ec74075cc5 | ||
|
|
e5379a2042 | ||
|
|
67ba24ec92 | ||
|
|
943c084de6 | ||
|
|
8d3c7e7807 | ||
|
|
fbd9d9f48f | ||
|
|
512da58f92 | ||
|
|
b239c97db1 | ||
|
|
650ce2770d | ||
|
|
ce500bf638 | ||
|
|
48f34a6146 | ||
|
|
40cae40b09 | ||
|
|
38a8161c1a | ||
|
|
dced86a404 | ||
|
|
a983ac00e5 | ||
|
|
e2b21e0f69 | ||
|
|
07ef8e01c5 | ||
|
|
77cb94ae5f | ||
|
|
14e7cbe186 | ||
|
|
49be774d83 | ||
|
|
06dcc037df | ||
|
|
9247a01058 | ||
|
|
856ddfe7cc | ||
|
|
4013d9dc3b | ||
|
|
ce8a2afb0f | ||
|
|
ea3efdb597 | ||
|
|
678c3faeea | ||
|
|
815adcc00e | ||
|
|
c0d766fd07 | ||
|
|
a9cd09f900 | ||
|
|
1452008bbe | ||
|
|
e71abbd761 | ||
|
|
6db86f10e7 | ||
|
|
f134186657 | ||
|
|
ef1b7ce6f7 | ||
|
|
f16e5c1064 | ||
|
|
0b9a436044 | ||
|
|
76f2aa58e1 | ||
|
|
6317a5399b | ||
|
|
3c1be89214 | ||
|
|
9551755b0d | ||
|
|
e1afa32f90 | ||
|
|
fa109ea506 | ||
|
|
ebe2b03455 | ||
|
|
3456a29225 | ||
|
|
c06f539f46 | ||
|
|
259d5173b8 | ||
|
|
3aa2070f49 | ||
|
|
248ac6ae2b | ||
|
|
54da5452d2 | ||
|
|
b1a3d6f0d1 | ||
|
|
9b761ef0c0 | ||
|
|
e965f7285a | ||
|
|
0f1f8b3f78 | ||
|
|
cce9600afb | ||
|
|
5ced673fd8 | ||
|
|
5a8c6b91d0 | ||
|
|
64f826fd98 | ||
|
|
5b0465efeb | ||
|
|
2f30488144 | ||
|
|
1aca9f74c4 | ||
|
|
932c9f9194 | ||
|
|
eafe7cd5e3 | ||
|
|
a319241fc2 | ||
|
|
540bbd4f6a | ||
|
|
8b8328c5b6 | ||
|
|
c508de9f2a | ||
|
|
483e958c58 | ||
|
|
01abc6c424 | ||
|
|
6d26556182 | ||
|
|
78e463d201 | ||
|
|
f67b792dd6 | ||
|
|
38eb77a049 | ||
|
|
624825f76b | ||
|
|
4dcf8fb6ff | ||
|
|
a06ae51240 | ||
|
|
3c80338a24 | ||
|
|
59a428e597 | ||
|
|
f65089a3bc | ||
|
|
3dc384625a | ||
|
|
41d9c2cb89 | ||
|
|
48c1fde6b0 | ||
|
|
9c332ffb4b | ||
|
|
4aaa78b7fc | ||
|
|
2d1a64177a | ||
|
|
5363c69ea7 | ||
|
|
5e79b7c916 | ||
|
|
c0797d33df | ||
|
|
fed8624fff | ||
|
|
0715533d18 | ||
|
|
d0d9402571 | ||
|
|
eb52e43eda | ||
|
|
1a7154a26e | ||
|
|
58d264ff28 | ||
|
|
80e9064854 | ||
|
|
8628f803c2 | ||
|
|
dc4a73f92b | ||
|
|
785325c5e2 | ||
|
|
f1f23b48a9 | ||
|
|
1e7ec58c46 | ||
|
|
a5b1d1c1c4 | ||
|
|
825c337518 | ||
|
|
3075603528 | ||
|
|
b7f290b6b9 | ||
|
|
a9c13dcd70 | ||
|
|
541507e23b | ||
|
|
861b6c2425 | ||
|
|
c0771ba8d9 | ||
|
|
594aaf149f | ||
|
|
891f42ac78 | ||
|
|
ca9decc263 | ||
|
|
6709316516 | ||
|
|
c86388a91f | ||
|
|
8ec40d0dcb | ||
|
|
00fb6f9ab7 | ||
|
|
a780b90545 | ||
|
|
c90b205633 | ||
|
|
089c2d85fe | ||
|
|
f197e9dcb9 | ||
|
|
db303d60b1 | ||
|
|
a66f857401 | ||
|
|
9e33137e10 | ||
|
|
8130bc9226 | ||
|
|
aa17d5c905 | ||
|
|
6ee523d185 | ||
|
|
3446b9d45f | ||
|
|
e2c1b3f536 | ||
|
|
004b0a731a | ||
|
|
7322788353 | ||
|
|
b9aaad9559 | ||
|
|
c5a7fbccbf | ||
|
|
2616bd9df6 | ||
|
|
7280aa9a6b | ||
|
|
53206ca75f | ||
|
|
a413f1d82c | ||
|
|
25008dc31d | ||
|
|
89871f0b36 | ||
|
|
9d257c6060 | ||
|
|
471a059ab2 | ||
|
|
a0bc01a355 | ||
|
|
30ef290b4f | ||
|
|
759b88fb4b | ||
|
|
ad74975559 | ||
|
|
27535b8b94 | ||
|
|
e400a4f904 | ||
|
|
299cc10748 |
14
.github/FUNDING.yml
vendored
Normal file
14
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||
polar: # Replace with a single Polar username
|
||||
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
|
||||
custom: https://afdian.net/a/Luminol
|
||||
68
.github/ISSUE_TEMPLATE/bug-report.yml
vendored
Normal file
68
.github/ISSUE_TEMPLATE/bug-report.yml
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
name: Bug反馈 Bug report
|
||||
description:
|
||||
报告Bug,插件不兼容情况,以及其他相关问题。
|
||||
Report issues with plugin incompatbility or other behavior related issues.
|
||||
labels:
|
||||
- bug
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
请详细描述您所遇到的Bug。确保您**真的**遇到了**服务端**Bug,而非原版特性或客户端Bug。
|
||||
Please describe the bug you encountered in detail. Make sure you're **actually** hitting a **server-side** bug, not a vanilla feature or client-side bug.<br>
|
||||
如果您确定的话,就按照下面的模板填充信息,并提交反馈。
|
||||
If you are sure, follow the template below to fill in the information and submit your feedback.<br>
|
||||
如果此bug被尝试修复,您可以帮助我们测试并回复。若bug的确被修复,您可以关闭issue来让开发者确认。
|
||||
If this bug is tried to fix, you can help us test and reply. If the bug is fixed, you can close the issue to let the developer confirm.
|
||||
- type: input
|
||||
id: leavesMC-version
|
||||
attributes:
|
||||
label: 服务端版本 LuminolMC Version
|
||||
description:
|
||||
LuminolMC服务端发行版本 LuminolMC server release version (contains the git commit's hash)<br>
|
||||
通过执行`/version`命令将获取到的内容复制到这里。 Run `/version` on your server and paste the full, unmodified output here.
|
||||
placeholder: >
|
||||
e.g. git-Luminol-"0635a89" (MC: 1.20.4)
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected-behavior
|
||||
attributes:
|
||||
label: 预期的行为 Expected behavior
|
||||
description: 你期望看到的情况是什么样。What you expected to see.
|
||||
placeholder: e.g. 使用 /tpsbar [NAME] 命令可以切换TPSBAR的开关
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: actual-behavior
|
||||
attributes:
|
||||
label: 观测到的实际行为 Observed/Actual behavior
|
||||
description: 你实际看到的。 What you actually saw.
|
||||
placeholder: e.g. 使用 /tpsbar [NAME] 命令切换不了TPSBAR
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: reproduce
|
||||
attributes:
|
||||
label: 复现步骤 Steps/models to reproduce
|
||||
description:
|
||||
这里应该有一个图片、视频或其他信息来展现你的问题。<br>
|
||||
This may include a build schematic, a video, or detailed instructions to help reconstruct the issue.
|
||||
placeholder: e.g. 登录其他账号,使用 /tpsbar [NAME] 命令切换不了TPSBAR
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: plugin-list
|
||||
attributes:
|
||||
label: 插件与数据包列表。 Plugin and Datapack List.
|
||||
description:
|
||||
服务器上的所有插件和数据包列表。
|
||||
All plugins and datapacks running on your server.<br>
|
||||
执行命令`/plugins`查看插件列表。执行命令`/datapack list`查看数据包列表。
|
||||
To list plugins, run `/plugins`. For datapacks, run `/datapack list`.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: other
|
||||
attributes:
|
||||
label: 更多详细信息。 The more information.
|
||||
31
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
Normal file
31
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
name: 新的需求 Feature Request
|
||||
description:
|
||||
为Luminol提供新的想法。
|
||||
Suggest an idea for Luminol.
|
||||
labels:
|
||||
- enhancement
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
感谢您为 Luminol 提交新的需求!请尽可能详细地描述,以便我们可以更轻松地考虑和审查请求。
|
||||
Thank you for filling out a feature request for Luminol! Please be as detailed as possible so that we may consider and review the request easier.<br>
|
||||
请搜索所有问题以避免重复的功能请求。如果您期望的功能已存在,请回复如果您有什么要补充的。
|
||||
We ask that you search all the issues to avoid a duplicate feature request. If one exists, please reply if you have anything to add.<br>
|
||||
在请求新功能之前,请确保您使用的是最新版本并且您请求的功能不在 Luminol 中。
|
||||
Before requesting a new feature, please make sure you are using the latest version and that the feature you are requesting is not already in Paper.<br>
|
||||
我们的开发人员可能没有过多时间来测试新功能的可用性,如新功能进入Test状态,您可以帮助我们进行测试并回复。
|
||||
Our developers may not have much time to test the usability of new functions. If the new functions enter the Test state, you can help us test and reply.
|
||||
|
||||
- type: textarea
|
||||
id: feature
|
||||
attributes:
|
||||
label: 描述你希望添加的功能。 Describe the feature you'd like.
|
||||
placeholder: e.g. 添加新的PATH
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: othre
|
||||
attributes:
|
||||
label: 其他 Other
|
||||
description: 添加其他的信息。 Add any other context or screenshots about the feature request below.
|
||||
63
.github/workflows/build.yml
vendored
63
.github/workflows/build.yml
vendored
@@ -1,63 +0,0 @@
|
||||
# This workflow uses actions that are not certified by GitHub.
|
||||
# They are provided by a third-party and are governed by
|
||||
# separate terms of service, privacy policy, and support
|
||||
# documentation.
|
||||
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
|
||||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
|
||||
|
||||
name: LuminolCI - Ver/1.20.2
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "ver/1.20.2" ]
|
||||
pull_request:
|
||||
branches: [ "ver/1.20.2" ]
|
||||
|
||||
permissions: write-all
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up git
|
||||
run: git config --global user.email "noreply@github.com" && git config --global user.name "ci"
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
- name: Make gradlew executable
|
||||
run: chmod 777 ./gradlew
|
||||
- name: Setup project
|
||||
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0
|
||||
with:
|
||||
arguments: applyPatches
|
||||
- name: Build project to paperclip jar
|
||||
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0
|
||||
with:
|
||||
arguments: createReobfPaperclipJar
|
||||
- name: Capture build artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Artifacts
|
||||
path: build/libs/
|
||||
- name: Publish API
|
||||
run: |
|
||||
echo "GITHUB_USERNAME=LuminolCI" >> $GITHUB_ENV
|
||||
export GITHUB_USERNAME=LuminolCI
|
||||
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
|
||||
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
|
||||
./gradlew publish
|
||||
- name: Rename jar file
|
||||
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.2 - ${{ github.event.repository.updated_at}}"
|
||||
tag: "1.20.2-${{ github.run_id }}"
|
||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
file: "build/libs/luminol-1.20.2-paperclip.jar"
|
||||
file_glob: true
|
||||
prerelease: false
|
||||
66
.github/workflows/build_1.20.6.yml
vendored
Normal file
66
.github/workflows/build_1.20.6.yml
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
name: Luminol CI - vev/1.20.6
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "ver/1.20.6" ]
|
||||
pull_request:
|
||||
branches: [ "ver/1.20.6" ]
|
||||
|
||||
permissions: write-all
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
environment: default
|
||||
steps:
|
||||
- name: Checkout Git Repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Validate Gradle wrapper
|
||||
uses: gradle/actions/wrapper-validation@v3
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v3
|
||||
with:
|
||||
gradle-version: 8.7
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '21'
|
||||
- name: Configure Git User Details
|
||||
run: git config --global user.email "ci@luminolmc.com" && git config --global user.name "LuminolMC CI"
|
||||
- name: Apply Patches
|
||||
run: gradle applyPatches
|
||||
- name: CreateJar
|
||||
run: gradle createMojmapBundlerJar createMojmapPaperclipJar
|
||||
- name: SetENV
|
||||
run: sh scripts/SetENV.sh
|
||||
- name: Upload Artifact
|
||||
uses: "actions/upload-artifact@v4"
|
||||
with:
|
||||
name: "${{ env.project_id_b }} CI Artifacts"
|
||||
path: "build/libs/*.jar"
|
||||
- name: Create Release
|
||||
if: "!contains(github.event.commits[0].message, '[release skip]')"
|
||||
uses: ncipollo/release-action@v1.14.0
|
||||
with:
|
||||
tag: ${{ env.tag }}
|
||||
name: ${{ env.project_id_b }} ${{ env.mcversion }} - ${{ env.commit_id }}
|
||||
body: |
|
||||
📦Version: `${{ env.mcversion }}` | Commit ${{ env.commit_id }} [](https://github.com/LuminolMC/${{ env.project_id }}/download/${{ env.tag }}/${{ env.jar }})
|
||||
This release is automatically compiled by GitHub Actions
|
||||
### Commit Message
|
||||
${{ env.commit_msg }}
|
||||
artifacts: |
|
||||
${{ env.jar_dir }}
|
||||
${{ env.jar_dir_bundler }}
|
||||
generateReleaseNotes: true
|
||||
prerelease: ${{ env.pre }}
|
||||
makeLatest: ${{ env.make_latest }}
|
||||
token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
- name: Push to API
|
||||
if: "!contains(github.event.commits[0].message, '[release skip]')"
|
||||
env:
|
||||
secret_v2: ${{ secrets.API_KEY }}
|
||||
tag: ${{ env.tag }}
|
||||
project_id: ${{ env.project_id }}
|
||||
run: sh scripts/PushToAPI.sh
|
||||
9
.gitignore
vendored
9
.gitignore
vendored
@@ -33,7 +33,6 @@ target/
|
||||
dependency-reduced-pom.xml
|
||||
|
||||
# various other potential build files
|
||||
build/
|
||||
bin/
|
||||
dist/
|
||||
manifest.mf
|
||||
@@ -51,8 +50,10 @@ manifest.mf
|
||||
# other stuff
|
||||
run/
|
||||
|
||||
# Luminol
|
||||
build-data/
|
||||
Hearse-API
|
||||
Hearse-Server
|
||||
Luminol-API
|
||||
Luminol-Server
|
||||
paper-api-generator
|
||||
*.jar
|
||||
/patches/todo/
|
||||
/patches2/todo/
|
||||
4
LICENSE
4
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Era4FunMC
|
||||
Copyright (c) 2024 LuminolMC
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
SOFTWARE.
|
||||
|
||||
68
README.md
68
README.md
@@ -1,39 +1,73 @@
|
||||
<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)
|
||||

|
||||

|
||||

|
||||
|
||||
<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_EN.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)
|
||||
## 特性
|
||||
- 可配置的原版特性
|
||||
- Tpsbar 支持
|
||||
- 对单线程区域性能的优化
|
||||
- 更多的插件开发API支持(进行中)
|
||||
|
||||
## 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.
|
||||
## 下载
|
||||
任何版本都可以在 [Release](https://github.com/LuminolMC/Luminol/releases) 中找到,你也可以通过[以下步骤](./README.md#构建)自己构建。
|
||||
|
||||
## 构建
|
||||
要构建一个paperclip jar,你需要运行以下命令。你可以在build/libs中找到jar(注意:需要`JDK21`)
|
||||
|
||||
## 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
|
||||
./gradlew applyPatches && ./gradlew createMojmapPaperclipJar
|
||||
```
|
||||
## Using API
|
||||
For gradle:
|
||||
|
||||
## 使用API
|
||||
使用 Gradle:
|
||||
|
||||
```kotlin
|
||||
dependencies {
|
||||
compileOnly("me.earthme.luminol:luminol-api:1.20.2-R0.1-SNAPSHOT")
|
||||
compileOnly("me.earthme.luminol:luminol-api:1.20.6-R0.1-SNAPSHOT")
|
||||
}
|
||||
```
|
||||
For maven
|
||||
|
||||
使用 Maven
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>me.earthme.luminol</groupId>
|
||||
<artifactId>luminol-api</artifactId>
|
||||
<version>1.20.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.20.6-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
## 联系方式
|
||||
> 如果您对这个项目感兴趣或有任何问题,请随时向我们提问。
|
||||
|
||||
**QQ群: [368632360](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=MfosKhcDd8Fdxn1MREuZ8Krbf9T6jiBC&authKey=3cm6qdHohON3gHnuD63FK4k07fIbrWnY4hdyq8OmELsfjMVP1kbFTJY9mRyM2Rkj&noverify=0&group_code=368632360)** | QQ频道: [点击加入](https://pd.qq.com/s/eq9krf9j) | Telegram: [点击加入](https://t.me/LuminolMC) | Discord: [点击加入](https://discord.gg/Qd7m3V6eDx)
|
||||
|
||||
|
||||
## 关于 Issue
|
||||
当您遇到任何问题时,请向我们提问,我们将尽力解决,但请记得清楚地描述您的问题并提供足够的日志等信息。
|
||||
|
||||
## 贡献代码
|
||||
可[查看 Contributing](./docs/CONTRIBUTING.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>
|
||||
71
README_EN.md
Normal file
71
README_EN.md
Normal file
@@ -0,0 +1,71 @@
|
||||
<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>
|
||||
|
||||
[](LICENSE)
|
||||
[](https://github.com/LuminolMC/Luminol/issues)
|
||||

|
||||

|
||||

|
||||
|
||||
**English** | [中文](./README.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)
|
||||
|
||||
## 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](./README_EN.md#build).
|
||||
|
||||
## Build
|
||||
To build a paperclip jar, you need to run the following command. You can find the jar in build/libs(Note: JDK21 is needed)
|
||||
|
||||
```shell
|
||||
./gradlew applyPatches && ./gradlew createMojmapPaperclipJar
|
||||
```
|
||||
|
||||
## Using API
|
||||
For gradle:
|
||||
|
||||
```kotlin
|
||||
dependencies {
|
||||
compileOnly("me.earthme.luminol:luminol-api:1.20.6-R0.1-SNAPSHOT")
|
||||
}
|
||||
```
|
||||
|
||||
For maven
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>me.earthme.luminol</groupId>
|
||||
<artifactId>luminol-api</artifactId>
|
||||
<version>1.20.6-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](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=MfosKhcDd8Fdxn1MREuZ8Krbf9T6jiBC&authKey=3cm6qdHohON3gHnuD63FK4k07fIbrWnY4hdyq8OmELsfjMVP1kbFTJY9mRyM2Rkj&noverify=0&group_code=368632360)** | QQ Channel: [Click To Join](https://pd.qq.com/s/eq9krf9j) | Telegram: [Click To Join](https://t.me/LuminolMC) | Discord: [Click To Join](https://discord.gg/Qd7m3V6eDx)
|
||||
|
||||
## About Issue
|
||||
When you meet any problems, just ask us, we will do our best to solve it, but remember to state your problem clear and provide enough logs etc.</br>
|
||||
|
||||
## Pull Requests
|
||||
See [Contributing](./docs/CONTRIBUTING_EN.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>
|
||||
@@ -1,10 +1,7 @@
|
||||
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.9"
|
||||
id("io.papermc.paperweight.patcher") version "1.7.1"
|
||||
}
|
||||
|
||||
val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
|
||||
@@ -17,9 +14,9 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
remapper("net.fabricmc:tiny-remapper:0.8.6:fat")
|
||||
decompiler("org.quiltmc:quiltflower:1.9.0")
|
||||
paperclip("io.papermc:paperclip:3.0.3-SNAPSHOT")
|
||||
remapper("net.fabricmc:tiny-remapper:0.10.1:fat")
|
||||
decompiler("org.vineflower:vineflower:1.10.1")
|
||||
paperclip("io.papermc:paperclip:3.0.3")
|
||||
}
|
||||
|
||||
subprojects {
|
||||
@@ -28,13 +25,13 @@ subprojects {
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.release.set(17)
|
||||
options.release.set(21)
|
||||
}
|
||||
|
||||
tasks.withType<Javadoc> {
|
||||
@@ -59,17 +56,6 @@ subprojects {
|
||||
|
||||
}
|
||||
|
||||
tasks.generateDevelopmentBundle {
|
||||
apiCoordinates.set("me.earthme.luminol:luminol-api")
|
||||
mojangApiCoordinates.set("io.papermc.paper:paper-mojangapi")
|
||||
libraryRepositories.set(
|
||||
listOf(
|
||||
"https://repo.maven.apache.org/maven2/",
|
||||
paperMavenPublicUrl,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
paperweight {
|
||||
serverProject.set(project(":luminol-server"))
|
||||
|
||||
@@ -91,5 +77,52 @@ 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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.generateDevelopmentBundle {
|
||||
apiCoordinates.set("me.earthme.luminol:luminol-api")
|
||||
libraryRepositories.addAll(
|
||||
"https://repo.maven.apache.org/maven2/",
|
||||
"https://maven.pkg.github.com/LuminolMC/Luminol",
|
||||
paperMavenPublicUrl,
|
||||
)
|
||||
}
|
||||
|
||||
allprojects {
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
name = "githubPackage"
|
||||
url = uri("https://maven.pkg.github.com/LuminolMC/Luminol")
|
||||
|
||||
credentials.username = System.getenv("GITHUB_USERNAME")
|
||||
credentials.password = System.getenv("GITHUB_TOKEN")
|
||||
}
|
||||
|
||||
publications {
|
||||
register<MavenPublication>("gpr") {
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
if (project.hasProperty("publishDevBundle")) {
|
||||
publications.create<MavenPublication>("devBundle") {
|
||||
artifact(tasks.generateDevelopmentBundle) {
|
||||
artifactId = "dev-bundle"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
67
docs/CONTRIBUTING.md
Normal file
67
docs/CONTRIBUTING.md
Normal file
@@ -0,0 +1,67 @@
|
||||
为Luminol贡献代码
|
||||
===========
|
||||
|
||||
[English](./CONTRIBUTING_EN.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 发回储存库。
|
||||
70
docs/CONTRIBUTING_EN.md
Normal file
70
docs/CONTRIBUTING_EN.md
Normal file
@@ -0,0 +1,70 @@
|
||||
Contributing to Luminol
|
||||
===========
|
||||
|
||||
**English** | [中文](./CONTRIBUTING.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,9 +1,13 @@
|
||||
group = me.earthme.luminol
|
||||
version = 1.20.2-R0.1-SNAPSHOT
|
||||
version = 1.20.6-R0.1-SNAPSHOT
|
||||
|
||||
foliaCommit = 1e5e2154c9f88d788cecf0b9fcc77ece7d1f8663
|
||||
foliaCommit = 36e5e836e8b72e39462545709fc656e69bfb53cf
|
||||
|
||||
org.gradle.caching = true
|
||||
org.gradle.parallel = true
|
||||
org.gradle.vfs.watch = false
|
||||
org.gradle.jvmargs = -Xmx3G
|
||||
|
||||
mcVersion = 1.20.6
|
||||
GroupMCV = 1.20
|
||||
preVersion = false
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
29
gradlew
vendored
Normal file → Executable file
29
gradlew
vendored
Normal file → Executable file
@@ -83,10 +83,8 @@ done
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -133,10 +131,13 @@ location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
@@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
@@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
|
||||
20
gradlew.bat
vendored
20
gradlew.bat
vendored
@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
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 639651972fddce4dff63a0f0a7e566a15b9e2dd6..890820cb36e4cadeadb4c2d7cd961a73b065a217 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -168,3 +168,23 @@ tasks.check {
|
||||
dependsOn(scanJar)
|
||||
}
|
||||
// Paper end
|
||||
+
|
||||
+// Luminol start
|
||||
+publishing {
|
||||
+ repositories {
|
||||
+ maven {
|
||||
+ name = "githubPackage"
|
||||
+ url = uri("https://maven.pkg.github.com/LuminolMC/Luminol")
|
||||
+
|
||||
+ credentials.username = System.getenv("GITHUB_USERNAME")
|
||||
+ credentials.password = System.getenv("GITHUB_TOKEN")
|
||||
+ }
|
||||
+
|
||||
+ publications {
|
||||
+ register<MavenPublication>("gpr") {
|
||||
+ from(components["java"])
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+// Luminol end
|
||||
\ No newline at end of file
|
||||
24
patches/api/0001-Rebrand-to-Luminol.patch
Normal file
24
patches/api/0001-Rebrand-to-Luminol.patch
Normal file
@@ -0,0 +1,24 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Tue, 21 May 2024 21:31:53 +0800
|
||||
Subject: [PATCH] Rebrand to Luminol
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/ServerBuildInfo.java b/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
index 9df9d09aa477d4cd3c496ba0933c816df1ef0964..b8a5e4f02499e3a3c370d43f6bbb84ffba58e1f3 100644
|
||||
--- a/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
+++ b/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
@@ -18,6 +18,13 @@ public interface ServerBuildInfo {
|
||||
*/
|
||||
Key BRAND_PAPER_ID = Key.key("papermc", "paper");
|
||||
|
||||
+ // Luminol start
|
||||
+ /**
|
||||
+ * The brand id for Luminol.
|
||||
+ */
|
||||
+ Key BRAND_LUMINOL_ID = Key.key("luminolmc", "luminol");
|
||||
+ // Luminol end
|
||||
+
|
||||
/**
|
||||
* Gets the {@code ServerBuildInfo}.
|
||||
*
|
||||
@@ -0,0 +1,101 @@
|
||||
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;
|
||||
+ }
|
||||
+}
|
||||
28
patches/api/0003-KioCG-Chunk-API.patch
Normal file
28
patches/api/0003-KioCG-Chunk-API.patch
Normal file
@@ -0,0 +1,28 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sat, 27 Apr 2024 13:22:59 +0000
|
||||
Subject: [PATCH] KioCG Chunk API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Chunk.java b/src/main/java/org/bukkit/Chunk.java
|
||||
index d547ae2b20c58bc703de4532b3b591dd34ddb1c6..8721954514f813d0a1200935e27a3ac00ceca135 100644
|
||||
--- a/src/main/java/org/bukkit/Chunk.java
|
||||
+++ b/src/main/java/org/bukkit/Chunk.java
|
||||
@@ -377,4 +377,6 @@ public interface Chunk extends PersistentDataHolder {
|
||||
*/
|
||||
UNLOADED;
|
||||
}
|
||||
+
|
||||
+ long getChunkHotAvg(); // KioCG
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||
index 6c327a07bf8a6aa11a2d7dad12b2830acc539484..d66a165ca910bf47da837fb166e5c295325ef9a8 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -3806,4 +3806,6 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||
@Override
|
||||
Spigot spigot();
|
||||
// Spigot end
|
||||
+
|
||||
+ long getNearbyChunkHot(); // KioCG
|
||||
}
|
||||
@@ -1,28 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 08:20:14 +0800
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Mon, 1 Jan 2024 07:59:27 +0000
|
||||
Subject: [PATCH] Fix build
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 0cd12a854e544e867abfd94c18a9f138ba57e587..d295ee01481b088a376691de7c0927e95d7a68a8 100644
|
||||
index eb2f9941b24af591f1e56339b97f5284a765cf81..32bfe781e5298e5ad1bd2ed4471fb824c49f0ab4 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -14,7 +14,7 @@ val alsoShade: Configuration by configurations.creating
|
||||
@@ -13,7 +13,7 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) {
|
||||
val alsoShade: Configuration by configurations.creating
|
||||
|
||||
dependencies {
|
||||
// Folia start
|
||||
- implementation(project(":folia-api"))
|
||||
+ implementation(project(":luminol-api")) //Luminol
|
||||
implementation("io.papermc.paper:paper-mojangapi:${project.version}") {
|
||||
exclude("io.papermc.paper", "paper-api")
|
||||
}
|
||||
@@ -74,7 +74,7 @@ tasks.jar {
|
||||
attributes(
|
||||
"Main-Class" to "org.bukkit.craftbukkit.Main",
|
||||
"Implementation-Title" to "CraftBukkit",
|
||||
- "Implementation-Version" to "git-Folia-$implementationVersion", // Folia
|
||||
+ "Implementation-Version" to "git-Luminol-$implementationVersion", // Folia //Luminol
|
||||
"Implementation-Vendor" to date, // Paper
|
||||
"Specification-Title" to "Bukkit",
|
||||
"Specification-Version" to project.version,
|
||||
- implementation(project(":folia-api")) // Folia
|
||||
+ implementation(project(":luminol-api")) // Folia // Luminol
|
||||
// Paper start
|
||||
implementation("org.jline:jline-terminal-jansi:3.21.0")
|
||||
implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,179 +0,0 @@
|
||||
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
|
||||
428
patches/server/0003-Empty-config-file-base.patch
Normal file
428
patches/server/0003-Empty-config-file-base.patch
Normal file
@@ -0,0 +1,428 @@
|
||||
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 f9919b9da90317bd615d7e57607df73ebcc1d077..ab07c307bea0d3b79a6239bdcca9714e1ddf3b28 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -14,6 +14,7 @@ val alsoShade: Configuration by configurations.creating
|
||||
|
||||
dependencies {
|
||||
implementation(project(":luminol-api")) // Folia // Luminol
|
||||
+ implementation("com.electronwill.night-config:toml:3.6.6") // Luminol - Night config
|
||||
// Paper start
|
||||
implementation("org.jline:jline-terminal-jansi:3.21.0")
|
||||
implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
||||
diff --git a/src/main/java/me/earthme/luminol/commands/LuminolConfigCommand.java b/src/main/java/me/earthme/luminol/commands/LuminolConfigCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..5c8745dffa80cf47e856d04d283937bda86881f8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/commands/LuminolConfigCommand.java
|
||||
@@ -0,0 +1,70 @@
|
||||
+package me.earthme.luminol.commands;
|
||||
+
|
||||
+import me.earthme.luminol.config.LuminolConfig;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.text.format.TextColor;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.List;
|
||||
+
|
||||
+public class LuminolConfigCommand extends Command {
|
||||
+ public LuminolConfigCommand(){
|
||||
+ super("luminolconfig");
|
||||
+ this.setPermission("luminol.commands.luminolconfig");
|
||||
+ this.setDescription("Manage config file");
|
||||
+ this.setUsage("/luminolconfig");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args, @Nullable Location location) throws IllegalArgumentException {
|
||||
+ final List<String> result = new ArrayList<>();
|
||||
+
|
||||
+ if (args.length == 1){
|
||||
+ result.add("reload");
|
||||
+ }
|
||||
+
|
||||
+ return result;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
|
||||
+ if (!this.testPermission(sender)){
|
||||
+ sender.sendMessage(Component
|
||||
+ .text("No permission to execute this command!")
|
||||
+ .color(TextColor.color(255,0,0))
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
+ if (args.length < 1){
|
||||
+ sender.sendMessage(
|
||||
+ Component
|
||||
+ .text("Wrong use!\n")
|
||||
+ .color(TextColor.color(255,0,0))
|
||||
+ );
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ switch (args[0]){
|
||||
+ case "reload" -> {
|
||||
+ LuminolConfig.reloadAsync().thenAccept(nullValue -> sender.sendMessage(
|
||||
+ Component
|
||||
+ .text("Reloaded config file!")
|
||||
+ .color(TextColor.color(0,255,0))
|
||||
+ ));
|
||||
+ }
|
||||
+
|
||||
+ default -> sender.sendMessage(
|
||||
+ Component
|
||||
+ .text("Unknown action!\n")
|
||||
+ .color(TextColor.color(255,0,0))
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+}
|
||||
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/HotReloadUnsupported.java b/src/main/java/me/earthme/luminol/config/HotReloadUnsupported.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..559c11cb523c7cade34a0abfad15c988f5ad87fe
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/HotReloadUnsupported.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 HotReloadUnsupported {
|
||||
+}
|
||||
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..2b4e64796bf01b0a5fcb306850cd60837ed4d36b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/LuminolConfig.java
|
||||
@@ -0,0 +1,218 @@
|
||||
+package me.earthme.luminol.config;
|
||||
+
|
||||
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import io.papermc.paper.threadedregions.RegionizedServer;
|
||||
+import me.earthme.luminol.commands.LuminolConfigCommand;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.scheduler.MinecraftInternalPlugin;
|
||||
+import org.jetbrains.annotations.Contract;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.io.IOException;
|
||||
+import java.lang.reflect.Field;
|
||||
+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.concurrent.CompletableFuture;
|
||||
+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 boolean alreadyInited = false;
|
||||
+ private static MinecraftInternalPlugin NULL_PLUGIN = new MinecraftInternalPlugin();
|
||||
+
|
||||
+ public static void setupLatch(){
|
||||
+ Bukkit.getCommandMap().register("luminolconfig","luminol",new LuminolConfigCommand());
|
||||
+ alreadyInited = true;
|
||||
+ }
|
||||
+
|
||||
+ public static void reload(){
|
||||
+ RegionizedServer.ensureGlobalTickThread("Reload luminol config off global region thread!");
|
||||
+
|
||||
+ dropAllInstanced();
|
||||
+ try {
|
||||
+ loadConfig();
|
||||
+ }catch (Exception e){
|
||||
+ logger.error(e);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Contract(" -> new")
|
||||
+ public static @NotNull CompletableFuture<Void> reloadAsync(){
|
||||
+ return CompletableFuture.runAsync(LuminolConfig::reload,task -> Bukkit.getGlobalRegionScheduler().run(NULL_PLUGIN,scheduled -> task.run()));
|
||||
+ }
|
||||
+
|
||||
+ public static void dropAllInstanced(){
|
||||
+ allInstanced.clear();
|
||||
+ }
|
||||
+
|
||||
+ 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 || (alreadyInited && field.getAnnotation(HotReloadUnsupported.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 bd333ffb44798069e180cad67c07d86425253024..bbd3b57b83b71ae9840124909f3864c36254f02c 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -222,6 +222,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
this.paperConfigurations.initializeGlobalConfiguration(this.registryAccess());
|
||||
this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess());
|
||||
// Paper end - initialize global and world-defaults configuration
|
||||
+ me.earthme.luminol.config.LuminolConfig.loadConfig(); //Luminol - load config file
|
||||
+ me.earthme.luminol.config.LuminolConfig.setupLatch(); //Luminol - load config file
|
||||
// Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save
|
||||
if (this.convertOldUsers()) {
|
||||
this.getProfileCache().save(false); // Paper
|
||||
@@ -1,49 +0,0 @@
|
||||
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) {
|
||||
61
patches/server/0004-Add-config-for-server-mod-name.patch
Normal file
61
patches/server/0004-Add-config-for-server-mod-name.patch
Normal file
@@ -0,0 +1,61 @@
|
||||
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 4c9c227c1395744128f347e9303f8a13667a4aa3..45f96e545a1a9883c9925d49f5eb69968313a0e9 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -2019,7 +2019,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
- return io.papermc.paper.ServerBuildInfo.buildInfo().brandName(); // Paper
|
||||
+ return me.earthme.luminol.config.modules.misc.ServerModNameConfig.fakeVanilla ? "vanilla" : me.earthme.luminol.config.modules.misc.ServerModNameConfig.serverModName; // Paper // Luminol - Add config for this
|
||||
}
|
||||
|
||||
public SystemReport fillSystemReport(SystemReport details) {
|
||||
@@ -1,77 +1,57 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 11:18:04 +0800
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 00:53:03 +0000
|
||||
Subject: [PATCH] Add config for unsafe teleportation
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/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;
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/UnsafeTeleportationConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/UnsafeTeleportationConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..1b0de6f0ccab72c409a63dc1904829008e30328e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/UnsafeTeleportationConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.fixes;
|
||||
+
|
||||
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");
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+ 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){
|
||||
+public class UnsafeTeleportationConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled", comments = "If you want to use sand duping,please turn on this")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.FIXES;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "allow_unsafe_teleportation";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 385d5bc08928dd990b690b926e174af86f178c64..e357ed9607889536ecd0e6ea8b59c97d3dab631f 100644
|
||||
index d8be7c8dca41b6ad6d9a28590be9e33ef9045bdb..bacc97007f09fca97cd2a9d097f93cf78f4d0166 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -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 {
|
||||
@@ -4112,6 +4112,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
|
||||
protected boolean tryEndPortal() {
|
||||
io.papermc.paper.util.TickThread.ensureTickThread(this, "Cannot portal entity async");
|
||||
+ if (!LuminolConfig.safeTeleportation && !(this instanceof Player)) return false; //Luminol - Unsafe teleportation
|
||||
+ if (me.earthme.luminol.config.modules.fixes.UnsafeTeleportationConfig.enabled && !(this instanceof Player)) return false; //Luminol - Unsafe teleportation
|
||||
BlockPos pos = this.portalBlock;
|
||||
ServerLevel world = this.portalWorld;
|
||||
this.portalBlock = null;
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
index 41d7cff39fc37955877668337689b4b26cd8c7cf..ca5799c618bec3d0abc4566d82a29bcc767c6f1f 100644
|
||||
index aeac09f628bd04070fd302842c304a7dfd39b229..dcdb7199ce731b2899ebd847f7c2d66dcd6d62bd 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
@@ -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 {
|
||||
@@ -61,6 +61,13 @@ public class EndPortalBlock extends BaseEntityBlock {
|
||||
// return; // CraftBukkit - always fire event in case plugins wish to change it
|
||||
}
|
||||
|
||||
+ //Luminol start - Unsafe teleportation
|
||||
+ if (!LuminolConfig.safeTeleportation && !(entity instanceof Player)){
|
||||
+ if (me.earthme.luminol.config.modules.fixes.UnsafeTeleportationConfig.enabled && !(entity instanceof net.minecraft.world.entity.player.Player)){
|
||||
+ entity.endPortalLogicAsync();
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
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/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 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
|
||||
@@ -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 (!LuminolConfig.enableSandDuping && this.isRemoved()) { //Luminol - Add config for sand duping
|
||||
return;
|
||||
}
|
||||
// Paper end - fix sand duping
|
||||
@@ -150,7 +152,7 @@ public class FallingBlockEntity extends Entity {
|
||||
this.move(MoverType.SELF, this.getDeltaMovement());
|
||||
|
||||
// Paper start - fix sand duping
|
||||
- if (this.isRemoved()) {
|
||||
+ if (!LuminolConfig.enableSandDuping && this.isRemoved()) { //Luminol - Add config for sand duping
|
||||
return;
|
||||
}
|
||||
// Paper end - fix sand duping
|
||||
45
patches/server/0006-Add-config-for-void-trading.patch
Normal file
45
patches/server/0006-Add-config-for-void-trading.patch
Normal file
@@ -0,0 +1,45 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 00:59:18 +0000
|
||||
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/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index b194f3448b5199e1204da31e1408f2e80803a77d..6b8cbf681203c20eebb214c5c0b0fe0374aa30dc 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -3011,7 +3011,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
|
||||
- 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
|
||||
merchant.getTrader().closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED);
|
||||
}
|
||||
// Paper end - Fix merchant inventory not closing on entity removal
|
||||
45
patches/server/0007-Add-config-for-vanilla-random.patch
Normal file
45
patches/server/0007-Add-config-for-vanilla-random.patch
Normal file
@@ -0,0 +1,45 @@
|
||||
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 bacc97007f09fca97cd2a9d097f93cf78f4d0166..723ae767d7a34643bba5ed616e3943d3d7633312 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 SyncedDataHolder, Nameable, EntityAccess
|
||||
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,39 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
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/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 e274c501e2455845f6f9a4614802336205362b69..722a5ec7f8e4995ac7025ca0785145d46bd66fcd 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -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
|
||||
- if (entity.getBukkitEntity() instanceof org.bukkit.inventory.Merchant merchant && merchant.getTrader() != null) {
|
||||
+ 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
|
||||
75
patches/server/0008-Add-config-for-chat-sign.patch
Normal file
75
patches/server/0008-Add-config-for-chat-sign.patch
Normal file
@@ -0,0 +1,75 @@
|
||||
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 479e6e2aa88a22ef7f8fccb06add6806f5b71d9d..22dae23a0c2fa4c85befd670637b1e592d889b58 100644
|
||||
--- a/src/main/java/net/minecraft/commands/arguments/ArgumentSignatures.java
|
||||
+++ b/src/main/java/net/minecraft/commands/arguments/ArgumentSignatures.java
|
||||
@@ -14,9 +14,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 - 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
|
||||
+
|
||||
public void write(FriendlyByteBuf buf) {
|
||||
buf.writeCollection(this.entries, (buf2, entry) -> entry.write(buf2));
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/network/FriendlyByteBuf.java b/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
||||
index aafeb9c61ddba6a8671f0238eda47b227619f1af..dc00ad0cc7f0c5c069a8d15dfdc926f2a1487319 100644
|
||||
--- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
||||
+++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
||||
@@ -129,6 +129,16 @@ public class FriendlyByteBuf extends ByteBuf {
|
||||
// Paper end - Adventure; add max length parameter
|
||||
DataResult<JsonElement> dataresult = codec.encodeStart(JsonOps.INSTANCE, value);
|
||||
|
||||
+ //Luminol start - Add config for chat sign
|
||||
+ if (codec == net.minecraft.network.protocol.status.ServerStatus.CODEC) {
|
||||
+ JsonElement element = dataresult.getOrThrow(string -> new EncoderException("Failed to encode: " + string + " " + value));
|
||||
+ element.getAsJsonObject().addProperty("preventsChatReports", !me.earthme.luminol.config.modules.misc.ChatSignConfig.enabled);
|
||||
+
|
||||
+ this.writeUtf(GSON.toJson(element));
|
||||
+ return;
|
||||
+ }
|
||||
+ //Luminol end
|
||||
+
|
||||
this.writeUtf(FriendlyByteBuf.GSON.toJson((JsonElement) dataresult.getOrThrow((s) -> {
|
||||
return new EncoderException("Failed to encode: " + s + " " + String.valueOf(value));
|
||||
})), maxLength); // Paper - Adventure; add max length parameter
|
||||
@@ -1,48 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
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/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 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
|
||||
@@ -2,6 +2,8 @@ package net.minecraft.world.level.block;
|
||||
|
||||
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);
|
||||
@@ -1,76 +1,24 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 15:19:16 +0800
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 04:39:56 +0000
|
||||
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
|
||||
index 0000000000000000000000000000000000000000..01677f210fae53a108bfe194189cb4c233e9fa47
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/commands/TpsBarCommand.java
|
||||
@@ -0,0 +1,40 @@
|
||||
@@ -0,0 +1,50 @@
|
||||
+package me.earthme.luminol.commands;
|
||||
+
|
||||
+import me.earthme.luminol.config.modules.misc.TpsBarConfig;
|
||||
+import me.earthme.luminol.functions.GlobalServerTpsBar;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.text.format.TextColor;
|
||||
+import net.kyori.adventure.util.RGBLike;
|
||||
+import org.bukkit.ChatColor;
|
||||
+import org.bukkit.Color;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.entity.Player;
|
||||
@@ -90,43 +38,104 @@ index 0000000000000000000000000000000000000000..ac8f0e3bf130ba6dfd7202e2f4803522
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ if (!TpsBarConfig.tpsbarEnabled){
|
||||
+ sender.sendMessage(Component.text("Tpsbar was already disabled!").color(TextColor.color(255,0,0)));
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ if (!(sender instanceof Player player)){
|
||||
+ sender.sendMessage(ChatColor.RED+"Only player can use this command!");
|
||||
+ sender.sendMessage(Component.text("Only player can use this command!").color(TextColor.color(255,0,0)));
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ if (GlobalServerTpsBar.isPlayerVisible(player)) {
|
||||
+ player.sendMessage(ChatColor.BLUE + "Disabled tps bar");
|
||||
+ player.sendMessage(Component.text("Disabled tps bar").color(TextColor.color(0,255,0)));
|
||||
+ GlobalServerTpsBar.setVisibilityForPlayer(player,false);
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ player.sendMessage(ChatColor.GREEN + "Enabled tps bar");
|
||||
+ player.sendMessage(Component.text("Enabled tps bar").color(TextColor.color(0,255,0)));
|
||||
+ GlobalServerTpsBar.setVisibilityForPlayer(player,true);
|
||||
+
|
||||
+ 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..aafb2f5052c7c8e5971a47308253badb3027093c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/TpsBarConfig.java
|
||||
@@ -0,0 +1,49 @@
|
||||
+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.*;
|
||||
+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");
|
||||
+ @ConfigInfo(baseName = "update_interval_ticks")
|
||||
+ public static int updateInterval = 15;
|
||||
+
|
||||
+ @DoNotLoad
|
||||
+ private static boolean inited = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "tpsbar";
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onLoaded(CommentedFileConfig configInstance){
|
||||
+ if (tpsbarEnabled){
|
||||
+ GlobalServerTpsBar.init();
|
||||
+ }else{
|
||||
+ GlobalServerTpsBar.cancelBarUpdateTask();
|
||||
+ }
|
||||
+
|
||||
+ if (!inited){
|
||||
+ Bukkit.getCommandMap().register("tpsbar","luminol",new TpsBarCommand("tpsbar"));
|
||||
+ inited = true;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
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..baec715e0c20e920ccb99f2f07d84fcb6f2b434e
|
||||
index 0000000000000000000000000000000000000000..3f1478dde900d671c4bfa43df80f629519cd602e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java
|
||||
@@ -0,0 +1,204 @@
|
||||
@@ -0,0 +1,225 @@
|
||||
+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.LuminolConfig;
|
||||
+import me.earthme.luminol.config.modules.misc.TpsBarConfig;
|
||||
+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;
|
||||
@@ -140,20 +149,40 @@ index 0000000000000000000000000000000000000000..baec715e0c20e920ccb99f2f07d84fcb
|
||||
+ 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 -> {
|
||||
+ cancelBarUpdateTask();
|
||||
+
|
||||
+ Bukkit.getGlobalRegionScheduler().runAtFixedRate(NULL_PLUGIN,c -> {
|
||||
+ tpsbarTask = c;
|
||||
+ try {
|
||||
+ update();
|
||||
+ }catch (Exception e){
|
||||
+ e.printStackTrace();
|
||||
+ logger.error(e);
|
||||
+ }
|
||||
+ },1,1, TimeUnit.SECONDS);
|
||||
+ },1,TpsBarConfig.updateInterval);
|
||||
+ }
|
||||
+
|
||||
+ public static void removeAllBars(){
|
||||
+ for (Map.Entry<UUID,BossBar> barEntry : uuid2Bossbars.entrySet()){
|
||||
+ final UUID playerUUID = barEntry.getKey();
|
||||
+ final BossBar tpsBar = barEntry.getValue();
|
||||
+
|
||||
+ final Player targetPlayer = Bukkit.getPlayer(playerUUID);{
|
||||
+ if (targetPlayer != null){
|
||||
+ targetPlayer.hideBossBar(tpsBar);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ uuid2Bossbars.clear();
|
||||
+ }
|
||||
+
|
||||
+ public static void cancelBarUpdateTask(){
|
||||
+ if (tpsbarTask == null){
|
||||
+ removeAllBars();
|
||||
+
|
||||
+ if (tpsbarTask == null || tpsbarTask.isCancelled()){
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
@@ -215,7 +244,7 @@ index 0000000000000000000000000000000000000000..baec715e0c20e920ccb99f2f07d84fcb
|
||||
+ BossBar targetBossbar = uuid2Bossbars.get(nmsPlayer.getUUID());
|
||||
+
|
||||
+ if (targetBossbar == null && isPlayerVisible(apiPlayer)){
|
||||
+ targetBossbar = BossBar.bossBar(Component.text(""),0.0F, BossBar.Color.valueOf(LuminolConfig.tpsColors[3]), BossBar.Overlay.NOTCHED_20);
|
||||
+ targetBossbar = BossBar.bossBar(Component.text(""),0.0F, BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(3)), BossBar.Overlay.NOTCHED_20);
|
||||
+ uuid2Bossbars.put(nmsPlayer.getUUID(),targetBossbar);
|
||||
+ apiPlayer.showBossBar(targetBossbar);
|
||||
+ }
|
||||
@@ -230,7 +259,7 @@ index 0000000000000000000000000000000000000000..baec715e0c20e920ccb99f2f07d84fcb
|
||||
+
|
||||
+ private static void updateTpsBar(double tps, double mspt, @NotNull BossBar bar, @NotNull Player player){
|
||||
+ bar.name(MiniMessage.miniMessage().deserialize(
|
||||
+ LuminolConfig.tpsBarFormat,
|
||||
+ TpsBarConfig.tpsBarFormat,
|
||||
+ Placeholder.component("tps",getTpsComponent(tps)),
|
||||
+ Placeholder.component("mspt",getMsptComponent(mspt)),
|
||||
+ Placeholder.component("ping",getPingComponent(player.getPing()))
|
||||
@@ -251,18 +280,18 @@ index 0000000000000000000000000000000000000000..baec715e0c20e920ccb99f2f07d84fcb
|
||||
+
|
||||
+ private static BossBar.Color barColorFromPing(int ping){
|
||||
+ if (ping == -1){
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[3]);
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.pingColors.get(3));
|
||||
+ }
|
||||
+
|
||||
+ if (ping <= 80){
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[0]);
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.pingColors.get(0));
|
||||
+ }
|
||||
+
|
||||
+ if (ping <= 160){
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[1]);
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.pingColors.get(1));
|
||||
+ }
|
||||
+
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[2]);
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.pingColors.get(2));
|
||||
+ }
|
||||
+
|
||||
+ private static @NotNull Component getMsptComponent(double mspt){
|
||||
@@ -277,18 +306,18 @@ index 0000000000000000000000000000000000000000..baec715e0c20e920ccb99f2f07d84fcb
|
||||
+
|
||||
+ private static BossBar.Color barColorFromMspt(double mspt){
|
||||
+ if (mspt == -1){
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[3]);
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(3));
|
||||
+ }
|
||||
+
|
||||
+ if (mspt <= 25){
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[0]);
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(0));
|
||||
+ }
|
||||
+
|
||||
+ if (mspt <= 50){
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[1]);
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(1));
|
||||
+ }
|
||||
+
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[2]);
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(2));
|
||||
+ }
|
||||
+
|
||||
+ private static @NotNull Component getTpsComponent(double tps){
|
||||
@@ -303,90 +332,65 @@ index 0000000000000000000000000000000000000000..baec715e0c20e920ccb99f2f07d84fcb
|
||||
+
|
||||
+ private static BossBar.Color barColorFromTps(double tps){
|
||||
+ if (tps == -1){
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[3]);
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(3));
|
||||
+ }
|
||||
+
|
||||
+ if (tps >= 18){
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[0]);
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(0));
|
||||
+ }
|
||||
+
|
||||
+ if (tps >= 15){
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[1]);
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(1));
|
||||
+ }
|
||||
+
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[2]);
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(2));
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index f0bf57a7acd77eeffbeeb6743ba58166823022fd..4a1e068c27853a38db0641806626e7ac740bd8de 100644
|
||||
index bbd3b57b83b71ae9840124909f3864c36254f02c..09bde51d3da062c5788151c15c448eaf2a02ea1b 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -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
|
||||
@@ -850,6 +850,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
|
||||
@Override
|
||||
public void stopServer() {
|
||||
+ GlobalServerTpsBar.cancelBarUpdateTask(); //Luminol - Tpsbar
|
||||
+ me.earthme.luminol.functions.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 97bfb92e52c3c5ef1cd22afe2b97c204eb45025a..d7a280427442bac8cc8ccb542d24d4e0901df70a 100644
|
||||
index 95b72e49469554983e07205b0bd462eec6c9fd86..db32beabfa7ba17b1c46d36fa1dc27bc20e06feb 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -278,6 +278,7 @@ public class ServerPlayer extends Player {
|
||||
@@ -302,6 +302,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;
|
||||
+ public volatile boolean isTpsBarVisible = false; //Luminol - Tps bar
|
||||
|
||||
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 6c8f6e26687b557fcdcd65c657d8b35d3fde805e..06c92a2d3ecb3b747c2303819f72c1c41967af8c 100644
|
||||
index 96201b5b458d8e0cbebf586062fac1ec2d81fdd0..ed4bdf27c38d881fd3896a736652686ff9107f16 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -2216,6 +2216,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@@ -2369,6 +2369,9 @@ 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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2237,6 +2241,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@@ -2390,6 +2393,9 @@ 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,118 +0,0 @@
|
||||
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);
|
||||
})));
|
||||
46
patches/server/0010-Add-config-for-username-check.patch
Normal file
46
patches/server/0010-Add-config-for-username-check.patch
Normal file
@@ -0,0 +1,46 @@
|
||||
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 83b09feec13a00c35e6f8d4f0ccdae1c8da9c0e5..d946a08f7a7532079eab83a7d4affc89e6e6ac1e 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
@@ -171,7 +171,8 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||
public void handleHello(ServerboundHelloPacket packet) {
|
||||
Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet", new Object[0]);
|
||||
// Paper start - Validate usernames
|
||||
- if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode()
|
||||
+ if (me.earthme.luminol.config.modules.misc.UsernameCheckConfig.enabled //Luminol - Add config for username check
|
||||
+ && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode()
|
||||
&& io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation
|
||||
&& !this.iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation) {
|
||||
Validate.validState(StringUtil.isReasonablePlayerName(packet.name()), "Invalid characters in username", new Object[0]);
|
||||
@@ -1,39 +0,0 @@
|
||||
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();
|
||||
@@ -0,0 +1,45 @@
|
||||
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 09bde51d3da062c5788151c15c448eaf2a02ea1b..6f86f25efbd4e6e79476c1563dc8f4c114c10695 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -294,7 +294,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
|
||||
@@ -0,0 +1,45 @@
|
||||
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 300929a406905f5ff1ede664d5b99fb0938d4d2e..7c82730e9a66f9b44dd559d7b8da511f9c5f8ca8 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||||
@@ -45,7 +45,7 @@ public class SignedMessageChain {
|
||||
SignedMessageLink signedMessageLink = SignedMessageChain.this.nextLink;
|
||||
if (signedMessageLink == null) {
|
||||
throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.CHAIN_BROKEN);
|
||||
- } else if (body.timeStamp().isBefore(SignedMessageChain.this.lastTimeStamp)) {
|
||||
+ } else if (me.earthme.luminol.config.modules.misc.InorderChatConfig.enabled && body.timeStamp().isBefore(SignedMessageChain.this.lastTimeStamp)) { // Luminol - Add config for out-of-order chat checks
|
||||
this.setChainBroken();
|
||||
throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.OUT_OF_ORDER_CHAT, org.bukkit.event.player.PlayerKickEvent.Cause.OUT_OF_ORDER_CHAT); // Paper - kick event causes
|
||||
} else {
|
||||
@@ -1,25 +0,0 @@
|
||||
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;
|
||||
258
patches/server/0013-Add-a-simple-watchdog-for-tick-regions.patch
Normal file
258
patches/server/0013-Add-a-simple-watchdog-for-tick-regions.patch
Normal file
@@ -0,0 +1,258 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sun, 10 Mar 2024 05:04:33 +0000
|
||||
Subject: [PATCH] Add a simple watchdog for tick regions
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/RegionizedServer.java b/src/main/java/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||
index fc3d332aa1c1d469cedfe2aaa7102dcd78e25642..1ae61bc6603dd3ac290e3ead20416f9c5b63ff02 100644
|
||||
--- a/src/main/java/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||
+++ b/src/main/java/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||
@@ -279,6 +279,7 @@ public final class RegionizedServer {
|
||||
*/
|
||||
|
||||
private void globalTick(final int tickCount) {
|
||||
+ me.earthme.luminol.utils.LuminolWatchDog.globalRegionHeartBeat(); //Luminol
|
||||
/*
|
||||
if (false) {
|
||||
io.papermc.paper.threadedregions.ThreadedTicketLevelPropagator.main(null);
|
||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/ThreadedRegionizer.java b/src/main/java/io/papermc/paper/threadedregions/ThreadedRegionizer.java
|
||||
index 531aa50f2c84e13358e8918bb0c15ea3cd036cb5..fd0053369eb68f0fd596d8acfba4a5247ef8105a 100644
|
||||
--- a/src/main/java/io/papermc/paper/threadedregions/ThreadedRegionizer.java
|
||||
+++ b/src/main/java/io/papermc/paper/threadedregions/ThreadedRegionizer.java
|
||||
@@ -167,6 +167,8 @@ public final class ThreadedRegionizer<R extends ThreadedRegionizer.ThreadedRegio
|
||||
if (removed != region) {
|
||||
throw new IllegalStateException("Expected to remove " + region + ", but removed " + removed);
|
||||
}
|
||||
+
|
||||
+ me.earthme.luminol.utils.LuminolWatchDog.onRegionDeath(region); //Luminol - Simple watchdog
|
||||
}
|
||||
|
||||
public int getSectionCoordinate(final int chunkCoordinate) {
|
||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/TickRegions.java b/src/main/java/io/papermc/paper/threadedregions/TickRegions.java
|
||||
index 2ad25dd345ab42125d456f2b9cf67d8c4515c8b7..78c50292fb25e8703e9c91db892f05456f07d72f 100644
|
||||
--- a/src/main/java/io/papermc/paper/threadedregions/TickRegions.java
|
||||
+++ b/src/main/java/io/papermc/paper/threadedregions/TickRegions.java
|
||||
@@ -402,6 +402,7 @@ public final class TickRegions implements ThreadedRegionizer.RegionCallbacks<Tic
|
||||
|
||||
@Override
|
||||
protected void tickRegion(final int tickCount, final long startTime, final long scheduledEnd) {
|
||||
+ me.earthme.luminol.utils.LuminolWatchDog.tickRegionHeartBeat(); //Luminol - Simple watchdog
|
||||
final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); // Folia - profiler
|
||||
profiler.startTick(); try { // Folia - profiler
|
||||
MinecraftServer.getServer().tickServer(startTime, scheduledEnd, TimeUnit.MILLISECONDS.toMillis(10L), this.region);
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/WatchdogConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/WatchdogConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..71d80b401470db777a86274d32f178bb2aa023d5
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/WatchdogConfig.java
|
||||
@@ -0,0 +1,27 @@
|
||||
+package me.earthme.luminol.config.modules.misc;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.HotReloadUnsupported;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class WatchdogConfig implements IConfigModule {
|
||||
+
|
||||
+ @HotReloadUnsupported
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+ @ConfigInfo(baseName = "warn_period_ticks")
|
||||
+ public static long warnPeriodTicks = 5 * 20;
|
||||
+ @ConfigInfo(baseName = "timeout_ticks")
|
||||
+ public static long timeOutTicks = 30 * 20;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "watchdog";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/utils/LuminolWatchDog.java b/src/main/java/me/earthme/luminol/utils/LuminolWatchDog.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..8901c50863032f4ae189fe47d44f9fe91f884a6c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/utils/LuminolWatchDog.java
|
||||
@@ -0,0 +1,162 @@
|
||||
+package me.earthme.luminol.utils;
|
||||
+
|
||||
+import com.google.common.collect.Maps;
|
||||
+import io.papermc.paper.threadedregions.ThreadedRegionizer;
|
||||
+import io.papermc.paper.threadedregions.TickRegionScheduler;
|
||||
+import io.papermc.paper.util.StacktraceDeobfuscator;
|
||||
+import me.earthme.luminol.config.modules.misc.WatchdogConfig;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import org.apache.commons.lang3.tuple.Pair;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+import org.slf4j.Logger;
|
||||
+
|
||||
+import java.lang.management.ManagementFactory;
|
||||
+import java.lang.management.ThreadInfo;
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.List;
|
||||
+import java.util.Map;
|
||||
+import java.util.concurrent.CompletableFuture;
|
||||
+import java.util.concurrent.Executor;
|
||||
+import java.util.concurrent.Executors;
|
||||
+import java.util.concurrent.TimeUnit;
|
||||
+
|
||||
+public class LuminolWatchDog {
|
||||
+ private static final Object keepaliveDataLock = new Object();
|
||||
+ private static Pair<Thread,Long> globalRegionLastKeepalive = null;
|
||||
+ private static final Map<Thread,Pair<ThreadedRegionizer.ThreadedRegion<?,?>,Long>> otherTickRegionKeepalive = Maps.newHashMap();
|
||||
+ private static final Executor checkTimer = CompletableFuture.delayedExecutor(50, TimeUnit.MILLISECONDS,Executors.newSingleThreadExecutor());
|
||||
+ private static final Logger logger = MinecraftServer.LOGGER;
|
||||
+ private static int tickCount = 0;
|
||||
+ private static boolean runScheduleNext = true;
|
||||
+
|
||||
+ public static void boot(){
|
||||
+ runCheck();
|
||||
+ }
|
||||
+
|
||||
+ private static void scheduleCheck(){
|
||||
+ checkTimer.execute(LuminolWatchDog::runCheck);
|
||||
+ }
|
||||
+
|
||||
+ private static void runCheck(){
|
||||
+ try {
|
||||
+ if (MinecraftServer.getServer().isStopped() || !runScheduleNext){
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ tickCount++;
|
||||
+
|
||||
+ final List<Pair<Thread,Long>> threadsToWarn = new ArrayList<>();
|
||||
+ final long currentTimeNano = System.nanoTime();
|
||||
+ boolean shouldStopServer = false;
|
||||
+
|
||||
+ synchronized (keepaliveDataLock){
|
||||
+ if (globalRegionLastKeepalive != null){
|
||||
+ final Thread lastGlobalRegionThread = globalRegionLastKeepalive.getLeft();
|
||||
+ final long lastTicked = globalRegionLastKeepalive.getRight();
|
||||
+
|
||||
+ final long timeEscaped = currentTimeNano - lastTicked;
|
||||
+
|
||||
+ if (timeEscaped >= WatchdogConfig.warnPeriodTicks * 50 * 1000 * 1000){
|
||||
+ threadsToWarn.add(Pair.of(lastGlobalRegionThread,timeEscaped));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ for(Pair<Thread,Long> warnInfo : threadsToWarn){
|
||||
+ final Thread targetThread = warnInfo.getLeft();
|
||||
+ final long timeEscaped = warnInfo.getRight();
|
||||
+
|
||||
+ final ThreadedRegionizer.ThreadedRegion<?,?> targetRegion;
|
||||
+
|
||||
+ synchronized (keepaliveDataLock){
|
||||
+ targetRegion = otherTickRegionKeepalive.get(targetThread).getLeft();
|
||||
+ }
|
||||
+
|
||||
+ if (tickCount % WatchdogConfig.warnPeriodTicks == 0){
|
||||
+ dumpSingleRegion(targetThread,targetRegion,timeEscaped);
|
||||
+ }
|
||||
+
|
||||
+ if (timeEscaped > WatchdogConfig.timeOutTicks * 50 * 1000 * 1000){
|
||||
+ shouldStopServer = true;
|
||||
+ runScheduleNext = false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (shouldStopServer){
|
||||
+ MinecraftServer.getServer().stopServer();
|
||||
+ }
|
||||
+ }
|
||||
+ }finally {
|
||||
+ if (runScheduleNext){
|
||||
+ scheduleCheck();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static void dumpSingleRegion(@NotNull Thread thread, @Nullable ThreadedRegionizer.ThreadedRegion<?,?> region,long timeEscaped){
|
||||
+ final StringBuilder messageBuilder = new StringBuilder();
|
||||
+ messageBuilder.append("====================================").append("\n");
|
||||
+ messageBuilder.append("There is a single region that has no responding in " + TimeUnit.NANOSECONDS.toSeconds(timeEscaped) + " seconds!").append("\n");
|
||||
+ messageBuilder.append("If you believe this is a bug,please send it to github issue after checking your plugins!").append("\n");
|
||||
+ messageBuilder.append("Tick Region: ").append(region == null ? "Global Region" : "ChunkX(Center): " + region.getCenterChunk().x + " ChunkZ(Center): " + region.getCenterChunk().z).append("\n");
|
||||
+ messageBuilder.append("Thread Name: ").append(thread.getName()).append("\n");
|
||||
+ messageBuilder.append("Thread Id: ").append(thread.getId()).append("\n");
|
||||
+
|
||||
+ final ThreadInfo targetThreadInfo = ManagementFactory.getThreadMXBean().getThreadInfo(thread.getId());
|
||||
+
|
||||
+ messageBuilder.append("Is Suspend: ").append(targetThreadInfo.isSuspended()).append("\n");
|
||||
+ messageBuilder.append("Thread State: ").append(targetThreadInfo.getThreadState()).append("\n");
|
||||
+ messageBuilder.append("Thread Priority: ").append(targetThreadInfo.getPriority()).append("\n");
|
||||
+ messageBuilder.append("Thread Stack Trace:").append("\n");
|
||||
+
|
||||
+ for (StackTraceElement stackTraceElement : StacktraceDeobfuscator.INSTANCE.deobfuscateStacktrace(thread.getStackTrace())){
|
||||
+ messageBuilder.append("\t\t").append(stackTraceElement).append("\n");
|
||||
+ }
|
||||
+
|
||||
+ messageBuilder.append("\n");
|
||||
+ messageBuilder.append("====================================");
|
||||
+
|
||||
+ logger.error(messageBuilder.toString());
|
||||
+ }
|
||||
+
|
||||
+ public static void globalRegionHeartBeat(){
|
||||
+ if (!WatchdogConfig.enabled){
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ synchronized (keepaliveDataLock){
|
||||
+ globalRegionLastKeepalive = Pair.of(Thread.currentThread(),System.nanoTime());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void tickRegionHeartBeat(){
|
||||
+ if (!WatchdogConfig.enabled){
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ final ThreadedRegionizer.ThreadedRegion<?,?> currentRegion = TickRegionScheduler.getCurrentRegion();
|
||||
+
|
||||
+ if (currentRegion == null) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ synchronized (keepaliveDataLock){
|
||||
+ if (!otherTickRegionKeepalive.containsKey(Thread.currentThread())){
|
||||
+ otherTickRegionKeepalive.put(Thread.currentThread(),Pair.of(currentRegion,System.nanoTime()));
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ otherTickRegionKeepalive.replace(Thread.currentThread(),Pair.of(currentRegion,System.nanoTime()));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void onRegionDeath(ThreadedRegionizer.ThreadedRegion<?,?> currentRegion){
|
||||
+ if (!WatchdogConfig.enabled){
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ synchronized (keepaliveDataLock){
|
||||
+ otherTickRegionKeepalive.remove(Thread.currentThread());
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 45f96e545a1a9883c9925d49f5eb69968313a0e9..97016c309d0a0fc13d733269f7dfb81ca0d8c574 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1226,6 +1226,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
this.statusIcon = (ServerStatus.Favicon) this.loadStatusIcon().orElse(null); // CraftBukkit - decompile error
|
||||
this.status = this.buildServerStatus();
|
||||
|
||||
+ me.earthme.luminol.utils.LuminolWatchDog.boot(); //Luminol - Simple watchdog
|
||||
+
|
||||
// Folia start - region threading
|
||||
if (true) {
|
||||
io.papermc.paper.threadedregions.RegionizedServer.getInstance().init(); // Folia - region threading - only after loading worlds
|
||||
@@ -1,98 +0,0 @@
|
||||
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;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,48 @@
|
||||
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 11b5155820d38a42e62f68fe0f70fe4daf80f5d1..90f4cc0bd3722400411e6b1aa2d03205a350ee8a 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -892,6 +892,11 @@ public class ServerPlayer extends Player {
|
||||
}
|
||||
|
||||
Entity entity = this.getCamera();
|
||||
+ //Luminol start - Fix folia spector teleportation
|
||||
+ if (!io.papermc.paper.util.TickThread.isTickThreadFor(entity) && me.earthme.luminol.config.modules.fixes.FoliaSpectorTeleportationFixConfig.fixSpectorTeleportFolia){
|
||||
+ this.setCamera(this);
|
||||
+ }
|
||||
+ //Luminol end
|
||||
|
||||
if (entity != this) {
|
||||
if (entity.isAlive()) {
|
||||
@@ -0,0 +1,79 @@
|
||||
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
|
||||
|
||||
|
||||
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/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 723ae767d7a34643bba5ed616e3943d3d7633312..f39e8291d2d8b15201835b8c018776ef6eda8d24 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -1128,10 +1128,40 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
// Paper end - detailed watchdog information
|
||||
|
||||
+ //Luminol start - Fix large pos moving
|
||||
+ private volatile boolean preventMoving = false;
|
||||
+ //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 && io.papermc.paper.util.TickThread.isTickThread()){ //Except the threads because it may be called by the chunk system worker thread
|
||||
+ if (this.preventMoving){
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ var finalPosition = movement.add(this.position);
|
||||
+ if (!io.papermc.paper.util.TickThread.isTickThreadFor(((ServerLevel) this.level),finalPosition)){
|
||||
+ this.preventMoving = true;
|
||||
+ this.teleportAsync(
|
||||
+ (ServerLevel) this.level(),
|
||||
+ finalPosition,
|
||||
+ this.getYRot(), this.getXRot(),
|
||||
+ null, PlayerTeleportEvent.TeleportCause.UNKNOWN,
|
||||
+ Entity.TELEPORT_FLAG_LOAD_CHUNK | Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS,
|
||||
+ result -> {
|
||||
+ this.preventMoving = false;
|
||||
+ }
|
||||
+ );
|
||||
+ if (me.earthme.luminol.config.modules.fixes.FoliaEntityMovingFixConfig.warnOnDetected){
|
||||
+ MinecraftServer.LOGGER.warn("Entity {} with entityId {} has tried moving to another region!",this.type.getCategory().getName(),this.getId());
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ //Luminol end
|
||||
synchronized (this.posLock) {
|
||||
this.moveStartX = this.getX();
|
||||
this.moveStartY = this.getY();
|
||||
@@ -1,55 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 15: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");
|
||||
@@ -0,0 +1,45 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Mon, 10 Jun 2024 10:51:08 +0000
|
||||
Subject: [PATCH] Try fixing folia off region POI accessing issue
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaPOIAccessOffRegionFixConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaPOIAccessOffRegionFixConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..343c85ded7e7abc22fac0aaeb7be786e9bd7b39a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaPOIAccessOffRegionFixConfig.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 FoliaPOIAccessOffRegionFixConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.FIXES;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "folia.fix_poi_access_off_region";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
||||
index cf69b4ed4a40015a23d053230c3f326a700788ef..5fdcad0038aad61d68cd329e72c8db309c5e3926 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
||||
@@ -96,7 +96,7 @@ public class PoiManager extends SectionStorage<PoiSection> {
|
||||
|
||||
public Stream<PoiRecord> getInSquare(Predicate<Holder<PoiType>> typePredicate, BlockPos pos, int radius, PoiManager.Occupancy occupationStatus) {
|
||||
int i = Math.floorDiv(radius, 16) + 1;
|
||||
- return ChunkPos.rangeClosed(new ChunkPos(pos), i).flatMap(chunkPos -> this.getInChunk(typePredicate, chunkPos, occupationStatus)).filter(poi -> {
|
||||
+ return ChunkPos.rangeClosed(new ChunkPos(pos), i).filter(cpos -> me.earthme.luminol.config.modules.fixes.FoliaPOIAccessOffRegionFixConfig.enabled ? io.papermc.paper.util.TickThread.isTickThreadFor(this.world,cpos) : true).flatMap(chunkPos -> this.getInChunk(typePredicate, chunkPos, occupationStatus)).filter(poi -> { //Luminol - Fix off region POI access
|
||||
BlockPos blockPos2 = poi.getPos();
|
||||
return Math.abs(blockPos2.getX() - pos.getX()) <= radius && Math.abs(blockPos2.getZ() - pos.getZ()) <= radius;
|
||||
});
|
||||
@@ -1,52 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 15: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;
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
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
|
||||
|
||||
|
||||
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/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 20f8c9bfdde62f1572e22319ebb752d12d9d5bac..24f4370b35d2cc50340de36d81b6c6d9aa250e4c 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -347,6 +347,10 @@ public class ServerPlayer extends Player {
|
||||
public double lastEntitySpawnRadiusSquared = -1.0;
|
||||
// Paper end - optimise chunk tick iteration
|
||||
|
||||
+ //Luminol start - Prevent teleportAsync calling during moving event being handled
|
||||
+ public boolean handlingMoveEvent = false;
|
||||
+ //Luminol end
|
||||
+
|
||||
public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, ClientInformation clientOptions) {
|
||||
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 b4c4e72ddd09231747f82962a9d2883c6415ce30..bd666d03324291ec847136bab905f0aec726a211 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -695,7 +695,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()) {
|
||||
@@ -1612,7 +1614,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()) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index f39e8291d2d8b15201835b8c018776ef6eda8d24..7112c529a652b6ab6a418b3a44fc1f075061cc74 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -4033,6 +4033,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
java.util.function.Consumer<Entity> teleportComplete) {
|
||||
io.papermc.paper.util.TickThread.ensureTickThread(this, "Cannot teleport entity async");
|
||||
|
||||
+ //Luminol start - Prevent teleportAsync calling during moving event being handled
|
||||
+ if (this instanceof ServerPlayer player && me.earthme.luminol.config.modules.fixes.FoliaTeleportAsyncFixConfig.enabled){
|
||||
+ if (player.handlingMoveEvent){
|
||||
+ if (me.earthme.luminol.config.modules.fixes.FoliaTeleportAsyncFixConfig.throwOnDetected){
|
||||
+ throw new IllegalStateException("Player " + player.getScoreboardName() + " is trying to teleport to " + pos + " during move event handling!");
|
||||
+ }
|
||||
+ MinecraftServer.LOGGER.warn("Player {} is trying to teleport to {} during move event handling!",player.getScoreboardName(),pos);
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ //Luminol end
|
||||
+
|
||||
if (!ServerLevel.isInSpawnableBounds(new BlockPos(io.papermc.paper.util.CoordinateUtils.getBlockX(pos), io.papermc.paper.util.CoordinateUtils.getBlockY(pos), io.papermc.paper.util.CoordinateUtils.getBlockZ(pos)))) {
|
||||
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 4d7454e5a64fc18e63793a221daa94617f17c666..a1dc46ec6d53389eb7c801a7a14c4169406de580 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
@@ -375,7 +375,21 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||
this.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
|
||||
|
||||
if (!from.equals(to)) {
|
||||
+ //Luminol start - Prevent teleportAsync calling during moving event being handled
|
||||
+ for (Entity passenger : this.getPassengers()) {
|
||||
+ if (passenger instanceof net.minecraft.server.level.ServerPlayer player){
|
||||
+ player.handlingMoveEvent = true;
|
||||
+ }
|
||||
+ }
|
||||
+ //Luminol end
|
||||
this.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to));
|
||||
+ //Luminol start - Prevent teleportAsync calling during moving event being handled
|
||||
+ for (Entity passenger : this.getPassengers()) {
|
||||
+ if (passenger instanceof net.minecraft.server.level.ServerPlayer player){
|
||||
+ player.handlingMoveEvent = false;
|
||||
+ }
|
||||
+ }
|
||||
+ //Luminol end
|
||||
}
|
||||
// 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 b068cff9b5aa457d65b679529956e8210296d799..d002519a356072284faa5f879e188f3e3062939f 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
@@ -370,8 +370,22 @@ public class Boat extends VehicleEntity implements VariantHolder<Boat.Type> {
|
||||
server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
|
||||
|
||||
if (this.lastLocation != null && !this.lastLocation.equals(to)) {
|
||||
+ //Luminol start - Prevent teleportAsync calling during moving event being handled
|
||||
+ for (Entity passenger : this.getPassengers()) {
|
||||
+ if (passenger instanceof net.minecraft.server.level.ServerPlayer player){
|
||||
+ player.handlingMoveEvent = true;
|
||||
+ }
|
||||
+ }
|
||||
+ //Luminol end
|
||||
VehicleMoveEvent event = new VehicleMoveEvent(vehicle, this.lastLocation, to);
|
||||
server.getPluginManager().callEvent(event);
|
||||
+ //Luminol start - Prevent teleportAsync calling during moving event being handled
|
||||
+ for (Entity passenger : this.getPassengers()) {
|
||||
+ if (passenger instanceof net.minecraft.server.level.ServerPlayer player){
|
||||
+ player.handlingMoveEvent = false;
|
||||
+ }
|
||||
+ }
|
||||
+ //Luminol end
|
||||
}
|
||||
this.lastLocation = vehicle.getLocation();
|
||||
// CraftBukkit end
|
||||
@@ -5,10 +5,10 @@ Subject: [PATCH] Kaiiju Don't pathfind outside region
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java b/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
||||
index 1ab77f3518d1df30f66ae44d7d4fa69e5b32d93a..98bf17441da3169d49de55fe89d79ebe250a2b7e 100644
|
||||
index 2a7a26ca447cc78f24e61a2bf557411c31eb16b2..28602455d659dfac4653ab5b7bf4139f65c190ad 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
||||
@@ -107,7 +107,9 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
||||
@@ -120,7 +120,9 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
||||
|
||||
private boolean tryComputePath(Mob entity, WalkTarget walkTarget, long time) {
|
||||
BlockPos blockPos = walkTarget.getTarget().currentBlockPosition();
|
||||
@@ -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 6f3e87661c3181b6537e4d6d96e50d8d5680c040..3a5c8f1f9a8173777b00d43c15e8e313526d3e28 100644
|
||||
index 7112c529a652b6ab6a418b3a44fc1f075061cc74..643631e11c88285f33d050bf7b4b1e2f63b5c992 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -4108,12 +4108,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
@@ -4240,12 +4240,17 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
targetPos, 16, // load 16 blocks to be safe from block physics
|
||||
ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.HIGH,
|
||||
(chunks) -> {
|
||||
@@ -28,7 +28,7 @@ index 6f3e87661c3181b6537e4d6d96e50d8d5680c040..3a5c8f1f9a8173777b00d43c15e8e313
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -4300,6 +4305,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
@@ -4432,6 +4437,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
if (!this.canPortalAsync(takePassengers)) {
|
||||
return false;
|
||||
}
|
||||
@@ -39,7 +39,7 @@ index 6f3e87661c3181b6537e4d6d96e50d8d5680c040..3a5c8f1f9a8173777b00d43c15e8e313
|
||||
|
||||
Vec3 initialPosition = this.position();
|
||||
ChunkPos initialPositionChunk = new ChunkPos(
|
||||
@@ -4358,7 +4367,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
@@ -4490,7 +4499,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
// place
|
||||
passengerTree.root.placeInAsync(
|
||||
originWorld, destination, Entity.TELEPORT_FLAG_LOAD_CHUNK | (takePassengers ? Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS : 0L),
|
||||
53
patches/server/0020-Petal-Reduce-sensor-work.patch
Normal file
53
patches/server/0020-Petal-Reduce-sensor-work.patch
Normal file
@@ -0,0 +1,53 @@
|
||||
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 ef5cd008de4d145b67c70e48ae21ea969aedb1f0..8345d8431e1c05639f14919b9bad1029249a5f50 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -983,12 +983,12 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti
|
||||
return;
|
||||
}
|
||||
// Paper end - Allow nerfed mobs to jump and float
|
||||
+ int i = this.tickCount + this.getId(); //Luminol - Petal - Move up
|
||||
ProfilerFiller gameprofilerfiller = this.level().getProfiler();
|
||||
|
||||
gameprofilerfiller.push("sensing");
|
||||
- this.sensing.tick();
|
||||
+ if (i % me.earthme.luminol.config.modules.optimizations.PetalReduceSensorWorkConfig.delayTicks == 0 || !me.earthme.luminol.config.modules.optimizations.PetalReduceSensorWorkConfig.enabled) this.sensing.tick(); // Luminol - Petal - Reduce sensor work
|
||||
gameprofilerfiller.pop();
|
||||
- int i = this.tickCount + this.getId();
|
||||
|
||||
if (i % 2 != 0 && this.tickCount > 1) {
|
||||
gameprofilerfiller.push("targetSelector");
|
||||
@@ -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 8f91b7f44baaf62b829a81afc0633311e6c13f19..a149d98be7b4744f18d4ed4940881e13a76e4a7c 100644
|
||||
index bb915f30997059f22c9002b1ddc1c3aecbf4e979..2034c67f5702b7b8d093ef2dd7601901c5fef363 100644
|
||||
--- a/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
+++ b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
@@ -213,7 +213,7 @@ public final class MCUtil {
|
||||
@@ -215,7 +215,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: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16:00:17 +0800
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sun, 14 Jan 2024 00:40:35 +0000
|
||||
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 cb32a3851a315f1f1b4fb6d26fdffbcb471bfc06..3c9ec0f5fef49b0abc42382551de11ab942b3b20 100644
|
||||
index 643631e11c88285f33d050bf7b4b1e2f63b5c992..94c9f407f526b2d43cf61725b414b113de03c67d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -308,7 +308,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
@@ -312,7 +312,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
public double yo;
|
||||
public double zo;
|
||||
private Vec3 position;
|
||||
@@ -18,18 +18,10 @@ index cb32a3851a315f1f1b4fb6d26fdffbcb471bfc06..3c9ec0f5fef49b0abc42382551de11ab
|
||||
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 82996d0c2891871bd6ef9ff81aef123add08ebda..51dee7adc0dc534fac66bf3e8709865157dd763b 100644
|
||||
index a7c0527dd7a8cc30bb42e7ce1342b3f11862ee81..89ff6f509a59b484977ffbdb4e4132a46ca4bbaa 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;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
-import co.aikar.timings.MinecraftTimings; // Paper
|
||||
|
||||
public abstract class LivingEntity extends Entity implements Attackable {
|
||||
|
||||
@@ -2006,6 +2005,20 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -2069,6 +2069,20 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
return this.lastClimbablePos;
|
||||
}
|
||||
|
||||
@@ -51,15 +43,15 @@ index 82996d0c2891871bd6ef9ff81aef123add08ebda..51dee7adc0dc534fac66bf3e87098651
|
||||
if (this.isSpectator()) {
|
||||
return false;
|
||||
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
index d88988200016c1a3cc76c017dfb7deabf6fc17af..22daed525b023998a05884db603e2c7385ce0873 100644
|
||||
index 4fc4690d03fd5f39e019f16845954052210c7361..c77beef9651aa2f7333d536e8ff4af3281834619 100644
|
||||
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
||||
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
@@ -305,7 +305,7 @@ public class ActivationRange
|
||||
@@ -307,7 +307,7 @@ public class ActivationRange
|
||||
if ( entity instanceof LivingEntity )
|
||||
{
|
||||
LivingEntity living = (LivingEntity) entity;
|
||||
- if ( living.onClimbable() || living.jumping || living.hurtTime > 0 || living.activeEffects.size() > 0 ) // Paper
|
||||
+ if ( living.onClimableCached() || living.jumping || living.hurtTime > 0 || living.activeEffects.size() > 0 ) // Paper // Pufferfish - use cached
|
||||
- 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
|
||||
{
|
||||
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 e21f4c5aff3a8e97101f6efc1349fbecf326b5ea..c55f51e6db55f9fa66f53eef0e7a56af5f81d742 100644
|
||||
index c2943d892b067b3f1fb3b93301a092e912d71f08..58296b67f80587af485b0068e461cfd3d8d6f96f 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 e21f4c5aff3a8e97101f6efc1349fbecf326b5ea..c55f51e6db55f9fa66f53eef0e7a56af
|
||||
private final Map<FluidState, VoxelShape> shapes = Maps.newIdentityHashMap();
|
||||
|
||||
public FlowingFluid() {}
|
||||
@@ -252,6 +262,8 @@ public abstract class FlowingFluid extends Fluid {
|
||||
@@ -251,6 +261,8 @@ public abstract class FlowingFluid extends Fluid {
|
||||
return false;
|
||||
}
|
||||
// Paper end - optimise collisions
|
||||
@@ -183,7 +183,7 @@ index e21f4c5aff3a8e97101f6efc1349fbecf326b5ea..c55f51e6db55f9fa66f53eef0e7a56af
|
||||
Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap;
|
||||
|
||||
if (!state.getBlock().hasDynamicShape() && !fromState.getBlock().hasDynamicShape()) {
|
||||
@@ -259,9 +271,16 @@ public abstract class FlowingFluid extends Fluid {
|
||||
@@ -258,9 +270,16 @@ public abstract class FlowingFluid extends Fluid {
|
||||
} else {
|
||||
object2bytelinkedopenhashmap = null;
|
||||
}
|
||||
@@ -200,7 +200,7 @@ index e21f4c5aff3a8e97101f6efc1349fbecf326b5ea..c55f51e6db55f9fa66f53eef0e7a56af
|
||||
if (object2bytelinkedopenhashmap != null) {
|
||||
block_a = new Block.BlockStatePairKey(state, fromState, face);
|
||||
byte b0 = object2bytelinkedopenhashmap.getAndMoveToFirst(block_a);
|
||||
@@ -272,11 +291,22 @@ public abstract class FlowingFluid extends Fluid {
|
||||
@@ -271,11 +290,22 @@ public abstract class FlowingFluid extends Fluid {
|
||||
} else {
|
||||
block_a = null;
|
||||
}
|
||||
@@ -223,7 +223,7 @@ index e21f4c5aff3a8e97101f6efc1349fbecf326b5ea..c55f51e6db55f9fa66f53eef0e7a56af
|
||||
if (object2bytelinkedopenhashmap != null) {
|
||||
if (object2bytelinkedopenhashmap.size() == 200) {
|
||||
object2bytelinkedopenhashmap.removeLastByte();
|
||||
@@ -284,6 +314,11 @@ public abstract class FlowingFluid extends Fluid {
|
||||
@@ -283,6 +313,11 @@ public abstract class FlowingFluid extends Fluid {
|
||||
|
||||
object2bytelinkedopenhashmap.putAndMoveToFirst(block_a, (byte) (flag ? 1 : 0));
|
||||
}
|
||||
@@ -1,43 +1,40 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16:05:32 +0800
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 04:55:43 +0000
|
||||
Subject: [PATCH] Pufferfish Optimize suffocation
|
||||
|
||||
|
||||
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/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/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 51dee7adc0dc534fac66bf3e8709865157dd763b..f13d26b280f095d006ffccb36af66bb7487cb8da 100644
|
||||
index 89ff6f509a59b484977ffbdb4e4132a46ca4bbaa..2a7172c987812347e308ae1ed86b3fd430ef04e9 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -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 {
|
||||
@@ -442,7 +442,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
boolean flag = this instanceof net.minecraft.world.entity.player.Player;
|
||||
|
||||
if (!this.level().isClientSide) {
|
||||
@@ -46,7 +43,7 @@ index 51dee7adc0dc534fac66bf3e8709865157dd763b..f13d26b280f095d006ffccb36af66bb7
|
||||
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();
|
||||
@@ -1410,6 +1412,19 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -1450,6 +1450,19 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
return this.getHealth() <= 0.0F;
|
||||
}
|
||||
|
||||
@@ -59,7 +56,7 @@ index 51dee7adc0dc534fac66bf3e8709865157dd763b..f13d26b280f095d006ffccb36af66bb7
|
||||
+ }
|
||||
+
|
||||
+ public boolean shouldCheckForSuffocation() {
|
||||
+ return !LuminolConfig.enableSuffocationOptimization || (tickCount % 10 == 0 && couldPossiblyBeHurt(1.0F));
|
||||
+ return !me.earthme.luminol.config.modules.optimizations.SuffocationOptimizationConfig.enabled || (tickCount % 10 == 0 && couldPossiblyBeHurt(1.0F));
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
+
|
||||
@@ -67,10 +64,10 @@ index 51dee7adc0dc534fac66bf3e8709865157dd763b..f13d26b280f095d006ffccb36af66bb7
|
||||
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 1e07febcf7a3dfb281728cc5e3e4f15dd776d7e0..c65ab566c6241dd6a44bd11a449ef0c4b2f6dc65 100644
|
||||
index 7ddca52f7fe3f289b4b867e134326b1ead1a2aee..5040b1a7125dd9647a98fd812f558ec3a2171092 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
|
||||
@@ -154,6 +154,13 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob
|
||||
this.bossEvent.setName(this.getDisplayName());
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16:07:30 +0800
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Tue, 6 Feb 2024 03:17:39 +0000
|
||||
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 c157309ac78e7af084d3acb6e8b2bcd469a39d5e..ac5e5676b194a2a99e5cf53eb89c1152cac963b8 100644
|
||||
index d2f0c3b26d4beedb49d86e0242d843590d469d02..c55fe31f3fc1c9ccb949c6bfb64e1bd6f37b8356 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
|
||||
@@ -75,9 +75,18 @@ public class TargetingConditions {
|
||||
@@ -76,9 +76,18 @@ public class TargetingConditions {
|
||||
}
|
||||
|
||||
if (this.range > 0.0D) {
|
||||
- double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0D;
|
||||
- double e = Math.max((this.useFollowRange ? this.getFollowRange(baseEntity) : this.range) * d, 2.0D); // Paper
|
||||
if (this.range > 0.0) {
|
||||
- double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0;
|
||||
- double e = Math.max((this.useFollowRange ? this.getFollowRange(baseEntity) : this.range) * d, 2.0); // Paper - Fix MC-145656
|
||||
+ // Pufferfish start - check range before getting visibility
|
||||
+ // d = invisibility percent, e = follow range adjusted for invisibility, f = distance
|
||||
double f = baseEntity.distanceToSqr(targetEntity.getX(), targetEntity.getY(), targetEntity.getZ());
|
||||
@@ -23,8 +23,8 @@ index c157309ac78e7af084d3acb6e8b2bcd469a39d5e..ac5e5676b194a2a99e5cf53eb89c1152
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0D;
|
||||
+ double e = Math.max((followRangeRaw) * d, 2.0D); // Paper
|
||||
+ double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0;
|
||||
+ double e = Math.max((followRangeRaw) * d, 2.0D); // Paper - Fix MC-145656
|
||||
+ // Pufferfish end
|
||||
if (f > e * e) {
|
||||
return false;
|
||||
@@ -5,10 +5,10 @@ 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 bd5996eef2d946e9d7765b6b315bc5951158810e..0d51f435f18f3f9d59a3241a0b7fa1c4af841b72 100644
|
||||
index 260202fab3ac300552c557b44dcf251f083c6a78..9cf4e2f309e182c69e9592ac606c0ae85a1200b6 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 {
|
||||
@@ -318,11 +318,17 @@ public class EnderMan extends Monster implements NeutralMob {
|
||||
private boolean teleport(double x, double y, double z) {
|
||||
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(x, y, z);
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16:09:27 +0800
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Tue, 6 Feb 2024 03:21:56 +0000
|
||||
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 34f319ad09276c6f68dde449c79351de0d7d86f5..a719af0b512d9ef243d0d54f3b744b1b1a5f2772 100644
|
||||
index aee0147649d458b87d92496eda0c1723ebe570d2..89e9ea999d2fbd81a1d74382ef3fcd675fc8b94e 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
|
||||
@@ -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) {
|
||||
@@ -121,6 +121,7 @@ public abstract class MoveToBlockGoal extends Goal {
|
||||
for (int m = 0; m <= l; m = m > 0 ? -m : 1 - m) {
|
||||
for (int n = m < l && m > -l ? l : 0; n <= l; n = n > 0 ? -n : 1 - n) {
|
||||
mutableBlockPos.setWithOffset(blockPos, m, k - 1, n);
|
||||
+ if (!this.mob.level().hasChunkAt(mutableBlockPos)) continue; // Pufferfish - if this block isn't loaded, continue
|
||||
if (this.mob.isWithinRestriction(mutableBlockPos) && this.isValidTarget(this.mob.level(), mutableBlockPos)) {
|
||||
this.blockPos = mutableBlockPos;
|
||||
setTargetPosition(mutableBlockPos.immutable()); // Paper
|
||||
this.mob.movingTarget = mutableBlockPos == BlockPos.ZERO ? null : mutableBlockPos.immutable(); // Paper
|
||||
@@ -1,87 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16: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
|
||||
@@ -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 3c9ec0f5fef49b0abc42382551de11ab942b3b20..967c7a953084dc68a0ecd4b1a0f13ead7e72cb3d 100644
|
||||
index 94c9f407f526b2d43cf61725b414b113de03c67d..94bac805d032015587e88b4de3cf7064a534e736 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -5132,16 +5132,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
@@ -5317,16 +5317,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
|
||||
public boolean updateFluidHeightAndDoFluidPushing(TagKey<Fluid> tag, double speed) {
|
||||
@@ -34,7 +34,7 @@ index 3c9ec0f5fef49b0abc42382551de11ab942b3b20..967c7a953084dc68a0ecd4b1a0f13ead
|
||||
double d1 = 0.0D;
|
||||
boolean flag = this.isPushedByFluid();
|
||||
boolean flag1 = false;
|
||||
@@ -5149,14 +5151,61 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
@@ -5334,14 +5336,61 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
int k1 = 0;
|
||||
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
|
||||
|
||||
@@ -102,7 +102,7 @@ index 3c9ec0f5fef49b0abc42382551de11ab942b3b20..967c7a953084dc68a0ecd4b1a0f13ead
|
||||
|
||||
if (d2 >= axisalignedbb.minY) {
|
||||
flag1 = true;
|
||||
@@ -5178,9 +5227,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
@@ -5363,9 +5412,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
// CraftBukkit end
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,7 @@ index 3c9ec0f5fef49b0abc42382551de11ab942b3b20..967c7a953084dc68a0ecd4b1a0f13ead
|
||||
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 f0de72afad4bb571153436399386a6a8a70582a6..45b7527341fcb6d24f35318cedb522646b5ee1c2 100644
|
||||
index a2a5aef769ee8bb638a5a9f3da9812fa4a85dda5..7288261b8924d08e93abecb664e2273c624a325b 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 f0de72afad4bb571153436399386a6a8a70582a6..45b7527341fcb6d24f35318cedb52264
|
||||
}
|
||||
|
||||
this.updateBlockCallback(x, y, z, iblockdata1, state); // Paper - optimise collisions
|
||||
@@ -161,6 +164,7 @@ public class LevelChunkSection {
|
||||
if (fluid.isRandomlyTicking()) {
|
||||
this.tickingFluidCount = (short) (this.tickingFluidCount + 1);
|
||||
}
|
||||
@@ -162,6 +165,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,21 +5,10 @@ Subject: [PATCH] Pufferfish Only check for spooky season once an hour
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ambient/Bat.java b/src/main/java/net/minecraft/world/entity/ambient/Bat.java
|
||||
index 5beaa849a250ea005733250ad3edfa8382224667..2028ae6cc50d86c579ec062536e8c6339196ce09 100644
|
||||
index dc27ddf5131e7398a5390a5187261d4c7fb6ccaa..39cc49b746b0a775fde5d173dd4f712ab4a84a97 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ambient/Bat.java
|
||||
@@ -3,6 +3,10 @@ package net.minecraft.world.entity.ambient;
|
||||
import java.time.LocalDate;
|
||||
import java.time.temporal.ChronoField;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import io.papermc.paper.threadedregions.ThreadedRegionizer;
|
||||
+import io.papermc.paper.threadedregions.TickRegionScheduler;
|
||||
+import io.papermc.paper.threadedregions.TickRegions;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
@@ -237,13 +241,25 @@ public class Bat extends AmbientCreature {
|
||||
@@ -239,13 +239,25 @@ public class Bat extends AmbientCreature {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +17,8 @@ index 5beaa849a250ea005733250ad3edfa8382224667..2028ae6cc50d86c579ec062536e8c633
|
||||
+ private static final int ONE_HOUR = 20 * 60 * 60;
|
||||
+ private static int lastSpookyCheck = -ONE_HOUR;
|
||||
private static boolean isHalloween() {
|
||||
+ final ThreadedRegionizer.ThreadedRegion<TickRegions.TickRegionData, TickRegions.TickRegionSectionData> region =
|
||||
+ TickRegionScheduler.getCurrentRegion();
|
||||
+ final io.papermc.paper.threadedregions.ThreadedRegionizer.ThreadedRegion<io.papermc.paper.threadedregions.TickRegions.TickRegionData, io.papermc.paper.threadedregions.TickRegions.TickRegionSectionData> region =
|
||||
+ io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegion();
|
||||
+ final long tickCount = region.getData().getCurrentTick();
|
||||
+ if (tickCount - lastSpookyCheck > ONE_HOUR) {
|
||||
LocalDate localdate = LocalDate.now();
|
||||
@@ -44,5 +33,5 @@ index 5beaa849a250ea005733250ad3edfa8382224667..2028ae6cc50d86c579ec062536e8c633
|
||||
}
|
||||
+ // Pufferfish end
|
||||
|
||||
@Override
|
||||
protected float getStandingEyeHeight(Pose pose, EntityDimensions dimensions) {
|
||||
private void setupAnimationStates() {
|
||||
if (this.isResting()) {
|
||||
@@ -1,78 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16:35:37 +0800
|
||||
Subject: [PATCH] Pufferfish Reduce projectile chunk loading
|
||||
|
||||
|
||||
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;
|
||||
+ public static int maxProjectileLoadsPerProjectile;
|
||||
|
||||
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 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;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import io.papermc.paper.threadedregions.TickRegionScheduler;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
@@ -44,6 +46,36 @@ public abstract class Projectile extends Entity implements TraceableEntity {
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
+ // Pufferfish start
|
||||
+ private static long loadedThisTick = 0;
|
||||
+ private static long loadedTick;
|
||||
+
|
||||
+ private int loadedLifetime = 0;
|
||||
+ @Override
|
||||
+ public void setPos(double x, double y, double z) {
|
||||
+ long currentTick = TickRegionScheduler.getCurrentRegion().getData().getCurrentTick();
|
||||
+ if (loadedTick != currentTick) {
|
||||
+ loadedTick = currentTick;
|
||||
+ loadedThisTick = 0;
|
||||
+ }
|
||||
+ int previousX = Mth.floor(this.getX()) >> 4, previousZ = Mth.floor(this.getZ()) >> 4;
|
||||
+ int newX = Mth.floor(x) >> 4, newZ = Mth.floor(z) >> 4;
|
||||
+ if (previousX != newX || previousZ != newZ) {
|
||||
+ boolean isLoaded = ((net.minecraft.server.level.ServerChunkCache) this.level().getChunkSource()).getChunkAtIfLoadedMainThread(newX, newZ) != null;
|
||||
+ if (!isLoaded) {
|
||||
+ if (Projectile.loadedThisTick > me.earthme.luminol.LuminolConfig.maxProjectileLoadsPerTick) {
|
||||
+ if (++this.loadedLifetime > me.earthme.luminol.LuminolConfig.maxProjectileLoadsPerProjectile) {
|
||||
+ this.discard();
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ Projectile.loadedThisTick++;
|
||||
+ }
|
||||
+ }
|
||||
+ super.setPos(x, y, z);
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
+
|
||||
public void setOwner(@Nullable Entity entity) {
|
||||
if (entity != null) {
|
||||
this.ownerUUID = entity.getUUID();
|
||||
79
patches/server/0030-Pufferfish-Entity-TTL.patch
Normal file
79
patches/server/0030-Pufferfish-Entity-TTL.patch
Normal file
@@ -0,0 +1,79 @@
|
||||
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 94bac805d032015587e88b4de3cf7064a534e736..5caa390a167c770f657f142fe3355d127fc95cce 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -856,6 +856,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
|
||||
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 a2f0fb8b4057bd3a84d18298e49c4d02955240d3..aa2bb97ef305ed234a11b05e665ac1062b571591 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
@@ -325,6 +325,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
|
||||
private final EntityDimensions dimensions;
|
||||
private final float spawnDimensionsScale;
|
||||
private final FeatureFlagSet requiredFeatures;
|
||||
+ public int ttl = -1; // Pufferfish
|
||||
|
||||
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
|
||||
@@ -0,0 +1,75 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 05:45:24 +0000
|
||||
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")
|
||||
+ 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";
|
||||
+ }
|
||||
+}
|
||||
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 a8d2f7a9d0bcb6db0b38ac30b098d59951053b47..77eee09a301a838f21834319d4962eba1c8dcbed 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
@@ -46,6 +46,36 @@ public abstract class Projectile extends Entity implements TraceableEntity {
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
+ // Pufferfish start
|
||||
+ private static long loadedThisTick = 0;
|
||||
+ private static long loadedTick;
|
||||
+
|
||||
+ private int loadedLifetime = 0;
|
||||
+ @Override
|
||||
+ public void setPos(double x, double y, double z) {
|
||||
+ long currentTick = io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegion().getData().getCurrentTick();
|
||||
+ if (loadedTick != currentTick) {
|
||||
+ loadedTick = currentTick;
|
||||
+ loadedThisTick = 0;
|
||||
+ }
|
||||
+ int previousX = Mth.floor(this.getX()) >> 4, previousZ = Mth.floor(this.getZ()) >> 4;
|
||||
+ int newX = Mth.floor(x) >> 4, newZ = Mth.floor(z) >> 4;
|
||||
+ if (previousX != newX || previousZ != newZ) {
|
||||
+ boolean isLoaded = ((net.minecraft.server.level.ServerChunkCache) this.level().getChunkSource()).getChunkAtIfLoadedMainThread(newX, newZ) != null;
|
||||
+ if (!isLoaded) {
|
||||
+ if (Projectile.loadedThisTick > me.earthme.luminol.config.modules.optimizations.ProjectileChunkReduceConfig.maxProjectileLoadsPerTick) {
|
||||
+ if (++this.loadedLifetime > me.earthme.luminol.config.modules.optimizations.ProjectileChunkReduceConfig.maxProjectileLoadsPerProjectile) {
|
||||
+ this.discard();
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ Projectile.loadedThisTick++;
|
||||
+ }
|
||||
+ }
|
||||
+ super.setPos(x, y, z);
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
+
|
||||
public void setOwner(@Nullable Entity entity) {
|
||||
if (entity != null) {
|
||||
this.ownerUUID = entity.getUUID();
|
||||
@@ -1,93 +1,80 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16:44:23 +0800
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 05:56:56 +0000
|
||||
Subject: [PATCH] Pufferfish Dynamic Activation of Brain
|
||||
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
+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 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 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 static int startDistanceSquared;
|
||||
+ public static int maximumActivationPrio;
|
||||
+ @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 activationDistanceMod;
|
||||
+ @ConfigInfo(baseName = "blacklisted-entities")
|
||||
+ public static List<String> blackedEntities = Collections.emptyList();
|
||||
+
|
||||
|
||||
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 EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.OPTIMIZATIONS;
|
||||
+ }
|
||||
+
|
||||
+ @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
|
||||
+ }
|
||||
+ get("optimizations.dab.blacklisted-entities",Collections.<String>emptyList(), "A list of entities to ignore for activation")
|
||||
+ .forEach(name -> EntityType.byString(name).ifPresentOrElse(entityType -> {
|
||||
+
|
||||
+ blackedEntities.forEach(name -> EntityType.byString(name).ifPresentOrElse(entityType -> {
|
||||
+ entityType.dabEnabled = false;
|
||||
+ }, () -> MinecraftServer.LOGGER.warn("Unknown entity \"" + name + "\"")));
|
||||
+ }, () -> MinecraftServer.LOGGER.warn("Unknown entity \"" + name + "\"")));
|
||||
+
|
||||
+ MAIN_CONFIG.setComment("optimizations.dab", "Optimizes entity brains when\n"+"they're far away from the player");
|
||||
+ 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 561681deaf647277ecde64eed4cfbd9f38b5fed1..2ba86122ccb444908c35ea5cc1e245f5068a054a 100644
|
||||
index 6b8cbf681203c20eebb214c5c0b0fe0374aa30dc..12c46e7a3f6a8675921d95dee97ece4a83252282 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -982,6 +982,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
@@ -994,6 +994,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
|
||||
@@ -96,26 +83,26 @@ index 561681deaf647277ecde64eed4cfbd9f38b5fed1..2ba86122ccb444908c35ea5cc1e245f5
|
||||
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 8bdaab46c2e128aa58d13101170ce358146377a8..56efbcc29adca0239ef09a269f0899a3a6e2801b 100644
|
||||
index 5caa390a167c770f657f142fe3355d127fc95cce..18c6fe66fa944f5e5b7892df4d8fef4c7346d3bc 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -436,6 +436,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
return this.originWorld;
|
||||
}
|
||||
// Paper end
|
||||
+ // Pufferfish start
|
||||
@@ -483,6 +483,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
|
||||
// Folia - region ticking
|
||||
// Paper end - optimise entity tracking
|
||||
+ //Pufferfish start
|
||||
+ public boolean activatedPriorityReset = false; // DAB
|
||||
+ public int activatedPriority = LuminolConfig.maximumActivationPrio; // golf score
|
||||
+ public int activatedPriority = me.earthme.luminol.config.modules.optimizations.EntityDABConfig.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 4d60ac50a1d3860f2a2e9265aef9507d790220a3..0867c85964952ec118ea7517cd5ef570be1ee982 100644
|
||||
index aa2bb97ef305ed234a11b05e665ac1062b571591..29699e51b3e791a1a82a19c95fd6a3f30bac75d5 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
@@ -301,6 +301,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
|
||||
@@ -316,6 +316,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
|
||||
private final boolean canSpawnFarFromPlayer;
|
||||
private final int clientTrackingRange;
|
||||
private final int updateInterval;
|
||||
@@ -124,10 +111,10 @@ index 4d60ac50a1d3860f2a2e9265aef9507d790220a3..0867c85964952ec118ea7517cd5ef570
|
||||
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 d3f8aa29b05a3813c0ec6e2ea5a253868abd6b07..54e821351e46d25e8b0ead52d2c8dfecd1957544 100644
|
||||
index 8345d8431e1c05639f14919b9bad1029249a5f50..208f0995479df5741ff780df607451f27c6f91af 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -234,10 +234,10 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||
@@ -249,10 +249,10 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
super.inactiveTick();
|
||||
@@ -140,60 +127,52 @@ index d3f8aa29b05a3813c0ec6e2ea5a253868abd6b07..54e821351e46d25e8b0ead52d2c8dfec
|
||||
this.targetSelector.tick();
|
||||
}
|
||||
}
|
||||
@@ -934,16 +934,20 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||
@@ -992,16 +992,20 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti
|
||||
|
||||
if (i % 2 != 0 && this.tickCount > 1) {
|
||||
this.level().getProfiler().push("targetSelector");
|
||||
gameprofilerfiller.push("targetSelector");
|
||||
+ if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
||||
this.targetSelector.tickRunningGoals(false);
|
||||
this.level().getProfiler().pop();
|
||||
this.level().getProfiler().push("goalSelector");
|
||||
gameprofilerfiller.pop();
|
||||
gameprofilerfiller.push("goalSelector");
|
||||
+ if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
||||
this.goalSelector.tickRunningGoals(false);
|
||||
this.level().getProfiler().pop();
|
||||
gameprofilerfiller.pop();
|
||||
} else {
|
||||
this.level().getProfiler().push("targetSelector");
|
||||
gameprofilerfiller.push("targetSelector");
|
||||
+ if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
||||
this.targetSelector.tick();
|
||||
this.level().getProfiler().pop();
|
||||
this.level().getProfiler().push("goalSelector");
|
||||
gameprofilerfiller.pop();
|
||||
gameprofilerfiller.push("goalSelector");
|
||||
+ if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
||||
this.goalSelector.tick();
|
||||
this.level().getProfiler().pop();
|
||||
gameprofilerfiller.pop();
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
||||
index b738ee2d3801fadfd09313f05ae24593e56b0ec6..9306ab8d2b6eeb73f86d4d94c0065d461905d702 100644
|
||||
index 74d4f653d5c7f1923c59019effd78337402f7025..73f2a527d18f61db97d5b5050ebe67822771cf58 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
|
||||
@@ -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 {
|
||||
@@ -43,9 +43,13 @@ public class GoalSelector {
|
||||
}
|
||||
|
||||
// Paper start
|
||||
- public boolean inactiveTick() {
|
||||
+ public boolean inactiveTick(int tickRate, boolean inactive) { // Pufferfish start
|
||||
+ if (inactive && !LuminolConfig.dearEnabled) tickRate = 4; // reset to Paper's
|
||||
+ tickRate = Math.min(tickRate, this.newGoalRate);
|
||||
+ if (inactive && !me.earthme.luminol.config.modules.optimizations.EntityDABConfig.dearEnabled) tickRate = 4; // reset to Paper's
|
||||
+ tickRate = Math.min(tickRate, 3);
|
||||
this.curRate++;
|
||||
- return this.curRate % this.newGoalRate == 0;
|
||||
+ return this.curRate % tickRate == 0;
|
||||
- return this.curRate % 3 == 0; // TODO newGoalRate was already unused in 1.20.4, check if this is correct
|
||||
+ //return this.curRate % 3 == 0; // TODO newGoalRate was already unused in 1.20.4, check if this is correct
|
||||
+ return this.curRate % tickRate == 0; // Luminol - Waiting Paper
|
||||
+ // Pufferfish end
|
||||
}
|
||||
public boolean hasTasks() {
|
||||
for (WrappedGoal task : this.availableGoals) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java
|
||||
index 5ad5f22e5aa26445e5eb229958e7bf356bdd460e..d241ca4d0295f9fce39c11197bd435cfac7f6e54 100644
|
||||
index 991e3274091c4e25eebc6debd44653e5b566eedb..789d3469ce4983868e4b880b6053bd2d8c33a10a 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java
|
||||
@@ -221,9 +221,11 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS
|
||||
@@ -215,9 +215,11 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS
|
||||
return 0.4F;
|
||||
}
|
||||
|
||||
@@ -206,10 +185,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 d5b97d4316390028f54aa9bb9fa52b0b003e32a0..b4793b88688bd568a428aa520e880f0038de45a7 100644
|
||||
index a8cc6ddbf45370fe632e5c5fb7ceef3d299e62a4..98766696556b520cf565ccadc8dba207832b4ae3 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
|
||||
@@ -280,9 +280,11 @@ public class Axolotl extends Animal implements LerpingModel, VariantHolder<Axolo
|
||||
@@ -268,9 +268,11 @@ public class Axolotl extends Animal implements LerpingModel, VariantHolder<Axolo
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -222,11 +201,11 @@ index d5b97d4316390028f54aa9bb9fa52b0b003e32a0..b4793b88688bd568a428aa520e880f00
|
||||
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 5000ebc5f19dee72a86360062b822aecd60beb47..c8e3d47b3f2dc919cca8ad397095437f1da6c762 100644
|
||||
index 816977990639ec0559b652fc9666afd5046f0a5d..714703519965e8dae42be7442f292b581cc7c049 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
@@ -164,9 +164,11 @@ public class Frog extends Animal implements VariantHolder<FrogVariant> {
|
||||
return true;
|
||||
@@ -181,9 +181,11 @@ public class Frog extends Animal implements VariantHolder<Holder<FrogVariant>> {
|
||||
.ifPresent(this::setVariant);
|
||||
}
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@@ -238,10 +217,10 @@ index 5000ebc5f19dee72a86360062b822aecd60beb47..c8e3d47b3f2dc919cca8ad397095437f
|
||||
this.level().getProfiler().pop();
|
||||
this.level().getProfiler().push("frogActivityUpdate");
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java b/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||
index 4aeab90e778629c355189dfe79c39c4b21f5f5ac..6ed4ac06c76b8d0d6e8db778cade15dbd1e3e5f5 100644
|
||||
index 290d41136f5ec7671bc4990dfe50da0a770c124d..0d34e9e0f7ce35c3c28a9216cf3cdd5eddfe90f6 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||
@@ -77,9 +77,11 @@ public class Tadpole extends AbstractFish {
|
||||
@@ -83,9 +83,11 @@ public class Tadpole extends AbstractFish {
|
||||
return SoundEvents.TADPOLE_FLOP;
|
||||
}
|
||||
|
||||
@@ -254,10 +233,10 @@ 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 111a244087e24f25ba8524a46a228da10cd9498a..ff12ba2b79cb2e7e0bfd0e3b58ff6cb9e770092b 100644
|
||||
index 02e49c7ae5e120302b6479cf3e3934b9217eebf0..81c9f1c2895adedec246732df9f9dadddfa5f345 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
@@ -191,9 +191,11 @@ public class Goat extends Animal {
|
||||
@@ -190,9 +190,11 @@ public class Goat extends Animal {
|
||||
return (Brain<Goat>) super.getBrain(); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@@ -270,11 +249,11 @@ index 111a244087e24f25ba8524a46a228da10cd9498a..ff12ba2b79cb2e7e0bfd0e3b58ff6cb9
|
||||
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 4257f2282152aee09533c9a2e53018d3e49effa4..e703320717ff620a19ff76d1c10066117c9895d5 100644
|
||||
index c583d883118ded5e1884c757427dc5e73c10dd27..6f8a22c51ba5e2713dcdfc61c61b35123f9bf326 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
||||
@@ -128,9 +128,11 @@ public class Hoglin extends Animal implements Enemy, HoglinBase {
|
||||
return (Brain<Hoglin>) super.getBrain(); // Paper - decompile fix
|
||||
@@ -153,9 +153,11 @@ public class Hoglin extends Animal implements Enemy, HoglinBase {
|
||||
return (Brain<Hoglin>)super.getBrain();
|
||||
}
|
||||
|
||||
+ private int behaviorTick; // Pufferfish
|
||||
@@ -286,10 +265,10 @@ index 4257f2282152aee09533c9a2e53018d3e49effa4..e703320717ff620a19ff76d1c1006611
|
||||
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 6407ddef8442fce4f310ac4babf3e3de0dd5fc9a..cfdc1650783d6855e0d4f33ec68aab48dbee09f0 100644
|
||||
index a8ab486c7e11ec137da48174af6f1030dfd48056..5878a6ecadc2b9f7ac9f70622a8c85e2940e139a 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
|
||||
@@ -294,9 +294,11 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento
|
||||
return !this.cannotHunt;
|
||||
}
|
||||
|
||||
@@ -302,10 +281,10 @@ index 6407ddef8442fce4f310ac4babf3e3de0dd5fc9a..cfdc1650783d6855e0d4f33ec68aab48
|
||||
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 b2bc3a832c310448046ccde37a04918aa6d63197..5e43912708f9074dee1bb351efa737a7e6796fc3 100644
|
||||
index ddd60be52dce5773c80934be5aa5705db239e3dd..9cf56f2ada025aae0710099bcc3b5c62fd7bbb9e 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
|
||||
@@ -272,11 +272,13 @@ public class Warden extends Monster implements VibrationSystem {
|
||||
@@ -271,11 +271,13 @@ public class Warden extends Monster implements VibrationSystem {
|
||||
|
||||
}
|
||||
|
||||
@@ -320,10 +299,10 @@ index b2bc3a832c310448046ccde37a04918aa6d63197..5e43912708f9074dee1bb351efa737a7
|
||||
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 4e9ccc518f37755e86687653f7724240db754682..a94661deaa6e1288bb957dc5d7711c5d03b9e460 100644
|
||||
index 6339967b154af1ca9632c7b8b315d612f4b80ea2..c4b7fd6c9d0f26361295a70d63f6fc080063d129 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
|
||||
@@ -143,6 +143,8 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
return holder.is(PoiTypes.MEETING);
|
||||
});
|
||||
|
||||
@@ -332,7 +311,7 @@ index 4e9ccc518f37755e86687653f7724240db754682..a94661deaa6e1288bb957dc5d7711c5d
|
||||
public Villager(EntityType<? extends Villager> entityType, Level world) {
|
||||
this(entityType, world, VillagerType.PLAINS);
|
||||
}
|
||||
@@ -245,6 +247,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -246,6 +248,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
}
|
||||
// Spigot End
|
||||
|
||||
@@ -340,7 +319,7 @@ index 4e9ccc518f37755e86687653f7724240db754682..a94661deaa6e1288bb957dc5d7711c5d
|
||||
@Override
|
||||
@Deprecated // Paper
|
||||
protected void customServerAiStep() {
|
||||
@@ -254,7 +257,11 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -255,7 +258,11 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
protected void customServerAiStep(final boolean inactive) {
|
||||
// Paper end
|
||||
this.level().getProfiler().push("villagerBrain");
|
||||
@@ -354,17 +333,10 @@ index 4e9ccc518f37755e86687653f7724240db754682..a94661deaa6e1288bb957dc5d7711c5d
|
||||
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 22daed525b023998a05884db603e2c7385ce0873..e77e1c60a611c49489c65d66e54236a86c3093e3 100644
|
||||
index c77beef9651aa2f7333d536e8ff4af3281834619..9628cc2b7f200e0bab4fed48997dde3e266200ee 100644
|
||||
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
||||
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
@@ -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;
|
||||
@@ -38,6 +38,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;
|
||||
@@ -375,24 +347,24 @@ index 22daed525b023998a05884db603e2c7385ce0873..e77e1c60a611c49489c65d66e54236a8
|
||||
|
||||
public class ActivationRange
|
||||
{
|
||||
@@ -230,6 +235,25 @@ public class ActivationRange
|
||||
@@ -232,6 +236,25 @@ public class ActivationRange
|
||||
}
|
||||
// Paper end - configurable marker ticking
|
||||
ActivationRange.activateEntity(entity);
|
||||
// Paper end - Configurable marker ticking
|
||||
ActivationRange.activateEntity(entity, bbByType); // Folia - threaded regions
|
||||
+
|
||||
+ // Pufferfish start
|
||||
+ if (LuminolConfig.dearEnabled && entity.getType().dabEnabled) {
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.EntityDABConfig.dearEnabled && entity.getType().dabEnabled) {
|
||||
+ if (!entity.activatedPriorityReset) {
|
||||
+ entity.activatedPriorityReset = true;
|
||||
+ entity.activatedPriority = LuminolConfig.maximumActivationPrio;
|
||||
+ entity.activatedPriority = me.earthme.luminol.config.modules.optimizations.EntityDABConfig.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 > LuminolConfig.startDistanceSquared ?
|
||||
+ Math.max(1, Math.min(squaredDistance >> LuminolConfig.activationDistanceMod, entity.activatedPriority)) :
|
||||
+ 1;
|
||||
+ 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;
|
||||
+ } else {
|
||||
+ entity.activatedPriority = 1;
|
||||
+ }
|
||||
@@ -401,7 +373,7 @@ index 22daed525b023998a05884db603e2c7385ce0873..e77e1c60a611c49489c65d66e54236a8
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
@@ -246,12 +270,12 @@ public class ActivationRange
|
||||
@@ -248,12 +271,12 @@ public class ActivationRange
|
||||
if ( io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick() > entity.activatedTick ) // Folia - threaded regions
|
||||
{
|
||||
if ( entity.defaultActivationState )
|
||||
@@ -410,7 +382,7 @@ index 22daed525b023998a05884db603e2c7385ce0873..e77e1c60a611c49489c65d66e54236a8
|
||||
entity.activatedTick = io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick(); // Folia - threaded regions
|
||||
return;
|
||||
}
|
||||
if ( entity.activationType.boundingBox.intersects( entity.getBoundingBox() ) )
|
||||
if ( bbByType[entity.activationType.ordinal()].intersects( entity.getBoundingBox() ) ) // Folia - threaded regions
|
||||
- {
|
||||
+ { // Pufferfish - diff on change
|
||||
entity.activatedTick = io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick(); // Folia - threaded regions
|
||||
@@ -0,0 +1,51 @@
|
||||
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 208f0995479df5741ff780df607451f27c6f91af..78619c2ce66c34c4866755aa8c6c9ae18d594498 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -245,11 +245,13 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti
|
||||
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
|
||||
@@ -1,90 +0,0 @@
|
||||
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,31 @@
|
||||
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 9ef8f014af332da129bfcd3370da983ec035ecc6..bc178967affd21ad04b83ea26639a2dd9b497454 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
|
||||
@@ -22,9 +22,11 @@ public class AttributeMap {
|
||||
private final Map<Holder<Attribute>, AttributeInstance> attributes = new Object2ObjectOpenHashMap<>();
|
||||
private final Set<AttributeInstance> dirtyAttributes = new ObjectOpenHashSet<>();
|
||||
private final AttributeSupplier supplier;
|
||||
+ private final java.util.function.Function<Holder<Attribute>, AttributeInstance> createInstance; // Pufferfish
|
||||
|
||||
public AttributeMap(AttributeSupplier defaultAttributes) {
|
||||
this.supplier = defaultAttributes;
|
||||
+ this.createInstance = attributex -> this.supplier.createInstance(this::onAttributeModified, attributex); // Pufferfish
|
||||
}
|
||||
|
||||
private void onAttributeModified(AttributeInstance instance) {
|
||||
@@ -43,7 +45,7 @@ public class AttributeMap {
|
||||
|
||||
@Nullable
|
||||
public AttributeInstance getInstance(Holder<Attribute> attribute) {
|
||||
- return this.attributes.computeIfAbsent(attribute, attributex -> this.supplier.createInstance(this::onAttributeModified, attributex));
|
||||
+ return this.attributes.computeIfAbsent(attribute, this.createInstance); // Pufferfish - cache lambda, as for some reason java allocates it anyways
|
||||
}
|
||||
|
||||
public boolean hasAttribute(Holder<Attribute> attribute) {
|
||||
@@ -1,24 +0,0 @@
|
||||
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,6 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16:08:46 +0800
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Mon, 25 Mar 2024 13:48:33 +0000
|
||||
Subject: [PATCH] Pufferfish Improve container checking with a bitset
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ index 241fec02e6869c638d3a160819b32173a081467b..6a8f9e8f5bf108674c47018def28906e
|
||||
public int getContainerSize() {
|
||||
return this.container1.getContainerSize() + this.container2.getContainerSize();
|
||||
diff --git a/src/main/java/net/minecraft/world/Container.java b/src/main/java/net/minecraft/world/Container.java
|
||||
index d6cbe98e67fdbf8db46338a88ab1356dd63b50a3..20dd3a63b2f955b05a75eb240e33ae4cf6aef28f 100644
|
||||
index f402dbbfe3a443e6bc51f88b85abe937852b52f0..541cb29a10e2c87a8214ff5beadb71bc1922d353 100644
|
||||
--- a/src/main/java/net/minecraft/world/Container.java
|
||||
+++ b/src/main/java/net/minecraft/world/Container.java
|
||||
@@ -3,6 +3,8 @@ package net.minecraft.world;
|
||||
@@ -234,13 +234,13 @@ index d6cbe98e67fdbf8db46338a88ab1356dd63b50a3..20dd3a63b2f955b05a75eb240e33ae4c
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
|
||||
int LARGE_MAX_STACK_SIZE = 64;
|
||||
int DEFAULT_DISTANCE_LIMIT = 8;
|
||||
float DEFAULT_DISTANCE_BUFFER = 4.0F;
|
||||
|
||||
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 00187fbbeddfc17e1b6887f8bf0f50da23938470..f64edfdb03f99624daf1e05b5dc86d845c3018b6 100644
|
||||
index 2704389bc3ec6dbbf1b568a4380972f8c0d62d15..c53cdaa59da87d96e34f06185b1f73e56a5bfc6c 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;
|
||||
@@ -30,7 +30,10 @@ import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
public abstract class AbstractMinecartContainer extends AbstractMinecart implements ContainerEntity {
|
||||
|
||||
@@ -249,9 +249,9 @@ index 00187fbbeddfc17e1b6887f8bf0f50da23938470..f64edfdb03f99624daf1e05b5dc86d84
|
||||
+ private gg.airplane.structs.ItemListWithBitset itemStacksOptimized;
|
||||
+ // Pufferfish end
|
||||
@Nullable
|
||||
public ResourceLocation lootTable;
|
||||
public ResourceKey<LootTable> lootTable;
|
||||
public long lootTableSeed;
|
||||
@@ -89,12 +92,18 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||
@@ -92,12 +95,18 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||
|
||||
protected AbstractMinecartContainer(EntityType<?> type, Level world) {
|
||||
super(type, world);
|
||||
@@ -272,7 +272,7 @@ index 00187fbbeddfc17e1b6887f8bf0f50da23938470..f64edfdb03f99624daf1e05b5dc86d84
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -156,6 +165,10 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||
@@ -166,6 +175,10 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||
protected void readAdditionalSaveData(CompoundTag nbt) {
|
||||
super.readAdditionalSaveData(nbt);
|
||||
this.lootableData.loadNbt(nbt); // Paper
|
||||
@@ -280,14 +280,39 @@ index 00187fbbeddfc17e1b6887f8bf0f50da23938470..f64edfdb03f99624daf1e05b5dc86d84
|
||||
+ this.itemStacksOptimized = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize());
|
||||
+ this.itemStacks = this.itemStacksOptimized.nonNullList;
|
||||
+ // Pufferfish end
|
||||
this.readChestVehicleSaveData(nbt);
|
||||
this.readChestVehicleSaveData(nbt, this.registryAccess());
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
|
||||
index 15fd1fe1b55b6421d2c09e8385c9f69fa0152e56..21c747f00892a8372c3ef239f63d59ccaa315295 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
|
||||
@@ -119,19 +119,7 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
- Iterator iterator = this.getItems().iterator();
|
||||
-
|
||||
- ItemStack itemstack;
|
||||
-
|
||||
- do {
|
||||
- if (!iterator.hasNext()) {
|
||||
- return true;
|
||||
- }
|
||||
-
|
||||
- itemstack = (ItemStack) iterator.next();
|
||||
- } while (itemstack.isEmpty());
|
||||
-
|
||||
- return false;
|
||||
+ return this.isCompletelyEmpty(null); // Pufferfish - use super
|
||||
}
|
||||
|
||||
@Override
|
||||
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 a71414397bd45ee7bcacfeef0041d80dfa25f114..d66806565770cb03a21794f99e5c4b0f3040b26a 100644
|
||||
index b88aa184cd06a0485146f58a5b61a56a50911209..7b64c57795fe27d8397500bfa41f71f9d2103b20 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;
|
||||
@@ -32,7 +32,10 @@ import org.bukkit.entity.HumanEntity;
|
||||
public class ChestBlockEntity extends RandomizableContainerBlockEntity implements LidBlockEntity {
|
||||
|
||||
private static final int EVENT_SET_OPEN_COUNT = 1;
|
||||
@@ -298,7 +323,7 @@ index a71414397bd45ee7bcacfeef0041d80dfa25f114..d66806565770cb03a21794f99e5c4b0f
|
||||
public final ContainerOpenersCounter openersCounter;
|
||||
private final ChestLidController chestLidController;
|
||||
|
||||
@@ -65,9 +68,13 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
@@ -66,9 +69,13 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
@@ -313,7 +338,7 @@ index a71414397bd45ee7bcacfeef0041d80dfa25f114..d66806565770cb03a21794f99e5c4b0f
|
||||
this.openersCounter = new ContainerOpenersCounter() {
|
||||
@Override
|
||||
protected void onOpen(Level world, BlockPos pos, BlockState state) {
|
||||
@@ -98,6 +105,23 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
@@ -99,6 +106,23 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
this.chestLidController = new ChestLidController();
|
||||
}
|
||||
|
||||
@@ -337,46 +362,46 @@ index a71414397bd45ee7bcacfeef0041d80dfa25f114..d66806565770cb03a21794f99e5c4b0f
|
||||
public ChestBlockEntity(BlockPos pos, BlockState state) {
|
||||
this(BlockEntityType.CHEST, pos, state);
|
||||
}
|
||||
@@ -115,7 +139,10 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
@@ -116,7 +140,10 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
@Override
|
||||
public void load(CompoundTag nbt) {
|
||||
super.load(nbt);
|
||||
protected void loadAdditional(CompoundTag nbt, HolderLookup.Provider registryLookup) {
|
||||
super.loadAdditional(nbt, registryLookup);
|
||||
- this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
|
||||
+ // Pufferfish start
|
||||
+ this.optimizedItems = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize());
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Pufferfish end
|
||||
if (!this.tryLoadLootTable(nbt)) {
|
||||
ContainerHelper.loadAllItems(nbt, this.items);
|
||||
ContainerHelper.loadAllItems(nbt, this.items, registryLookup);
|
||||
}
|
||||
@@ -187,7 +214,10 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
@@ -188,7 +215,10 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
|
||||
@Override
|
||||
protected void setItems(NonNullList<ItemStack> list) {
|
||||
- this.items = list;
|
||||
protected void setItems(NonNullList<ItemStack> inventory) {
|
||||
- this.items = inventory;
|
||||
+ // Pufferfish start
|
||||
+ this.optimizedItems = gg.airplane.structs.ItemListWithBitset.fromList(list);
|
||||
+ this.optimizedItems = gg.airplane.structs.ItemListWithBitset.fromList(inventory);
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Pufferfish end
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
index 72779080969fe9f058c19533ffc9dad5f9c47086..c90d578643490709936545ee9cbd41c8671eeb7a 100644
|
||||
index 1280c358748bbb08f0361acd4ebc095bf6bc3496..957c217653a664bab26db476724d288b18d87102 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
|
||||
|
||||
public static final int MOVE_ITEM_SPEED = 8;
|
||||
public static final int HOPPER_CONTAINER_SIZE = 5;
|
||||
private static final int[][] CACHED_SLOTS = new int[54][];
|
||||
+ // Pufferfish start
|
||||
private NonNullList<ItemStack> items;
|
||||
+ private gg.airplane.structs.ItemListWithBitset optimizedItems; // Pufferfish
|
||||
+ // Pufferfish end
|
||||
private int cooldownTime;
|
||||
private long tickedGameTime;
|
||||
|
||||
@@ -83,14 +86,37 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
public int cooldownTime;
|
||||
private long tickedGameTime = Long.MIN_VALUE; // Folia - region threading
|
||||
private Direction facing;
|
||||
@@ -94,15 +97,38 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
|
||||
public HopperBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(BlockEntityType.HOPPER, pos, state);
|
||||
@@ -386,6 +411,7 @@ index 72779080969fe9f058c19533ffc9dad5f9c47086..c90d578643490709936545ee9cbd41c8
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Pufferfish end
|
||||
this.cooldownTime = -1;
|
||||
this.facing = (Direction) state.getValue(HopperBlock.FACING);
|
||||
}
|
||||
|
||||
+ // Pufferfish start
|
||||
@@ -406,38 +432,25 @@ index 72779080969fe9f058c19533ffc9dad5f9c47086..c90d578643490709936545ee9cbd41c8
|
||||
+ // Pufferfish end
|
||||
+
|
||||
@Override
|
||||
public void load(CompoundTag nbt) {
|
||||
super.load(nbt);
|
||||
protected void loadAdditional(CompoundTag nbt, HolderLookup.Provider registryLookup) {
|
||||
super.loadAdditional(nbt, registryLookup);
|
||||
- this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
|
||||
+ // Pufferfish start
|
||||
+ this.optimizedItems = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize());
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Pufferfish end
|
||||
if (!this.tryLoadLootTable(nbt)) {
|
||||
ContainerHelper.loadAllItems(nbt, this.items);
|
||||
ContainerHelper.loadAllItems(nbt, this.items, registryLookup);
|
||||
}
|
||||
@@ -493,6 +519,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
@@ -537,6 +563,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
}
|
||||
|
||||
private static boolean isFullContainer(Container inventory, Direction direction) {
|
||||
+ if (true) return inventory.isCompletelyFull(direction); // Pufferfish - use bitsets
|
||||
// Paper start - 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 start
|
||||
+ // Pufferfish start - use bitsets
|
||||
+ //return allMatch(inv, facing, IS_EMPTY_TEST);
|
||||
+ return inv.isCompletelyEmpty(facing);
|
||||
+ // Pufferfish end
|
||||
}
|
||||
|
||||
public static boolean suckInItems(Level world, Hopper hopper) {
|
||||
@@ -716,7 +747,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
int[] aint = HopperBlockEntity.getSlots(inventory, direction);
|
||||
int[] aint1 = aint;
|
||||
int i = aint.length;
|
||||
@@ -736,7 +763,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
|
||||
if (HopperBlockEntity.canPlaceItemInContainer(to, stack, slot, side)) {
|
||||
boolean flag = false;
|
||||
@@ -446,33 +459,15 @@ index 72779080969fe9f058c19533ffc9dad5f9c47086..c90d578643490709936545ee9cbd41c8
|
||||
|
||||
if (itemstack1.isEmpty()) {
|
||||
// Spigot start - SPIGOT-6693, InventorySubcontainer#setItem
|
||||
@@ -911,7 +942,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
@@ -924,7 +951,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
|
||||
@Override
|
||||
protected void setItems(NonNullList<ItemStack> list) {
|
||||
- this.items = list;
|
||||
protected void setItems(NonNullList<ItemStack> inventory) {
|
||||
- this.items = inventory;
|
||||
+ // Pufferfish start
|
||||
+ this.optimizedItems = gg.airplane.structs.ItemListWithBitset.fromList(list);
|
||||
+ this.optimizedItems = gg.airplane.structs.ItemListWithBitset.fromList(inventory);
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Pufferfish end
|
||||
}
|
||||
|
||||
public static void entityInside(Level world, BlockPos pos, BlockState state, Entity entity, HopperBlockEntity blockEntity) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
index 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
|
||||
@@ -96,12 +96,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
|
||||
public boolean isEmpty() {
|
||||
this.unpackLootTable((Player)null);
|
||||
// Paper start
|
||||
- for (final ItemStack itemStack : this.getItems()) {
|
||||
- if (!itemStack.isEmpty()) {
|
||||
- return false;
|
||||
- }
|
||||
- }
|
||||
- return true;
|
||||
+ return this.isCompletelyEmpty(null); // Pufferfish - use super
|
||||
// Paper end
|
||||
}
|
||||
|
||||
@@ -1,34 +1,40 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 17:08:22 +0800
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 06:00:22 +0000
|
||||
Subject: [PATCH] Gale Variable entity wake-up duration
|
||||
|
||||
|
||||
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;
|
||||
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")
|
||||
+ public static double entityWakeUpDurationRatioStandardDeviation = 0.2;
|
||||
|
||||
|
||||
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){
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.OPTIMIZATIONS;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "variable_entity_waking_up";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
index e77e1c60a611c49489c65d66e54236a86c3093e3..51adf24b9274b6bc78ef94e77a0b2d73b1f2bbbb 100644
|
||||
index 9628cc2b7f200e0bab4fed48997dde3e266200ee..3a6ae320891f1e3202c59b63a5f2c96c18727314 100644
|
||||
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
||||
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
@@ -76,28 +76,40 @@ public class ActivationRange
|
||||
@@ -75,28 +75,41 @@ public class ActivationRange
|
||||
if (entity.activationType == ActivationType.VILLAGER) {
|
||||
if (inactiveFor > config.wakeUpInactiveVillagersEvery && worldData.wakeupInactiveRemainingVillagers > 0) { // Folia - threaded regions
|
||||
worldData.wakeupInactiveRemainingVillagers--; // Folia - threaded regions
|
||||
@@ -59,10 +65,10 @@ index e77e1c60a611c49489c65d66e54236a86c3093e3..51adf24b9274b6bc78ef94e77a0b2d73
|
||||
// Paper end
|
||||
|
||||
+ // Gale start - variable entity wake-up duration
|
||||
+ private static final java.util.Random wakeUpDurationRandom = new java.util.Random();
|
||||
+ private static final java.util.concurrent.ThreadLocalRandom wakeUpDurationRandom = java.util.concurrent.ThreadLocalRandom.current();
|
||||
+
|
||||
+ private static int getWakeUpDurationWithVariance(Entity entity, int wakeUpDuration) {
|
||||
+ double deviation = LuminolConfig.entityWakeUpDurationRatioStandardDeviation;
|
||||
+ double deviation = me.earthme.luminol.config.modules.optimizations.GaleVariableEntityWakeupConfig.entityWakeUpDurationRatioStandardDeviation;
|
||||
+ if (deviation <= 0) {
|
||||
+ return wakeUpDuration;
|
||||
+ }
|
||||
@@ -70,6 +76,7 @@ index e77e1c60a611c49489c65d66e54236a86c3093e3..51adf24b9274b6bc78ef94e77a0b2d73
|
||||
+ }
|
||||
+ // Gale end - variable entity wake-up duration
|
||||
+
|
||||
static AABB maxBB = new AABB( 0, 0, 0, 0, 0, 0 );
|
||||
+
|
||||
// Folia - threaded regions - replaced by local variable
|
||||
|
||||
/**
|
||||
@@ -1,44 +1,50 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 17:21:11 +0800
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 06:03:02 +0000
|
||||
Subject: [PATCH] Gale Don't load chunks to activate climbing entities
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/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/me/earthme/luminol/config/modules/optimizations/LoadChunksToActiveClimbingEntitiesConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/LoadChunksToActiveClimbingEntitiesConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ed62d25d6cd6dfcf8c5db20ced36eb3d3c79dafd
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/LoadChunksToActiveClimbingEntitiesConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.optimizations;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class LoadChunksToActiveClimbingEntitiesConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "allow")
|
||||
+ public static boolean allow = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.OPTIMIZATIONS;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "load_chunks_to_active_climbing_entities";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 56efbcc29adca0239ef09a269f0899a3a6e2801b..54daa1744c89e98136d0f594a35119d5fd3d6bc8 100644
|
||||
index 18c6fe66fa944f5e5b7892df4d8fef4c7346d3bc..a9e32fba699c718011abc52d91ec7158ab22b5ea 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -5330,6 +5330,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
return this.feetBlockState;
|
||||
@@ -5515,6 +5515,16 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
return this.inBlockState;
|
||||
}
|
||||
|
||||
+ // Gale start - don't load chunks to activate climbing entities
|
||||
+ public @Nullable BlockState getFeetBlockStateIfLoaded() {
|
||||
+ if (this.feetBlockState == null) {
|
||||
+ this.feetBlockState = this.level.getBlockStateIfLoaded(this.blockPosition());
|
||||
+ if (this.inBlockState == null) {
|
||||
+ this.inBlockState = this.level.getBlockStateIfLoaded(this.blockPosition());
|
||||
+ }
|
||||
+
|
||||
+ return this.feetBlockState;
|
||||
+ return this.inBlockState;
|
||||
+ }
|
||||
+ // Gale end - don't load chunks to activate climbing entities
|
||||
+
|
||||
@@ -46,17 +52,17 @@ index 56efbcc29adca0239ef09a269f0899a3a6e2801b..54daa1744c89e98136d0f594a35119d5
|
||||
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 f13d26b280f095d006ffccb36af66bb7487cb8da..ecbacbed29af51d949122b21c3ae9fc95885c6d8 100644
|
||||
index 2a7172c987812347e308ae1ed86b3fd430ef04e9..0eb73b666fe161fc148e0c0dc2da3362f8452187 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -2027,19 +2027,43 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -2089,19 +2089,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(LuminolConfig.loadChunksToActiveClimbingEntities);
|
||||
+ Boolean onClimbableIfLoaded = this.onClimbable(me.earthme.luminol.config.modules.optimizations.LoadChunksToActiveClimbingEntitiesConfig.allow);
|
||||
+ if (onClimbableIfLoaded != null) {
|
||||
+ this.cachedOnClimable = onClimbableIfLoaded;
|
||||
+ this.lastClimbingPosition = this.blockPosition();
|
||||
@@ -81,11 +87,11 @@ index f13d26b280f095d006ffccb36af66bb7487cb8da..ecbacbed29af51d949122b21c3ae9fc9
|
||||
return false;
|
||||
} else {
|
||||
BlockPos blockposition = this.blockPosition();
|
||||
- BlockState iblockdata = this.getFeetBlockState();
|
||||
- BlockState iblockdata = this.getInBlockState();
|
||||
+ // Gale start - don't load chunks to activate climbing entities
|
||||
+ BlockState iblockdata;
|
||||
+ if (loadChunk) {
|
||||
+ iblockdata = this.getFeetBlockState();
|
||||
+ iblockdata = this.getInBlockState();
|
||||
+ } else {
|
||||
+ iblockdata = this.getFeetBlockStateIfLoaded();
|
||||
+ if (iblockdata == null) {
|
||||
@@ -1,99 +0,0 @@
|
||||
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() {
|
||||
@@ -1,39 +0,0 @@
|
||||
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
|
||||
@@ -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 54daa1744c89e98136d0f594a35119d5fd3d6bc8..6f3e87661c3181b6537e4d6d96e50d8d5680c040 100644
|
||||
index a9e32fba699c718011abc52d91ec7158ab22b5ea..f3c1a5b5880aefd1b3121be27172735134016437 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -307,7 +307,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
@@ -311,7 +311,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
public double xo;
|
||||
public double yo;
|
||||
public double zo;
|
||||
@@ -17,7 +17,7 @@ index 54daa1744c89e98136d0f594a35119d5fd3d6bc8..6f3e87661c3181b6537e4d6d96e50d8d
|
||||
public BlockPos blockPosition; // Pufferfish - private->public
|
||||
private ChunkPos chunkPosition;
|
||||
private Vec3 deltaMovement;
|
||||
@@ -2026,9 +2026,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
@@ -2121,9 +2121,17 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
/** @deprecated */
|
||||
@Deprecated
|
||||
public float getLightLevelDependentMagicValue() {
|
||||
@@ -37,11 +37,11 @@ index 54daa1744c89e98136d0f594a35119d5fd3d6bc8..6f3e87661c3181b6537e4d6d96e50d8d
|
||||
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 54e821351e46d25e8b0ead52d2c8dfecd1957544..394913950ac8fbcfcdbce817bac95f3b6604beb7 100644
|
||||
index 78619c2ce66c34c4866755aa8c6c9ae18d594498..26362c7fa4fcc39f40c2736fd14647542e7161e2 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -1736,13 +1736,29 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||
|
||||
@@ -1869,13 +1869,29 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti
|
||||
return flag;
|
||||
}
|
||||
|
||||
+ // Gale start - JettPack - optimize sun burn tick - cache eye blockpos
|
||||
@@ -1,39 +0,0 @@
|
||||
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.");
|
||||
@@ -0,0 +1,31 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sun, 28 Jan 2024 09:30:22 +0000
|
||||
Subject: [PATCH] Gale Check frozen ticks before landing block
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 0eb73b666fe161fc148e0c0dc2da3362f8452187..bae654c209fc423cafe66f10ba35971af7579710 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -609,11 +609,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
|
||||
protected void tryAddFrost() {
|
||||
- if (!this.getBlockStateOnLegacy().isAir()) {
|
||||
int i = this.getTicksFrozen();
|
||||
|
||||
if (i > 0) {
|
||||
- AttributeInstance attributemodifiable = this.getAttribute(Attributes.MOVEMENT_SPEED);
|
||||
+ AttributeInstance attributemodifiable = this.getBlockStateOnLegacy().isAir() ? null : this.getAttribute(Attributes.MOVEMENT_SPEED); // Gale - Lithium - check frozen ticks before landing block
|
||||
|
||||
if (attributemodifiable == null) {
|
||||
return;
|
||||
@@ -623,7 +622,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.ADD_VALUE));
|
||||
}
|
||||
- }
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +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
|
||||
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 17da915ffa638500a83b67db0940a7b9a9b333a1..e47c9481f39426e1767e73275edbf9a1d298caea 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
|
||||
@@ -74,6 +74,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
|
||||
|
||||
@Override
|
||||
public void unpackLootTable(@org.jetbrains.annotations.Nullable final Player player) {
|
||||
+ if (player == null) return; // Gale - EMC - don't trigger lootable refresh for non-player interaction
|
||||
// Copied from super with changes, always check the original method
|
||||
net.minecraft.world.level.Level level = this.getLevel();
|
||||
BlockPos blockPos = this.getBlockPos();
|
||||
File diff suppressed because it is too large
Load Diff
187
patches/server/0041-Gale-Use-platform-math-functions.patch
Normal file
187
patches/server/0041-Gale-Use-platform-math-functions.patch
Normal file
@@ -0,0 +1,187 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sun, 28 Jan 2024 09:31:27 +0000
|
||||
Subject: [PATCH] Gale Use platform math functions
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
Gale - https://galemc.org
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Use Math.floor instead of fastfloor"
|
||||
By: Xymb <xymb@endcrystal.me>
|
||||
As part of: Kaiiju (https://github.com/KaiijuMC/Kaiiju)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Comparison of floor methods used in Paper *
|
||||
|
||||
Measure shown is floored number of milliseconds
|
||||
(nanoseconds integer-divided by 1_000_000
|
||||
taken to get the floor of 1000 randomly chosen doubles
|
||||
(all in the range of [-Integer.MAX_VALUE + 10, Integer.MAX_VALUE - 10])
|
||||
100_000 times (making it 100_000_000 floor operations total)
|
||||
and adding it to a total.
|
||||
|
||||
We are testing the following methods:
|
||||
* net.minecraft.util.Mth.floor
|
||||
* java.lang.Math.floor
|
||||
* java.lang.StrictMath.floor
|
||||
* org.apache.commons.math3.util.FastMath.floor
|
||||
* org.apache.commons.math3.util.FastMath.floor, but with a hot start (see comment in code)
|
||||
* io.papermc.paper.util.MCUtil.fastFloor
|
||||
|
||||
The tests performed clearly show that Math.floor is the fastest.
|
||||
This is most likely due to java.lang.Math's usage of the @IntrinsicCandidate
|
||||
annotation, which allows the JVM to use a more optimized implementation at runtime.
|
||||
However, in the case that there is no intrinsic replacement for Math.floor,
|
||||
it defers to StrictMath.floor, which relies on a number of native methods, and is
|
||||
still much faster than the existing Minecraft utility functions.
|
||||
Therefore, using Math.floor instead of these functions is better regardless.
|
||||
In Apache Commons Math 4, FastMath.floor has also been removed in favor of Math.floor.
|
||||
|
||||
The versions used:
|
||||
* Windows 10 Home 21H2 19044.3086
|
||||
* OpenJDK Runtime Environment Temurin-19.0.2+7 (build 19.0.2+7)
|
||||
* Paper a3c760e6af1e8c7244ef75c6da6e6df278a79e14 on Minecraft 1.20.1
|
||||
* Apache Commons Math 3.6.1
|
||||
|
||||
Results:
|
||||
Total is of type int Total is of type double
|
||||
----------------------------------------------------------------------------------
|
||||
Mth.floor 2113 (double) Mth.floor 2658
|
||||
(int) Math.floor 130 Math.floor 194
|
||||
(int) StrictMath.floor 835 StrictMath.floor 381
|
||||
(int) FastMath.floor 412 FastMath.floor 376
|
||||
(int) FastMath.floor with hot start 359 FastMath.floor with hot start 321
|
||||
MCUtil.fastFloor 2284 (double) MCUtil.fastFloor 2469
|
||||
|
||||
Code is below:
|
||||
```java
|
||||
package somepackage;
|
||||
|
||||
import io.papermc.paper.util.MCUtil;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// IF FastMath.floor with a hot start:
|
||||
// FastMath.floor(37485.5);
|
||||
|
||||
var random = new Random(4889338);
|
||||
int size = 1000;
|
||||
var values = new double[size];
|
||||
double bound = Integer.MAX_VALUE - 10;
|
||||
for (int i = 0; i < size; i++) {
|
||||
values[i] = random.nextDouble(bound * 2) - bound;
|
||||
}
|
||||
int repeats = 100_000;
|
||||
|
||||
// int total = 0;
|
||||
// OR
|
||||
// double total = 0;
|
||||
|
||||
long start = System.nanoTime();
|
||||
for (int repeat = 0; repeat < repeats; repeat++) {
|
||||
for (int index = 0; index < size; index++) {
|
||||
total += insert_function_being_tested_here(values[index]);
|
||||
}
|
||||
}
|
||||
long diff = System.nanoTime() - start;
|
||||
System.out.println(total);
|
||||
System.out.println(diff / 1_000_000L);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
index 2034c67f5702b7b8d093ef2dd7601901c5fef363..2a88165dd4edbc2ca1acd2f6e0a4b99ec61cf958 100644
|
||||
--- a/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
+++ b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
@@ -168,13 +168,11 @@ public final class MCUtil {
|
||||
}
|
||||
|
||||
public static int fastFloor(double x) {
|
||||
- int truncated = (int)x;
|
||||
- return x < (double)truncated ? truncated - 1 : truncated;
|
||||
+ return (int) Math.floor(x); // Gale - use platform math functions
|
||||
}
|
||||
|
||||
public static int fastFloor(float x) {
|
||||
- int truncated = (int)x;
|
||||
- return x < (double)truncated ? truncated - 1 : truncated;
|
||||
+ return (int) Math.floor(x); // Gale - use platform math functions
|
||||
}
|
||||
|
||||
public static float normalizeYaw(float f) {
|
||||
@@ -235,11 +233,11 @@ public final class MCUtil {
|
||||
}
|
||||
|
||||
public static int getChunkCoordinate(final double coordinate) {
|
||||
- return MCUtil.fastFloor(coordinate) >> 4;
|
||||
+ return ((int) Math.floor(coordinate)) >> 4; // Gale - use platform math functions
|
||||
}
|
||||
|
||||
public static int getBlockCoordinate(final double coordinate) {
|
||||
- return MCUtil.fastFloor(coordinate);
|
||||
+ return (int) Math.floor(coordinate); // Gale - use platform math functions
|
||||
}
|
||||
|
||||
public static long getBlockKey(final int x, final int y, final int z) {
|
||||
diff --git a/src/main/java/net/minecraft/util/Mth.java b/src/main/java/net/minecraft/util/Mth.java
|
||||
index 990ea96de8e940390b67e9462fcfd6025f2f5770..e102c109d01e0f992808a6096b5f6a323b52d970 100644
|
||||
--- a/src/main/java/net/minecraft/util/Mth.java
|
||||
+++ b/src/main/java/net/minecraft/util/Mth.java
|
||||
@@ -58,13 +58,11 @@ public class Mth {
|
||||
}
|
||||
|
||||
public static int floor(float value) {
|
||||
- int i = (int)value;
|
||||
- return value < (float)i ? i - 1 : i;
|
||||
+ return (int) Math.floor(value); // Gale - use platform math functions
|
||||
}
|
||||
|
||||
public static int floor(double value) {
|
||||
- int i = (int)value;
|
||||
- return value < (double)i ? i - 1 : i;
|
||||
+ return (int) Math.floor(value); // Gale - use platform math functions
|
||||
}
|
||||
|
||||
public static long lfloor(double value) {
|
||||
@@ -81,13 +79,11 @@ public class Mth {
|
||||
}
|
||||
|
||||
public static int ceil(float value) {
|
||||
- int i = (int)value;
|
||||
- return value > (float)i ? i + 1 : i;
|
||||
+ return (int) Math.ceil(value); // Gale - use platform math functions
|
||||
}
|
||||
|
||||
public static int ceil(double value) {
|
||||
- int i = (int)value;
|
||||
- return value > (double)i ? i + 1 : i;
|
||||
+ return (int) Math.ceil(value); // Gale - use platform math functions
|
||||
}
|
||||
|
||||
public static int clamp(int value, int min, int max) {
|
||||
@@ -123,15 +119,7 @@ public class Mth {
|
||||
}
|
||||
|
||||
public static double absMax(double a, double b) {
|
||||
- if (a < 0.0) {
|
||||
- a = -a;
|
||||
- }
|
||||
-
|
||||
- if (b < 0.0) {
|
||||
- b = -b;
|
||||
- }
|
||||
-
|
||||
- return Math.max(a, b);
|
||||
+ return Math.max(Math.abs(a), Math.abs(b)); // Gale - use platform math functions
|
||||
}
|
||||
|
||||
public static int floorDiv(int dividend, int divisor) {
|
||||
@@ -1,483 +0,0 @@
|
||||
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
|
||||
@@ -1,19 +0,0 @@
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Tue, 6 Feb 2024 04:21:05 +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 f3c1a5b5880aefd1b3121be27172735134016437..d975134fe5dd38a8655406a39821593f055b7381 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -320,6 +320,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
public float yRotO;
|
||||
public float xRotO;
|
||||
private AABB bb;
|
||||
+ private boolean boundingBoxChanged = false; // Gale - VMP - skip entity move if movement is zero
|
||||
public boolean onGround;
|
||||
public boolean horizontalCollision;
|
||||
public boolean verticalCollision;
|
||||
@@ -1144,6 +1145,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
//Luminol end
|
||||
|
||||
public void move(MoverType movementType, Vec3 movement) {
|
||||
+ // Gale start - VMP - skip entity move if movement is zero
|
||||
+ if (!this.boundingBoxChanged && movement.equals(Vec3.ZERO)) {
|
||||
+ 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");
|
||||
@@ -5006,6 +5012,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
|
||||
public final void setBoundingBox(AABB boundingBox) {
|
||||
+ // Gale start - VMP - skip entity move if movement is zero
|
||||
+ if (!this.bb.equals(boundingBox)) {
|
||||
+ this.boundingBoxChanged = true;
|
||||
+ }
|
||||
+ // Gale end - VMP - skip entity move if movement is zero
|
||||
// CraftBukkit start - block invalid bounding boxes
|
||||
double minX = boundingBox.minX,
|
||||
minY = boundingBox.minY,
|
||||
@@ -0,0 +1,183 @@
|
||||
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 888cf5257fba032b9edd95a89e71ca8b4ed1fb81..dc89751d1ddd71fb98657abfdb67da7f395ef3db 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
|
||||
@@ -86,6 +86,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
|
||||
private final net.minecraft.world.level.StructureManager structureManager;
|
||||
@@ -116,6 +120,11 @@ public class WorldGenRegion implements WorldGenLevel {
|
||||
this.lastPos = ((ChunkAccess) chunks.get(chunks.size() - 1)).getPos();
|
||||
this.structureManager = world.structureManager().forWorldGenRegion(this); // Folia - region threading
|
||||
}
|
||||
+ // 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
|
||||
@@ -154,8 +163,28 @@ 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
|
||||
@@ -220,7 +249,17 @@ public class WorldGenRegion implements WorldGenLevel {
|
||||
|
||||
@Override
|
||||
public BlockState getBlockState(BlockPos pos) {
|
||||
- return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())).getBlockState(pos);
|
||||
+ // Gale start - Lithium - optimize world generation chunk and block access - avoid pointer de-referencing, make method easier to inline
|
||||
+ int x = SectionPos.blockToSectionCoord(pos.getX()) - this.minChunkX;
|
||||
+ int z = SectionPos.blockToSectionCoord(pos.getZ()) - this.minChunkZ;
|
||||
+ int w = this.size;
|
||||
+
|
||||
+ if (x >= 0 && z >= 0 && x < w && z < w) {
|
||||
+ return this.chunksArr[x + z * w].getBlockState(pos);
|
||||
+ } else {
|
||||
+ throw new NullPointerException("No chunk exists at " + new ChunkPos(pos));
|
||||
+ }
|
||||
+ // Gale end - Lithium - optimize world generation chunk and block access - avoid pointer de-referencing, make method easier to inline
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,77 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
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/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;
|
||||
|
||||
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 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
|
||||
private long keepAliveTime = Util.getMillis(); // Paper
|
||||
private boolean keepAlivePending;
|
||||
private long keepAliveChallenge;
|
||||
+ private it.unimi.dsi.fastutil.longs.LongList keepAlives = new it.unimi.dsi.fastutil.longs.LongArrayList(); // Purpur
|
||||
private int latency;
|
||||
private volatile boolean suspendFlushingOnServerThread = false;
|
||||
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.LuminolConfig.useAlternateKeepAlive) {
|
||||
+ long id = packet.getId();
|
||||
+ if (keepAlives.size() > 0 && keepAlives.contains(id)) {
|
||||
+ int ping = (int) (Util.getMillis() - id);
|
||||
+ this.latency = (this.latency * 3 + ping) / 4;
|
||||
+ 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 - This shouldn't be on the main thread
|
||||
if (this.keepAlivePending && packet.getId() == this.keepAliveChallenge) {
|
||||
int i = (int) (Util.getMillis() - this.keepAliveTime);
|
||||
@@ -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.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());
|
||||
+ disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE, org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT);
|
||||
+ } else {
|
||||
+ keepAliveTime = currentTime; // hijack this field for 1 second intervals
|
||||
+ keepAlives.add(currentTime); // currentTime is ID
|
||||
+ send(new ClientboundKeepAlivePacket(currentTime));
|
||||
+ }
|
||||
+ }
|
||||
+ } else
|
||||
+ // Purpur end
|
||||
+
|
||||
if (this.keepAlivePending) {
|
||||
if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); // more info
|
||||
239
patches/server/0044-Gale-Optimize-noise-generation.patch
Normal file
239
patches/server/0044-Gale-Optimize-noise-generation.patch
Normal file
@@ -0,0 +1,239 @@
|
||||
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 9a97e5cd23d839183ac4d243d28df92af3119fe7..0da2d816f0497eae0c055f3929b8194a3473a221 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java
|
||||
@@ -11,6 +11,27 @@ public final class ImprovedNoise {
|
||||
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.0;
|
||||
this.yo = random.nextDouble() * 256.0;
|
||||
@@ -38,12 +59,14 @@ public final class ImprovedNoise {
|
||||
double d = x + this.xo;
|
||||
double e = y + this.yo;
|
||||
double f = z + this.zo;
|
||||
- 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.0) {
|
||||
double m;
|
||||
@@ -53,25 +76,27 @@ public final class ImprovedNoise {
|
||||
m = h;
|
||||
}
|
||||
|
||||
- o = (double)Mth.floor(m / yScale + 1.0E-7F) * yScale;
|
||||
+ o = Math.floor(m / yScale + (double)1.0E-7F) * yScale; // Gale - C2ME - optimize noise generation - optimize: remove frequent type conversions
|
||||
} else {
|
||||
o = 0.0;
|
||||
}
|
||||
|
||||
- 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) {
|
||||
@@ -83,24 +108,69 @@ public final class ImprovedNoise {
|
||||
}
|
||||
|
||||
private double sampleAndLerp(int sectionX, int sectionY, int sectionZ, double localX, double localY, double localZ, double fadeLocalY) {
|
||||
- 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.0, localY, localZ);
|
||||
- double f = gradDot(this.p(l + sectionZ), localX, localY - 1.0, localZ);
|
||||
- double g = gradDot(this.p(n + sectionZ), localX - 1.0, localY - 1.0, localZ);
|
||||
- double h = gradDot(this.p(k + sectionZ + 1), localX, localY, localZ - 1.0);
|
||||
- double o = gradDot(this.p(m + sectionZ + 1), localX - 1.0, localY, localZ - 1.0);
|
||||
- double p = gradDot(this.p(l + sectionZ + 1), localX, localY - 1.0, localZ - 1.0);
|
||||
- double q = gradDot(this.p(n + sectionZ + 1), localX - 1.0, localY - 1.0, localZ - 1.0);
|
||||
- double r = Mth.smoothstep(localX);
|
||||
- double s = Mth.smoothstep(fadeLocalY);
|
||||
- double t = Mth.smoothstep(localZ);
|
||||
- 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 35820670837376bcad8891241724d5b946fbd31f..eb7aef08bd855416902d3e7988d07576ee13a9cb 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinNoise.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinNoise.java
|
||||
@@ -26,6 +26,10 @@ public class PerlinNoise {
|
||||
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
|
||||
public static PerlinNoise createLegacyForBlendedNoise(RandomSource random, IntStream octaves) {
|
||||
@@ -127,6 +131,10 @@ public class PerlinNoise {
|
||||
this.lowestFreqInputFactor = Math.pow(2.0, (double)(-j));
|
||||
this.lowestFreqValueFactor = Math.pow(2.0, (double)(i - 1)) / (Math.pow(2.0, (double)i) - 1.0);
|
||||
this.maxValue = this.edgeValue(2.0);
|
||||
+ // Gale start - C2ME - optimize noise generation
|
||||
+ this.octaveSamplersCount = this.noiseLevels.length;
|
||||
+ this.amplitudesArray = this.amplitudes.toDoubleArray();
|
||||
+ // Gale end - C2ME - optimize noise generation
|
||||
}
|
||||
|
||||
protected double maxValue() {
|
||||
@@ -138,7 +146,27 @@ public class PerlinNoise {
|
||||
}
|
||||
|
||||
public double getValue(double x, double y, double z) {
|
||||
- return this.getValue(x, y, z, 0.0, 0.0, false);
|
||||
+ // Gale start - C2ME - optimize noise generation - optimize for common cases
|
||||
+ double d = 0.0;
|
||||
+ double e = this.lowestFreqInputFactor;
|
||||
+ 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
|
||||
@@ -1,579 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
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 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 {
|
||||
|
||||
// player list
|
||||
MinecraftServer.getServer().getPlayerList().tick();
|
||||
+
|
||||
+ top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleTick(); //Leaves
|
||||
}
|
||||
|
||||
private void tickPlayerSample() {
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java b/src/main/java/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java
|
||||
index af86f752c33a2990405fea058b7c41c437ba9d46..bada9fae1e7178162429e1f5a1608b9c4a680a6c 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java
|
||||
@@ -20,7 +20,12 @@ public record ServerboundCustomPayloadPacket(CustomPacketPayload payload) implem
|
||||
|
||||
private static CustomPacketPayload readPayload(ResourceLocation id, FriendlyByteBuf buf) {
|
||||
FriendlyByteBuf.Reader<? extends CustomPacketPayload> packetdataserializer_a = (FriendlyByteBuf.Reader) ServerboundCustomPayloadPacket.KNOWN_TYPES.get(id);
|
||||
-
|
||||
+ // Leaves start - protocol
|
||||
+ CustomPacketPayload leavesPayload = top.leavesmc.leaves.protocol.core.LeavesProtocolManager.getPayload(id, buf);
|
||||
+ if (leavesPayload != null) {
|
||||
+ return leavesPayload;
|
||||
+ }
|
||||
+ // Leaves end - protocol
|
||||
return (CustomPacketPayload) (packetdataserializer_a != null ? (CustomPacketPayload) packetdataserializer_a.apply(buf) : readUnknownPayload(id, buf));
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
index 9d23285f97ac5d90eb177ddc325281fa197d7f76..e1ace2ad411b8d54c56660b41e774a1c998b3ac3 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
@@ -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 - handle brand payload packet
|
||||
if (packet.payload() instanceof net.minecraft.network.protocol.common.custom.BrandPayload brandPayload) {
|
||||
this.player.clientBrandName = brandPayload.brand();
|
||||
@@ -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);
|
||||
+ top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleMinecraftRegister(channel, player); // Leaves - protocol
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t register custom payload", ex);
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 7edaa7558e40942f94c459e9b480ef640146ec6b..3f366ad035ada0ac8170d2925bbfe86b80bd84cb 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -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
|
||||
}
|
||||
|
||||
+ top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); // Leaves - protocol
|
||||
+
|
||||
final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage();
|
||||
|
||||
if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure
|
||||
@@ -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
|
||||
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 5fe36cbb14f0f0e9692cfa40381cebdb4e142bbe..ee66241a422acb8920395fd5e41578a966746f5c 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -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
|
||||
+ top.leavesmc.leaves.protocol.core.LeavesProtocolManager.init(); // Leaves - protocol
|
||||
}
|
||||
|
||||
public boolean getCommandBlockOverride(String command) {
|
||||
@@ -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");
|
||||
+ top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleServerReload(); // Leaves - protocol
|
||||
|
||||
int pollCount = 0;
|
||||
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocol.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..64a1d25973b032e8cab64bbffa6824a131676773
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocol.java
|
||||
@@ -0,0 +1,16 @@
|
||||
+package top.leavesmc.leaves.protocol.core;
|
||||
+
|
||||
+import java.lang.annotation.ElementType;
|
||||
+import java.lang.annotation.Retention;
|
||||
+import java.lang.annotation.RetentionPolicy;
|
||||
+import java.lang.annotation.Target;
|
||||
+
|
||||
+@Target(ElementType.TYPE)
|
||||
+@Retention(RetentionPolicy.RUNTIME)
|
||||
+public @interface LeavesProtocol {
|
||||
+
|
||||
+ String namespace() default "minecraft";
|
||||
+
|
||||
+ String[] namespaces() default {};
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocolManager.java b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..055f044ce6cef4377f6f577efdbfad0ec9a2d57b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
|
||||
@@ -0,0 +1,340 @@
|
||||
+package top.leavesmc.leaves.protocol.core;
|
||||
+
|
||||
+import net.minecraft.network.FriendlyByteBuf;
|
||||
+import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import org.apache.commons.lang.ArrayUtils;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.io.IOException;
|
||||
+import java.lang.reflect.Constructor;
|
||||
+import java.lang.reflect.InvocationTargetException;
|
||||
+import java.lang.reflect.Method;
|
||||
+import java.lang.reflect.Modifier;
|
||||
+import java.net.JarURLConnection;
|
||||
+import java.net.URL;
|
||||
+import java.net.URLDecoder;
|
||||
+import java.nio.charset.StandardCharsets;
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.Collections;
|
||||
+import java.util.Enumeration;
|
||||
+import java.util.HashMap;
|
||||
+import java.util.HashSet;
|
||||
+import java.util.LinkedHashSet;
|
||||
+import java.util.List;
|
||||
+import java.util.Map;
|
||||
+import java.util.Set;
|
||||
+import java.util.jar.JarEntry;
|
||||
+import java.util.jar.JarFile;
|
||||
+
|
||||
+public class LeavesProtocolManager {
|
||||
+
|
||||
+ private static final Map<LeavesProtocol, Map<ProtocolHandler.PayloadReceiver, Constructor<? extends CustomPacketPayload>>> KNOWN_TYPES = new HashMap<>();
|
||||
+ private static final Map<LeavesProtocol, Map<ProtocolHandler.PayloadReceiver, Method>> KNOW_RECEIVERS = new HashMap<>();
|
||||
+
|
||||
+ private static final List<Method> TICKERS = new ArrayList<>();
|
||||
+ private static final List<Method> PLAYER_JOIN = new ArrayList<>();
|
||||
+ private static final List<Method> PLAYER_LEAVE = new ArrayList<>();
|
||||
+ private static final List<Method> RELOAD_SERVER = new ArrayList<>();
|
||||
+ private static final Map<LeavesProtocol, Map<ProtocolHandler.MinecraftRegister, Method>> MINECRAFT_REGISTER = new HashMap<>();
|
||||
+
|
||||
+ public static void init() {
|
||||
+ for (Class<?> clazz : getClasses("top.leavesmc.leaves.protocol")) {
|
||||
+ final LeavesProtocol protocol = clazz.getAnnotation(LeavesProtocol.class);
|
||||
+ if (protocol != null) {
|
||||
+ Set<Method> methods;
|
||||
+ try {
|
||||
+ Method[] publicMethods = clazz.getMethods();
|
||||
+ Method[] privateMethods = clazz.getDeclaredMethods();
|
||||
+ methods = new HashSet<>(publicMethods.length + privateMethods.length, 1.0f);
|
||||
+ Collections.addAll(methods, publicMethods);
|
||||
+ Collections.addAll(methods, privateMethods);
|
||||
+ } catch (NoClassDefFoundError e) {
|
||||
+ e.printStackTrace();
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ Map<ProtocolHandler.PayloadReceiver, Constructor<? extends CustomPacketPayload>> map = new HashMap<>();
|
||||
+ for (final Method method : methods) {
|
||||
+ if (method.isBridge() || method.isSynthetic() || !Modifier.isStatic(method.getModifiers())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ method.setAccessible(true);
|
||||
+
|
||||
+ final ProtocolHandler.Init init = method.getAnnotation(ProtocolHandler.Init.class);
|
||||
+ if (init != null) {
|
||||
+ try {
|
||||
+ method.invoke(null);
|
||||
+ } catch (InvocationTargetException | IllegalAccessException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final ProtocolHandler.PayloadReceiver receiver = method.getAnnotation(ProtocolHandler.PayloadReceiver.class);
|
||||
+ if (receiver != null) {
|
||||
+ try {
|
||||
+ map.put(receiver, receiver.payload().getConstructor(ResourceLocation.class, FriendlyByteBuf.class));
|
||||
+ } catch (NoSuchMethodException e) {
|
||||
+ e.printStackTrace();
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if (!KNOW_RECEIVERS.containsKey(protocol)) {
|
||||
+ KNOW_RECEIVERS.put(protocol, new HashMap<>());
|
||||
+ }
|
||||
+
|
||||
+ KNOW_RECEIVERS.get(protocol).put(receiver, method);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final ProtocolHandler.Ticker ticker = method.getAnnotation(ProtocolHandler.Ticker.class);
|
||||
+ if (ticker != null) {
|
||||
+ TICKERS.add(method);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final ProtocolHandler.PlayerJoin playerJoin = method.getAnnotation(ProtocolHandler.PlayerJoin.class);
|
||||
+ if (playerJoin != null) {
|
||||
+ PLAYER_JOIN.add(method);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final ProtocolHandler.PlayerLeave playerLeave = method.getAnnotation(ProtocolHandler.PlayerLeave.class);
|
||||
+ if (playerLeave != null) {
|
||||
+ PLAYER_LEAVE.add(method);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final ProtocolHandler.ReloadServer reloadServer = method.getAnnotation(ProtocolHandler.ReloadServer.class);
|
||||
+ if (reloadServer != null) {
|
||||
+ RELOAD_SERVER.add(method);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final ProtocolHandler.MinecraftRegister minecraftRegister = method.getAnnotation(ProtocolHandler.MinecraftRegister.class);
|
||||
+ if (minecraftRegister != null) {
|
||||
+ if (!MINECRAFT_REGISTER.containsKey(protocol)) {
|
||||
+ MINECRAFT_REGISTER.put(protocol, new HashMap<>());
|
||||
+ }
|
||||
+
|
||||
+ MINECRAFT_REGISTER.get(protocol).put(minecraftRegister, method);
|
||||
+ }
|
||||
+ }
|
||||
+ KNOWN_TYPES.put(protocol, map);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static CustomPacketPayload getPayload(ResourceLocation id, FriendlyByteBuf buf) {
|
||||
+ for (LeavesProtocol protocol : KNOWN_TYPES.keySet()) {
|
||||
+ if (!protocol.namespace().equals(id.getNamespace()) && !ArrayUtils.contains(protocol.namespaces(), id.getNamespace())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ Map<ProtocolHandler.PayloadReceiver, Constructor<? extends CustomPacketPayload>> map = KNOWN_TYPES.get(protocol);
|
||||
+ for (ProtocolHandler.PayloadReceiver receiver : map.keySet()) {
|
||||
+ if (receiver.ignoreId() || receiver.payloadId().equals(id.getPath()) || ArrayUtils.contains(receiver.payloadIds(), id.getPath())) {
|
||||
+ try {
|
||||
+ return map.get(receiver).newInstance(id, buf);
|
||||
+ } catch (InvocationTargetException | InstantiationException | IllegalAccessException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ public static void handlePayload(ServerPlayer player, CustomPacketPayload payload) {
|
||||
+ for (LeavesProtocol protocol : KNOW_RECEIVERS.keySet()) {
|
||||
+ if (!protocol.namespace().equals(payload.id().getNamespace()) && !ArrayUtils.contains(protocol.namespaces(), payload.id().getNamespace())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ Map<ProtocolHandler.PayloadReceiver, Method> map = KNOW_RECEIVERS.get(protocol);
|
||||
+ for (ProtocolHandler.PayloadReceiver receiver : map.keySet()) {
|
||||
+ if (payload.getClass() == receiver.payload()) {
|
||||
+ if (receiver.ignoreId() || receiver.payloadId().equals(payload.id().getPath()) ||
|
||||
+ ArrayUtils.contains(receiver.payloadIds(), payload.id().getPath())) {
|
||||
+ try {
|
||||
+ map.get(receiver).invoke(null, player, payload);
|
||||
+ } catch (InvocationTargetException | IllegalAccessException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void handleTick() {
|
||||
+ if (!TICKERS.isEmpty()) {
|
||||
+ try {
|
||||
+ for (Method method : TICKERS) {
|
||||
+ method.invoke(null);
|
||||
+ }
|
||||
+ } catch (InvocationTargetException | IllegalAccessException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void handlePlayerJoin(ServerPlayer player) {
|
||||
+ if (!PLAYER_JOIN.isEmpty()) {
|
||||
+ try {
|
||||
+ for (Method method : PLAYER_JOIN) {
|
||||
+ method.invoke(null, player);
|
||||
+ }
|
||||
+ } catch (InvocationTargetException | IllegalAccessException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void handlePlayerLeave(ServerPlayer player) {
|
||||
+ if (!PLAYER_LEAVE.isEmpty()) {
|
||||
+ try {
|
||||
+ for (Method method : PLAYER_LEAVE) {
|
||||
+ method.invoke(null, player);
|
||||
+ }
|
||||
+ } catch (InvocationTargetException | IllegalAccessException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void handleServerReload() {
|
||||
+ if (!RELOAD_SERVER.isEmpty()) {
|
||||
+ try {
|
||||
+ for (Method method : RELOAD_SERVER) {
|
||||
+ method.invoke(null);
|
||||
+ }
|
||||
+ } catch (InvocationTargetException | IllegalAccessException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void handleMinecraftRegister(String channelId, ServerPlayer player) {
|
||||
+ for (LeavesProtocol protocol : MINECRAFT_REGISTER.keySet()) {
|
||||
+ String[] channel = channelId.split(":");
|
||||
+ if (!protocol.namespace().equals(channel[0]) && !ArrayUtils.contains(protocol.namespaces(), channel[0])) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ Map<ProtocolHandler.MinecraftRegister, Method> map = MINECRAFT_REGISTER.get(protocol);
|
||||
+ for (ProtocolHandler.MinecraftRegister register : map.keySet()) {
|
||||
+ if (register.ignoreId() || register.channelId().equals(channel[1]) ||
|
||||
+ ArrayUtils.contains(register.channelIds(), channel[1])) {
|
||||
+ try {
|
||||
+ map.get(register).invoke(null, player);
|
||||
+ } catch (InvocationTargetException | IllegalAccessException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static Set<Class<?>> getClasses(String pack) {
|
||||
+ Set<Class<?>> classes = new LinkedHashSet<Class<?>>();
|
||||
+ String packageDirName = pack.replace('.', '/');
|
||||
+ Enumeration<URL> dirs;
|
||||
+ try {
|
||||
+ dirs = Thread.currentThread().getContextClassLoader().getResources(packageDirName);
|
||||
+ while (dirs.hasMoreElements()) {
|
||||
+ URL url = dirs.nextElement();
|
||||
+ String protocol = url.getProtocol();
|
||||
+ if ("file".equals(protocol)) {
|
||||
+ String filePath = URLDecoder.decode(url.getFile(), StandardCharsets.UTF_8);
|
||||
+ findClassesInPackageByFile(pack, filePath, classes);
|
||||
+ } else if ("jar".equals(protocol)) {
|
||||
+ JarFile jar;
|
||||
+ try {
|
||||
+ jar = ((JarURLConnection) url.openConnection()).getJarFile();
|
||||
+ Enumeration<JarEntry> entries = jar.entries();
|
||||
+ findClassesInPackageByJar(pack, entries, packageDirName, classes);
|
||||
+ } catch (IOException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ } catch (IOException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ return classes;
|
||||
+ }
|
||||
+
|
||||
+ private static void findClassesInPackageByFile(String packageName, String packagePath, Set<Class<?>> classes) {
|
||||
+ File dir = new File(packagePath);
|
||||
+ if (!dir.exists() || !dir.isDirectory()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ File[] dirfiles = dir.listFiles((file) -> file.isDirectory() || file.getName().endsWith(".class"));
|
||||
+ if (dirfiles != null) {
|
||||
+ for (File file : dirfiles) {
|
||||
+ if (file.isDirectory()) {
|
||||
+ findClassesInPackageByFile(packageName + "." + file.getName(), file.getAbsolutePath(), classes);
|
||||
+ } else {
|
||||
+ String className = file.getName().substring(0, file.getName().length() - 6);
|
||||
+ try {
|
||||
+ classes.add(Class.forName(packageName + '.' + className));
|
||||
+ } catch (ClassNotFoundException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static void findClassesInPackageByJar(String packageName, Enumeration<JarEntry> entries, String packageDirName, Set<Class<?>> classes) {
|
||||
+ while (entries.hasMoreElements()) {
|
||||
+ JarEntry entry = entries.nextElement();
|
||||
+ String name = entry.getName();
|
||||
+ if (name.charAt(0) == '/') {
|
||||
+ name = name.substring(1);
|
||||
+ }
|
||||
+ if (name.startsWith(packageDirName)) {
|
||||
+ int idx = name.lastIndexOf('/');
|
||||
+ if (idx != -1) {
|
||||
+ packageName = name.substring(0, idx).replace('/', '.');
|
||||
+ }
|
||||
+ if (name.endsWith(".class") && !entry.isDirectory()) {
|
||||
+ String className = name.substring(packageName.length() + 1, name.length() - 6);
|
||||
+ try {
|
||||
+ classes.add(Class.forName(packageName + '.' + className));
|
||||
+ } catch (ClassNotFoundException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public record EmptyPayload(ResourceLocation id) implements CustomPacketPayload {
|
||||
+
|
||||
+ public EmptyPayload(ResourceLocation location, FriendlyByteBuf buf) {
|
||||
+ this(location);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void write(@NotNull FriendlyByteBuf buf) {
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public record LeavesPayload(FriendlyByteBuf data, ResourceLocation id) implements CustomPacketPayload {
|
||||
+
|
||||
+ public LeavesPayload(ResourceLocation location, FriendlyByteBuf buf) {
|
||||
+ this(new FriendlyByteBuf(buf.readBytes(buf.readableBytes())), location);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void write(FriendlyByteBuf buf) {
|
||||
+ buf.writeBytes(data);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolHandler.java b/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolHandler.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..d696f001d2576d1b61cc732c81f22eb52205072b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolHandler.java
|
||||
@@ -0,0 +1,65 @@
|
||||
+package top.leavesmc.leaves.protocol.core;
|
||||
+
|
||||
+import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
+
|
||||
+import java.lang.annotation.ElementType;
|
||||
+import java.lang.annotation.Retention;
|
||||
+import java.lang.annotation.RetentionPolicy;
|
||||
+import java.lang.annotation.Target;
|
||||
+
|
||||
+public class ProtocolHandler {
|
||||
+
|
||||
+ @Target(ElementType.METHOD)
|
||||
+ @Retention(RetentionPolicy.RUNTIME)
|
||||
+ public @interface Init {
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ @Target(ElementType.METHOD)
|
||||
+ @Retention(RetentionPolicy.RUNTIME)
|
||||
+ public @interface PayloadReceiver {
|
||||
+
|
||||
+ Class<? extends CustomPacketPayload> payload();
|
||||
+
|
||||
+ String[] payloadIds() default {};
|
||||
+
|
||||
+ String payloadId() default "";
|
||||
+
|
||||
+ boolean ignoreId() default false;
|
||||
+ }
|
||||
+
|
||||
+ @Target(ElementType.METHOD)
|
||||
+ @Retention(RetentionPolicy.RUNTIME)
|
||||
+ public @interface Ticker {
|
||||
+ int delay() default 0;
|
||||
+ }
|
||||
+
|
||||
+ @Target(ElementType.METHOD)
|
||||
+ @Retention(RetentionPolicy.RUNTIME)
|
||||
+ public @interface PlayerJoin {
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ @Target(ElementType.METHOD)
|
||||
+ @Retention(RetentionPolicy.RUNTIME)
|
||||
+ public @interface PlayerLeave {
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ @Target(ElementType.METHOD)
|
||||
+ @Retention(RetentionPolicy.RUNTIME)
|
||||
+ public @interface ReloadServer {
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ @Target(ElementType.METHOD)
|
||||
+ @Retention(RetentionPolicy.RUNTIME)
|
||||
+ public @interface MinecraftRegister {
|
||||
+
|
||||
+ String channelId() default "";
|
||||
+
|
||||
+ String[] channelIds() default {};
|
||||
+
|
||||
+ boolean ignoreId() default false;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolUtils.java b/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolUtils.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..5282c5ad3d26d06ab685ddaaf6fd9a4d49559717
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolUtils.java
|
||||
@@ -0,0 +1,36 @@
|
||||
+package top.leavesmc.leaves.protocol.core;
|
||||
+
|
||||
+import net.minecraft.network.FriendlyByteBuf;
|
||||
+import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
|
||||
+import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.util.function.Consumer;
|
||||
+
|
||||
+public class ProtocolUtils {
|
||||
+
|
||||
+ public static void sendEmptyPayloadPacket(ServerPlayer player, ResourceLocation id) {
|
||||
+ player.connection.send(new ClientboundCustomPayloadPacket(new LeavesProtocolManager.EmptyPayload(id)));
|
||||
+ }
|
||||
+
|
||||
+ public static void sendPayloadPacket(ServerPlayer player, ResourceLocation id, Consumer<FriendlyByteBuf> consumer) {
|
||||
+ player.connection.send(new ClientboundCustomPayloadPacket(new CustomPacketPayload() {
|
||||
+ @Override
|
||||
+ public void write(@NotNull FriendlyByteBuf buf) {
|
||||
+ consumer.accept(buf);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull
|
||||
+ public ResourceLocation id() {
|
||||
+ return id;
|
||||
+ }
|
||||
+ }));
|
||||
+ }
|
||||
+
|
||||
+ public static void sendPayloadPacket(ServerPlayer player, CustomPacketPayload payload) {
|
||||
+ player.connection.send(new ClientboundCustomPayloadPacket(payload));
|
||||
+ }
|
||||
+}
|
||||
424
patches/server/0045-Gale-Faster-chunk-serialization.patch
Normal file
424
patches/server/0045-Gale-Faster-chunk-serialization.patch
Normal file
@@ -0,0 +1,424 @@
|
||||
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 8d7d763bf51cac556057645e6169c9447993189b..c1e5f04df9529e9236a5c8a047b02ad560085025 100644
|
||||
--- a/src/main/java/net/minecraft/util/SimpleBitStorage.java
|
||||
+++ b/src/main/java/net/minecraft/util/SimpleBitStorage.java
|
||||
@@ -389,4 +389,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 01f5b946fabbe34f31110e75973dab9f39897346..1cd79ab7635d4a5e55538c1130f487245f45b4b6 100644
|
||||
--- a/src/main/java/net/minecraft/util/ZeroBitStorage.java
|
||||
+++ b/src/main/java/net/minecraft/util/ZeroBitStorage.java
|
||||
@@ -71,4 +71,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 81368bf186365878db2e1ed305bb7bf36c26f61f..ee7ce575a80b47da752f1cc722b7f4dc3b1b1314 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) -> 0;
|
||||
public final IdMap<T> registry;
|
||||
@@ -304,28 +320,54 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
||||
public synchronized PalettedContainerRO.PackedData<T> pack(IdMap<T> idList, PalettedContainer.Strategy paletteProvider) { // Paper - synchronize
|
||||
this.acquire();
|
||||
|
||||
- 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 -> 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) {
|
||||
@@ -364,13 +406,33 @@ 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,694 +0,0 @@
|
||||
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/top/leavesmc/leaves/protocol/PcaSyncProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/PcaSyncProtocol.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..946b4183c7ae438bff5938115961057759c77dac
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/PcaSyncProtocol.java
|
||||
@@ -0,0 +1,382 @@
|
||||
+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.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 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();
|
||||
+
|
||||
+ server.execute(() -> {
|
||||
+ 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();
|
||||
+ });
|
||||
+ }
|
||||
+
|
||||
+ @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();
|
||||
+ server.execute(() -> {
|
||||
+ 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();
|
||||
+ }
|
||||
+ });
|
||||
+ }
|
||||
+
|
||||
+ 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;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
@@ -0,0 +1,31 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sat, 6 Apr 2024 05:14:57 +0000
|
||||
Subject: [PATCH] Gale Reduce lambda and Optional allocation in
|
||||
EntityBasedExplosionDamageCalculator
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java b/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java
|
||||
index 3527f1621ef9b4f3f8d8bbb93379f13ff141c3be..4e4dfb72d5a0b46917999b709c655ccfdae27183 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java
|
||||
@@ -15,8 +15,17 @@ public class EntityBasedExplosionDamageCalculator extends ExplosionDamageCalcula
|
||||
|
||||
@Override
|
||||
public Optional<Float> getBlockExplosionResistance(Explosion explosion, BlockGetter world, BlockPos pos, BlockState blockState, FluidState fluidState) {
|
||||
- return super.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState)
|
||||
- .map(max -> this.source.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState, max));
|
||||
+ // Gale start - Lithium - reduce lambda and Optional allocation in EntityBasedExplosionDamageCalculator
|
||||
+ Optional<Float> optionalBlastResistance = super.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState);
|
||||
+ if (optionalBlastResistance.isPresent()) {
|
||||
+ float blastResistance = optionalBlastResistance.get();
|
||||
+ float effectiveExplosionResistance = this.source.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState, blastResistance);
|
||||
+ if (effectiveExplosionResistance != blastResistance) {
|
||||
+ return Optional.of(effectiveExplosionResistance);
|
||||
+ }
|
||||
+ }
|
||||
+ return optionalBlastResistance;
|
||||
+ // Gale end - Lithium - reduce lambda and Optional allocation in EntityBasedExplosionDamageCalculator
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,183 +0,0 @@
|
||||
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;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
@@ -0,0 +1,61 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sat, 6 Apr 2024 05:18:00 +0000
|
||||
Subject: [PATCH] Gale Replace throttle tracker map with optimized collection
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
index 45a2683c9489bee6d67a1f3d702c17f2e9dc02e4..8e90f35218e66690359dac35828a1485a77f34c1 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.minecraft.server.network;
|
||||
|
||||
+import it.unimi.dsi.fastutil.objects.Object2LongMap;
|
||||
+import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -14,7 +16,8 @@ import net.minecraft.server.MinecraftServer;
|
||||
|
||||
// CraftBukkit start
|
||||
import java.net.InetAddress;
|
||||
-import java.util.HashMap;
|
||||
+import java.util.Iterator;
|
||||
+import java.util.Map;
|
||||
// CraftBukkit end
|
||||
|
||||
public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketListener {
|
||||
@@ -25,7 +28,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
||||
static final java.util.regex.Pattern PROP_PATTERN = java.util.regex.Pattern.compile("\\w{0,16}");
|
||||
// Spigot end
|
||||
// CraftBukkit start - add fields
|
||||
- private static final HashMap<InetAddress, Long> throttleTracker = new HashMap<InetAddress, Long>();
|
||||
+ private static final Object2LongOpenHashMap<InetAddress> throttleTracker = new Object2LongOpenHashMap<>(); // Gale - Dionysus - replace throttle tracker map with optimized collection
|
||||
private static int throttleCounter = 0;
|
||||
// CraftBukkit end
|
||||
private static final Component IGNORE_STATUS_REASON = Component.translatable("disconnect.ignoring_status_request");
|
||||
@@ -86,7 +89,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
||||
InetAddress address = ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getAddress();
|
||||
|
||||
synchronized (ServerHandshakePacketListenerImpl.throttleTracker) {
|
||||
- if (ServerHandshakePacketListenerImpl.throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - ServerHandshakePacketListenerImpl.throttleTracker.get(address) < connectionThrottle) {
|
||||
+ if (ServerHandshakePacketListenerImpl.throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - ServerHandshakePacketListenerImpl.throttleTracker.getLong(address) < connectionThrottle) { // Gale - Dionysus - replace throttle tracker map with optimized collection
|
||||
ServerHandshakePacketListenerImpl.throttleTracker.put(address, currentTime);
|
||||
Component chatmessage = io.papermc.paper.adventure.PaperAdventure.asVanilla(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.connectionThrottle); // Paper - Configurable connection throttle kick message
|
||||
this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage));
|
||||
@@ -100,13 +103,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
||||
ServerHandshakePacketListenerImpl.throttleCounter = 0;
|
||||
|
||||
// Cleanup stale entries
|
||||
- java.util.Iterator iter = ServerHandshakePacketListenerImpl.throttleTracker.entrySet().iterator();
|
||||
- while (iter.hasNext()) {
|
||||
- java.util.Map.Entry<InetAddress, Long> entry = (java.util.Map.Entry) iter.next();
|
||||
- if (entry.getValue() > connectionThrottle) {
|
||||
- iter.remove();
|
||||
- }
|
||||
- }
|
||||
+ throttleTracker.object2LongEntrySet().removeIf(entry -> entry.getLongValue() > connectionThrottle); // Gale - Dionysus - replace throttle tracker map with optimized collection
|
||||
}
|
||||
}
|
||||
} // Paper - Unix domain socket support
|
||||
@@ -1,126 +0,0 @@
|
||||
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);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,50 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Sun, 28 Jan 2024 09:11:58 +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 c547d51eebd965f2be7ac45bc0981626c0515ef1..b7d91b7e8eb31f838cf540246f2d9b9c32b28780 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -1422,7 +1422,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
// Folia end - region threading
|
||||
|
||||
// CraftBukkit start - respect vanish API
|
||||
- if (flag && (!io.papermc.paper.util.TickThread.isTickThreadFor(player) || !player.getBukkitEntity().canSee(this.entity.getBukkitEntity()))) { // Paper - only consider hits // Folia - region threading
|
||||
+ if (flag && (!io.papermc.paper.util.TickThread.isTickThreadFor(player) || !player.getBukkitEntity().canSeeChunkMapUpdatePlayer(this.entity.getBukkitEntity()))) { // Paper - only consider hits // Folia - region threading // SparklyPaper - optimize canSee checks
|
||||
flag = false;
|
||||
}
|
||||
// CraftBukkit end
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index ed4bdf27c38d881fd3896a736652686ff9107f16..eb5ec3637aedb643801f369e43d39ef987546ce0 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -198,7 +198,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 static final WeakHashMap<Plugin, WeakReference<Plugin>> pluginWeakReferences = new WeakHashMap<>();
|
||||
private int hash = 0;
|
||||
@@ -2233,9 +2233,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
@Override
|
||||
public boolean canSee(org.bukkit.entity.Entity entity) {
|
||||
- return this.equals(entity) || entity.isVisibleByDefault() ^ this.invertedVisibilityEntities.containsKey(entity.getUniqueId()); // SPIGOT-7312: Can always see self
|
||||
+ return this.equals(entity) || entity.isVisibleByDefault() ^ (!invertedVisibilityEntities.isEmpty() && this.invertedVisibilityEntities.containsKey(entity.getUniqueId())); // SPIGOT-7312: Can always see self // SparklyPaper - optimize canSee checks
|
||||
}
|
||||
|
||||
+ // SparklyPaper - optimize canSee checks
|
||||
+ // The check in ChunkMap#updatePlayer already rejects if it is the same entity, so we don't need to check it twice, especially because CraftPlayer's equals check is a bit expensive
|
||||
+ public boolean canSeeChunkMapUpdatePlayer(org.bukkit.entity.Entity entity) {
|
||||
+ return entity.isVisibleByDefault() ^ (!invertedVisibilityEntities.isEmpty() && this.invertedVisibilityEntities.containsKey(entity.getUniqueId())); // SPIGOT-7312: Can always see self // SparklyPaper - optimize canSee checks
|
||||
+ }
|
||||
+ // SparklyPaper end
|
||||
+
|
||||
public boolean canSeePlayer(UUID uuid) {
|
||||
org.bukkit.entity.Entity entity = this.getServer().getPlayer(uuid);
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
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);
|
||||
90
patches/server/0050-Purpur-use-alternative-keep-alive.patch
Normal file
90
patches/server/0050-Purpur-use-alternative-keep-alive.patch
Normal file
@@ -0,0 +1,90 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 08:35:11 +0000
|
||||
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")
|
||||
+ public static boolean useAlternateKeepAlive = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.OPTIMIZATIONS;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "alternative_keepalive_handling";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
index f907dbb55369395058091dd75ae435d2025d94dd..20720424f5e63d07c885759b8b5104311aa6c7c8 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
@@ -73,6 +73,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
private long keepAliveChallenge;
|
||||
private long closedListenerTime;
|
||||
private boolean closed = false;
|
||||
+ private it.unimi.dsi.fastutil.longs.LongList keepAlives = new it.unimi.dsi.fastutil.longs.LongArrayList(); // Purpur
|
||||
private int latency;
|
||||
private volatile boolean suspendFlushingOnServerThread = false;
|
||||
public final java.util.Map<java.util.UUID, net.kyori.adventure.resource.ResourcePackCallback> packCallbacks = new java.util.concurrent.ConcurrentHashMap<>(); // Paper - adventure resource pack callbacks
|
||||
@@ -135,6 +136,16 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
|
||||
@Override
|
||||
public void handleKeepAlive(ServerboundKeepAlivePacket packet) {
|
||||
+ // Purpur start
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.PurpurAlternativeKeepaliveConfig.useAlternateKeepAlive) {
|
||||
+ long id = packet.getId();
|
||||
+ if (keepAlives.size() > 0 && keepAlives.contains(id)) {
|
||||
+ int ping = (int) (Util.getMillis() - id);
|
||||
+ this.latency = (this.latency * 3 + ping) / 4;
|
||||
+ 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
|
||||
if (this.keepAlivePending && packet.getId() == this.keepAliveChallenge) {
|
||||
int i = (int) (Util.getMillis() - this.keepAliveTime);
|
||||
@@ -264,6 +275,20 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
long currentTime = Util.getMillis();
|
||||
long elapsedTime = currentTime - this.keepAliveTime;
|
||||
|
||||
+ // Purpur start
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.PurpurAlternativeKeepaliveConfig.useAlternateKeepAlive) {
|
||||
+ if (elapsedTime >= 1000L) { // 1 second
|
||||
+ if (!processedDisconnect && keepAlives.size() * 1000L >= KEEPALIVE_LIMIT) {
|
||||
+ LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName());
|
||||
+ disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE, org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT);
|
||||
+ } else {
|
||||
+ keepAliveTime = currentTime; // hijack this field for 1 second intervals
|
||||
+ keepAlives.add(currentTime); // currentTime is ID
|
||||
+ send(new ClientboundKeepAlivePacket(currentTime));
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+
|
||||
if (!this.isSingleplayerOwner() && elapsedTime >= 15000L) { // Paper - use vanilla's 15000L between keep alive packets
|
||||
if (this.keepAlivePending && !this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // Paper - check keepalive limit, don't fire if already disconnected
|
||||
this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE, org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); // Paper - kick event cause
|
||||
@@ -275,6 +300,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
}
|
||||
}
|
||||
// Paper end - give clients a longer time to respond to pings as per pre 1.12.2 timings
|
||||
+ } // Purpur end
|
||||
|
||||
this.server.getProfiler().pop();
|
||||
}
|
||||
41
patches/server/0051-Fix-MC-2025.patch
Normal file
41
patches/server/0051-Fix-MC-2025.patch
Normal file
@@ -0,0 +1,41 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <fsjk947@gmail.com>
|
||||
Date: Fri, 15 Mar 2024 03:32:46 +0800
|
||||
Subject: [PATCH] Fix-MC-2025
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index d975134fe5dd38a8655406a39821593f055b7381..546063255bf29cba839d73cf2778a798150658f5 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -2608,6 +2608,16 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
nbttagcompound.putBoolean("Paper.FreezeLock", true);
|
||||
}
|
||||
// Paper end
|
||||
+
|
||||
+ // Luminol start - Fix MC-2025
|
||||
+ AABB boundingBox = getBoundingBox();
|
||||
+ ListTag boundingBoxList = new ListTag();
|
||||
+ for (double coord : new double[]{boundingBox.minX, boundingBox.minY, boundingBox.minZ, boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ}) {
|
||||
+ boundingBoxList.add(DoubleTag.valueOf(coord));
|
||||
+ }
|
||||
+ nbttagcompound.put("Luminol.BoundingBox", boundingBoxList);
|
||||
+ // Luminol end
|
||||
+
|
||||
return nbttagcompound;
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
|
||||
@@ -2685,6 +2695,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
this.reapplyPosition();
|
||||
}
|
||||
|
||||
+ // Luminol start - Fix MC-2025
|
||||
+ if (nbt.contains("Luminol.BoundingBox", net.minecraft.nbt.Tag.TAG_LIST)) {
|
||||
+ ListTag boundingBoxList = nbt.getList("Luminol.BoundingBox", net.minecraft.nbt.Tag.TAG_DOUBLE);
|
||||
+ setBoundingBox(new AABB(boundingBoxList.getDouble(0), boundingBoxList.getDouble(1), boundingBoxList.getDouble(2), boundingBoxList.getDouble(3), boundingBoxList.getDouble(4), boundingBoxList.getDouble(5)));
|
||||
+ }
|
||||
+ // Luminol end
|
||||
+
|
||||
} else {
|
||||
throw new IllegalStateException("Entity has invalid rotation");
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user