Compare commits
358 Commits
1.20.4-770
...
1.21.4-bbc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3e8f024a7 | ||
|
|
85f21d1be1 | ||
|
|
c0f20000cf | ||
|
|
b33e2fc51d | ||
|
|
b2c753bcfd | ||
|
|
677544289b | ||
|
|
87d2047f24 | ||
|
|
217047f7b5 | ||
|
|
2dcdca21b2 | ||
|
|
7afc1b403c | ||
|
|
e6e33b3947 | ||
|
|
bebfe1eda7 | ||
|
|
b9ca4c0c7a | ||
|
|
12cfb7a0ef | ||
|
|
e618370375 | ||
|
|
74aeb4fe5d | ||
|
|
102979a7d8 | ||
|
|
c5f561233f | ||
|
|
0d6b9a051f | ||
|
|
36b617c5be | ||
|
|
487fcdfc10 | ||
|
|
c99f65d958 | ||
|
|
1984558e49 | ||
|
|
ab5b160232 | ||
|
|
16df7dce12 | ||
|
|
8a01b9ad39 | ||
|
|
27a2e2a129 | ||
|
|
3b9b3813b4 | ||
|
|
9b4a6d60ac | ||
|
|
6055cc7367 | ||
|
|
9edeb2a539 | ||
|
|
207f96891a | ||
|
|
9baaa0a236 | ||
|
|
99c167504b | ||
|
|
2b5bedf14b | ||
|
|
38e4a96ab7 | ||
|
|
c7134597cb | ||
|
|
b1c6c29458 | ||
|
|
eeae6bc62c | ||
|
|
852529973b | ||
|
|
43af4d5432 | ||
|
|
b428505e23 | ||
|
|
e4b448c6df | ||
|
|
db4f0f7e1b | ||
|
|
bb144df37b | ||
|
|
21d1ee350a | ||
|
|
4a76009af8 | ||
|
|
1445e4683d | ||
|
|
fa959bf213 | ||
|
|
4a40f56920 | ||
|
|
9360a5adbd | ||
|
|
ea34494c03 | ||
|
|
1526790e77 | ||
|
|
af556ab869 | ||
|
|
4e8d54e073 | ||
|
|
f8559b9ca6 | ||
|
|
bc5a83c69c | ||
|
|
6a8df3771b | ||
|
|
ff4fdcc7d1 | ||
|
|
94ae8e3ce0 | ||
|
|
f1dfac26d8 | ||
|
|
5d9dfc3e17 | ||
|
|
ca44ba98a5 | ||
|
|
27298b865c | ||
|
|
bcea80b4d1 | ||
|
|
d20e0b1940 | ||
|
|
6fb1f6934b | ||
|
|
ab28422974 | ||
|
|
1247d8bf89 | ||
|
|
76ce141d63 | ||
|
|
f9514f1866 | ||
|
|
3102b1c581 | ||
|
|
770e4b848d | ||
|
|
78cfb0a760 | ||
|
|
98552da7aa | ||
|
|
a50e2f5be9 | ||
|
|
c275bd7e93 | ||
|
|
6825d1dbd1 | ||
|
|
cad01d6368 | ||
|
|
dacd3c5a29 | ||
|
|
4f051b3c62 | ||
|
|
a0f4d02bc9 | ||
|
|
63a8beaafc | ||
|
|
5905dbad61 | ||
|
|
bfe835b8b9 | ||
|
|
bf5c6d04d4 | ||
|
|
e20088ff17 | ||
|
|
62470e9097 | ||
|
|
b96655d098 | ||
|
|
f3b16cb314 | ||
|
|
0296cd03b1 | ||
|
|
791d374a94 | ||
|
|
065b78f0d5 | ||
|
|
156837d199 | ||
|
|
5a60f7395f | ||
|
|
973b437ad6 | ||
|
|
051ed97668 | ||
|
|
4918bb98e5 | ||
|
|
8d491c23a9 | ||
|
|
16eca828f1 | ||
|
|
7c312e7851 | ||
|
|
76f1b9d02d | ||
|
|
896fd7bf1a | ||
|
|
81f17dc7b0 | ||
|
|
5f694869c2 | ||
|
|
dc0f1f9933 | ||
|
|
1a6ea9fc98 | ||
|
|
f175359ad9 | ||
|
|
e6a76b5794 | ||
|
|
d170436ff0 | ||
|
|
cc907e891d | ||
|
|
5b9d44ee94 | ||
|
|
c749ca011a | ||
|
|
72f6717b13 | ||
|
|
55be3489f0 | ||
|
|
d547f8ab3f | ||
|
|
a22472fe99 | ||
|
|
d15f2774ea | ||
|
|
b27cf9614e | ||
|
|
98bbcd67e4 | ||
|
|
1ed71f5812 | ||
|
|
14de6bf8c7 | ||
|
|
d0d9ce0c46 | ||
|
|
2e520168e1 | ||
|
|
58d45e32c5 | ||
|
|
8830d65945 | ||
|
|
fb55d3e201 | ||
|
|
892dfcd2a0 | ||
|
|
6c600853dd | ||
|
|
1299dbfeea | ||
|
|
8e876b48f2 | ||
|
|
a4794fb096 | ||
|
|
064679fd22 | ||
|
|
2541ddfd7b | ||
|
|
c5cb9503c9 | ||
|
|
ab71de6298 | ||
|
|
7bba0412a3 | ||
|
|
b56f9723e7 | ||
|
|
190e5e094a | ||
|
|
17e9d04db0 | ||
|
|
09861230f7 | ||
|
|
a92cfa3637 | ||
|
|
84cf8fbb38 | ||
|
|
620e093735 | ||
|
|
d01eef55ec | ||
|
|
05101da67b | ||
|
|
32db7a453c | ||
|
|
576d488a36 | ||
|
|
4959ecceba | ||
|
|
6614f67647 | ||
|
|
85f3a4a123 | ||
|
|
99e29a0596 | ||
|
|
0a0cdb8d54 | ||
|
|
aa49ca63a4 | ||
|
|
fefc53dd71 | ||
|
|
0e049306c9 | ||
|
|
e991f0b80f | ||
|
|
4752f00d09 | ||
|
|
e6027bdfbf | ||
|
|
1f881dd409 | ||
|
|
be0d1b1bb2 | ||
|
|
3fd73145d6 | ||
|
|
b8963f9862 | ||
|
|
83a868e3d2 | ||
|
|
9153d07d43 | ||
|
|
fcf4731fa2 | ||
|
|
0795ae027d | ||
|
|
f2a13748e8 | ||
|
|
acc31af9f6 | ||
|
|
9121c2ba4e | ||
|
|
0cc6f1cdb3 | ||
|
|
ac1cc484c2 | ||
|
|
b208bcc81f | ||
|
|
43eda55b88 | ||
|
|
e6ee20986b | ||
|
|
46aec00348 | ||
|
|
3deaf5f7fb | ||
|
|
81dd04e018 | ||
|
|
bd26f9aeab | ||
|
|
6b2a9d25c8 | ||
|
|
15bb0f42d0 | ||
|
|
841c0b9cd3 | ||
|
|
63ef3ce0b9 | ||
|
|
92b9d91fdf | ||
|
|
a02d29c6a7 | ||
|
|
7b971faccc | ||
|
|
b952734d6b | ||
|
|
5e86abed12 | ||
|
|
266ea43135 | ||
|
|
a33f5c92bb | ||
|
|
1238ec3bf9 | ||
|
|
dec6cf5fd3 | ||
|
|
bb679c51fc | ||
|
|
0f1fee37ef | ||
|
|
5a852d792e | ||
|
|
4333f80871 | ||
|
|
45e119a5ad | ||
|
|
b027e4cd03 | ||
|
|
1e5e540795 | ||
|
|
a020b181cc | ||
|
|
7ea76f4f74 | ||
|
|
787c3793c6 | ||
|
|
39c74a5409 | ||
|
|
fca5e33fa4 | ||
|
|
2d14daaa87 | ||
|
|
0a63aeaca2 | ||
|
|
729312415f | ||
|
|
96499c26ff | ||
|
|
7645ef08e8 | ||
|
|
e7dde4f240 | ||
|
|
dbb30dc4f3 | ||
|
|
65de2ae23e | ||
|
|
ec74075cc5 | ||
|
|
e5379a2042 | ||
|
|
67ba24ec92 | ||
|
|
943c084de6 | ||
|
|
8d3c7e7807 | ||
|
|
fbd9d9f48f | ||
|
|
512da58f92 | ||
|
|
b239c97db1 | ||
|
|
650ce2770d | ||
|
|
ce500bf638 | ||
|
|
48f34a6146 | ||
|
|
40cae40b09 | ||
|
|
38a8161c1a | ||
|
|
dced86a404 | ||
|
|
a983ac00e5 | ||
|
|
e2b21e0f69 | ||
|
|
07ef8e01c5 | ||
|
|
77cb94ae5f | ||
|
|
14e7cbe186 | ||
|
|
49be774d83 | ||
|
|
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.com/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.
|
||||
71
.github/workflows/build_1.21.4.yml
vendored
Normal file
71
.github/workflows/build_1.21.4.yml
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
name: Luminol CI - ver/1.21.4
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "ver/1.21.4" ]
|
||||
pull_request:
|
||||
branches: [ "ver/1.21.4" ]
|
||||
|
||||
permissions: write-all
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
environment: default
|
||||
steps:
|
||||
- name: Checkout Git Repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v4
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '22'
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
- 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: ./gradlew applyPatches
|
||||
- name: CreateJar
|
||||
run: ./gradlew createMojmapPaperclipJar
|
||||
- name: Publish to repo
|
||||
continue-on-error: true
|
||||
run: |
|
||||
export MAVEN_REPO_USER=${{ secrets.MAVEN_REPO_USER }}
|
||||
export MAVEN_REPO_PASSWORD=${{ secrets.MAVEN_REPO_PASSWORD }}
|
||||
./gradlew publish -PpublishDevBundle=true
|
||||
- name: SetENV
|
||||
run: sh scripts/SetENV.sh
|
||||
- name: Upload Artifact
|
||||
uses: "actions/upload-artifact@v4"
|
||||
with:
|
||||
name: "${{ env.project_id_b }} CI Artifacts"
|
||||
path: "build/libs/*.jar"
|
||||
- name: Create Release
|
||||
if: "!contains(github.event.commits[0].message, '[release skip]')"
|
||||
uses: ncipollo/release-action@v1.14.0
|
||||
with:
|
||||
tag: ${{ env.tag }}
|
||||
name: ${{ env.project_id_b }} ${{ env.mcversion }} - ${{ env.commit_id }}
|
||||
body: |
|
||||
📦Version: `${{ env.mcversion }}` | Commit ${{ env.commit_id }} [](https://github.com/LuminolMC/${{ env.project_id }}/download/${{ env.tag }}/${{ env.jar }})
|
||||
This release is automatically compiled by GitHub Actions
|
||||
### Commit Message
|
||||
${{ env.commit_msg }}
|
||||
artifacts: |
|
||||
${{ env.jar_dir }}
|
||||
${{ env.jar_dir_bundler }}
|
||||
generateReleaseNotes: true
|
||||
prerelease: ${{ env.pre }}
|
||||
makeLatest: ${{ env.make_latest }}
|
||||
token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
- name: Push to API
|
||||
if: "!contains(github.event.commits[0].message, '[release skip]')"
|
||||
continue-on-error: true
|
||||
env:
|
||||
secret_v2: ${{ secrets.API_KEY }}
|
||||
tag: ${{ env.tag }}
|
||||
project_id: ${{ env.project_id }}
|
||||
run: sh scripts/PushToAPI.sh
|
||||
63
.github/workflows/build_1_20_2.yml
vendored
63
.github/workflows/build_1_20_2.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
|
||||
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/
|
||||
91
README.md
91
README.md
@@ -1,39 +1,88 @@
|
||||
<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
|
||||
repositories {
|
||||
maven {
|
||||
url = "https://maven.moliatopia.icu/repository/maven-snapshots/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("me.earthme.luminol:luminol-api:1.20.2-R0.1-SNAPSHOT")
|
||||
compileOnly("me.earthme.luminol:luminol-api:1.21.3-R0.1-20241201.004037-1")
|
||||
}
|
||||
```
|
||||
For maven
|
||||
|
||||
使用 Maven
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>me.earthme.luminol</groupId>
|
||||
<artifactId>luminol-api</artifactId>
|
||||
<version>1.20.2-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>moliatopia</id>
|
||||
<url>https://maven.moliatopia.icu/repository/maven-snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>me.earthme.luminol</groupId>
|
||||
<artifactId>luminol-api</artifactId>
|
||||
<version>1.21.3-R0.1-20241201.004037-1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
```
|
||||
|
||||
## 联系方式
|
||||
> 如果您对这个项目感兴趣或有任何问题,请随时向我们提问。
|
||||
|
||||
**QQ群: [368632360](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=MfosKhcDd8Fdxn1MREuZ8Krbf9T6jiBC&authKey=3cm6qdHohON3gHnuD63FK4k07fIbrWnY4hdyq8OmELsfjMVP1kbFTJY9mRyM2Rkj&noverify=0&group_code=368632360)** | QQ频道: [点击加入](https://pd.qq.com/s/eq9krf9j) | Telegram: [点击加入](https://t.me/LuminolMC) | Discord: [点击加入](https://discord.gg/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>
|
||||
|
||||
86
README_EN.md
Normal file
86
README_EN.md
Normal file
@@ -0,0 +1,86 @@
|
||||
<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
|
||||
repositories {
|
||||
maven {
|
||||
url = "https://maven.moliatopia.icu/repository/maven-snapshots/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("me.earthme.luminol:luminol-api:1.21.3-R0.1-20241201.004037-1")
|
||||
}
|
||||
```
|
||||
|
||||
For maven
|
||||
|
||||
```xml
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>moliatopia</id>
|
||||
<url>https://maven.moliatopia.icu/repository/maven-snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>me.earthme.luminol</groupId>
|
||||
<artifactId>luminol-api</artifactId>
|
||||
<version>1.21.3-R0.1-20241201.004037-1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
```
|
||||
|
||||
## Contact
|
||||
> If you are interested in this project or have any issue, feel free to ask us.
|
||||
|
||||
**QQ Group: [368632360](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=MfosKhcDd8Fdxn1MREuZ8Krbf9T6jiBC&authKey=3cm6qdHohON3gHnuD63FK4k07fIbrWnY4hdyq8OmELsfjMVP1kbFTJY9mRyM2Rkj&noverify=0&group_code=368632360)** | QQ Channel: [Click To Join](https://pd.qq.com/s/eq9krf9j) | Telegram: [Click To Join](https://t.me/LuminolMC) | Discord: [Click To Join](https://discord.gg/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>
|
||||
208
build.gradle.kts
208
build.gradle.kts
@@ -1,95 +1,113 @@
|
||||
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"
|
||||
}
|
||||
|
||||
val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven(paperMavenPublicUrl) {
|
||||
content { onlyForConfigurations(configurations.paperclip.name) }
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
remapper("net.fabricmc:tiny-remapper:0.8.6:fat")
|
||||
decompiler("org.quiltmc:quiltflower:1.9.0")
|
||||
paperclip("io.papermc:paperclip:3.0.3-SNAPSHOT")
|
||||
}
|
||||
|
||||
subprojects {
|
||||
apply(plugin = "java")
|
||||
apply(plugin = "maven-publish")
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.release.set(17)
|
||||
}
|
||||
|
||||
tasks.withType<Javadoc> {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
}
|
||||
|
||||
tasks.withType<ProcessResources> {
|
||||
filteringCharset = Charsets.UTF_8.name()
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven(paperMavenPublicUrl)
|
||||
maven("https://oss.sonatype.org/content/groups/public/")
|
||||
maven("https://ci.emc.gs/nexus/content/groups/aikar/")
|
||||
maven("https://repo.aikar.co/content/groups/aikar")
|
||||
maven("https://repo.md-5.net/content/repositories/releases/")
|
||||
maven("https://hub.spigotmc.org/nexus/content/groups/public/")
|
||||
maven("https://jitpack.io")
|
||||
maven("https://repo.codemc.io/repository/maven-public/")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
tasks.generateDevelopmentBundle {
|
||||
apiCoordinates.set("me.earthme.luminol:luminol-api")
|
||||
mojangApiCoordinates.set("io.papermc.paper:paper-mojangapi")
|
||||
libraryRepositories.set(
|
||||
listOf(
|
||||
"https://repo.maven.apache.org/maven2/",
|
||||
paperMavenPublicUrl,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
paperweight {
|
||||
serverProject.set(project(":luminol-server"))
|
||||
|
||||
remapRepo.set("https://maven.fabricmc.net/")
|
||||
decompileRepo.set("https://maven.quiltmc.org/")
|
||||
|
||||
useStandardUpstream("folia") {
|
||||
url.set(github("PaperMC", "Folia"))
|
||||
ref.set(providers.gradleProperty("foliaCommit"))
|
||||
|
||||
withStandardPatcher {
|
||||
apiSourceDirPath.set("Folia-API")
|
||||
serverSourceDirPath.set("Folia-Server")
|
||||
|
||||
|
||||
apiPatchDir.set(layout.projectDirectory.dir("patches/api"))
|
||||
apiOutputDir.set(layout.projectDirectory.dir("Luminol-API"))
|
||||
|
||||
serverPatchDir.set(layout.projectDirectory.dir("patches/server"))
|
||||
serverOutputDir.set(layout.projectDirectory.dir("Luminol-Server"))
|
||||
}
|
||||
}
|
||||
}
|
||||
plugins {
|
||||
java
|
||||
`maven-publish`
|
||||
id("io.papermc.paperweight.patcher") version "1.7.7"
|
||||
}
|
||||
|
||||
val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven(paperMavenPublicUrl) {
|
||||
content { onlyForConfigurations(configurations.paperclip.name) }
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
remapper("net.fabricmc:tiny-remapper:0.10.3:fat")
|
||||
decompiler("org.vineflower:vineflower:1.10.1")
|
||||
paperclip("io.papermc:paperclip:3.0.3")
|
||||
}
|
||||
|
||||
subprojects {
|
||||
apply(plugin = "java")
|
||||
apply(plugin = "maven-publish")
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.release.set(21)
|
||||
}
|
||||
|
||||
tasks.withType<Javadoc> {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
}
|
||||
|
||||
tasks.withType<ProcessResources> {
|
||||
filteringCharset = Charsets.UTF_8.name()
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven(paperMavenPublicUrl)
|
||||
}
|
||||
}
|
||||
|
||||
paperweight {
|
||||
serverProject.set(project(":luminol-server"))
|
||||
|
||||
remapRepo.set(paperMavenPublicUrl)
|
||||
decompileRepo.set(paperMavenPublicUrl)
|
||||
|
||||
useStandardUpstream("folia") {
|
||||
url.set(github("PaperMC", "Folia"))
|
||||
ref.set(providers.gradleProperty("foliaCommit"))
|
||||
|
||||
withStandardPatcher {
|
||||
apiSourceDirPath.set("Folia-API")
|
||||
serverSourceDirPath.set("Folia-Server")
|
||||
|
||||
|
||||
apiPatchDir.set(layout.projectDirectory.dir("patches/api"))
|
||||
apiOutputDir.set(layout.projectDirectory.dir("Luminol-API"))
|
||||
|
||||
serverPatchDir.set(layout.projectDirectory.dir("patches/server"))
|
||||
serverOutputDir.set(layout.projectDirectory.dir("Luminol-Server"))
|
||||
}
|
||||
|
||||
patchTasks.register("generatedApi") {
|
||||
isBareDirectory = true
|
||||
upstreamDirPath = "paper-api-generator/generated"
|
||||
patchDir = layout.projectDirectory.dir("patches/generatedApi")
|
||||
outputDir = layout.projectDirectory.dir("paper-api-generator/generated")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.generateDevelopmentBundle {
|
||||
apiCoordinates.set("me.earthme.luminol:luminol-api")
|
||||
libraryRepositories.addAll(
|
||||
"https://repo.maven.apache.org/maven2/",
|
||||
"https://maven.pkg.github.com/LuminolMC/Luminol",
|
||||
paperMavenPublicUrl,
|
||||
)
|
||||
}
|
||||
|
||||
allprojects {
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
name = "moliaMavenRepo"
|
||||
url = uri("https://maven.moliatopia.icu/repository/maven-snapshots/")
|
||||
|
||||
credentials.username = System.getenv("MAVEN_REPO_USER")
|
||||
credentials.password = System.getenv("MAVEN_REPO_PASSWORD")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
if (project.hasProperty("publishDevBundle")) {
|
||||
publications.create<MavenPublication>("devBundle") {
|
||||
artifact(tasks.generateDevelopmentBundle) {
|
||||
artifactId = "dev-bundle"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.21.4-R0.1-SNAPSHOT
|
||||
|
||||
foliaCommit = 1e5e2154c9f88d788cecf0b9fcc77ece7d1f8663
|
||||
foliaCommit = 8af1aef1f14630ede6575a72632e7f943d8fb903
|
||||
|
||||
org.gradle.caching = true
|
||||
org.gradle.parallel = true
|
||||
org.gradle.vfs.watch = false
|
||||
org.gradle.jvmargs = -Xmx3G
|
||||
|
||||
mcVersion = 1.21.4
|
||||
GroupMCV = 1.21
|
||||
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.11.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
34
gradlew
vendored
34
gradlew
vendored
@@ -15,6 +15,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@@ -55,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -83,10 +85,9 @@ 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 -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||
' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -133,10 +134,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 +148,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 +156,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 +201,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" \
|
||||
|
||||
22
gradlew.bat
vendored
22
gradlew.bat
vendored
@@ -13,6 +13,8 @@
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@@ -43,11 +45,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 +59,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 652ff54e7c50412503725d628bfe72ed03059790..ee163b9fa8f441aa4b3e2309f33e8f932dfc02d7 100644
|
||||
--- a/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
+++ b/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
@@ -19,6 +19,13 @@ public interface ServerBuildInfo {
|
||||
*/
|
||||
Key BRAND_PAPER_ID = Key.key("papermc", "paper");
|
||||
|
||||
+ // Luminol start
|
||||
+ /**
|
||||
+ * The brand id for Luminol.
|
||||
+ */
|
||||
+ Key BRAND_LUMINOL_ID = Key.key("luminolmc", "luminol");
|
||||
+ // Luminol end
|
||||
+
|
||||
/**
|
||||
* Gets the {@code ServerBuildInfo}.
|
||||
*
|
||||
@@ -1,564 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Mon, 29 Jan 2024 12:44:10 +0000
|
||||
Subject: [PATCH] Leaves fakeplayer API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||
index b7e1c8bd8dd38e1a9e74925740b22dad61a75f49..36863cd765277b9b551ae04a4ecbee502c4d0a4e 100644
|
||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||
@@ -58,6 +58,7 @@ import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import io.papermc.paper.util.JarManifests; // Paper
|
||||
+import top.leavesmc.leaves.entity.BotManager;
|
||||
|
||||
/**
|
||||
* Represents the Bukkit core, for version and Server singleton handling
|
||||
@@ -2836,6 +2837,18 @@ public final class Bukkit {
|
||||
}
|
||||
// Folia end - region threading API
|
||||
|
||||
+ // Leaves start - Bot API
|
||||
+ /**
|
||||
+ * Returns a bot manager.
|
||||
+ *
|
||||
+ * @return Bot Manager
|
||||
+ */
|
||||
+ public static @NotNull BotManager getBotManager() {
|
||||
+ return server.getBotManager();
|
||||
+ }
|
||||
+ // Leaves end - Bot API
|
||||
+
|
||||
+
|
||||
@NotNull
|
||||
public static Server.Spigot spigot() {
|
||||
return server.spigot();
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index 85b169c04f44431363d4e14d4857140f160ceace..ed89520a9bf17a6f2665a17ded0c334d8f9bf130 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -58,6 +58,7 @@ import org.bukkit.util.CachedServerIcon;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
+import top.leavesmc.leaves.entity.BotManager;
|
||||
|
||||
/**
|
||||
* Represents a server implementation.
|
||||
@@ -2479,4 +2480,14 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
*/
|
||||
public boolean isGlobalTickThread();
|
||||
// Folia end - region threading API
|
||||
+
|
||||
+ // Leaves start - Bot API
|
||||
+ /**
|
||||
+ * Returns a bot manager.
|
||||
+ *
|
||||
+ * @return Bot Manager
|
||||
+ */
|
||||
+ @NotNull BotManager getBotManager();
|
||||
+ // Leaves end - Bot API
|
||||
+
|
||||
}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/entity/Bot.java b/src/main/java/top/leavesmc/leaves/entity/Bot.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..02815077dcd6d5c1b155ef3ca5cd6e3a9c45c0b5
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/entity/Bot.java
|
||||
@@ -0,0 +1,51 @@
|
||||
+package top.leavesmc.leaves.entity;
|
||||
+
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+import top.leavesmc.leaves.entity.botaction.LeavesBotAction;
|
||||
+
|
||||
+import java.util.UUID;
|
||||
+
|
||||
+/**
|
||||
+ * Represents a fakeplayer
|
||||
+ */
|
||||
+public interface Bot extends Player {
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the fakeplayer skin
|
||||
+ *
|
||||
+ * @return fakeplayer skin name
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public String getSkinName();
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the fakeplayer name without prefix and suffix
|
||||
+ *
|
||||
+ * @return fakeplayer real name
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public String getRealName();
|
||||
+
|
||||
+ @Nullable
|
||||
+ public UUID getCreatePlayerUUID();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the fakeplayer action with args.
|
||||
+ *
|
||||
+ * @param action action name
|
||||
+ * @param player player who create this action
|
||||
+ * @param args passed action arguments
|
||||
+ */
|
||||
+ public boolean setBotAction(@NotNull String action, @NotNull Player player, @NotNull String[] args);
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the fakeplayer action with args.
|
||||
+ *
|
||||
+ * @param action leaves bot action
|
||||
+ * @param player player who create this action
|
||||
+ * @param args passed action arguments
|
||||
+ */
|
||||
+ public boolean setBotAction(@NotNull LeavesBotAction action, @NotNull Player player, @NotNull String[] args);
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/entity/BotManager.java b/src/main/java/top/leavesmc/leaves/entity/BotManager.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..f2258027b2ed4bfcf7feda2e9075b1a1a05a85b6
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/entity/BotManager.java
|
||||
@@ -0,0 +1,107 @@
|
||||
+package top.leavesmc.leaves.entity;
|
||||
+
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.util.Consumer;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+import top.leavesmc.leaves.entity.botaction.CustomBotAction;
|
||||
+
|
||||
+import java.util.Collection;
|
||||
+import java.util.UUID;
|
||||
+
|
||||
+/**
|
||||
+ * Simple fakeplayer manager
|
||||
+ */
|
||||
+public interface BotManager {
|
||||
+
|
||||
+ /**
|
||||
+ * Gets a fakeplayer object by the given uuid.
|
||||
+ *
|
||||
+ * @param uuid the uuid to look up
|
||||
+ * @return a fakeplayer if one was found, null otherwise
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public Bot getBot(@NotNull UUID uuid);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets a fakeplayer object by the given name.
|
||||
+ *
|
||||
+ * @param name the name to look up
|
||||
+ * @return a fakeplayer if one was found, null otherwise
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public Bot getBot(@NotNull String name);
|
||||
+
|
||||
+ /**
|
||||
+ * Creates a fakeplayer with given param.
|
||||
+ * <p>
|
||||
+ * prefix and suffix will not be added.
|
||||
+ *
|
||||
+ * @param name fakeplayer name
|
||||
+ * @param realName fakeplayer real name
|
||||
+ * @param skin fakeplayer skin arr
|
||||
+ * @param skinName fakeplayer skin name
|
||||
+ * @param location a location will create fakeplayer
|
||||
+ * @return a fakeplayer if success, null otherwise
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public Bot createBot(@NotNull String name, @NotNull String realName, @Nullable String[] skin, @Nullable String skinName, @NotNull Location location);
|
||||
+
|
||||
+ /**
|
||||
+ * Creates a fakeplayer with given param.
|
||||
+ *
|
||||
+ * @param name fakeplayer name
|
||||
+ * @param skinName fakeplayer skin name
|
||||
+ * @param location a location will create fakeplayer
|
||||
+ * @param consumer a consumer after create fakeplayer success
|
||||
+ */
|
||||
+ public void createBot(@NotNull String name, @Nullable String skinName, @NotNull Location location, @Nullable Consumer<Bot> consumer);
|
||||
+
|
||||
+ /**
|
||||
+ * Removes a fakeplayer object by the given name.
|
||||
+ *
|
||||
+ * @param name the name to look up
|
||||
+ */
|
||||
+ public void removeBot(@NotNull String name);
|
||||
+
|
||||
+ /**
|
||||
+ * Removes a fakeplayer object by the given uuid.
|
||||
+ *
|
||||
+ * @param uuid the uuid to look up
|
||||
+ */
|
||||
+ public void removeBot(@NotNull UUID uuid);
|
||||
+
|
||||
+ /**
|
||||
+ * Removes all fakeplayers.
|
||||
+ */
|
||||
+ public void removeAllBots();
|
||||
+
|
||||
+ /**
|
||||
+ * Save fakeplayers data if resident-fakeplayer is true, or remove all fakeplayer.
|
||||
+ */
|
||||
+ public void saveOrRemoveAllBots();
|
||||
+
|
||||
+ /**
|
||||
+ * Gets a view of all currently logged in fakeplayers. This view is a reused object, making some operations like Collection.size() zero-allocation.
|
||||
+ *
|
||||
+ * @return a view of fakeplayers.
|
||||
+ */
|
||||
+ public Collection<Bot> getBots();
|
||||
+
|
||||
+ /**
|
||||
+ * Register a custom bot action.
|
||||
+ *
|
||||
+ * @param name action name
|
||||
+ * @param action action executor
|
||||
+ * @return true if success, or false
|
||||
+ */
|
||||
+ public boolean registerCustomBotAction(String name, CustomBotAction action);
|
||||
+
|
||||
+ /**
|
||||
+ * Unregister a custom bot action.
|
||||
+ *
|
||||
+ * @param name action name
|
||||
+ * @return true if success, or false
|
||||
+ */
|
||||
+ public boolean unregisterCustomBotAction(String name);
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/entity/botaction/CustomBotAction.java b/src/main/java/top/leavesmc/leaves/entity/botaction/CustomBotAction.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7abf4eef22e40468929e724ebc07a97b0b2a05f3
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/entity/botaction/CustomBotAction.java
|
||||
@@ -0,0 +1,52 @@
|
||||
+package top.leavesmc.leaves.entity.botaction;
|
||||
+
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+import top.leavesmc.leaves.entity.Bot;
|
||||
+
|
||||
+import java.util.List;
|
||||
+
|
||||
+/**
|
||||
+ * Represents a class which contains methods for a custom bot action
|
||||
+ */
|
||||
+public interface CustomBotAction {
|
||||
+
|
||||
+ /**
|
||||
+ * Executes the action, returning its success.
|
||||
+ *
|
||||
+ * @param bot bot of the action
|
||||
+ * @return true if once action finish, otherwise false
|
||||
+ */
|
||||
+ public boolean doTick(Bot bot);
|
||||
+
|
||||
+ /**
|
||||
+ * Created a new action instance.
|
||||
+ *
|
||||
+ * @param player player who create this action
|
||||
+ * @param args passed action arguments
|
||||
+ * @return a new action instance with given args
|
||||
+ */
|
||||
+ public @Nullable CustomBotAction getNew(Player player, String[] args);
|
||||
+
|
||||
+ /**
|
||||
+ * Requests a list of possible completions for a action argument.
|
||||
+ *
|
||||
+ * @return A List of a List of possible completions for the argument.
|
||||
+ */
|
||||
+ public @NotNull List<List<String>> getTabComplete();
|
||||
+
|
||||
+ /**
|
||||
+ * Return a ticks to wait between {@link CustomBotAction#doTick(Bot)}
|
||||
+ *
|
||||
+ * @return the ticks to wait between runs
|
||||
+ */
|
||||
+ public int getTickDelay();
|
||||
+
|
||||
+ /**
|
||||
+ * Return a number of times {@link CustomBotAction#doTick(Bot)} can return true
|
||||
+ *
|
||||
+ * @return the number of times an action can be executed
|
||||
+ */
|
||||
+ public int getNumber();
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/entity/botaction/LeavesBotAction.java b/src/main/java/top/leavesmc/leaves/entity/botaction/LeavesBotAction.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e298722319ff0cfd52e531693ea3767e5f9a3d52
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/entity/botaction/LeavesBotAction.java
|
||||
@@ -0,0 +1,32 @@
|
||||
+package top.leavesmc.leaves.entity.botaction;
|
||||
+
|
||||
+/**
|
||||
+ * A Leaves bot action enum
|
||||
+ */
|
||||
+public enum LeavesBotAction {
|
||||
+ ATTACK("attack"),
|
||||
+ ATTACK_SELF("attack_self"),
|
||||
+ BREAK("break"),
|
||||
+ DROP("drop"),
|
||||
+ FISH("fish"),
|
||||
+ JUMP("jump"),
|
||||
+ LAY("lay"),
|
||||
+ LOOK("look"),
|
||||
+ ROTATE("rotate"),
|
||||
+ SNEAK("sneak"),
|
||||
+ STOP("stop"),
|
||||
+ SWIM("swim"),
|
||||
+ USE("use"),
|
||||
+ USE_ON("use_on"),
|
||||
+ USE_TO("use_to");
|
||||
+
|
||||
+ private final String name;
|
||||
+
|
||||
+ private LeavesBotAction(String name) {
|
||||
+ this.name = name;
|
||||
+ }
|
||||
+
|
||||
+ public String getName() {
|
||||
+ return name;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/event/bot/BotCreateEvent.java b/src/main/java/top/leavesmc/leaves/event/bot/BotCreateEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7cf1eb4eb3d2fe9310f9272ec53208632b87b49b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/event/bot/BotCreateEvent.java
|
||||
@@ -0,0 +1,106 @@
|
||||
+package top.leavesmc.leaves.event.bot;
|
||||
+
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+/**
|
||||
+ * Call when a fakeplayer creates a server
|
||||
+ */
|
||||
+public class BotCreateEvent extends Event implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+
|
||||
+ private final String bot;
|
||||
+ private final String skin;
|
||||
+ private String joinMessage;
|
||||
+ private Location createLocation;
|
||||
+ private boolean cancel = false;
|
||||
+
|
||||
+ public BotCreateEvent(@NotNull final String who, @NotNull final String skin, @NotNull final Location createLocation, @Nullable final String joinMessage) {
|
||||
+ this.bot = who;
|
||||
+ this.skin = skin;
|
||||
+ this.joinMessage = joinMessage;
|
||||
+ this.createLocation = createLocation;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the fakeplayer name
|
||||
+ *
|
||||
+ * @return fakeplayer name
|
||||
+ */
|
||||
+ public String getBot() {
|
||||
+ return bot;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the join message to send to all online players
|
||||
+ *
|
||||
+ * @return string join message. Can be null
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public String getJoinMessage() {
|
||||
+ return joinMessage;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the join message to send to all online players
|
||||
+ *
|
||||
+ * @param joinMessage join message. If null, no message will be sent
|
||||
+ */
|
||||
+ public void setJoinMessage(@Nullable String joinMessage) {
|
||||
+ this.joinMessage = joinMessage;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the location to create the fakeplayer
|
||||
+ *
|
||||
+ * @return Location to create the fakeplayer
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Location getCreateLocation() {
|
||||
+ return createLocation;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the location to create the fakeplayer
|
||||
+ *
|
||||
+ * @param createLocation location to create the fakeplayer
|
||||
+ */
|
||||
+ public void setCreateLocation(@NotNull Location createLocation) {
|
||||
+ this.createLocation = createLocation;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the fakeplayer skin
|
||||
+ *
|
||||
+ * @return fakeplayer skin name
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public String getSkin() {
|
||||
+ return skin;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancel = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/event/bot/BotEvent.java b/src/main/java/top/leavesmc/leaves/event/bot/BotEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..4a4fe07ce965d4a97e0d8105a91310dac7d1343c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/event/bot/BotEvent.java
|
||||
@@ -0,0 +1,31 @@
|
||||
+package top.leavesmc.leaves.event.bot;
|
||||
+
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import top.leavesmc.leaves.entity.Bot;
|
||||
+
|
||||
+/**
|
||||
+ * Represents a fakeplayer related event
|
||||
+ */
|
||||
+public abstract class BotEvent extends Event {
|
||||
+ protected Bot bot;
|
||||
+
|
||||
+ public BotEvent(@NotNull final Bot who) {
|
||||
+ bot = who;
|
||||
+ }
|
||||
+
|
||||
+ public BotEvent(@NotNull final Bot who, boolean async) { // Paper - public
|
||||
+ super(async);
|
||||
+ bot = who;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the fakeplayer involved in this event
|
||||
+ *
|
||||
+ * @return Fakeplayer who is involved in this event
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public final Bot getBot() {
|
||||
+ return bot;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/event/bot/BotInventoryOpenEvent.java b/src/main/java/top/leavesmc/leaves/event/bot/BotInventoryOpenEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e889f7e98ec9cb6a3b95d8ea865e25fffea662a1
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/event/bot/BotInventoryOpenEvent.java
|
||||
@@ -0,0 +1,46 @@
|
||||
+package top.leavesmc.leaves.event.bot;
|
||||
+
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+import top.leavesmc.leaves.entity.Bot;
|
||||
+
|
||||
+public class BotInventoryOpenEvent extends BotEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+
|
||||
+ private final Player player;
|
||||
+ private boolean cancel = false;
|
||||
+
|
||||
+ public BotInventoryOpenEvent(@NotNull Bot who, @Nullable Player player) {
|
||||
+ super(who);
|
||||
+ this.player = player;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancel = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public Player getOpenPlayer() {
|
||||
+ return player;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/event/bot/BotJoinEvent.java b/src/main/java/top/leavesmc/leaves/event/bot/BotJoinEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..10afa5c7fd4ee8a4e72d64f8ca9bf8731ec2ad61
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/event/bot/BotJoinEvent.java
|
||||
@@ -0,0 +1,27 @@
|
||||
+package top.leavesmc.leaves.event.bot;
|
||||
+
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import top.leavesmc.leaves.entity.Bot;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a fakeplayer joins a server
|
||||
+ */
|
||||
+public class BotJoinEvent extends BotEvent {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+
|
||||
+ public BotJoinEvent(@NotNull Bot who) {
|
||||
+ super(who);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
@@ -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 <wangxyper@163.com>
|
||||
Date: Fri, 25 Oct 2024 00:07:15 +0800
|
||||
Subject: [PATCH] KioCG Chunk API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Chunk.java b/src/main/java/org/bukkit/Chunk.java
|
||||
index bc8b5bc17706250b8535b1b309134843d2ce2bb1..1cfe84ad1094e3c4fab96487f328be53e035a64c 100644
|
||||
--- a/src/main/java/org/bukkit/Chunk.java
|
||||
+++ b/src/main/java/org/bukkit/Chunk.java
|
||||
@@ -389,4 +389,6 @@ public interface Chunk extends PersistentDataHolder {
|
||||
*/
|
||||
UNLOADED;
|
||||
}
|
||||
+
|
||||
+ long getChunkHotAvg(); // KioCG
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||
index 95f0b3186e313c7fbd5c8531d52b82a69e525f94..ce98b3de2fe935de4c280f7af9940499d6f09926 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -3911,4 +3911,6 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||
*/
|
||||
void sendEntityEffect(org.bukkit.@NotNull EntityEffect effect, @NotNull Entity target);
|
||||
// Paper end - entity effect API
|
||||
+
|
||||
+ long getNearbyChunkHot(); // KioCG
|
||||
}
|
||||
68
patches/api/0004-FoliaPR-Add-TPS-From-Region.patch
Normal file
68
patches/api/0004-FoliaPR-Add-TPS-From-Region.patch
Normal file
@@ -0,0 +1,68 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Tue, 30 Jul 2024 17:58:25 +0800
|
||||
Subject: [PATCH] FoliaPR Add TPS From Region
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||
index 5ce98e09e9bfcae45896401c69578aa879222893..dacb9342f21ba045b97f004c6c9970adbc2b9eb5 100644
|
||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||
@@ -2429,6 +2429,28 @@ public final class Bukkit {
|
||||
}
|
||||
// Paper end
|
||||
|
||||
+ // Folia start
|
||||
+ /**
|
||||
+ * Gets the current location TPS.
|
||||
+ *
|
||||
+ * @param location the location for which to get the TPS
|
||||
+ * @return current location TPS (5s, 15s, 1m, 5m, 15m in Folia-Server), or null if the region doesn't exist
|
||||
+ */
|
||||
+ public double @Nullable [] getTPS(Location location) {
|
||||
+ return server.getTPS(location);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the current chunk TPS.
|
||||
+ *
|
||||
+ * @param chunk the chunk for which to get the TPS
|
||||
+ * @return current chunk TPS (5s, 15s, 1m, 5m, 15m in Folia-Server), or null if the region doesn't exist
|
||||
+ */
|
||||
+ public double @Nullable [] getTPS(Chunk chunk){
|
||||
+ return server.getTPS(chunk);
|
||||
+ }
|
||||
+ // Folia end
|
||||
+
|
||||
/**
|
||||
* Get the advancement specified by this key.
|
||||
*
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index a92bd4da6788f1331a4838ab5760baec2dc6e8ec..32ec411df95dbce73700ce47fb24737f1f508bb5 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -2076,6 +2076,24 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
double getAverageTickTime();
|
||||
// Paper end
|
||||
|
||||
+ // Folia start
|
||||
+ /**
|
||||
+ * Gets the current location TPS.
|
||||
+ *
|
||||
+ * @param location the location for which to get the TPS
|
||||
+ * @return current location TPS (5s, 15s, 1m, 5m, 15m in Folia-Server), or null if the region doesn't exist
|
||||
+ */
|
||||
+ public double @Nullable [] getTPS(Location location);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the current chunk TPS.
|
||||
+ *
|
||||
+ * @param chunk the chunk for which to get the TPS
|
||||
+ * @return current chunk TPS (5s, 15s, 1m, 5m, 15m in Folia-Server), or null if the region doesn't exist
|
||||
+ */
|
||||
+ public double @Nullable [] getTPS(Chunk chunk);
|
||||
+ // Folia end
|
||||
+
|
||||
// Paper start
|
||||
/**
|
||||
* Gets the active {@link org.bukkit.command.CommandMap}
|
||||
118
patches/api/0005-Pufferfish-SIMD-Utilities.patch
Normal file
118
patches/api/0005-Pufferfish-SIMD-Utilities.patch
Normal file
@@ -0,0 +1,118 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Tue, 6 Aug 2024 14:32:22 +0800
|
||||
Subject: [PATCH] Pufferfish SIMD Utilities
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 571534b42cd9c33d6a7bb6fe3bf3a28e33f8e5de..1aa76451f9129b578d6887b1239966eb67f5ee1b 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -150,6 +150,13 @@ val generateApiVersioningFile by tasks.registering {
|
||||
}
|
||||
}
|
||||
|
||||
+// Pufferfish Start
|
||||
+tasks.withType<JavaCompile> {
|
||||
+ val compilerArgs = options.compilerArgs
|
||||
+ compilerArgs.add("--add-modules=jdk.incubator.vector")
|
||||
+}
|
||||
+// Pufferfish End
|
||||
+
|
||||
tasks.jar {
|
||||
from(generateApiVersioningFile.map { it.outputs.files.singleFile }) {
|
||||
into("META-INF/maven/${project.group}/${project.name}")
|
||||
@@ -209,6 +216,7 @@ tasks.withType<Javadoc> {
|
||||
into("build/docs/javadoc")
|
||||
}
|
||||
}
|
||||
+ options.addStringOption("-add-modules", "jdk.incubator.vector") // Pufferfish - SIMD support
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..f00c008c03e2533f568085838cf13cb9b5b32cd9
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
|
||||
@@ -0,0 +1,39 @@
|
||||
+package gg.pufferfish.pufferfish.simd;
|
||||
+
|
||||
+import jdk.incubator.vector.FloatVector;
|
||||
+import jdk.incubator.vector.IntVector;
|
||||
+import jdk.incubator.vector.VectorSpecies;
|
||||
+import org.slf4j.Logger;
|
||||
+
|
||||
+/**
|
||||
+ * Basically, java is annoying and we have to push this out to its own class.
|
||||
+ */
|
||||
+@Deprecated
|
||||
+public class SIMDChecker {
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public static boolean canEnable(Logger logger) {
|
||||
+ try {
|
||||
+ if (SIMDDetection.getJavaVersion() < 17 || SIMDDetection.getJavaVersion() > 21) {
|
||||
+ return false;
|
||||
+ } else {
|
||||
+ SIMDDetection.testRun = true;
|
||||
+
|
||||
+ VectorSpecies<Integer> ISPEC = IntVector.SPECIES_PREFERRED;
|
||||
+ VectorSpecies<Float> FSPEC = FloatVector.SPECIES_PREFERRED;
|
||||
+
|
||||
+ logger.info("Max SIMD vector size on this system is {} bits (int)", ISPEC.vectorBitSize());
|
||||
+ logger.info("Max SIMD vector size on this system is " + FSPEC.vectorBitSize() + " bits (float)");
|
||||
+
|
||||
+ if (ISPEC.elementSize() < 2 || FSPEC.elementSize() < 2) {
|
||||
+ logger.warn("SIMD is not properly supported on this system!");
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+ } catch (NoClassDefFoundError | Exception ignored) {} // Basically, we don't do anything. This lets us detect if it's not functional and disable it.
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..cd953435a6179eaae7c9cc250a791cae26c5567b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java
|
||||
@@ -0,0 +1,35 @@
|
||||
+package gg.pufferfish.pufferfish.simd;
|
||||
+
|
||||
+import org.slf4j.Logger;
|
||||
+
|
||||
+@Deprecated
|
||||
+public class SIMDDetection {
|
||||
+
|
||||
+ public static boolean isEnabled = false;
|
||||
+ public static boolean versionLimited = false;
|
||||
+ public static boolean testRun = false;
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public static boolean canEnable(Logger logger) {
|
||||
+ try {
|
||||
+ return SIMDChecker.canEnable(logger);
|
||||
+ } catch (NoClassDefFoundError | Exception ignored) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public static int getJavaVersion() {
|
||||
+ // https://stackoverflow.com/a/2591122
|
||||
+ String version = System.getProperty("java.version");
|
||||
+ if(version.startsWith("1.")) {
|
||||
+ version = version.substring(2, 3);
|
||||
+ } else {
|
||||
+ int dot = version.indexOf(".");
|
||||
+ if(dot != -1) { version = version.substring(0, dot); }
|
||||
+ }
|
||||
+ version = version.split("-")[0]; // Azul is stupid
|
||||
+ return Integer.parseInt(version);
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
45
patches/api/0006-Disable-timings-warn-msg-and-commands.patch
Normal file
45
patches/api/0006-Disable-timings-warn-msg-and-commands.patch
Normal file
@@ -0,0 +1,45 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sat, 30 Nov 2024 12:34:50 +0800
|
||||
Subject: [PATCH] Disable timings warn msg and commands
|
||||
|
||||
|
||||
diff --git a/src/main/java/co/aikar/timings/Timings.java b/src/main/java/co/aikar/timings/Timings.java
|
||||
index 89017af09ce32e7a66014fc3aeb50155921252a5..b862779b48176dd7e67a2f1a3e7f24bc8c84e993 100644
|
||||
--- a/src/main/java/co/aikar/timings/Timings.java
|
||||
+++ b/src/main/java/co/aikar/timings/Timings.java
|
||||
@@ -147,7 +147,7 @@ public final class Timings {
|
||||
public static void setTimingsEnabled(boolean enabled) {
|
||||
enabled = false; // Folia - region threading - disable timings
|
||||
if (enabled && !warnedAboutDeprecationOnEnable) {
|
||||
- Bukkit.getLogger().severe(PlainTextComponentSerializer.plainText().serialize(deprecationMessage()));
|
||||
+ // Bukkit.getLogger().severe(PlainTextComponentSerializer.plainText().serialize(deprecationMessage())); // Luminol - Disable timings warn msg and commands
|
||||
warnedAboutDeprecationOnEnable = true;
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||
index 5df19bd701c67506689fc7f49d91f99ebfbc83f0..baf0cbd2f995ebe2e4382244eff6e15ec125d790 100644
|
||||
--- a/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||
+++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||
@@ -39,7 +39,7 @@ public class SimpleCommandMap implements CommandMap {
|
||||
register("bukkit", new VersionCommand("version"));
|
||||
register("bukkit", new ReloadCommand("reload"));
|
||||
//register("bukkit", new PluginsCommand("plugins")); // Paper
|
||||
- register("bukkit", new co.aikar.timings.TimingsCommand("timings")); // Paper
|
||||
+ //register("bukkit", new co.aikar.timings.TimingsCommand("timings")); // Paper // Luminol - Disable timings warn msg and commands
|
||||
}
|
||||
|
||||
public void setFallbackCommands() {
|
||||
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
index 9611e8e254b4fa9579dc9ffd5198182c43819c56..170fefdc50605c0c4d742a606c18d871966e6e72 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
@@ -966,7 +966,7 @@ public final class SimplePluginManager implements PluginManager {
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public void useTimings(boolean use) {
|
||||
- co.aikar.timings.Timings.setTimingsEnabled(use); // Paper
|
||||
+ // co.aikar.timings.Timings.setTimingsEnabled(use); // Paper // Luminol - Disable timings warn msg and commands
|
||||
}
|
||||
|
||||
// Paper start
|
||||
243
patches/api/0007-Pufferfish-Sentry.patch
Normal file
243
patches/api/0007-Pufferfish-Sentry.patch
Normal file
@@ -0,0 +1,243 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: adabugra <57899270+adabugra@users.noreply.github.com>
|
||||
Date: Mon, 6 Jan 2025 19:24:06 +0300
|
||||
Subject: [PATCH] Pufferfish: Sentry
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 1aa76451f9129b578d6887b1239966eb67f5ee1b..2ddad10cf12dd07fd227ddda13336fdd61cd0197 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -66,6 +66,7 @@ dependencies {
|
||||
apiAndDocs("net.kyori:adventure-text-logger-slf4j")
|
||||
api("org.apache.logging.log4j:log4j-api:$log4jVersion")
|
||||
api("org.slf4j:slf4j-api:$slf4jVersion")
|
||||
+ api("io.sentry:sentry:8.0.0-rc.2") // Pufferfish
|
||||
|
||||
implementation("org.ow2.asm:asm:9.7.1")
|
||||
implementation("org.ow2.asm:asm-commons:9.7.1")
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/sentry/SentryContext.java b/src/main/java/gg/pufferfish/pufferfish/sentry/SentryContext.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..c7772aac00f6db664f7a5673bc2585fa025e6aad
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/sentry/SentryContext.java
|
||||
@@ -0,0 +1,165 @@
|
||||
+package gg.pufferfish.pufferfish.sentry;
|
||||
+
|
||||
+import com.google.gson.Gson;
|
||||
+
|
||||
+import java.lang.reflect.Field;
|
||||
+import java.lang.reflect.Modifier;
|
||||
+import java.util.Map;
|
||||
+import java.util.TreeMap;
|
||||
+
|
||||
+import org.apache.logging.log4j.ThreadContext;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.player.PlayerEvent;
|
||||
+import org.bukkit.plugin.Plugin;
|
||||
+import org.bukkit.plugin.RegisteredListener;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+public class SentryContext {
|
||||
+
|
||||
+ private static final Gson GSON = new Gson();
|
||||
+
|
||||
+ public static void setPluginContext(@Nullable Plugin plugin) {
|
||||
+ if (plugin != null) {
|
||||
+ ThreadContext.put("pufferfishsentry_pluginname", plugin.getName());
|
||||
+ ThreadContext.put("pufferfishsentry_pluginversion", plugin.getPluginMeta().getVersion());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void removePluginContext() {
|
||||
+ ThreadContext.remove("pufferfishsentry_pluginname");
|
||||
+ ThreadContext.remove("pufferfishsentry_pluginversion");
|
||||
+ }
|
||||
+
|
||||
+ public static void setSenderContext(@Nullable CommandSender sender) {
|
||||
+ if (sender != null) {
|
||||
+ ThreadContext.put("pufferfishsentry_playername", sender.getName());
|
||||
+ if (sender instanceof Player player) {
|
||||
+ ThreadContext.put("pufferfishsentry_playerid", player.getUniqueId().toString());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void removeSenderContext() {
|
||||
+ ThreadContext.remove("pufferfishsentry_playername");
|
||||
+ ThreadContext.remove("pufferfishsentry_playerid");
|
||||
+ }
|
||||
+
|
||||
+ public static void setEventContext(Event event, RegisteredListener registration) {
|
||||
+ setPluginContext(registration.getPlugin());
|
||||
+
|
||||
+ try {
|
||||
+ // Find the player that was involved with this event
|
||||
+ Player player = null;
|
||||
+ if (event instanceof PlayerEvent) {
|
||||
+ player = ((PlayerEvent) event).getPlayer();
|
||||
+ } else {
|
||||
+ Class<? extends Event> eventClass = event.getClass();
|
||||
+
|
||||
+ Field playerField = null;
|
||||
+
|
||||
+ for (Field field : eventClass.getDeclaredFields()) {
|
||||
+ if (field.getType().equals(Player.class)) {
|
||||
+ playerField = field;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (playerField != null) {
|
||||
+ playerField.setAccessible(true);
|
||||
+ player = (Player) playerField.get(event);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (player != null) {
|
||||
+ setSenderContext(player);
|
||||
+ }
|
||||
+ } catch (Exception ignored) {
|
||||
+ } // We can't really safely log exceptions.
|
||||
+
|
||||
+ ThreadContext.put("pufferfishsentry_eventdata", GSON.toJson(serializeFields(event)));
|
||||
+ }
|
||||
+
|
||||
+ public static void removeEventContext() {
|
||||
+ removePluginContext();
|
||||
+ removeSenderContext();
|
||||
+ ThreadContext.remove("pufferfishsentry_eventdata");
|
||||
+ }
|
||||
+
|
||||
+ private static Map<String, String> serializeFields(Object object) {
|
||||
+ Map<String, String> fields = new TreeMap<>();
|
||||
+ fields.put("_class", object.getClass().getName());
|
||||
+ for (Field declaredField : object.getClass().getDeclaredFields()) {
|
||||
+ try {
|
||||
+ if (Modifier.isStatic(declaredField.getModifiers())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ String fieldName = declaredField.getName();
|
||||
+ if (fieldName.equals("handlers")) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ declaredField.setAccessible(true);
|
||||
+ Object value = declaredField.get(object);
|
||||
+ if (value != null) {
|
||||
+ fields.put(fieldName, value.toString());
|
||||
+ } else {
|
||||
+ fields.put(fieldName, "<null>");
|
||||
+ }
|
||||
+ } catch (Exception ignored) {
|
||||
+ } // We can't really safely log exceptions.
|
||||
+ }
|
||||
+ return fields;
|
||||
+ }
|
||||
+
|
||||
+ public static class State {
|
||||
+
|
||||
+ private Plugin plugin;
|
||||
+ private Command command;
|
||||
+ private String commandLine;
|
||||
+ private Event event;
|
||||
+ private RegisteredListener registeredListener;
|
||||
+
|
||||
+ public Plugin getPlugin() {
|
||||
+ return plugin;
|
||||
+ }
|
||||
+
|
||||
+ public void setPlugin(Plugin plugin) {
|
||||
+ this.plugin = plugin;
|
||||
+ }
|
||||
+
|
||||
+ public Command getCommand() {
|
||||
+ return command;
|
||||
+ }
|
||||
+
|
||||
+ public void setCommand(Command command) {
|
||||
+ this.command = command;
|
||||
+ }
|
||||
+
|
||||
+ public String getCommandLine() {
|
||||
+ return commandLine;
|
||||
+ }
|
||||
+
|
||||
+ public void setCommandLine(String commandLine) {
|
||||
+ this.commandLine = commandLine;
|
||||
+ }
|
||||
+
|
||||
+ public Event getEvent() {
|
||||
+ return event;
|
||||
+ }
|
||||
+
|
||||
+ public void setEvent(Event event) {
|
||||
+ this.event = event;
|
||||
+ }
|
||||
+
|
||||
+ public RegisteredListener getRegisteredListener() {
|
||||
+ return registeredListener;
|
||||
+ }
|
||||
+
|
||||
+ public void setRegisteredListener(RegisteredListener registeredListener) {
|
||||
+ this.registeredListener = registeredListener;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
index ab36e3aaff57e2f27b5aed06b4bdfe277f86a35e..96da9f1082ab134d197b3a6069f2fcdf38585efe 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
@@ -597,7 +597,9 @@ public final class SimplePluginManager implements PluginManager {
|
||||
|
||||
// Paper start
|
||||
private void handlePluginException(String msg, Throwable ex, Plugin plugin) {
|
||||
+ gg.pufferfish.pufferfish.sentry.SentryContext.setPluginContext(plugin); // Pufferfish
|
||||
server.getLogger().log(Level.SEVERE, msg, ex);
|
||||
+ gg.pufferfish.pufferfish.sentry.SentryContext.removePluginContext(); // Pufferfish
|
||||
callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerPluginEnableDisableException(msg, ex, plugin)));
|
||||
}
|
||||
// Paper end
|
||||
@@ -667,9 +669,11 @@ public final class SimplePluginManager implements PluginManager {
|
||||
));
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
+ gg.pufferfish.pufferfish.sentry.SentryContext.setEventContext(event, registration); // Pufferfish
|
||||
// Paper start - error reporting
|
||||
String msg = "Could not pass event " + event.getEventName() + " to " + registration.getPlugin().getDescription().getFullName();
|
||||
server.getLogger().log(Level.SEVERE, msg, ex);
|
||||
+ gg.pufferfish.pufferfish.sentry.SentryContext.removeEventContext(); // Pufferfish
|
||||
if (!(event instanceof com.destroystokyo.paper.event.server.ServerExceptionEvent)) { // We don't want to cause an endless event loop
|
||||
callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerEventException(msg, ex, registration.getPlugin(), registration.getListener(), event)));
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||
index b412aaf08901d169ac9fc89b36f9d6ccb95c53d3..45a9ca8969f635d20cc44c062fda85bbccd8f8ff 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||
@@ -336,7 +336,13 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
try {
|
||||
jPlugin.setEnabled(true);
|
||||
} catch (Throwable ex) {
|
||||
+ gg.pufferfish.pufferfish.sentry.SentryContext.setPluginContext(plugin); // Pufferfish
|
||||
server.getLogger().log(Level.SEVERE, "Error occurred while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
|
||||
+ gg.pufferfish.pufferfish.sentry.SentryContext.removePluginContext(); // Pufferfish
|
||||
+ // Paper start - Disable plugins that fail to load
|
||||
+ this.server.getPluginManager().disablePlugin(jPlugin);
|
||||
+ return;
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
// Perhaps abort here, rather than continue going, but as it stands,
|
||||
@@ -361,7 +367,9 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
try {
|
||||
jPlugin.setEnabled(false);
|
||||
} catch (Throwable ex) {
|
||||
+ gg.pufferfish.pufferfish.sentry.SentryContext.setPluginContext(plugin); // Pufferfish
|
||||
server.getLogger().log(Level.SEVERE, "Error occurred while disabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
|
||||
+ gg.pufferfish.pufferfish.sentry.SentryContext.removePluginContext(); // Pufferfish
|
||||
}
|
||||
|
||||
if (cloader instanceof PluginClassLoader) {
|
||||
@@ -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 <wangxyper@163.com>
|
||||
Date: Wed, 4 Dec 2024 23:04:00 +0800
|
||||
Subject: [PATCH] Fix build
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 0cd12a854e544e867abfd94c18a9f138ba57e587..d295ee01481b088a376691de7c0927e95d7a68a8 100644
|
||||
index 8d2b5fec6fe27dca3ce01ba1ce50506179fc3b4d..dd6cc4972a209e58313a2b6c6fe87c3605fe34ae 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -14,7 +14,7 @@ val alsoShade: Configuration by configurations.creating
|
||||
@@ -25,7 +25,7 @@ abstract class MockitoAgentProvider : CommandLineArgumentProvider {
|
||||
// Paper end - configure mockito agent that is needed in newer java versions
|
||||
|
||||
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
|
||||
implementation("ca.spottedleaf:concurrentutil:0.0.2") // Paper - Add ConcurrentUtil dependency
|
||||
// Paper start
|
||||
implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+
|
||||
|
||||
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
|
||||
608
patches/server/0003-Empty-config-file-base.patch
Normal file
608
patches/server/0003-Empty-config-file-base.patch
Normal file
@@ -0,0 +1,608 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 4 Dec 2024 23:07:13 +0800
|
||||
Subject: [PATCH] Empty config file base
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 17d2d18d7898e4f0898cc18c930b7cb26f826f2a..017dc1ff0a7c6f7c50a57bf615fc31947ed49639 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -26,6 +26,7 @@ abstract class MockitoAgentProvider : CommandLineArgumentProvider {
|
||||
|
||||
dependencies {
|
||||
implementation(project(":luminol-api")) // Folia // Luminol
|
||||
+ implementation("com.electronwill.night-config:toml:3.6.6") // Luminol - Night config
|
||||
implementation("ca.spottedleaf:concurrentutil:0.0.2") // Paper - Add ConcurrentUtil dependency
|
||||
// Paper start
|
||||
implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+
|
||||
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..7b75405c468d24ed8aea5aa54ae5ac339118bf60
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/EnumConfigCategory.java
|
||||
@@ -0,0 +1,19 @@
|
||||
+package me.earthme.luminol.config;
|
||||
+
|
||||
+public enum EnumConfigCategory {
|
||||
+ OPTIMIZATIONS("optimizations"),
|
||||
+ FIXES("fixes"),
|
||||
+ MISC("misc"),
|
||||
+ GAMEPLAY("gameplay"),
|
||||
+ EXPERIMENT("experiment");
|
||||
+
|
||||
+ 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..526b68e184a2f6f9e38cd02995b473a943404141
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/LuminolConfig.java
|
||||
@@ -0,0 +1,226 @@
|
||||
+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.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;
|
||||
+
|
||||
+ 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 {
|
||||
+ preLoadConfig();
|
||||
+ finalizeLoadConfig();
|
||||
+ }catch (Exception e){
|
||||
+ logger.error(e);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Contract(" -> new")
|
||||
+ public static @NotNull CompletableFuture<Void> reloadAsync(){
|
||||
+ return CompletableFuture.runAsync(LuminolConfig::reload,task -> RegionizedServer.getInstance().addTask(() -> {
|
||||
+ try{
|
||||
+ task.run();
|
||||
+ }catch (Exception e){
|
||||
+ logger.error(e);
|
||||
+ }
|
||||
+ }));
|
||||
+ }
|
||||
+
|
||||
+ public static void dropAllInstanced(){
|
||||
+ allInstanced.clear();
|
||||
+ }
|
||||
+
|
||||
+ public static void finalizeLoadConfig() {
|
||||
+ for (IConfigModule module : allInstanced) {
|
||||
+ module.onLoaded(configFileInstance);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void preLoadConfig() 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);
|
||||
+ throw new RuntimeException(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);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ 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/me/earthme/luminol/utils/NullPlugin.java b/src/main/java/me/earthme/luminol/utils/NullPlugin.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..de94c8e39f0ae0da80d5a79af63413e287f5d190
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/utils/NullPlugin.java
|
||||
@@ -0,0 +1,152 @@
|
||||
+package me.earthme.luminol.utils;
|
||||
+
|
||||
+import io.papermc.paper.plugin.configuration.PluginMeta;
|
||||
+import io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager;
|
||||
+import org.bukkit.Server;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.configuration.file.FileConfiguration;
|
||||
+import org.bukkit.generator.BiomeProvider;
|
||||
+import org.bukkit.generator.ChunkGenerator;
|
||||
+import org.bukkit.plugin.*;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.io.InputStream;
|
||||
+import java.util.List;
|
||||
+import java.util.logging.Logger;
|
||||
+
|
||||
+public class NullPlugin extends PluginBase {
|
||||
+ private boolean enabled = true;
|
||||
+
|
||||
+ private final String pluginName;
|
||||
+ private PluginDescriptionFile pdf;
|
||||
+
|
||||
+ public NullPlugin() {
|
||||
+ this.pluginName = "Minecraft";
|
||||
+ pdf = new PluginDescriptionFile(pluginName, "1.0", "nms");
|
||||
+ }
|
||||
+
|
||||
+ public void setEnabled(boolean enabled) {
|
||||
+ this.enabled = enabled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public File getDataFolder() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public PluginDescriptionFile getDescription() {
|
||||
+ return pdf;
|
||||
+ }
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public io.papermc.paper.plugin.configuration.PluginMeta getPluginMeta() {
|
||||
+ return pdf;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
+ @Override
|
||||
+ public FileConfiguration getConfig() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public InputStream getResource(String filename) {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void saveConfig() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void saveDefaultConfig() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void saveResource(String resourcePath, boolean replace) {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void reloadConfig() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public PluginLogger getLogger() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public PluginLoader getPluginLoader() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Server getServer() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isEnabled() {
|
||||
+ return enabled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onDisable() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onLoad() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onEnable() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isNaggable() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setNaggable(boolean canNag) {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @Nullable BiomeProvider getDefaultBiomeProvider(@NotNull String worldName, @Nullable String id) {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+
|
||||
+ // Paper start - lifecycle events
|
||||
+ @Override
|
||||
+ public @NotNull io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager<org.bukkit.plugin.Plugin> getLifecycleManager() {
|
||||
+ throw new UnsupportedOperationException("Not supported.");
|
||||
+ }
|
||||
+ // Paper end - lifecycle events
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java
|
||||
index 300a044bb0f0e377133f24469cea1a9669de6e58..b30690eba7f06e5af06fb3019e89c067629b77a6 100644
|
||||
--- a/src/main/java/net/minecraft/server/Main.java
|
||||
+++ b/src/main/java/net/minecraft/server/Main.java
|
||||
@@ -123,6 +123,7 @@ public class Main {
|
||||
}
|
||||
|
||||
io.papermc.paper.plugin.PluginInitializerManager.load(optionset); // Paper
|
||||
+ me.earthme.luminol.config.LuminolConfig.preLoadConfig(); //Luminol - load config file
|
||||
Bootstrap.bootStrap();
|
||||
Bootstrap.validate();
|
||||
Util.startTimerHackThread();
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 78f33298e809a7f6d079d9f2c64e2caa47a1b25a..426efbc58deb56e044a6b51021ea63cd8f120a14 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -223,6 +223,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.finalizeLoadConfig(); //Luminol - load config file
|
||||
+ me.earthme.luminol.config.LuminolConfig.setupLatch(); //Luminol - load config file
|
||||
this.server.spark.enableEarlyIfRequested(); // Paper - spark
|
||||
// Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save
|
||||
if (this.convertOldUsers()) {
|
||||
@@ -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 1676c4abb3f6f71bb7b25351aa58b4e127786fca..8cc0c01a19fc71753d7c3ed4fa7e9992aaf93b5a 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -2121,7 +2121,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,82 +1,73 @@
|
||||
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 <wangxyper@163.com>
|
||||
Date: Sat, 30 Nov 2024 11:26:36 +0800
|
||||
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..865ffe0051d84ac9018ab54a54894c2fe8fd573e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/UnsafeTeleportationConfig.java
|
||||
@@ -0,0 +1,22 @@
|
||||
+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 class UnsafeTeleportationConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled", comments = "Allow non player entities enter end portals if enabled.\n" +
|
||||
+ "If you want to use sand duping,please turn on this.\n" +
|
||||
+ "Warning: This would cause some unsafe issues, you could learn more on : https://github.com/PaperMC/Folia/issues/297")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.FIXES;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "allow_unsafe_teleportation";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
index a498cdbe42df3161c35b2a1652dfa63693366bd6..76e8eca1229430742c6c2557d481fb98c570a8bc 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
@@ -69,7 +69,7 @@ public class FallingBlockEntity extends Entity {
|
||||
public float fallDamagePerDistance;
|
||||
@Nullable
|
||||
public CompoundTag blockData;
|
||||
- public boolean forceTickAfterTeleportToDuplicate;
|
||||
+ public boolean forceTickAfterTeleportToDuplicate = me.earthme.luminol.config.modules.fixes.UnsafeTeleportationConfig.enabled; // Luminol - Unsafe teleportation
|
||||
protected static final EntityDataAccessor<BlockPos> DATA_START_POS = SynchedEntityData.defineId(FallingBlockEntity.class, EntityDataSerializers.BLOCK_POS);
|
||||
public boolean autoExpire = true; // Paper - Expand FallingBlock API
|
||||
|
||||
@@ -430,7 +430,7 @@ public class FallingBlockEntity extends Entity {
|
||||
boolean flag = (resourcekey1 == Level.END || resourcekey == Level.END) && resourcekey1 != resourcekey;
|
||||
Entity entity = super.teleport(teleportTarget);
|
||||
|
||||
- this.forceTickAfterTeleportToDuplicate = entity != null && flag && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowUnsafeEndPortalTeleportation; // Paper
|
||||
+ this.forceTickAfterTeleportToDuplicate = entity != null && flag && (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowUnsafeEndPortalTeleportation || me.earthme.luminol.config.modules.fixes.UnsafeTeleportationConfig.enabled); // Paper // Luminol - Unsafe teleportation
|
||||
return entity;
|
||||
}
|
||||
|
||||
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 385d5bc08928dd990b690b926e174af86f178c64..e357ed9607889536ecd0e6ea8b59c97d3dab631f 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 {
|
||||
|
||||
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
|
||||
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 45b8ac1418864ea32bd625b0d57fcec288ea5b0c..96dfc7062c2b0d371717c2042bf7c8e8b32e8716 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 {
|
||||
// return; // CraftBukkit - always fire event in case plugins wish to change it
|
||||
}
|
||||
|
||||
+ //Luminol start - Unsafe teleportation
|
||||
+ if (!LuminolConfig.safeTeleportation && !(entity instanceof Player)){
|
||||
+ entity.endPortalLogicAsync();
|
||||
+ return;
|
||||
@@ -76,7 +76,11 @@ public class EndPortalBlock extends BaseEntityBlock implements Portal {
|
||||
if (event.isCancelled()) return; // Paper - make cancellable
|
||||
// CraftBukkit end
|
||||
// Folia - region threading - do not show credits
|
||||
-
|
||||
+ // Luminol start - unsafe teleportation
|
||||
+ if (me.earthme.luminol.config.modules.fixes.UnsafeTeleportationConfig.enabled && !(entity instanceof net.minecraft.world.entity.player.Player)) {
|
||||
+ entity.endPortalLogicAsync(pos);
|
||||
+ }
|
||||
+ //Luminol end - Unsafe teleportation
|
||||
+
|
||||
// Paper start - move all of this logic into portal tick
|
||||
entity.portalWorld = ((ServerLevel)world);
|
||||
entity.portalBlock = pos.immutable();
|
||||
+ // Luminol end
|
||||
entity.setAsInsidePortal(this, pos);
|
||||
}
|
||||
|
||||
|
||||
@@ -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-vanilla-random.patch
Normal file
45
patches/server/0006-Add-config-for-vanilla-random.patch
Normal file
@@ -0,0 +1,45 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 12:02:01 +0800
|
||||
Subject: [PATCH] Add config for vanilla random
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/VanillaRandomSourceConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/VanillaRandomSourceConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0e6bfc03be660415c333024b56ac6565e3b61ab1
|
||||
--- /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",comments = "Related with RNG cracks")
|
||||
+ 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 20fe53cc8e9edfc7b7d50f23379e0044e520c84d..eeb094265756e5440c0cdd0784f725f7de536493 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -590,7 +590,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();
|
||||
75
patches/server/0007-Add-config-for-chat-sign.patch
Normal file
75
patches/server/0007-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 a523a83aec3a6ecbec4d60a187edc0c0167d15b4..324df3cce3f5a1ab6b4d2acfbb8e80aa551870d7 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,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
|
||||
386
patches/server/0008-Add-a-simple-tpsbar.patch
Normal file
386
patches/server/0008-Add-a-simple-tpsbar.patch
Normal file
@@ -0,0 +1,386 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 12:05:39 +0800
|
||||
Subject: [PATCH] Add a simple tpsbar
|
||||
|
||||
|
||||
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..01677f210fae53a108bfe194189cb4c233e9fa47
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/commands/TpsBarCommand.java
|
||||
@@ -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;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+public class TpsBarCommand extends Command {
|
||||
+ public TpsBarCommand(@NotNull String name) {
|
||||
+ super(name);
|
||||
+ this.setPermission("luminol.commands.tpsbar");
|
||||
+ this.setDescription("Show the tps and mspt through a bossbar");
|
||||
+ this.setUsage("/tpsbar");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
|
||||
+ if (!testPermission(sender)){
|
||||
+ 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(Component.text("Only player can use this command!").color(TextColor.color(255,0,0)));
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ if (GlobalServerTpsBar.isPlayerVisible(player)) {
|
||||
+ player.sendMessage(Component.text("Disabled tps bar").color(TextColor.color(0,255,0)));
|
||||
+ GlobalServerTpsBar.setVisibilityForPlayer(player,false);
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ 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..de2f03d6e771c09e8da2da454b7ec4a16c0a17ab
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java
|
||||
@@ -0,0 +1,214 @@
|
||||
+package me.earthme.luminol.functions;
|
||||
+
|
||||
+import com.google.common.collect.Maps;
|
||||
+import com.mojang.logging.LogUtils;
|
||||
+import io.papermc.paper.threadedregions.ThreadedRegionizer;
|
||||
+import io.papermc.paper.threadedregions.TickData;
|
||||
+import io.papermc.paper.threadedregions.TickRegionScheduler;
|
||||
+import io.papermc.paper.threadedregions.TickRegions;
|
||||
+import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
||||
+import me.earthme.luminol.config.modules.misc.TpsBarConfig;
|
||||
+import me.earthme.luminol.utils.NullPlugin;
|
||||
+import net.kyori.adventure.bossbar.BossBar;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
+import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.slf4j.Logger;
|
||||
+
|
||||
+import java.util.*;
|
||||
+
|
||||
+public class GlobalServerTpsBar {
|
||||
+ protected static final NullPlugin NULL_PLUGIN = new NullPlugin();
|
||||
+ protected static final Map<UUID, BossBar> uuid2Bossbars = Maps.newConcurrentMap();
|
||||
+ protected static final Map<UUID, ScheduledTask> scheduledTasks = new HashMap<>();
|
||||
+
|
||||
+ protected static volatile ScheduledTask scannerTask = null;
|
||||
+ private static final Logger logger = LogUtils.getLogger();
|
||||
+
|
||||
+ public static void init(){
|
||||
+ cancelBarUpdateTask();
|
||||
+
|
||||
+ scannerTask = Bukkit.getGlobalRegionScheduler().runAtFixedRate(NULL_PLUGIN, unused -> {
|
||||
+ try {
|
||||
+ update();
|
||||
+ cleanUp();
|
||||
+ }catch (Exception e){
|
||||
+ logger.error(e.getLocalizedMessage());
|
||||
+ }
|
||||
+ }, 1, TpsBarConfig.updateInterval);
|
||||
+ }
|
||||
+
|
||||
+ public static void cancelBarUpdateTask(){
|
||||
+ if (scannerTask == null || scannerTask.isCancelled()){
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ scannerTask.cancel();
|
||||
+
|
||||
+ for (ScheduledTask task : scheduledTasks.values()) {
|
||||
+ if (!task.isCancelled()) {
|
||||
+ task.cancel();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static boolean isPlayerVisible(Player player){
|
||||
+ return ((CraftPlayer) player).getHandle().isTpsBarVisible;
|
||||
+ }
|
||||
+
|
||||
+ public static void setVisibilityForPlayer(Player target,boolean canSee){
|
||||
+ ((CraftPlayer) target).getHandle().isTpsBarVisible = canSee;
|
||||
+ }
|
||||
+
|
||||
+ private static void update(){
|
||||
+ for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
+ scheduledTasks.computeIfAbsent(player.getUniqueId(), unused -> createBossBarForPlayer(player));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static void cleanUp() {
|
||||
+ final List<UUID> toCleanUp = new ArrayList<>();
|
||||
+
|
||||
+ for (Map.Entry<UUID, ScheduledTask> toCheck : scheduledTasks.entrySet()) {
|
||||
+ if (toCheck.getValue().isCancelled()) {
|
||||
+ toCleanUp.add(toCheck.getKey());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ for (UUID uuid : toCleanUp) {
|
||||
+ scheduledTasks.remove(uuid);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static ScheduledTask createBossBarForPlayer(@NotNull Player apiPlayer) {
|
||||
+ final UUID playerUUID = apiPlayer.getUniqueId();
|
||||
+
|
||||
+ return apiPlayer.getScheduler().runAtFixedRate(NULL_PLUGIN, (n) -> {
|
||||
+ if (!isPlayerVisible(apiPlayer)) {
|
||||
+ final BossBar removed = uuid2Bossbars.remove(playerUUID);
|
||||
+
|
||||
+ if (removed != null) {
|
||||
+ apiPlayer.hideBossBar(removed);
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ final ThreadedRegionizer.ThreadedRegion<TickRegions.TickRegionData, TickRegions.TickRegionSectionData> region = TickRegionScheduler.getCurrentRegion();
|
||||
+ final TickData.TickReportData reportData = region.getData().getRegionSchedulingHandle().getTickReport5s(System.nanoTime());
|
||||
+
|
||||
+
|
||||
+ BossBar targetBossbar = uuid2Bossbars.computeIfAbsent(
|
||||
+ playerUUID,
|
||||
+ unused -> BossBar.bossBar(Component.text(""),0.0F, BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(3)), BossBar.Overlay.NOTCHED_20)
|
||||
+ );
|
||||
+
|
||||
+ apiPlayer.showBossBar(targetBossbar);
|
||||
+
|
||||
+ if (reportData != null){
|
||||
+ final TickData.SegmentData tpsData = reportData.tpsData().segmentAll();
|
||||
+ final double mspt = reportData.timePerTickData().segmentAll().average() / 1.0E6;
|
||||
+
|
||||
+ updateTpsBar(tpsData.average(), mspt, targetBossbar, apiPlayer);
|
||||
+ }
|
||||
+ }, () -> {
|
||||
+ final BossBar removed = uuid2Bossbars.remove(playerUUID); // Auto clean up it
|
||||
+
|
||||
+ if (removed != null) {
|
||||
+ apiPlayer.hideBossBar(removed);
|
||||
+ }
|
||||
+ }, 1, TpsBarConfig.updateInterval);
|
||||
+ }
|
||||
+
|
||||
+ private static void updateTpsBar(double tps, double mspt, @NotNull BossBar bar, @NotNull Player player){
|
||||
+ bar.name(MiniMessage.miniMessage().deserialize(
|
||||
+ TpsBarConfig.tpsBarFormat,
|
||||
+ Placeholder.component("tps",getTpsComponent(tps)),
|
||||
+ Placeholder.component("mspt",getMsptComponent(mspt)),
|
||||
+ Placeholder.component("ping",getPingComponent(player.getPing()))
|
||||
+ ));
|
||||
+ bar.color(barColorFromTps(tps));
|
||||
+ bar.progress((float) Math.min((float)1,Math.max(mspt / 50,0)));
|
||||
+ }
|
||||
+
|
||||
+ private static @NotNull Component getPingComponent(int ping){
|
||||
+ final BossBar.Color colorBukkit = barColorFromPing(ping);
|
||||
+ final String colorString = colorBukkit.name();
|
||||
+
|
||||
+ final String content = "<%s><text></%s>";
|
||||
+ final String replaced = String.format(content,colorString,colorString);
|
||||
+
|
||||
+ return MiniMessage.miniMessage().deserialize(replaced,Placeholder.parsed("text", String.valueOf(ping)));
|
||||
+ }
|
||||
+
|
||||
+ private static BossBar.Color barColorFromPing(int ping){
|
||||
+ if (ping == -1){
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.pingColors.get(3));
|
||||
+ }
|
||||
+
|
||||
+ if (ping <= 80){
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.pingColors.get(0));
|
||||
+ }
|
||||
+
|
||||
+ if (ping <= 160){
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.pingColors.get(1));
|
||||
+ }
|
||||
+
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.pingColors.get(2));
|
||||
+ }
|
||||
+
|
||||
+ private static @NotNull Component getMsptComponent(double mspt){
|
||||
+ final BossBar.Color colorBukkit = barColorFromMspt(mspt);
|
||||
+ final String colorString = colorBukkit.name();
|
||||
+
|
||||
+ final String content = "<%s><text></%s>";
|
||||
+ final String replaced = String.format(content,colorString,colorString);
|
||||
+
|
||||
+ return MiniMessage.miniMessage().deserialize(replaced,Placeholder.parsed("text", String.format("%.2f", mspt)));
|
||||
+ }
|
||||
+
|
||||
+ private static BossBar.Color barColorFromMspt(double mspt){
|
||||
+ if (mspt == -1){
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(3));
|
||||
+ }
|
||||
+
|
||||
+ if (mspt <= 25){
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(0));
|
||||
+ }
|
||||
+
|
||||
+ if (mspt <= 50){
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(1));
|
||||
+ }
|
||||
+
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(2));
|
||||
+ }
|
||||
+
|
||||
+ private static @NotNull Component getTpsComponent(double tps){
|
||||
+ final BossBar.Color colorBukkit = barColorFromTps(tps);
|
||||
+ final String colorString = colorBukkit.name();
|
||||
+
|
||||
+ final String content = "<%s><text></%s>";
|
||||
+ final String replaced = String.format(content,colorString,colorString);
|
||||
+
|
||||
+ return MiniMessage.miniMessage().deserialize(replaced,Placeholder.parsed("text", String.format("%.2f", tps)));
|
||||
+ }
|
||||
+
|
||||
+ private static BossBar.Color barColorFromTps(double tps){
|
||||
+ if (tps == -1){
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(3));
|
||||
+ }
|
||||
+
|
||||
+ if (tps >= 18){
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(0));
|
||||
+ }
|
||||
+
|
||||
+ if (tps >= 15){
|
||||
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(1));
|
||||
+ }
|
||||
+
|
||||
+ 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 e3c8deea68ef49bcd07359e243a12afb57cbcf52..279bc6eede3a1ae77b810f0553efe36adeeefaa4 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -802,6 +802,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
|
||||
@Override
|
||||
public void stopServer() {
|
||||
+ 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 23f852ede94bce4d000c8fcaa8fba5d4800b533c..0752d13febc5f1831ae58f7216fba89e1290c780 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -327,7 +327,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
||||
public com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent
|
||||
public @Nullable String clientBrandName = null; // Paper - Brand support
|
||||
public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event
|
||||
-
|
||||
+ public volatile boolean isTpsBarVisible = false; //Luminol - Tps bar
|
||||
// Paper start - rewrite chunk system
|
||||
private ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader;
|
||||
private final ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.ViewDistanceHolder viewDistanceHolder = new ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.ViewDistanceHolder();
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index b0e93050839ce00b057e3a9bf3bdf8dd5e0662cf..c39e9ea1ce46864623a6d15027ce337611e6b712 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -2414,6 +2414,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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2435,6 +2438,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,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);
|
||||
340
patches/server/0009-Add-a-simple-membar.patch
Normal file
340
patches/server/0009-Add-a-simple-membar.patch
Normal file
@@ -0,0 +1,340 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 31 Jul 2024 12:18:09 +0800
|
||||
Subject: [PATCH] Add a simple membar
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/commands/MembarCommand.java b/src/main/java/me/earthme/luminol/commands/MembarCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..a5cbad6b947b1c3e1499bc6d311e17a5eb570c2f
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/commands/MembarCommand.java
|
||||
@@ -0,0 +1,47 @@
|
||||
+package me.earthme.luminol.commands;
|
||||
+
|
||||
+import me.earthme.luminol.config.modules.misc.MembarConfig;
|
||||
+import me.earthme.luminol.functions.GlobalServerMemoryBar;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.text.format.TextColor;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+public class MembarCommand extends Command {
|
||||
+ public MembarCommand(@NotNull String name) {
|
||||
+ super(name);
|
||||
+ this.setPermission("luminol.commands.membar");
|
||||
+ this.setDescription("Show the memory usage through a bossbar");
|
||||
+ this.setUsage("/membar");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
|
||||
+ if (!testPermission(sender)){
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ if (!MembarConfig.memoryBarEnabled){
|
||||
+ sender.sendMessage(Component.text("Membar was already disabled!").color(TextColor.color(255,0,0)));
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ if (!(sender instanceof Player player)){
|
||||
+ sender.sendMessage(Component.text("Only player can use this command!").color(TextColor.color(255,0,0)));
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ if (GlobalServerMemoryBar.isPlayerVisible(player)) {
|
||||
+ player.sendMessage(Component.text("Disabled mem bar").color(TextColor.color(0,255,0)));
|
||||
+ GlobalServerMemoryBar.setVisibilityForPlayer(player,false);
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ player.sendMessage(Component.text("Enabled mem bar").color(TextColor.color(0,255,0)));
|
||||
+ GlobalServerMemoryBar.setVisibilityForPlayer(player,true);
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/MembarConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/MembarConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..b632c4a636974535bf001f010de1dcb6b25868c0
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/MembarConfig.java
|
||||
@@ -0,0 +1,50 @@
|
||||
+package me.earthme.luminol.config.modules.misc;
|
||||
+
|
||||
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import me.earthme.luminol.commands.MembarCommand;
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.DoNotLoad;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+import me.earthme.luminol.functions.GlobalServerMemoryBar;
|
||||
+import org.bukkit.Bukkit;
|
||||
+
|
||||
+import java.util.List;
|
||||
+
|
||||
+public class MembarConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean memoryBarEnabled = false;
|
||||
+ @ConfigInfo(baseName = "format")
|
||||
+ public static String memBarFormat = "<gray>Memory usage <yellow>:</yellow> <used>MB<yellow>/</yellow><available>MB";
|
||||
+ @ConfigInfo(baseName = "memory_color_list")
|
||||
+ public static List<String> memColors = List.of("GREEN","YELLOW","RED","PURPLE");
|
||||
+ @ConfigInfo(baseName = "update_interval_ticks")
|
||||
+ public static int updateInterval = 15;
|
||||
+
|
||||
+ @DoNotLoad
|
||||
+ private static boolean inited = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "membar";
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onLoaded(CommentedFileConfig configInstance){
|
||||
+ if (memoryBarEnabled){
|
||||
+ GlobalServerMemoryBar.init();
|
||||
+ }else{
|
||||
+ GlobalServerMemoryBar.cancelBarUpdateTask();
|
||||
+ }
|
||||
+
|
||||
+ if (!inited){
|
||||
+ Bukkit.getCommandMap().register("membar","luminol",new MembarCommand("membar"));
|
||||
+ inited = true;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/functions/GlobalServerMemoryBar.java b/src/main/java/me/earthme/luminol/functions/GlobalServerMemoryBar.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..3535cf03e7855b4d8b312ccf3a7b0564ea753019
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/functions/GlobalServerMemoryBar.java
|
||||
@@ -0,0 +1,171 @@
|
||||
+package me.earthme.luminol.functions;
|
||||
+
|
||||
+import com.google.common.collect.Maps;
|
||||
+import com.mojang.logging.LogUtils;
|
||||
+import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
||||
+import me.earthme.luminol.config.modules.misc.MembarConfig;
|
||||
+import me.earthme.luminol.utils.NullPlugin;
|
||||
+import net.kyori.adventure.bossbar.BossBar;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
+import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.slf4j.Logger;
|
||||
+
|
||||
+import java.lang.management.ManagementFactory;
|
||||
+import java.lang.management.MemoryUsage;
|
||||
+import java.util.*;
|
||||
+
|
||||
+public class GlobalServerMemoryBar {
|
||||
+ protected static final NullPlugin NULL_PLUGIN = new NullPlugin();
|
||||
+ protected static final Map<UUID, BossBar> uuid2Bossbars = Maps.newConcurrentMap();
|
||||
+ protected static final Map<UUID, ScheduledTask> scheduledTasks = new HashMap<>();
|
||||
+ protected static volatile ScheduledTask scannerTask = null;
|
||||
+ private static final Logger logger = LogUtils.getLogger();
|
||||
+
|
||||
+ public static void init(){
|
||||
+ cancelBarUpdateTask();
|
||||
+
|
||||
+ scannerTask = Bukkit.getGlobalRegionScheduler().runAtFixedRate(NULL_PLUGIN, unused -> {
|
||||
+ try {
|
||||
+ update();
|
||||
+ }catch (Exception e){
|
||||
+ logger.error(e.getLocalizedMessage());
|
||||
+ }
|
||||
+ }, 1, MembarConfig.updateInterval);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static void cancelBarUpdateTask(){
|
||||
+ if (scannerTask == null || scannerTask.isCancelled()){
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ scannerTask.cancel();
|
||||
+
|
||||
+ for (ScheduledTask task : scheduledTasks.values()) {
|
||||
+ if (!task.isCancelled()) {
|
||||
+ task.cancel();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static boolean isPlayerVisible(Player player){
|
||||
+ return ((CraftPlayer) player).getHandle().isMemBarVisible;
|
||||
+ }
|
||||
+
|
||||
+ public static void setVisibilityForPlayer(Player target,boolean canSee){
|
||||
+ ((CraftPlayer) target).getHandle().isMemBarVisible = canSee;
|
||||
+ }
|
||||
+
|
||||
+ private static void update(){
|
||||
+ doUpdate();
|
||||
+ cleanUp();
|
||||
+ }
|
||||
+
|
||||
+ private static void cleanUp(){
|
||||
+ final List<UUID> toCleanUp = new ArrayList<>();
|
||||
+
|
||||
+ for (Map.Entry<UUID, ScheduledTask> toCheck : scheduledTasks.entrySet()) {
|
||||
+ if (toCheck.getValue().isCancelled()) {
|
||||
+ toCleanUp.add(toCheck.getKey());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ for (UUID uuid : toCleanUp) {
|
||||
+ scheduledTasks.remove(uuid);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static void doUpdate(){
|
||||
+ for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
+ scheduledTasks.computeIfAbsent(player.getUniqueId(), unused -> createBossBarForPlayer(player));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static ScheduledTask createBossBarForPlayer(Player apiPlayer) {
|
||||
+ return apiPlayer.getScheduler().runAtFixedRate(NULL_PLUGIN, (unused) -> {
|
||||
+ final UUID playerUUID = apiPlayer.getUniqueId();
|
||||
+
|
||||
+ if (!isPlayerVisible(apiPlayer)) {
|
||||
+ final BossBar removed = uuid2Bossbars.remove(playerUUID);
|
||||
+
|
||||
+ if (removed != null) {
|
||||
+ apiPlayer.hideBossBar(removed);
|
||||
+ }
|
||||
+
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ MemoryUsage heap = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
|
||||
+
|
||||
+ long used = heap.getUsed();
|
||||
+ long xmx = heap.getMax();
|
||||
+
|
||||
+ BossBar targetBossbar = uuid2Bossbars.computeIfAbsent(
|
||||
+ playerUUID,
|
||||
+ (unused1) -> BossBar.bossBar(Component.text(""),0.0F, BossBar.Color.valueOf(MembarConfig.memColors.get(3)), BossBar.Overlay.NOTCHED_20)
|
||||
+ );
|
||||
+
|
||||
+ apiPlayer.showBossBar(targetBossbar);
|
||||
+
|
||||
+ updateMembar(targetBossbar, used, xmx);
|
||||
+ }, () -> {
|
||||
+ final BossBar removed = uuid2Bossbars.remove(apiPlayer.getUniqueId());
|
||||
+
|
||||
+ if (removed != null) {
|
||||
+ apiPlayer.hideBossBar(removed);
|
||||
+ }
|
||||
+ }, 1, MembarConfig.updateInterval);
|
||||
+ }
|
||||
+
|
||||
+ private static void updateMembar(@NotNull BossBar bar, long used, long xmx){
|
||||
+ double percent = Math.max(Math.min((float) used / xmx, 1.0F), 0.0F);
|
||||
+ bar.name(MiniMessage.miniMessage().deserialize(
|
||||
+ MembarConfig.memBarFormat,
|
||||
+ Placeholder.component("used", getMemoryComponent(used,xmx)),
|
||||
+ Placeholder.component("available",getMaxMemComponent(xmx))
|
||||
+ ));
|
||||
+ bar.color(barColorFromMemory(percent));
|
||||
+ bar.progress((float) percent);
|
||||
+ }
|
||||
+
|
||||
+ private static @NotNull Component getMaxMemComponent(double max){
|
||||
+ final BossBar.Color colorBukkit = BossBar.Color.GREEN;
|
||||
+ final String colorString = colorBukkit.name();
|
||||
+
|
||||
+ final String content = "<%s><text></%s>";
|
||||
+ final String replaced = String.format(content,colorString,colorString);
|
||||
+
|
||||
+ return MiniMessage.miniMessage().deserialize(replaced,Placeholder.parsed("text", String.format("%.2f", max / (1024 * 1024))));
|
||||
+ }
|
||||
+
|
||||
+ private static @NotNull Component getMemoryComponent(long used,long max){
|
||||
+ final BossBar.Color colorBukkit = barColorFromMemory(Math.max(Math.min((float) used / max, 1.0F), 0.0F));
|
||||
+ final String colorString = colorBukkit.name();
|
||||
+
|
||||
+ final String content = "<%s><text></%s>";
|
||||
+ final String replaced = String.format(content,colorString,colorString);
|
||||
+
|
||||
+ return MiniMessage.miniMessage().deserialize(replaced,Placeholder.parsed("text", String.format("%.2f", (double)used / (1024 * 1024))));
|
||||
+ }
|
||||
+
|
||||
+ private static BossBar.Color barColorFromMemory(double memPercent){
|
||||
+ if (memPercent == -1){
|
||||
+ return BossBar.Color.valueOf(MembarConfig.memColors.get(3));
|
||||
+ }
|
||||
+
|
||||
+ if (memPercent <= 50){
|
||||
+ return BossBar.Color.valueOf(MembarConfig.memColors.getFirst());
|
||||
+ }
|
||||
+
|
||||
+ if (memPercent <= 70){
|
||||
+ return BossBar.Color.valueOf(MembarConfig.memColors.get(1));
|
||||
+ }
|
||||
+
|
||||
+ return BossBar.Color.valueOf(MembarConfig.memColors.get(2));
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 279bc6eede3a1ae77b810f0553efe36adeeefaa4..4ff5105d32c41a8ea145e7833ea6a3cee0108031 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -803,6 +803,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@Override
|
||||
public void stopServer() {
|
||||
me.earthme.luminol.functions.GlobalServerTpsBar.cancelBarUpdateTask(); //Luminol - Tpsbar
|
||||
+ me.earthme.luminol.functions.GlobalServerMemoryBar.cancelBarUpdateTask(); //Luminol - Memory bar
|
||||
super.stopServer();
|
||||
//Util.shutdownExecutors(); // Paper - moved into super
|
||||
SkullBlockEntity.clear();
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 0752d13febc5f1831ae58f7216fba89e1290c780..93c038ba1fd216fd11ab8b5cec5807453f34e152 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -328,6 +328,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
||||
public @Nullable String clientBrandName = null; // Paper - Brand support
|
||||
public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event
|
||||
public volatile boolean isTpsBarVisible = false; //Luminol - Tps bar
|
||||
+ public volatile boolean isMemBarVisible = false; //Luminol - Memory bar
|
||||
// Paper start - rewrite chunk system
|
||||
private ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader;
|
||||
private final ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.ViewDistanceHolder viewDistanceHolder = new ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.ViewDistanceHolder();
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index c39e9ea1ce46864623a6d15027ce337611e6b712..1872b19dfefb40e6673fd2b8ddb8d3c384020073 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -2417,6 +2417,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
//Luminol start - Tpsbar
|
||||
getHandle().isTpsBarVisible = data.getBoolean("tpsbarVisible");
|
||||
//Luminol end
|
||||
+ //Luminol start - Membar
|
||||
+ getHandle().isMemBarVisible = data.getBoolean("membarVisible");
|
||||
+ //Luminol end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2441,6 +2444,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
//Luminol start - Tpsbar
|
||||
data.putBoolean("tpsbarVisible",handle.isTpsBarVisible);
|
||||
//Luminol end
|
||||
+ //Luminol start - Membar
|
||||
+ data.putBoolean("membarVisible", handle.isMemBarVisible);
|
||||
+ //Luminol end
|
||||
// Paper start - persist for use in offline save data
|
||||
if (!nbttagcompound.contains("Paper")) {
|
||||
nbttagcompound.put("Paper", new CompoundTag());
|
||||
@@ -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);
|
||||
})));
|
||||
77
patches/server/0010-Add-config-for-username-check.patch
Normal file
77
patches/server/0010-Add-config-for-username-check.patch
Normal file
@@ -0,0 +1,77 @@
|
||||
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 227d62a69a453d49c28568ecb41ecef85a35405b..8951397adcc5505304d0dece6435aab786017399 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
@@ -178,7 +178,8 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||
public void handleHello(ServerboundHelloPacket packet) {
|
||||
Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet", new Object[0]);
|
||||
// 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]);
|
||||
diff --git a/src/main/java/net/minecraft/server/players/GameProfileCache.java b/src/main/java/net/minecraft/server/players/GameProfileCache.java
|
||||
index 34b4166adfae8ff7d1eb73d56a72931b005330a7..fc95632268caa8941dcce7a575ce00303864c4c1 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/GameProfileCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/GameProfileCache.java
|
||||
@@ -82,7 +82,7 @@ public class GameProfileCache {
|
||||
}
|
||||
|
||||
private static Optional<GameProfile> lookupGameProfile(GameProfileRepository repository, String name) {
|
||||
- if (!StringUtil.isValidPlayerName(name)) {
|
||||
+ if (!StringUtil.isValidPlayerName(name, false)) { // Luminol - Add config for username check - Directly return, skip unnecessary following logic
|
||||
return GameProfileCache.createUnknownProfile(name);
|
||||
} else {
|
||||
final AtomicReference<GameProfile> atomicreference = new AtomicReference();
|
||||
diff --git a/src/main/java/net/minecraft/util/StringUtil.java b/src/main/java/net/minecraft/util/StringUtil.java
|
||||
index 6c33002dc8bbb3759c3156302ab7d1f26ce5e8ee..8caf8dd187dfdc67a8b97db080a9fe0ef5234943 100644
|
||||
--- a/src/main/java/net/minecraft/util/StringUtil.java
|
||||
+++ b/src/main/java/net/minecraft/util/StringUtil.java
|
||||
@@ -64,6 +64,13 @@ public class StringUtil {
|
||||
}
|
||||
|
||||
public static boolean isValidPlayerName(String name) {
|
||||
+ // Luminol start - Add config for username check
|
||||
+ return isValidPlayerName(name, !me.earthme.luminol.config.modules.misc.UsernameCheckConfig.enabled);
|
||||
+ }
|
||||
+
|
||||
+ public static boolean isValidPlayerName(String name, boolean bypassCheck) {
|
||||
+ if (bypassCheck) return name.length() <= 16;
|
||||
+ // Luminol end - Add config for username check
|
||||
return name.length() <= 16 && name.chars().filter(c -> c <= 32 || c >= 127).findAny().isEmpty();
|
||||
}
|
||||
|
||||
@@ -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 4ff5105d32c41a8ea145e7833ea6a3cee0108031..295504dab771c8bb8c668545fe5d62eae0561b76 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -297,7 +297,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;
|
||||
46
patches/server/0013-Add-config-for-tripwire-dupe.patch
Normal file
46
patches/server/0013-Add-config-for-tripwire-dupe.patch
Normal file
@@ -0,0 +1,46 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Tue, 24 Dec 2024 13:28:56 -0500
|
||||
Subject: [PATCH] Add config for tripwire dupe
|
||||
|
||||
Bring back MC-59471, MC-129055 on 1.21.2+, which fixed in 1.21.2 snapshots 24w33a and 24w36a
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/TripwireConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/TripwireConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..8def8aad908f5e6b828d7d9179bfe1962c39f9f7
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/TripwireConfig.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 TripwireConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "tripwire_dupe";
|
||||
+ }
|
||||
+}
|
||||
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 c2589f42c467ca672417c24076313da51bb2dcbb..f85f53082cf5a56c723648f68bb103d58da0e8bd 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
|
||||
@@ -206,7 +206,7 @@ public class TripWireHookBlock extends Block {
|
||||
if (iblockdata4 != null) {
|
||||
BlockState iblockdata5 = world.getBlockState(blockposition2);
|
||||
|
||||
- if (iblockdata5.is(Blocks.TRIPWIRE) || iblockdata5.is(Blocks.TRIPWIRE_HOOK)) {
|
||||
+ if (me.earthme.luminol.config.modules.misc.TripwireConfig.enabled || iblockdata5.is(Blocks.TRIPWIRE) || iblockdata5.is(Blocks.TRIPWIRE_HOOK)) { // Luminol - Add config for tripwire dupe
|
||||
world.setBlock(blockposition2, (BlockState) iblockdata4.trySetValue(TripWireHookBlock.ATTACHED, flag4), 3);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -0,0 +1,62 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stabrinai <wujiaxin752@outlook.com>
|
||||
Date: Sun, 30 Jun 2024 20:46:42 +0800
|
||||
Subject: [PATCH] Add config to verify signature only in online-mode
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/PublickeyVerifyConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/PublickeyVerifyConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e45ce3abf49684c911678abcefd69586246cc0e3
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/PublickeyVerifyConfig.java
|
||||
@@ -0,0 +1,21 @@
|
||||
+package me.earthme.luminol.config.modules.misc;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class PublickeyVerifyConfig implements IConfigModule {
|
||||
+
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "verify_publickey_only_in_online_mode";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/player/ProfilePublicKey.java b/src/main/java/net/minecraft/world/entity/player/ProfilePublicKey.java
|
||||
index 6a7d7fad990fc44fdda6849d43dad141e61f7f37..dd470577fe314154b5a3677851eef95ebd151721 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/player/ProfilePublicKey.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/player/ProfilePublicKey.java
|
||||
@@ -9,12 +9,15 @@ import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
+
|
||||
+import me.earthme.luminol.config.modules.misc.PublickeyVerifyConfig;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.ThrowingComponent;
|
||||
import net.minecraft.util.Crypt;
|
||||
import net.minecraft.util.ExtraCodecs;
|
||||
import net.minecraft.util.SignatureValidator;
|
||||
+import org.bukkit.Bukkit;
|
||||
|
||||
public record ProfilePublicKey(ProfilePublicKey.Data data) {
|
||||
public static final Component EXPIRED_PROFILE_PUBLIC_KEY = Component.translatable("multiplayer.disconnect.expired_public_key");
|
||||
@@ -23,7 +26,7 @@ public record ProfilePublicKey(ProfilePublicKey.Data data) {
|
||||
public static final Codec<ProfilePublicKey> TRUSTED_CODEC = ProfilePublicKey.Data.CODEC.xmap(ProfilePublicKey::new, ProfilePublicKey::data);
|
||||
|
||||
public static ProfilePublicKey createValidated(SignatureValidator servicesSignatureVerifier, UUID playerUuid, ProfilePublicKey.Data publicKeyData) throws ProfilePublicKey.ValidationException {
|
||||
- if (!publicKeyData.validateSignature(servicesSignatureVerifier, playerUuid)) {
|
||||
+ if ((!PublickeyVerifyConfig.enabled || Bukkit.getServer().getOnlineMode()) && !publicKeyData.validateSignature(servicesSignatureVerifier, playerUuid)) { // Luminol - Verify signature only in online-mode
|
||||
throw new ProfilePublicKey.ValidationException(INVALID_SIGNATURE, org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PUBLIC_KEY_SIGNATURE); // Paper - kick event causes
|
||||
} else {
|
||||
return new ProfilePublicKey(publicKeyData);
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,392 +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:19:16 +0800
|
||||
Subject: [PATCH] Add a simple tpsbar
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index 90a6cfd011aaefe66fda79f887380ab2d62a07b1..0657fce8aabb956a400b3cead53c28ef52e67fe9 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -2,11 +2,15 @@ package me.earthme.luminol;
|
||||
|
||||
import dev.kaiijumc.kaiiju.region.RegionFileFormat;
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import me.earthme.luminol.commands.TpsBarCommand;
|
||||
+import me.earthme.luminol.functions.GlobalServerTpsBar;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
+import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.Arrays;
|
||||
+import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -20,6 +24,10 @@ public class LuminolConfig {
|
||||
public static String serverModName = "Luminol";
|
||||
public static boolean fakeVanillaModeEnabled = false;
|
||||
public static boolean disableChatSign = false;
|
||||
+ public static boolean tpsbarEnabled = false;
|
||||
+ public static String tpsBarFormat = "<gray>TPS<yellow>:</yellow> <tps> MSPT<yellow>:</yellow> <mspt> Ping<yellow>:</yellow> <ping>ms";
|
||||
+ public static String[] tpsColors = new String[]{"GREEN","YELLOW","RED","PURPLE"};
|
||||
+ public static String[] pingColors = new String[]{"GREEN","YELLOW","RED","PURPLE"};
|
||||
|
||||
public static boolean safeTeleportation = true;
|
||||
public static boolean enableSandDuping = false;
|
||||
@@ -46,10 +54,25 @@ public class LuminolConfig {
|
||||
MAIN_CONFIG.save();
|
||||
}
|
||||
|
||||
+ public static void initTpsbar(){
|
||||
+ if (tpsbarEnabled){
|
||||
+ GlobalServerTpsBar.init();
|
||||
+ Bukkit.getCommandMap().register("tpsbar","luminol",new TpsBarCommand("tpsbar"));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
public static void initValues(){
|
||||
serverModName = get("misc.server_mod_name",serverModName,"The servermod name will be sent to players,and you can see it in F3 or motd responses");
|
||||
fakeVanillaModeEnabled = get("misc.enable_fake_vanilla_mode",fakeVanillaModeEnabled,"Enable this to make the ping response of your server like a vanilla server");
|
||||
disableChatSign = get("misc.disable_chat_sign",disableChatSign,"Set this to true to disable mojang's chat sign");
|
||||
+ tpsbarEnabled = get("misc.enable_tpsbar",tpsbarEnabled,"When this enabled,You or your players can see the tps,mspt and ping through a simple bossbar");
|
||||
+ tpsBarFormat = get("misc.tpsbar_title_format",tpsBarFormat,"The format of tpsbar.");
|
||||
+ tpsColors = get("misc.tpsbar_range_colors", List.of(tpsColors),"The bar and text color of each tps ranges.The last is the color of initial bar's color").toArray(String[]::new);
|
||||
+ pingColors = get("misc.tpsbar_ping_range_colors",List.of(pingColors),"As same as the tpsColors").toArray(String[]::new);
|
||||
+
|
||||
+ if (tpsbarEnabled){
|
||||
+ initTpsbar();
|
||||
+ }
|
||||
|
||||
safeTeleportation = get("fixes.enable_safe_teleportation",safeTeleportation,"If this enabled,the end portals will not teleport removed entities.");
|
||||
enableSandDuping = get("fixes.enable_sand_duping",enableSandDuping,"If this enabled,The value of safe teleportation will always be false and sand duping will be enabled");
|
||||
diff --git a/src/main/java/me/earthme/luminol/commands/TpsBarCommand.java b/src/main/java/me/earthme/luminol/commands/TpsBarCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ac8f0e3bf130ba6dfd7202e2f480352218154cdc
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/commands/TpsBarCommand.java
|
||||
@@ -0,0 +1,40 @@
|
||||
+package me.earthme.luminol.commands;
|
||||
+
|
||||
+import me.earthme.luminol.functions.GlobalServerTpsBar;
|
||||
+import org.bukkit.ChatColor;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+public class TpsBarCommand extends Command {
|
||||
+ public TpsBarCommand(@NotNull String name) {
|
||||
+ super(name);
|
||||
+ this.setPermission("luminol.commands.tpsbar");
|
||||
+ this.setDescription("Show the tps and mspt through a bossbar");
|
||||
+ this.setUsage("/tpsbar");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
|
||||
+ if (!testPermission(sender)){
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ if (!(sender instanceof Player player)){
|
||||
+ sender.sendMessage(ChatColor.RED+"Only player can use this command!");
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ if (GlobalServerTpsBar.isPlayerVisible(player)) {
|
||||
+ player.sendMessage(ChatColor.BLUE + "Disabled tps bar");
|
||||
+ GlobalServerTpsBar.setVisibilityForPlayer(player,false);
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ player.sendMessage(ChatColor.GREEN + "Enabled tps bar");
|
||||
+ GlobalServerTpsBar.setVisibilityForPlayer(player,true);
|
||||
+
|
||||
+ return 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
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java
|
||||
@@ -0,0 +1,204 @@
|
||||
+package me.earthme.luminol.functions;
|
||||
+
|
||||
+import com.google.common.collect.Lists;
|
||||
+import io.papermc.paper.threadedregions.ThreadedRegionizer;
|
||||
+import io.papermc.paper.threadedregions.TickData;
|
||||
+import io.papermc.paper.threadedregions.TickRegions;
|
||||
+import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
+import net.kyori.adventure.bossbar.BossBar;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
+import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
+import net.minecraft.server.level.ServerLevel;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
+import org.bukkit.craftbukkit.scheduler.MinecraftInternalPlugin;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.util.*;
|
||||
+import java.util.concurrent.TimeUnit;
|
||||
+
|
||||
+public class GlobalServerTpsBar {
|
||||
+ protected static final MinecraftInternalPlugin NULL_PLUGIN = new MinecraftInternalPlugin();
|
||||
+ protected static final Map<UUID,BossBar> uuid2Bossbars = new HashMap<>();
|
||||
+ protected static volatile ScheduledTask tpsbarTask = null;
|
||||
+
|
||||
+ public static void init(){
|
||||
+ Bukkit.getAsyncScheduler().runAtFixedRate(NULL_PLUGIN,c -> {
|
||||
+ tpsbarTask = c;
|
||||
+ try {
|
||||
+ update();
|
||||
+ }catch (Exception e){
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ },1,1, TimeUnit.SECONDS);
|
||||
+ }
|
||||
+
|
||||
+ public static void cancelBarUpdateTask(){
|
||||
+ if (tpsbarTask == null){
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ tpsbarTask.cancel();
|
||||
+ }
|
||||
+
|
||||
+ public static boolean isPlayerVisible(Player player){
|
||||
+ return ((CraftPlayer) player).getHandle().isTpsBarVisible;
|
||||
+ }
|
||||
+
|
||||
+ public static void setVisibilityForPlayer(Player target,boolean canSee){
|
||||
+ ((CraftPlayer) target).getHandle().isTpsBarVisible = canSee;
|
||||
+ }
|
||||
+
|
||||
+ private static void update(){
|
||||
+ updateBarValues();
|
||||
+ cleanUpPlayers();
|
||||
+ }
|
||||
+
|
||||
+ private static void cleanUpPlayers(){
|
||||
+ final List<UUID> toRemove = new ArrayList<>();
|
||||
+
|
||||
+ for (Map.Entry<UUID,BossBar> bossBarEntry : uuid2Bossbars.entrySet()){
|
||||
+ final UUID uuid = bossBarEntry.getKey();
|
||||
+ boolean shouldRemove = true;
|
||||
+
|
||||
+ final Player target = Bukkit.getPlayer(uuid);
|
||||
+ if (target != null){
|
||||
+ shouldRemove = !isPlayerVisible(target);
|
||||
+ }
|
||||
+
|
||||
+ if (shouldRemove){
|
||||
+ toRemove.add(uuid);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ for (UUID uuid : toRemove){
|
||||
+ final BossBar removed = uuid2Bossbars.remove(uuid);
|
||||
+ if (removed != null){
|
||||
+ final Player targetPlayer = Bukkit.getPlayer(uuid);
|
||||
+ if (targetPlayer != null){
|
||||
+ targetPlayer.hideBossBar(removed);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static void updateBarValues(){
|
||||
+ for (Player apiPlayer : Bukkit.getOnlinePlayers()){
|
||||
+ final ServerPlayer nmsPlayer = ((CraftPlayer) apiPlayer).getHandle();
|
||||
+ final ThreadedRegionizer.ThreadedRegion<TickRegions.TickRegionData, TickRegions.TickRegionSectionData> region = ((ServerLevel) nmsPlayer.level()).regioniser.getRegionAtUnsynchronised(nmsPlayer.sectionX,nmsPlayer.sectionZ);
|
||||
+
|
||||
+ if (region == null){
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final TickData.TickReportData reportData = region.getData().getRegionSchedulingHandle().getTickReport5s(System.nanoTime());
|
||||
+
|
||||
+ 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);
|
||||
+ uuid2Bossbars.put(nmsPlayer.getUUID(),targetBossbar);
|
||||
+ apiPlayer.showBossBar(targetBossbar);
|
||||
+ }
|
||||
+
|
||||
+ if (reportData != null && targetBossbar != null){
|
||||
+ final TickData.SegmentData tpsData = reportData.tpsData().segmentAll();
|
||||
+ final double mspt = reportData.timePerTickData().segmentAll().average() / 1.0E6;
|
||||
+ updateTpsBar(tpsData.average(),mspt,targetBossbar,apiPlayer);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static void updateTpsBar(double tps, double mspt, @NotNull BossBar bar, @NotNull Player player){
|
||||
+ bar.name(MiniMessage.miniMessage().deserialize(
|
||||
+ LuminolConfig.tpsBarFormat,
|
||||
+ Placeholder.component("tps",getTpsComponent(tps)),
|
||||
+ Placeholder.component("mspt",getMsptComponent(mspt)),
|
||||
+ Placeholder.component("ping",getPingComponent(player.getPing()))
|
||||
+ ));
|
||||
+ bar.color(barColorFromTps(tps));
|
||||
+ bar.progress((float) Math.min((float)1,Math.max(mspt / 50,0)));
|
||||
+ }
|
||||
+
|
||||
+ private static @NotNull Component getPingComponent(int ping){
|
||||
+ final BossBar.Color colorBukkit = barColorFromPing(ping);
|
||||
+ final String colorString = colorBukkit.name();
|
||||
+
|
||||
+ final String content = "<%s><text></%s>";
|
||||
+ final String replaced = String.format(content,colorString,colorString);
|
||||
+
|
||||
+ return MiniMessage.miniMessage().deserialize(replaced,Placeholder.parsed("text", String.valueOf(ping)));
|
||||
+ }
|
||||
+
|
||||
+ private static BossBar.Color barColorFromPing(int ping){
|
||||
+ if (ping == -1){
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[3]);
|
||||
+ }
|
||||
+
|
||||
+ if (ping <= 80){
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[0]);
|
||||
+ }
|
||||
+
|
||||
+ if (ping <= 160){
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[1]);
|
||||
+ }
|
||||
+
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[2]);
|
||||
+ }
|
||||
+
|
||||
+ private static @NotNull Component getMsptComponent(double mspt){
|
||||
+ final BossBar.Color colorBukkit = barColorFromMspt(mspt);
|
||||
+ final String colorString = colorBukkit.name();
|
||||
+
|
||||
+ final String content = "<%s><text></%s>";
|
||||
+ final String replaced = String.format(content,colorString,colorString);
|
||||
+
|
||||
+ return MiniMessage.miniMessage().deserialize(replaced,Placeholder.parsed("text", String.format("%.2f", mspt)));
|
||||
+ }
|
||||
+
|
||||
+ private static BossBar.Color barColorFromMspt(double mspt){
|
||||
+ if (mspt == -1){
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[3]);
|
||||
+ }
|
||||
+
|
||||
+ if (mspt <= 25){
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[0]);
|
||||
+ }
|
||||
+
|
||||
+ if (mspt <= 50){
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[1]);
|
||||
+ }
|
||||
+
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[2]);
|
||||
+ }
|
||||
+
|
||||
+ private static @NotNull Component getTpsComponent(double tps){
|
||||
+ final BossBar.Color colorBukkit = barColorFromTps(tps);
|
||||
+ final String colorString = colorBukkit.name();
|
||||
+
|
||||
+ final String content = "<%s><text></%s>";
|
||||
+ final String replaced = String.format(content,colorString,colorString);
|
||||
+
|
||||
+ return MiniMessage.miniMessage().deserialize(replaced,Placeholder.parsed("text", String.format("%.2f", tps)));
|
||||
+ }
|
||||
+
|
||||
+ private static BossBar.Color barColorFromTps(double tps){
|
||||
+ if (tps == -1){
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[3]);
|
||||
+ }
|
||||
+
|
||||
+ if (tps >= 18){
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[0]);
|
||||
+ }
|
||||
+
|
||||
+ if (tps >= 15){
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[1]);
|
||||
+ }
|
||||
+
|
||||
+ return BossBar.Color.valueOf(LuminolConfig.tpsColors[2]);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index f0bf57a7acd77eeffbeeb6743ba58166823022fd..4a1e068c27853a38db0641806626e7ac740bd8de 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
|
||||
|
||||
@Override
|
||||
public void stopServer() {
|
||||
+ 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
|
||||
--- 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 {
|
||||
// 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 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
|
||||
--- 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 {
|
||||
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 {
|
||||
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());
|
||||
@@ -0,0 +1,45 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 7 Aug 2024 14:27:24 +0800
|
||||
Subject: [PATCH] Add config to disable entity tick catchers
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/experiment/DisableEntityCatchConfig.java b/src/main/java/me/earthme/luminol/config/modules/experiment/DisableEntityCatchConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0fd71151a85dd87c2294033e2e7512ac365caa62
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/experiment/DisableEntityCatchConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.experiment;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class DisableEntityCatchConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.EXPERIMENT;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "disable_entity_exception_catchers";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 456f15e44e41d65338c0346594be2b0042b84005..5127d0ef0c85b8f57d412d36eaca00153c4fe7b3 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -1538,7 +1538,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
try {
|
||||
tickConsumer.accept(entity);
|
||||
} catch (Throwable throwable) {
|
||||
- if (throwable instanceof ThreadDeath) throw throwable; // Paper
|
||||
+ if (throwable instanceof ThreadDeath || me.earthme.luminol.config.modules.experiment.DisableEntityCatchConfig.enabled) throw throwable; // Paper // Luminol
|
||||
// Paper start - Prevent block entity and entity crashes
|
||||
final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level().getWorld().getName(), entity.getX(), entity.getY(), entity.getZ());
|
||||
MinecraftServer.LOGGER.error(msg, throwable);
|
||||
106
patches/server/0016-Add-config-to-disable-async-catchers.patch
Normal file
106
patches/server/0016-Add-config-to-disable-async-catchers.patch
Normal file
@@ -0,0 +1,106 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 7 Aug 2024 14:34:15 +0800
|
||||
Subject: [PATCH] Add config to disable async catchers
|
||||
|
||||
|
||||
diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java b/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java
|
||||
index 301cc1c0d91f5e755f74ace60dbe5551240b496d..2befb04b18cbdcc854437dfc534832ae02e70ee6 100644
|
||||
--- a/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java
|
||||
+++ b/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java
|
||||
@@ -26,49 +26,49 @@ public class TickThread extends Thread {
|
||||
*/
|
||||
@Deprecated
|
||||
public static void ensureTickThread(final String reason) {
|
||||
- if (!isTickThread()) {
|
||||
+ if (!isTickThread() && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Luminol
|
||||
LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||
throw new IllegalStateException(reason);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ensureTickThread(final Level world, final BlockPos pos, final String reason) {
|
||||
- if (!isTickThreadFor(world, pos)) {
|
||||
+ if (!isTickThreadFor(world, pos) && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Luminol
|
||||
LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||
throw new IllegalStateException(reason);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ensureTickThread(final Level world, final ChunkPos pos, final String reason) {
|
||||
- if (!isTickThreadFor(world, pos)) {
|
||||
+ if (!isTickThreadFor(world, pos) && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Luminol
|
||||
LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||
throw new IllegalStateException(reason);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ensureTickThread(final Level world, final int chunkX, final int chunkZ, final String reason) {
|
||||
- if (!isTickThreadFor(world, chunkX, chunkZ)) {
|
||||
+ if (!isTickThreadFor(world, chunkX, chunkZ) && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Luminol
|
||||
LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||
throw new IllegalStateException(reason);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ensureTickThread(final Entity entity, final String reason) {
|
||||
- if (!isTickThreadFor(entity)) {
|
||||
+ if (!isTickThreadFor(entity) && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Luminol
|
||||
LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||
throw new IllegalStateException(reason);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ensureTickThread(final Level world, final AABB aabb, final String reason) {
|
||||
- if (!isTickThreadFor(world, aabb)) {
|
||||
+ if (!isTickThreadFor(world, aabb) && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Luminol
|
||||
LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||
throw new IllegalStateException(reason);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ensureTickThread(final Level world, final double blockX, final double blockZ, final String reason) {
|
||||
- if (!isTickThreadFor(world, blockX, blockZ)) {
|
||||
+ if (!isTickThreadFor(world, blockX, blockZ) && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Luminol
|
||||
LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||
throw new IllegalStateException(reason);
|
||||
}
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/experiment/DisableAsyncCatcherConfig.java b/src/main/java/me/earthme/luminol/config/modules/experiment/DisableAsyncCatcherConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..61f653eeca366672ded88c491cf5c59e546e7301
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/experiment/DisableAsyncCatcherConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.experiment;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class DisableAsyncCatcherConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.EXPERIMENT;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "disable_async_catchers";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/spigotmc/AsyncCatcher.java b/src/main/java/org/spigotmc/AsyncCatcher.java
|
||||
index 1f23e775eba1c34e01145bd91b0ce26fed6ca9de..3e0dbf379fc1b5baa27936cb902b3c54f9b0f4c9 100644
|
||||
--- a/src/main/java/org/spigotmc/AsyncCatcher.java
|
||||
+++ b/src/main/java/org/spigotmc/AsyncCatcher.java
|
||||
@@ -9,7 +9,7 @@ public class AsyncCatcher
|
||||
|
||||
public static void catchOp(String reason)
|
||||
{
|
||||
- if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThread()) // Paper // Paper - rewrite chunk system
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThread() && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) // Paper // Paper - rewrite chunk system // Luminol
|
||||
{
|
||||
MinecraftServer.LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable()); // Paper
|
||||
throw new IllegalStateException( "Asynchronous " + reason + "!" );
|
||||
@@ -1,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");
|
||||
@@ -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,45 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sat, 31 Aug 2024 10:56:58 +0800
|
||||
Subject: [PATCH] Add experiment config for command block command execution
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/experiment/CommandBlockConfig.java b/src/main/java/me/earthme/luminol/config/modules/experiment/CommandBlockConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..3eafc59cc015569d3da8b1d8c4bfd046af17e0be
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/experiment/CommandBlockConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.experiment;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class CommandBlockConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enable")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.EXPERIMENT;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "force_enable_command_block_execution";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
|
||||
index ccf476d1ed22cf992e3cbca6a375d36f85a82fa8..81f69938ccc72522090c4bee1a941c0de8054feb 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
|
||||
@@ -117,7 +117,7 @@ public abstract class BaseCommandBlock implements CommandSource {
|
||||
}
|
||||
|
||||
public boolean performCommand(Level world) {
|
||||
- if (true) return false; // Folia - region threading
|
||||
+ if (!me.earthme.luminol.config.modules.experiment.CommandBlockConfig.enabled) return false; // Folia - region threading // Luminol
|
||||
if (!world.isClientSide && world.getGameTime() != this.lastExecution) {
|
||||
if ("Searge".equalsIgnoreCase(this.command)) {
|
||||
this.lastOutput = Component.literal("#itzlipofutzli");
|
||||
@@ -0,0 +1,25 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Fri, 6 Dec 2024 23:53:03 +0800
|
||||
Subject: [PATCH] Add fix for off region adult following ai behavior
|
||||
|
||||
Might fix: https://github.com/PaperMC/Folia/issues/245
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/BabyFollowAdult.java b/src/main/java/net/minecraft/world/entity/ai/behavior/BabyFollowAdult.java
|
||||
index 0ff878a8cfcd6a3e08575b7537d9b7e2b817908f..742662da3497b0042fa0fb6ff3456fc62692473d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/BabyFollowAdult.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/BabyFollowAdult.java
|
||||
@@ -33,6 +33,13 @@ public class BabyFollowAdult {
|
||||
} else {
|
||||
LivingEntity entityageable1 = (AgeableMob) behaviorbuilder_b.get(memoryaccessor); // CraftBukkit - type
|
||||
|
||||
+ // Luminol start - Fix off world entity following which caused async issue
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(entityageable1)) {
|
||||
+ memoryaccessor.erase();
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Luminol end
|
||||
+
|
||||
if (entityageable.closerThan(entityageable1, (double) (executionRange.getMaxValue() + 1)) && !entityageable.closerThan(entityageable1, (double) executionRange.getMinValue())) {
|
||||
// CraftBukkit start
|
||||
EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(entityageable, entityageable1, EntityTargetEvent.TargetReason.FOLLOW_LEADER);
|
||||
@@ -1,19 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 15:59:49 +0800
|
||||
Subject: [PATCH] Pufferfish Optimize entity coordinate key
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
index 8f91b7f44baaf62b829a81afc0633311e6c13f19..a149d98be7b4744f18d4ed4940881e13a76e4a7c 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 {
|
||||
}
|
||||
|
||||
public static long getCoordinateKey(final Entity entity) {
|
||||
- return ((long)(MCUtil.fastFloor(entity.getZ()) >> 4) << 32) | ((MCUtil.fastFloor(entity.getX()) >> 4) & 0xFFFFFFFFL);
|
||||
+ return ((long)(entity.blockPosition.getZ() >> 4) << 32) | ((entity.blockPosition.getX() >> 4) & 0xFFFFFFFFL); // Pufferfish - eliminate double->long cast in hotpath
|
||||
}
|
||||
|
||||
public static long getCoordinateKey(final ChunkPos pair) {
|
||||
File diff suppressed because it is too large
Load Diff
45
patches/server/0020-Add-config-for-watchdog-timeout.patch
Normal file
45
patches/server/0020-Add-config-for-watchdog-timeout.patch
Normal file
@@ -0,0 +1,45 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Tue, 31 Dec 2024 17:45:55 +0800
|
||||
Subject: [PATCH] Add config for watchdog timeout
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/FoliaWatchdogThread.java b/src/main/java/io/papermc/paper/threadedregions/FoliaWatchdogThread.java
|
||||
index 258d82ab2c78482e1561343e8e1f81fc33f1895e..967107c0f4a18a29877883ccddb4d7962f4b5788 100644
|
||||
--- a/src/main/java/io/papermc/paper/threadedregions/FoliaWatchdogThread.java
|
||||
+++ b/src/main/java/io/papermc/paper/threadedregions/FoliaWatchdogThread.java
|
||||
@@ -65,7 +65,7 @@ public final class FoliaWatchdogThread extends Thread {
|
||||
|
||||
for (final RunningTick tick : ticks) {
|
||||
final long elapsed = now - tick.lastPrint;
|
||||
- if (elapsed <= TimeUnit.SECONDS.toNanos(5L)) {
|
||||
+ if (elapsed <= TimeUnit.MILLISECONDS.toNanos(me.earthme.luminol.config.modules.misc.FoliaWatchogConfig.tickRegionTimeOutMs)) { // Luminol - Add config for watchdog timeout
|
||||
continue;
|
||||
}
|
||||
tick.lastPrint = now;
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/FoliaWatchogConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/FoliaWatchogConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..de58b5bf9dedf35bc56a9211d0769b988704a7fe
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/FoliaWatchogConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.misc;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class FoliaWatchogConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "tick_region_time_out_ms")
|
||||
+ public static int tickRegionTimeOutMs = 5000;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "folia_watchdog";
|
||||
+ }
|
||||
+}
|
||||
@@ -1,237 +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:00:59 +0800
|
||||
Subject: [PATCH] Pufferfish Improve fluid direction caching
|
||||
|
||||
|
||||
diff --git a/src/main/java/gg/airplane/structs/FluidDirectionCache.java b/src/main/java/gg/airplane/structs/FluidDirectionCache.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..aa8467b9dda1f7707e41f50ac7b3e9d7343723ec
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/airplane/structs/FluidDirectionCache.java
|
||||
@@ -0,0 +1,136 @@
|
||||
+package gg.airplane.structs;
|
||||
+
|
||||
+import it.unimi.dsi.fastutil.HashCommon;
|
||||
+
|
||||
+/**
|
||||
+ * This is a replacement for the cache used in FluidTypeFlowing.
|
||||
+ * The requirements for the previous cache were:
|
||||
+ * - Store 200 entries
|
||||
+ * - Look for the flag in the cache
|
||||
+ * - If it exists, move to front of cache
|
||||
+ * - If it doesn't exist, remove last entry in cache and insert in front
|
||||
+ *
|
||||
+ * This class accomplishes something similar, however has a few different
|
||||
+ * requirements put into place to make this more optimize:
|
||||
+ *
|
||||
+ * - maxDistance is the most amount of entries to be checked, instead
|
||||
+ * of having to check the entire list.
|
||||
+ * - In combination with that, entries are all tracked by age and how
|
||||
+ * frequently they're used. This enables us to remove old entries,
|
||||
+ * without constantly shifting any around.
|
||||
+ *
|
||||
+ * Usage of the previous map would have to reset the head every single usage,
|
||||
+ * shifting the entire map. Here, nothing happens except an increment when
|
||||
+ * the cache is hit, and when it needs to replace an old element only a single
|
||||
+ * element is modified.
|
||||
+ */
|
||||
+public class FluidDirectionCache<T> {
|
||||
+
|
||||
+ private static class FluidDirectionEntry<T> {
|
||||
+ private final T data;
|
||||
+ private final boolean flag;
|
||||
+ private int uses = 0;
|
||||
+ private int age = 0;
|
||||
+
|
||||
+ private FluidDirectionEntry(T data, boolean flag) {
|
||||
+ this.data = data;
|
||||
+ this.flag = flag;
|
||||
+ }
|
||||
+
|
||||
+ public int getValue() {
|
||||
+ return this.uses - (this.age >> 1); // age isn't as important as uses
|
||||
+ }
|
||||
+
|
||||
+ public void incrementUses() {
|
||||
+ this.uses = this.uses + 1 & Integer.MAX_VALUE;
|
||||
+ }
|
||||
+
|
||||
+ public void incrementAge() {
|
||||
+ this.age = this.age + 1 & Integer.MAX_VALUE;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private final FluidDirectionEntry[] entries;
|
||||
+ private final int mask;
|
||||
+ private final int maxDistance; // the most amount of entries to check for a value
|
||||
+
|
||||
+ public FluidDirectionCache(int size) {
|
||||
+ int arraySize = HashCommon.nextPowerOfTwo(size);
|
||||
+ this.entries = new FluidDirectionEntry[arraySize];
|
||||
+ this.mask = arraySize - 1;
|
||||
+ this.maxDistance = Math.min(arraySize, 4);
|
||||
+ }
|
||||
+
|
||||
+ public Boolean getValue(T data) {
|
||||
+ FluidDirectionEntry curr;
|
||||
+ int pos;
|
||||
+
|
||||
+ if ((curr = this.entries[pos = HashCommon.mix(data.hashCode()) & this.mask]) == null) {
|
||||
+ return null;
|
||||
+ } else if (data.equals(curr.data)) {
|
||||
+ curr.incrementUses();
|
||||
+ return curr.flag;
|
||||
+ }
|
||||
+
|
||||
+ int checked = 1; // start at 1 because we already checked the first spot above
|
||||
+
|
||||
+ while ((curr = this.entries[pos = (pos + 1) & this.mask]) != null) {
|
||||
+ if (data.equals(curr.data)) {
|
||||
+ curr.incrementUses();
|
||||
+ return curr.flag;
|
||||
+ } else if (++checked >= this.maxDistance) {
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ public void putValue(T data, boolean flag) {
|
||||
+ FluidDirectionEntry<T> curr;
|
||||
+ int pos;
|
||||
+
|
||||
+ if ((curr = this.entries[pos = HashCommon.mix(data.hashCode()) & this.mask]) == null) {
|
||||
+ this.entries[pos] = new FluidDirectionEntry<>(data, flag); // add
|
||||
+ return;
|
||||
+ } else if (data.equals(curr.data)) {
|
||||
+ curr.incrementUses();
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ int checked = 1; // start at 1 because we already checked the first spot above
|
||||
+
|
||||
+ while ((curr = this.entries[pos = (pos + 1) & this.mask]) != null) {
|
||||
+ if (data.equals(curr.data)) {
|
||||
+ curr.incrementUses();
|
||||
+ return;
|
||||
+ } else if (++checked >= this.maxDistance) {
|
||||
+ this.forceAdd(data, flag);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ this.entries[pos] = new FluidDirectionEntry<>(data, flag); // add
|
||||
+ }
|
||||
+
|
||||
+ private void forceAdd(T data, boolean flag) {
|
||||
+ int expectedPos = HashCommon.mix(data.hashCode()) & this.mask;
|
||||
+
|
||||
+ int toRemovePos = expectedPos;
|
||||
+ FluidDirectionEntry entryToRemove = this.entries[toRemovePos];
|
||||
+
|
||||
+ for (int i = expectedPos + 1; i < expectedPos + this.maxDistance; i++) {
|
||||
+ int pos = i & this.mask;
|
||||
+ FluidDirectionEntry entry = this.entries[pos];
|
||||
+ if (entry.getValue() < entryToRemove.getValue()) {
|
||||
+ toRemovePos = pos;
|
||||
+ entryToRemove = entry;
|
||||
+ }
|
||||
+
|
||||
+ entry.incrementAge(); // use this as a mechanism to age the other entries
|
||||
+ }
|
||||
+
|
||||
+ // remove the least used/oldest entry
|
||||
+ this.entries[toRemovePos] = new FluidDirectionEntry(data, flag);
|
||||
+ }
|
||||
+}
|
||||
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
|
||||
--- 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 {
|
||||
public static final BooleanProperty FALLING = BlockStateProperties.FALLING;
|
||||
public static final IntegerProperty LEVEL = BlockStateProperties.LEVEL_FLOWING;
|
||||
private static final int CACHE_SIZE = 200;
|
||||
+ // Pufferfish start - use our own cache
|
||||
+ /*
|
||||
private static final ThreadLocal<Object2ByteLinkedOpenHashMap<Block.BlockStatePairKey>> OCCLUSION_CACHE = ThreadLocal.withInitial(() -> {
|
||||
Object2ByteLinkedOpenHashMap<Block.BlockStatePairKey> object2bytelinkedopenhashmap = new Object2ByteLinkedOpenHashMap<Block.BlockStatePairKey>(200) {
|
||||
protected void rehash(int i) {}
|
||||
@@ -53,6 +55,14 @@ public abstract class FlowingFluid extends Fluid {
|
||||
object2bytelinkedopenhashmap.defaultReturnValue((byte) 127);
|
||||
return object2bytelinkedopenhashmap;
|
||||
});
|
||||
+ */
|
||||
+
|
||||
+ private static final ThreadLocal<gg.airplane.structs.FluidDirectionCache<Block.BlockStatePairKey>> localFluidDirectionCache = ThreadLocal.withInitial(() -> {
|
||||
+ // Pufferfish todo - mess with this number for performance
|
||||
+ // with 2048 it seems very infrequent on a small world that it has to remove old entries
|
||||
+ return new gg.airplane.structs.FluidDirectionCache<>(2048);
|
||||
+ });
|
||||
+ // Pufferfish end
|
||||
private final Map<FluidState, VoxelShape> shapes = Maps.newIdentityHashMap();
|
||||
|
||||
public FlowingFluid() {}
|
||||
@@ -252,6 +262,8 @@ public abstract class FlowingFluid extends Fluid {
|
||||
return false;
|
||||
}
|
||||
// Paper end - optimise collisions
|
||||
+ // Pufferfish start - modify to use our cache
|
||||
+ /*
|
||||
Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap;
|
||||
|
||||
if (!state.getBlock().hasDynamicShape() && !fromState.getBlock().hasDynamicShape()) {
|
||||
@@ -259,9 +271,16 @@ public abstract class FlowingFluid extends Fluid {
|
||||
} else {
|
||||
object2bytelinkedopenhashmap = null;
|
||||
}
|
||||
+ */
|
||||
+ gg.airplane.structs.FluidDirectionCache<Block.BlockStatePairKey> cache = null;
|
||||
+
|
||||
+ if (!state.getBlock().hasDynamicShape() && !fromState.getBlock().hasDynamicShape()) {
|
||||
+ cache = localFluidDirectionCache.get();
|
||||
+ }
|
||||
|
||||
Block.BlockStatePairKey block_a;
|
||||
|
||||
+ /*
|
||||
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 {
|
||||
} else {
|
||||
block_a = null;
|
||||
}
|
||||
+ */
|
||||
+ if (cache != null) {
|
||||
+ block_a = new Block.BlockStatePairKey(state, fromState, face);
|
||||
+ Boolean flag = cache.getValue(block_a);
|
||||
+ if (flag != null) {
|
||||
+ return flag;
|
||||
+ }
|
||||
+ } else {
|
||||
+ block_a = null;
|
||||
+ }
|
||||
|
||||
VoxelShape voxelshape = state.getCollisionShape(world, pos);
|
||||
VoxelShape voxelshape1 = fromState.getCollisionShape(world, fromPos);
|
||||
boolean flag = !Shapes.mergedFaceOccludes(voxelshape, voxelshape1, face);
|
||||
|
||||
+ /*
|
||||
if (object2bytelinkedopenhashmap != null) {
|
||||
if (object2bytelinkedopenhashmap.size() == 200) {
|
||||
object2bytelinkedopenhashmap.removeLastByte();
|
||||
@@ -284,6 +314,11 @@ public abstract class FlowingFluid extends Fluid {
|
||||
|
||||
object2bytelinkedopenhashmap.putAndMoveToFirst(block_a, (byte) (flag ? 1 : 0));
|
||||
}
|
||||
+ */
|
||||
+ if (cache != null) {
|
||||
+ cache.putValue(block_a, flag);
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
|
||||
return flag;
|
||||
}
|
||||
@@ -1,86 +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:05:32 +0800
|
||||
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/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 51dee7adc0dc534fac66bf3e8709865157dd763b..f13d26b280f095d006ffccb36af66bb7487cb8da 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 {
|
||||
boolean flag = this instanceof net.minecraft.world.entity.player.Player;
|
||||
|
||||
if (!this.level().isClientSide) {
|
||||
- if (this.isInWall()) {
|
||||
+ if (shouldCheckForSuffocation() && this.isInWall()) { // Pufferfish - optimize suffocation
|
||||
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 {
|
||||
return this.getHealth() <= 0.0F;
|
||||
}
|
||||
|
||||
+ // Pufferfish start - optimize suffocation
|
||||
+ public boolean couldPossiblyBeHurt(float amount) {
|
||||
+ if ((float) this.invulnerableTime > (float) this.invulnerableDuration / 2.0F && amount <= this.lastHurt) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ public boolean shouldCheckForSuffocation() {
|
||||
+ return !LuminolConfig.enableSuffocationOptimization || (tickCount % 10 == 0 && couldPossiblyBeHurt(1.0F));
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
+
|
||||
@Override
|
||||
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
|
||||
--- 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
|
||||
this.bossEvent.setName(this.getDisplayName());
|
||||
}
|
||||
|
||||
+ // Pufferfish start - optimize suffocation
|
||||
+ @Override
|
||||
+ public boolean shouldCheckForSuffocation() {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
+
|
||||
@Override
|
||||
protected SoundEvent getAmbientSound() {
|
||||
return SoundEvents.WITHER_AMBIENT;
|
||||
@@ -0,0 +1,67 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 7 Feb 2024 06:30:03 +0000
|
||||
Subject: [PATCH] Try fixing folia spector teleportation
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaSpectorTeleportationFixConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaSpectorTeleportationFixConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..01f8c6ff3662569be5a4ff998bcd4fbbcb555105
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaSpectorTeleportationFixConfig.java
|
||||
@@ -0,0 +1,25 @@
|
||||
+package me.earthme.luminol.config.modules.fixes;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class FoliaSpectorTeleportationFixConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled", comments =
|
||||
+ """
|
||||
+ The teleportation of spector players would call absMoveTo directly.\s
|
||||
+ And when the camera teleported to another region,this would call absMoveTo\s
|
||||
+ to let the spector player move to another region without any checks, which \s
|
||||
+ would trigger the async catcher and crash the server""")
|
||||
+ public static boolean fixSpectorTeleportFolia = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.FIXES;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "folia.fix_spector_teleportation";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 93c038ba1fd216fd11ab8b5cec5807453f34e152..c72bda7413d9a7ce763743d0efbd85257262477e 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1162,9 +1162,24 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
||||
}
|
||||
|
||||
Entity entity = this.getCamera();
|
||||
+ //Luminol start - Fix folia spector teleportation
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(entity) && me.earthme.luminol.config.modules.fixes.FoliaSpectorTeleportationFixConfig.fixSpectorTeleportFolia){
|
||||
+ this.setCamera(this);
|
||||
+ }
|
||||
+ //Luminol end
|
||||
|
||||
if (entity != this) {
|
||||
- if (entity.isAlive()) {
|
||||
+ // Luminol start - Fix folia spector teleportation
|
||||
+ var flag = false;
|
||||
+ var cameraPos = entity.blockPosition();
|
||||
+ var cameraLevel = entity.level();
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(cameraLevel, cameraPos) && me.earthme.luminol.config.modules.fixes.FoliaSpectorTeleportationFixConfig.fixSpectorTeleportFolia){
|
||||
+ this.setCamera(this);
|
||||
+ flag = true;
|
||||
+ }
|
||||
+ // Luminol end
|
||||
+
|
||||
+ if (entity.isAlive() && !flag) { // Luminol - Fix folia spector teleportation
|
||||
this.absMoveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot());
|
||||
this.serverLevel().getChunkSource().move(this);
|
||||
if (this.wantsToStopRiding()) {
|
||||
@@ -1,31 +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:07:30 +0800
|
||||
Subject: [PATCH] Pufferfish Early return optimization for target finding
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
|
||||
index c157309ac78e7af084d3acb6e8b2bcd469a39d5e..ac5e5676b194a2a99e5cf53eb89c1152cac963b8 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
|
||||
@@ -75,9 +75,18 @@ public class TargetingConditions {
|
||||
}
|
||||
|
||||
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
|
||||
+ // 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());
|
||||
+ double followRangeRaw = this.useFollowRange ? this.getFollowRange(baseEntity) : this.range;
|
||||
+
|
||||
+ if (f > followRangeRaw * followRangeRaw) { // the actual follow range will always be this value or smaller, so if the distance is larger then it never will return true after getting invis
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0D;
|
||||
+ double e = Math.max((followRangeRaw) * d, 2.0D); // Paper
|
||||
+ // Pufferfish end
|
||||
if (f > e * e) {
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sat, 30 Nov 2024 11:36:43 +0800
|
||||
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..0e51d465db3554ac80d00c6b85cc1f013f3949ba
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaEntityMovingFixConfig.java
|
||||
@@ -0,0 +1,28 @@
|
||||
+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", comments =
|
||||
+ """
|
||||
+ A simple fix of a issue on folia\s
|
||||
+ (Some times the entity would\s
|
||||
+ have a large moment that cross the\s
|
||||
+ different tick regions and it would\s
|
||||
+ make the server crashed) but sometimes it might doesn't work""")
|
||||
+ public static boolean enabled = false;
|
||||
+ @ConfigInfo(baseName = "warn_on_detected")
|
||||
+ public static boolean warnOnDetected = true;
|
||||
+
|
||||
+ @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 8e1a75e56cc373a9ec9b563666af0864eee99479..4fdbdd1c5c937c20026afe555fa1c8371b4eaa16 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -1181,6 +1181,10 @@ 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 type, Vec3 movement) {
|
||||
final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity
|
||||
// Paper start - detailed watchdog information
|
||||
@@ -1191,6 +1195,32 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
this.moveStartZ = this.getZ();
|
||||
this.moveVector = movement;
|
||||
}
|
||||
+ //Luminol start - Fix high position moving
|
||||
+ if (me.earthme.luminol.config.modules.fixes.FoliaEntityMovingFixConfig.enabled && ca.spottedleaf.moonrise.common.util.TickThread.isTickThread()){ //Except the threads because it may be called by the chunk system worker thread
|
||||
+ var finalPosition = movement.add(this.position);
|
||||
+ if (this.preventMoving || Double.isNaN(finalPosition.x) || Double.isNaN(finalPosition.y) || Double.isNaN(finalPosition.z)){
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (!ca.spottedleaf.moonrise.common.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
|
||||
try {
|
||||
// Paper end - detailed watchdog information
|
||||
if (this.noPhysics) {
|
||||
@@ -0,0 +1,89 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Mon, 10 Jun 2024 10:51:08 +0000
|
||||
Subject: [PATCH] Try fixing folia off region POI accessing issue
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaPOIAccessOffRegionFixConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaPOIAccessOffRegionFixConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7812a71f05dd32646037afd22cdabf72bb23b0d1
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaPOIAccessOffRegionFixConfig.java
|
||||
@@ -0,0 +1,25 @@
|
||||
+package me.earthme.luminol.config.modules.fixes;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class FoliaPOIAccessOffRegionFixConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled", comments =
|
||||
+ """
|
||||
+ The POIManager of folia has something which has not been patched\s
|
||||
+ for regionized ticking and these would trigger the async catcher\s
|
||||
+ and make the server crash.If you would like to prevent it and didn't\s
|
||||
+ mind the side effect(currently unknown), you can enable this""")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.FIXES;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "folia.fix_poi_access_off_region";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/GoToPotentialJobSite.java b/src/main/java/net/minecraft/world/entity/ai/behavior/GoToPotentialJobSite.java
|
||||
index aac1df9e2c0652bc6348af0404deba7465f82d42..ad812fd30d21ee3b7727105c66f2fc495a44f6ca 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/GoToPotentialJobSite.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/GoToPotentialJobSite.java
|
||||
@@ -49,10 +49,17 @@ public class GoToPotentialJobSite extends Behavior<Villager> {
|
||||
ServerLevel serverLevel2 = serverLevel.getServer().getLevel(pos.dimension());
|
||||
if (serverLevel2 != null) {
|
||||
PoiManager poiManager = serverLevel2.getPoiManager();
|
||||
+ //Luminol start - Fix off region POI accessing
|
||||
+ java.lang.Runnable scheduledRelease = () -> {
|
||||
if (poiManager.exists(blockPos, poiType -> true)) {
|
||||
poiManager.release(blockPos);
|
||||
}
|
||||
-
|
||||
+ };
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(serverLevel2, blockPos) && me.earthme.luminol.config.modules.fixes.FoliaPOIAccessOffRegionFixConfig.enabled)
|
||||
+ io.papermc.paper.threadedregions.RegionizedServer.getInstance().taskQueue.queueTickTaskQueue(serverLevel2, blockPos.getX() >> 4, blockPos.getZ() >> 4, scheduledRelease);
|
||||
+ else
|
||||
+ scheduledRelease.run();
|
||||
+ //Luminol end
|
||||
DebugPackets.sendPoiTicketCountPacket(serverLevel, blockPos);
|
||||
}
|
||||
});
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/YieldJobSite.java b/src/main/java/net/minecraft/world/entity/ai/behavior/YieldJobSite.java
|
||||
index d1a9b62d3304916275dd6b4c4e783cf1563b5e21..7d90e57b59ca1be1cc64ff6b53c64ea1f1767ad0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/YieldJobSite.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/YieldJobSite.java
|
||||
@@ -33,7 +33,10 @@ public class YieldJobSite {
|
||||
} else if (entity.getVillagerData().getProfession() != VillagerProfession.NONE) {
|
||||
return false;
|
||||
} else {
|
||||
- BlockPos blockPos = context.<GlobalPos>get(potentialJobSite).pos();
|
||||
+ final GlobalPos globalPos = context.<GlobalPos>get(potentialJobSite); //Luminol - Try fixing off main POI accessing
|
||||
+ final net.minecraft.server.level.ServerLevel targetLevel = net.minecraft.server.MinecraftServer.getServer().getLevel(globalPos.dimension()); //Luminol - Try fixing off main POI accessing
|
||||
+ BlockPos blockPos = globalPos.pos(); //Luminol - Try fixing off main POI accessing
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(targetLevel, blockPos) && me.earthme.luminol.config.modules.fixes.FoliaPOIAccessOffRegionFixConfig.enabled) return true; //Luminol - Try fixing off main POI accessing
|
||||
Optional<Holder<PoiType>> optional = world.getPoiManager().getType(blockPos);
|
||||
if (optional.isEmpty()) {
|
||||
return true;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
||||
index f3f98e6276dda3bc4f290fc2d80569f7e1e7ef66..edc127c94a54aed42120a5b4cc7036b5ddc8c656 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
|
||||
@@ -212,7 +212,7 @@ public class PoiManager extends SectionStorage<PoiSection, PoiSection.Packed> im
|
||||
|
||||
public Stream<PoiRecord> getInSquare(Predicate<Holder<PoiType>> typePredicate, BlockPos pos, int radius, PoiManager.Occupancy occupationStatus) {
|
||||
int i = Math.floorDiv(radius, 16) + 1;
|
||||
- return ChunkPos.rangeClosed(new ChunkPos(pos), i).flatMap(chunkPos -> this.getInChunk(typePredicate, chunkPos, occupationStatus)).filter(poi -> {
|
||||
+ return ChunkPos.rangeClosed(new ChunkPos(pos), i).filter(cpos -> me.earthme.luminol.config.modules.fixes.FoliaPOIAccessOffRegionFixConfig.enabled ? ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(this.world,cpos) : true).flatMap(chunkPos -> this.getInChunk(typePredicate, chunkPos, occupationStatus)).filter(poi -> { //Luminol - Fix off region POI access
|
||||
BlockPos blockPos2 = poi.getPos();
|
||||
return Math.abs(blockPos2.getX() - pos.getX()) <= radius && Math.abs(blockPos2.getZ() - pos.getZ()) <= radius;
|
||||
});
|
||||
@@ -1,478 +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:08:46 +0800
|
||||
Subject: [PATCH] Pufferfish Improve container checking with a bitset
|
||||
|
||||
|
||||
diff --git a/src/main/java/gg/airplane/structs/ItemListWithBitset.java b/src/main/java/gg/airplane/structs/ItemListWithBitset.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..1b7a4ee47f4445d7f2ac91d3a73ae113edbdddb2
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/airplane/structs/ItemListWithBitset.java
|
||||
@@ -0,0 +1,114 @@
|
||||
+package gg.airplane.structs;
|
||||
+
|
||||
+import net.minecraft.core.NonNullList;
|
||||
+import net.minecraft.world.item.ItemStack;
|
||||
+import org.apache.commons.lang.Validate;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+import java.util.AbstractList;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.List;
|
||||
+
|
||||
+public class ItemListWithBitset extends AbstractList<ItemStack> {
|
||||
+ public static ItemListWithBitset fromList(List<ItemStack> list) {
|
||||
+ if (list instanceof ItemListWithBitset ours) {
|
||||
+ return ours;
|
||||
+ }
|
||||
+ return new ItemListWithBitset(list);
|
||||
+ }
|
||||
+
|
||||
+ private static ItemStack[] createArray(int size) {
|
||||
+ ItemStack[] array = new ItemStack[size];
|
||||
+ Arrays.fill(array, ItemStack.EMPTY);
|
||||
+ return array;
|
||||
+ }
|
||||
+
|
||||
+ private final ItemStack[] items;
|
||||
+
|
||||
+ private long bitSet = 0;
|
||||
+ private final long allBits;
|
||||
+
|
||||
+ private static class OurNonNullList extends NonNullList<ItemStack> {
|
||||
+ protected OurNonNullList(List<ItemStack> delegate) {
|
||||
+ super(delegate, ItemStack.EMPTY);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public final NonNullList<ItemStack> nonNullList = new OurNonNullList(this);
|
||||
+
|
||||
+ private ItemListWithBitset(List<ItemStack> list) {
|
||||
+ this(list.size());
|
||||
+
|
||||
+ for (int i = 0; i < list.size(); i++) {
|
||||
+ this.set(i, list.get(i));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public ItemListWithBitset(int size) {
|
||||
+ Validate.isTrue(size < Long.BYTES * 8, "size is too large");
|
||||
+
|
||||
+ this.items = createArray(size);
|
||||
+ this.allBits = ((1L << size) - 1);
|
||||
+ }
|
||||
+
|
||||
+ public boolean isCompletelyEmpty() {
|
||||
+ return this.bitSet == 0;
|
||||
+ }
|
||||
+
|
||||
+ public boolean hasFullStacks() {
|
||||
+ return (this.bitSet & this.allBits) == allBits;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ItemStack set(int index, @NotNull ItemStack itemStack) {
|
||||
+ ItemStack existing = this.items[index];
|
||||
+
|
||||
+ this.items[index] = itemStack;
|
||||
+
|
||||
+ if (itemStack == ItemStack.EMPTY) {
|
||||
+ this.bitSet &= ~(1L << index);
|
||||
+ } else {
|
||||
+ this.bitSet |= 1L << index;
|
||||
+ }
|
||||
+
|
||||
+ return existing;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ public ItemStack get(int var0) {
|
||||
+ return this.items[var0];
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int size() {
|
||||
+ return this.items.length;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void clear() {
|
||||
+ Arrays.fill(this.items, ItemStack.EMPTY);
|
||||
+ }
|
||||
+
|
||||
+ // these are unsupported for block inventories which have a static size
|
||||
+ @Override
|
||||
+ public void add(int var0, ItemStack var1) {
|
||||
+ throw new UnsupportedOperationException();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ItemStack remove(int var0) {
|
||||
+ throw new UnsupportedOperationException();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String toString() {
|
||||
+ return "ItemListWithBitset{" +
|
||||
+ "items=" + Arrays.toString(items) +
|
||||
+ ", bitSet=" + Long.toString(bitSet, 2) +
|
||||
+ ", allBits=" + Long.toString(allBits, 2) +
|
||||
+ ", size=" + this.items.length +
|
||||
+ '}';
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/CompoundContainer.java b/src/main/java/net/minecraft/world/CompoundContainer.java
|
||||
index 241fec02e6869c638d3a160819b32173a081467b..6a8f9e8f5bf108674c47018def28906e2d0a729c 100644
|
||||
--- a/src/main/java/net/minecraft/world/CompoundContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/CompoundContainer.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.world;
|
||||
|
||||
+import net.minecraft.core.Direction; // Pufferfish
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
@@ -64,6 +65,23 @@ public class CompoundContainer implements Container {
|
||||
this.container2 = second;
|
||||
}
|
||||
|
||||
+ // Pufferfish start
|
||||
+ @Override
|
||||
+ public boolean hasEmptySlot(Direction enumdirection) {
|
||||
+ return this.container1.hasEmptySlot(null) || this.container2.hasEmptySlot(null);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCompletelyFull(Direction enumdirection) {
|
||||
+ return this.container1.isCompletelyFull(null) && this.container2.isCompletelyFull(null);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCompletelyEmpty(Direction enumdirection) {
|
||||
+ return this.container1.isCompletelyEmpty(null) && this.container2.isCompletelyEmpty(null);
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
+
|
||||
@Override
|
||||
public int getContainerSize() {
|
||||
return this.container1.getContainerSize() + this.container2.getContainerSize();
|
||||
diff --git a/src/main/java/net/minecraft/world/Container.java b/src/main/java/net/minecraft/world/Container.java
|
||||
index d6cbe98e67fdbf8db46338a88ab1356dd63b50a3..20dd3a63b2f955b05a75eb240e33ae4cf6aef28f 100644
|
||||
--- a/src/main/java/net/minecraft/world/Container.java
|
||||
+++ b/src/main/java/net/minecraft/world/Container.java
|
||||
@@ -3,6 +3,8 @@ package net.minecraft.world;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import net.minecraft.core.BlockPos;
|
||||
+
|
||||
+import net.minecraft.core.Direction; // Pufferfish
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -14,6 +16,63 @@ import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
// CraftBukkit end
|
||||
|
||||
public interface Container extends Clearable {
|
||||
+ // Pufferfish start - allow the inventory to override and optimize these frequent calls
|
||||
+ default boolean hasEmptySlot(@org.jetbrains.annotations.Nullable Direction enumdirection) { // there is a slot with 0 items in it
|
||||
+ if (this instanceof WorldlyContainer worldlyContainer) {
|
||||
+ for (int i : worldlyContainer.getSlotsForFace(enumdirection)) {
|
||||
+ if (this.getItem(i).isEmpty()) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ int size = this.getContainerSize();
|
||||
+ for (int i = 0; i < size; i++) {
|
||||
+ if (this.getItem(i).isEmpty()) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ default boolean isCompletelyFull(@org.jetbrains.annotations.Nullable Direction enumdirection) { // every stack is maxed
|
||||
+ if (this instanceof WorldlyContainer worldlyContainer) {
|
||||
+ for (int i : worldlyContainer.getSlotsForFace(enumdirection)) {
|
||||
+ ItemStack itemStack = this.getItem(i);
|
||||
+ if (itemStack.getCount() < itemStack.getMaxStackSize()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ int size = this.getContainerSize();
|
||||
+ for (int i = 0; i < size; i++) {
|
||||
+ ItemStack itemStack = this.getItem(i);
|
||||
+ if (itemStack.getCount() < itemStack.getMaxStackSize()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ default boolean isCompletelyEmpty(@org.jetbrains.annotations.Nullable Direction enumdirection) {
|
||||
+ if (this instanceof WorldlyContainer worldlyContainer) {
|
||||
+ for (int i : worldlyContainer.getSlotsForFace(enumdirection)) {
|
||||
+ if (!this.getItem(i).isEmpty()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ int size = this.getContainerSize();
|
||||
+ for (int i = 0; i < size; i++) {
|
||||
+ if (!this.getItem(i).isEmpty()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
|
||||
int LARGE_MAX_STACK_SIZE = 64;
|
||||
int DEFAULT_DISTANCE_LIMIT = 8;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
index 00187fbbeddfc17e1b6887f8bf0f50da23938470..f64edfdb03f99624daf1e05b5dc86d845c3018b6 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
@@ -27,7 +27,10 @@ import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
public abstract class AbstractMinecartContainer extends AbstractMinecart implements ContainerEntity {
|
||||
|
||||
+ // Pufferfish start
|
||||
private NonNullList<ItemStack> itemStacks;
|
||||
+ private gg.airplane.structs.ItemListWithBitset itemStacksOptimized;
|
||||
+ // Pufferfish end
|
||||
@Nullable
|
||||
public ResourceLocation lootTable;
|
||||
public long lootTableSeed;
|
||||
@@ -89,12 +92,18 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||
|
||||
protected AbstractMinecartContainer(EntityType<?> type, Level world) {
|
||||
super(type, world);
|
||||
- this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513
|
||||
+ // Pufferfish start
|
||||
+ this.itemStacksOptimized = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize()); // CraftBukkit - SPIGOT-3513
|
||||
+ this.itemStacks = this.itemStacksOptimized.nonNullList;
|
||||
+ // Pufferfish end
|
||||
}
|
||||
|
||||
protected AbstractMinecartContainer(EntityType<?> type, double x, double y, double z, Level world) {
|
||||
super(type, world, x, y, z);
|
||||
- this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513
|
||||
+ // Pufferfish start
|
||||
+ this.itemStacksOptimized = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize()); // CraftBukkit - SPIGOT-3513
|
||||
+ this.itemStacks = this.itemStacksOptimized.nonNullList;
|
||||
+ // Pufferfish end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -156,6 +165,10 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||
protected void readAdditionalSaveData(CompoundTag nbt) {
|
||||
super.readAdditionalSaveData(nbt);
|
||||
this.lootableData.loadNbt(nbt); // Paper
|
||||
+ // Pufferfish start
|
||||
+ this.itemStacksOptimized = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize());
|
||||
+ this.itemStacks = this.itemStacksOptimized.nonNullList;
|
||||
+ // Pufferfish end
|
||||
this.readChestVehicleSaveData(nbt);
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
index a71414397bd45ee7bcacfeef0041d80dfa25f114..d66806565770cb03a21794f99e5c4b0f3040b26a 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
@@ -31,7 +31,10 @@ import org.bukkit.entity.HumanEntity;
|
||||
public class ChestBlockEntity extends RandomizableContainerBlockEntity implements LidBlockEntity {
|
||||
|
||||
private static final int EVENT_SET_OPEN_COUNT = 1;
|
||||
+ // Pufferfish start
|
||||
private NonNullList<ItemStack> items;
|
||||
+ private gg.airplane.structs.ItemListWithBitset optimizedItems;
|
||||
+ // Pufferfish end
|
||||
public final ContainerOpenersCounter openersCounter;
|
||||
private final ChestLidController chestLidController;
|
||||
|
||||
@@ -65,9 +68,13 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
+ private final boolean isNative = getClass().equals(ChestBlockEntity.class); // Pufferfish
|
||||
protected ChestBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
- this.items = NonNullList.withSize(27, ItemStack.EMPTY);
|
||||
+ // Pufferfish start
|
||||
+ this.optimizedItems = new gg.airplane.structs.ItemListWithBitset(27);
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Pufferfish end
|
||||
this.openersCounter = new ContainerOpenersCounter() {
|
||||
@Override
|
||||
protected void onOpen(Level world, BlockPos pos, BlockState state) {
|
||||
@@ -98,6 +105,23 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
this.chestLidController = new ChestLidController();
|
||||
}
|
||||
|
||||
+ // Pufferfish start
|
||||
+ @Override
|
||||
+ public boolean hasEmptySlot(Direction enumdirection) {
|
||||
+ return isNative ? !this.optimizedItems.hasFullStacks() : super.hasEmptySlot(enumdirection);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCompletelyFull(Direction enumdirection) {
|
||||
+ return isNative ? this.optimizedItems.hasFullStacks() && super.isCompletelyFull(enumdirection) : super.isCompletelyFull(enumdirection);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCompletelyEmpty(Direction enumdirection) {
|
||||
+ return isNative && this.optimizedItems.isCompletelyEmpty() || super.isCompletelyEmpty(enumdirection);
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
+
|
||||
public ChestBlockEntity(BlockPos pos, BlockState state) {
|
||||
this(BlockEntityType.CHEST, pos, state);
|
||||
}
|
||||
@@ -115,7 +139,10 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
@Override
|
||||
public void load(CompoundTag nbt) {
|
||||
super.load(nbt);
|
||||
- this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
|
||||
+ // Pufferfish start
|
||||
+ this.optimizedItems = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize());
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Pufferfish end
|
||||
if (!this.tryLoadLootTable(nbt)) {
|
||||
ContainerHelper.loadAllItems(nbt, this.items);
|
||||
}
|
||||
@@ -187,7 +214,10 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
|
||||
@Override
|
||||
protected void setItems(NonNullList<ItemStack> list) {
|
||||
- this.items = list;
|
||||
+ // Pufferfish start
|
||||
+ this.optimizedItems = gg.airplane.structs.ItemListWithBitset.fromList(list);
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Pufferfish end
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
index 72779080969fe9f058c19533ffc9dad5f9c47086..c90d578643490709936545ee9cbd41c8671eeb7a 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
@@ -47,7 +47,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
|
||||
public static final int MOVE_ITEM_SPEED = 8;
|
||||
public static final int HOPPER_CONTAINER_SIZE = 5;
|
||||
+ // Pufferfish start
|
||||
private NonNullList<ItemStack> items;
|
||||
+ private gg.airplane.structs.ItemListWithBitset optimizedItems; // Pufferfish
|
||||
+ // Pufferfish end
|
||||
private int cooldownTime;
|
||||
private long tickedGameTime;
|
||||
|
||||
@@ -83,14 +86,37 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
|
||||
public HopperBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(BlockEntityType.HOPPER, pos, state);
|
||||
- this.items = NonNullList.withSize(5, ItemStack.EMPTY);
|
||||
+ // Pufferfish start
|
||||
+ this.optimizedItems = new gg.airplane.structs.ItemListWithBitset(5);
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Pufferfish end
|
||||
this.cooldownTime = -1;
|
||||
}
|
||||
|
||||
+ // Pufferfish start
|
||||
+ @Override
|
||||
+ public boolean hasEmptySlot(Direction enumdirection) {
|
||||
+ return !this.optimizedItems.hasFullStacks();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCompletelyFull(Direction enumdirection) {
|
||||
+ return this.optimizedItems.hasFullStacks() && super.isCompletelyFull(enumdirection);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCompletelyEmpty(Direction enumdirection) {
|
||||
+ return this.optimizedItems.isCompletelyEmpty() || super.isCompletelyEmpty(enumdirection);
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
+
|
||||
@Override
|
||||
public void load(CompoundTag nbt) {
|
||||
super.load(nbt);
|
||||
- this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
|
||||
+ // Pufferfish start
|
||||
+ this.optimizedItems = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize());
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Pufferfish end
|
||||
if (!this.tryLoadLootTable(nbt)) {
|
||||
ContainerHelper.loadAllItems(nbt, this.items);
|
||||
}
|
||||
@@ -493,6 +519,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
|
||||
|
||||
if (HopperBlockEntity.canPlaceItemInContainer(to, stack, slot, side)) {
|
||||
boolean flag = false;
|
||||
- boolean flag1 = to.isEmpty();
|
||||
+ boolean flag1 = to.isCompletelyEmpty(side); // Pufferfish
|
||||
|
||||
if (itemstack1.isEmpty()) {
|
||||
// Spigot start - SPIGOT-6693, InventorySubcontainer#setItem
|
||||
@@ -911,7 +942,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
|
||||
@Override
|
||||
protected void setItems(NonNullList<ItemStack> list) {
|
||||
- this.items = list;
|
||||
+ // Pufferfish start
|
||||
+ this.optimizedItems = gg.airplane.structs.ItemListWithBitset.fromList(list);
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Pufferfish end
|
||||
}
|
||||
|
||||
public static void entityInside(Level world, BlockPos pos, BlockState state, Entity entity, HopperBlockEntity blockEntity) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
index 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
|
||||
}
|
||||
|
||||
37
patches/server/0024-Try-fixing-folia-315.patch
Normal file
37
patches/server/0024-Try-fixing-folia-315.patch
Normal file
@@ -0,0 +1,37 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sat, 11 Jan 2025 15:23:31 +0800
|
||||
Subject: [PATCH] Try fixing folia #315
|
||||
|
||||
Might be useful to https://github.com/PaperMC/Folia/issues/315
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
|
||||
index 3bd0f3ae53eaa22409152d7f41e511e76bdaa265..6e76e4801653d0c84cb811bf72f1e1e8e1712ff6 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
|
||||
@@ -51,7 +51,7 @@ public class ThrownEnderpearl extends ThrowableItemProjectile {
|
||||
return Items.ENDER_PEARL;
|
||||
}
|
||||
|
||||
- @Override
|
||||
+ /*@Override // Luminol - Try fixing folia #315
|
||||
protected void setOwnerThroughUUID(UUID uuid) {
|
||||
this.deregisterFromCurrentOwner();
|
||||
super.setOwnerThroughUUID(uuid);
|
||||
@@ -64,6 +64,7 @@ public class ThrownEnderpearl extends ThrowableItemProjectile {
|
||||
super.setOwner(entity);
|
||||
this.registerToCurrentOwner();
|
||||
}
|
||||
+ */ // Luminol - Try fixing folia #315
|
||||
|
||||
private void deregisterFromCurrentOwner() {
|
||||
Entity entity = this.getOwner();
|
||||
@@ -388,7 +389,7 @@ public class ThrownEnderpearl extends ThrowableItemProjectile {
|
||||
@Override
|
||||
public void onRemoval(Entity.RemovalReason reason) {
|
||||
if (reason != Entity.RemovalReason.UNLOADED_WITH_PLAYER) {
|
||||
- this.deregisterFromCurrentOwner();
|
||||
+ // this.deregisterFromCurrentOwner(); // Luminol - Try fixing folia #315
|
||||
}
|
||||
|
||||
super.onRemoval(reason);
|
||||
151
patches/server/0025-Force-disable-builtin-spark-plugin.patch
Normal file
151
patches/server/0025-Force-disable-builtin-spark-plugin.patch
Normal file
@@ -0,0 +1,151 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sat, 30 Nov 2024 11:41:53 +0800
|
||||
Subject: [PATCH] Force disable builtin spark plugin
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/plugin/provider/source/FileProviderSource.java b/src/main/java/io/papermc/paper/plugin/provider/source/FileProviderSource.java
|
||||
index 48604e7f96adc9e226e034054c5e2bad0b024eb5..99f0c1e4d3437154a1062b0a8f94b7a04dd935af 100644
|
||||
--- a/src/main/java/io/papermc/paper/plugin/provider/source/FileProviderSource.java
|
||||
+++ b/src/main/java/io/papermc/paper/plugin/provider/source/FileProviderSource.java
|
||||
@@ -88,7 +88,7 @@ public class FileProviderSource implements ProviderSource<Path, Path> {
|
||||
}
|
||||
|
||||
final PluginMeta config = type.getConfig(file);
|
||||
- if ((config.getName().equals("spark") && config.getMainClass().equals("me.lucko.spark.bukkit.BukkitSparkPlugin")) && !SparksFly.isPluginPreferred()) {
|
||||
+ if ((config.getName().equals("spark") && config.getMainClass().equals("me.lucko.spark.bukkit.BukkitSparkPlugin")) && !SparksFly.isPluginPreferred() && false) { // Luminol - Force disable builtin spark
|
||||
LOGGER.info("The spark plugin will not be loaded as this server bundles the spark profiler.");
|
||||
return;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 04f68856cb3d982f1644d26f5ae57587b6e36ff2..55bac6e6cccce6e0282936ac78bbe82628daa655 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -809,8 +809,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
// Paper end - Configurable player collision
|
||||
|
||||
this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD);
|
||||
- this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark
|
||||
- this.server.spark.enableAfterPlugins(this.server); // Paper - spark
|
||||
+ if (false) this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark // Luminol - Force disable builtin spark
|
||||
+ if (false) this.server.spark.enableAfterPlugins(this.server); // Paper - spark // Luminol - Force disable builtin spark
|
||||
if (io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper != null) io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper.pluginsEnabled(); // Paper - Remap plugins
|
||||
io.papermc.paper.command.brigadier.PaperCommands.INSTANCE.setValid(); // Paper - reset invalid state for event fire below
|
||||
io.papermc.paper.plugin.lifecycle.event.LifecycleEventRunner.INSTANCE.callReloadableRegistrarEvent(io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents.COMMANDS, io.papermc.paper.command.brigadier.PaperCommands.INSTANCE, org.bukkit.plugin.Plugin.class, io.papermc.paper.plugin.lifecycle.event.registrar.ReloadableRegistrarEvent.Cause.INITIAL); // Paper - call commands event for regular plugins
|
||||
@@ -1126,7 +1126,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
Commands.COMMAND_SENDING_POOL.shutdownNow(); // Paper - Perf: Async command map building; Shutdown and don't bother finishing
|
||||
// CraftBukkit start
|
||||
if (this.server != null) {
|
||||
- this.server.spark.disable(); // Paper - spark
|
||||
+ if (false) this.server.spark.disable(); // Paper - spark // Luminol - Force disable builtin spark
|
||||
this.server.disablePlugins();
|
||||
this.server.waitForAsyncTasksShutdown(); // Paper - Wait for Async Tasks during shutdown
|
||||
}
|
||||
@@ -1323,7 +1323,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
this.statusIcon = (ServerStatus.Favicon) this.loadStatusIcon().orElse(null); // CraftBukkit - decompile error
|
||||
this.status = this.buildServerStatus();
|
||||
|
||||
- this.server.spark.enableBeforePlugins(); // Paper - spark
|
||||
+ if (false) this.server.spark.enableBeforePlugins(); // Paper - spark // Luminol - Force disable builtin spark
|
||||
// Folia start - region threading
|
||||
if (true) {
|
||||
io.papermc.paper.threadedregions.RegionizedServer.getInstance().init(); // Folia - region threading - only after loading worlds
|
||||
@@ -1728,7 +1728,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
|
||||
if (this.emptyTicks >= j) {
|
||||
- this.server.spark.tickStart(); // Paper - spark
|
||||
+ if (false)this.server.spark.tickStart(); // Paper - spark // Luminol - Force disable builtin spark
|
||||
if (this.emptyTicks == j) {
|
||||
MinecraftServer.LOGGER.info("Server empty for {} seconds, pausing", this.pauseWhileEmptySeconds());
|
||||
this.autoSave();
|
||||
@@ -1747,7 +1747,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
// Paper end - avoid issues with certain tasks not processing during sleep
|
||||
// Folia - region threading
|
||||
this.tickConnection();
|
||||
- this.server.spark.tickEnd(((double)(System.nanoTime() - lastTick) / 1000000D)); // Paper - spark
|
||||
+ if (false) this.server.spark.tickEnd(((double)(System.nanoTime() - lastTick) / 1000000D)); // Paper - spark // Luminol - Force disable builtin spark
|
||||
+ // Paper end - Server Tick Events
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1772,7 +1773,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
};
|
||||
// Folia end - region threading
|
||||
|
||||
- this.server.spark.tickStart(); // Paper - spark
|
||||
+ if (false) this.server.spark.tickStart(); // Paper - spark // Luminol - Force disable builtin spark
|
||||
new com.destroystokyo.paper.event.server.ServerTickStartEvent((int)region.getCurrentTick()).callEvent(); // Paper - Server Tick Events // Folia - region threading
|
||||
// Folia start - region threading
|
||||
if (region != null) {
|
||||
@@ -1843,7 +1844,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
long remaining = scheduledEnd - endTime; // Folia - region ticking
|
||||
new com.destroystokyo.paper.event.server.ServerTickEndEvent((int)io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick(), ((double)(endTime - startTime) / 1000000D), remaining).callEvent(); // Folia - region ticking
|
||||
// Paper end - Server Tick Events
|
||||
- this.server.spark.tickEnd(((double)(endTime - startTime) / 1000000D)); // Paper - spark // Folia - region ticking
|
||||
+ if (false) this.server.spark.tickEnd(((double)(endTime - startTime) / 1000000D)); // Paper - spark // Folia - region ticking // Luminol - Force disable builtin spark
|
||||
gameprofilerfiller.push("tallying");
|
||||
// Folia - region threading
|
||||
gameprofilerfiller.pop();
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index e6db178f57b63a1abb72c965d4a6e67f97d3b570..3c26533876ffa1d06bbc4d68f2712b8c96e37351 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -225,7 +225,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
// Paper end - initialize global and world-defaults configuration
|
||||
me.earthme.luminol.config.LuminolConfig.finalizeLoadConfig(); //Luminol - load config file
|
||||
me.earthme.luminol.config.LuminolConfig.setupLatch(); //Luminol - load config file
|
||||
- this.server.spark.enableEarlyIfRequested(); // Paper - spark
|
||||
+ if (false) this.server.spark.enableEarlyIfRequested(); // Paper - spark // Luminol - Force disable builtin spark
|
||||
// Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save
|
||||
if (this.convertOldUsers()) {
|
||||
this.getProfileCache().save(false); // Paper
|
||||
@@ -235,7 +235,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
org.spigotmc.WatchdogThread.doStart(org.spigotmc.SpigotConfig.timeoutTime, org.spigotmc.SpigotConfig.restartOnCrash); // Paper - start watchdog thread
|
||||
thread.start(); // Paper - Enhance console tab completions for brigadier commands; start console thread after MinecraftServer.console & PaperConfig are initialized
|
||||
io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command
|
||||
- this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark
|
||||
+ if (false) this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark // Luminol - Force disable builtin spark
|
||||
com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics
|
||||
com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 567e12e24ece2cd823b73e7337b10eb89995da21..20cf4ce4f73f681bdbe092d4693812800c953be9 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -312,7 +312,7 @@ public final class CraftServer implements Server {
|
||||
public static Exception excessiveVelEx; // Paper - Velocity warnings
|
||||
private final io.papermc.paper.logging.SysoutCatcher sysoutCatcher = new io.papermc.paper.logging.SysoutCatcher(); // Paper
|
||||
private final io.papermc.paper.potion.PaperPotionBrewer potionBrewer; // Paper - Custom Potion Mixes
|
||||
- public final io.papermc.paper.SparksFly spark; // Paper - spark
|
||||
+ public io.papermc.paper.SparksFly spark; // Paper - spark // Luminol - Force disable builtin spark
|
||||
|
||||
// Paper start - Folia region threading API
|
||||
private final io.papermc.paper.threadedregions.scheduler.FoliaRegionScheduler regionizedScheduler = new io.papermc.paper.threadedregions.scheduler.FoliaRegionScheduler(); // Folia - region threading
|
||||
@@ -490,7 +490,7 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
this.potionBrewer = new io.papermc.paper.potion.PaperPotionBrewer(console); // Paper - custom potion mixes
|
||||
datapackManager = new io.papermc.paper.datapack.PaperDatapackManager(console.getPackRepository()); // Paper
|
||||
- this.spark = new io.papermc.paper.SparksFly(this); // Paper - spark
|
||||
+ if (false) this.spark = new io.papermc.paper.SparksFly(this); // Paper - spark // Luminol - Force disable builtin spark
|
||||
}
|
||||
|
||||
public boolean getCommandBlockOverride(String command) {
|
||||
@@ -1154,7 +1154,7 @@ public final class CraftServer implements Server {
|
||||
this.reloadData();
|
||||
org.spigotmc.SpigotConfig.registerCommands(); // Spigot
|
||||
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
|
||||
- this.spark.registerCommandBeforePlugins(this); // Paper - spark
|
||||
+ if (false) this.spark.registerCommandBeforePlugins(this); // Paper - spark // Luminol - Force disable builtin spark
|
||||
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
||||
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
|
||||
|
||||
@@ -1183,7 +1183,7 @@ public final class CraftServer implements Server {
|
||||
this.loadPlugins();
|
||||
this.enablePlugins(PluginLoadOrder.STARTUP);
|
||||
this.enablePlugins(PluginLoadOrder.POSTWORLD);
|
||||
- this.spark.registerCommandAfterPlugins(this); // Paper - spark
|
||||
+ if (false) this.spark.registerCommandAfterPlugins(this); // Paper - spark // Luminol - Force disable builtin spark
|
||||
if (io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper != null) io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper.pluginsEnabled(); // Paper - Remap plugins
|
||||
// Paper start - brigadier command API
|
||||
io.papermc.paper.command.brigadier.PaperCommands.INSTANCE.setValid(); // to clear invalid state for event fire below
|
||||
@@ -1,153 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16:10:26 +0800
|
||||
Subject: [PATCH] Pufferfish Reduce entity fluid lookups if no fluids
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 3c9ec0f5fef49b0abc42382551de11ab942b3b20..967c7a953084dc68a0ecd4b1a0f13ead7e72cb3d 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 {
|
||||
}
|
||||
|
||||
public boolean updateFluidHeightAndDoFluidPushing(TagKey<Fluid> tag, double speed) {
|
||||
- if (this.touchingUnloadedChunk()) {
|
||||
+ if (false && this.touchingUnloadedChunk()) { // Pufferfish - cost of a lookup here is the same cost as below, so skip
|
||||
return false;
|
||||
} else {
|
||||
AABB axisalignedbb = this.getBoundingBox().deflate(0.001D);
|
||||
- int i = Mth.floor(axisalignedbb.minX);
|
||||
- int j = Mth.ceil(axisalignedbb.maxX);
|
||||
- int k = Mth.floor(axisalignedbb.minY);
|
||||
- int l = Mth.ceil(axisalignedbb.maxY);
|
||||
- int i1 = Mth.floor(axisalignedbb.minZ);
|
||||
- int j1 = Mth.ceil(axisalignedbb.maxZ);
|
||||
+ // Pufferfish start - rename
|
||||
+ int minBlockX = Mth.floor(axisalignedbb.minX);
|
||||
+ int maxBlockX = Mth.ceil(axisalignedbb.maxX);
|
||||
+ int minBlockY = Mth.floor(axisalignedbb.minY);
|
||||
+ int maxBlockY = Mth.ceil(axisalignedbb.maxY);
|
||||
+ int minBlockZ = Mth.floor(axisalignedbb.minZ);
|
||||
+ int maxBlockZ = Mth.ceil(axisalignedbb.maxZ);
|
||||
+ // Pufferfish end
|
||||
double d1 = 0.0D;
|
||||
boolean flag = this.isPushedByFluid();
|
||||
boolean flag1 = false;
|
||||
@@ -5149,14 +5151,61 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
int k1 = 0;
|
||||
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
|
||||
|
||||
- for (int l1 = i; l1 < j; ++l1) {
|
||||
- for (int i2 = k; i2 < l; ++i2) {
|
||||
- for (int j2 = i1; j2 < j1; ++j2) {
|
||||
- blockposition_mutableblockposition.set(l1, i2, j2);
|
||||
- FluidState fluid = this.level().getFluidState(blockposition_mutableblockposition);
|
||||
+ // Pufferfish start - based off CollisionUtil.getCollisionsForBlocksOrWorldBorder
|
||||
+ final int minSection = io.papermc.paper.util.WorldUtil.getMinSection(this.level());
|
||||
+ final int maxSection = io.papermc.paper.util.WorldUtil.getMaxSection(this.level());
|
||||
+ final int minBlock = minSection << 4;
|
||||
+ final int maxBlock = (maxSection << 4) | 15;
|
||||
+
|
||||
+ // special cases:
|
||||
+ if (minBlockY > maxBlock || maxBlockY < minBlock) {
|
||||
+ // no point in checking
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ int minYIterate = Math.max(minBlock, minBlockY);
|
||||
+ int maxYIterate = Math.min(maxBlock, maxBlockY);
|
||||
+
|
||||
+ int minChunkX = minBlockX >> 4;
|
||||
+ int maxChunkX = maxBlockX >> 4;
|
||||
+
|
||||
+ int minChunkZ = minBlockZ >> 4;
|
||||
+ int maxChunkZ = maxBlockZ >> 4;
|
||||
+
|
||||
+ for (int currChunkZ = minChunkZ; currChunkZ <= maxChunkZ; ++currChunkZ) {
|
||||
+ int minZ = currChunkZ == minChunkZ ? minBlockZ & 15 : 0; // coordinate in chunk
|
||||
+ int maxZ = currChunkZ == maxChunkZ ? maxBlockZ & 15 : 16; // coordinate in chunk
|
||||
+
|
||||
+ for (int currChunkX = minChunkX; currChunkX <= maxChunkX; ++currChunkX) {
|
||||
+ int minX = currChunkX == minChunkX ? minBlockX & 15 : 0; // coordinate in chunk
|
||||
+ int maxX = currChunkX == maxChunkX ? maxBlockX & 15 : 16; // coordinate in chunk
|
||||
+
|
||||
+ net.minecraft.world.level.chunk.ChunkAccess chunk = this.level().getChunkIfLoadedImmediately(currChunkX, currChunkZ);
|
||||
+ if (chunk == null) {
|
||||
+ return false; // if we're touching an unloaded chunk then it's false
|
||||
+ }
|
||||
+
|
||||
+ net.minecraft.world.level.chunk.LevelChunkSection[] sections = chunk.getSections();
|
||||
+
|
||||
+ for (int currY = minYIterate; currY < maxYIterate; ++currY) {
|
||||
+ net.minecraft.world.level.chunk.LevelChunkSection section = sections[(currY >> 4) - minSection];
|
||||
+
|
||||
+ if (section == null || section.hasOnlyAir() || section.fluidStateCount == 0) { // if no fluids, nothing in this section
|
||||
+ // empty
|
||||
+ // skip to next section
|
||||
+ currY = (currY & ~(15)) + 15; // increment by 15: iterator loop increments by the extra one
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ net.minecraft.world.level.chunk.PalettedContainer<BlockState> blocks = section.states;
|
||||
+
|
||||
+ for (int currZ = minZ; currZ < maxZ; ++currZ) {
|
||||
+ for (int currX = minX; currX < maxX; ++currX) {
|
||||
+ FluidState fluid = blocks.get(currX & 15, currY & 15, currZ & 15).getFluidState();
|
||||
|
||||
if (fluid.is(tag)) {
|
||||
- double d2 = (double) ((float) i2 + fluid.getHeight(this.level(), blockposition_mutableblockposition));
|
||||
+ blockposition_mutableblockposition.set((currChunkX << 4) + currX, currY, (currChunkZ << 4) + currZ);
|
||||
+ double d2 = (double) ((float) currY + fluid.getHeight(this.level(), blockposition_mutableblockposition));
|
||||
|
||||
if (d2 >= axisalignedbb.minY) {
|
||||
flag1 = true;
|
||||
@@ -5178,9 +5227,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
// CraftBukkit end
|
||||
}
|
||||
}
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
}
|
||||
}
|
||||
+ // Pufferfish end
|
||||
|
||||
if (vec3d.length() > 0.0D) {
|
||||
if (k1 > 0) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
index f0de72afad4bb571153436399386a6a8a70582a6..45b7527341fcb6d24f35318cedb522646b5ee1c2 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
@@ -25,6 +25,7 @@ public class LevelChunkSection {
|
||||
public final PalettedContainer<BlockState> states;
|
||||
// CraftBukkit start - read/write
|
||||
private PalettedContainer<Holder<Biome>> biomes;
|
||||
+ public short fluidStateCount; // Pufferfish
|
||||
public final com.destroystokyo.paper.util.maplist.IBlockDataList tickingList = new com.destroystokyo.paper.util.maplist.IBlockDataList(); // Paper
|
||||
// Paper start - optimise collisions
|
||||
private int specialCollidingBlocks;
|
||||
@@ -102,6 +103,7 @@ public class LevelChunkSection {
|
||||
|
||||
if (!fluid.isEmpty()) {
|
||||
--this.tickingFluidCount;
|
||||
+ --this.fluidStateCount; // Pufferfish
|
||||
}
|
||||
|
||||
if (!state.isAir()) {
|
||||
@@ -116,6 +118,7 @@ public class LevelChunkSection {
|
||||
|
||||
if (!fluid1.isEmpty()) {
|
||||
++this.tickingFluidCount;
|
||||
+ ++this.fluidStateCount; // Pufferfish
|
||||
}
|
||||
|
||||
this.updateBlockCallback(x, y, z, iblockdata1, state); // Paper - optimise collisions
|
||||
@@ -161,6 +164,7 @@ public class LevelChunkSection {
|
||||
if (fluid.isRandomlyTicking()) {
|
||||
this.tickingFluidCount = (short) (this.tickingFluidCount + 1);
|
||||
}
|
||||
+ this.fluidStateCount++; // Pufferfish
|
||||
}
|
||||
|
||||
// Paper start - optimise collisions
|
||||
@@ -0,0 +1,44 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 1 Jan 2025 12:18:18 +0800
|
||||
Subject: [PATCH] Set old pos before moving entity by piston
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaPistonIssueFixConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaPistonIssueFixConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..6edfb1d36a88d319151d28ba14873269736f84b6
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaPistonIssueFixConfig.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 FoliaPistonIssueFixConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.FIXES;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "folia.fix_piston_moving_issue";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
|
||||
index c3a04ef842630b3df447dea48b84bccde0c89e83..9545f46c22cb7dcdf2412f9a741dc51be40faace 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
|
||||
@@ -195,6 +195,7 @@ public class PistonMovingBlockEntity extends BlockEntity {
|
||||
|
||||
private static void moveEntityByPiston(Direction direction, Entity entity, double distance, Direction movementDirection) {
|
||||
NOCLIP.set(direction);
|
||||
+ if (me.earthme.luminol.config.modules.fixes.FoliaPistonIssueFixConfig.enabled) entity.setOldPosAndRot(); // Luminol- Try fixing folia issue #311
|
||||
entity.move(
|
||||
MoverType.PISTON,
|
||||
new Vec3(
|
||||
@@ -0,0 +1,22 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sat, 11 Jan 2025 18:41:11 +0800
|
||||
Subject: [PATCH] Merge Paper #11945 for temporary hooper behavior fix
|
||||
|
||||
A hopper optimization fix on Paper's pr : https://github.com/PaperMC/Paper/pull/11945
|
||||
|
||||
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 44aae845da6cd34fc00e0c71795d6f610679bd4b..df56451927d049c1baa5cd43ed0c25a3837474ec 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
|
||||
@@ -764,8 +764,8 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
} else if (HopperBlockEntity.canMergeItems(itemstack1, stack)) {
|
||||
int j = Math.min(stack.getMaxStackSize(), to.getMaxStackSize()) - itemstack1.getCount(); // Paper - Make hoppers respect inventory max stack size
|
||||
int k = Math.min(stack.getCount(), j);
|
||||
-
|
||||
- stack.shrink(k);
|
||||
+ stack = stack.copy(true); // Paper - Perf: Optimize Hoppers
|
||||
+ stack.shrink(k); // Paper - Perf: Optimize Hoppers
|
||||
itemstack1.grow(k);
|
||||
flag = k > 0;
|
||||
}
|
||||
@@ -5,14 +5,14 @@ Subject: [PATCH] Kaiiju Don't pathfind outside region
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java b/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
||||
index 1ab77f3518d1df30f66ae44d7d4fa69e5b32d93a..98bf17441da3169d49de55fe89d79ebe250a2b7e 100644
|
||||
index 2a7a26ca447cc78f24e61a2bf557411c31eb16b2..361e79e13dacc765283b2736324f365400e9860e 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
||||
@@ -107,7 +107,9 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
||||
@@ -120,7 +120,9 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
||||
|
||||
private boolean tryComputePath(Mob entity, WalkTarget walkTarget, long time) {
|
||||
BlockPos blockPos = walkTarget.getTarget().currentBlockPosition();
|
||||
+ if (io.papermc.paper.util.TickThread.isTickThreadFor((ServerLevel) entity.level(), blockPos)) // Kaiiju - Don't pathfind outside region
|
||||
+ if (ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor((ServerLevel) entity.level(), blockPos)) // Kaiiju - Don't pathfind outside region
|
||||
this.path = entity.getNavigation().createPath(blockPos, 0);
|
||||
+ else this.path = null; // Kaiiju - Don't pathfind outside region
|
||||
this.speedModifier = walkTarget.getSpeedModifier();
|
||||
@@ -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
|
||||
@@ -0,0 +1,66 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sat, 30 Nov 2024 11:48:36 +0800
|
||||
Subject: [PATCH] Kaiiju Vanilla end portal teleportation
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 4fdbdd1c5c937c20026afe555fa1c8371b4eaa16..64e081f993c2c844f83af227380b8a957eaabad4 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -114,6 +114,7 @@ import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.border.WorldBorder;
|
||||
+import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.entity.EntityAccess;
|
||||
import net.minecraft.world.level.entity.EntityInLevelCallback;
|
||||
import net.minecraft.world.level.gameevent.DynamicGameEventListener;
|
||||
@@ -4458,13 +4459,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
targetPos, 16, // load 16 blocks to be safe from block physics
|
||||
ca.spottedleaf.concurrentutil.util.Priority.HIGH,
|
||||
(chunks) -> {
|
||||
- net.minecraft.world.level.levelgen.feature.EndPlatformFeature.createEndPlatform(destination, targetPos.below(), true, null);
|
||||
+ //net.minecraft.world.level.levelgen.feature.EndPlatformFeature.createEndPlatform(destination, targetPos.below(), true, null); // Kaiiju - Vanilla end teleportation - moved down
|
||||
|
||||
+ // Kaiiju start - Vanilla end teleportation
|
||||
+ Vec3 finalPos;
|
||||
+ if (this instanceof Player) finalPos = Vec3.atBottomCenterOf(targetPos.below());
|
||||
+ else finalPos = Vec3.atBottomCenterOf(targetPos);
|
||||
+ // Kaiiju end
|
||||
// the portal obsidian is placed at targetPos.y - 2, so if we want to place the entity
|
||||
// on the obsidian, we need to spawn at targetPos.y - 1
|
||||
portalInfoCompletable.complete(
|
||||
new net.minecraft.world.level.portal.TeleportTransition(
|
||||
- destination, Vec3.atBottomCenterOf(targetPos.below()), Vec3.ZERO, 90.0f, 0.0f,
|
||||
+ destination, finalPos, this.getDeltaMovement(), 90.0f, 0.0f, // Kaiiju - Vanilla end teleportation
|
||||
TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET),
|
||||
org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL
|
||||
)
|
||||
@@ -4660,6 +4666,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
if (!this.canPortalAsync(destination, takePassengers)) {
|
||||
return false;
|
||||
}
|
||||
+ // Kaiiju start - sync end platform spawning & entity teleportation
|
||||
+ final java.util.function.Consumer<Entity> tpComplete = type == PortalType.END && destination.getTypeKey() == LevelStem.END ?
|
||||
+ e -> net.minecraft.world.level.levelgen.feature.EndPlatformFeature.createEndPlatform(destination, ServerLevel.END_SPAWN_POINT.below(), true, null) : teleportComplete;
|
||||
+ // Kaiiju end
|
||||
|
||||
Vec3 initialPosition = this.position();
|
||||
ChunkPos initialPositionChunk = new ChunkPos(
|
||||
@@ -4724,9 +4734,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
info.postTeleportTransition().onTransition(teleported);
|
||||
}
|
||||
|
||||
- if (teleportComplete != null) {
|
||||
+ // Kaiiju start - vanilla end teleportation
|
||||
+ /*if (teleportComplete != null) {
|
||||
teleportComplete.accept(teleported);
|
||||
+ }*/
|
||||
+ if (tpComplete != null){
|
||||
+ tpComplete.accept(teleported);
|
||||
}
|
||||
+ // Kaiiju end
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -1,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();
|
||||
330
patches/server/0030-Kaiiju-Entity-tick-and-removal-limiter.patch
Normal file
330
patches/server/0030-Kaiiju-Entity-tick-and-removal-limiter.patch
Normal file
@@ -0,0 +1,330 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 4 Dec 2024 23:39:18 +0800
|
||||
Subject: [PATCH] Kaiiju Entity tick and removal limiter
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 8f23bf19618382ccf5fd10a0b17b57cd445dea58..4b79f96103c98896332113ffe5f0e22cf08ffdd1 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -27,6 +27,7 @@ abstract class MockitoAgentProvider : CommandLineArgumentProvider {
|
||||
dependencies {
|
||||
implementation(project(":luminol-api")) // Folia // Luminol
|
||||
implementation("com.electronwill.night-config:toml:3.6.6") // Luminol - Night config
|
||||
+ implementation("io.github.classgraph:classgraph:4.8.158") // Kaiiju - Entity throttling & Removal
|
||||
implementation("ca.spottedleaf:concurrentutil:0.0.2") // Paper - Add ConcurrentUtil dependency
|
||||
// Paper start
|
||||
implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityLimits.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityLimits.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..40e80fc685a42bbaeea3e6e64754121178cc7d22
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityLimits.java
|
||||
@@ -0,0 +1,141 @@
|
||||
+package dev.kaiijumc.kaiiju;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.io.IOException;
|
||||
+import java.util.Map;
|
||||
+import java.util.HashMap;
|
||||
+import java.util.logging.Level;
|
||||
+
|
||||
+import com.google.common.base.Throwables;
|
||||
+import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
+import io.github.classgraph.ClassGraph;
|
||||
+import io.github.classgraph.ClassInfo;
|
||||
+import io.github.classgraph.ScanResult;
|
||||
+import org.slf4j.Logger;
|
||||
+
|
||||
+import com.mojang.logging.LogUtils;
|
||||
+import net.minecraft.world.entity.Entity;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.configuration.InvalidConfigurationException;
|
||||
+import org.bukkit.configuration.file.YamlConfiguration;
|
||||
+
|
||||
+@SuppressWarnings("unused")
|
||||
+public class KaiijuEntityLimits {
|
||||
+ private static final Logger LOGGER = LogUtils.getLogger();
|
||||
+ private static final File CONFIG_FOLDER = new File("luminol_config");
|
||||
+
|
||||
+ protected static final String HEADER =
|
||||
+ "Per region entity limits for Kaiiju.\n"
|
||||
+ + "If there are more of particular entity type in a region than limit, entity ticking will be throttled.\n"
|
||||
+ + "Example: for Wither limit 100 & 300 Withers in a region -> 100 Withers tick every tick & every Wither ticks every 3 ticks.\n"
|
||||
+ + "Available entities: GlowSquid, Ambient, Bat, Animal, Bee, Cat, Chicken, Cod, Cow, Dolphin, Fish, FishSchool, Fox, Golem, IronGolem, "
|
||||
+ + "MushroomCow, Ocelot, Panda, Parrot, Perchable, Pig, PolarBear, PufferFish, Rabbit, Salmon, Sheep, Snowman, Squid, TropicalFish, Turtle, "
|
||||
+ + "WaterAnimal, Wolf, Allay, Axolotl, Camel, Frog, Tadpole, Goat, Horse, HorseAbstract, HorseChestedAbstract, HorseDonkey, HorseMule, "
|
||||
+ + "HorseSkeleton, HorseZombie, Llama, LlamaTrader, Sniffer, EnderCrystal, EnderDragon, Wither, ArmorStand, Hanging, ItemFrame, Leash, "
|
||||
+ + "Painting, GlowItemFrame, FallingBlock, Item, TNTPrimed, Blaze, CaveSpider, Creeper, Drowned, Enderman, Endermite, Evoker, Ghast, "
|
||||
+ + "GiantZombie, Guardian, GuardianElder, IllagerAbstract, IllagerIllusioner, IllagerWizard, MagmaCube, Monster, MonsterPatrolling, Phantom, "
|
||||
+ + "PigZombie, Pillager, Ravager, Shulker, Silverfish, Skeleton, SkeletonAbstract, SkeletonStray, SkeletonWither, Slime, Spider, Strider, Vex, "
|
||||
+ + "Vindicator, Witch, Zoglin, Zombie, ZombieHusk, ZombieVillager, Hoglin, Piglin, PiglinAbstract, PiglinBrute, Warden, Villager, "
|
||||
+ + "VillagerTrader, Arrow, DragonFireball, Egg, EnderPearl, EnderSignal, EvokerFangs, Fireball, FireballFireball, Fireworks, FishingHook, "
|
||||
+ + "LargeFireball, LlamaSpit, Potion, Projectile, ProjectileThrowable, ShulkerBullet, SmallFireball, Snowball, SpectralArrow, ThrownExpBottle, "
|
||||
+ + "ThrownTrident, TippedArrow, WitherSkull, Raider, ChestBoat, Boat, MinecartAbstract, MinecartChest, MinecartCommandBlock, MinecartContainer, "
|
||||
+ + "MinecartFurnace, MinecartHopper, MinecartMobSpawner, MinecartRideable, MinecartTNT\n";
|
||||
+ protected static final File ENTITY_LIMITS_FILE = new File(CONFIG_FOLDER, "kaiiju_entity_limits.yml");
|
||||
+ public static YamlConfiguration entityLimitsConfig;
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ protected static Map<Class<? extends Entity>, EntityLimit> entityLimits;
|
||||
+
|
||||
+ static final String ENTITY_PREFIX = "Entity";
|
||||
+
|
||||
+ public static void init() {
|
||||
+ init(true);
|
||||
+ }
|
||||
+
|
||||
+ private static void init(boolean setup) {
|
||||
+ entityLimitsConfig = new YamlConfiguration();
|
||||
+
|
||||
+ if (ENTITY_LIMITS_FILE.exists()) {
|
||||
+ try {
|
||||
+ entityLimitsConfig.load(ENTITY_LIMITS_FILE);
|
||||
+ } catch (InvalidConfigurationException ex) {
|
||||
+ Bukkit.getLogger().log(Level.SEVERE, "Could not load kaiiju_entity_limits.yml, please correct your syntax errors", ex);
|
||||
+ throw Throwables.propagate(ex);
|
||||
+ } catch (IOException ignore) {}
|
||||
+ } else {
|
||||
+ if (setup) {
|
||||
+ entityLimitsConfig.options().header(HEADER);
|
||||
+ entityLimitsConfig.options().copyDefaults(true);
|
||||
+ entityLimitsConfig.set("enabled", enabled);
|
||||
+ entityLimitsConfig.set("Axolotl.limit", 1000);
|
||||
+ entityLimitsConfig.set("Axolotl.removal", 2000);
|
||||
+ try {
|
||||
+ entityLimitsConfig.save(ENTITY_LIMITS_FILE);
|
||||
+ } catch (IOException ex) {
|
||||
+ Bukkit.getLogger().log(Level.SEVERE, "Could not save " + ENTITY_LIMITS_FILE, ex);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ enabled = entityLimitsConfig.getBoolean("enabled");
|
||||
+
|
||||
+ entityLimits = new Object2ObjectOpenHashMap<>();
|
||||
+ try (ScanResult scanResult = new ClassGraph().enableAllInfo().acceptPackages("net.minecraft.world.entity").scan()) {
|
||||
+ Map<String, ClassInfo> entityClasses = new HashMap<>();
|
||||
+ for (ClassInfo classInfo : scanResult.getAllClasses()) {
|
||||
+ Class<?> entityClass = Class.forName(classInfo.getName());
|
||||
+ if (Entity.class.isAssignableFrom(entityClass)) {
|
||||
+ String entityName = extractEntityName(entityClass.getSimpleName());
|
||||
+ entityClasses.put(entityName, classInfo);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ for (String key : entityLimitsConfig.getKeys(false)) {
|
||||
+ if (key.equals("enabled")) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if (!entityClasses.containsKey(key)) {
|
||||
+ LOGGER.error("Unknown entity '" + key + "' in kaiiju-entity-limits.yml, skipping");
|
||||
+ continue;
|
||||
+ }
|
||||
+ int limit = entityLimitsConfig.getInt(key + ".limit");
|
||||
+ int removal = entityLimitsConfig.getInt(key + ".removal");
|
||||
+
|
||||
+ if (limit < 1) {
|
||||
+ LOGGER.error(key + " has a limit less than the minimum of 1, ignoring");
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (removal <= limit && removal != -1) {
|
||||
+ LOGGER.error(key + " has a removal limit that is less than or equal to its limit, setting removal to limit * 10");
|
||||
+ removal = limit * 10;
|
||||
+ }
|
||||
+
|
||||
+ entityLimits.put((Class<? extends Entity>) Class.forName(entityClasses.get(key).getName()), new EntityLimit(limit, removal));
|
||||
+ }
|
||||
+ } catch (ClassNotFoundException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static EntityLimit getEntityLimit(Entity entity) {
|
||||
+ return entityLimits.get(entity.getClass());
|
||||
+ }
|
||||
+
|
||||
+ private static String extractEntityName(String input) {
|
||||
+ int prefixLength = ENTITY_PREFIX.length();
|
||||
+
|
||||
+ if (input.length() <= prefixLength || !input.startsWith(ENTITY_PREFIX)) {
|
||||
+ return input;
|
||||
+ } else {
|
||||
+ return input.substring(prefixLength);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public record EntityLimit(int limit, int removal) {
|
||||
+ @Override
|
||||
+ public String toString() {
|
||||
+ return "EntityLimit{limit=" + limit + ", removal=" + removal + "}";
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityThrottler.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityThrottler.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..eb690efacf083e4ff3e321578b12c534e6a40196
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityThrottler.java
|
||||
@@ -0,0 +1,84 @@
|
||||
+package dev.kaiijumc.kaiiju;
|
||||
+
|
||||
+import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
+import net.minecraft.world.entity.Entity;
|
||||
+import io.papermc.paper.threadedregions.RegionizedWorldData;
|
||||
+
|
||||
+public class KaiijuEntityThrottler {
|
||||
+ private static class TickInfo {
|
||||
+ int currentTick;
|
||||
+ int continueFrom;
|
||||
+ int toTick;
|
||||
+ int toRemove;
|
||||
+ }
|
||||
+
|
||||
+ public static class EntityThrottlerReturn {
|
||||
+ public boolean skip;
|
||||
+ public boolean remove;
|
||||
+ }
|
||||
+
|
||||
+ private final Object2ObjectOpenHashMap<KaiijuEntityLimits.EntityLimit, TickInfo> entityLimitTickInfoMap = new Object2ObjectOpenHashMap<>();
|
||||
+
|
||||
+ public void tickLimiterStart() {
|
||||
+ for (TickInfo tickInfo : entityLimitTickInfoMap.values()) {
|
||||
+ tickInfo.currentTick = 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public EntityThrottlerReturn tickLimiterShouldSkip(Entity entity) {
|
||||
+ EntityThrottlerReturn retVal = new EntityThrottlerReturn();
|
||||
+ if (entity.isRemoved()) return retVal;
|
||||
+ KaiijuEntityLimits.EntityLimit entityLimit = KaiijuEntityLimits.getEntityLimit(entity);
|
||||
+
|
||||
+ if (entityLimit != null) {
|
||||
+ TickInfo tickInfo = entityLimitTickInfoMap.computeIfAbsent(entityLimit, el -> {
|
||||
+ TickInfo newTickInfo = new TickInfo();
|
||||
+ newTickInfo.toTick = entityLimit.limit();
|
||||
+ return newTickInfo;
|
||||
+ });
|
||||
+
|
||||
+ tickInfo.currentTick++;
|
||||
+ if (tickInfo.currentTick <= tickInfo.toRemove && entityLimit.removal() > 0) {
|
||||
+ retVal.skip = false;
|
||||
+ retVal.remove = true;
|
||||
+ return retVal;
|
||||
+ }
|
||||
+
|
||||
+ if (tickInfo.currentTick < tickInfo.continueFrom) {
|
||||
+ retVal.skip = true;
|
||||
+ return retVal;
|
||||
+ }
|
||||
+ if (tickInfo.currentTick - tickInfo.continueFrom < tickInfo.toTick) {
|
||||
+ retVal.skip = false;
|
||||
+ return retVal;
|
||||
+ }
|
||||
+ retVal.skip = true;
|
||||
+ return retVal;
|
||||
+ } else {
|
||||
+ retVal.skip = false;
|
||||
+ return retVal;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void tickLimiterFinish(RegionizedWorldData regionizedWorldData) {
|
||||
+ for (var entry : entityLimitTickInfoMap.entrySet()) {
|
||||
+ KaiijuEntityLimits.EntityLimit entityLimit = entry.getKey();
|
||||
+ TickInfo tickInfo = entry.getValue();
|
||||
+
|
||||
+ int additionals = 0;
|
||||
+ int nextContinueFrom = tickInfo.continueFrom + tickInfo.toTick;
|
||||
+ if (nextContinueFrom >= tickInfo.currentTick) {
|
||||
+ additionals = entityLimit.limit() - (tickInfo.currentTick - tickInfo.continueFrom);
|
||||
+ nextContinueFrom = 0;
|
||||
+ }
|
||||
+ tickInfo.continueFrom = nextContinueFrom;
|
||||
+ tickInfo.toTick = entityLimit.limit() + additionals;
|
||||
+
|
||||
+ if (tickInfo.toRemove == 0 && tickInfo.currentTick > entityLimit.removal()) {
|
||||
+ tickInfo.toRemove = tickInfo.currentTick - entityLimit.removal();
|
||||
+ } else if (tickInfo.toRemove != 0) {
|
||||
+ tickInfo.toRemove = 0;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/RegionizedWorldData.java b/src/main/java/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
index 1b741d4bccfd45beeec43300f44770516c0d850e..3c37ad27488486f9bb0f972369ccaee2284df673 100644
|
||||
--- a/src/main/java/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
+++ b/src/main/java/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
@@ -354,6 +354,7 @@ public final class RegionizedWorldData {
|
||||
private final IteratorSafeOrderedReferenceSet<Mob> navigatingMobs = new IteratorSafeOrderedReferenceSet<>();
|
||||
public final ReferenceList<Entity> trackerEntities = new ReferenceList<>(EMPTY_ENTITY_ARRAY); // Moonrise - entity tracker
|
||||
public final ReferenceList<Entity> trackerUnloadedEntities = new ReferenceList<>(EMPTY_ENTITY_ARRAY); // Moonrise - entity tracker
|
||||
+ public final dev.kaiijumc.kaiiju.KaiijuEntityThrottler entityThrottler = new dev.kaiijumc.kaiiju.KaiijuEntityThrottler(); // Kaiiju
|
||||
|
||||
// block ticking
|
||||
private final ObjectLinkedOpenHashSet<BlockEventData> blockEvents = new ObjectLinkedOpenHashSet<>();
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/KaiijuEntityLimiterConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/KaiijuEntityLimiterConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..038d9ab60cfac7e40e7c0c0644fa0a0d035eac01
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/KaiijuEntityLimiterConfig.java
|
||||
@@ -0,0 +1,23 @@
|
||||
+package me.earthme.luminol.config.modules.misc;
|
||||
+
|
||||
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import dev.kaiijumc.kaiiju.KaiijuEntityLimits;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class KaiijuEntityLimiterConfig implements IConfigModule {
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "kaiiju_entity_limiter";
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onLoaded(CommentedFileConfig configInstance) {
|
||||
+ KaiijuEntityLimits.init();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 07037eb601f9dcae2cad5f3e3d5f9a0ac142b68a..5503d506c595296ecad09a3ce4497a365f216af5 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -811,6 +811,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
}
|
||||
|
||||
profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ACTIVATE_ENTITIES); try { // Folia - profiler
|
||||
+ if (dev.kaiijumc.kaiiju.KaiijuEntityLimits.enabled) regionizedWorldData.entityThrottler.tickLimiterStart(); // Kaiiju
|
||||
org.spigotmc.ActivationRange.activateEntities(this); // Spigot
|
||||
} finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ACTIVATE_ENTITIES); } // Folia - profiler
|
||||
profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_TICK); try { // Folia - profiler
|
||||
@@ -832,6 +833,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
entity.stopRiding();
|
||||
}
|
||||
|
||||
+ // Kaiiju start
|
||||
+ if (dev.kaiijumc.kaiiju.KaiijuEntityLimits.enabled) {
|
||||
+ dev.kaiijumc.kaiiju.KaiijuEntityThrottler.EntityThrottlerReturn throttle = regionizedWorldData.entityThrottler.tickLimiterShouldSkip(entity);
|
||||
+ if (throttle.remove && !entity.hasCustomName()) entity.remove(Entity.RemovalReason.DISCARDED);
|
||||
+ if (throttle.skip) return;
|
||||
+ }
|
||||
+ // Kaiiju end
|
||||
gameprofilerfiller.push("tick");
|
||||
this.guardEntityTick(this::tickNonPassenger, entity);
|
||||
gameprofilerfiller.pop();
|
||||
@@ -839,6 +847,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
}
|
||||
}
|
||||
});
|
||||
+ if (dev.kaiijumc.kaiiju.KaiijuEntityLimits.enabled) regionizedWorldData.entityThrottler.tickLimiterFinish(regionizedWorldData); // Kaiiju
|
||||
} finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_TICK); } // Folia - profiler
|
||||
gameprofilerfiller.pop();
|
||||
profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.TILE_ENTITY); try { // Folia - profiler
|
||||
@@ -1,418 +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:44:23 +0800
|
||||
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;
|
||||
|
||||
+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();
|
||||
private static final File PARENT_FOLDER = new File("luminol_config");
|
||||
@@ -48,6 +51,12 @@ public class LuminolConfig {
|
||||
public static boolean enableSuffocationOptimization = true;
|
||||
public static int maxProjectileLoadsPerTick;
|
||||
public static int maxProjectileLoadsPerProjectile;
|
||||
+ public static boolean dearEnabled;
|
||||
+ public static int startDistance;
|
||||
+ public static int startDistanceSquared;
|
||||
+ public static int maximumActivationPrio;
|
||||
+ public static int activationDistanceMod;
|
||||
+
|
||||
|
||||
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.""");
|
||||
+
|
||||
+ 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 -> {
|
||||
+ entityType.dabEnabled = false;
|
||||
+ }, () -> MinecraftServer.LOGGER.warn("Unknown entity \"" + name + "\"")));
|
||||
+
|
||||
+ MAIN_CONFIG.setComment("optimizations.dab", "Optimizes entity brains when\n"+"they're far away from the player");
|
||||
+ }
|
||||
+
|
||||
public static void initValues(){
|
||||
serverModName = get("misc.server_mod_name",serverModName,"The servermod name will be sent to players,and you can see it in F3 or motd responses");
|
||||
fakeVanillaModeEnabled = get("misc.enable_fake_vanilla_mode",fakeVanillaModeEnabled,"Enable this to make the ping response of your server like a vanilla server");
|
||||
@@ -130,6 +166,7 @@ public class LuminolConfig {
|
||||
initEntityTTL();
|
||||
maxProjectileLoadsPerTick = get("optimizations.projectile.max-loads-per-tick", maxProjectileLoadsPerTick, "Controls how many chunks are allowed \nto be sync loaded by projectiles in a tick.");
|
||||
maxProjectileLoadsPerProjectile = get("optimizations.projectile.max-loads-per-projectile", maxProjectileLoadsPerProjectile, "Controls how many chunks a projectile \n can load in its lifetime before it gets \nautomatically removed.");
|
||||
+ initDAB();
|
||||
}
|
||||
|
||||
public static <T> T get(String key,T def){
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 561681deaf647277ecde64eed4cfbd9f38b5fed1..2ba86122ccb444908c35ea5cc1e245f5068a054a 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 {
|
||||
this.timings.entityTick.startTiming(); // Spigot
|
||||
profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_TICK); try { // Folia - profiler
|
||||
regionizedWorldData.forEachTickingEntity((entity) -> { // Folia - regionised ticking
|
||||
+ entity.activatedPriorityReset = false; // Pufferfish - DAB
|
||||
if (!entity.isRemoved()) {
|
||||
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
|
||||
--- 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
|
||||
+ public boolean activatedPriorityReset = false; // DAB
|
||||
+ public int activatedPriority = LuminolConfig.maximumActivationPrio; // golf score
|
||||
+ // Pufferfish end
|
||||
+
|
||||
public float getBukkitYaw() {
|
||||
return this.yRot;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
index 4d60ac50a1d3860f2a2e9265aef9507d790220a3..0867c85964952ec118ea7517cd5ef570be1ee982 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
|
||||
private final boolean canSpawnFarFromPlayer;
|
||||
private final int clientTrackingRange;
|
||||
private final int updateInterval;
|
||||
+ public boolean dabEnabled = false; // Pufferfish
|
||||
@Nullable
|
||||
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
|
||||
--- 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 {
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
super.inactiveTick();
|
||||
- if (this.goalSelector.inactiveTick()) {
|
||||
+ if (this.goalSelector.inactiveTick(this.activatedPriority, true)) { // Pufferfish - pass activated priroity
|
||||
this.goalSelector.tick();
|
||||
}
|
||||
- if (this.targetSelector.inactiveTick()) {
|
||||
+ if (this.targetSelector.inactiveTick(this.activatedPriority, true)) { // Pufferfish - pass activated priority
|
||||
this.targetSelector.tick();
|
||||
}
|
||||
}
|
||||
@@ -934,16 +934,20 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||
|
||||
if (i % 2 != 0 && this.tickCount > 1) {
|
||||
this.level().getProfiler().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");
|
||||
+ if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
||||
this.goalSelector.tickRunningGoals(false);
|
||||
this.level().getProfiler().pop();
|
||||
} else {
|
||||
this.level().getProfiler().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");
|
||||
+ if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
||||
this.goalSelector.tick();
|
||||
this.level().getProfiler().pop();
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
||||
index b738ee2d3801fadfd09313f05ae24593e56b0ec6..9306ab8d2b6eeb73f86d4d94c0065d461905d702 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
||||
@@ -11,6 +11,8 @@ import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
+
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -53,9 +55,12 @@ public class GoalSelector {
|
||||
}
|
||||
|
||||
// Paper start
|
||||
- public boolean inactiveTick() {
|
||||
+ public boolean inactiveTick(int tickRate, boolean inactive) { // Pufferfish start
|
||||
+ if (inactive && !LuminolConfig.dearEnabled) tickRate = 4; // reset to Paper's
|
||||
+ tickRate = Math.min(tickRate, this.newGoalRate);
|
||||
this.curRate++;
|
||||
- return this.curRate % this.newGoalRate == 0;
|
||||
+ return this.curRate % tickRate == 0;
|
||||
+ // 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
|
||||
--- 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
|
||||
return 0.4F;
|
||||
}
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep() {
|
||||
this.level().getProfiler().push("allayBrain");
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick((ServerLevel) this.level(), this);
|
||||
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
|
||||
--- 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
|
||||
return true;
|
||||
}
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep() {
|
||||
this.level().getProfiler().push("axolotlBrain");
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick((ServerLevel) this.level(), this);
|
||||
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
|
||||
--- 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;
|
||||
}
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep() {
|
||||
this.level().getProfiler().push("frogBrain");
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick((ServerLevel)this.level(), this);
|
||||
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
|
||||
--- 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 {
|
||||
return SoundEvents.TADPOLE_FLOP;
|
||||
}
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep() {
|
||||
this.level().getProfiler().push("tadpoleBrain");
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick((ServerLevel) this.level(), this);
|
||||
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
|
||||
--- 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 {
|
||||
return (Brain<Goat>) super.getBrain(); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep() {
|
||||
this.level().getProfiler().push("goatBrain");
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick((ServerLevel) this.level(), this);
|
||||
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
|
||||
--- 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
|
||||
}
|
||||
|
||||
+ private int behaviorTick; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep() {
|
||||
this.level().getProfiler().push("hoglinBrain");
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick((ServerLevel)this.level(), this);
|
||||
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
|
||||
--- 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
|
||||
return !this.cannotHunt;
|
||||
}
|
||||
|
||||
+ private int behaviorTick; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep() {
|
||||
this.level().getProfiler().push("piglinBrain");
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick((ServerLevel) this.level(), this);
|
||||
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
|
||||
--- 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 {
|
||||
|
||||
}
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep() {
|
||||
ServerLevel worldserver = (ServerLevel) this.level();
|
||||
|
||||
worldserver.getProfiler().push("wardenBrain");
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick(worldserver, this);
|
||||
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
|
||||
--- 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
|
||||
return holder.is(PoiTypes.MEETING);
|
||||
});
|
||||
|
||||
+ public long nextGolemPanic = -1; // Pufferfish
|
||||
+
|
||||
public Villager(EntityType<? extends Villager> entityType, Level world) {
|
||||
this(entityType, world, VillagerType.PLAINS);
|
||||
}
|
||||
@@ -245,6 +247,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
}
|
||||
// Spigot End
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@Override
|
||||
@Deprecated // Paper
|
||||
protected void customServerAiStep() {
|
||||
@@ -254,7 +257,11 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
protected void customServerAiStep(final boolean inactive) {
|
||||
// Paper end
|
||||
this.level().getProfiler().push("villagerBrain");
|
||||
- if (!inactive) this.getBrain().tick((ServerLevel) this.level(), this); // Paper
|
||||
+ // Pufferfish start
|
||||
+ if (!inactive && this.behaviorTick++ % this.activatedPriority == 0) {
|
||||
+ this.getBrain().tick((ServerLevel) this.level(), this); // Paper
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
this.level().getProfiler().pop();
|
||||
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
|
||||
--- 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;
|
||||
import net.minecraft.world.entity.schedule.Activity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
+// Pufferfish start
|
||||
+import net.minecraft.world.phys.Vec3;
|
||||
+import java.util.List;
|
||||
+// Pufferfish end
|
||||
|
||||
public class ActivationRange
|
||||
{
|
||||
@@ -230,6 +235,25 @@ public class ActivationRange
|
||||
}
|
||||
// Paper end - configurable marker ticking
|
||||
ActivationRange.activateEntity(entity);
|
||||
+
|
||||
+ // Pufferfish start
|
||||
+ if (LuminolConfig.dearEnabled && entity.getType().dabEnabled) {
|
||||
+ if (!entity.activatedPriorityReset) {
|
||||
+ entity.activatedPriorityReset = true;
|
||||
+ entity.activatedPriority = LuminolConfig.maximumActivationPrio;
|
||||
+ }
|
||||
+ Vec3 playerVec = player.position();
|
||||
+ Vec3 entityVec = entity.position();
|
||||
+ double diffX = playerVec.x - entityVec.x, diffY = playerVec.y - entityVec.y, diffZ = playerVec.z - entityVec.z;
|
||||
+ int squaredDistance = (int) (diffX * diffX + diffY * diffY + diffZ * diffZ);
|
||||
+ entity.activatedPriority = squaredDistance > LuminolConfig.startDistanceSquared ?
|
||||
+ Math.max(1, Math.min(squaredDistance >> LuminolConfig.activationDistanceMod, entity.activatedPriority)) :
|
||||
+ 1;
|
||||
+ } else {
|
||||
+ entity.activatedPriority = 1;
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
+
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
@@ -246,12 +270,12 @@ public class ActivationRange
|
||||
if ( io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick() > entity.activatedTick ) // Folia - threaded regions
|
||||
{
|
||||
if ( entity.defaultActivationState )
|
||||
- {
|
||||
+ { // Pufferfish - diff on change
|
||||
entity.activatedTick = io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick(); // Folia - threaded regions
|
||||
return;
|
||||
}
|
||||
if ( entity.activationType.boundingBox.intersects( entity.getBoundingBox() ) )
|
||||
- {
|
||||
+ { // Pufferfish - diff on change
|
||||
entity.activatedTick = io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick(); // Folia - threaded regions
|
||||
}
|
||||
}
|
||||
53
patches/server/0031-Petal-Reduce-sensor-work.patch
Normal file
53
patches/server/0031-Petal-Reduce-sensor-work.patch
Normal file
@@ -0,0 +1,53 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sat, 30 Nov 2024 11:50:09 +0800
|
||||
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 e48728723e9f765099fc1cea8e6a2baa48d7fc75..6b66d73daa0145829cd964403e7958335ef0aa9a 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -930,12 +930,12 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
return;
|
||||
}
|
||||
// Paper end - Allow nerfed mobs to jump and float
|
||||
+ int i = this.tickCount + this.getId(); //Luminol - Petal - Move up
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
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");
|
||||
@@ -1,98 +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:21:11 +0800
|
||||
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/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 56efbcc29adca0239ef09a269f0899a3a6e2801b..54daa1744c89e98136d0f594a35119d5fd3d6bc8 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;
|
||||
}
|
||||
|
||||
+ // Gale start - don't load chunks to activate climbing entities
|
||||
+ public @Nullable BlockState getFeetBlockStateIfLoaded() {
|
||||
+ if (this.feetBlockState == null) {
|
||||
+ this.feetBlockState = this.level.getBlockStateIfLoaded(this.blockPosition());
|
||||
+ }
|
||||
+
|
||||
+ return this.feetBlockState;
|
||||
+ }
|
||||
+ // Gale end - don't load chunks to activate climbing entities
|
||||
+
|
||||
public ChunkPos chunkPosition() {
|
||||
return this.chunkPosition;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index f13d26b280f095d006ffccb36af66bb7487cb8da..ecbacbed29af51d949122b21c3ae9fc95885c6d8 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 {
|
||||
|
||||
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);
|
||||
+ if (onClimbableIfLoaded != null) {
|
||||
+ this.cachedOnClimable = onClimbableIfLoaded;
|
||||
+ this.lastClimbingPosition = this.blockPosition();
|
||||
+ } else {
|
||||
+ this.cachedOnClimable = false;
|
||||
+ this.lastClimbingPosition = null;
|
||||
+ }
|
||||
+ // Gale end - don't load chunks to activate climbing entities
|
||||
}
|
||||
return this.cachedOnClimable;
|
||||
}
|
||||
// Pufferfish end
|
||||
|
||||
public boolean onClimbable() {
|
||||
+ // Gale start - don't load chunks to activate climbing entities
|
||||
+ return onClimbable(true);
|
||||
+ }
|
||||
+
|
||||
+ public Boolean onClimbable(boolean loadChunk) {
|
||||
+ // Gale end - don't load chunks to activate climbing entities
|
||||
if (this.isSpectator()) {
|
||||
return false;
|
||||
} else {
|
||||
BlockPos blockposition = this.blockPosition();
|
||||
- BlockState iblockdata = this.getFeetBlockState();
|
||||
+ // Gale start - don't load chunks to activate climbing entities
|
||||
+ BlockState iblockdata;
|
||||
+ if (loadChunk) {
|
||||
+ iblockdata = this.getFeetBlockState();
|
||||
+ } else {
|
||||
+ iblockdata = this.getFeetBlockStateIfLoaded();
|
||||
+ if (iblockdata == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ }
|
||||
+ // Gale end - don't load chunks to activate climbing entities
|
||||
|
||||
if (iblockdata.is(BlockTags.CLIMBABLE)) {
|
||||
this.lastClimbablePos = Optional.of(blockposition);
|
||||
@@ -1,35 +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 <wangxyper@163.com>
|
||||
Date: Sat, 30 Nov 2024 11:52:43 +0800
|
||||
Subject: [PATCH] Pufferfish Cache climbing check for activation
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index cb32a3851a315f1f1b4fb6d26fdffbcb471bfc06..3c9ec0f5fef49b0abc42382551de11ab942b3b20 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 {
|
||||
public double yo;
|
||||
public double zo;
|
||||
private Vec3 position;
|
||||
- private BlockPos blockPosition;
|
||||
+ public BlockPos blockPosition; // Pufferfish - private->public
|
||||
private ChunkPos chunkPosition;
|
||||
private Vec3 deltaMovement;
|
||||
private float yRot;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 82996d0c2891871bd6ef9ff81aef123add08ebda..51dee7adc0dc534fac66bf3e8709865157dd763b 100644
|
||||
index 73af15d18180b4df3fa0614b323f2397f5543db5..dcdc5ca699832b3c26b33a27f684a4c7dea103b9 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 {
|
||||
@@ -2154,6 +2154,20 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
return this.lastClimbablePos;
|
||||
}
|
||||
|
||||
@@ -51,15 +30,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 f2f5eb1a443ac411539e1c87eec60e76682b82fa..cbe785f5fab22630e8a80519664791e2ac621b9f 100644
|
||||
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
||||
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
@@ -305,7 +305,7 @@ public class ActivationRange
|
||||
@@ -304,7 +304,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
|
||||
}
|
||||
@@ -1,25 +1,25 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16:07:56 +0800
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sat, 30 Nov 2024 11:53:29 +0800
|
||||
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 2a394381a4ad46359359ba402b65c62b331480b4..4e4dab5bc202f6f421dcff98f0e36e8e70378b49 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 {
|
||||
@@ -306,11 +306,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);
|
||||
|
||||
- while (blockposition_mutableblockposition.getY() > this.level().getMinBuildHeight() && !this.level().getBlockState(blockposition_mutableblockposition).blocksMotion()) {
|
||||
- while (blockposition_mutableblockposition.getY() > this.level().getMinY() && !this.level().getBlockState(blockposition_mutableblockposition).blocksMotion()) {
|
||||
+ // Pufferfish start - single chunk lookup
|
||||
+ net.minecraft.world.level.chunk.LevelChunk chunk = this.level().getChunkIfLoaded(blockposition_mutableblockposition);
|
||||
+ if (chunk == null) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
+ while (blockposition_mutableblockposition.getY() > this.level().getMinBuildHeight() && !chunk.getBlockState(blockposition_mutableblockposition).blocksMotion()) { // Pufferfish
|
||||
+ while (blockposition_mutableblockposition.getY() > this.level().getMinY() && !chunk.getBlockState(blockposition_mutableblockposition).blocksMotion()) { // Pufferfish
|
||||
blockposition_mutableblockposition.move(Direction.DOWN);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -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 <wangxyper@163.com>
|
||||
Date: Sat, 30 Nov 2024 11:54:17 +0800
|
||||
Subject: [PATCH] Pufferfish Fix Paper#6045, block goal shouldn't load chunks
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
|
||||
index 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,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();
|
||||
@@ -0,0 +1,79 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sat, 30 Nov 2024 11:54:58 +0800
|
||||
Subject: [PATCH] Pufferfish Reduce projectile chunk loading
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/ProjectileChunkReduceConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/ProjectileChunkReduceConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..12683ec5a5102e45b6171fea0b833ba57e5e188c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/ProjectileChunkReduceConfig.java
|
||||
@@ -0,0 +1,22 @@
|
||||
+package me.earthme.luminol.config.modules.optimizations;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class ProjectileChunkReduceConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "max-loads-per-tick")
|
||||
+ 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 a6bcf7b57b804af74f75c0b24ff48ee2714c3b73..7ccd7d6dc61948210ecb9c3acee8f1740e389106 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
@@ -58,6 +58,40 @@ public abstract class Projectile extends Entity implements TraceableEntity {
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
+ // Pufferfish start
|
||||
+ private static final java.lang.ThreadLocal<Long> loadedThisTick = java.lang.ThreadLocal.withInitial(() -> 0L);
|
||||
+ private static final java.lang.ThreadLocal<Long> loadedTick = java.lang.ThreadLocal.withInitial(() -> 0L);
|
||||
+
|
||||
+ private int loadedLifetime = 0;
|
||||
+ @Override
|
||||
+ public void setPos(double x, double y, double z) {
|
||||
+ if (io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegion() != null && ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(this)){
|
||||
+ long currentTick = io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegion().getData().getCurrentTick();
|
||||
+
|
||||
+ if (loadedTick.get() != currentTick) {
|
||||
+ loadedTick.set(currentTick);
|
||||
+ loadedThisTick.set(0L);
|
||||
+ }
|
||||
+
|
||||
+ int previousX = Mth.floor(this.getX()) >> 4, previousZ = Mth.floor(this.getZ()) >> 4;
|
||||
+ int newX = Mth.floor(x) >> 4, newZ = Mth.floor(z) >> 4;
|
||||
+ if ((previousX != newX || previousZ != newZ) && ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(this.level(), newX, newZ)) {
|
||||
+ boolean isLoaded = ((net.minecraft.server.level.ServerChunkCache) this.level().getChunkSource()).getChunkAtIfCachedImmediately(newX, newZ) != null;
|
||||
+ if (!isLoaded) {
|
||||
+ if (Projectile.loadedThisTick.get() > me.earthme.luminol.config.modules.optimizations.ProjectileChunkReduceConfig.maxProjectileLoadsPerTick) {
|
||||
+ if (++this.loadedLifetime > me.earthme.luminol.config.modules.optimizations.ProjectileChunkReduceConfig.maxProjectileLoadsPerProjectile) {
|
||||
+ this.discard();
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ Projectile.loadedThisTick.set(Projectile.loadedThisTick.get() + 1);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ super.setPos(x, y, z);
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
+
|
||||
public void setOwner(@Nullable Entity entity) {
|
||||
if (entity != null) {
|
||||
this.ownerUUID = entity.getUUID();
|
||||
@@ -1,50 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 20:25:38 +0800
|
||||
Subject: [PATCH] Kaiiju Vanilla end portal teleportation
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 6f3e87661c3181b6537e4d6d96e50d8d5680c040..3a5c8f1f9a8173777b00d43c15e8e313526d3e28 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 {
|
||||
targetPos, 16, // load 16 blocks to be safe from block physics
|
||||
ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.HIGH,
|
||||
(chunks) -> {
|
||||
- ServerLevel.makeObsidianPlatform(destination, null, targetPos);
|
||||
+ //ServerLevel.makeObsidianPlatform(destination, null, targetPos); // Kaiiju - Vanilla end teleportation - moved down
|
||||
|
||||
+ // Kaiiju start - Vanilla end teleportation
|
||||
+ Vec3 finalPos;
|
||||
+ if (this instanceof Player) finalPos = Vec3.atBottomCenterOf(targetPos.below());
|
||||
+ else finalPos = Vec3.atBottomCenterOf(targetPos);
|
||||
+ // Kaiiju end
|
||||
// the portal obsidian is placed at targetPos.y - 2, so if we want to place the entity
|
||||
// on the obsidian, we need to spawn at targetPos.y - 1
|
||||
portalInfoCompletable.complete(
|
||||
- new PortalInfo(Vec3.atBottomCenterOf(targetPos.below()), Vec3.ZERO, 90.0f, 0.0f, destination, null)
|
||||
+ new PortalInfo(finalPos, this.getDeltaMovement(), 90.0f, 0.0f, destination, null) // Kaiiju - Vanilla end teleportation
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -4300,6 +4305,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
if (!this.canPortalAsync(takePassengers)) {
|
||||
return false;
|
||||
}
|
||||
+ // Kaiiju start - sync end platform spawning & entity teleportation
|
||||
+ final java.util.function.Consumer<Entity> tpComplete = type == PortalType.END && destination.getTypeKey() == LevelStem.END ?
|
||||
+ e -> ServerLevel.makeObsidianPlatform(destination, null, ServerLevel.END_SPAWN_POINT) : teleportComplete;
|
||||
+ // Kaiiju end
|
||||
|
||||
Vec3 initialPosition = this.position();
|
||||
ChunkPos initialPositionChunk = new ChunkPos(
|
||||
@@ -4358,7 +4367,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
// place
|
||||
passengerTree.root.placeInAsync(
|
||||
originWorld, destination, Entity.TELEPORT_FLAG_LOAD_CHUNK | (takePassengers ? Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS : 0L),
|
||||
- passengerTree, teleportComplete
|
||||
+ passengerTree, tpComplete // Kaiiju - vanilla end teleportation
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,25 +1,14 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 16:15:28 +0800
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sat, 30 Nov 2024 11:59:05 +0800
|
||||
Subject: [PATCH] Pufferfish Only check for spooky season once an hour
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ambient/Bat.java b/src/main/java/net/minecraft/world/entity/ambient/Bat.java
|
||||
index 5beaa849a250ea005733250ad3edfa8382224667..2028ae6cc50d86c579ec062536e8c6339196ce09 100644
|
||||
index 60c2868f255d372226e0c1389caaa5477bbef41e..4f2993214f1789251742fe106bc7acad5b37440b 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 {
|
||||
@@ -242,13 +242,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()) {
|
||||
83
patches/server/0037-Pufferfish-Optimize-suffocation.patch
Normal file
83
patches/server/0037-Pufferfish-Optimize-suffocation.patch
Normal file
@@ -0,0 +1,83 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sat, 30 Nov 2024 12:05:17 +0800
|
||||
Subject: [PATCH] Pufferfish Optimize suffocation
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/SuffocationOptimizationConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/SuffocationOptimizationConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..3e48cd297b4869e5c89b6abc43c726d3a7511e7f
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/SuffocationOptimizationConfig.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.earthme.luminol.config.modules.optimizations;
|
||||
+
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+
|
||||
+public class SuffocationOptimizationConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.OPTIMIZATIONS;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "suffocation_optimization";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index dcdc5ca699832b3c26b33a27f684a4c7dea103b9..f537fd0a6bf689b5804924950d1b7acf51664f33 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -480,7 +480,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
|
||||
if (world1 instanceof ServerLevel) {
|
||||
worldserver1 = (ServerLevel) world1;
|
||||
- if (this.isInWall()) {
|
||||
+ if (shouldCheckForSuffocation() && this.isInWall()) { // Pufferfish - optimize suffocation
|
||||
this.hurtServer(worldserver1, this.damageSources().inWall(), 1.0F);
|
||||
} else if (flag && !this.level().getWorldBorder().isWithinBounds(this.getBoundingBox())) {
|
||||
double d1 = this.level().getWorldBorder().getDistanceToBorder(this) + this.level().getWorldBorder().getDamageSafeZone();
|
||||
@@ -1456,6 +1456,19 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
return this.getHealth() <= 0.0F;
|
||||
}
|
||||
|
||||
+ // Pufferfish start - optimize suffocation
|
||||
+ public boolean couldPossiblyBeHurt(float amount) {
|
||||
+ if ((float) this.invulnerableTime > (float) this.invulnerableDuration / 2.0F && amount <= this.lastHurt) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ public boolean shouldCheckForSuffocation() {
|
||||
+ return !me.earthme.luminol.config.modules.optimizations.SuffocationOptimizationConfig.enabled || (tickCount % 10 == 0 && couldPossiblyBeHurt(1.0F));
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
+
|
||||
@Override
|
||||
public boolean hurtServer(ServerLevel world, DamageSource source, float amount) {
|
||||
if (this.isInvulnerableTo(world, 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 bd9e10f79eaf0d23908229b3ebc2227946a14843..2ce65ef77e4b28e1fd5ac7bd6a304cc115b8aca2 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
@@ -151,6 +151,13 @@ public class WitherBoss extends Monster implements RangedAttackMob {
|
||||
this.bossEvent.setName(this.getDisplayName());
|
||||
}
|
||||
|
||||
+ // Pufferfish start - optimize suffocation
|
||||
+ @Override
|
||||
+ public boolean shouldCheckForSuffocation() {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
+
|
||||
@Override
|
||||
protected SoundEvent getAmbientSound() {
|
||||
return SoundEvents.WITHER_AMBIENT;
|
||||
@@ -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
|
||||
384
patches/server/0038-Pufferfish-Dynamic-Activation-of-Brain.patch
Normal file
384
patches/server/0038-Pufferfish-Dynamic-Activation-of-Brain.patch
Normal file
@@ -0,0 +1,384 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 4 Dec 2024 23:49:02 +0800
|
||||
Subject: [PATCH] Pufferfish Dynamic Activation of Brain
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/EntityDABConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/EntityDABConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..af5893ba1f738ec9827d7b714682c314229292d9
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/EntityDABConfig.java
|
||||
@@ -0,0 +1,60 @@
|
||||
+package me.earthme.luminol.config.modules.optimizations;
|
||||
+
|
||||
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.DoNotLoad;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.world.entity.EntityType;
|
||||
+import java.util.Collections;
|
||||
+import java.util.List;
|
||||
+
|
||||
+public class EntityDABConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean dearEnabled = false;
|
||||
+ @ConfigInfo(baseName = "start_distance",comments =
|
||||
+ "This value determines how far away an entity has to be\n" +
|
||||
+ " from the player to start being effected by DEAR."
|
||||
+ )
|
||||
+ public static int startDistance = 12;
|
||||
+ @DoNotLoad
|
||||
+ public static int startDistanceSquared;
|
||||
+ @ConfigInfo(baseName = "max-tick-freq",comments =
|
||||
+ "This value defines how often in ticks, the furthest entity\n"+
|
||||
+ "will get their pathfinders and behaviors ticked. 20 = 1s")
|
||||
+ public static int maximumActivationPrio = 20;
|
||||
+ @ConfigInfo(baseName = "activation-dist-mod",comments =
|
||||
+ """
|
||||
+ This value defines how much distance modifies an entity's
|
||||
+ tick frequency. freq = (distanceToPlayer^2) / (2^value)
|
||||
+ If you want further away entities to tick less often, use 7.
|
||||
+ If you want further away entities to tick more often, try 9.""")
|
||||
+ public static int activationDistanceMod;
|
||||
+ @ConfigInfo(baseName = "blacklisted-entities")
|
||||
+ public static List<String> blackedEntities = Collections.emptyList();
|
||||
+
|
||||
+ @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
|
||||
+ }
|
||||
+
|
||||
+ blackedEntities.forEach(name -> EntityType.byString(name).ifPresentOrElse(entityType -> {
|
||||
+ entityType.dabEnabled = false;
|
||||
+ }, () -> MinecraftServer.LOGGER.warn("Unknown entity \"" + name + "\"")));
|
||||
+
|
||||
+ config.setComment("optimizations.dab", "Optimizes entity brains when\n" + "they're far away from the player");
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 5503d506c595296ecad09a3ce4497a365f216af5..98aef7a3cfc759e4415df3a56b5fe01eb50b0428 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -816,6 +816,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
} finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ACTIVATE_ENTITIES); } // Folia - profiler
|
||||
profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_TICK); try { // Folia - profiler
|
||||
regionizedWorldData.forEachTickingEntity((entity) -> { // Folia - regionised ticking
|
||||
+ entity.activatedPriorityReset = false; // Pufferfish - DAB
|
||||
if (!entity.isRemoved()) {
|
||||
if (!tickratemanager.isEntityFrozen(entity)) {
|
||||
gameprofilerfiller.push("checkDespawn");
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 64e081f993c2c844f83af227380b8a957eaabad4..15cbbd8c660b8544bd39c8f4ebe8e44922fe81b1 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -390,6 +390,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
public boolean freezeLocked = false; // Paper - Freeze Tick Lock API
|
||||
public boolean fixedPose = false; // Paper - Expand Pose API
|
||||
private final int despawnTime; // Paper - entity despawn time limit
|
||||
+ public boolean activatedPriorityReset = false; // Pufferfish - DAB
|
||||
+ public int activatedPriority = me.earthme.luminol.config.modules.optimizations.EntityDABConfig.maximumActivationPrio; // Pufferfish - DAB (golf score)
|
||||
|
||||
public void setOrigin(@javax.annotation.Nonnull Location location) {
|
||||
this.origin = location.toVector();
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
index 635c9c7a8c8307c2bc845a8e1f24aacb526a3c92..c824e8a540dccffd848ae0a0624ce034b78f7db6 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
@@ -385,6 +385,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
|
||||
private final int clientTrackingRange;
|
||||
private final int updateInterval;
|
||||
private final String descriptionId;
|
||||
+ public boolean dabEnabled = false; // Pufferfish
|
||||
@Nullable
|
||||
private Component description;
|
||||
private final Optional<ResourceKey<LootTable>> lootTable;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index 6b66d73daa0145829cd964403e7958335ef0aa9a..80756e96faed0e0ca239f58f63522b9f15822c07 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -235,10 +235,10 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
super.inactiveTick();
|
||||
- if (this.goalSelector.inactiveTick()) {
|
||||
+ if (this.goalSelector.inactiveTick(this.activatedPriority, true)) { // Pufferfish - pass activated priroity
|
||||
this.goalSelector.tick();
|
||||
}
|
||||
- if (this.targetSelector.inactiveTick()) {
|
||||
+ if (this.targetSelector.inactiveTick(this.activatedPriority, true)) { // Pufferfish - pass activated priority
|
||||
this.targetSelector.tick();
|
||||
}
|
||||
}
|
||||
@@ -939,16 +939,20 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
|
||||
if (i % 2 != 0 && this.tickCount > 1) {
|
||||
gameprofilerfiller.push("targetSelector");
|
||||
+ if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
||||
this.targetSelector.tickRunningGoals(false);
|
||||
gameprofilerfiller.pop();
|
||||
gameprofilerfiller.push("goalSelector");
|
||||
+ if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
||||
this.goalSelector.tickRunningGoals(false);
|
||||
gameprofilerfiller.pop();
|
||||
} else {
|
||||
gameprofilerfiller.push("targetSelector");
|
||||
+ if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
||||
this.targetSelector.tick();
|
||||
gameprofilerfiller.pop();
|
||||
gameprofilerfiller.push("goalSelector");
|
||||
+ if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
||||
this.goalSelector.tick();
|
||||
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 29ae74339a4831ccef3d01e8054931715ba192ad..dd08eb5d44de5a482df538bca18a2255bb93a81f 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
|
||||
@@ -38,9 +38,12 @@ public class GoalSelector {
|
||||
}
|
||||
|
||||
// Paper start - EAR 2
|
||||
- public boolean inactiveTick() {
|
||||
+ public boolean inactiveTick(int tickRate, boolean inactive) { // Pufferfish start
|
||||
+ if (inactive && !me.earthme.luminol.config.modules.optimizations.EntityDABConfig.dearEnabled) tickRate = 4; // reset to Paper's
|
||||
+ tickRate = Math.min(tickRate, 3);
|
||||
this.curRate++;
|
||||
- return this.curRate % 3 == 0; // TODO newGoalRate was already unused in 1.20.4, check if this is correct
|
||||
+ return this.curRate % tickRate == 0; // TODO newGoalRate was already unused in 1.20.4, check if this is correct
|
||||
+ // Pufferfish end
|
||||
}
|
||||
public boolean hasTasks() {
|
||||
for (WrappedGoal task : this.availableGoals) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java
|
||||
index b86f638390d386c838318a4d9b6571ac5514df8f..f4788104b1bb73810fdf0dc7f5311d5b078a81d5 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
|
||||
@@ -223,11 +223,13 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS
|
||||
return 0.4F;
|
||||
}
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel world) {
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
gameprofilerfiller.push("allayBrain");
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick(world, this);
|
||||
gameprofilerfiller.pop();
|
||||
gameprofilerfiller.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 31b10cd404b672d7ce21c2107d8f83e32de26ef4..cb47876a13cb1990bb0ab4cff1bbe57b3b2d0a5e 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
|
||||
@@ -292,11 +292,13 @@ public class Axolotl extends Animal implements VariantHolder<Axolotl.Variant>, B
|
||||
return true;
|
||||
}
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel world) {
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
gameprofilerfiller.push("axolotlBrain");
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick(world, this);
|
||||
gameprofilerfiller.pop();
|
||||
gameprofilerfiller.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 ca04e5d829331551a2c2f44e223ff05c6ce04e76..db91b8018591fe248efda417fcde7fd2071c4cb6 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
|
||||
@@ -184,10 +184,12 @@ public class Frog extends Animal implements VariantHolder<Holder<FrogVariant>> {
|
||||
.ifPresent(this::setVariant);
|
||||
}
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel world) {
|
||||
ProfilerFiller profilerFiller = Profiler.get();
|
||||
profilerFiller.push("frogBrain");
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick(world, this);
|
||||
profilerFiller.pop();
|
||||
profilerFiller.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 48ac8c3f6e00c3c2dc67b6c994be7c0ac6dfcf81..cf326ef35bac732e7addf75537963593d5b268ae 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
|
||||
@@ -83,11 +83,13 @@ public class Tadpole extends AbstractFish {
|
||||
return SoundEvents.TADPOLE_FLOP;
|
||||
}
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel world) {
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
gameprofilerfiller.push("tadpoleBrain");
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick(world, this);
|
||||
gameprofilerfiller.pop();
|
||||
gameprofilerfiller.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 76aca47d8638d5c37c57d3a59fa7f8ceaa5a53b4..fb92cd4b0c15b614c0c06d2867039aee1a6212a2 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
|
||||
@@ -192,11 +192,13 @@ public class Goat extends Animal {
|
||||
return (Brain<Goat>) super.getBrain(); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel world) {
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
gameprofilerfiller.push("goatBrain");
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick(world, this);
|
||||
gameprofilerfiller.pop();
|
||||
gameprofilerfiller.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 92270912ef26924f611a1df7cb3d5b485b0a262d..9c20651b74157582e60793ceba8adde2c354f2a8 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
|
||||
@@ -138,11 +138,13 @@ public class Hoglin extends Animal implements Enemy, HoglinBase {
|
||||
return (Brain<Hoglin>) super.getBrain(); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
+ private int behaviorTick; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel world) {
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
gameprofilerfiller.push("hoglinBrain");
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick(world, this);
|
||||
gameprofilerfiller.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 2121d2a2e1aa1d0f0390cc515317096431f6dcb0..74ab50723056fef2a96dcc9e2de0e58526738011 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
|
||||
@@ -307,11 +307,13 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento
|
||||
return !this.cannotHunt;
|
||||
}
|
||||
|
||||
+ private int behaviorTick; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel world) {
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
gameprofilerfiller.push("piglinBrain");
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick(world, this);
|
||||
gameprofilerfiller.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 c47ed605f0822effd58df4f875297ed015e1e57e..4331ada8bed7ade7b53fd8ba000c1c1b34fa4331 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
|
||||
@@ -275,11 +275,13 @@ public class Warden extends Monster implements VibrationSystem {
|
||||
|
||||
}
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel world) {
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
gameprofilerfiller.push("wardenBrain");
|
||||
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
||||
this.getBrain().tick(world, this);
|
||||
gameprofilerfiller.pop();
|
||||
super.customServerAiStep(world);
|
||||
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 07f50048e9748b28178847ad470b8b2ce37e0eea..8fbf0df15716940622144fb2d4423f74264580f7 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
|
||||
return holder.is(PoiTypes.MEETING);
|
||||
});
|
||||
|
||||
+ public long nextGolemPanic = -1; // Pufferfish
|
||||
+
|
||||
public Villager(EntityType<? extends Villager> entityType, Level world) {
|
||||
this(entityType, world, VillagerType.PLAINS);
|
||||
}
|
||||
@@ -245,6 +247,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
}
|
||||
// Spigot End
|
||||
|
||||
+ private int behaviorTick = 0; // Pufferfish
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel world) {
|
||||
// Paper start - EAR 2
|
||||
@@ -255,7 +258,11 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
gameprofilerfiller.push("villagerBrain");
|
||||
- if (!inactive) this.getBrain().tick(world, this);
|
||||
+ // Pufferfish start
|
||||
+ if (!inactive && this.behaviorTick++ % this.activatedPriority == 0) {
|
||||
+ this.getBrain().tick((ServerLevel) this.level(), this); // Paper
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
gameprofilerfiller.pop();
|
||||
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 cbe785f5fab22630e8a80519664791e2ac621b9f..820145408fa2150820c4c14ea55bee23e7e9a366 100644
|
||||
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
||||
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
@@ -37,6 +37,10 @@ import net.minecraft.world.entity.projectile.ThrownTrident;
|
||||
import net.minecraft.world.entity.raid.Raider;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
+// Pufferfish start
|
||||
+import net.minecraft.world.phys.Vec3;
|
||||
+import java.util.List;
|
||||
+// Pufferfish end
|
||||
|
||||
public class ActivationRange
|
||||
{
|
||||
@@ -230,6 +234,25 @@ public class ActivationRange
|
||||
}
|
||||
// Paper end - Configurable marker ticking
|
||||
ActivationRange.activateEntity(entity, bbByType); // Folia - threaded regions
|
||||
+
|
||||
+ // Pufferfish start
|
||||
+ if (me.earthme.luminol.config.modules.optimizations.EntityDABConfig.dearEnabled && entity.getType().dabEnabled) {
|
||||
+ if (!entity.activatedPriorityReset) {
|
||||
+ entity.activatedPriorityReset = true;
|
||||
+ 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 > 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;
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
+
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
@@ -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,51 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 4 Dec 2024 23:50:22 +0800
|
||||
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 80756e96faed0e0ca239f58f63522b9f15822c07..4e587a5c59eb271ed31c5584bd665953ae82aa8a 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -231,11 +231,13 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
return this.lookControl;
|
||||
}
|
||||
|
||||
+ int _pufferfish_inactiveTickDisableCounter = 0; // Pufferfish - throttle inactive goal selector ticking
|
||||
// Paper start
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
super.inactiveTick();
|
||||
- if (this.goalSelector.inactiveTick(this.activatedPriority, true)) { // Pufferfish - pass activated priroity
|
||||
+ boolean isThrottled = 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
|
||||
File diff suppressed because it is too large
Load Diff
84
patches/server/0040-Pufferfish-SIMD-Utilities.patch
Normal file
84
patches/server/0040-Pufferfish-SIMD-Utilities.patch
Normal file
@@ -0,0 +1,84 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 4 Dec 2024 23:51:17 +0800
|
||||
Subject: [PATCH] Pufferfish SIMD Utilities
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 4b79f96103c98896332113ffe5f0e22cf08ffdd1..fbf51f738e98ac6e8358a7fa81b7fc545469a5a6 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -94,6 +94,14 @@ paperweight {
|
||||
craftBukkitPackageVersion.set("v1_21_R3") // also needs to be updated in MappingEnvironment
|
||||
}
|
||||
|
||||
+
|
||||
+// Pufferfish Start
|
||||
+tasks.withType<JavaCompile> {
|
||||
+ val compilerArgs = options.compilerArgs
|
||||
+ compilerArgs.add("--add-modules=jdk.incubator.vector")
|
||||
+}
|
||||
+// Pufferfish End
|
||||
+
|
||||
tasks.jar {
|
||||
archiveClassifier.set("dev")
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/SIMDConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/SIMDConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..76cea165bcef0794a66ef7c29721f7716869420f
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/SIMDConfig.java
|
||||
@@ -0,0 +1,53 @@
|
||||
+package me.earthme.luminol.config.modules.optimizations;
|
||||
+
|
||||
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import com.mojang.logging.LogUtils;
|
||||
+import gg.pufferfish.pufferfish.simd.SIMDDetection;
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.DoNotLoad;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+import org.slf4j.Logger;
|
||||
+
|
||||
+public class SIMDConfig implements IConfigModule {
|
||||
+ @DoNotLoad
|
||||
+ private static final Logger LOGGER = LogUtils.getLogger();
|
||||
+ @ConfigInfo(baseName = "enabled")
|
||||
+ public static boolean enabled = true;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.OPTIMIZATIONS;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "use_simd";
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onLoaded(CommentedFileConfig configInstance) {
|
||||
+ if (!enabled){
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // Attempt to detect vectorization
|
||||
+ try {
|
||||
+ SIMDDetection.isEnabled = SIMDDetection.canEnable(LOGGER);
|
||||
+ SIMDDetection.versionLimited = SIMDDetection.getJavaVersion() < 17;
|
||||
+ } catch (NoClassDefFoundError | Exception ignored) {
|
||||
+ ignored.printStackTrace();
|
||||
+ }
|
||||
+
|
||||
+ if (SIMDDetection.isEnabled) {
|
||||
+ LOGGER.info("SIMD operations detected as functional. Will replace some operations with faster versions.");
|
||||
+ } else if (SIMDDetection.versionLimited) {
|
||||
+ LOGGER.warn("Will not enable SIMD! These optimizations are only safely supported on Java 17+.");
|
||||
+ } else {
|
||||
+ LOGGER.warn("SIMD operations are available for your server, but are not configured!");
|
||||
+ LOGGER.warn("To enable additional optimizations, add \"--add-modules=jdk.incubator.vector\" to your startup flags, BEFORE the \"-jar\".");
|
||||
+ LOGGER.warn("If you have already added this flag, then SIMD operations are not supported on your JVM or CPU.");
|
||||
+ LOGGER.warn("Debug: Java: {}, test run: {}", System.getProperty("java.version"), SIMDDetection.testRun);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
@@ -1,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
|
||||
249
patches/server/0041-Pufferfish-Sentry.patch
Normal file
249
patches/server/0041-Pufferfish-Sentry.patch
Normal file
@@ -0,0 +1,249 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: adabugra <57899270+adabugra@users.noreply.github.com>
|
||||
Date: Mon, 6 Jan 2025 19:24:05 +0300
|
||||
Subject: [PATCH] Pufferfish: Sentry
|
||||
|
||||
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/sentry/PufferfishSentryAppender.java b/src/main/java/gg/pufferfish/pufferfish/sentry/PufferfishSentryAppender.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..2b830cb288ceba390ed39cd33fc1ee855357a97e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/sentry/PufferfishSentryAppender.java
|
||||
@@ -0,0 +1,133 @@
|
||||
+package gg.pufferfish.pufferfish.sentry;
|
||||
+
|
||||
+import com.google.common.reflect.TypeToken;
|
||||
+import com.google.gson.Gson;
|
||||
+import io.sentry.Breadcrumb;
|
||||
+import io.sentry.Sentry;
|
||||
+import io.sentry.SentryEvent;
|
||||
+import io.sentry.SentryLevel;
|
||||
+import io.sentry.protocol.Message;
|
||||
+import io.sentry.protocol.User;
|
||||
+
|
||||
+import java.util.Map;
|
||||
+
|
||||
+import me.earthme.luminol.config.modules.misc.SentryConfig;
|
||||
+import org.apache.logging.log4j.Level;
|
||||
+import org.apache.logging.log4j.LogManager;
|
||||
+import org.apache.logging.log4j.Marker;
|
||||
+import org.apache.logging.log4j.core.LogEvent;
|
||||
+import org.apache.logging.log4j.core.Logger;
|
||||
+import org.apache.logging.log4j.core.appender.AbstractAppender;
|
||||
+import org.apache.logging.log4j.core.filter.AbstractFilter;
|
||||
+
|
||||
+public class PufferfishSentryAppender extends AbstractAppender {
|
||||
+
|
||||
+ private static final org.apache.logging.log4j.Logger logger = LogManager.getLogger(PufferfishSentryAppender.class.getSimpleName());
|
||||
+ private static final Gson GSON = new Gson();
|
||||
+ private final Level logLevel;
|
||||
+
|
||||
+ public PufferfishSentryAppender(Level logLevel) {
|
||||
+ super("PufferfishSentryAdapter", new SentryFilter(), null);
|
||||
+ this.logLevel = logLevel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void append(LogEvent logEvent) {
|
||||
+ if (logEvent.getLevel().isMoreSpecificThan(logLevel) && (logEvent.getThrown() != null || !SentryConfig.onlyLogThrown)) {
|
||||
+ try {
|
||||
+ logException(logEvent);
|
||||
+ } catch (Exception e) {
|
||||
+ logger.warn("Failed to log event with sentry", e);
|
||||
+ }
|
||||
+ } else {
|
||||
+ try {
|
||||
+ logBreadcrumb(logEvent);
|
||||
+ } catch (Exception e) {
|
||||
+ logger.warn("Failed to log event with sentry", e);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void logException(LogEvent e) {
|
||||
+ SentryEvent event = new SentryEvent(e.getThrown());
|
||||
+
|
||||
+ Message sentryMessage = new Message();
|
||||
+ sentryMessage.setMessage(e.getMessage().getFormattedMessage());
|
||||
+
|
||||
+ event.setThrowable(e.getThrown());
|
||||
+ event.setLevel(getLevel(e.getLevel()));
|
||||
+ event.setLogger(e.getLoggerName());
|
||||
+ event.setTransaction(e.getLoggerName());
|
||||
+ event.setExtra("thread_name", e.getThreadName());
|
||||
+
|
||||
+ boolean hasContext = e.getContextData() != null;
|
||||
+
|
||||
+ if (hasContext && e.getContextData().containsKey("pufferfishsentry_playerid")) {
|
||||
+ User user = new User();
|
||||
+ user.setId(e.getContextData().getValue("pufferfishsentry_playerid"));
|
||||
+ user.setUsername(e.getContextData().getValue("pufferfishsentry_playername"));
|
||||
+ event.setUser(user);
|
||||
+ }
|
||||
+
|
||||
+ if (hasContext && e.getContextData().containsKey("pufferfishsentry_pluginname")) {
|
||||
+ event.setExtra("plugin.name", e.getContextData().getValue("pufferfishsentry_pluginname"));
|
||||
+ event.setExtra("plugin.version", e.getContextData().getValue("pufferfishsentry_pluginversion"));
|
||||
+ event.setTransaction(e.getContextData().getValue("pufferfishsentry_pluginname"));
|
||||
+ }
|
||||
+
|
||||
+ if (hasContext && e.getContextData().containsKey("pufferfishsentry_eventdata")) {
|
||||
+ Map<String, String> eventFields = GSON.fromJson((String) e.getContextData().getValue("pufferfishsentry_eventdata"), new TypeToken<Map<String, String>>() {
|
||||
+ }.getType());
|
||||
+ if (eventFields != null) {
|
||||
+ event.setExtra("event", eventFields);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ Sentry.captureEvent(event);
|
||||
+ }
|
||||
+
|
||||
+ private void logBreadcrumb(LogEvent e) {
|
||||
+ Breadcrumb breadcrumb = new Breadcrumb();
|
||||
+
|
||||
+ breadcrumb.setLevel(getLevel(e.getLevel()));
|
||||
+ breadcrumb.setCategory(e.getLoggerName());
|
||||
+ breadcrumb.setType(e.getLoggerName());
|
||||
+ breadcrumb.setMessage(e.getMessage().getFormattedMessage());
|
||||
+
|
||||
+ Sentry.addBreadcrumb(breadcrumb);
|
||||
+ }
|
||||
+
|
||||
+ private SentryLevel getLevel(Level level) {
|
||||
+ return switch (level.getStandardLevel()) {
|
||||
+ case TRACE, DEBUG -> SentryLevel.DEBUG;
|
||||
+ case WARN -> SentryLevel.WARNING;
|
||||
+ case ERROR -> SentryLevel.ERROR;
|
||||
+ case FATAL -> SentryLevel.FATAL;
|
||||
+ default -> SentryLevel.INFO;
|
||||
+ };
|
||||
+ }
|
||||
+
|
||||
+ private static class SentryFilter extends AbstractFilter {
|
||||
+
|
||||
+ @Override
|
||||
+ public Result filter(Logger logger, Level level, Marker marker, String msg,
|
||||
+ Object... params) {
|
||||
+ return this.filter(logger.getName());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t) {
|
||||
+ return this.filter(logger.getName());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Result filter(LogEvent event) {
|
||||
+ return this.filter(event == null ? null : event.getLoggerName());
|
||||
+ }
|
||||
+
|
||||
+ private Result filter(String loggerName) {
|
||||
+ return loggerName != null && loggerName.startsWith("gg.castaway.pufferfish.sentry") ? Result.DENY
|
||||
+ : Result.NEUTRAL;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/sentry/SentryManager.java b/src/main/java/gg/pufferfish/pufferfish/sentry/SentryManager.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..c01e5b5de685eca7edbe8a87732efd45d4dd2557
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/sentry/SentryManager.java
|
||||
@@ -0,0 +1,44 @@
|
||||
+package gg.pufferfish.pufferfish.sentry;
|
||||
+
|
||||
+import io.sentry.Sentry;
|
||||
+import org.apache.logging.log4j.Level;
|
||||
+import org.apache.logging.log4j.LogManager;
|
||||
+import org.apache.logging.log4j.Logger;
|
||||
+
|
||||
+public class SentryManager {
|
||||
+
|
||||
+ private static final Logger logger = LogManager.getLogger(SentryManager.class);
|
||||
+
|
||||
+ private SentryManager() {
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ private static boolean initialized = false;
|
||||
+
|
||||
+ public static synchronized void init(Level logLevel) {
|
||||
+ if (initialized) {
|
||||
+ return;
|
||||
+ }
|
||||
+ if (logLevel == null) {
|
||||
+ logger.error("Invalid log level, defaulting to WARN.");
|
||||
+ logLevel = Level.WARN;
|
||||
+ }
|
||||
+ try {
|
||||
+ initialized = true;
|
||||
+
|
||||
+ Sentry.init(options -> {
|
||||
+ options.setDsn(me.earthme.luminol.config.modules.misc.SentryConfig.sentryDsn);
|
||||
+ options.setMaxBreadcrumbs(100);
|
||||
+ });
|
||||
+
|
||||
+ PufferfishSentryAppender appender = new PufferfishSentryAppender(logLevel);
|
||||
+ appender.start();
|
||||
+ ((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger()).addAppender(appender);
|
||||
+ logger.info("Sentry logging started!");
|
||||
+ } catch (Exception e) {
|
||||
+ logger.warn("Failed to initialize sentry!", e);
|
||||
+ initialized = false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/SentryConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/SentryConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..55d6bb635b182d15471bfcd481a2b7c6ce26c00b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/SentryConfig.java
|
||||
@@ -0,0 +1,47 @@
|
||||
+package me.earthme.luminol.config.modules.misc;
|
||||
+
|
||||
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import me.earthme.luminol.config.ConfigInfo;
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+import org.apache.logging.log4j.Level;
|
||||
+
|
||||
+public class SentryConfig implements IConfigModule {
|
||||
+
|
||||
+ @ConfigInfo(baseName = "dsn", comments =
|
||||
+ " Sentry DSN for improved error logging, leave blank to disable,\n" +
|
||||
+ " Obtain from https://sentry.io/")
|
||||
+ public static String sentryDsn = "";
|
||||
+
|
||||
+ @ConfigInfo(baseName = "log_level", comments = " Logs with a level higher than or equal to this level will be recorded.")
|
||||
+ public static String logLevel = "WARN";
|
||||
+
|
||||
+ @ConfigInfo(baseName = "only_log_thrown", comments = " Only log with a Throwable will be recorded after enabling this.")
|
||||
+ public static boolean onlyLogThrown = true;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "sentry";
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onLoaded(CommentedFileConfig configInstance) {
|
||||
+ String sentryEnvironment = System.getenv("SENTRY_DSN");
|
||||
+
|
||||
+ sentryDsn = sentryEnvironment != null && !sentryEnvironment.isBlank()
|
||||
+ ? sentryEnvironment
|
||||
+ : configInstance.getOrElse("sentry.dsn", sentryDsn);
|
||||
+
|
||||
+ logLevel = configInstance.getOrElse("sentry.log-level", logLevel);
|
||||
+ onlyLogThrown = configInstance.getOrElse("sentry.only-log-thrown", onlyLogThrown);
|
||||
+
|
||||
+ if (sentryDsn != null && !sentryDsn.isBlank()) {
|
||||
+ gg.pufferfish.pufferfish.sentry.SentryManager.init(Level.getLevel(logLevel));
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
\ No newline at end of file
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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 <wangxyper@163.com>
|
||||
Date: Sat, 30 Nov 2024 12:07:11 +0800
|
||||
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 820145408fa2150820c4c14ea55bee23e7e9a366..57eb8bfb0e9d4a45d89eca75a2de219bff626bb5 100644
|
||||
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
||||
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
@@ -76,28 +76,40 @@ public class ActivationRange
|
||||
@@ -74,28 +74,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,23 +1,23 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 26 Nov 2023 17:21:44 +0800
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sun, 4 Aug 2024 22:14:21 +0800
|
||||
Subject: [PATCH] Gale Optimize sun burn tick
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 54daa1744c89e98136d0f594a35119d5fd3d6bc8..6f3e87661c3181b6537e4d6d96e50d8d5680c040 100644
|
||||
index 15cbbd8c660b8544bd39c8f4ebe8e44922fe81b1..ae3af52c8b6368e40e39bcd9ecd8e2cdcb0b9c5b 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 {
|
||||
@@ -274,7 +274,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
public double xo;
|
||||
public double yo;
|
||||
public double zo;
|
||||
- private Vec3 position;
|
||||
+ public Vec3 position; // Gale - JettPack - optimize sun burn tick - private -> public
|
||||
public BlockPos blockPosition; // Pufferfish - private->public
|
||||
private BlockPos blockPosition;
|
||||
private ChunkPos chunkPosition;
|
||||
private Vec3 deltaMovement;
|
||||
@@ -2026,9 +2026,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
@@ -2227,9 +2227,19 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
/** @deprecated */
|
||||
@Deprecated
|
||||
public float getLightLevelDependentMagicValue() {
|
||||
@@ -26,7 +26,9 @@ index 54daa1744c89e98136d0f594a35119d5fd3d6bc8..6f3e87661c3181b6537e4d6d96e50d8d
|
||||
}
|
||||
|
||||
+ // Gale start - JettPack - optimize sun burn tick - allow passing BlockPos to getLightLevelDependentMagicValue
|
||||
+ /** @deprecated */
|
||||
+ /**
|
||||
+ * @deprecated
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ public float getLightLevelDependentMagicValue(BlockPos pos) {
|
||||
+ return this.level().hasChunkAt(this.getBlockX(), this.getBlockZ()) ? this.level.getLightLevelDependentMagicValue(pos) : 0.0F;
|
||||
@@ -35,18 +37,18 @@ index 54daa1744c89e98136d0f594a35119d5fd3d6bc8..6f3e87661c3181b6537e4d6d96e50d8d
|
||||
+
|
||||
public void absMoveTo(double x, double y, double z, float yaw, float pitch) {
|
||||
this.absMoveTo(x, y, z);
|
||||
this.setYRot(yaw % 360.0F);
|
||||
this.absRotateTo(yaw, pitch);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index 54e821351e46d25e8b0ead52d2c8dfecd1957544..394913950ac8fbcfcdbce817bac95f3b6604beb7 100644
|
||||
index 4e587a5c59eb271ed31c5584bd665953ae82aa8a..5280e0bd88b39a2f1ca62b03ed2c54a89df4f212 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 {
|
||||
@@ -1761,13 +1761,28 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
|
||||
}
|
||||
protected void playAttackSound() {}
|
||||
|
||||
+ // Gale start - JettPack - optimize sun burn tick - cache eye blockpos
|
||||
+ private BlockPos cached_eye_blockpos;
|
||||
+ private int cached_position_hashcode;
|
||||
+ private net.minecraft.world.phys.Vec3 cached_position;
|
||||
+ // Gale end - JettPack - optimize sun burn tick - cache eye blockpos
|
||||
+
|
||||
public boolean isSunBurnTick() {
|
||||
@@ -54,10 +56,9 @@ index 54e821351e46d25e8b0ead52d2c8dfecd1957544..394913950ac8fbcfcdbce817bac95f3b
|
||||
- float f = this.getLightLevelDependentMagicValue();
|
||||
- BlockPos blockposition = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ());
|
||||
+ // Gale start - JettPack - optimize sun burn tick - optimizations and cache eye blockpos
|
||||
+ int positionHashCode = this.position.hashCode();
|
||||
+ if (this.cached_position_hashcode != positionHashCode) {
|
||||
+ if (this.cached_position != this.position) {
|
||||
+ this.cached_eye_blockpos = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ());
|
||||
+ this.cached_position_hashcode = positionHashCode;
|
||||
+ this.cached_position = this.position;
|
||||
+ }
|
||||
+
|
||||
+ float f = this.getLightLevelDependentMagicValue(cached_eye_blockpos); // Pass BlockPos to getBrightness
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user